@namzu/cli 63.2.0 → 63.3.0

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 (615) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +36 -36
  3. package/dist/bin.js +1 -1
  4. package/dist/chunks/{acp-XC6FTO64.js → acp-J3TMCBRY.js} +242 -184
  5. package/dist/chunks/acp-J3TMCBRY.js.map +6 -0
  6. package/dist/chunks/{activity-command-PIH63SRU.js → activity-command-X25POZ3R.js} +15 -15
  7. package/dist/chunks/{add-CWIB4XVU.js → add-HL4MO6R2.js} +38 -38
  8. package/dist/chunks/{agent-CNRZCXHY.js → agent-MHH4MGYB.js} +67 -65
  9. package/dist/chunks/agent-session-OC32VSS6.js +107 -0
  10. package/dist/chunks/{apply-at-exit-CMRH3GQN.js → apply-at-exit-ADWMDFFQ.js} +7 -7
  11. package/dist/chunks/{archive-DPZ3PWUU.js → archive-6X2FED3E.js} +14 -14
  12. package/dist/chunks/{auth-JAKMDE4X.js → auth-KRORFNAA.js} +64 -27
  13. package/dist/chunks/auth-KRORFNAA.js.map +6 -0
  14. package/dist/chunks/{bin-main-V6PBLHRK.js → bin-main-74KBBJNG.js} +10 -9
  15. package/dist/chunks/bin-main-74KBBJNG.js.map +6 -0
  16. package/dist/chunks/{binding-UHJZD5Z3.js → binding-OXJ5TL6T.js} +3 -3
  17. package/dist/chunks/{browser-2QBVPHCB.js → browser-DFLZNRRZ.js} +7 -7
  18. package/dist/chunks/{chat-DJEP53BA.js → chat-PPSFN5JK.js} +18 -18
  19. package/dist/chunks/{chunk-4JKWOO7I.js → chunk-23AYRMS2.js} +4 -4
  20. package/dist/chunks/{chunk-5U4IA3HS.js → chunk-2AUUX6VA.js} +19 -1
  21. package/dist/chunks/chunk-2AUUX6VA.js.map +6 -0
  22. package/dist/chunks/{chunk-MUQOV75B.js → chunk-2H75JWKG.js} +3 -3
  23. package/dist/chunks/{chunk-NEOVE6D5.js → chunk-2JKQ6BFI.js} +2 -2
  24. package/dist/chunks/{chunk-UZVJQEYT.js → chunk-2KJUKF2E.js} +6 -6
  25. package/dist/chunks/{chunk-IYBVVKSB.js → chunk-2QGSHJ4Y.js} +3 -3
  26. package/dist/chunks/{chunk-ZNSVRCPH.js → chunk-2R6Z32IU.js} +3 -3
  27. package/dist/chunks/{chunk-7FGITTVH.js → chunk-2USTJGLA.js} +5 -5
  28. package/dist/chunks/{chunk-EIIJLF6W.js → chunk-333RR5BA.js} +4 -4
  29. package/dist/chunks/{chunk-MCIYCR57.js → chunk-33TGFQ2U.js} +5 -5
  30. package/dist/chunks/{chunk-C4RV2D57.js → chunk-3FFV4OSR.js} +4 -4
  31. package/dist/chunks/{chunk-QI4IEHLE.js → chunk-3QXUETDN.js} +4 -4
  32. package/dist/chunks/{chunk-4VTRURM6.js → chunk-3TLDTD6R.js} +14 -14
  33. package/dist/chunks/{chunk-ONEBRD5O.js → chunk-4ASXGRP5.js} +3 -3
  34. package/dist/chunks/{chunk-ZFOZVUUJ.js → chunk-4JPZYI6M.js} +2 -2
  35. package/dist/chunks/{chunk-7L3PTSKY.js → chunk-4OWFI7ZE.js} +16 -9
  36. package/dist/chunks/chunk-4OWFI7ZE.js.map +6 -0
  37. package/dist/chunks/{chunk-RBJDS73T.js → chunk-4TPXEWD5.js} +3 -3
  38. package/dist/chunks/{chunk-XJ4APISC.js → chunk-4U6TAYDK.js} +65 -12
  39. package/dist/chunks/chunk-4U6TAYDK.js.map +6 -0
  40. package/dist/chunks/chunk-4VKLCPVW.js +526 -0
  41. package/dist/chunks/chunk-4VKLCPVW.js.map +6 -0
  42. package/dist/chunks/{chunk-VVMI6HQM.js → chunk-554DVVVR.js} +611 -214
  43. package/dist/chunks/chunk-554DVVVR.js.map +6 -0
  44. package/dist/chunks/{chunk-COOW2AWX.js → chunk-5GJWIDVU.js} +3 -3
  45. package/dist/chunks/{chunk-RXFFBB7A.js → chunk-5PQHBLZI.js} +3 -3
  46. package/dist/chunks/{chunk-GMUWAUKQ.js → chunk-5UARTCJW.js} +2 -2
  47. package/dist/chunks/{chunk-Q5SAOE7Q.js → chunk-5XROCBT5.js} +9 -9
  48. package/dist/chunks/{chunk-WI6IGTC4.js → chunk-5YOREQIA.js} +3 -3
  49. package/dist/chunks/{chunk-4E5KFKJA.js → chunk-6CL7TQOC.js} +5 -5
  50. package/dist/chunks/{chunk-5B4BXZCI.js → chunk-75RHEPE7.js} +36 -3
  51. package/dist/chunks/chunk-75RHEPE7.js.map +6 -0
  52. package/dist/chunks/{chunk-N5YRJQPS.js → chunk-7RCI6OBE.js} +2 -2
  53. package/dist/chunks/{chunk-SIMI4VB7.js → chunk-7WPF7ATU.js} +3 -3
  54. package/dist/chunks/{chunk-DKZAHG7B.js → chunk-AAN4XLUD.js} +4 -4
  55. package/dist/chunks/{chunk-LDJXUI3Q.js → chunk-BB2RJOFI.js} +11 -11
  56. package/dist/chunks/{chunk-KGCHR4TQ.js → chunk-BBNACUZ3.js} +1527 -676
  57. package/dist/chunks/chunk-BBNACUZ3.js.map +6 -0
  58. package/dist/chunks/{chunk-ESWXNISI.js → chunk-BCHHHNLK.js} +2 -2
  59. package/dist/chunks/{chunk-C6JX3GVK.js → chunk-BUQCQMXH.js} +3 -3
  60. package/dist/chunks/{chunk-VLWMMDBY.js → chunk-COSMRH2Q.js} +5 -5
  61. package/dist/chunks/{chunk-4VMFD7UC.js → chunk-CPZEJQ2Z.js} +4 -4
  62. package/dist/chunks/{chunk-3AKPBYMA.js → chunk-DCVWFBYB.js} +2 -2
  63. package/dist/chunks/{chunk-ADGTOEHA.js → chunk-DD3BJ4GM.js} +9 -9
  64. package/dist/chunks/{chunk-4H2RPAXN.js → chunk-DKTU6RWO.js} +5 -5
  65. package/dist/chunks/{chunk-OWKPJJKH.js → chunk-EODC62SI.js} +4 -4
  66. package/dist/chunks/{chunk-IVTYJBJF.js → chunk-EOHPS7LC.js} +7 -7
  67. package/dist/chunks/{chunk-2LZAZAWT.js → chunk-EPSLHLT3.js} +8 -8
  68. package/dist/chunks/{chunk-SHUKR2A5.js → chunk-FAQQGJ2Z.js} +3 -3
  69. package/dist/chunks/{chunk-OQFX532E.js → chunk-FJPM4YAO.js} +4 -4
  70. package/dist/chunks/{chunk-TPMF64WM.js → chunk-FZSM7DSH.js} +11 -11
  71. package/dist/chunks/{chunk-MMQGQ7BJ.js → chunk-G3V2OKYP.js} +5 -5
  72. package/dist/chunks/{chunk-6WPK5S6Z.js → chunk-G4OR74MC.js} +10 -10
  73. package/dist/chunks/{chunk-TV7UBGX2.js → chunk-GCOTJ6XY.js} +147 -3
  74. package/dist/chunks/chunk-GCOTJ6XY.js.map +6 -0
  75. package/dist/chunks/{chunk-QWUHCBDT.js → chunk-HXZA5UUN.js} +2 -2
  76. package/dist/chunks/{chunk-2AWKLDCQ.js → chunk-IDIVB67E.js} +2 -2
  77. package/dist/chunks/{chunk-IISM3GHE.js → chunk-ISI36EUS.js} +3 -3
  78. package/dist/chunks/{chunk-SNHJJI52.js → chunk-IUMOIQKL.js} +10 -10
  79. package/dist/chunks/{chunk-P5LQ4NRD.js → chunk-J4NFH5T2.js} +2 -2
  80. package/dist/chunks/{chunk-HYHHGMBC.js → chunk-J6JBHNNR.js} +2 -2
  81. package/dist/chunks/{chunk-UGBHE6ZS.js → chunk-JCY3OPTY.js} +7 -7
  82. package/dist/chunks/{chunk-S76POTJP.js → chunk-JD7EWFIJ.js} +6 -6
  83. package/dist/chunks/chunk-JKMOMRIV.js +564 -0
  84. package/dist/chunks/chunk-JKMOMRIV.js.map +6 -0
  85. package/dist/chunks/{chunk-2K7EIRI2.js → chunk-JOVKHMJS.js} +8 -8
  86. package/dist/chunks/{chunk-GOKGPFXK.js → chunk-JQ7HNIBS.js} +6 -6
  87. package/dist/chunks/{chunk-I3HOLAAO.js → chunk-JSWFUARY.js} +3 -3
  88. package/dist/chunks/{chunk-NTUKFINL.js → chunk-JU3P3ZJJ.js} +3 -3
  89. package/dist/chunks/{chunk-ZLMO5YL4.js → chunk-JWBS363M.js} +2 -2
  90. package/dist/chunks/{chunk-HZGT5EHL.js → chunk-JXBSJNUF.js} +2 -2
  91. package/dist/chunks/{chunk-X6LDRLVN.js → chunk-JZTNWODR.js} +8 -8
  92. package/dist/chunks/{chunk-HJHZJKAD.js → chunk-K4AUROOC.js} +2 -2
  93. package/dist/chunks/{chunk-RL2CTUF2.js → chunk-KFFW7EYQ.js} +2 -2
  94. package/dist/chunks/{chunk-SEW4KEZ5.js → chunk-KGKVNHFC.js} +4 -4
  95. package/dist/chunks/{chunk-SOZSIDCY.js → chunk-KLIJLSWF.js} +2 -2
  96. package/dist/chunks/{chunk-ZZ7A2Y7O.js → chunk-LA6FHUOG.js} +4 -2
  97. package/dist/chunks/chunk-LA6FHUOG.js.map +6 -0
  98. package/dist/chunks/{chunk-BS3KGJJZ.js → chunk-LJFDFGFU.js} +8 -8
  99. package/dist/chunks/{chunk-O3T5CJQG.js → chunk-LZPPIRJW.js} +4 -4
  100. package/dist/chunks/{chunk-H624ADJH.js → chunk-MHEYQD24.js} +2 -2
  101. package/dist/chunks/{chunk-44KWXPBG.js → chunk-MM7HGD6H.js} +2 -2
  102. package/dist/chunks/{chunk-C56FUSQH.js → chunk-N4KE47J2.js} +2 -2
  103. package/dist/chunks/{chunk-QNRBLNA3.js → chunk-N4USZWBA.js} +3 -3
  104. package/dist/chunks/{chunk-GCLZEMDF.js → chunk-OIFFABSH.js} +4 -4
  105. package/dist/chunks/{chunk-NRR2SMR6.js → chunk-OKFU62GA.js} +3 -3
  106. package/dist/chunks/{chunk-G6YSAHKC.js → chunk-OWPDRJ6S.js} +2 -2
  107. package/dist/chunks/{chunk-LCZWTKIB.js → chunk-P4WMRT5Q.js} +2 -2
  108. package/dist/chunks/{chunk-EHKWQ7IS.js → chunk-PGHGBSS2.js} +2 -2
  109. package/dist/chunks/{chunk-OA76OH27.js → chunk-PLPVXHTM.js} +21 -21
  110. package/dist/chunks/{chunk-KE2RFCTY.js → chunk-PMA5NXWF.js} +6 -6
  111. package/dist/chunks/{chunk-VBG357AO.js → chunk-PP7AG46K.js} +293 -105
  112. package/dist/chunks/chunk-PP7AG46K.js.map +6 -0
  113. package/dist/chunks/{chunk-5RA5FZDM.js → chunk-PSRWFKFX.js} +2 -2
  114. package/dist/chunks/{chunk-NXFB5AP5.js → chunk-PTUICVCN.js} +5 -5
  115. package/dist/chunks/{chunk-YOPTDWON.js → chunk-Q23JN3PA.js} +3 -2
  116. package/dist/chunks/{chunk-YOPTDWON.js.map → chunk-Q23JN3PA.js.map} +1 -1
  117. package/dist/chunks/{chunk-ZIF4GK2U.js → chunk-Q5THGA3N.js} +2 -2
  118. package/dist/chunks/{chunk-AUDTDXWX.js → chunk-Q6NWIY5D.js} +35 -15
  119. package/dist/chunks/chunk-Q6NWIY5D.js.map +6 -0
  120. package/dist/chunks/{chunk-5SRVOPRS.js → chunk-QTR6UU63.js} +2 -2
  121. package/dist/chunks/{chunk-2YPRONTU.js → chunk-RBRBYXJX.js} +259 -103
  122. package/dist/chunks/chunk-RBRBYXJX.js.map +6 -0
  123. package/dist/chunks/{chunk-7BNKRTXM.js → chunk-RIVPA5TG.js} +5 -5
  124. package/dist/chunks/{chunk-HPUVBU7G.js → chunk-RQYSVELQ.js} +2 -2
  125. package/dist/chunks/{chunk-RKAZUYKY.js → chunk-RWSHMPFM.js} +2 -2
  126. package/dist/chunks/{chunk-CQNIP7QC.js → chunk-RZ3HYPV4.js} +6 -6
  127. package/dist/chunks/{chunk-3OHJYUFP.js → chunk-SCGWXYZW.js} +84 -37
  128. package/dist/chunks/chunk-SCGWXYZW.js.map +6 -0
  129. package/dist/chunks/{chunk-AFYS4U45.js → chunk-SDWOSB3L.js} +2 -2
  130. package/dist/chunks/{chunk-AT42FHTY.js → chunk-SPKNKEW5.js} +4 -4
  131. package/dist/chunks/{chunk-UUMISHVL.js → chunk-SQDZZCQJ.js} +2 -2
  132. package/dist/chunks/{chunk-KFB4RMNZ.js → chunk-SRNS347K.js} +2 -2
  133. package/dist/chunks/{chunk-GUOCXE6V.js → chunk-SX7FXWTB.js} +3 -3
  134. package/dist/chunks/{chunk-HS7PPGS3.js → chunk-T34DMFOM.js} +19 -7
  135. package/dist/chunks/chunk-T34DMFOM.js.map +6 -0
  136. package/dist/chunks/{chunk-WGN4AUAW.js → chunk-T6FMC7R5.js} +3 -3
  137. package/dist/chunks/{chunk-SHW5NXAS.js → chunk-TDCHFQVU.js} +2 -2
  138. package/dist/chunks/{chunk-6AINAG3P.js → chunk-TGQWC44Q.js} +2 -2
  139. package/dist/chunks/{chunk-XPTCRZ6F.js → chunk-TIM7OEJN.js} +3 -3
  140. package/dist/chunks/{chunk-MNQL7ZAW.js → chunk-TLSFOP3I.js} +170 -24
  141. package/dist/chunks/chunk-TLSFOP3I.js.map +6 -0
  142. package/dist/chunks/{chunk-TAPWAMDX.js → chunk-TO5ROEIW.js} +9 -9
  143. package/dist/chunks/{chunk-QTGW6FJG.js → chunk-TTBXKYFP.js} +6 -6
  144. package/dist/chunks/{chunk-757LAANV.js → chunk-TXCQMW7F.js} +5 -5
  145. package/dist/chunks/{chunk-WD5XJ5ZU.js → chunk-UCF6H5BB.js} +2 -2
  146. package/dist/chunks/{chunk-5ER7BU54.js → chunk-UP3ATLU6.js} +3 -3
  147. package/dist/chunks/{chunk-E5LJN2DV.js → chunk-UTC325FB.js} +3 -3
  148. package/dist/chunks/{chunk-A2GT47E2.js → chunk-V2DQFFLG.js} +1486 -1370
  149. package/dist/chunks/chunk-V2DQFFLG.js.map +6 -0
  150. package/dist/chunks/{chunk-C3UATI2T.js → chunk-VH647IFM.js} +2 -2
  151. package/dist/chunks/{chunk-5K6GFGCD.js → chunk-VMWPRI2S.js} +3 -3
  152. package/dist/chunks/{chunk-PTBKVAHY.js → chunk-VWJOJJNQ.js} +6 -6
  153. package/dist/chunks/{chunk-QVUF2FSM.js → chunk-W3QW6SK6.js} +13 -13
  154. package/dist/chunks/{chunk-P5UUY56J.js → chunk-W4EKIBRD.js} +3 -3
  155. package/dist/chunks/{chunk-SC3GK5QC.js → chunk-WMWRRDO2.js} +13 -13
  156. package/dist/chunks/{chunk-5TSOB5RI.js → chunk-WNBIAOXA.js} +2 -2
  157. package/dist/chunks/{chunk-Q7NB7LRR.js → chunk-WQL7MEOD.js} +2 -2
  158. package/dist/chunks/{chunk-335D56LG.js → chunk-X2LYTBDH.js} +3 -3
  159. package/dist/chunks/{chunk-OLX3IUKN.js → chunk-X4TVUANR.js} +9 -9
  160. package/dist/chunks/{chunk-EGRSUSP4.js → chunk-XBX3T6YY.js} +10 -10
  161. package/dist/chunks/{chunk-Z4UCKCEQ.js → chunk-XC6G27M2.js} +2 -2
  162. package/dist/chunks/{chunk-RXVJEZSV.js → chunk-XGH3FZ76.js} +2 -2
  163. package/dist/chunks/{chunk-6GCYUKNK.js → chunk-XK7NQIZA.js} +4 -4
  164. package/dist/chunks/{chunk-BHO3RAXS.js → chunk-XNMJLM5W.js} +12 -12
  165. package/dist/chunks/{chunk-G5MD6XCV.js → chunk-XORYHNZ3.js} +10 -10
  166. package/dist/chunks/{chunk-NJUB2ADX.js → chunk-XRAVC5W6.js} +36 -10
  167. package/dist/chunks/chunk-XRAVC5W6.js.map +6 -0
  168. package/dist/chunks/{chunk-EW2YVKTN.js → chunk-XTMUUGTN.js} +2 -2
  169. package/dist/chunks/{chunk-DO5JIP3I.js → chunk-Y36ZTLIJ.js} +4 -4
  170. package/dist/chunks/{chunk-NUMKSEG4.js → chunk-YCPK5ZTB.js} +3 -3
  171. package/dist/chunks/{chunk-HXINZ7D3.js → chunk-YRQ5PI7O.js} +3 -3
  172. package/dist/chunks/{chunk-V5DZWA6R.js → chunk-YVQE7BQ7.js} +242 -707
  173. package/dist/chunks/chunk-YVQE7BQ7.js.map +6 -0
  174. package/dist/chunks/{chunk-ORXNYBJU.js → chunk-YXR3LVZE.js} +3 -3
  175. package/dist/chunks/{chunk-4ABPUIBF.js → chunk-YYGE5EWH.js} +3 -3
  176. package/dist/chunks/{chunk-RJINNWMH.js → chunk-YZ6UKIKL.js} +4 -4
  177. package/dist/chunks/{chunk-L45TVHRJ.js → chunk-Z75IWPPX.js} +7 -7
  178. package/dist/chunks/{chunk-XNVZ6BPI.js → chunk-ZAQFM5BR.js} +6 -6
  179. package/dist/chunks/{chunk-FDLXZRE4.js → chunk-ZDJWREOA.js} +5 -5
  180. package/dist/chunks/{chunk-UGTDCLS5.js → chunk-ZKTDZOCC.js} +2 -2
  181. package/dist/chunks/{chunk-QHJJ333E.js → chunk-ZQL7XFSE.js} +8 -8
  182. package/dist/chunks/{cli-runtime-FK3WLEHC.js → cli-runtime-ZKBJFWOI.js} +29 -29
  183. package/dist/chunks/{commands-UVEHHHUD.js → commands-3WI6F2YZ.js} +6 -6
  184. package/dist/chunks/completion-shells-FUAKFK5A.js +167 -0
  185. package/dist/chunks/completion-shells-FUAKFK5A.js.map +6 -0
  186. package/dist/chunks/{computer-GABH2PJF.js → computer-WEEMTZUV.js} +2 -2
  187. package/dist/chunks/{config-PUASBICJ.js → config-E6UPAUGU.js} +19 -18
  188. package/dist/chunks/config-E6UPAUGU.js.map +6 -0
  189. package/dist/chunks/{cost-S6LUVWMS.js → cost-557HKPZ4.js} +5 -5
  190. package/dist/chunks/{crash-report-WSCK3UQK.js → crash-report-J47RFQ5T.js} +8 -8
  191. package/dist/chunks/{debug-DX3SZNDB.js → debug-WJJFYSZF.js} +21 -15
  192. package/dist/chunks/debug-WJJFYSZF.js.map +6 -0
  193. package/dist/chunks/{desktop-host-schedule-tool-X5AYUZMV.js → desktop-host-schedule-tool-IOOJNMPQ.js} +36 -36
  194. package/dist/chunks/{dist-WBDFP2PT.js → dist-665VSCM2.js} +2 -2
  195. package/dist/chunks/{dist-NJJDM4QY.js → dist-AQO44B7K.js} +2 -2
  196. package/dist/chunks/{dist-3GV6WNET.js → dist-D2RTUX7F.js} +24 -2
  197. package/dist/chunks/{dist-BFD35FTG.js → dist-JLTZUUMS.js} +2 -2
  198. package/dist/chunks/{dist-X7QK25WG.js → dist-L5C6AOXZ.js} +2 -2
  199. package/dist/chunks/{dist-K64KWQUG.js → dist-OIM6DSGL.js} +12 -2
  200. package/dist/chunks/{dist-K64KWQUG.js.map → dist-OIM6DSGL.js.map} +1 -1
  201. package/dist/chunks/{dist-AAPFBZPA.js → dist-SEISKEDK.js} +3 -3
  202. package/dist/chunks/{dist-XLMKK2FY.js → dist-VQVXULA5.js} +2 -2
  203. package/dist/chunks/doctor-ZRPCR5DP.js +104 -0
  204. package/dist/chunks/{drain-2WIWFYU3.js → drain-NHR22ZM6.js} +86 -30
  205. package/dist/chunks/drain-NHR22ZM6.js.map +6 -0
  206. package/dist/chunks/{entry-KSTSU23A.js → entry-TPBKHAWV.js} +6 -6
  207. package/dist/chunks/{eval-QJQ7H4E7.js → eval-HKBQQXOD.js} +53 -35
  208. package/dist/chunks/{eval-QJQ7H4E7.js.map → eval-HKBQQXOD.js.map} +1 -1
  209. package/dist/chunks/{exec-J55XOCSL.js → exec-R5U6FFFE.js} +138 -98
  210. package/dist/chunks/exec-R5U6FFFE.js.map +6 -0
  211. package/dist/chunks/{extension-3YMXVKLS.js → extension-KJJ7XNR4.js} +5 -5
  212. package/dist/chunks/{feed-66TKSG2Y.js → feed-LQNVF7M6.js} +4 -4
  213. package/dist/chunks/{github-7JHAZZC3.js → github-LMMBAQWI.js} +3 -3
  214. package/dist/chunks/{home-RJERCCZS.js → home-D7JCGXQE.js} +3 -3
  215. package/dist/chunks/{homes-P5UAFUPZ.js → homes-EKTHOMXX.js} +6 -6
  216. package/dist/chunks/{hooks-U2Z463DN.js → hooks-IT2ZUPG6.js} +27 -27
  217. package/dist/chunks/{hooks-report-FIPQINVZ.js → hooks-report-A7F26EDM.js} +23 -23
  218. package/dist/chunks/{host-IWAXBSUX.js → host-FS2RMOHW.js} +13 -13
  219. package/dist/chunks/{host-queries-3IRCFZ74.js → host-queries-OJXR2XYT.js} +18 -18
  220. package/dist/chunks/index-project-2UUHV7X3.js +134 -0
  221. package/dist/chunks/index-project-2UUHV7X3.js.map +6 -0
  222. package/dist/chunks/{installed-list-IBGMBHUJ.js → installed-list-27KYS56I.js} +4 -4
  223. package/dist/chunks/{launch-UHLESLJC.js → launch-33I3O7VJ.js} +32 -32
  224. package/dist/chunks/{learn-TQHDWYWB.js → learn-G5UEINB6.js} +18 -18
  225. package/dist/chunks/{learn-builtin-2OY2YL6U.js → learn-builtin-Y5FIKQSV.js} +21 -21
  226. package/dist/chunks/{lifecycle-ECBTALQV.js → lifecycle-NJQ7FIK2.js} +47 -47
  227. package/dist/chunks/{list-GECT7X6E.js → list-UKBQESKU.js} +24 -24
  228. package/dist/chunks/live-3YNFFWY5.js +103 -0
  229. package/dist/chunks/{load-LFCACQWA.js → load-KDS3CW6R.js} +14 -14
  230. package/dist/chunks/{logs-55HJKNP6.js → logs-3XKNKFY2.js} +5 -5
  231. package/dist/chunks/{mcp-XUKNYMSO.js → mcp-B2ZVGJQE.js} +31 -31
  232. package/dist/chunks/{mcp-serve-XYNR3BNJ.js → mcp-serve-DH63SWUH.js} +22 -22
  233. package/dist/chunks/{message-command-QF7YMZDH.js → message-command-KRDDHWLA.js} +73 -71
  234. package/dist/chunks/message-command-KRDDHWLA.js.map +6 -0
  235. package/dist/chunks/{notes-TQTBT2ZZ.js → notes-ZCY7LTUD.js} +6 -6
  236. package/dist/chunks/{open-CDLLQS4B.js → open-A4H4HWGO.js} +8 -8
  237. package/dist/chunks/{operator-tools-XAFRSL26.js → operator-tools-EH6R2JQC.js} +16 -16
  238. package/dist/chunks/{output-schema-5KOV6OJ6.js → output-schema-2NSAYRBS.js} +3 -3
  239. package/dist/chunks/{pal-7XHBGZ4S.js → pal-EANL2OUH.js} +17 -17
  240. package/dist/chunks/{peers-2MJG2EON.js → peers-H3ANL6XB.js} +9 -9
  241. package/dist/chunks/{peers-FJNLC7ZV.js → peers-W5KEFXN6.js} +25 -24
  242. package/dist/chunks/peers-W5KEFXN6.js.map +6 -0
  243. package/dist/chunks/{pending-4FM6EO26.js → pending-TRLAK2BR.js} +7 -7
  244. package/dist/chunks/{plugin-5J3GMENO.js → plugin-RAY3J2G2.js} +33 -32
  245. package/dist/chunks/plugin-RAY3J2G2.js.map +6 -0
  246. package/dist/chunks/{proposals-BGOU7KAM.js → proposals-YB3YJOPW.js} +39 -39
  247. package/dist/chunks/{providers-6PVAW2M3.js → providers-JA3AF524.js} +20 -20
  248. package/dist/chunks/{providers-ZFUFVRRD.js → providers-LVD7T5JI.js} +12 -12
  249. package/dist/chunks/{pty-3WHZDZXY.js → pty-66OF4YNF.js} +3 -3
  250. package/dist/chunks/resume-W4JBH2A7.js +28 -0
  251. package/dist/chunks/{resume-command-4VQ5ZTNJ.js → resume-command-J3VONMB5.js} +5 -5
  252. package/dist/chunks/{running-QT5QIYNC.js → running-5GQPD6OM.js} +4 -4
  253. package/dist/chunks/{say-JISSL5GL.js → say-7GQSUSTD.js} +21 -21
  254. package/dist/chunks/{schedule-5VVP4D3W.js → schedule-LMXNNMAZ.js} +16 -16
  255. package/dist/chunks/{send-F7EBK2UQ.js → send-Z35YQVV2.js} +20 -20
  256. package/dist/chunks/send-person-TIM427ZP.js +39 -0
  257. package/dist/chunks/{servers-WVOZNOUM.js → servers-4QP7GKOK.js} +8 -8
  258. package/dist/chunks/{service-7QGHSF2V.js → service-U244Z3VG.js} +48 -48
  259. package/dist/chunks/{session-options-WW5IDZEZ.js → session-options-ODKOXNAT.js} +5 -5
  260. package/dist/chunks/{setting-cli-AC5BEDWA.js → setting-cli-H5UKKB4F.js} +18 -17
  261. package/dist/chunks/{skills-QQ74IBRB.js → skills-ELR2D7WU.js} +33 -33
  262. package/dist/chunks/{source-deliveries-C2DRS4H6.js → source-deliveries-CI5K5DJQ.js} +20 -20
  263. package/dist/chunks/{start-check-5L262F53.js → start-check-JYINXXEG.js} +2 -2
  264. package/dist/chunks/{startup-failure-4PLTFEVA.js → startup-failure-G3HSW2U3.js} +2 -2
  265. package/dist/chunks/{state-BTF5VEKZ.js → state-EDIR4EM2.js} +25 -25
  266. package/dist/chunks/{store-WECWJFQV.js → store-4HJUNR5E.js} +3 -3
  267. package/dist/chunks/{store-WOSPWPH2.js → store-6SNBHHJA.js} +4 -4
  268. package/dist/chunks/{store-RTWBXAKA.js → store-ADMKKWZF.js} +13 -13
  269. package/dist/chunks/{store-OTVBA4G2.js → store-IKXRGI2L.js} +9 -9
  270. package/dist/chunks/{tui-EWG7SLNZ.js → tui-AKXFDXNZ.js} +122 -120
  271. package/dist/chunks/tui-AKXFDXNZ.js.map +6 -0
  272. package/dist/chunks/{update-7FGJLU2B.js → update-TYCWQEHZ.js} +315 -34
  273. package/dist/chunks/update-TYCWQEHZ.js.map +6 -0
  274. package/dist/chunks/{watch-KKQKQKA6.js → watch-RQYBCHYR.js} +124 -122
  275. package/dist/chunks/watch-RQYBCHYR.js.map +6 -0
  276. package/dist/chunks/{windows-home-VPSYQVOZ.js → windows-home-IZGCRSW7.js} +5 -5
  277. package/dist/chunks/{workspaces-7DZS6QLA.js → workspaces-6KGOMHCM.js} +30 -30
  278. package/dist/chunks/{worktree-XZ5Y74RZ.js → worktree-O7RSM3PC.js} +33 -33
  279. package/dist/cli.d.ts.map +1 -1
  280. package/dist/commands/acp.d.ts.map +1 -1
  281. package/dist/commands/action-help.d.ts +1 -1
  282. package/dist/commands/action-help.d.ts.map +1 -1
  283. package/dist/commands/actions/small.d.ts +1 -0
  284. package/dist/commands/actions/small.d.ts.map +1 -1
  285. package/dist/commands/auth-status.d.ts +1 -1
  286. package/dist/commands/auth-status.d.ts.map +1 -1
  287. package/dist/commands/auth.d.ts.map +1 -1
  288. package/dist/commands/completion-shells.d.ts +8 -0
  289. package/dist/commands/completion-shells.d.ts.map +1 -0
  290. package/dist/commands/completion.d.ts +6 -0
  291. package/dist/commands/completion.d.ts.map +1 -0
  292. package/dist/commands/debug.d.ts.map +1 -1
  293. package/dist/commands/desktop-chat-workspace.d.ts +25 -0
  294. package/dist/commands/desktop-chat-workspace.d.ts.map +1 -0
  295. package/dist/commands/desktop-host.d.ts.map +1 -1
  296. package/dist/commands/doctor.d.ts.map +1 -1
  297. package/dist/commands/drain.d.ts +19 -1
  298. package/dist/commands/drain.d.ts.map +1 -1
  299. package/dist/commands/eval.d.ts.map +1 -1
  300. package/dist/commands/exec-json.d.ts.map +1 -1
  301. package/dist/commands/exec.d.ts.map +1 -1
  302. package/dist/commands/index-project.d.ts +3 -0
  303. package/dist/commands/index-project.d.ts.map +1 -0
  304. package/dist/commands/manifest.d.ts +1 -0
  305. package/dist/commands/manifest.d.ts.map +1 -1
  306. package/dist/commands/registry.d.ts +1 -0
  307. package/dist/commands/registry.d.ts.map +1 -1
  308. package/dist/commands/update-migrate.d.ts +39 -0
  309. package/dist/commands/update-migrate.d.ts.map +1 -0
  310. package/dist/commands/update.d.ts +8 -0
  311. package/dist/commands/update.d.ts.map +1 -1
  312. package/dist/config/load.d.ts.map +1 -1
  313. package/dist/config/schema.d.ts +9 -0
  314. package/dist/config/schema.d.ts.map +1 -1
  315. package/dist/config/session-options.d.ts +1 -1
  316. package/dist/config/session-options.d.ts.map +1 -1
  317. package/dist/config/settings-descriptors.d.ts.map +1 -1
  318. package/dist/doctor/checks/chain.d.ts.map +1 -1
  319. package/dist/doctor/checks/credentials.d.ts.map +1 -1
  320. package/dist/doctor/checks/updates.d.ts.map +1 -1
  321. package/dist/index.d.ts +1 -1
  322. package/dist/index.d.ts.map +1 -1
  323. package/dist/index.js +58 -57
  324. package/dist/integrations/auto-update/apply.d.ts.map +1 -1
  325. package/dist/integrations/auto-update/install-kind.d.ts +13 -0
  326. package/dist/integrations/auto-update/install-kind.d.ts.map +1 -1
  327. package/dist/integrations/auto-update/install-plan.d.ts +40 -0
  328. package/dist/integrations/auto-update/install-plan.d.ts.map +1 -0
  329. package/dist/integrations/auto-update/status.d.ts +8 -0
  330. package/dist/integrations/auto-update/status.d.ts.map +1 -1
  331. package/dist/integrations/auto-update/updater.d.ts.map +1 -1
  332. package/dist/integrations/images/generate-image.d.ts +2 -0
  333. package/dist/integrations/images/generate-image.d.ts.map +1 -1
  334. package/dist/integrations/providers/discover.d.ts +1 -0
  335. package/dist/integrations/providers/discover.d.ts.map +1 -1
  336. package/dist/integrations/providers/gemini-credentials.d.ts +2 -0
  337. package/dist/integrations/providers/gemini-credentials.d.ts.map +1 -1
  338. package/dist/integrations/semantic-search/chunk.d.ts +9 -0
  339. package/dist/integrations/semantic-search/chunk.d.ts.map +1 -0
  340. package/dist/integrations/semantic-search/consent.d.ts +4 -0
  341. package/dist/integrations/semantic-search/consent.d.ts.map +1 -0
  342. package/dist/integrations/semantic-search/embedding.d.ts +14 -0
  343. package/dist/integrations/semantic-search/embedding.d.ts.map +1 -0
  344. package/dist/integrations/semantic-search/index.d.ts +30 -0
  345. package/dist/integrations/semantic-search/index.d.ts.map +1 -0
  346. package/dist/integrations/semantic-search/tool.d.ts +3 -0
  347. package/dist/integrations/semantic-search/tool.d.ts.map +1 -0
  348. package/dist/integrations/sessions/uncheckpointed-turn.d.ts +47 -0
  349. package/dist/integrations/sessions/uncheckpointed-turn.d.ts.map +1 -0
  350. package/dist/plan/approval.d.ts +8 -6
  351. package/dist/plan/approval.d.ts.map +1 -1
  352. package/dist/plan/exit-plan-mode-tool.d.ts.map +1 -1
  353. package/dist/plan/handover.d.ts +23 -0
  354. package/dist/plan/handover.d.ts.map +1 -0
  355. package/dist/rounds/types.d.ts +2 -0
  356. package/dist/rounds/types.d.ts.map +1 -1
  357. package/dist/sdk-peer.js +23 -1
  358. package/dist/tui/App.d.ts.map +1 -1
  359. package/dist/tui/Composer.d.ts +3 -1
  360. package/dist/tui/Composer.d.ts.map +1 -1
  361. package/dist/tui/PlanApprovalOverlay.d.ts +2 -2
  362. package/dist/tui/PlanApprovalOverlay.d.ts.map +1 -1
  363. package/dist/tui/StatusBar.d.ts +1 -7
  364. package/dist/tui/StatusBar.d.ts.map +1 -1
  365. package/dist/tui/agent.d.ts +21 -1
  366. package/dist/tui/agent.d.ts.map +1 -1
  367. package/dist/tui/computer-use-enable-offer.d.ts.map +1 -1
  368. package/dist/tui/message-closes-ask.d.ts +14 -0
  369. package/dist/tui/message-closes-ask.d.ts.map +1 -0
  370. package/dist/tui/plain-failure.d.ts.map +1 -1
  371. package/dist/tui/slash-argument-completion.d.ts +37 -0
  372. package/dist/tui/slash-argument-completion.d.ts.map +1 -0
  373. package/dist/tui/slashCommands.d.ts +3 -1
  374. package/dist/tui/slashCommands.d.ts.map +1 -1
  375. package/dist/tui/types.d.ts +1 -0
  376. package/dist/tui/types.d.ts.map +1 -1
  377. package/dist/usage-error.d.ts +0 -10
  378. package/dist/usage-error.d.ts.map +1 -1
  379. package/package.json +15 -15
  380. package/dist/chunks/acp-XC6FTO64.js.map +0 -6
  381. package/dist/chunks/agent-session-LYNJM6TP.js +0 -105
  382. package/dist/chunks/auth-JAKMDE4X.js.map +0 -6
  383. package/dist/chunks/bin-main-V6PBLHRK.js.map +0 -6
  384. package/dist/chunks/chunk-2YPRONTU.js.map +0 -6
  385. package/dist/chunks/chunk-3OHJYUFP.js.map +0 -6
  386. package/dist/chunks/chunk-5B4BXZCI.js.map +0 -6
  387. package/dist/chunks/chunk-5U4IA3HS.js.map +0 -6
  388. package/dist/chunks/chunk-7L3PTSKY.js.map +0 -6
  389. package/dist/chunks/chunk-A2GT47E2.js.map +0 -6
  390. package/dist/chunks/chunk-AUDTDXWX.js.map +0 -6
  391. package/dist/chunks/chunk-HS7PPGS3.js.map +0 -6
  392. package/dist/chunks/chunk-KGCHR4TQ.js.map +0 -6
  393. package/dist/chunks/chunk-MNQL7ZAW.js.map +0 -6
  394. package/dist/chunks/chunk-NJUB2ADX.js.map +0 -6
  395. package/dist/chunks/chunk-TV7UBGX2.js.map +0 -6
  396. package/dist/chunks/chunk-V5DZWA6R.js.map +0 -6
  397. package/dist/chunks/chunk-VBG357AO.js.map +0 -6
  398. package/dist/chunks/chunk-VVMI6HQM.js.map +0 -6
  399. package/dist/chunks/chunk-XJ4APISC.js.map +0 -6
  400. package/dist/chunks/chunk-ZZ7A2Y7O.js.map +0 -6
  401. package/dist/chunks/config-PUASBICJ.js.map +0 -6
  402. package/dist/chunks/debug-DX3SZNDB.js.map +0 -6
  403. package/dist/chunks/doctor-CPX7KDGR.js +0 -103
  404. package/dist/chunks/drain-2WIWFYU3.js.map +0 -6
  405. package/dist/chunks/exec-J55XOCSL.js.map +0 -6
  406. package/dist/chunks/live-LDWIFGRI.js +0 -102
  407. package/dist/chunks/message-command-QF7YMZDH.js.map +0 -6
  408. package/dist/chunks/peers-FJNLC7ZV.js.map +0 -6
  409. package/dist/chunks/plugin-5J3GMENO.js.map +0 -6
  410. package/dist/chunks/resume-IQMUIIBO.js +0 -28
  411. package/dist/chunks/send-person-LHJCPCAT.js +0 -39
  412. package/dist/chunks/tui-EWG7SLNZ.js.map +0 -6
  413. package/dist/chunks/update-7FGJLU2B.js.map +0 -6
  414. package/dist/chunks/watch-KKQKQKA6.js.map +0 -6
  415. /package/dist/chunks/{activity-command-PIH63SRU.js.map → activity-command-X25POZ3R.js.map} +0 -0
  416. /package/dist/chunks/{add-CWIB4XVU.js.map → add-HL4MO6R2.js.map} +0 -0
  417. /package/dist/chunks/{agent-CNRZCXHY.js.map → agent-MHH4MGYB.js.map} +0 -0
  418. /package/dist/chunks/{agent-session-LYNJM6TP.js.map → agent-session-OC32VSS6.js.map} +0 -0
  419. /package/dist/chunks/{apply-at-exit-CMRH3GQN.js.map → apply-at-exit-ADWMDFFQ.js.map} +0 -0
  420. /package/dist/chunks/{archive-DPZ3PWUU.js.map → archive-6X2FED3E.js.map} +0 -0
  421. /package/dist/chunks/{binding-UHJZD5Z3.js.map → binding-OXJ5TL6T.js.map} +0 -0
  422. /package/dist/chunks/{browser-2QBVPHCB.js.map → browser-DFLZNRRZ.js.map} +0 -0
  423. /package/dist/chunks/{chat-DJEP53BA.js.map → chat-PPSFN5JK.js.map} +0 -0
  424. /package/dist/chunks/{chunk-4JKWOO7I.js.map → chunk-23AYRMS2.js.map} +0 -0
  425. /package/dist/chunks/{chunk-MUQOV75B.js.map → chunk-2H75JWKG.js.map} +0 -0
  426. /package/dist/chunks/{chunk-NEOVE6D5.js.map → chunk-2JKQ6BFI.js.map} +0 -0
  427. /package/dist/chunks/{chunk-UZVJQEYT.js.map → chunk-2KJUKF2E.js.map} +0 -0
  428. /package/dist/chunks/{chunk-IYBVVKSB.js.map → chunk-2QGSHJ4Y.js.map} +0 -0
  429. /package/dist/chunks/{chunk-ZNSVRCPH.js.map → chunk-2R6Z32IU.js.map} +0 -0
  430. /package/dist/chunks/{chunk-7FGITTVH.js.map → chunk-2USTJGLA.js.map} +0 -0
  431. /package/dist/chunks/{chunk-EIIJLF6W.js.map → chunk-333RR5BA.js.map} +0 -0
  432. /package/dist/chunks/{chunk-MCIYCR57.js.map → chunk-33TGFQ2U.js.map} +0 -0
  433. /package/dist/chunks/{chunk-C4RV2D57.js.map → chunk-3FFV4OSR.js.map} +0 -0
  434. /package/dist/chunks/{chunk-QI4IEHLE.js.map → chunk-3QXUETDN.js.map} +0 -0
  435. /package/dist/chunks/{chunk-4VTRURM6.js.map → chunk-3TLDTD6R.js.map} +0 -0
  436. /package/dist/chunks/{chunk-ONEBRD5O.js.map → chunk-4ASXGRP5.js.map} +0 -0
  437. /package/dist/chunks/{chunk-ZFOZVUUJ.js.map → chunk-4JPZYI6M.js.map} +0 -0
  438. /package/dist/chunks/{chunk-RBJDS73T.js.map → chunk-4TPXEWD5.js.map} +0 -0
  439. /package/dist/chunks/{chunk-COOW2AWX.js.map → chunk-5GJWIDVU.js.map} +0 -0
  440. /package/dist/chunks/{chunk-RXFFBB7A.js.map → chunk-5PQHBLZI.js.map} +0 -0
  441. /package/dist/chunks/{chunk-GMUWAUKQ.js.map → chunk-5UARTCJW.js.map} +0 -0
  442. /package/dist/chunks/{chunk-Q5SAOE7Q.js.map → chunk-5XROCBT5.js.map} +0 -0
  443. /package/dist/chunks/{chunk-WI6IGTC4.js.map → chunk-5YOREQIA.js.map} +0 -0
  444. /package/dist/chunks/{chunk-4E5KFKJA.js.map → chunk-6CL7TQOC.js.map} +0 -0
  445. /package/dist/chunks/{chunk-N5YRJQPS.js.map → chunk-7RCI6OBE.js.map} +0 -0
  446. /package/dist/chunks/{chunk-SIMI4VB7.js.map → chunk-7WPF7ATU.js.map} +0 -0
  447. /package/dist/chunks/{chunk-DKZAHG7B.js.map → chunk-AAN4XLUD.js.map} +0 -0
  448. /package/dist/chunks/{chunk-LDJXUI3Q.js.map → chunk-BB2RJOFI.js.map} +0 -0
  449. /package/dist/chunks/{chunk-ESWXNISI.js.map → chunk-BCHHHNLK.js.map} +0 -0
  450. /package/dist/chunks/{chunk-C6JX3GVK.js.map → chunk-BUQCQMXH.js.map} +0 -0
  451. /package/dist/chunks/{chunk-VLWMMDBY.js.map → chunk-COSMRH2Q.js.map} +0 -0
  452. /package/dist/chunks/{chunk-4VMFD7UC.js.map → chunk-CPZEJQ2Z.js.map} +0 -0
  453. /package/dist/chunks/{chunk-3AKPBYMA.js.map → chunk-DCVWFBYB.js.map} +0 -0
  454. /package/dist/chunks/{chunk-ADGTOEHA.js.map → chunk-DD3BJ4GM.js.map} +0 -0
  455. /package/dist/chunks/{chunk-4H2RPAXN.js.map → chunk-DKTU6RWO.js.map} +0 -0
  456. /package/dist/chunks/{chunk-OWKPJJKH.js.map → chunk-EODC62SI.js.map} +0 -0
  457. /package/dist/chunks/{chunk-IVTYJBJF.js.map → chunk-EOHPS7LC.js.map} +0 -0
  458. /package/dist/chunks/{chunk-2LZAZAWT.js.map → chunk-EPSLHLT3.js.map} +0 -0
  459. /package/dist/chunks/{chunk-SHUKR2A5.js.map → chunk-FAQQGJ2Z.js.map} +0 -0
  460. /package/dist/chunks/{chunk-OQFX532E.js.map → chunk-FJPM4YAO.js.map} +0 -0
  461. /package/dist/chunks/{chunk-TPMF64WM.js.map → chunk-FZSM7DSH.js.map} +0 -0
  462. /package/dist/chunks/{chunk-MMQGQ7BJ.js.map → chunk-G3V2OKYP.js.map} +0 -0
  463. /package/dist/chunks/{chunk-6WPK5S6Z.js.map → chunk-G4OR74MC.js.map} +0 -0
  464. /package/dist/chunks/{chunk-QWUHCBDT.js.map → chunk-HXZA5UUN.js.map} +0 -0
  465. /package/dist/chunks/{chunk-2AWKLDCQ.js.map → chunk-IDIVB67E.js.map} +0 -0
  466. /package/dist/chunks/{chunk-IISM3GHE.js.map → chunk-ISI36EUS.js.map} +0 -0
  467. /package/dist/chunks/{chunk-SNHJJI52.js.map → chunk-IUMOIQKL.js.map} +0 -0
  468. /package/dist/chunks/{chunk-P5LQ4NRD.js.map → chunk-J4NFH5T2.js.map} +0 -0
  469. /package/dist/chunks/{chunk-HYHHGMBC.js.map → chunk-J6JBHNNR.js.map} +0 -0
  470. /package/dist/chunks/{chunk-UGBHE6ZS.js.map → chunk-JCY3OPTY.js.map} +0 -0
  471. /package/dist/chunks/{chunk-S76POTJP.js.map → chunk-JD7EWFIJ.js.map} +0 -0
  472. /package/dist/chunks/{chunk-2K7EIRI2.js.map → chunk-JOVKHMJS.js.map} +0 -0
  473. /package/dist/chunks/{chunk-GOKGPFXK.js.map → chunk-JQ7HNIBS.js.map} +0 -0
  474. /package/dist/chunks/{chunk-I3HOLAAO.js.map → chunk-JSWFUARY.js.map} +0 -0
  475. /package/dist/chunks/{chunk-NTUKFINL.js.map → chunk-JU3P3ZJJ.js.map} +0 -0
  476. /package/dist/chunks/{chunk-ZLMO5YL4.js.map → chunk-JWBS363M.js.map} +0 -0
  477. /package/dist/chunks/{chunk-HZGT5EHL.js.map → chunk-JXBSJNUF.js.map} +0 -0
  478. /package/dist/chunks/{chunk-X6LDRLVN.js.map → chunk-JZTNWODR.js.map} +0 -0
  479. /package/dist/chunks/{chunk-HJHZJKAD.js.map → chunk-K4AUROOC.js.map} +0 -0
  480. /package/dist/chunks/{chunk-RL2CTUF2.js.map → chunk-KFFW7EYQ.js.map} +0 -0
  481. /package/dist/chunks/{chunk-SEW4KEZ5.js.map → chunk-KGKVNHFC.js.map} +0 -0
  482. /package/dist/chunks/{chunk-SOZSIDCY.js.map → chunk-KLIJLSWF.js.map} +0 -0
  483. /package/dist/chunks/{chunk-BS3KGJJZ.js.map → chunk-LJFDFGFU.js.map} +0 -0
  484. /package/dist/chunks/{chunk-O3T5CJQG.js.map → chunk-LZPPIRJW.js.map} +0 -0
  485. /package/dist/chunks/{chunk-H624ADJH.js.map → chunk-MHEYQD24.js.map} +0 -0
  486. /package/dist/chunks/{chunk-44KWXPBG.js.map → chunk-MM7HGD6H.js.map} +0 -0
  487. /package/dist/chunks/{chunk-C56FUSQH.js.map → chunk-N4KE47J2.js.map} +0 -0
  488. /package/dist/chunks/{chunk-QNRBLNA3.js.map → chunk-N4USZWBA.js.map} +0 -0
  489. /package/dist/chunks/{chunk-GCLZEMDF.js.map → chunk-OIFFABSH.js.map} +0 -0
  490. /package/dist/chunks/{chunk-NRR2SMR6.js.map → chunk-OKFU62GA.js.map} +0 -0
  491. /package/dist/chunks/{chunk-G6YSAHKC.js.map → chunk-OWPDRJ6S.js.map} +0 -0
  492. /package/dist/chunks/{chunk-LCZWTKIB.js.map → chunk-P4WMRT5Q.js.map} +0 -0
  493. /package/dist/chunks/{chunk-EHKWQ7IS.js.map → chunk-PGHGBSS2.js.map} +0 -0
  494. /package/dist/chunks/{chunk-OA76OH27.js.map → chunk-PLPVXHTM.js.map} +0 -0
  495. /package/dist/chunks/{chunk-KE2RFCTY.js.map → chunk-PMA5NXWF.js.map} +0 -0
  496. /package/dist/chunks/{chunk-5RA5FZDM.js.map → chunk-PSRWFKFX.js.map} +0 -0
  497. /package/dist/chunks/{chunk-NXFB5AP5.js.map → chunk-PTUICVCN.js.map} +0 -0
  498. /package/dist/chunks/{chunk-ZIF4GK2U.js.map → chunk-Q5THGA3N.js.map} +0 -0
  499. /package/dist/chunks/{chunk-5SRVOPRS.js.map → chunk-QTR6UU63.js.map} +0 -0
  500. /package/dist/chunks/{chunk-7BNKRTXM.js.map → chunk-RIVPA5TG.js.map} +0 -0
  501. /package/dist/chunks/{chunk-HPUVBU7G.js.map → chunk-RQYSVELQ.js.map} +0 -0
  502. /package/dist/chunks/{chunk-RKAZUYKY.js.map → chunk-RWSHMPFM.js.map} +0 -0
  503. /package/dist/chunks/{chunk-CQNIP7QC.js.map → chunk-RZ3HYPV4.js.map} +0 -0
  504. /package/dist/chunks/{chunk-AFYS4U45.js.map → chunk-SDWOSB3L.js.map} +0 -0
  505. /package/dist/chunks/{chunk-AT42FHTY.js.map → chunk-SPKNKEW5.js.map} +0 -0
  506. /package/dist/chunks/{chunk-UUMISHVL.js.map → chunk-SQDZZCQJ.js.map} +0 -0
  507. /package/dist/chunks/{chunk-KFB4RMNZ.js.map → chunk-SRNS347K.js.map} +0 -0
  508. /package/dist/chunks/{chunk-GUOCXE6V.js.map → chunk-SX7FXWTB.js.map} +0 -0
  509. /package/dist/chunks/{chunk-WGN4AUAW.js.map → chunk-T6FMC7R5.js.map} +0 -0
  510. /package/dist/chunks/{chunk-SHW5NXAS.js.map → chunk-TDCHFQVU.js.map} +0 -0
  511. /package/dist/chunks/{chunk-6AINAG3P.js.map → chunk-TGQWC44Q.js.map} +0 -0
  512. /package/dist/chunks/{chunk-XPTCRZ6F.js.map → chunk-TIM7OEJN.js.map} +0 -0
  513. /package/dist/chunks/{chunk-TAPWAMDX.js.map → chunk-TO5ROEIW.js.map} +0 -0
  514. /package/dist/chunks/{chunk-QTGW6FJG.js.map → chunk-TTBXKYFP.js.map} +0 -0
  515. /package/dist/chunks/{chunk-757LAANV.js.map → chunk-TXCQMW7F.js.map} +0 -0
  516. /package/dist/chunks/{chunk-WD5XJ5ZU.js.map → chunk-UCF6H5BB.js.map} +0 -0
  517. /package/dist/chunks/{chunk-5ER7BU54.js.map → chunk-UP3ATLU6.js.map} +0 -0
  518. /package/dist/chunks/{chunk-E5LJN2DV.js.map → chunk-UTC325FB.js.map} +0 -0
  519. /package/dist/chunks/{chunk-C3UATI2T.js.map → chunk-VH647IFM.js.map} +0 -0
  520. /package/dist/chunks/{chunk-5K6GFGCD.js.map → chunk-VMWPRI2S.js.map} +0 -0
  521. /package/dist/chunks/{chunk-PTBKVAHY.js.map → chunk-VWJOJJNQ.js.map} +0 -0
  522. /package/dist/chunks/{chunk-QVUF2FSM.js.map → chunk-W3QW6SK6.js.map} +0 -0
  523. /package/dist/chunks/{chunk-P5UUY56J.js.map → chunk-W4EKIBRD.js.map} +0 -0
  524. /package/dist/chunks/{chunk-SC3GK5QC.js.map → chunk-WMWRRDO2.js.map} +0 -0
  525. /package/dist/chunks/{chunk-5TSOB5RI.js.map → chunk-WNBIAOXA.js.map} +0 -0
  526. /package/dist/chunks/{chunk-Q7NB7LRR.js.map → chunk-WQL7MEOD.js.map} +0 -0
  527. /package/dist/chunks/{chunk-335D56LG.js.map → chunk-X2LYTBDH.js.map} +0 -0
  528. /package/dist/chunks/{chunk-OLX3IUKN.js.map → chunk-X4TVUANR.js.map} +0 -0
  529. /package/dist/chunks/{chunk-EGRSUSP4.js.map → chunk-XBX3T6YY.js.map} +0 -0
  530. /package/dist/chunks/{chunk-Z4UCKCEQ.js.map → chunk-XC6G27M2.js.map} +0 -0
  531. /package/dist/chunks/{chunk-RXVJEZSV.js.map → chunk-XGH3FZ76.js.map} +0 -0
  532. /package/dist/chunks/{chunk-6GCYUKNK.js.map → chunk-XK7NQIZA.js.map} +0 -0
  533. /package/dist/chunks/{chunk-BHO3RAXS.js.map → chunk-XNMJLM5W.js.map} +0 -0
  534. /package/dist/chunks/{chunk-G5MD6XCV.js.map → chunk-XORYHNZ3.js.map} +0 -0
  535. /package/dist/chunks/{chunk-EW2YVKTN.js.map → chunk-XTMUUGTN.js.map} +0 -0
  536. /package/dist/chunks/{chunk-DO5JIP3I.js.map → chunk-Y36ZTLIJ.js.map} +0 -0
  537. /package/dist/chunks/{chunk-NUMKSEG4.js.map → chunk-YCPK5ZTB.js.map} +0 -0
  538. /package/dist/chunks/{chunk-HXINZ7D3.js.map → chunk-YRQ5PI7O.js.map} +0 -0
  539. /package/dist/chunks/{chunk-ORXNYBJU.js.map → chunk-YXR3LVZE.js.map} +0 -0
  540. /package/dist/chunks/{chunk-4ABPUIBF.js.map → chunk-YYGE5EWH.js.map} +0 -0
  541. /package/dist/chunks/{chunk-RJINNWMH.js.map → chunk-YZ6UKIKL.js.map} +0 -0
  542. /package/dist/chunks/{chunk-L45TVHRJ.js.map → chunk-Z75IWPPX.js.map} +0 -0
  543. /package/dist/chunks/{chunk-XNVZ6BPI.js.map → chunk-ZAQFM5BR.js.map} +0 -0
  544. /package/dist/chunks/{chunk-FDLXZRE4.js.map → chunk-ZDJWREOA.js.map} +0 -0
  545. /package/dist/chunks/{chunk-UGTDCLS5.js.map → chunk-ZKTDZOCC.js.map} +0 -0
  546. /package/dist/chunks/{chunk-QHJJ333E.js.map → chunk-ZQL7XFSE.js.map} +0 -0
  547. /package/dist/chunks/{cli-runtime-FK3WLEHC.js.map → cli-runtime-ZKBJFWOI.js.map} +0 -0
  548. /package/dist/chunks/{commands-UVEHHHUD.js.map → commands-3WI6F2YZ.js.map} +0 -0
  549. /package/dist/chunks/{computer-GABH2PJF.js.map → computer-WEEMTZUV.js.map} +0 -0
  550. /package/dist/chunks/{cost-S6LUVWMS.js.map → cost-557HKPZ4.js.map} +0 -0
  551. /package/dist/chunks/{crash-report-WSCK3UQK.js.map → crash-report-J47RFQ5T.js.map} +0 -0
  552. /package/dist/chunks/{desktop-host-schedule-tool-X5AYUZMV.js.map → desktop-host-schedule-tool-IOOJNMPQ.js.map} +0 -0
  553. /package/dist/chunks/{dist-WBDFP2PT.js.map → dist-665VSCM2.js.map} +0 -0
  554. /package/dist/chunks/{dist-NJJDM4QY.js.map → dist-AQO44B7K.js.map} +0 -0
  555. /package/dist/chunks/{dist-3GV6WNET.js.map → dist-D2RTUX7F.js.map} +0 -0
  556. /package/dist/chunks/{dist-BFD35FTG.js.map → dist-JLTZUUMS.js.map} +0 -0
  557. /package/dist/chunks/{dist-X7QK25WG.js.map → dist-L5C6AOXZ.js.map} +0 -0
  558. /package/dist/chunks/{dist-AAPFBZPA.js.map → dist-SEISKEDK.js.map} +0 -0
  559. /package/dist/chunks/{dist-XLMKK2FY.js.map → dist-VQVXULA5.js.map} +0 -0
  560. /package/dist/chunks/{doctor-CPX7KDGR.js.map → doctor-ZRPCR5DP.js.map} +0 -0
  561. /package/dist/chunks/{entry-KSTSU23A.js.map → entry-TPBKHAWV.js.map} +0 -0
  562. /package/dist/chunks/{extension-3YMXVKLS.js.map → extension-KJJ7XNR4.js.map} +0 -0
  563. /package/dist/chunks/{feed-66TKSG2Y.js.map → feed-LQNVF7M6.js.map} +0 -0
  564. /package/dist/chunks/{github-7JHAZZC3.js.map → github-LMMBAQWI.js.map} +0 -0
  565. /package/dist/chunks/{home-RJERCCZS.js.map → home-D7JCGXQE.js.map} +0 -0
  566. /package/dist/chunks/{homes-P5UAFUPZ.js.map → homes-EKTHOMXX.js.map} +0 -0
  567. /package/dist/chunks/{hooks-U2Z463DN.js.map → hooks-IT2ZUPG6.js.map} +0 -0
  568. /package/dist/chunks/{hooks-report-FIPQINVZ.js.map → hooks-report-A7F26EDM.js.map} +0 -0
  569. /package/dist/chunks/{host-IWAXBSUX.js.map → host-FS2RMOHW.js.map} +0 -0
  570. /package/dist/chunks/{host-queries-3IRCFZ74.js.map → host-queries-OJXR2XYT.js.map} +0 -0
  571. /package/dist/chunks/{installed-list-IBGMBHUJ.js.map → installed-list-27KYS56I.js.map} +0 -0
  572. /package/dist/chunks/{launch-UHLESLJC.js.map → launch-33I3O7VJ.js.map} +0 -0
  573. /package/dist/chunks/{learn-TQHDWYWB.js.map → learn-G5UEINB6.js.map} +0 -0
  574. /package/dist/chunks/{learn-builtin-2OY2YL6U.js.map → learn-builtin-Y5FIKQSV.js.map} +0 -0
  575. /package/dist/chunks/{lifecycle-ECBTALQV.js.map → lifecycle-NJQ7FIK2.js.map} +0 -0
  576. /package/dist/chunks/{list-GECT7X6E.js.map → list-UKBQESKU.js.map} +0 -0
  577. /package/dist/chunks/{live-LDWIFGRI.js.map → live-3YNFFWY5.js.map} +0 -0
  578. /package/dist/chunks/{load-LFCACQWA.js.map → load-KDS3CW6R.js.map} +0 -0
  579. /package/dist/chunks/{logs-55HJKNP6.js.map → logs-3XKNKFY2.js.map} +0 -0
  580. /package/dist/chunks/{mcp-XUKNYMSO.js.map → mcp-B2ZVGJQE.js.map} +0 -0
  581. /package/dist/chunks/{mcp-serve-XYNR3BNJ.js.map → mcp-serve-DH63SWUH.js.map} +0 -0
  582. /package/dist/chunks/{notes-TQTBT2ZZ.js.map → notes-ZCY7LTUD.js.map} +0 -0
  583. /package/dist/chunks/{open-CDLLQS4B.js.map → open-A4H4HWGO.js.map} +0 -0
  584. /package/dist/chunks/{operator-tools-XAFRSL26.js.map → operator-tools-EH6R2JQC.js.map} +0 -0
  585. /package/dist/chunks/{output-schema-5KOV6OJ6.js.map → output-schema-2NSAYRBS.js.map} +0 -0
  586. /package/dist/chunks/{pal-7XHBGZ4S.js.map → pal-EANL2OUH.js.map} +0 -0
  587. /package/dist/chunks/{peers-2MJG2EON.js.map → peers-H3ANL6XB.js.map} +0 -0
  588. /package/dist/chunks/{pending-4FM6EO26.js.map → pending-TRLAK2BR.js.map} +0 -0
  589. /package/dist/chunks/{proposals-BGOU7KAM.js.map → proposals-YB3YJOPW.js.map} +0 -0
  590. /package/dist/chunks/{providers-6PVAW2M3.js.map → providers-JA3AF524.js.map} +0 -0
  591. /package/dist/chunks/{providers-ZFUFVRRD.js.map → providers-LVD7T5JI.js.map} +0 -0
  592. /package/dist/chunks/{pty-3WHZDZXY.js.map → pty-66OF4YNF.js.map} +0 -0
  593. /package/dist/chunks/{resume-IQMUIIBO.js.map → resume-W4JBH2A7.js.map} +0 -0
  594. /package/dist/chunks/{resume-command-4VQ5ZTNJ.js.map → resume-command-J3VONMB5.js.map} +0 -0
  595. /package/dist/chunks/{running-QT5QIYNC.js.map → running-5GQPD6OM.js.map} +0 -0
  596. /package/dist/chunks/{say-JISSL5GL.js.map → say-7GQSUSTD.js.map} +0 -0
  597. /package/dist/chunks/{schedule-5VVP4D3W.js.map → schedule-LMXNNMAZ.js.map} +0 -0
  598. /package/dist/chunks/{send-F7EBK2UQ.js.map → send-Z35YQVV2.js.map} +0 -0
  599. /package/dist/chunks/{send-person-LHJCPCAT.js.map → send-person-TIM427ZP.js.map} +0 -0
  600. /package/dist/chunks/{servers-WVOZNOUM.js.map → servers-4QP7GKOK.js.map} +0 -0
  601. /package/dist/chunks/{service-7QGHSF2V.js.map → service-U244Z3VG.js.map} +0 -0
  602. /package/dist/chunks/{session-options-WW5IDZEZ.js.map → session-options-ODKOXNAT.js.map} +0 -0
  603. /package/dist/chunks/{setting-cli-AC5BEDWA.js.map → setting-cli-H5UKKB4F.js.map} +0 -0
  604. /package/dist/chunks/{skills-QQ74IBRB.js.map → skills-ELR2D7WU.js.map} +0 -0
  605. /package/dist/chunks/{source-deliveries-C2DRS4H6.js.map → source-deliveries-CI5K5DJQ.js.map} +0 -0
  606. /package/dist/chunks/{start-check-5L262F53.js.map → start-check-JYINXXEG.js.map} +0 -0
  607. /package/dist/chunks/{startup-failure-4PLTFEVA.js.map → startup-failure-G3HSW2U3.js.map} +0 -0
  608. /package/dist/chunks/{state-BTF5VEKZ.js.map → state-EDIR4EM2.js.map} +0 -0
  609. /package/dist/chunks/{store-OTVBA4G2.js.map → store-4HJUNR5E.js.map} +0 -0
  610. /package/dist/chunks/{store-RTWBXAKA.js.map → store-6SNBHHJA.js.map} +0 -0
  611. /package/dist/chunks/{store-WECWJFQV.js.map → store-ADMKKWZF.js.map} +0 -0
  612. /package/dist/chunks/{store-WOSPWPH2.js.map → store-IKXRGI2L.js.map} +0 -0
  613. /package/dist/chunks/{windows-home-VPSYQVOZ.js.map → windows-home-IZGCRSW7.js.map} +0 -0
  614. /package/dist/chunks/{workspaces-7DZS6QLA.js.map → workspaces-6KGOMHCM.js.map} +0 -0
  615. /package/dist/chunks/{worktree-XZ5Y74RZ.js.map → worktree-O7RSM3PC.js.map} +0 -0
@@ -15,7 +15,7 @@ import {
15
15
  selectAssistantText,
16
16
  toToolResultBlocks,
17
17
  toolResultToText
18
- } from "./chunk-KGCHR4TQ.js";
18
+ } from "./chunk-BBNACUZ3.js";
19
19
  import {
20
20
  __name
21
21
  } from "./chunk-76FLAFCG.js";
@@ -158,6 +158,145 @@ function servedSpeed(served, requested) {
158
158
  }
159
159
  __name(servedSpeed, "servedSpeed");
160
160
 
161
+ // ../providers/openai/dist/images.js
162
+ var CODEX_IMAGE_MODEL = "gpt-image-2";
163
+ var CODEX_DEFAULT_BASE_URL = "https://chatgpt.com/backend-api/codex";
164
+ var IMAGE_TURN_HEADER = "x-codex-image-turn-id";
165
+ var ACTIVE_LIMIT_HEADER = "x-codex-active-limit";
166
+ var CODEX_IMAGE_TIMEOUT_MS = 10 * 60 * 1e3;
167
+ var CODEX_IMAGE_MAX_BYTES = 32 * 1024 * 1024;
168
+ var CODEX_IMAGE_LIMIT_IDS = ["image_gen", "imagegen_premium"];
169
+ var CodexImagesError = class extends Error {
170
+ static {
171
+ __name(this, "CodexImagesError");
172
+ }
173
+ status;
174
+ usageLimit;
175
+ requestId;
176
+ constructor(message, details = {}) {
177
+ super(message);
178
+ this.name = "CodexImagesError";
179
+ if (details.status !== void 0)
180
+ this.status = details.status;
181
+ if (details.usageLimit !== void 0)
182
+ this.usageLimit = details.usageLimit;
183
+ if (details.requestId !== void 0)
184
+ this.requestId = details.requestId;
185
+ }
186
+ };
187
+ function asRecord(value) {
188
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
189
+ }
190
+ __name(asRecord, "asRecord");
191
+ function codexRequestHeaders(accountId) {
192
+ return {
193
+ ...attributionHeaders(),
194
+ "ChatGPT-Account-Id": accountId,
195
+ originator: "Codex Namzu",
196
+ "User-Agent": "Codex Namzu/1.0"
197
+ };
198
+ }
199
+ __name(codexRequestHeaders, "codexRequestHeaders");
200
+ function sniffImageType(bytes) {
201
+ const head = bytes.subarray(0, 6).toString("latin1");
202
+ return head === "GIF87a" || head === "GIF89a" ? "image/gif" : "image/png";
203
+ }
204
+ __name(sniffImageType, "sniffImageType");
205
+ function failureFrom(status, text, headers) {
206
+ const requestId = headers.get("x-codex-imagegen-request-id") ?? void 0;
207
+ let body = null;
208
+ try {
209
+ body = asRecord(JSON.parse(text));
210
+ } catch {
211
+ body = null;
212
+ }
213
+ const error = asRecord(body?.error);
214
+ const type = typeof error?.type === "string" ? error.type : void 0;
215
+ const message = typeof error?.message === "string" && error.message || text.trim().slice(0, 300) || "";
216
+ if (status === 429 && type === "usage_limit_reached") {
217
+ const limitId = headers.get(ACTIVE_LIMIT_HEADER) ?? void 0;
218
+ const seconds = typeof error?.resets_at === "number" ? error.resets_at : void 0;
219
+ return new CodexImagesError("The image quota of this plan is used up.", {
220
+ status,
221
+ usageLimit: {
222
+ ...limitId ? { limitId } : {},
223
+ ...seconds !== void 0 ? { resetsAt: seconds * 1e3 } : {}
224
+ },
225
+ ...requestId ? { requestId } : {}
226
+ });
227
+ }
228
+ return new CodexImagesError(`HTTP ${status}${message ? `: ${message}` : ""}`, {
229
+ status,
230
+ ...requestId ? { requestId } : {}
231
+ });
232
+ }
233
+ __name(failureFrom, "failureFrom");
234
+ async function requestCodexImage(config, request) {
235
+ const base = (config.baseURL ?? CODEX_DEFAULT_BASE_URL).replace(/\/+$/, "");
236
+ const editing = request.images !== void 0 && request.images.length > 0;
237
+ const url = `${base}/images/${editing ? "edits" : "generations"}`;
238
+ const body = {
239
+ prompt: request.prompt,
240
+ model: CODEX_IMAGE_MODEL,
241
+ quality: "auto",
242
+ size: "auto",
243
+ background: request.transparentBackground === true ? "transparent" : "opaque",
244
+ ...editing ? { images: request.images?.map((image_url) => ({ image_url })) } : {}
245
+ };
246
+ const timeout = AbortSignal.timeout(config.timeoutMs ?? CODEX_IMAGE_TIMEOUT_MS);
247
+ const signal = request.signal ? AbortSignal.any([request.signal, timeout]) : timeout;
248
+ const doFetch = config.fetch ?? fetch;
249
+ let response;
250
+ try {
251
+ response = await doFetch(url, {
252
+ method: "POST",
253
+ signal,
254
+ headers: {
255
+ ...codexRequestHeaders(config.accountId),
256
+ ...config.headers ?? {},
257
+ Authorization: `Bearer ${config.accessToken}`,
258
+ "Content-Type": "application/json",
259
+ Accept: "application/json",
260
+ ...request.turnId ? { [IMAGE_TURN_HEADER]: request.turnId } : {}
261
+ },
262
+ body: JSON.stringify(body)
263
+ });
264
+ } catch (error) {
265
+ if (request.signal?.aborted)
266
+ throw request.signal.reason ?? error;
267
+ if (timeout.aborted)
268
+ throw new CodexImagesError("The image request timed out.");
269
+ throw new CodexImagesError(`The image request could not be sent: ${error instanceof Error ? error.message : String(error)}`);
270
+ }
271
+ const text = await response.text();
272
+ if (!response.ok)
273
+ throw failureFrom(response.status, text, response.headers);
274
+ const requestId = response.headers.get("x-codex-imagegen-request-id") ?? void 0;
275
+ let parsed = null;
276
+ try {
277
+ parsed = asRecord(JSON.parse(text));
278
+ } catch {
279
+ throw new CodexImagesError("The image response could not be read.", { requestId });
280
+ }
281
+ const first = Array.isArray(parsed?.data) ? asRecord(parsed.data[0]) : null;
282
+ const encoded = typeof first?.b64_json === "string" ? first.b64_json : "";
283
+ if (encoded === "")
284
+ throw new CodexImagesError("The image service returned no image data.");
285
+ if (Math.ceil(encoded.length * 0.75) > CODEX_IMAGE_MAX_BYTES + 3)
286
+ throw new CodexImagesError("The generated image is larger than 32 MiB and was not kept.");
287
+ const bytes = Buffer.from(encoded, "base64");
288
+ if (bytes.length === 0)
289
+ throw new CodexImagesError("The image service returned no image data.");
290
+ if (bytes.length > CODEX_IMAGE_MAX_BYTES)
291
+ throw new CodexImagesError("The generated image is larger than 32 MiB and was not kept.");
292
+ return {
293
+ bytes,
294
+ mediaType: sniffImageType(bytes),
295
+ ...requestId ? { requestId } : {}
296
+ };
297
+ }
298
+ __name(requestCodexImage, "requestCodexImage");
299
+
161
300
  // ../providers/openai/dist/model-limits.js
162
301
  function asNumber(value) {
163
302
  if (typeof value === "number")
@@ -209,1535 +348,1512 @@ function subscriptionLimits(row) {
209
348
  }
210
349
  __name(subscriptionLimits, "subscriptionLimits");
211
350
 
212
- // ../providers/openai/dist/client.js
213
- var OPENAI_CAPABILITIES = {
214
- supportsNativeStructuredOutput: true,
351
+ // ../providers/openai/dist/codex.js
352
+ var CODEX_CAPABILITIES = {
353
+ supportsHostedWebSearch: true,
215
354
  supportsTools: true,
216
355
  supportsStreaming: true,
217
356
  supportsFunctionCalling: true,
357
+ supportsNativeStructuredOutput: true,
218
358
  supportsVision: true,
219
- supportsDocuments: true,
220
- supportsToolResultImages: false,
359
+ supportsDocuments: false,
360
+ supportsToolResultImages: true,
221
361
  supportsToolResultDocuments: false
222
362
  };
223
- var GPT_5_EFFORT = [
224
- "minimal",
225
- "low",
226
- "medium",
227
- "high"
228
- ];
229
- var GPT_5_1_EFFORT = [
230
- "none",
231
- "low",
232
- "medium",
233
- "high"
234
- ];
235
- var GPT_5_2_TO_5_5_EFFORT = [
236
- "none",
237
- "low",
238
- "medium",
239
- "high",
240
- "xhigh"
241
- ];
242
- var GPT_6_ASTRA_EFFORT = ["low", "medium", "high", "xhigh", "max"];
243
- var GPT_5_6_EFFORT = [
363
+ var DEFAULT_CODEX_BASE_URL = CODEX_DEFAULT_BASE_URL;
364
+ var KNOWN_EFFORT_LEVELS = [
244
365
  "none",
366
+ "minimal",
245
367
  "low",
246
368
  "medium",
247
369
  "high",
248
370
  "xhigh",
249
- "max"
371
+ "max",
372
+ "ultra"
250
373
  ];
251
- function openAIReasoningEffortLevels(model) {
252
- const normalized = model.toLowerCase();
253
- if (normalized === "gpt-6-astra")
254
- return GPT_6_ASTRA_EFFORT;
255
- if (/^gpt-5\.6(?:-(?:sol|terra|luna))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
256
- return GPT_5_6_EFFORT;
257
- }
258
- if (/^gpt-5\.5(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
259
- return GPT_5_2_TO_5_5_EFFORT;
260
- }
261
- if (/^gpt-5\.4(?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
262
- return GPT_5_2_TO_5_5_EFFORT;
263
- }
264
- if (/^gpt-5\.2(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
265
- return GPT_5_2_TO_5_5_EFFORT;
266
- }
267
- if (/^gpt-5\.1(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
268
- return GPT_5_1_EFFORT;
269
- }
270
- if (/^gpt-5(?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
271
- return GPT_5_EFFORT;
374
+ function subscriptionReasoningProfile(item) {
375
+ if (!Array.isArray(item.supported_reasoning_levels))
376
+ return void 0;
377
+ const levels = [];
378
+ for (const entry of item.supported_reasoning_levels) {
379
+ const effort = record(entry)?.effort;
380
+ if (typeof effort !== "string" || !KNOWN_EFFORT_LEVELS.includes(effort))
381
+ return void 0;
382
+ if (levels.includes(effort))
383
+ return void 0;
384
+ levels.push(effort);
272
385
  }
273
- return void 0;
386
+ const defaultLevel = item.default_reasoning_level;
387
+ return {
388
+ levels: Object.freeze(levels),
389
+ ...typeof defaultLevel === "string" && levels.includes(defaultLevel) ? { default: defaultLevel } : {}
390
+ };
274
391
  }
275
- __name(openAIReasoningEffortLevels, "openAIReasoningEffortLevels");
276
- function isOpenAIReasoningModel(model) {
277
- const normalized = model.toLowerCase();
278
- if (normalized === "gpt-6-astra")
279
- return true;
280
- if (/^(?:ft:)?gpt-5(?![a-z0-9])/.test(normalized))
281
- return !/-chat(?:-|$)/.test(normalized);
282
- return /^(?:ft:)?o\d/.test(normalized);
392
+ __name(subscriptionReasoningProfile, "subscriptionReasoningProfile");
393
+ function sameRoute(left, right) {
394
+ return left.providerId === right.providerId && left.model === right.model && left.chainIndex === right.chainIndex;
283
395
  }
284
- __name(isOpenAIReasoningModel, "isOpenAIReasoningModel");
285
- function needsResponsesForToolsWithReasoning(model) {
286
- return /^gpt-5\.6(?:-(?:sol|terra|luna))?(?:-\d{4}-\d{2}-\d{2})?$/.test(model.toLowerCase());
396
+ __name(sameRoute, "sameRoute");
397
+ function record(value) {
398
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
287
399
  }
288
- __name(needsResponsesForToolsWithReasoning, "needsResponsesForToolsWithReasoning");
289
- function assertToolsWithReasoningAllowed(model, params) {
290
- if (!params.tools || params.tools.length === 0)
291
- return;
292
- if (!needsResponsesForToolsWithReasoning(model))
293
- return;
294
- if (params.effort === "none" || params.thinking?.type === "disabled")
295
- return;
296
- throw new Error(`OpenAIProvider: model "${model}" does not take function tools together with reasoning on Chat Completions (it needs the Responses API, which this driver does not use with an API key). Set \`effort\` to "none" for this request, drop the tools, or choose another model.`);
400
+ __name(record, "record");
401
+ function isRoute(value) {
402
+ const route = record(value);
403
+ return typeof route?.providerId === "string" && typeof route.model === "string" && Number.isInteger(route.chainIndex) && route.chainIndex >= 0;
297
404
  }
298
- __name(assertToolsWithReasoningAllowed, "assertToolsWithReasoningAllowed");
299
- function isCompatibleHost(baseURL) {
300
- return !isFirstPartyOpenAIEndpoint(baseURL);
405
+ __name(isRoute, "isRoute");
406
+ function durableToolCalls(message) {
407
+ return (message.toolCalls ?? []).map((call) => ({
408
+ id: call.id,
409
+ name: call.function.name,
410
+ arguments: call.function.arguments
411
+ }));
301
412
  }
302
- __name(isCompatibleHost, "isCompatibleHost");
303
- function hostOf(baseURL) {
304
- if (!baseURL)
305
- return void 0;
306
- try {
307
- return new URL(baseURL).hostname;
308
- } catch {
309
- return void 0;
413
+ __name(durableToolCalls, "durableToolCalls");
414
+ function isCodexReplayState(value) {
415
+ const state = record(value);
416
+ if (state?.kind !== "namzu.codex.responses" || state.version !== 1 || !isRoute(state.route) || state.content !== null && typeof state.content !== "string" || !Array.isArray(state.toolCalls) || !Array.isArray(state.items)) {
417
+ return false;
310
418
  }
419
+ return state.toolCalls.every((item) => {
420
+ const call = record(item);
421
+ return typeof call?.id === "string" && typeof call.name === "string" && typeof call.arguments === "string";
422
+ });
311
423
  }
312
- __name(hostOf, "hostOf");
313
- var WINDOW_LISTING_TIMEOUT_MS = 3e3;
314
- var WINDOW_LISTING_RETRY_MS = 5 * 6e4;
315
- var EFFORT_VOCABULARY = [
316
- "none",
317
- "minimal",
318
- "low",
319
- "medium",
320
- "high",
321
- "xhigh",
322
- "max",
323
- "ultra"
324
- ];
325
- var INPUT_MODALITIES = ["text", "image", "document"];
326
- function asRecord(value) {
327
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
328
- }
329
- __name(asRecord, "asRecord");
330
- function ratePerMillion(value) {
331
- const perToken = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
332
- if (typeof perToken !== "number" || !Number.isFinite(perToken) || perToken < 0)
333
- return void 0;
334
- return Number((perToken * 1e6).toPrecision(12));
335
- }
336
- __name(ratePerMillion, "ratePerMillion");
337
- function inputModalitiesOf(row, capabilities) {
338
- if (capabilities?.vision === true)
339
- return ["text", "image"];
340
- if (capabilities?.vision === false)
341
- return ["text"];
342
- const declared = row.input_modalities ?? asRecord(row.architecture)?.input_modalities ?? // A plain `modalities` list is read for a chat model only: on another task it may name outputs.
343
- (row.task === void 0 || row.task === "chat" ? row.modalities : void 0);
344
- if (!Array.isArray(declared))
345
- return void 0;
346
- const known = INPUT_MODALITIES.filter((kind) => declared.includes(kind));
347
- return known.length > 0 ? known : void 0;
424
+ __name(isCodexReplayState, "isCodexReplayState");
425
+ function replayItems(message, targetRoute) {
426
+ const source = message.source;
427
+ if (!source || source.type !== "model" || !sameRoute(source, targetRoute))
428
+ return null;
429
+ const state = source.replayState;
430
+ if (!isCodexReplayState(state) || !sameRoute(state.route, source))
431
+ return null;
432
+ if (state.content !== message.content)
433
+ return null;
434
+ if (state.textParts !== void 0 && JSON.stringify(state.textParts) !== JSON.stringify(message.textParts))
435
+ return null;
436
+ if (JSON.stringify(state.toolCalls) !== JSON.stringify(durableToolCalls(message)))
437
+ return null;
438
+ return state.items;
348
439
  }
349
- __name(inputModalitiesOf, "inputModalitiesOf");
350
- function compatibleModelMetadata(model) {
351
- const row = asRecord(model) ?? {};
352
- const capabilities = asRecord(row.capabilities);
353
- const result = {};
354
- const contextWindow = declaredContextWindow(row);
355
- if (contextWindow !== void 0)
356
- result.contextWindow = contextWindow;
357
- const maxOutputTokens = firstCount(row, ["maximum_output_tokens", "max_output_tokens", "max_completion_tokens"]) ?? firstCount(asRecord(row.top_provider), ["max_completion_tokens"]);
358
- if (maxOutputTokens !== void 0)
359
- result.maxOutputTokens = maxOutputTokens;
360
- const inputModalities = inputModalitiesOf(row, capabilities);
361
- if (inputModalities !== void 0)
362
- result.inputModalities = inputModalities;
363
- if (capabilities?.tools === false)
364
- result.supportsToolUse = false;
365
- const pricing = asRecord(row.pricing);
366
- const currency = typeof pricing?.currency === "string" ? pricing.currency.toUpperCase() : void 0;
367
- if (pricing && (currency === void 0 || currency === "USD")) {
368
- const input = ratePerMillion(pricing.prompt);
369
- const output = ratePerMillion(pricing.completion);
370
- if (input !== void 0)
371
- result.inputPrice = input;
372
- if (output !== void 0)
373
- result.outputPrice = output;
374
- }
375
- let offered = Array.isArray(row.supported_reasoning_efforts) ? row.supported_reasoning_efforts : void 0;
376
- if (offered === void 0 && Array.isArray(capabilities?.reasoning_effort_values)) {
377
- const aliases = asRecord(capabilities.reasoning_effort_aliases);
378
- offered = [.../* @__PURE__ */ new Set([...capabilities.reasoning_effort_values, ...Object.keys(aliases ?? {})])];
379
- }
380
- const menu = offered !== void 0 && new Set(offered).size === offered.length && offered.every((level) => typeof level === "string" && EFFORT_VOCABULARY.includes(level)) ? offered : void 0;
381
- if (menu) {
382
- result.reasoningEffortLevels = [...menu];
383
- const defaultEffort = row.reasoning_effort;
384
- if (typeof defaultEffort === "string" && menu.includes(defaultEffort))
385
- result.reasoningEffortDefault = defaultEffort;
386
- } else if (offered === void 0 && capabilities?.reasoning_effort === false) {
387
- result.reasoningEffortLevels = [];
440
+ __name(replayItems, "replayItems");
441
+ var IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp", "image/gif"]);
442
+ var TOOL_RESULT_IMAGE_DETAIL = "high";
443
+ function codexImage(data, mediaType, source) {
444
+ if (!IMAGE_MEDIA_TYPES.has(mediaType)) {
445
+ throw new Error(`CodexProvider: ${source} image type '${mediaType}' is not supported. Use image/png, image/jpeg, image/webp, or image/gif.`);
388
446
  }
389
- return result;
390
- }
391
- __name(compatibleModelMetadata, "compatibleModelMetadata");
392
- function assertOpenAIReasoningEffort(model, effort) {
393
- if (effort === void 0)
394
- return;
395
- const supported = openAIReasoningEffortLevels(model);
396
- if (supported === void 0 || supported.includes(effort))
397
- return;
398
- throw new Error(`OpenAIProvider: effort "${effort}" is not supported by model "${model}". Supported levels: ${supported.join(", ")}. Choose one of those levels or omit \`effort\`.`);
399
- }
400
- __name(assertOpenAIReasoningEffort, "assertOpenAIReasoningEffort");
401
- function withReasoningEffort(request, effort) {
402
- if (effort === void 0)
403
- return request;
404
447
  return {
405
- ...request,
406
- reasoning_effort: effort
448
+ type: "input_image",
449
+ detail: source === "tool result" ? TOOL_RESULT_IMAGE_DETAIL : "auto",
450
+ image_url: `data:${mediaType};base64,${data}`
407
451
  };
408
452
  }
409
- __name(withReasoningEffort, "withReasoningEffort");
410
- function mapFinishReason(reason) {
411
- switch (reason) {
412
- case "length":
413
- return "length";
414
- case "tool_calls":
415
- case "function_call":
416
- return "tool_calls";
417
- case "content_filter":
418
- return "content_filter";
419
- default:
420
- return "stop";
453
+ __name(codexImage, "codexImage");
454
+ function codexUserContent(message) {
455
+ const attachments = message.attachments ?? [];
456
+ if (attachments.length === 0)
457
+ return message.content;
458
+ const content = [];
459
+ if (message.content.length > 0)
460
+ content.push({ type: "input_text", text: message.content });
461
+ for (const attachment of attachments) {
462
+ if (attachment.type === "stored") {
463
+ throw new Error("CodexProvider: an unresolved stored attachment reached the driver. Configure an AttachmentStore so Namzu can resolve its bytes before the model request.");
464
+ }
465
+ if (attachment.type === "document") {
466
+ throw new Error("CodexProvider: this subscription transport does not support document input. Route the turn to a document-capable provider.");
467
+ }
468
+ if (attachment.modelOmission) {
469
+ throw new Error("CodexProvider: an image marked for model omission reached the driver without request projection.");
470
+ }
471
+ content.push(codexImage(attachment.data, attachment.mediaType, "user attachment"));
421
472
  }
473
+ return content;
422
474
  }
423
- __name(mapFinishReason, "mapFinishReason");
424
- function parseUsage(raw, servedTier, requestedSpeed) {
425
- if (!raw) {
426
- return {
427
- promptTokens: 0,
428
- completionTokens: 0,
429
- totalTokens: 0,
430
- cachedTokens: 0,
431
- cacheWriteTokens: 0
475
+ __name(codexUserContent, "codexUserContent");
476
+ function codexToolOutput(content) {
477
+ if (typeof content === "string")
478
+ return content;
479
+ if (content.length === 0)
480
+ return "";
481
+ const output = [];
482
+ for (const block of toToolResultBlocks(content)) {
483
+ if (block.type === "text") {
484
+ output.push({ type: "input_text", text: block.text });
485
+ continue;
486
+ }
487
+ if (block.type === "document") {
488
+ throw new Error("CodexProvider: this subscription transport does not support document tool results. Route the turn to a provider whose tool-result wire admits documents.");
489
+ }
490
+ if (block.modelOmission) {
491
+ throw new Error("CodexProvider: a tool image marked for model omission reached the driver without request projection.");
492
+ }
493
+ output.push(codexImage(block.data, block.mediaType, "tool result"));
494
+ }
495
+ return output;
496
+ }
497
+ __name(codexToolOutput, "codexToolOutput");
498
+ function toCodexInput(messages, targetRoute, openingSystemRun = messages.findIndex((message) => message.role !== "system"), laterSystemRole = "developer") {
499
+ const input = [];
500
+ const opening = openingSystemRun < 0 ? messages.length : openingSystemRun;
501
+ for (const [at, message] of messages.entries()) {
502
+ if (message.role === "system") {
503
+ if (at >= opening && message.content) {
504
+ input.push({ type: "message", role: laterSystemRole, content: message.content });
505
+ }
506
+ continue;
507
+ }
508
+ if (message.role === "user") {
509
+ input.push({
510
+ type: "message",
511
+ role: "user",
512
+ content: codexUserContent(message)
513
+ });
514
+ continue;
515
+ }
516
+ if (message.role === "tool") {
517
+ input.push({
518
+ type: "function_call_output",
519
+ call_id: message.toolCallId,
520
+ output: codexToolOutput(message.content)
521
+ });
522
+ continue;
523
+ }
524
+ const replayed = replayItems(message, targetRoute);
525
+ if (replayed) {
526
+ input.push(...replayed);
527
+ continue;
528
+ }
529
+ if (message.content) {
530
+ input.push({
531
+ type: "message",
532
+ role: "assistant",
533
+ content: message.content
534
+ });
535
+ }
536
+ for (const call of message.toolCalls ?? []) {
537
+ input.push({
538
+ type: "function_call",
539
+ call_id: call.id,
540
+ name: call.function.name,
541
+ arguments: call.function.arguments
542
+ });
543
+ }
544
+ }
545
+ return input;
546
+ }
547
+ __name(toCodexInput, "toCodexInput");
548
+ function toCodexTools(params, apiKey = false) {
549
+ const tools = (params.tools ?? []).map((tool) => ({
550
+ type: "function",
551
+ name: tool.function.name,
552
+ description: tool.function.description ?? "",
553
+ parameters: tool.function.parameters ?? {},
554
+ // The ChatGPT Codex backend validates `strict: true` against a narrower
555
+ // Responses schema than the Chat Completions endpoint. In particular,
556
+ // every composition branch needs an explicit type and every object
557
+ // property must also be required. Namzu model schemas deliberately keep
558
+ // conditional edit shapes optional and validate the selected shape at
559
+ // execution, so claiming strictness rejects the whole request before the
560
+ // model can answer. The Codex client uses the same boundary for its own
561
+ // tools: Responses function tools are sent with `strict: false` and tool
562
+ // inputs are validated by the runtime. `enforceToolInputSchema` remains a
563
+ // provider hint; this transport cannot truthfully consume it for Namzu's
564
+ // general tool-schema contract.
565
+ strict: false
566
+ }));
567
+ if (params.webSearch) {
568
+ if (params.webSearch.mode !== "live" && params.webSearch.mode !== "cached")
569
+ throw new Error("Invalid web search mode.");
570
+ const hosted = {
571
+ type: "web_search",
572
+ // The public API takes the plain tool; the access switch is a subscription-wire field.
573
+ ...apiKey ? {} : { external_web_access: params.webSearch.mode === "live" }
432
574
  };
575
+ tools.push(hosted);
433
576
  }
434
- const promptTokens = raw.prompt_tokens ?? 0;
435
- const completionTokens = raw.completion_tokens ?? 0;
577
+ return tools.length ? tools : void 0;
578
+ }
579
+ __name(toCodexTools, "toCodexTools");
580
+ function responseUsage(usage, servedTier, requestedSpeed, requestShape) {
581
+ const promptTokens = usage.input_tokens ?? 0;
582
+ const completionTokens = usage.output_tokens ?? 0;
436
583
  return {
437
584
  promptTokens,
438
585
  completionTokens,
439
- totalTokens: raw.total_tokens ?? promptTokens + completionTokens,
440
- cachedTokens: raw.prompt_tokens_details?.cached_tokens ?? 0,
586
+ totalTokens: usage.total_tokens ?? promptTokens + completionTokens,
587
+ cachedTokens: usage.input_tokens_details?.cached_tokens ?? 0,
441
588
  cacheWriteTokens: 0,
442
- ...servedSpeed(servedTier, requestedSpeed)
589
+ ...servedSpeed(servedTier, requestedSpeed),
590
+ ...requestShape ? { requestShape } : {}
443
591
  };
444
592
  }
445
- __name(parseUsage, "parseUsage");
446
- function formatToolChoice(tc) {
447
- if (tc === void 0)
448
- return void 0;
449
- if (tc === "auto" || tc === "none" || tc === "required")
450
- return tc;
451
- if (typeof tc === "object" && tc.type === "function") {
452
- return { type: "function", function: { name: tc.function.name } };
593
+ __name(responseUsage, "responseUsage");
594
+ function subscriptionSpeedTiers(item) {
595
+ const tiers = /* @__PURE__ */ new Set();
596
+ const note = /* @__PURE__ */ __name((id) => {
597
+ if (id === "priority" || id === "fast")
598
+ tiers.add("fast");
599
+ else if (id === "ultrafast")
600
+ tiers.add("ultrafast");
601
+ }, "note");
602
+ if (Array.isArray(item.service_tiers)) {
603
+ for (const entry of item.service_tiers)
604
+ note(record(entry)?.id);
453
605
  }
454
- return void 0;
455
- }
456
- __name(formatToolChoice, "formatToolChoice");
457
- function assertThinkingSupported(params) {
458
- assertThinkingUnsupported("OpenAIProvider", { thinking: params.thinking });
459
- }
460
- __name(assertThinkingSupported, "assertThinkingSupported");
461
- function assertCitationsSupported(attachment, index) {
462
- if (!attachment.citations)
463
- return;
464
- const which = attachment.name ?? `attachment ${index}`;
465
- throw new Error(`This provider cannot return citations, and ${which} asked for them. Drop \`citations\` to send the document without them, or use a provider whose capabilities include citation support.`);
606
+ if (Array.isArray(item.additional_speed_tiers)) {
607
+ for (const entry of item.additional_speed_tiers)
608
+ note(entry);
609
+ }
610
+ return ["fast", "ultrafast"].filter((tier) => tiers.has(tier));
466
611
  }
467
- __name(assertCitationsSupported, "assertCitationsSupported");
468
- function toOpenAIMessages(messages) {
469
- const converted = messages.map((msg) => {
470
- if (msg.role === "system") {
471
- return { role: "system", content: msg.content };
472
- }
473
- if (msg.role === "user") {
474
- if (msg.attachments && msg.attachments.length > 0) {
475
- const parts = [];
476
- if (msg.content.length > 0) {
477
- parts.push({ type: "text", text: msg.content });
478
- }
479
- for (const [index, att] of msg.attachments.entries()) {
480
- if (att.type === "document") {
481
- assertCitationsSupported(att, index);
482
- parts.push({
483
- type: "file",
484
- file: {
485
- file_data: `data:${att.mediaType};base64,${att.data}`,
486
- ...att.name ? { filename: att.name } : {}
487
- }
488
- });
489
- continue;
490
- }
491
- if (att.type === "stored") {
492
- throw new Error(`A stored attachment ("${att.ref}") reached the driver unresolved. Resolve it against the run's attachment store before sending.`);
493
- }
494
- parts.push({
495
- type: "image_url",
496
- image_url: { url: `data:${att.mediaType};base64,${att.data}` }
497
- });
498
- }
499
- return { role: "user", content: parts };
612
+ __name(subscriptionSpeedTiers, "subscriptionSpeedTiers");
613
+ function buildRequest(params, model, targetRoute, supportedEffort, downgrade = NO_DOWNGRADE, apiKey = false) {
614
+ if (params.effort !== void 0 && supportedEffort !== void 0 && !supportedEffort.includes(params.effort)) {
615
+ throw new Error(`CodexProvider: effort "${params.effort}" is not supported by model "${model}". Supported levels: ${supportedEffort.join(", ")}. Choose one of those levels or omit \`effort\`.`);
616
+ }
617
+ if (params.thinking?.type === "enabled") {
618
+ throw new Error("CodexProvider: manual thinking budgets are not a Responses API capability. Use adaptive thinking or omit `thinking`.");
619
+ }
620
+ if (params.thinking?.type === "disabled" && params.effort !== "none") {
621
+ throw new Error('CodexProvider: disabling reasoning requires `effort: "none"`; omitting that level would not prove reasoning was disabled.');
622
+ }
623
+ let openingRun = 0;
624
+ while (params.messages[openingRun]?.role === "system")
625
+ openingRun++;
626
+ const instructions = params.messages.slice(0, openingRun).map((message) => message.content).join("\n\n");
627
+ const request = {
628
+ model,
629
+ stream: true,
630
+ store: false,
631
+ instructions: instructions || void 0,
632
+ input: toCodexInput(params.messages, targetRoute, openingRun, downgrade.noDeveloper ? "user" : "developer"),
633
+ // One key for the whole conversation routes every request to the same
634
+ // cache; without it the backend keys on the request alone.
635
+ ...params.cacheKey && !downgrade.noCacheKey ? { prompt_cache_key: params.cacheKey } : {},
636
+ // An API key reaches the public Responses endpoint, which has the member and
637
+ // is told the budget the caller set.
638
+ ...apiKey && params.maxTokens !== void 0 ? { max_output_tokens: params.maxTokens } : {},
639
+ // The Codex subscription request schema deliberately has no
640
+ // `max_output_tokens` member. `ChatCompletionParams.maxTokens` is a public
641
+ // API control, but projecting it onto this route makes the whole request
642
+ // invalid; the backend owns the output budget here.
643
+ // The subscription Responses backend expects these three fields even for a
644
+ // turn that exposes no tools. The ordinary public Responses endpoint admits
645
+ // their omission, which is why the generated client types all make them
646
+ // optional; the Codex wire does not have the same defaulting contract.
647
+ tools: toCodexTools(params, apiKey) ?? [],
648
+ tool_choice: params.toolChoice ?? "auto",
649
+ parallel_tool_calls: params.parallelToolCalls ?? true,
650
+ include: ["reasoning.encrypted_content"],
651
+ ...params.responseFormat ? {
652
+ text: {
653
+ format: params.responseFormat.type === "json_schema" ? { type: "json_schema", ...params.responseFormat.json_schema } : { type: "json_object" }
500
654
  }
501
- return { role: "user", content: msg.content };
502
- }
503
- if (msg.role === "tool") {
504
- return {
505
- role: "tool",
506
- // Tool messages are text-only on this wire, so a content block
507
- // degrades to an honest placeholder rather than having its
508
- // base64 payload dumped as text.
509
- content: toolResultToText(msg.content),
510
- tool_call_id: msg.toolCallId
511
- };
512
- }
513
- const assistant = {
514
- role: "assistant",
515
- content: msg.content
516
- };
517
- if ("toolCalls" in msg && msg.toolCalls && msg.toolCalls.length > 0) {
518
- ;
519
- assistant.tool_calls = msg.toolCalls.map((tc) => ({
520
- id: tc.id,
521
- type: "function",
522
- function: {
523
- name: tc.function.name,
524
- arguments: tc.function.arguments
525
- }
526
- }));
527
- }
528
- return assistant;
529
- });
530
- return converted.filter((msg) => msg.role !== "assistant" || Boolean(msg.content) || (msg.tool_calls?.length ?? 0) > 0);
655
+ } : {},
656
+ ...params.effort !== void 0 ? { reasoning: { effort: params.effort, summary: "auto" } } : params.thinking?.type === "adaptive" ? { reasoning: { summary: "auto" } } : {}
657
+ };
658
+ return request;
531
659
  }
532
- __name(toOpenAIMessages, "toOpenAIMessages");
533
- function toOpenAITools(params) {
534
- if (!params.tools || params.tools.length === 0)
660
+ __name(buildRequest, "buildRequest");
661
+ var NO_DOWNGRADE = {
662
+ noDeveloper: false,
663
+ noSessionHeader: false,
664
+ noCacheKey: false
665
+ };
666
+ var subscriptionDowngrade = { ...NO_DOWNGRADE };
667
+ function refusedNewShape(error) {
668
+ if (typeof error !== "object" || error === null)
535
669
  return void 0;
536
- const enforced = new Set(params.enforceToolInputSchema ?? []);
537
- return params.tools.map((t) => ({
538
- type: "function",
539
- function: {
540
- name: t.function.name,
541
- description: t.function.description ?? "",
542
- parameters: t.function.parameters ?? {},
543
- ...enforced.has(t.function.name) && acceptsStrictSchema(t.function.parameters) ? { strict: true } : {}
544
- }
545
- }));
670
+ const status = error.status;
671
+ if (!(error instanceof OpenAI.BadRequestError) && status !== 400)
672
+ return void 0;
673
+ const message = error.message;
674
+ if (typeof message !== "string")
675
+ return void 0;
676
+ const refused = {};
677
+ if (/\bdeveloper\b|input\[\d*\]\.role/i.test(message))
678
+ refused.noDeveloper = true;
679
+ if (/session_id/i.test(message))
680
+ refused.noSessionHeader = true;
681
+ if (/prompt_cache_key/i.test(message))
682
+ refused.noCacheKey = true;
683
+ return Object.keys(refused).length > 0 ? refused : void 0;
546
684
  }
547
- __name(toOpenAITools, "toOpenAITools");
548
- var OpenAIProvider = class {
685
+ __name(refusedNewShape, "refusedNewShape");
686
+ var listingByAccount = /* @__PURE__ */ new Map();
687
+ var MODELS_CLIENT_VERSION = "1.0.0";
688
+ var WINDOW_LISTING_TIMEOUT_MS = 3e3;
689
+ var WINDOW_LISTING_RETRY_MS = 5 * 6e4;
690
+ var RESPONSES_API_BASE_URL = "https://api.openai.com/v1";
691
+ var CodexProvider = class {
549
692
  static {
550
- __name(this, "OpenAIProvider");
693
+ __name(this, "CodexProvider");
551
694
  }
552
- id = "openai";
553
- name = "OpenAI";
554
- capabilities = OPENAI_CAPABILITIES;
695
+ id;
696
+ name;
697
+ capabilities = CODEX_CAPABILITIES;
698
+ /** True when an API key (not a subscription) is the credential. */
699
+ apiKeyRoute;
555
700
  client;
556
701
  defaultModel;
557
- /** Whether requests go somewhere other than OpenAI's own API, which is where a model's window is worth asking for. */
558
- compatibleHost;
559
- /** The windows a compatible endpoint's last fulfilled listing declared, by model id. */
560
- declaredWindows;
561
- /** Before this time (ms since the epoch) a failed listing is not asked for again. */
702
+ reasoningProfiles = /* @__PURE__ */ new Map();
703
+ /** Per model, the speed tiers the account's listing offers. Absent until a listing has answered. */
704
+ speedTiers;
705
+ /** Per model, the window the account's listing states. Absent until a listing has answered. */
706
+ windows;
707
+ /** Per model, the compaction threshold the account's listing states or implies. */
708
+ compactLimits;
562
709
  windowListingRetryAt = 0;
563
- thinkingOffFields;
564
- /** The base URL requests go to, kept to name the host when fast mode is refused there. */
565
- effectiveBaseURL;
710
+ /** The listing in flight, shared by callers that arrive while it runs. */
711
+ windowListing;
712
+ listingKey;
566
713
  constructor(config) {
567
- if (!config.apiKey) {
568
- throw new Error("OpenAI API key is required. Set OPENAI_API_KEY env variable.");
714
+ if ("responsesApi" in config) {
715
+ if (!config.apiKey)
716
+ throw new Error("OpenAI API key is required.");
717
+ this.id = "openai";
718
+ this.name = "OpenAI";
719
+ this.apiKeyRoute = true;
720
+ this.client = new OpenAI({
721
+ apiKey: config.apiKey,
722
+ baseURL: config.baseURL ?? RESPONSES_API_BASE_URL,
723
+ ...config.organization ? { organization: config.organization } : {},
724
+ ...config.project ? { project: config.project } : {},
725
+ ...config.timeout !== void 0 ? { timeout: config.timeout } : {},
726
+ ...config.maxRetries !== void 0 ? { maxRetries: config.maxRetries } : {},
727
+ defaultHeaders: config.defaultHeaders ?? {}
728
+ });
729
+ this.defaultModel = config.model;
730
+ this.listingKey = "";
731
+ return;
569
732
  }
570
- const clientOptions = {
571
- apiKey: config.apiKey
572
- };
573
- if (config.baseURL)
574
- clientOptions.baseURL = config.baseURL;
575
- if (config.organization)
576
- clientOptions.organization = config.organization;
577
- if (config.project)
578
- clientOptions.project = config.project;
579
- if (config.timeout !== void 0)
580
- clientOptions.timeout = config.timeout;
581
- if (config.maxRetries !== void 0)
582
- clientOptions.maxRetries = config.maxRetries;
583
- clientOptions.defaultHeaders = {
584
- ...attributionHeaders(),
585
- ...config.defaultHeaders ?? {}
586
- };
587
- this.client = new OpenAI(clientOptions);
733
+ this.id = "codex";
734
+ this.name = "OpenAI Codex";
735
+ this.apiKeyRoute = false;
736
+ if (!config.accessToken)
737
+ throw new Error("Codex access token is required.");
738
+ if (!config.accountId)
739
+ throw new Error("Codex ChatGPT account id is required.");
740
+ this.client = new OpenAI({
741
+ apiKey: config.accessToken,
742
+ baseURL: config.baseURL ?? DEFAULT_CODEX_BASE_URL,
743
+ timeout: config.timeout,
744
+ ...config.maxRetries !== void 0 ? { maxRetries: config.maxRetries } : {},
745
+ defaultHeaders: {
746
+ ...codexRequestHeaders(config.accountId),
747
+ ...config.defaultHeaders ?? {}
748
+ }
749
+ });
588
750
  this.defaultModel = config.model;
589
- this.thinkingOffFields = config.thinkingOffFields;
590
- this.effectiveBaseURL = config.baseURL ?? process.env.OPENAI_BASE_URL;
591
- this.compatibleHost = isCompatibleHost(this.effectiveBaseURL);
751
+ this.listingKey = `${config.accountId}\0${config.baseURL ?? DEFAULT_CODEX_BASE_URL}`;
752
+ const known = listingByAccount.get(this.listingKey);
753
+ if (known) {
754
+ this.speedTiers = known.speedTiers;
755
+ this.reasoningProfiles = known.reasoningProfiles;
756
+ this.windows = known.windows;
757
+ this.compactLimits = known.compactLimits;
758
+ }
759
+ }
760
+ resolveModel(params) {
761
+ const model = params.model || this.defaultModel;
762
+ if (!model)
763
+ throw new Error("CodexProvider: model is required.");
764
+ return model;
765
+ }
766
+ reasoningEffortLevelsFor(model) {
767
+ return this.reasoningProfiles.get(model.toLowerCase())?.levels;
768
+ }
769
+ reasoningEffortDefaultFor(model) {
770
+ return this.reasoningProfiles.get(model.toLowerCase())?.default;
592
771
  }
593
772
  /**
594
- * The window the runtime measures compaction against, as a compatible endpoint's own model
595
- * listing declares it, or `undefined` when it declares none, which leaves the SDK's table to
596
- * answer. The table is a hand-kept guess by model name; an endpoint that serves a model knows
597
- * how long a prompt it takes. OpenAI's own API declares no window, so it is not asked.
773
+ * The speed tiers the account's listing offers for `model`. `undefined`
774
+ * until a listing has answered; once one has, a model it does not carry
775
+ * offers none.
776
+ */
777
+ speedTiersFor(model) {
778
+ if (this.speedTiers === void 0)
779
+ return void 0;
780
+ return this.speedTiers.get(model.toLowerCase()) ?? [];
781
+ }
782
+ /**
783
+ * The window the runtime measures compaction against, as the account's model listing states
784
+ * it (scaled by the effective-percent the listing sends, when it sends one), or `undefined`
785
+ * when the listing states none, which leaves the SDK's table to answer.
598
786
  *
599
- * The listing is asked once and a fulfilled one is kept. A failure is remembered for a few
600
- * minutes, so an endpoint with no usable listing is not asked at the start of every turn, and a
601
- * listing that hangs is cut short. Neither ever fails a turn.
787
+ * The listing is asked once per account and kept. A failure is remembered for a few minutes
788
+ * and a listing that hangs is cut short. Neither ever fails a turn; only the caller's own
789
+ * abort propagates.
602
790
  */
603
791
  async resolveContextWindow(model, signal) {
604
792
  signal?.throwIfAborted();
605
- if (!this.compatibleHost)
606
- return void 0;
607
- if (!this.declaredWindows) {
793
+ if (!this.windows) {
608
794
  if (Date.now() < this.windowListingRetryAt)
609
795
  return void 0;
610
- const controller = new AbortController();
611
- const forward = /* @__PURE__ */ __name(() => controller.abort(), "forward");
612
- signal?.addEventListener("abort", forward, { once: true });
613
- const timer = setTimeout(forward, WINDOW_LISTING_TIMEOUT_MS);
614
- try {
615
- const listed = await this.listModels(controller.signal);
616
- this.declaredWindows ??= new Map(listed.flatMap((entry) => entry.contextWindow !== void 0 ? [[entry.id, entry.contextWindow]] : []));
617
- } catch {
618
- signal?.throwIfAborted();
619
- this.windowListingRetryAt = Date.now() + WINDOW_LISTING_RETRY_MS;
620
- return void 0;
621
- } finally {
622
- clearTimeout(timer);
623
- signal?.removeEventListener("abort", forward);
624
- }
796
+ this.windowListing ??= this.listForWindow().finally(() => {
797
+ this.windowListing = void 0;
798
+ });
799
+ const abandoned = new Promise((_, reject) => {
800
+ if (signal?.aborted)
801
+ reject(signal.reason);
802
+ signal?.addEventListener("abort", () => reject(signal.reason), { once: true });
803
+ });
804
+ await Promise.race([this.windowListing, abandoned]);
805
+ signal?.throwIfAborted();
625
806
  }
626
- return this.declaredWindows.get(model);
807
+ return this.windows?.get(model.toLowerCase());
627
808
  }
628
- resolveModel(params) {
629
- const model = params.model || this.defaultModel;
630
- if (!model) {
631
- throw new Error("OpenAIProvider: model is required. Pass `model` in config or on the chat call.");
632
- }
633
- return model;
809
+ /**
810
+ * The token count the account's listing says compaction starts at for `model`: its
811
+ * `auto_compact_token_limit` held to 90% of the window, or 90% of the window when it sends
812
+ * none. Shares the one listing `resolveContextWindow` asks for, with the same bounds.
813
+ */
814
+ async resolveAutoCompactLimit(model, signal) {
815
+ await this.resolveContextWindow(model, signal);
816
+ return this.compactLimits?.get(model.toLowerCase());
634
817
  }
635
- reasoningEffortLevelsFor(model) {
636
- return openAIReasoningEffortLevels(model);
818
+ /** One bounded listing for every caller waiting on it; a failure is remembered, never thrown. */
819
+ async listForWindow() {
820
+ const controller = new AbortController();
821
+ const timer = setTimeout(() => controller.abort(), WINDOW_LISTING_TIMEOUT_MS);
822
+ try {
823
+ await this.listModels(controller.signal);
824
+ return true;
825
+ } catch {
826
+ this.windowListingRetryAt = Date.now() + WINDOW_LISTING_RETRY_MS;
827
+ return false;
828
+ } finally {
829
+ clearTimeout(timer);
830
+ }
637
831
  }
638
832
  async *chatStream(params) {
639
833
  const model = this.resolveModel(params);
640
- assertThinkingSupported(params);
641
- assertOpenAIReasoningEffort(model, params.effort);
642
- const reasoningModel = !this.compatibleHost && isOpenAIReasoningModel(model);
643
- if (!this.compatibleHost)
644
- assertToolsWithReasoningAllowed(model, params);
645
- const dropsSampling = reasoningModel && model.toLowerCase() !== "gpt-6-astra";
646
- const reasoningOff = params.effort === "none" || params.thinking?.type === "disabled";
647
- const offFields = reasoningOff ? typeof this.thinkingOffFields === "function" ? this.thinkingOffFields(model) : this.thinkingOffFields : void 0;
648
- let serviceTier;
649
- if (params.speed === "fast" || params.speed === "ultrafast") {
650
- const accepted = assertFastModeAccepted({
651
- route: "api",
652
- model,
653
- tier: params.speed,
654
- firstPartyEndpoint: !this.compatibleHost,
655
- host: hostOf(this.effectiveBaseURL)
834
+ const targetRoute = params.providerRoute ?? {
835
+ providerId: this.id,
836
+ model,
837
+ chainIndex: 0
838
+ };
839
+ const effortLevels = this.reasoningEffortLevelsFor(model);
840
+ const apiKey = this.apiKeyRoute;
841
+ const downgradeState = apiKey ? NO_DOWNGRADE : subscriptionDowngrade;
842
+ const built = buildRequest(params, model, targetRoute, effortLevels, downgradeState, apiKey);
843
+ const fast = params.speed === "fast" || params.speed === "ultrafast" ? assertFastModeAccepted({
844
+ route: apiKey ? "api" : "subscription",
845
+ model,
846
+ tier: params.speed,
847
+ advertised: apiKey ? void 0 : this.speedTiersFor(model),
848
+ firstPartyEndpoint: true
849
+ }) : void 0;
850
+ const withTier = /* @__PURE__ */ __name((body) => fast ? { ...body, service_tier: fast.wire } : body, "withTier");
851
+ const requestedSpeed = params.speed === "fast" || params.speed === "ultrafast" ? params.speed : void 0;
852
+ let wire = { cacheKey: false, sessionHeader: false };
853
+ const send = /* @__PURE__ */ __name((body, sessionHeader) => {
854
+ wire = {
855
+ cacheKey: Boolean(body.prompt_cache_key),
856
+ sessionHeader: Boolean(sessionHeader && params.cacheKey),
857
+ // Recorded from the downgrade state, not from the items built: a request
858
+ // with no guidance to send is not a refusal.
859
+ ...downgradeState.noDeveloper ? { developerRefused: true } : {}
860
+ };
861
+ return this.client.responses.create(withTier(body), {
862
+ signal: params.signal,
863
+ ...fast?.header || sessionHeader && params.cacheKey ? {
864
+ headers: {
865
+ ...fast?.header ?? {},
866
+ ...sessionHeader && params.cacheKey ? { session_id: params.cacheKey } : {}
867
+ }
868
+ } : {}
656
869
  });
657
- serviceTier = accepted.wire === "priority" ? "priority" : void 0;
658
- }
659
- const requestedSpeed = params.speed === "fast" ? "fast" : void 0;
870
+ }, "send");
660
871
  let stream;
661
872
  try {
662
- stream = await this.client.chat.completions.create(
663
- withReasoningEffort({
664
- model,
665
- messages: toOpenAIMessages(params.messages),
666
- stream: true,
667
- stream_options: { include_usage: true },
668
- tools: toOpenAITools(params),
669
- tool_choice: formatToolChoice(params.toolChoice),
670
- parallel_tool_calls: params.parallelToolCalls,
671
- ...dropsSampling ? {} : {
672
- temperature: params.temperature,
673
- top_p: params.topP,
674
- frequency_penalty: params.frequencyPenalty,
675
- presence_penalty: params.presencePenalty
676
- },
677
- ...reasoningModel ? { max_completion_tokens: params.maxTokens } : { max_tokens: params.maxTokens },
678
- stop: params.stop,
679
- response_format: params.responseFormat,
680
- ...serviceTier ? { service_tier: serviceTier } : {},
681
- ...offFields ?? {}
682
- }, params.effort),
683
- // Per-request abort: a Stop tears the in-flight SSE request down.
684
- { signal: params.signal }
685
- );
686
- } catch (err) {
687
- if (isCallerAbortError(err, params.signal))
688
- throw params.signal?.reason ?? err;
689
- if (isProviderRequestError(err))
690
- throw err;
691
- throw providerVendorError({ providerId: "openai", error: err });
873
+ try {
874
+ stream = await send(built, !apiKey && !subscriptionDowngrade.noSessionHeader);
875
+ } catch (error) {
876
+ const refused = refusedNewShape(error);
877
+ const newShapeSent = built.input !== void 0 && (Boolean(params.cacheKey) || Array.isArray(built.input) && built.input.some((item) => "role" in item && item.role === "developer"));
878
+ const fresh = refused && [
879
+ "noDeveloper",
880
+ "noSessionHeader",
881
+ "noCacheKey"
882
+ ].filter((key) => refused[key] && !subscriptionDowngrade[key]);
883
+ if (apiKey || !fresh || fresh.length === 0 || !newShapeSent || params.signal?.aborted)
884
+ throw error;
885
+ for (const key of fresh)
886
+ subscriptionDowngrade[key] = true;
887
+ stream = await send(buildRequest(params, model, targetRoute, effortLevels, subscriptionDowngrade, apiKey), !subscriptionDowngrade.noSessionHeader);
888
+ }
889
+ } catch (error) {
890
+ if (isCallerAbortError(error, params.signal))
891
+ throw params.signal?.reason ?? error;
892
+ if (isProviderRequestError(error))
893
+ throw error;
894
+ throw providerVendorError({ providerId: this.id, error });
692
895
  }
896
+ const callIndex = /* @__PURE__ */ new Map();
897
+ const completedItems = /* @__PURE__ */ new Map();
898
+ const textItems = /* @__PURE__ */ new Map();
899
+ let nextCallIndex = 0;
900
+ let responseId = "codex-response";
693
901
  let finished = false;
694
- let servedTier;
695
902
  try {
696
- for await (const chunk of stream) {
697
- const echoed = chunk.service_tier;
698
- if (typeof echoed === "string" && echoed.length > 0)
699
- servedTier = echoed;
903
+ for await (const event of stream) {
700
904
  params.signal?.throwIfAborted();
701
- try {
702
- const choice = chunk.choices[0];
703
- const delta = choice?.delta;
704
- const extra = delta;
705
- const emitted = typeof extra?.reasoning_content === "string" ? extra.reasoning_content : typeof extra?.reasoning === "string" ? extra.reasoning : void 0;
706
- const reasoning = reasoningOff ? void 0 : emitted;
707
- const toolCalls = delta?.tool_calls?.map((tc) => ({
708
- index: tc.index,
709
- id: tc.id,
710
- type: tc.type,
711
- function: tc.function ? {
712
- name: tc.function.name,
713
- arguments: tc.function.arguments
714
- } : void 0
715
- }));
716
- const hasDelta = delta?.content !== void 0 && delta.content !== null || reasoning !== void 0 && reasoning.length > 0 || toolCalls && toolCalls.length > 0;
717
- const finishReason = choice?.finish_reason ? mapFinishReason(choice.finish_reason) : void 0;
718
- const usage = chunk.usage ? parseUsage(chunk.usage, servedTier, requestedSpeed) : void 0;
719
- if (finishReason)
720
- finished = true;
721
- if (!hasDelta && !finishReason && !usage)
722
- continue;
723
- yield {
724
- id: chunk.id,
725
- delta: {
726
- content: delta?.content ?? void 0,
727
- ...reasoning ? {
905
+ switch (event.type) {
906
+ case "response.created":
907
+ responseId = event.response.id;
908
+ break;
909
+ case "response.output_text.delta": {
910
+ const textPart = textItems.get(event.item_id);
911
+ yield {
912
+ id: responseId,
913
+ delta: {
914
+ content: event.delta,
915
+ ...textPart ? { textPart } : {}
916
+ }
917
+ };
918
+ break;
919
+ }
920
+ case "response.reasoning_summary_text.delta":
921
+ yield {
922
+ id: responseId,
923
+ delta: {
728
924
  reasoning: {
729
- index: 0,
925
+ index: event.output_index,
730
926
  type: "thinking",
731
- text: reasoning
927
+ text: event.delta
732
928
  }
733
- } : {},
734
- toolCalls
735
- },
736
- finishReason,
737
- // A content filter stopped the reply; the API says nothing more.
738
- ...finishReason === "content_filter" ? { refusal: {} } : {},
739
- usage
740
- };
741
- } catch (parseErr) {
742
- if (isProviderRequestError(parseErr))
743
- throw parseErr;
744
- throw new ProviderRequestError({
745
- kind: "server",
746
- providerId: "openai",
747
- detail: "the provider stream returned malformed data"
748
- });
749
- }
750
- }
751
- if (!finished) {
752
- throw new ProviderRequestError({
753
- kind: "network",
754
- providerId: "openai",
755
- detail: "the connection closed before the response finished"
756
- });
757
- }
758
- } catch (err) {
759
- if (isCallerAbortError(err, params.signal))
760
- throw params.signal?.reason ?? err;
761
- if (isProviderRequestError(err))
762
- throw err;
763
- throw providerVendorError({ providerId: "openai", error: err });
764
- }
765
- }
766
- /**
767
- * Declared even though this driver's listing already fails correctly on a
768
- * bad key. The check is a declared capability rather than something inferred
769
- * from whether a menu happened to throw, so a driver that answers the
770
- * question has to say so — otherwise it is reported unverifiable, which is
771
- * the honest default and would be a regression here.
772
- */
773
- async probeCredential(signal) {
774
- signal?.throwIfAborted();
775
- await this.client.models.list(signal ? { signal } : void 0);
776
- signal?.throwIfAborted();
777
- }
778
- async listModels(signal) {
779
- signal?.throwIfAborted();
780
- const page = await this.client.models.list(signal ? { signal } : void 0);
781
- signal?.throwIfAborted();
782
- return page.data.map((m) => ({
783
- id: m.id,
784
- name: m.id,
785
- supportsToolUse: true,
786
- supportsStreaming: true,
787
- ...compatibleModelMetadata(m)
788
- }));
929
+ }
930
+ };
931
+ break;
932
+ case "response.reasoning_summary_text.done":
933
+ yield {
934
+ id: responseId,
935
+ delta: {
936
+ reasoning: {
937
+ index: event.output_index,
938
+ type: "thinking",
939
+ done: true
940
+ }
941
+ }
942
+ };
943
+ break;
944
+ case "response.output_item.added":
945
+ if (event.item.type === "message" && (event.item.phase === "commentary" || event.item.phase === "final_answer"))
946
+ textItems.set(event.item.id, {
947
+ id: event.item.id,
948
+ phase: event.item.phase
949
+ });
950
+ if (event.item.type === "web_search_call") {
951
+ yield {
952
+ id: responseId,
953
+ delta: {
954
+ hostedTool: {
955
+ id: event.item.id,
956
+ name: "web_search",
957
+ status: "running",
958
+ ...webSearchDetail(event.item)
959
+ }
960
+ }
961
+ };
962
+ }
963
+ if (event.item.type === "function_call") {
964
+ const index = nextCallIndex++;
965
+ callIndex.set(event.item.id ?? event.item.call_id, index);
966
+ callIndex.set(event.item.call_id, index);
967
+ yield {
968
+ id: responseId,
969
+ delta: {
970
+ toolCalls: [
971
+ {
972
+ index,
973
+ id: event.item.call_id,
974
+ type: "function",
975
+ function: {
976
+ name: event.item.name,
977
+ arguments: event.item.arguments
978
+ }
979
+ }
980
+ ]
981
+ }
982
+ };
983
+ }
984
+ break;
985
+ case "response.function_call_arguments.delta": {
986
+ const index = callIndex.get(event.item_id) ?? event.output_index;
987
+ yield {
988
+ id: responseId,
989
+ delta: {
990
+ toolCalls: [{ index, function: { arguments: event.delta } }]
991
+ }
992
+ };
993
+ break;
994
+ }
995
+ case "response.output_item.done":
996
+ completedItems.set(event.output_index, event.item);
997
+ if (event.item.type === "web_search_call") {
998
+ yield {
999
+ id: responseId,
1000
+ delta: {
1001
+ hostedTool: {
1002
+ id: event.item.id,
1003
+ name: "web_search",
1004
+ status: event.item.status === "completed" ? "completed" : "failed",
1005
+ ...webSearchDetail(event.item)
1006
+ }
1007
+ }
1008
+ };
1009
+ }
1010
+ if (event.item.type === "function_call") {
1011
+ yield {
1012
+ id: responseId,
1013
+ delta: {
1014
+ toolCallEnd: {
1015
+ index: callIndex.get(event.item.id ?? event.item.call_id) ?? event.output_index,
1016
+ id: event.item.call_id
1017
+ }
1018
+ }
1019
+ };
1020
+ }
1021
+ break;
1022
+ case "response.completed": {
1023
+ const output = event.response.output?.length ? event.response.output : [...completedItems].sort(([left], [right]) => left - right).map(([, item]) => item);
1024
+ const calls = output.filter((item) => item.type === "function_call").map((item) => ({
1025
+ id: item.call_id,
1026
+ name: item.name,
1027
+ arguments: item.arguments
1028
+ }));
1029
+ const textParts = output.filter((item) => item.type === "message").map((item) => ({
1030
+ id: item.id,
1031
+ ...item.phase === "commentary" || item.phase === "final_answer" ? { phase: item.phase } : {},
1032
+ text: item.content.filter((part) => part.type === "output_text").map((part) => part.text).join("")
1033
+ }));
1034
+ const phased = textParts.some((part) => part.phase !== void 0);
1035
+ let content = phased ? selectAssistantText(textParts) : textParts.map((part) => part.text).join("");
1036
+ const sources = /* @__PURE__ */ new Map();
1037
+ for (const item of output) {
1038
+ if (item.type !== "message")
1039
+ continue;
1040
+ for (const part of item.content) {
1041
+ if (part.type !== "output_text")
1042
+ continue;
1043
+ for (const annotation of part.annotations ?? []) {
1044
+ if (annotation.type === "url_citation" && /^https?:\/\//i.test(annotation.url) && !content.includes(annotation.url)) {
1045
+ sources.set(annotation.url, annotation.title);
1046
+ }
1047
+ }
1048
+ }
1049
+ }
1050
+ if (sources.size) {
1051
+ const links = [...sources].map(([url, title]) => `[${title.replace(/[\[\]\r\n]/g, " ")}](<${url.replace(/[<>\s]/g, (c) => encodeURIComponent(c))}>)`).join(" \xB7 ");
1052
+ const suffix = `
1053
+
1054
+ Sources: ${links}`;
1055
+ content += suffix;
1056
+ let partIndex = textParts.length - 1;
1057
+ for (let i = textParts.length - 1; i >= 0; i--) {
1058
+ if (textParts[i]?.phase === "final_answer") {
1059
+ partIndex = i;
1060
+ break;
1061
+ }
1062
+ }
1063
+ const part = textParts[partIndex];
1064
+ if (part)
1065
+ textParts[partIndex] = { ...part, text: part.text + suffix };
1066
+ yield {
1067
+ id: responseId,
1068
+ delta: { content: suffix, contentOrigin: "driver" }
1069
+ };
1070
+ }
1071
+ const replayState = {
1072
+ kind: "namzu.codex.responses",
1073
+ version: 1,
1074
+ route: targetRoute,
1075
+ content: content || null,
1076
+ ...phased ? { textParts } : {},
1077
+ toolCalls: calls,
1078
+ items: output
1079
+ };
1080
+ finished = true;
1081
+ yield {
1082
+ id: event.response.id,
1083
+ delta: {},
1084
+ ...phased ? { textParts } : {},
1085
+ finishReason: calls.length > 0 ? "tool_calls" : "stop",
1086
+ usage: responseUsage(event.response.usage ?? {}, event.response.service_tier, requestedSpeed, wire),
1087
+ replayState
1088
+ };
1089
+ break;
1090
+ }
1091
+ case "response.incomplete": {
1092
+ const reason = event.response.incomplete_details?.reason;
1093
+ finished = true;
1094
+ yield {
1095
+ id: event.response.id,
1096
+ delta: {},
1097
+ finishReason: reason === "content_filter" ? "content_filter" : "length",
1098
+ ...reason === "content_filter" ? { refusal: {} } : {},
1099
+ usage: responseUsage(event.response.usage ?? {}, event.response.service_tier, requestedSpeed, wire)
1100
+ };
1101
+ break;
1102
+ }
1103
+ case "error":
1104
+ case "response.failed":
1105
+ throw new ProviderRequestError({
1106
+ kind: "server",
1107
+ providerId: this.id,
1108
+ detail: apiKey ? "the Responses stream failed" : "the Codex Responses stream failed"
1109
+ });
1110
+ }
1111
+ }
1112
+ if (!finished) {
1113
+ throw new ProviderRequestError({
1114
+ kind: "network",
1115
+ providerId: this.id,
1116
+ detail: "the connection closed before the response finished"
1117
+ });
1118
+ }
1119
+ } catch (error) {
1120
+ if (isCallerAbortError(error, params.signal))
1121
+ throw params.signal?.reason ?? error;
1122
+ if (isProviderRequestError(error))
1123
+ throw error;
1124
+ throw providerVendorError({ providerId: this.id, error });
1125
+ }
1126
+ }
1127
+ async listModels(signal) {
1128
+ signal?.throwIfAborted();
1129
+ const response = await this.client.get(`/models?client_version=${MODELS_CLIENT_VERSION}`, {
1130
+ signal
1131
+ });
1132
+ signal?.throwIfAborted();
1133
+ const profiles = /* @__PURE__ */ new Map();
1134
+ const tiersBySlug = /* @__PURE__ */ new Map();
1135
+ const windows = /* @__PURE__ */ new Map();
1136
+ const compactLimits = /* @__PURE__ */ new Map();
1137
+ const models = (Array.isArray(response.models) ? response.models : []).flatMap((value) => {
1138
+ const item = record(value);
1139
+ if (typeof item?.slug !== "string" || item.slug.length === 0)
1140
+ return [];
1141
+ if (item.visibility === "hide" || item.visibility === "hidden")
1142
+ return [];
1143
+ const profile = subscriptionReasoningProfile(item);
1144
+ if (profile)
1145
+ profiles.set(item.slug.toLowerCase(), profile);
1146
+ const speedTiers = subscriptionSpeedTiers(item);
1147
+ tiersBySlug.set(item.slug.toLowerCase(), speedTiers);
1148
+ const { contextWindow, autoCompactTokenLimit } = subscriptionLimits(item);
1149
+ if (contextWindow !== void 0)
1150
+ windows.set(item.slug.toLowerCase(), contextWindow);
1151
+ if (autoCompactTokenLimit !== void 0)
1152
+ compactLimits.set(item.slug.toLowerCase(), autoCompactTokenLimit);
1153
+ return [
1154
+ {
1155
+ id: item.slug,
1156
+ name: typeof item.display_name === "string" ? item.display_name : item.slug,
1157
+ supportsToolUse: true,
1158
+ supportsStreaming: true,
1159
+ ...profile ? { reasoningEffortLevels: profile.levels } : {},
1160
+ ...profile?.default !== void 0 ? { reasoningEffortDefault: profile.default } : {},
1161
+ speedTiers,
1162
+ ...contextWindow !== void 0 ? { contextWindow } : {},
1163
+ ...autoCompactTokenLimit !== void 0 ? { autoCompactTokenLimit } : {}
1164
+ }
1165
+ ];
1166
+ });
1167
+ this.reasoningProfiles = profiles;
1168
+ this.speedTiers = tiersBySlug;
1169
+ this.windows = windows;
1170
+ this.compactLimits = compactLimits;
1171
+ listingByAccount.set(this.listingKey, {
1172
+ speedTiers: tiersBySlug,
1173
+ reasoningProfiles: profiles,
1174
+ windows,
1175
+ compactLimits
1176
+ });
1177
+ return models;
1178
+ }
1179
+ async probeCredential(signal) {
1180
+ await this.listModels(signal);
789
1181
  }
790
1182
  async healthCheck() {
791
1183
  try {
792
- await this.client.models.list();
1184
+ await this.probeCredential();
793
1185
  return true;
794
1186
  } catch {
795
1187
  return false;
796
1188
  }
797
1189
  }
798
1190
  };
799
-
800
- // ../providers/openai/dist/images.js
801
- var CODEX_IMAGE_MODEL = "gpt-image-2";
802
- var CODEX_DEFAULT_BASE_URL = "https://chatgpt.com/backend-api/codex";
803
- var IMAGE_TURN_HEADER = "x-codex-image-turn-id";
804
- var ACTIVE_LIMIT_HEADER = "x-codex-active-limit";
805
- var CODEX_IMAGE_TIMEOUT_MS = 10 * 60 * 1e3;
806
- var CODEX_IMAGE_MAX_BYTES = 32 * 1024 * 1024;
807
- var CODEX_IMAGE_LIMIT_IDS = ["image_gen", "imagegen_premium"];
808
- var CodexImagesError = class extends Error {
809
- static {
810
- __name(this, "CodexImagesError");
811
- }
812
- status;
813
- usageLimit;
814
- requestId;
815
- constructor(message, details = {}) {
816
- super(message);
817
- this.name = "CodexImagesError";
818
- if (details.status !== void 0)
819
- this.status = details.status;
820
- if (details.usageLimit !== void 0)
821
- this.usageLimit = details.usageLimit;
822
- if (details.requestId !== void 0)
823
- this.requestId = details.requestId;
824
- }
825
- };
826
- function asRecord2(value) {
827
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
828
- }
829
- __name(asRecord2, "asRecord");
830
- function codexRequestHeaders(accountId) {
1191
+ function webSearchDetail(item) {
1192
+ const action = item.action;
1193
+ if (!action || typeof action !== "object")
1194
+ return {};
1195
+ const queries = Array.isArray(action.queries) ? action.queries.filter((q) => typeof q === "string" && q.trim().length > 0) : [];
1196
+ const query = typeof action.query === "string" && action.query.trim().length > 0 ? action.query.trim() : queries[0]?.trim();
1197
+ const url = typeof action.url === "string" && action.url.length > 0 ? action.url : void 0;
831
1198
  return {
832
- ...attributionHeaders(),
833
- "ChatGPT-Account-Id": accountId,
834
- originator: "Codex Namzu",
835
- "User-Agent": "Codex Namzu/1.0"
1199
+ ...query ? { query } : {},
1200
+ ...url && !query ? { url } : {},
1201
+ ...Array.isArray(action.sources) ? { results: action.sources.length } : {},
1202
+ // One hosted item may run several queries; the count says so, the label names the first.
1203
+ ...queries.length > 1 ? { searches: queries.length } : {}
836
1204
  };
837
1205
  }
838
- __name(codexRequestHeaders, "codexRequestHeaders");
839
- function sniffImageType(bytes) {
840
- const head = bytes.subarray(0, 6).toString("latin1");
841
- return head === "GIF87a" || head === "GIF89a" ? "image/gif" : "image/png";
842
- }
843
- __name(sniffImageType, "sniffImageType");
844
- function failureFrom(status, text, headers) {
845
- const requestId = headers.get("x-codex-imagegen-request-id") ?? void 0;
846
- let body = null;
847
- try {
848
- body = asRecord2(JSON.parse(text));
849
- } catch {
850
- body = null;
851
- }
852
- const error = asRecord2(body?.error);
853
- const type = typeof error?.type === "string" ? error.type : void 0;
854
- const message = typeof error?.message === "string" && error.message || text.trim().slice(0, 300) || "";
855
- if (status === 429 && type === "usage_limit_reached") {
856
- const limitId = headers.get(ACTIVE_LIMIT_HEADER) ?? void 0;
857
- const seconds = typeof error?.resets_at === "number" ? error.resets_at : void 0;
858
- return new CodexImagesError("The image quota of this plan is used up.", {
859
- status,
860
- usageLimit: {
861
- ...limitId ? { limitId } : {},
862
- ...seconds !== void 0 ? { resetsAt: seconds * 1e3 } : {}
863
- },
864
- ...requestId ? { requestId } : {}
865
- });
866
- }
867
- return new CodexImagesError(`HTTP ${status}${message ? `: ${message}` : ""}`, {
868
- status,
869
- ...requestId ? { requestId } : {}
870
- });
1206
+ __name(webSearchDetail, "webSearchDetail");
1207
+
1208
+ // ../providers/openai/dist/listed-chat-models.js
1209
+ var CHAT_FAMILY = /^(?:gpt-|o\d|chatgpt-|chat-latest)/;
1210
+ var NOT_CHAT = /(?:audio|realtime|gpt-live|transcribe|diarize|whisper|tts|image|sora|dall-e|embed|moderation|search-api|search-preview|computer-use|instruct|babbage|davinci)/;
1211
+ function isOpenAIChatModelId(id) {
1212
+ const normalized = id.toLowerCase().replace(/^ft:/, "");
1213
+ return CHAT_FAMILY.test(normalized) && !NOT_CHAT.test(normalized);
871
1214
  }
872
- __name(failureFrom, "failureFrom");
873
- async function requestCodexImage(config, request) {
874
- const base = (config.baseURL ?? CODEX_DEFAULT_BASE_URL).replace(/\/+$/, "");
875
- const editing = request.images !== void 0 && request.images.length > 0;
876
- const url = `${base}/images/${editing ? "edits" : "generations"}`;
877
- const body = {
878
- prompt: request.prompt,
879
- model: CODEX_IMAGE_MODEL,
880
- quality: "auto",
881
- size: "auto",
882
- background: request.transparentBackground === true ? "transparent" : "opaque",
883
- ...editing ? { images: request.images?.map((image_url) => ({ image_url })) } : {}
884
- };
885
- const timeout = AbortSignal.timeout(config.timeoutMs ?? CODEX_IMAGE_TIMEOUT_MS);
886
- const signal = request.signal ? AbortSignal.any([request.signal, timeout]) : timeout;
887
- const doFetch = config.fetch ?? fetch;
888
- let response;
889
- try {
890
- response = await doFetch(url, {
891
- method: "POST",
892
- signal,
893
- headers: {
894
- ...codexRequestHeaders(config.accountId),
895
- ...config.headers ?? {},
896
- Authorization: `Bearer ${config.accessToken}`,
897
- "Content-Type": "application/json",
898
- Accept: "application/json",
899
- ...request.turnId ? { [IMAGE_TURN_HEADER]: request.turnId } : {}
900
- },
901
- body: JSON.stringify(body)
902
- });
903
- } catch (error) {
904
- if (request.signal?.aborted)
905
- throw request.signal.reason ?? error;
906
- if (timeout.aborted)
907
- throw new CodexImagesError("The image request timed out.");
908
- throw new CodexImagesError(`The image request could not be sent: ${error instanceof Error ? error.message : String(error)}`);
909
- }
910
- const text = await response.text();
911
- if (!response.ok)
912
- throw failureFrom(response.status, text, response.headers);
913
- const requestId = response.headers.get("x-codex-imagegen-request-id") ?? void 0;
914
- let parsed = null;
915
- try {
916
- parsed = asRecord2(JSON.parse(text));
917
- } catch {
918
- throw new CodexImagesError("The image response could not be read.", { requestId });
919
- }
920
- const first = Array.isArray(parsed?.data) ? asRecord2(parsed.data[0]) : null;
921
- const encoded = typeof first?.b64_json === "string" ? first.b64_json : "";
922
- if (encoded === "")
923
- throw new CodexImagesError("The image service returned no image data.");
924
- if (Math.ceil(encoded.length * 0.75) > CODEX_IMAGE_MAX_BYTES + 3)
925
- throw new CodexImagesError("The generated image is larger than 32 MiB and was not kept.");
926
- const bytes = Buffer.from(encoded, "base64");
927
- if (bytes.length === 0)
928
- throw new CodexImagesError("The image service returned no image data.");
929
- if (bytes.length > CODEX_IMAGE_MAX_BYTES)
930
- throw new CodexImagesError("The generated image is larger than 32 MiB and was not kept.");
931
- return {
932
- bytes,
933
- mediaType: sniffImageType(bytes),
934
- ...requestId ? { requestId } : {}
935
- };
1215
+ __name(isOpenAIChatModelId, "isOpenAIChatModelId");
1216
+ function chatModelsOnly(rows) {
1217
+ return rows.filter((row) => isOpenAIChatModelId(row.id));
936
1218
  }
937
- __name(requestCodexImage, "requestCodexImage");
1219
+ __name(chatModelsOnly, "chatModelsOnly");
938
1220
 
939
- // ../providers/openai/dist/codex.js
940
- var CODEX_CAPABILITIES = {
941
- supportsHostedWebSearch: true,
1221
+ // ../providers/openai/dist/client.js
1222
+ var OPENAI_CAPABILITIES = {
1223
+ supportsNativeStructuredOutput: true,
942
1224
  supportsTools: true,
943
1225
  supportsStreaming: true,
944
1226
  supportsFunctionCalling: true,
945
- supportsNativeStructuredOutput: true,
946
1227
  supportsVision: true,
947
- supportsDocuments: false,
948
- supportsToolResultImages: true,
1228
+ supportsDocuments: true,
1229
+ supportsToolResultImages: false,
949
1230
  supportsToolResultDocuments: false
950
1231
  };
951
- var DEFAULT_CODEX_BASE_URL = CODEX_DEFAULT_BASE_URL;
952
- var KNOWN_EFFORT_LEVELS = [
953
- "none",
1232
+ var GPT_5_EFFORT = [
954
1233
  "minimal",
955
1234
  "low",
956
1235
  "medium",
1236
+ "high"
1237
+ ];
1238
+ var GPT_5_1_EFFORT = [
1239
+ "none",
1240
+ "low",
1241
+ "medium",
1242
+ "high"
1243
+ ];
1244
+ var GPT_5_2_TO_5_5_EFFORT = [
1245
+ "none",
1246
+ "low",
1247
+ "medium",
1248
+ "high",
1249
+ "xhigh"
1250
+ ];
1251
+ var GPT_6_ASTRA_EFFORT = ["low", "medium", "high", "xhigh", "max"];
1252
+ var GPT_5_6_EFFORT = [
1253
+ "none",
1254
+ "low",
1255
+ "medium",
957
1256
  "high",
958
1257
  "xhigh",
959
- "max",
960
- "ultra"
1258
+ "max"
961
1259
  ];
962
- function subscriptionReasoningProfile(item) {
963
- if (!Array.isArray(item.supported_reasoning_levels))
964
- return void 0;
965
- const levels = [];
966
- for (const entry of item.supported_reasoning_levels) {
967
- const effort = record(entry)?.effort;
968
- if (typeof effort !== "string" || !KNOWN_EFFORT_LEVELS.includes(effort))
969
- return void 0;
970
- if (levels.includes(effort))
971
- return void 0;
972
- levels.push(effort);
1260
+ function openAIReasoningEffortLevels(model) {
1261
+ const normalized = model.toLowerCase();
1262
+ if (normalized === "gpt-6-astra")
1263
+ return GPT_6_ASTRA_EFFORT;
1264
+ if (/^gpt-5\.6(?:-(?:sol|terra|luna))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1265
+ return GPT_5_6_EFFORT;
973
1266
  }
974
- const defaultLevel = item.default_reasoning_level;
975
- return {
976
- levels: Object.freeze(levels),
977
- ...typeof defaultLevel === "string" && levels.includes(defaultLevel) ? { default: defaultLevel } : {}
978
- };
1267
+ if (/^gpt-5\.5(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1268
+ return GPT_5_2_TO_5_5_EFFORT;
1269
+ }
1270
+ if (/^gpt-5\.4(?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1271
+ return GPT_5_2_TO_5_5_EFFORT;
1272
+ }
1273
+ if (/^gpt-5\.2(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1274
+ return GPT_5_2_TO_5_5_EFFORT;
1275
+ }
1276
+ if (/^gpt-5\.1(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1277
+ return GPT_5_1_EFFORT;
1278
+ }
1279
+ if (/^gpt-5(?:-(?:mini|nano))?(?:-\d{4}-\d{2}-\d{2})?$/.test(normalized)) {
1280
+ return GPT_5_EFFORT;
1281
+ }
1282
+ return void 0;
979
1283
  }
980
- __name(subscriptionReasoningProfile, "subscriptionReasoningProfile");
981
- function sameRoute(left, right) {
982
- return left.providerId === right.providerId && left.model === right.model && left.chainIndex === right.chainIndex;
1284
+ __name(openAIReasoningEffortLevels, "openAIReasoningEffortLevels");
1285
+ function openAIModelNeedsResponses(model, params) {
1286
+ const id = model.toLowerCase().replace(/^ft:/, "");
1287
+ if (/^gpt-5\.6(?![a-z0-9.])/.test(id) || /^gpt-6(?![a-z0-9])/.test(id))
1288
+ return true;
1289
+ if (/^gpt-live(?![a-z0-9])/.test(id))
1290
+ return true;
1291
+ if (/-pro(?:-\d{4}-\d{2}-\d{2})?$/.test(id))
1292
+ return true;
1293
+ if (learnedResponsesModels.has(id))
1294
+ return true;
1295
+ const hasTools = (params.tools?.length ?? 0) > 0;
1296
+ if (hasTools && params.effort !== void 0 && /^gpt-5\.(?:4-mini|5)(?![a-z0-9.])/.test(id)) {
1297
+ return true;
1298
+ }
1299
+ return false;
983
1300
  }
984
- __name(sameRoute, "sameRoute");
985
- function record(value) {
986
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
1301
+ __name(openAIModelNeedsResponses, "openAIModelNeedsResponses");
1302
+ var learnedResponsesModels = /* @__PURE__ */ new Set();
1303
+ function isResponsesOnlyRefusal(error) {
1304
+ const e = error;
1305
+ if (typeof e?.message !== "string")
1306
+ return false;
1307
+ if (e.status === 400)
1308
+ return /Function tools with reasoning_effort are not supported/i.test(e.message);
1309
+ return e.status === 404 && /not a chat model|only supported in v1\/responses|not supported in the v1\/chat\/completions endpoint|use the v1\/responses endpoint/i.test(e.message);
987
1310
  }
988
- __name(record, "record");
989
- function isRoute(value) {
990
- const route = record(value);
991
- return typeof route?.providerId === "string" && typeof route.model === "string" && Number.isInteger(route.chainIndex) && route.chainIndex >= 0;
1311
+ __name(isResponsesOnlyRefusal, "isResponsesOnlyRefusal");
1312
+ function isClassicChatModel(model) {
1313
+ return /^(?:ft:)?(?:gpt-3\.5|gpt-4|chatgpt-4)/.test(model.toLowerCase());
992
1314
  }
993
- __name(isRoute, "isRoute");
994
- function durableToolCalls(message) {
995
- return (message.toolCalls ?? []).map((call) => ({
996
- id: call.id,
997
- name: call.function.name,
998
- arguments: call.function.arguments
999
- }));
1315
+ __name(isClassicChatModel, "isClassicChatModel");
1316
+ function takesSamplingFields(model, effort) {
1317
+ if (isClassicChatModel(model))
1318
+ return true;
1319
+ const id = model.toLowerCase();
1320
+ return /^(?:ft:)?gpt-5\.[1-4](?![a-z0-9.])(?!-(?:codex|pro|chat))/.test(id) && (effort === void 0 || effort === "none");
1000
1321
  }
1001
- __name(durableToolCalls, "durableToolCalls");
1002
- function isCodexReplayState(value) {
1003
- const state = record(value);
1004
- if (state?.kind !== "namzu.codex.responses" || state.version !== 1 || !isRoute(state.route) || state.content !== null && typeof state.content !== "string" || !Array.isArray(state.toolCalls) || !Array.isArray(state.items)) {
1005
- return false;
1006
- }
1007
- return state.toolCalls.every((item) => {
1008
- const call = record(item);
1009
- return typeof call?.id === "string" && typeof call.name === "string" && typeof call.arguments === "string";
1010
- });
1322
+ __name(takesSamplingFields, "takesSamplingFields");
1323
+ function refusesReasoningEffort(model) {
1324
+ return isClassicChatModel(model);
1011
1325
  }
1012
- __name(isCodexReplayState, "isCodexReplayState");
1013
- function replayItems(message, targetRoute) {
1014
- const source = message.source;
1015
- if (!source || source.type !== "model" || !sameRoute(source, targetRoute))
1016
- return null;
1017
- const state = source.replayState;
1018
- if (!isCodexReplayState(state) || !sameRoute(state.route, source))
1019
- return null;
1020
- if (state.content !== message.content)
1021
- return null;
1022
- if (state.textParts !== void 0 && JSON.stringify(state.textParts) !== JSON.stringify(message.textParts))
1023
- return null;
1024
- if (JSON.stringify(state.toolCalls) !== JSON.stringify(durableToolCalls(message)))
1025
- return null;
1026
- return state.items;
1326
+ __name(refusesReasoningEffort, "refusesReasoningEffort");
1327
+ function isCompatibleHost(baseURL) {
1328
+ return !isFirstPartyOpenAIEndpoint(baseURL);
1027
1329
  }
1028
- __name(replayItems, "replayItems");
1029
- var IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp", "image/gif"]);
1030
- var TOOL_RESULT_IMAGE_DETAIL = "high";
1031
- function codexImage(data, mediaType, source) {
1032
- if (!IMAGE_MEDIA_TYPES.has(mediaType)) {
1033
- throw new Error(`CodexProvider: ${source} image type '${mediaType}' is not supported. Use image/png, image/jpeg, image/webp, or image/gif.`);
1330
+ __name(isCompatibleHost, "isCompatibleHost");
1331
+ function hostOf(baseURL) {
1332
+ if (!baseURL)
1333
+ return void 0;
1334
+ try {
1335
+ return new URL(baseURL).hostname;
1336
+ } catch {
1337
+ return void 0;
1034
1338
  }
1035
- return {
1036
- type: "input_image",
1037
- detail: source === "tool result" ? TOOL_RESULT_IMAGE_DETAIL : "auto",
1038
- image_url: `data:${mediaType};base64,${data}`
1039
- };
1040
1339
  }
1041
- __name(codexImage, "codexImage");
1042
- function codexUserContent(message) {
1043
- const attachments = message.attachments ?? [];
1044
- if (attachments.length === 0)
1045
- return message.content;
1046
- const content = [];
1047
- if (message.content.length > 0)
1048
- content.push({ type: "input_text", text: message.content });
1049
- for (const attachment of attachments) {
1050
- if (attachment.type === "stored") {
1051
- throw new Error("CodexProvider: an unresolved stored attachment reached the driver. Configure an AttachmentStore so Namzu can resolve its bytes before the model request.");
1052
- }
1053
- if (attachment.type === "document") {
1054
- throw new Error("CodexProvider: this subscription transport does not support document input. Route the turn to a document-capable provider.");
1055
- }
1056
- if (attachment.modelOmission) {
1057
- throw new Error("CodexProvider: an image marked for model omission reached the driver without request projection.");
1058
- }
1059
- content.push(codexImage(attachment.data, attachment.mediaType, "user attachment"));
1060
- }
1061
- return content;
1340
+ __name(hostOf, "hostOf");
1341
+ var WINDOW_LISTING_TIMEOUT_MS2 = 3e3;
1342
+ var WINDOW_LISTING_RETRY_MS2 = 5 * 6e4;
1343
+ var EFFORT_VOCABULARY = [
1344
+ "none",
1345
+ "minimal",
1346
+ "low",
1347
+ "medium",
1348
+ "high",
1349
+ "xhigh",
1350
+ "max",
1351
+ "ultra"
1352
+ ];
1353
+ var INPUT_MODALITIES = ["text", "image", "document"];
1354
+ function asRecord2(value) {
1355
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
1062
1356
  }
1063
- __name(codexUserContent, "codexUserContent");
1064
- function codexToolOutput(content) {
1065
- if (typeof content === "string")
1066
- return content;
1067
- if (content.length === 0)
1068
- return "";
1069
- const output = [];
1070
- for (const block of toToolResultBlocks(content)) {
1071
- if (block.type === "text") {
1072
- output.push({ type: "input_text", text: block.text });
1073
- continue;
1074
- }
1075
- if (block.type === "document") {
1076
- throw new Error("CodexProvider: this subscription transport does not support document tool results. Route the turn to a provider whose tool-result wire admits documents.");
1077
- }
1078
- if (block.modelOmission) {
1079
- throw new Error("CodexProvider: a tool image marked for model omission reached the driver without request projection.");
1080
- }
1081
- output.push(codexImage(block.data, block.mediaType, "tool result"));
1082
- }
1083
- return output;
1357
+ __name(asRecord2, "asRecord");
1358
+ function ratePerMillion(value) {
1359
+ const perToken = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
1360
+ if (typeof perToken !== "number" || !Number.isFinite(perToken) || perToken < 0)
1361
+ return void 0;
1362
+ return Number((perToken * 1e6).toPrecision(12));
1084
1363
  }
1085
- __name(codexToolOutput, "codexToolOutput");
1086
- function toCodexInput(messages, targetRoute, openingSystemRun = messages.findIndex((message) => message.role !== "system")) {
1087
- const input = [];
1088
- const opening = openingSystemRun < 0 ? messages.length : openingSystemRun;
1089
- for (const [at, message] of messages.entries()) {
1090
- if (message.role === "system") {
1091
- if (at >= opening && message.content) {
1092
- input.push({ type: "message", role: "developer", content: message.content });
1093
- }
1094
- continue;
1095
- }
1096
- if (message.role === "user") {
1097
- input.push({
1098
- type: "message",
1099
- role: "user",
1100
- content: codexUserContent(message)
1101
- });
1102
- continue;
1103
- }
1104
- if (message.role === "tool") {
1105
- input.push({
1106
- type: "function_call_output",
1107
- call_id: message.toolCallId,
1108
- output: codexToolOutput(message.content)
1109
- });
1110
- continue;
1111
- }
1112
- const replayed = replayItems(message, targetRoute);
1113
- if (replayed) {
1114
- input.push(...replayed);
1115
- continue;
1116
- }
1117
- if (message.content) {
1118
- input.push({
1119
- type: "message",
1120
- role: "assistant",
1121
- content: message.content
1122
- });
1123
- }
1124
- for (const call of message.toolCalls ?? []) {
1125
- input.push({
1126
- type: "function_call",
1127
- call_id: call.id,
1128
- name: call.function.name,
1129
- arguments: call.function.arguments
1130
- });
1131
- }
1132
- }
1133
- return input;
1364
+ __name(ratePerMillion, "ratePerMillion");
1365
+ function inputModalitiesOf(row, capabilities) {
1366
+ if (capabilities?.vision === true)
1367
+ return ["text", "image"];
1368
+ if (capabilities?.vision === false)
1369
+ return ["text"];
1370
+ const declared = row.input_modalities ?? asRecord2(row.architecture)?.input_modalities ?? // A plain `modalities` list is read for a chat model only: on another task it may name outputs.
1371
+ (row.task === void 0 || row.task === "chat" ? row.modalities : void 0);
1372
+ if (!Array.isArray(declared))
1373
+ return void 0;
1374
+ const known = INPUT_MODALITIES.filter((kind) => declared.includes(kind));
1375
+ return known.length > 0 ? known : void 0;
1134
1376
  }
1135
- __name(toCodexInput, "toCodexInput");
1136
- function toCodexTools(params) {
1137
- const tools = (params.tools ?? []).map((tool) => ({
1138
- type: "function",
1139
- name: tool.function.name,
1140
- description: tool.function.description ?? "",
1141
- parameters: tool.function.parameters ?? {},
1142
- // The ChatGPT Codex backend validates `strict: true` against a narrower
1143
- // Responses schema than the Chat Completions endpoint. In particular,
1144
- // every composition branch needs an explicit type and every object
1145
- // property must also be required. Namzu model schemas deliberately keep
1146
- // conditional edit shapes optional and validate the selected shape at
1147
- // execution, so claiming strictness rejects the whole request before the
1148
- // model can answer. The Codex client uses the same boundary for its own
1149
- // tools: Responses function tools are sent with `strict: false` and tool
1150
- // inputs are validated by the runtime. `enforceToolInputSchema` remains a
1151
- // provider hint; this transport cannot truthfully consume it for Namzu's
1152
- // general tool-schema contract.
1153
- strict: false
1154
- }));
1155
- if (params.webSearch) {
1156
- if (params.webSearch.mode !== "live" && params.webSearch.mode !== "cached")
1157
- throw new Error("Invalid web search mode.");
1158
- const hosted = {
1159
- type: "web_search",
1160
- external_web_access: params.webSearch.mode === "live"
1161
- };
1162
- tools.push(hosted);
1377
+ __name(inputModalitiesOf, "inputModalitiesOf");
1378
+ function compatibleModelMetadata(model) {
1379
+ const row = asRecord2(model) ?? {};
1380
+ const capabilities = asRecord2(row.capabilities);
1381
+ const result = {};
1382
+ const contextWindow = declaredContextWindow(row);
1383
+ if (contextWindow !== void 0)
1384
+ result.contextWindow = contextWindow;
1385
+ const maxOutputTokens = firstCount(row, ["maximum_output_tokens", "max_output_tokens", "max_completion_tokens"]) ?? firstCount(asRecord2(row.top_provider), ["max_completion_tokens"]);
1386
+ if (maxOutputTokens !== void 0)
1387
+ result.maxOutputTokens = maxOutputTokens;
1388
+ const inputModalities = inputModalitiesOf(row, capabilities);
1389
+ if (inputModalities !== void 0)
1390
+ result.inputModalities = inputModalities;
1391
+ if (capabilities?.tools === false)
1392
+ result.supportsToolUse = false;
1393
+ const pricing = asRecord2(row.pricing);
1394
+ const currency = typeof pricing?.currency === "string" ? pricing.currency.toUpperCase() : void 0;
1395
+ if (pricing && (currency === void 0 || currency === "USD")) {
1396
+ const input = ratePerMillion(pricing.prompt);
1397
+ const output = ratePerMillion(pricing.completion);
1398
+ if (input !== void 0)
1399
+ result.inputPrice = input;
1400
+ if (output !== void 0)
1401
+ result.outputPrice = output;
1163
1402
  }
1164
- return tools.length ? tools : void 0;
1403
+ let offered = Array.isArray(row.supported_reasoning_efforts) ? row.supported_reasoning_efforts : void 0;
1404
+ if (offered === void 0 && Array.isArray(capabilities?.reasoning_effort_values)) {
1405
+ const aliases = asRecord2(capabilities.reasoning_effort_aliases);
1406
+ offered = [.../* @__PURE__ */ new Set([...capabilities.reasoning_effort_values, ...Object.keys(aliases ?? {})])];
1407
+ }
1408
+ const menu = offered !== void 0 && new Set(offered).size === offered.length && offered.every((level) => typeof level === "string" && EFFORT_VOCABULARY.includes(level)) ? offered : void 0;
1409
+ if (menu) {
1410
+ result.reasoningEffortLevels = [...menu];
1411
+ const defaultEffort = row.reasoning_effort;
1412
+ if (typeof defaultEffort === "string" && menu.includes(defaultEffort))
1413
+ result.reasoningEffortDefault = defaultEffort;
1414
+ } else if (offered === void 0 && capabilities?.reasoning_effort === false) {
1415
+ result.reasoningEffortLevels = [];
1416
+ }
1417
+ return result;
1165
1418
  }
1166
- __name(toCodexTools, "toCodexTools");
1167
- function responseUsage(usage, servedTier, requestedSpeed) {
1168
- const promptTokens = usage.input_tokens ?? 0;
1169
- const completionTokens = usage.output_tokens ?? 0;
1419
+ __name(compatibleModelMetadata, "compatibleModelMetadata");
1420
+ function assertOpenAIReasoningEffort(model, effort) {
1421
+ if (effort === void 0)
1422
+ return;
1423
+ const supported = openAIReasoningEffortLevels(model);
1424
+ if (supported === void 0 || supported.includes(effort))
1425
+ return;
1426
+ throw new Error(`OpenAIProvider: effort "${effort}" is not supported by model "${model}". Supported levels: ${supported.join(", ")}. Choose one of those levels or omit \`effort\`.`);
1427
+ }
1428
+ __name(assertOpenAIReasoningEffort, "assertOpenAIReasoningEffort");
1429
+ function withReasoningEffort(request, effort) {
1430
+ if (effort === void 0)
1431
+ return request;
1170
1432
  return {
1171
- promptTokens,
1172
- completionTokens,
1173
- totalTokens: usage.total_tokens ?? promptTokens + completionTokens,
1174
- cachedTokens: usage.input_tokens_details?.cached_tokens ?? 0,
1175
- cacheWriteTokens: 0,
1176
- ...servedSpeed(servedTier, requestedSpeed)
1433
+ ...request,
1434
+ reasoning_effort: effort
1177
1435
  };
1178
1436
  }
1179
- __name(responseUsage, "responseUsage");
1180
- function subscriptionSpeedTiers(item) {
1181
- const tiers = /* @__PURE__ */ new Set();
1182
- const note = /* @__PURE__ */ __name((id) => {
1183
- if (id === "priority" || id === "fast")
1184
- tiers.add("fast");
1185
- else if (id === "ultrafast")
1186
- tiers.add("ultrafast");
1187
- }, "note");
1188
- if (Array.isArray(item.service_tiers)) {
1189
- for (const entry of item.service_tiers)
1190
- note(record(entry)?.id);
1191
- }
1192
- if (Array.isArray(item.additional_speed_tiers)) {
1193
- for (const entry of item.additional_speed_tiers)
1194
- note(entry);
1437
+ __name(withReasoningEffort, "withReasoningEffort");
1438
+ function mapFinishReason(reason) {
1439
+ switch (reason) {
1440
+ case "length":
1441
+ return "length";
1442
+ case "tool_calls":
1443
+ case "function_call":
1444
+ return "tool_calls";
1445
+ case "content_filter":
1446
+ return "content_filter";
1447
+ default:
1448
+ return "stop";
1195
1449
  }
1196
- return ["fast", "ultrafast"].filter((tier) => tiers.has(tier));
1197
1450
  }
1198
- __name(subscriptionSpeedTiers, "subscriptionSpeedTiers");
1199
- function buildRequest(params, model, targetRoute, supportedEffort, downgrade = NO_DOWNGRADE) {
1200
- if (params.effort !== void 0 && supportedEffort !== void 0 && !supportedEffort.includes(params.effort)) {
1201
- throw new Error(`CodexProvider: effort "${params.effort}" is not supported by model "${model}". Supported levels: ${supportedEffort.join(", ")}. Choose one of those levels or omit \`effort\`.`);
1202
- }
1203
- if (params.thinking?.type === "enabled") {
1204
- throw new Error("CodexProvider: manual thinking budgets are not a Responses API capability. Use adaptive thinking or omit `thinking`.");
1205
- }
1206
- if (params.thinking?.type === "disabled" && params.effort !== "none") {
1207
- throw new Error('CodexProvider: disabling reasoning requires `effort: "none"`; omitting that level would not prove reasoning was disabled.');
1451
+ __name(mapFinishReason, "mapFinishReason");
1452
+ function parseUsage(raw, servedTier, requestedSpeed) {
1453
+ if (!raw) {
1454
+ return {
1455
+ promptTokens: 0,
1456
+ completionTokens: 0,
1457
+ totalTokens: 0,
1458
+ cachedTokens: 0,
1459
+ cacheWriteTokens: 0
1460
+ };
1208
1461
  }
1209
- let openingRun = 0;
1210
- while (params.messages[openingRun]?.role === "system")
1211
- openingRun++;
1212
- if (downgrade.legacyShape)
1213
- openingRun = params.messages.length;
1214
- const instructions = (downgrade.legacyShape ? params.messages.filter((message) => message.role === "system") : params.messages.slice(0, openingRun)).map((message) => message.content).join("\n\n");
1215
- const request = {
1216
- model,
1217
- stream: true,
1218
- store: false,
1219
- instructions: instructions || void 0,
1220
- input: toCodexInput(params.messages, targetRoute, openingRun),
1221
- // One key for the whole conversation routes every request to the same
1222
- // cache; without it the backend keys on the request alone.
1223
- ...params.cacheKey && !downgrade.noCacheKey ? { prompt_cache_key: params.cacheKey } : {},
1224
- // The Codex subscription request schema deliberately has no
1225
- // `max_output_tokens` member. `ChatCompletionParams.maxTokens` is a public
1226
- // API control, but projecting it onto this route makes the whole request
1227
- // invalid; the backend owns the output budget here.
1228
- // The subscription Responses backend expects these three fields even for a
1229
- // turn that exposes no tools. The ordinary public Responses endpoint admits
1230
- // their omission, which is why the generated client types all make them
1231
- // optional; the Codex wire does not have the same defaulting contract.
1232
- tools: toCodexTools(params) ?? [],
1233
- tool_choice: params.toolChoice ?? "auto",
1234
- parallel_tool_calls: params.parallelToolCalls ?? true,
1235
- include: ["reasoning.encrypted_content"],
1236
- ...params.responseFormat ? {
1237
- text: {
1238
- format: params.responseFormat.type === "json_schema" ? { type: "json_schema", ...params.responseFormat.json_schema } : { type: "json_object" }
1239
- }
1240
- } : {},
1241
- ...params.effort !== void 0 ? { reasoning: { effort: params.effort, summary: "auto" } } : params.thinking?.type === "adaptive" ? { reasoning: { summary: "auto" } } : {}
1462
+ const promptTokens = raw.prompt_tokens ?? 0;
1463
+ const completionTokens = raw.completion_tokens ?? 0;
1464
+ return {
1465
+ promptTokens,
1466
+ completionTokens,
1467
+ totalTokens: raw.total_tokens ?? promptTokens + completionTokens,
1468
+ cachedTokens: raw.prompt_tokens_details?.cached_tokens ?? 0,
1469
+ cacheWriteTokens: 0,
1470
+ ...servedSpeed(servedTier, requestedSpeed)
1242
1471
  };
1243
- return request;
1244
1472
  }
1245
- __name(buildRequest, "buildRequest");
1246
- var NO_DOWNGRADE = { legacyShape: false, noCacheKey: false };
1247
- var subscriptionDowngrade = { legacyShape: false, noCacheKey: false };
1248
- var REFUSED_SHAPE = /\bdeveloper\b|\brole\b|\binput\[\d*\]|session_id|prompt_cache_key/i;
1249
- function refusedNewShape(error) {
1250
- if (typeof error !== "object" || error === null)
1251
- return void 0;
1252
- const status = error.status;
1253
- if (!(error instanceof OpenAI.BadRequestError) && status !== 400)
1473
+ __name(parseUsage, "parseUsage");
1474
+ function formatToolChoice(tc) {
1475
+ if (tc === void 0)
1254
1476
  return void 0;
1255
- const message = error.message;
1256
- if (typeof message !== "string" || !REFUSED_SHAPE.test(message))
1477
+ if (tc === "auto" || tc === "none" || tc === "required")
1478
+ return tc;
1479
+ if (typeof tc === "object" && tc.type === "function") {
1480
+ return { type: "function", function: { name: tc.function.name } };
1481
+ }
1482
+ return void 0;
1483
+ }
1484
+ __name(formatToolChoice, "formatToolChoice");
1485
+ function assertThinkingSupported(params) {
1486
+ assertThinkingUnsupported("OpenAIProvider", { thinking: params.thinking });
1487
+ }
1488
+ __name(assertThinkingSupported, "assertThinkingSupported");
1489
+ function assertCitationsSupported(attachment, index) {
1490
+ if (!attachment.citations)
1491
+ return;
1492
+ const which = attachment.name ?? `attachment ${index}`;
1493
+ throw new Error(`This provider cannot return citations, and ${which} asked for them. Drop \`citations\` to send the document without them, or use a provider whose capabilities include citation support.`);
1494
+ }
1495
+ __name(assertCitationsSupported, "assertCitationsSupported");
1496
+ function toOpenAIMessages(messages) {
1497
+ const converted = messages.map((msg) => {
1498
+ if (msg.role === "system") {
1499
+ return { role: "system", content: msg.content };
1500
+ }
1501
+ if (msg.role === "user") {
1502
+ if (msg.attachments && msg.attachments.length > 0) {
1503
+ const parts = [];
1504
+ if (msg.content.length > 0) {
1505
+ parts.push({ type: "text", text: msg.content });
1506
+ }
1507
+ for (const [index, att] of msg.attachments.entries()) {
1508
+ if (att.type === "document") {
1509
+ assertCitationsSupported(att, index);
1510
+ parts.push({
1511
+ type: "file",
1512
+ file: {
1513
+ file_data: `data:${att.mediaType};base64,${att.data}`,
1514
+ ...att.name ? { filename: att.name } : {}
1515
+ }
1516
+ });
1517
+ continue;
1518
+ }
1519
+ if (att.type === "stored") {
1520
+ throw new Error(`A stored attachment ("${att.ref}") reached the driver unresolved. Resolve it against the run's attachment store before sending.`);
1521
+ }
1522
+ parts.push({
1523
+ type: "image_url",
1524
+ image_url: { url: `data:${att.mediaType};base64,${att.data}` }
1525
+ });
1526
+ }
1527
+ return { role: "user", content: parts };
1528
+ }
1529
+ return { role: "user", content: msg.content };
1530
+ }
1531
+ if (msg.role === "tool") {
1532
+ return {
1533
+ role: "tool",
1534
+ // Tool messages are text-only on this wire, so a content block
1535
+ // degrades to an honest placeholder rather than having its
1536
+ // base64 payload dumped as text.
1537
+ content: toolResultToText(msg.content),
1538
+ tool_call_id: msg.toolCallId
1539
+ };
1540
+ }
1541
+ const assistant = {
1542
+ role: "assistant",
1543
+ content: msg.content
1544
+ };
1545
+ if ("toolCalls" in msg && msg.toolCalls && msg.toolCalls.length > 0) {
1546
+ ;
1547
+ assistant.tool_calls = msg.toolCalls.map((tc) => ({
1548
+ id: tc.id,
1549
+ type: "function",
1550
+ function: {
1551
+ name: tc.function.name,
1552
+ arguments: tc.function.arguments
1553
+ }
1554
+ }));
1555
+ }
1556
+ return assistant;
1557
+ });
1558
+ return converted.filter((msg) => msg.role !== "assistant" || Boolean(msg.content) || (msg.tool_calls?.length ?? 0) > 0);
1559
+ }
1560
+ __name(toOpenAIMessages, "toOpenAIMessages");
1561
+ function toOpenAITools(params) {
1562
+ if (!params.tools || params.tools.length === 0)
1257
1563
  return void 0;
1258
- return { cacheKey: /prompt_cache_key/i.test(message) };
1564
+ const enforced = new Set(params.enforceToolInputSchema ?? []);
1565
+ return params.tools.map((t) => ({
1566
+ type: "function",
1567
+ function: {
1568
+ name: t.function.name,
1569
+ description: t.function.description ?? "",
1570
+ parameters: t.function.parameters ?? {},
1571
+ ...enforced.has(t.function.name) && acceptsStrictSchema(t.function.parameters) ? { strict: true } : {}
1572
+ }
1573
+ }));
1259
1574
  }
1260
- __name(refusedNewShape, "refusedNewShape");
1261
- var listingByAccount = /* @__PURE__ */ new Map();
1262
- var MODELS_CLIENT_VERSION = "1.0.0";
1263
- var WINDOW_LISTING_TIMEOUT_MS2 = 3e3;
1264
- var WINDOW_LISTING_RETRY_MS2 = 5 * 6e4;
1265
- var CodexProvider = class {
1575
+ __name(toOpenAITools, "toOpenAITools");
1576
+ var OpenAIProvider = class {
1266
1577
  static {
1267
- __name(this, "CodexProvider");
1578
+ __name(this, "OpenAIProvider");
1268
1579
  }
1269
- id = "codex";
1270
- name = "OpenAI Codex";
1271
- capabilities = CODEX_CAPABILITIES;
1580
+ id = "openai";
1581
+ name = "OpenAI";
1582
+ capabilities = OPENAI_CAPABILITIES;
1272
1583
  client;
1273
1584
  defaultModel;
1274
- reasoningProfiles = /* @__PURE__ */ new Map();
1275
- /** Per model, the speed tiers the account's listing offers. Absent until a listing has answered. */
1276
- speedTiers;
1277
- /** Per model, the window the account's listing states. Absent until a listing has answered. */
1278
- windows;
1279
- /** Per model, the compaction threshold the account's listing states or implies. */
1280
- compactLimits;
1585
+ /** Whether requests go somewhere other than OpenAI's own API, which is where a model's window is worth asking for. */
1586
+ compatibleHost;
1587
+ /** The windows a compatible endpoint's last fulfilled listing declared, by model id. */
1588
+ declaredWindows;
1589
+ /** Before this time (ms since the epoch) a failed listing is not asked for again. */
1281
1590
  windowListingRetryAt = 0;
1282
- /** The listing in flight, shared by callers that arrive while it runs. */
1283
- windowListing;
1284
- listingKey;
1591
+ thinkingOffFields;
1592
+ /** The base URL requests go to, kept to name the host when fast mode is refused there. */
1593
+ effectiveBaseURL;
1594
+ config;
1595
+ responses;
1285
1596
  constructor(config) {
1286
- if (!config.accessToken)
1287
- throw new Error("Codex access token is required.");
1288
- if (!config.accountId)
1289
- throw new Error("Codex ChatGPT account id is required.");
1290
- this.client = new OpenAI({
1291
- apiKey: config.accessToken,
1292
- baseURL: config.baseURL ?? DEFAULT_CODEX_BASE_URL,
1293
- timeout: config.timeout,
1294
- ...config.maxRetries !== void 0 ? { maxRetries: config.maxRetries } : {},
1295
- defaultHeaders: {
1296
- ...codexRequestHeaders(config.accountId),
1297
- ...config.defaultHeaders ?? {}
1298
- }
1299
- });
1300
- this.defaultModel = config.model;
1301
- this.listingKey = `${config.accountId}\0${config.baseURL ?? DEFAULT_CODEX_BASE_URL}`;
1302
- const known = listingByAccount.get(this.listingKey);
1303
- if (known) {
1304
- this.speedTiers = known.speedTiers;
1305
- this.reasoningProfiles = known.reasoningProfiles;
1306
- this.windows = known.windows;
1307
- this.compactLimits = known.compactLimits;
1597
+ if (!config.apiKey) {
1598
+ throw new Error("OpenAI API key is required. Set OPENAI_API_KEY env variable.");
1308
1599
  }
1309
- }
1310
- resolveModel(params) {
1311
- const model = params.model || this.defaultModel;
1312
- if (!model)
1313
- throw new Error("CodexProvider: model is required.");
1314
- return model;
1315
- }
1316
- reasoningEffortLevelsFor(model) {
1317
- return this.reasoningProfiles.get(model.toLowerCase())?.levels;
1318
- }
1319
- reasoningEffortDefaultFor(model) {
1320
- return this.reasoningProfiles.get(model.toLowerCase())?.default;
1321
- }
1322
- /**
1323
- * The speed tiers the account's listing offers for `model`. `undefined`
1324
- * until a listing has answered; once one has, a model it does not carry
1325
- * offers none.
1326
- */
1327
- speedTiersFor(model) {
1328
- if (this.speedTiers === void 0)
1329
- return void 0;
1330
- return this.speedTiers.get(model.toLowerCase()) ?? [];
1600
+ const clientOptions = {
1601
+ apiKey: config.apiKey
1602
+ };
1603
+ if (config.baseURL)
1604
+ clientOptions.baseURL = config.baseURL;
1605
+ if (config.organization)
1606
+ clientOptions.organization = config.organization;
1607
+ if (config.project)
1608
+ clientOptions.project = config.project;
1609
+ if (config.timeout !== void 0)
1610
+ clientOptions.timeout = config.timeout;
1611
+ if (config.maxRetries !== void 0)
1612
+ clientOptions.maxRetries = config.maxRetries;
1613
+ clientOptions.defaultHeaders = {
1614
+ ...attributionHeaders(),
1615
+ ...config.defaultHeaders ?? {}
1616
+ };
1617
+ this.client = new OpenAI(clientOptions);
1618
+ this.config = config;
1619
+ this.defaultModel = config.model;
1620
+ this.thinkingOffFields = config.thinkingOffFields;
1621
+ this.effectiveBaseURL = config.baseURL ?? process.env.OPENAI_BASE_URL;
1622
+ this.compatibleHost = isCompatibleHost(this.effectiveBaseURL);
1331
1623
  }
1332
1624
  /**
1333
- * The window the runtime measures compaction against, as the account's model listing states
1334
- * it (scaled by the effective-percent the listing sends, when it sends one), or `undefined`
1335
- * when the listing states none, which leaves the SDK's table to answer.
1625
+ * The window the runtime measures compaction against, as a compatible endpoint's own model
1626
+ * listing declares it, or `undefined` when it declares none, which leaves the SDK's table to
1627
+ * answer. The table is a hand-kept guess by model name; an endpoint that serves a model knows
1628
+ * how long a prompt it takes. OpenAI's own API declares no window, so it is not asked.
1336
1629
  *
1337
- * The listing is asked once per account and kept. A failure is remembered for a few minutes
1338
- * and a listing that hangs is cut short. Neither ever fails a turn; only the caller's own
1339
- * abort propagates.
1630
+ * The listing is asked once and a fulfilled one is kept. A failure is remembered for a few
1631
+ * minutes, so an endpoint with no usable listing is not asked at the start of every turn, and a
1632
+ * listing that hangs is cut short. Neither ever fails a turn.
1340
1633
  */
1341
1634
  async resolveContextWindow(model, signal) {
1342
1635
  signal?.throwIfAborted();
1343
- if (!this.windows) {
1636
+ if (!this.compatibleHost)
1637
+ return void 0;
1638
+ if (!this.declaredWindows) {
1344
1639
  if (Date.now() < this.windowListingRetryAt)
1345
1640
  return void 0;
1346
- this.windowListing ??= this.listForWindow().finally(() => {
1347
- this.windowListing = void 0;
1348
- });
1349
- const abandoned = new Promise((_, reject) => {
1350
- if (signal?.aborted)
1351
- reject(signal.reason);
1352
- signal?.addEventListener("abort", () => reject(signal.reason), { once: true });
1353
- });
1354
- await Promise.race([this.windowListing, abandoned]);
1355
- signal?.throwIfAborted();
1356
- }
1357
- return this.windows?.get(model.toLowerCase());
1358
- }
1359
- /**
1360
- * The token count the account's listing says compaction starts at for `model`: its
1361
- * `auto_compact_token_limit` held to 90% of the window, or 90% of the window when it sends
1362
- * none. Shares the one listing `resolveContextWindow` asks for, with the same bounds.
1363
- */
1364
- async resolveAutoCompactLimit(model, signal) {
1365
- await this.resolveContextWindow(model, signal);
1366
- return this.compactLimits?.get(model.toLowerCase());
1367
- }
1368
- /** One bounded listing for every caller waiting on it; a failure is remembered, never thrown. */
1369
- async listForWindow() {
1370
- const controller = new AbortController();
1371
- const timer = setTimeout(() => controller.abort(), WINDOW_LISTING_TIMEOUT_MS2);
1372
- try {
1373
- await this.listModels(controller.signal);
1374
- return true;
1375
- } catch {
1376
- this.windowListingRetryAt = Date.now() + WINDOW_LISTING_RETRY_MS2;
1377
- return false;
1378
- } finally {
1379
- clearTimeout(timer);
1380
- }
1381
- }
1382
- async *chatStream(params) {
1383
- const model = this.resolveModel(params);
1384
- const targetRoute = params.providerRoute ?? {
1385
- providerId: this.id,
1386
- model,
1387
- chainIndex: 0
1388
- };
1389
- const effortLevels = this.reasoningEffortLevelsFor(model);
1390
- const built = buildRequest(params, model, targetRoute, effortLevels, subscriptionDowngrade);
1391
- const fast = params.speed === "fast" || params.speed === "ultrafast" ? assertFastModeAccepted({
1392
- route: "subscription",
1393
- model,
1394
- tier: params.speed,
1395
- advertised: this.speedTiersFor(model),
1396
- firstPartyEndpoint: true
1397
- }) : void 0;
1398
- const withTier = /* @__PURE__ */ __name((body) => fast ? { ...body, service_tier: fast.wire } : body, "withTier");
1399
- const requestedSpeed = params.speed === "fast" || params.speed === "ultrafast" ? params.speed : void 0;
1400
- const send = /* @__PURE__ */ __name((body, sessionHeader) => this.client.responses.create(withTier(body), {
1401
- signal: params.signal,
1402
- ...fast?.header || sessionHeader && params.cacheKey ? {
1403
- headers: {
1404
- ...fast?.header ?? {},
1405
- ...sessionHeader && params.cacheKey ? { session_id: params.cacheKey } : {}
1406
- }
1407
- } : {}
1408
- }), "send");
1409
- let stream;
1410
- try {
1411
- try {
1412
- stream = await send(built, !subscriptionDowngrade.legacyShape);
1413
- } catch (error) {
1414
- const refused = subscriptionDowngrade.legacyShape ? void 0 : refusedNewShape(error);
1415
- const newShapeSent = built.input !== void 0 && (Boolean(params.cacheKey) || Array.isArray(built.input) && built.input.some((item) => "role" in item && item.role === "developer"));
1416
- if (!refused || !newShapeSent || params.signal?.aborted)
1417
- throw error;
1418
- subscriptionDowngrade.legacyShape = true;
1419
- if (refused.cacheKey)
1420
- subscriptionDowngrade.noCacheKey = true;
1421
- stream = await send(buildRequest(params, model, targetRoute, effortLevels, subscriptionDowngrade), false);
1422
- }
1423
- } catch (error) {
1424
- if (isCallerAbortError(error, params.signal))
1425
- throw params.signal?.reason ?? error;
1426
- if (isProviderRequestError(error))
1427
- throw error;
1428
- throw providerVendorError({ providerId: this.id, error });
1429
- }
1430
- const callIndex = /* @__PURE__ */ new Map();
1431
- const completedItems = /* @__PURE__ */ new Map();
1432
- const textItems = /* @__PURE__ */ new Map();
1433
- let nextCallIndex = 0;
1434
- let responseId = "codex-response";
1435
- let finished = false;
1436
- try {
1437
- for await (const event of stream) {
1438
- params.signal?.throwIfAborted();
1439
- switch (event.type) {
1440
- case "response.created":
1441
- responseId = event.response.id;
1442
- break;
1443
- case "response.output_text.delta": {
1444
- const textPart = textItems.get(event.item_id);
1445
- yield {
1446
- id: responseId,
1447
- delta: {
1448
- content: event.delta,
1449
- ...textPart ? { textPart } : {}
1450
- }
1451
- };
1452
- break;
1453
- }
1454
- case "response.reasoning_summary_text.delta":
1455
- yield {
1456
- id: responseId,
1457
- delta: {
1458
- reasoning: {
1459
- index: event.output_index,
1460
- type: "thinking",
1461
- text: event.delta
1462
- }
1463
- }
1464
- };
1465
- break;
1466
- case "response.reasoning_summary_text.done":
1467
- yield {
1468
- id: responseId,
1469
- delta: {
1470
- reasoning: {
1471
- index: event.output_index,
1472
- type: "thinking",
1473
- done: true
1474
- }
1475
- }
1476
- };
1477
- break;
1478
- case "response.output_item.added":
1479
- if (event.item.type === "message" && (event.item.phase === "commentary" || event.item.phase === "final_answer"))
1480
- textItems.set(event.item.id, {
1481
- id: event.item.id,
1482
- phase: event.item.phase
1483
- });
1484
- if (event.item.type === "web_search_call") {
1485
- yield {
1486
- id: responseId,
1487
- delta: {
1488
- hostedTool: {
1489
- id: event.item.id,
1490
- name: "web_search",
1491
- status: "running",
1492
- ...webSearchDetail(event.item)
1493
- }
1494
- }
1495
- };
1496
- }
1497
- if (event.item.type === "function_call") {
1498
- const index = nextCallIndex++;
1499
- callIndex.set(event.item.id ?? event.item.call_id, index);
1500
- callIndex.set(event.item.call_id, index);
1501
- yield {
1502
- id: responseId,
1503
- delta: {
1504
- toolCalls: [
1505
- {
1506
- index,
1507
- id: event.item.call_id,
1508
- type: "function",
1509
- function: {
1510
- name: event.item.name,
1511
- arguments: event.item.arguments
1512
- }
1513
- }
1514
- ]
1515
- }
1516
- };
1517
- }
1518
- break;
1519
- case "response.function_call_arguments.delta": {
1520
- const index = callIndex.get(event.item_id) ?? event.output_index;
1521
- yield {
1522
- id: responseId,
1523
- delta: {
1524
- toolCalls: [{ index, function: { arguments: event.delta } }]
1525
- }
1526
- };
1527
- break;
1528
- }
1529
- case "response.output_item.done":
1530
- completedItems.set(event.output_index, event.item);
1531
- if (event.item.type === "web_search_call") {
1532
- yield {
1533
- id: responseId,
1534
- delta: {
1535
- hostedTool: {
1536
- id: event.item.id,
1537
- name: "web_search",
1538
- status: event.item.status === "completed" ? "completed" : "failed",
1539
- ...webSearchDetail(event.item)
1540
- }
1541
- }
1542
- };
1543
- }
1544
- if (event.item.type === "function_call") {
1545
- yield {
1546
- id: responseId,
1547
- delta: {
1548
- toolCallEnd: {
1549
- index: callIndex.get(event.item.id ?? event.item.call_id) ?? event.output_index,
1550
- id: event.item.call_id
1551
- }
1552
- }
1553
- };
1554
- }
1555
- break;
1556
- case "response.completed": {
1557
- const output = event.response.output?.length ? event.response.output : [...completedItems].sort(([left], [right]) => left - right).map(([, item]) => item);
1558
- const calls = output.filter((item) => item.type === "function_call").map((item) => ({
1559
- id: item.call_id,
1560
- name: item.name,
1561
- arguments: item.arguments
1562
- }));
1563
- const textParts = output.filter((item) => item.type === "message").map((item) => ({
1564
- id: item.id,
1565
- ...item.phase === "commentary" || item.phase === "final_answer" ? { phase: item.phase } : {},
1566
- text: item.content.filter((part) => part.type === "output_text").map((part) => part.text).join("")
1567
- }));
1568
- const phased = textParts.some((part) => part.phase !== void 0);
1569
- let content = phased ? selectAssistantText(textParts) : textParts.map((part) => part.text).join("");
1570
- const sources = /* @__PURE__ */ new Map();
1571
- for (const item of output) {
1572
- if (item.type !== "message")
1573
- continue;
1574
- for (const part of item.content) {
1575
- if (part.type !== "output_text")
1576
- continue;
1577
- for (const annotation of part.annotations ?? []) {
1578
- if (annotation.type === "url_citation" && /^https?:\/\//i.test(annotation.url) && !content.includes(annotation.url)) {
1579
- sources.set(annotation.url, annotation.title);
1580
- }
1581
- }
1582
- }
1583
- }
1584
- if (sources.size) {
1585
- const links = [...sources].map(([url, title]) => `[${title.replace(/[\[\]\r\n]/g, " ")}](<${url.replace(/[<>\s]/g, (c) => encodeURIComponent(c))}>)`).join(" \xB7 ");
1586
- const suffix = `
1587
-
1588
- Sources: ${links}`;
1589
- content += suffix;
1590
- let partIndex = textParts.length - 1;
1591
- for (let i = textParts.length - 1; i >= 0; i--) {
1592
- if (textParts[i]?.phase === "final_answer") {
1593
- partIndex = i;
1594
- break;
1595
- }
1596
- }
1597
- const part = textParts[partIndex];
1598
- if (part)
1599
- textParts[partIndex] = { ...part, text: part.text + suffix };
1600
- yield {
1601
- id: responseId,
1602
- delta: { content: suffix, contentOrigin: "driver" }
1603
- };
1604
- }
1605
- const replayState = {
1606
- kind: "namzu.codex.responses",
1607
- version: 1,
1608
- route: targetRoute,
1609
- content: content || null,
1610
- ...phased ? { textParts } : {},
1611
- toolCalls: calls,
1612
- items: output
1613
- };
1614
- finished = true;
1615
- yield {
1616
- id: event.response.id,
1617
- delta: {},
1618
- ...phased ? { textParts } : {},
1619
- finishReason: calls.length > 0 ? "tool_calls" : "stop",
1620
- usage: responseUsage(event.response.usage ?? {}, event.response.service_tier, requestedSpeed),
1621
- replayState
1622
- };
1623
- break;
1624
- }
1625
- case "response.incomplete": {
1626
- const reason = event.response.incomplete_details?.reason;
1641
+ const controller = new AbortController();
1642
+ const forward = /* @__PURE__ */ __name(() => controller.abort(), "forward");
1643
+ signal?.addEventListener("abort", forward, { once: true });
1644
+ const timer = setTimeout(forward, WINDOW_LISTING_TIMEOUT_MS2);
1645
+ try {
1646
+ const listed = await this.listModels(controller.signal);
1647
+ this.declaredWindows ??= new Map(listed.flatMap((entry) => entry.contextWindow !== void 0 ? [[entry.id, entry.contextWindow]] : []));
1648
+ } catch {
1649
+ signal?.throwIfAborted();
1650
+ this.windowListingRetryAt = Date.now() + WINDOW_LISTING_RETRY_MS2;
1651
+ return void 0;
1652
+ } finally {
1653
+ clearTimeout(timer);
1654
+ signal?.removeEventListener("abort", forward);
1655
+ }
1656
+ }
1657
+ return this.declaredWindows.get(model);
1658
+ }
1659
+ /**
1660
+ * The Responses transport for this key, built on the subscription driver's
1661
+ * request and stream handling. Only used on OpenAI's own endpoint.
1662
+ */
1663
+ responsesRoute() {
1664
+ this.responses ??= new CodexProvider({
1665
+ responsesApi: true,
1666
+ apiKey: this.config.apiKey,
1667
+ model: this.defaultModel,
1668
+ ...this.effectiveBaseURL ? { baseURL: this.effectiveBaseURL } : {},
1669
+ organization: this.config.organization,
1670
+ project: this.config.project,
1671
+ timeout: this.config.timeout,
1672
+ maxRetries: this.config.maxRetries,
1673
+ defaultHeaders: { ...attributionHeaders(), ...this.config.defaultHeaders ?? {} }
1674
+ });
1675
+ return this.responses;
1676
+ }
1677
+ resolveModel(params) {
1678
+ const model = params.model || this.defaultModel;
1679
+ if (!model) {
1680
+ throw new Error("OpenAIProvider: model is required. Pass `model` in config or on the chat call.");
1681
+ }
1682
+ return model;
1683
+ }
1684
+ reasoningEffortLevelsFor(model) {
1685
+ return openAIReasoningEffortLevels(model);
1686
+ }
1687
+ async *chatStream(params) {
1688
+ const model = this.resolveModel(params);
1689
+ assertThinkingSupported(params);
1690
+ assertOpenAIReasoningEffort(model, params.effort);
1691
+ const firstParty = !this.compatibleHost;
1692
+ if (firstParty && openAIModelNeedsResponses(model, params)) {
1693
+ yield* this.responsesRoute().chatStream({ ...params, model });
1694
+ return;
1695
+ }
1696
+ const dropsSampling = firstParty && !takesSamplingFields(model, params.effort);
1697
+ const effort = firstParty && refusesReasoningEffort(model) ? void 0 : params.effort;
1698
+ const reasoningOff = params.effort === "none" || params.thinking?.type === "disabled";
1699
+ const offFields = reasoningOff ? typeof this.thinkingOffFields === "function" ? this.thinkingOffFields(model) : this.thinkingOffFields : void 0;
1700
+ let serviceTier;
1701
+ if (params.speed === "fast" || params.speed === "ultrafast") {
1702
+ const accepted = assertFastModeAccepted({
1703
+ route: "api",
1704
+ model,
1705
+ tier: params.speed,
1706
+ firstPartyEndpoint: !this.compatibleHost,
1707
+ host: hostOf(this.effectiveBaseURL)
1708
+ });
1709
+ serviceTier = accepted.wire === "priority" ? "priority" : void 0;
1710
+ }
1711
+ const requestedSpeed = params.speed === "fast" ? "fast" : void 0;
1712
+ let stream;
1713
+ try {
1714
+ stream = await this.client.chat.completions.create(
1715
+ withReasoningEffort({
1716
+ model,
1717
+ messages: toOpenAIMessages(params.messages),
1718
+ stream: true,
1719
+ stream_options: { include_usage: true },
1720
+ tools: toOpenAITools(params),
1721
+ tool_choice: formatToolChoice(params.toolChoice),
1722
+ parallel_tool_calls: params.parallelToolCalls,
1723
+ ...dropsSampling ? {} : {
1724
+ temperature: params.temperature,
1725
+ top_p: params.topP,
1726
+ frequency_penalty: params.frequencyPenalty,
1727
+ presence_penalty: params.presencePenalty
1728
+ },
1729
+ ...firstParty ? { max_completion_tokens: params.maxTokens } : { max_tokens: params.maxTokens },
1730
+ stop: params.stop,
1731
+ response_format: params.responseFormat,
1732
+ ...serviceTier ? { service_tier: serviceTier } : {},
1733
+ ...offFields ?? {}
1734
+ }, effort),
1735
+ // Per-request abort: a Stop tears the in-flight SSE request down.
1736
+ { signal: params.signal }
1737
+ );
1738
+ } catch (err) {
1739
+ if (isCallerAbortError(err, params.signal))
1740
+ throw params.signal?.reason ?? err;
1741
+ if (isProviderRequestError(err))
1742
+ throw err;
1743
+ if (firstParty && isResponsesOnlyRefusal(err)) {
1744
+ learnedResponsesModels.add(model.toLowerCase().replace(/^ft:/, ""));
1745
+ yield* this.responsesRoute().chatStream({ ...params, model });
1746
+ return;
1747
+ }
1748
+ throw providerVendorError({ providerId: "openai", error: err });
1749
+ }
1750
+ let finished = false;
1751
+ let servedTier;
1752
+ try {
1753
+ for await (const chunk of stream) {
1754
+ const echoed = chunk.service_tier;
1755
+ if (typeof echoed === "string" && echoed.length > 0)
1756
+ servedTier = echoed;
1757
+ params.signal?.throwIfAborted();
1758
+ try {
1759
+ const choice = chunk.choices[0];
1760
+ const delta = choice?.delta;
1761
+ const extra = delta;
1762
+ const emitted = typeof extra?.reasoning_content === "string" ? extra.reasoning_content : typeof extra?.reasoning === "string" ? extra.reasoning : void 0;
1763
+ const reasoning = reasoningOff ? void 0 : emitted;
1764
+ const toolCalls = delta?.tool_calls?.map((tc) => ({
1765
+ index: tc.index,
1766
+ id: tc.id,
1767
+ type: tc.type,
1768
+ function: tc.function ? {
1769
+ name: tc.function.name,
1770
+ arguments: tc.function.arguments
1771
+ } : void 0
1772
+ }));
1773
+ const hasDelta = delta?.content !== void 0 && delta.content !== null || reasoning !== void 0 && reasoning.length > 0 || toolCalls && toolCalls.length > 0;
1774
+ const finishReason = choice?.finish_reason ? mapFinishReason(choice.finish_reason) : void 0;
1775
+ const usage = chunk.usage ? parseUsage(chunk.usage, servedTier, requestedSpeed) : void 0;
1776
+ if (finishReason)
1627
1777
  finished = true;
1628
- yield {
1629
- id: event.response.id,
1630
- delta: {},
1631
- finishReason: reason === "content_filter" ? "content_filter" : "length",
1632
- ...reason === "content_filter" ? { refusal: {} } : {},
1633
- usage: responseUsage(event.response.usage ?? {}, event.response.service_tier, requestedSpeed)
1634
- };
1635
- break;
1636
- }
1637
- case "error":
1638
- case "response.failed":
1639
- throw new ProviderRequestError({
1640
- kind: "server",
1641
- providerId: this.id,
1642
- detail: "the Codex Responses stream failed"
1643
- });
1778
+ if (!hasDelta && !finishReason && !usage)
1779
+ continue;
1780
+ yield {
1781
+ id: chunk.id,
1782
+ delta: {
1783
+ content: delta?.content ?? void 0,
1784
+ ...reasoning ? {
1785
+ reasoning: {
1786
+ index: 0,
1787
+ type: "thinking",
1788
+ text: reasoning
1789
+ }
1790
+ } : {},
1791
+ toolCalls
1792
+ },
1793
+ finishReason,
1794
+ // A content filter stopped the reply; the API says nothing more.
1795
+ ...finishReason === "content_filter" ? { refusal: {} } : {},
1796
+ usage
1797
+ };
1798
+ } catch (parseErr) {
1799
+ if (isProviderRequestError(parseErr))
1800
+ throw parseErr;
1801
+ throw new ProviderRequestError({
1802
+ kind: "server",
1803
+ providerId: "openai",
1804
+ detail: "the provider stream returned malformed data"
1805
+ });
1644
1806
  }
1645
1807
  }
1646
1808
  if (!finished) {
1647
1809
  throw new ProviderRequestError({
1648
1810
  kind: "network",
1649
- providerId: this.id,
1811
+ providerId: "openai",
1650
1812
  detail: "the connection closed before the response finished"
1651
1813
  });
1652
1814
  }
1653
- } catch (error) {
1654
- if (isCallerAbortError(error, params.signal))
1655
- throw params.signal?.reason ?? error;
1656
- if (isProviderRequestError(error))
1657
- throw error;
1658
- throw providerVendorError({ providerId: this.id, error });
1815
+ } catch (err) {
1816
+ if (isCallerAbortError(err, params.signal))
1817
+ throw params.signal?.reason ?? err;
1818
+ if (isProviderRequestError(err))
1819
+ throw err;
1820
+ throw providerVendorError({ providerId: "openai", error: err });
1659
1821
  }
1660
1822
  }
1661
- async listModels(signal) {
1823
+ /**
1824
+ * Declared even though this driver's listing already fails correctly on a
1825
+ * bad key. The check is a declared capability rather than something inferred
1826
+ * from whether a menu happened to throw, so a driver that answers the
1827
+ * question has to say so — otherwise it is reported unverifiable, which is
1828
+ * the honest default and would be a regression here.
1829
+ */
1830
+ async probeCredential(signal) {
1662
1831
  signal?.throwIfAborted();
1663
- const response = await this.client.get(`/models?client_version=${MODELS_CLIENT_VERSION}`, {
1664
- signal
1665
- });
1832
+ await this.client.models.list(signal ? { signal } : void 0);
1666
1833
  signal?.throwIfAborted();
1667
- const profiles = /* @__PURE__ */ new Map();
1668
- const tiersBySlug = /* @__PURE__ */ new Map();
1669
- const windows = /* @__PURE__ */ new Map();
1670
- const compactLimits = /* @__PURE__ */ new Map();
1671
- const models = (Array.isArray(response.models) ? response.models : []).flatMap((value) => {
1672
- const item = record(value);
1673
- if (typeof item?.slug !== "string" || item.slug.length === 0)
1674
- return [];
1675
- if (item.visibility === "hide" || item.visibility === "hidden")
1676
- return [];
1677
- const profile = subscriptionReasoningProfile(item);
1678
- if (profile)
1679
- profiles.set(item.slug.toLowerCase(), profile);
1680
- const speedTiers = subscriptionSpeedTiers(item);
1681
- tiersBySlug.set(item.slug.toLowerCase(), speedTiers);
1682
- const { contextWindow, autoCompactTokenLimit } = subscriptionLimits(item);
1683
- if (contextWindow !== void 0)
1684
- windows.set(item.slug.toLowerCase(), contextWindow);
1685
- if (autoCompactTokenLimit !== void 0)
1686
- compactLimits.set(item.slug.toLowerCase(), autoCompactTokenLimit);
1687
- return [
1688
- {
1689
- id: item.slug,
1690
- name: typeof item.display_name === "string" ? item.display_name : item.slug,
1691
- supportsToolUse: true,
1692
- supportsStreaming: true,
1693
- ...profile ? { reasoningEffortLevels: profile.levels } : {},
1694
- ...profile?.default !== void 0 ? { reasoningEffortDefault: profile.default } : {},
1695
- speedTiers,
1696
- ...contextWindow !== void 0 ? { contextWindow } : {},
1697
- ...autoCompactTokenLimit !== void 0 ? { autoCompactTokenLimit } : {}
1698
- }
1699
- ];
1700
- });
1701
- this.reasoningProfiles = profiles;
1702
- this.speedTiers = tiersBySlug;
1703
- this.windows = windows;
1704
- this.compactLimits = compactLimits;
1705
- listingByAccount.set(this.listingKey, {
1706
- speedTiers: tiersBySlug,
1707
- reasoningProfiles: profiles,
1708
- windows,
1709
- compactLimits
1710
- });
1711
- return models;
1712
1834
  }
1713
- async probeCredential(signal) {
1714
- await this.listModels(signal);
1835
+ async listModels(signal) {
1836
+ signal?.throwIfAborted();
1837
+ const page = await this.client.models.list(signal ? { signal } : void 0);
1838
+ signal?.throwIfAborted();
1839
+ const rows = this.compatibleHost ? page.data : chatModelsOnly(page.data);
1840
+ return rows.map((m) => ({
1841
+ id: m.id,
1842
+ name: m.id,
1843
+ supportsToolUse: true,
1844
+ supportsStreaming: true,
1845
+ ...compatibleModelMetadata(m)
1846
+ }));
1715
1847
  }
1716
1848
  async healthCheck() {
1717
1849
  try {
1718
- await this.probeCredential();
1850
+ await this.client.models.list();
1719
1851
  return true;
1720
1852
  } catch {
1721
1853
  return false;
1722
1854
  }
1723
1855
  }
1724
1856
  };
1725
- function webSearchDetail(item) {
1726
- const action = item.action;
1727
- if (!action || typeof action !== "object")
1728
- return {};
1729
- const queries = Array.isArray(action.queries) ? action.queries.filter((q) => typeof q === "string" && q.trim().length > 0) : [];
1730
- const query = typeof action.query === "string" && action.query.trim().length > 0 ? action.query.trim() : queries[0]?.trim();
1731
- const url = typeof action.url === "string" && action.url.length > 0 ? action.url : void 0;
1732
- return {
1733
- ...query ? { query } : {},
1734
- ...url && !query ? { url } : {},
1735
- ...Array.isArray(action.sources) ? { results: action.sources.length } : {},
1736
- // One hosted item may run several queries; the count says so, the label names the first.
1737
- ...queries.length > 1 ? { searches: queries.length } : {}
1738
- };
1739
- }
1740
- __name(webSearchDetail, "webSearchDetail");
1741
1857
 
1742
1858
  // ../providers/openai/dist/index.js
1743
1859
  function registerCodex(options) {
@@ -1756,9 +1872,6 @@ export {
1756
1872
  supportsFastMode,
1757
1873
  isFirstPartyOpenAIEndpoint,
1758
1874
  servedSpeed,
1759
- OPENAI_CAPABILITIES,
1760
- openAIReasoningEffortLevels,
1761
- OpenAIProvider,
1762
1875
  CODEX_IMAGE_MODEL,
1763
1876
  CODEX_DEFAULT_BASE_URL,
1764
1877
  CODEX_IMAGE_TIMEOUT_MS,
@@ -1769,7 +1882,10 @@ export {
1769
1882
  requestCodexImage,
1770
1883
  CODEX_CAPABILITIES,
1771
1884
  CodexProvider,
1885
+ OPENAI_CAPABILITIES,
1886
+ openAIReasoningEffortLevels,
1887
+ OpenAIProvider,
1772
1888
  registerCodex,
1773
1889
  registerOpenAI
1774
1890
  };
1775
- //# sourceMappingURL=chunk-A2GT47E2.js.map
1891
+ //# sourceMappingURL=chunk-V2DQFFLG.js.map