@organizaone/o1-code 0.10.4 → 0.12.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 (344) hide show
  1. package/bundled/qc-helper/docs/extension/introduction.md +23 -9
  2. package/bundled/qc-helper/docs/features/commands.md +1 -0
  3. package/chunks/{MaxSizedBox-VHZXGVLW.js → MaxSizedBox-JTZPQAQ5.js} +66 -66
  4. package/chunks/{StandaloneSessionPicker-3EROWATU.js → StandaloneSessionPicker-VFQEG54H.js} +88 -88
  5. package/chunks/{acp-subagent-executor-GWQKAEPB.js → acp-subagent-executor-QEOKYURZ.js} +70 -70
  6. package/chunks/{acpAgent-AL6KTCSY.js → acpAgent-5MQXC2XU.js} +229 -227
  7. package/chunks/{agent-RU7E6G34.js → agent-FKFYDUVP.js} +42 -42
  8. package/chunks/{agent-headless-M4PN25BD.js → agent-headless-TVPFCEOP.js} +42 -42
  9. package/chunks/all-providers-CAKB5HCH.js +73 -0
  10. package/chunks/{anthropicContentGenerator-6TKL2GXG.js → anthropicContentGenerator-K2ELMX7W.js} +121 -73
  11. package/chunks/{bridge-SEYIHH6G.js → bridge-33WHGPXZ.js} +71 -71
  12. package/chunks/{bwrap-execution-UZAMPG6F.js → bwrap-execution-FIGUBZCN.js} +6 -6
  13. package/chunks/{caption-audio-HGDJVVJZ.js → caption-audio-EK6K45W3.js} +8 -8
  14. package/chunks/{caption-image-ATZSXV7W.js → caption-image-WDXLQK6T.js} +6 -6
  15. package/chunks/{chunk-SOWXEFJH.js → chunk-32XL2YY2.js} +2434 -4254
  16. package/chunks/{chunk-3PVG3FQN.js → chunk-3EPSY3X7.js} +9 -9
  17. package/chunks/{chunk-CNOWGY7D.js → chunk-3T72AXG7.js} +6 -6
  18. package/chunks/{chunk-VCNQFVKJ.js → chunk-3YUQQOUL.js} +13 -13
  19. package/chunks/{chunk-RMWEXCAN.js → chunk-46JJPOUF.js} +3 -3
  20. package/chunks/{chunk-WUP5273H.js → chunk-4G6OUQPH.js} +3 -3
  21. package/chunks/{chunk-QCONHGJR.js → chunk-4OUIZHHJ.js} +4 -4
  22. package/chunks/{chunk-QYUMJTBP.js → chunk-4SJO2I35.js} +1 -1
  23. package/chunks/{chunk-TAFMMFLK.js → chunk-4X3MIKOZ.js} +5 -5
  24. package/chunks/{chunk-HCE5HUQG.js → chunk-55BVGW3L.js} +4 -4
  25. package/chunks/{chunk-5CB4U6DS.js → chunk-5AIPNJAB.js} +5 -5
  26. package/chunks/{chunk-ODYKSVON.js → chunk-5NNMFA5J.js} +1 -1
  27. package/chunks/{chunk-OCTSNICG.js → chunk-5OGI74MG.js} +2 -2
  28. package/chunks/{chunk-FHXZKNON.js → chunk-5ZO4TG64.js} +4 -4
  29. package/chunks/{chunk-WWNTQFH7.js → chunk-62SWENB6.js} +2 -2
  30. package/chunks/{chunk-3KUQCZUE.js → chunk-65JWVPGE.js} +1 -1
  31. package/chunks/{chunk-SWJZH7BK.js → chunk-65NGV7DR.js} +11 -11
  32. package/chunks/{chunk-VOETOZWN.js → chunk-6O3ZQGW7.js} +1 -1
  33. package/chunks/{chunk-67LZSGOU.js → chunk-6WTLQ4BD.js} +1 -1
  34. package/chunks/{chunk-CF5SF4G5.js → chunk-72EBG4FJ.js} +3 -471
  35. package/chunks/{chunk-VHIYZGUD.js → chunk-776VI66O.js} +2 -2
  36. package/chunks/{chunk-HD3KYIZP.js → chunk-7JEEDCZF.js} +3 -3
  37. package/chunks/{chunk-VVRQLG57.js → chunk-7LQNUREG.js} +1 -1
  38. package/chunks/chunk-7TK6OY2J.js +53 -0
  39. package/chunks/{chunk-6NXC4BI5.js → chunk-ADPTJZ7L.js} +3 -3
  40. package/chunks/{chunk-2VE7AXYY.js → chunk-AKIPIOIW.js} +62 -36
  41. package/chunks/{chunk-ZDBDDHSP.js → chunk-BF6VCZFG.js} +4 -4
  42. package/chunks/{chunk-NDK2PD5Y.js → chunk-C7LS4YW3.js} +1 -1
  43. package/chunks/{chunk-ZHMOCPV6.js → chunk-D56JIPBA.js} +3 -3
  44. package/chunks/{chunk-BKKZR7X4.js → chunk-DBPKYUKM.js} +5 -5
  45. package/chunks/{chunk-RJUVWCC5.js → chunk-DNJPSAMC.js} +1 -1
  46. package/chunks/{chunk-KMTAGPIN.js → chunk-DOG2T422.js} +2 -2
  47. package/chunks/{chunk-PYIWZPBY.js → chunk-DOWMMDKU.js} +9 -9
  48. package/chunks/{chunk-HFXEXI4S.js → chunk-EMXZMR7F.js} +322 -109
  49. package/chunks/{chunk-ME5CDTOQ.js → chunk-EO3GEEN5.js} +3 -3
  50. package/chunks/{chunk-RS2LNQEC.js → chunk-EVC2HZ5T.js} +3 -39
  51. package/chunks/{chunk-MIWMCUU5.js → chunk-EVIJNKSX.js} +17 -8
  52. package/chunks/{chunk-W2SFVYBK.js → chunk-EWBEXGRC.js} +10 -10
  53. package/chunks/{chunk-NHRB3THC.js → chunk-EXTCLF42.js} +2 -2
  54. package/chunks/{chunk-Y6AFQKTE.js → chunk-F36DMAAF.js} +5 -5
  55. package/chunks/{chunk-4EYPKVHD.js → chunk-FEQM3UVX.js} +8 -8
  56. package/chunks/{chunk-V75J4GJ2.js → chunk-FJAZPBX2.js} +1 -1
  57. package/chunks/{chunk-43427ZT3.js → chunk-FJB4BIQY.js} +1 -1
  58. package/chunks/{chunk-WS3L2RKL.js → chunk-FL43SLBB.js} +36 -36
  59. package/chunks/{chunk-FII3ST7W.js → chunk-FOGGBV5D.js} +3 -3
  60. package/chunks/{chunk-JQPMOOCH.js → chunk-FXR7OHQM.js} +1 -1
  61. package/chunks/{chunk-DVRWYOU6.js → chunk-GQ2KSD3A.js} +1 -1
  62. package/chunks/{chunk-QLP5B3HQ.js → chunk-GSMPZG6N.js} +1 -1
  63. package/chunks/{chunk-YHWOPL2T.js → chunk-H4FGPXI3.js} +65 -64
  64. package/chunks/{chunk-7PYXIRCE.js → chunk-H4K55KOQ.js} +5 -5
  65. package/chunks/{chunk-7ODOX4UM.js → chunk-IKYYF5PP.js} +388 -620
  66. package/chunks/{chunk-PF7G5TYG.js → chunk-J2WSYRAJ.js} +28 -28
  67. package/chunks/{chunk-ADBL3IRA.js → chunk-J33WTLCX.js} +5 -5
  68. package/chunks/{chunk-7M4NSLWM.js → chunk-JOBZWTVK.js} +1 -1
  69. package/chunks/{chunk-SKU7JRIS.js → chunk-K3RGDBVU.js} +3 -3
  70. package/chunks/{chunk-EHYUNTVE.js → chunk-KCBAWQGT.js} +19 -19
  71. package/chunks/{chunk-WQBWL6YE.js → chunk-KD2QZWRE.js} +12 -10
  72. package/chunks/{chunk-DVJZ2C55.js → chunk-KEBHJIGX.js} +4 -4
  73. package/chunks/{chunk-NSH5JHZH.js → chunk-KYFNPY5G.js} +1 -1
  74. package/chunks/{chunk-DHPOSTBT.js → chunk-M2HUTNAI.js} +7 -7
  75. package/chunks/{chunk-UX6ZDNDO.js → chunk-MKBG6C2K.js} +1 -1
  76. package/chunks/{chunk-RUPTHAC7.js → chunk-MMVLDNOK.js} +5 -5
  77. package/chunks/{chunk-H2DCMLIK.js → chunk-MRR2UVN6.js} +4 -4
  78. package/chunks/{chunk-P35MCCDH.js → chunk-NIOE4OJE.js} +1 -1
  79. package/chunks/{chunk-AJSSTPJK.js → chunk-NLDWAN5E.js} +1 -1
  80. package/chunks/{chunk-OJSW65PQ.js → chunk-NOL6NAWN.js} +1 -1
  81. package/chunks/{chunk-LIAMHIGS.js → chunk-NPGATJZA.js} +2 -2
  82. package/chunks/{chunk-XHYWPHWN.js → chunk-NQTVSCZM.js} +1 -1
  83. package/chunks/chunk-NTDRNHKB.js +484 -0
  84. package/chunks/{chunk-TBSUV4QV.js → chunk-NTHY5RR5.js} +2 -2
  85. package/chunks/{chunk-KPRPJMSP.js → chunk-O43YWGHK.js} +1 -1
  86. package/chunks/{chunk-KGDJZNQC.js → chunk-OF7SHQ7M.js} +3 -3
  87. package/chunks/{chunk-QATTWMLJ.js → chunk-OP553VGL.js} +8 -8
  88. package/chunks/{chunk-7GSPYBET.js → chunk-OS6CVNKI.js} +1 -1
  89. package/chunks/{chunk-7LFCBMVX.js → chunk-P4F73WS7.js} +1 -1
  90. package/chunks/{chunk-CKKPLKIP.js → chunk-PD4HVHCC.js} +1 -1
  91. package/chunks/{chunk-5E373J3N.js → chunk-Q5CQXESD.js} +1 -1
  92. package/chunks/{chunk-T7M2HD7D.js → chunk-QFMADEHM.js} +1 -1
  93. package/chunks/{chunk-4XS46ASJ.js → chunk-QFUVHWOM.js} +1 -1
  94. package/chunks/{chunk-VLALIFPR.js → chunk-QJQOFPJ5.js} +18 -18
  95. package/chunks/{chunk-HDVJIXPT.js → chunk-QNHUPN6K.js} +3 -3
  96. package/chunks/{chunk-TI76PXY3.js → chunk-RE37G7GK.js} +7 -7
  97. package/chunks/{chunk-EZCJ26MU.js → chunk-RRYTDYCK.js} +4 -4
  98. package/chunks/{chunk-GGUL6GZ5.js → chunk-RS2CMJTM.js} +1 -1
  99. package/chunks/{chunk-545ROI6V.js → chunk-S5H5TQN4.js} +1 -1
  100. package/chunks/{chunk-V7NIAOMT.js → chunk-S5QFGJXY.js} +7 -7
  101. package/chunks/{chunk-ER3EHNTV.js → chunk-SPTU3FVH.js} +4 -4
  102. package/chunks/chunk-TC2TJAOF.js +1365 -0
  103. package/chunks/{chunk-5Y44KHOU.js → chunk-TFFOK3SJ.js} +1 -1
  104. package/chunks/{chunk-AIGLVHBV.js → chunk-TJRZBOWB.js} +6 -6
  105. package/chunks/chunk-TL23ZRID.js +327 -0
  106. package/chunks/{chunk-QMCDBQRJ.js → chunk-TP3M5WJ2.js} +1 -1
  107. package/chunks/chunk-TPHHBX2V.js +372 -0
  108. package/chunks/{chunk-7JG3HELJ.js → chunk-TXTBBSFN.js} +6 -6
  109. package/chunks/{chunk-AGMYBSIU.js → chunk-U5W3UVUJ.js} +15 -15
  110. package/chunks/{chunk-L4XP2BXW.js → chunk-UEBG3R2E.js} +19 -19
  111. package/chunks/{chunk-N7NBYHMJ.js → chunk-UNY7AZRV.js} +1 -1
  112. package/chunks/{chunk-CPWPD6SR.js → chunk-VBCZ36HL.js} +16 -12
  113. package/chunks/{chunk-N5MLNIET.js → chunk-VCQ6UT2V.js} +86 -86
  114. package/chunks/{chunk-NKHM3QSK.js → chunk-VGJTZHV4.js} +28 -28
  115. package/chunks/{chunk-XOVXSDNN.js → chunk-VPFTCMMK.js} +1 -1
  116. package/chunks/{chunk-UFXAWOXR.js → chunk-VSGHHI2A.js} +1 -1
  117. package/chunks/{chunk-FQO3QDB5.js → chunk-VT3TJFQR.js} +1 -1
  118. package/chunks/{chunk-TUTCCLI7.js → chunk-VWSBLBKL.js} +2 -2
  119. package/chunks/{chunk-IK7Y64IL.js → chunk-W52IXLWZ.js} +2 -2
  120. package/chunks/{chunk-H75LW27M.js → chunk-W7TFIXSV.js} +8 -6
  121. package/chunks/chunk-WBPIFM2X.js +2008 -0
  122. package/chunks/{chunk-OVTUMTW6.js → chunk-WDHSE635.js} +4 -4
  123. package/chunks/{chunk-M2EBVYXC.js → chunk-WK44MSGW.js} +1 -1
  124. package/chunks/{chunk-H7LYSOSQ.js → chunk-WSEWAUUB.js} +1 -1
  125. package/chunks/{chunk-FJHDFJVI.js → chunk-WSHOWMUB.js} +1 -1
  126. package/chunks/{chunk-WCWPITU4.js → chunk-WVGCMQD5.js} +1 -1
  127. package/chunks/{chunk-BEI5P3M7.js → chunk-XD6GHBUY.js} +9 -9
  128. package/chunks/{chunk-NAKKROMI.js → chunk-XDTO4IJ3.js} +2 -2
  129. package/chunks/{chunk-YXR7EEJO.js → chunk-XRY5FMOE.js} +2 -2
  130. package/chunks/{chunk-ZSP6FDZ2.js → chunk-YII34AZ7.js} +13 -13
  131. package/chunks/{chunk-RX5J7HHZ.js → chunk-ZGPPP7FC.js} +30 -30
  132. package/chunks/{chunk-ZQBNP2ZQ.js → chunk-ZRO2FPEP.js} +4 -4
  133. package/chunks/{chunk-HOLP2BCW.js → chunk-ZUP2FFM5.js} +4 -4
  134. package/chunks/{codex-subagent-executor-UGS4BKXM.js → codex-subagent-executor-6GZ7UBTB.js} +70 -70
  135. package/chunks/{contextCommand-ADTFEKEK.js → contextCommand-RK4SGQXM.js} +69 -69
  136. package/chunks/{core-runtime-QIWPENIC.js → core-runtime-Z3MAZ6W4.js} +78 -78
  137. package/chunks/{create-sub-session-IU3OMOYV.js → create-sub-session-KWT7I6XG.js} +72 -72
  138. package/chunks/{daemon-git-worktree-guard-BLBIBY4P.js → daemon-git-worktree-guard-RVYAPX2W.js} +68 -68
  139. package/chunks/{daemon-status-provider-QQYQA54F.js → daemon-status-provider-7Q4AQLU7.js} +76 -76
  140. package/chunks/{daemon-trust-policy-RL42K32W.js → daemon-trust-policy-K6KAYOII.js} +74 -74
  141. package/chunks/{daemon-trust-policy-monitor-W6A2KI3R.js → daemon-trust-policy-monitor-L2HR4KDO.js} +74 -74
  142. package/chunks/{deferred-core-runtime-7IMZJYKO.js → deferred-core-runtime-B3GYIW7X.js} +66 -66
  143. package/chunks/{display-image-U6HZKF3G.js → display-image-ETU7QIAC.js} +2 -2
  144. package/chunks/{edit-XEHFRLTK.js → edit-DHFV3SJW.js} +44 -44
  145. package/chunks/{en-2EMGSVEU.js → en-PCBCZAUA.js} +66 -3
  146. package/chunks/{enter-worktree-A2WD27HQ.js → enter-worktree-OZOIH6KH.js} +4 -4
  147. package/chunks/{enterPlanMode-TJNAVH6W.js → enterPlanMode-FHBSHN7T.js} +42 -42
  148. package/chunks/{environment-EINU6SZC.js → environment-SJ2O6HRJ.js} +69 -69
  149. package/chunks/{errors-2IFCUYY5.js → errors-SLII5WDL.js} +69 -69
  150. package/chunks/{execution-sandbox-config-YE2XOT56.js → execution-sandbox-config-EYZYM2IC.js} +7 -7
  151. package/chunks/{execution-tool-SZ4AURPN.js → execution-tool-VRA7QCXP.js} +45 -45
  152. package/chunks/{execution-worker-WHSC3ZGX.js → execution-worker-LT2EFVHR.js} +50 -50
  153. package/chunks/{exit-worktree-S7KUQ4HO.js → exit-worktree-W5TC4B4C.js} +4 -4
  154. package/chunks/{exitPlanMode-PAZMVUS6.js → exitPlanMode-XQ75FETK.js} +42 -42
  155. package/chunks/{fast-path-W6DEVJVB.js → fast-path-NQQ53WED.js} +2 -2
  156. package/chunks/{glob-WJQOKIRP.js → glob-7SQOB5CX.js} +42 -42
  157. package/chunks/{goal-tools-CDMDPDOI.js → goal-tools-4GR2BFFX.js} +42 -42
  158. package/chunks/{handleAutoUpdate-JRPITHAS.js → handleAutoUpdate-OLVCIBDN.js} +70 -70
  159. package/chunks/{i18n-4PMXKRMM.js → i18n-NXRBYDXM.js} +68 -68
  160. package/chunks/{image-gen-GRJ73O3N.js → image-gen-Q4E7L7EV.js} +3 -6
  161. package/chunks/{initializer-NHTBAZUN.js → initializer-NGPV43CI.js} +74 -74
  162. package/chunks/{installationInfo-OTUBAVXR.js → installationInfo-U5NUDGQV.js} +66 -66
  163. package/chunks/{keychain-token-storage-NDVFNJI5.js → keychain-token-storage-SJOKJDWV.js} +2 -1
  164. package/chunks/{list-OIRYDK5J.js → list-WUD2DUO4.js} +77 -77
  165. package/chunks/{llm-CWNQ7Z4U.js → llm-3GFPNXO6.js} +142 -142
  166. package/chunks/{llm-content-generator-5662XHRK.js → llm-content-generator-5CTS3JEL.js} +8 -6
  167. package/chunks/{loadedSettingsAdapter-E7AA2YEL.js → loadedSettingsAdapter-45PMLPYE.js} +74 -74
  168. package/chunks/{local-execution-environment-HRGLGYYE.js → local-execution-environment-XJ5Y5J5E.js} +50 -50
  169. package/chunks/{loggingContentGenerator-S434PEH5.js → loggingContentGenerator-BJHOK6Q7.js} +69 -69
  170. package/chunks/{managed-npm-update-OLKKN32W.js → managed-npm-update-TCLLJP27.js} +66 -66
  171. package/chunks/{mcp-HHJNHR4Y.js → mcp-LJGCW5XK.js} +74 -74
  172. package/chunks/{memory-side-query-EHR7FGIB.js → memory-side-query-BSVTSKCB.js} +7 -7
  173. package/chunks/{model-call-collection-CQDJ77VA.js → model-call-collection-GCSBAMPN.js} +7 -7
  174. package/chunks/{model-configuration-K26C67NU.js → model-configuration-N6EASNX6.js} +75 -75
  175. package/chunks/{modelConfigUtils-OME5BXU4.js → modelConfigUtils-4O46TEAJ.js} +68 -68
  176. package/chunks/{monitor-YAWMJU7P.js → monitor-OOKJVU73.js} +42 -42
  177. package/chunks/{nonInteractiveCli-MPZIO64Q.js → nonInteractiveCli-6H3CIYOC.js} +113 -113
  178. package/chunks/{nonInteractiveToolExecutor-AIM44M2P.js → nonInteractiveToolExecutor-MWOHBQ3G.js} +43 -43
  179. package/chunks/{notebook-edit-FTYD3OR2.js → notebook-edit-CG5ZTY7N.js} +43 -43
  180. package/chunks/{ocr-image-ZJCSAMSQ.js → ocr-image-O6ECQNUE.js} +6 -6
  181. package/chunks/{omni-RULYOVJP.js → omni-MWVCLGTK.js} +40 -42
  182. package/chunks/{openaiContentGenerator-HYNXDAHQ.js → openaiContentGenerator-XDEGXNI6.js} +62 -59
  183. package/chunks/{openaiResponsesContentGenerator-TK2Y64AP.js → openaiResponsesContentGenerator-KVV57AK6.js} +40 -24
  184. package/chunks/{processUtils-VKDQXNAC.js → processUtils-7C3HIK43.js} +2 -2
  185. package/chunks/{prompt-terminal-ledger-BAOIS32T.js → prompt-terminal-ledger-R4EB443Y.js} +67 -67
  186. package/chunks/{pt-BM6ETOUU.js → pt-3QNK7RYA.js} +66 -3
  187. package/chunks/{reactive-degrade-L6W5KNGV.js → reactive-degrade-6JECKK6A.js} +25 -23
  188. package/chunks/{read-file-G4G5LOGO.js → read-file-2V6MBYCS.js} +12 -11
  189. package/chunks/{recall-media-memory-tool-GAR6JWON.js → recall-media-memory-tool-WIFEB2OG.js} +5 -5
  190. package/chunks/{record-artifact-PL2T5AJY.js → record-artifact-IVE6QT4D.js} +3 -3
  191. package/chunks/{record-source-ANENC5K7.js → record-source-U53PRXYX.js} +5 -5
  192. package/chunks/{report-findings-RFO53756.js → report-findings-W75NCFXY.js} +4 -4
  193. package/chunks/{request-shutdown-LRWCJOEG.js → request-shutdown-E5QAHOAD.js} +4 -4
  194. package/chunks/{resumeHistoryUtils-ECDR2CS2.js → resumeHistoryUtils-OA7LAAZ7.js} +72 -72
  195. package/chunks/{ripGrep-2MEBBDSU.js → ripGrep-KR5EE3HU.js} +14 -13
  196. package/chunks/{run-o1-code-serve-PH2GYSP2.js → run-o1-code-serve-RJHXITCF.js} +59 -59
  197. package/chunks/{runtime-shell-policy-Y3TGAQLT.js → runtime-shell-policy-Z53GWNM7.js} +1 -1
  198. package/chunks/{sandboxConfig-ZA5EE5YP.js → sandboxConfig-Q5GADSBO.js} +66 -66
  199. package/chunks/{scheduled-tasks-MU2VVZZA.js → scheduled-tasks-6FXAE77O.js} +75 -75
  200. package/chunks/{scheduler-3GBVAF3D.js → scheduler-W5XJHCSY.js} +68 -68
  201. package/chunks/{sdk-exporters-grpc-J2ILXEUS.js → sdk-exporters-grpc-FZO3Y43M.js} +2 -2
  202. package/chunks/{sdk-exporters-http-HGBOA62S.js → sdk-exporters-http-WYXH2KE4.js} +14 -14
  203. package/chunks/{sdk-impl-G2NWB5MF.js → sdk-impl-5PWLMFPQ.js} +20 -20
  204. package/chunks/{send-message-QOWWQKZJ.js → send-message-OSS7K7GE.js} +4 -4
  205. package/chunks/{serve-2AICGZTS.js → serve-PRXYYEOA.js} +74 -74
  206. package/chunks/{server-2TVKATWR.js → server-UBJ5BVPH.js} +260 -260
  207. package/chunks/{session-NQKO6WQB.js → session-62TX2TX2.js} +122 -122
  208. package/chunks/session-WTJAKLQE.js +34 -0
  209. package/chunks/{session-attachments-root-SSB5ARJJ.js → session-attachments-root-FW2TX3FF.js} +66 -66
  210. package/chunks/{session-pr-refresh-YMET6WC7.js → session-pr-refresh-R2Y6QHL7.js} +75 -75
  211. package/chunks/{settings-L3QP6XRJ.js → settings-HJODN63R.js} +74 -74
  212. package/chunks/{shell-BUXOKE4X.js → shell-P3L2UMOI.js} +42 -42
  213. package/chunks/{skill-Y4TKTJS7.js → skill-3PV7IPAH.js} +14 -13
  214. package/chunks/{skill-settings-MRFNTHGU.js → skill-settings-TSXFLSXL.js} +74 -74
  215. package/chunks/{spawnChannel-6YZABREF.js → spawnChannel-VV2PWHJ2.js} +69 -69
  216. package/chunks/{standalone-update-NPL3226O.js → standalone-update-4BRRDDO4.js} +69 -69
  217. package/chunks/{startInteractiveUI-SK5FABV5.js → startInteractiveUI-KUDCHKGV.js} +3611 -2801
  218. package/chunks/{task-create-2BHPJUF3.js → task-create-WLFSUWNH.js} +5 -5
  219. package/chunks/{task-update-NGKKBFU5.js → task-update-STSLD6C5.js} +5 -5
  220. package/chunks/{team-create-2M2ZEJK3.js → team-create-DXTHTZKI.js} +42 -42
  221. package/chunks/{team-plan-approval-AHSBAARB.js → team-plan-approval-22HFWRXC.js} +42 -42
  222. package/chunks/{terminal-image-renderer-6DD2LV7J.js → terminal-image-renderer-YBRDENRT.js} +66 -66
  223. package/chunks/{theme-manager-IDMOY52V.js → theme-manager-3GMAH5RD.js} +66 -66
  224. package/chunks/{tool-call-GVZHLCX6.js → tool-call-2R6GT3ZZ.js} +5 -5
  225. package/chunks/{tool-result-media-5BM7EQS2.js → tool-result-media-TPGTYKAD.js} +21 -23
  226. package/chunks/{tool-search-MCB74V2Z.js → tool-search-JYV3OQ6L.js} +19 -18
  227. package/chunks/{total-session-admission-65EGYQPO.js → total-session-admission-A27OSZFH.js} +71 -71
  228. package/chunks/{transcribe-audio-J3OVKT5D.js → transcribe-audio-R6YC24KU.js} +3 -3
  229. package/chunks/{trustedFolders-B2SE4YQI.js → trustedFolders-OVHIYR7G.js} +68 -68
  230. package/chunks/{understand-video-segments-OMAJP6Q7.js → understand-video-segments-2WK4T6PO.js} +8 -8
  231. package/chunks/{update-relaunch-BI3KOPOU.js → update-relaunch-NJNXJ7YF.js} +5 -5
  232. package/chunks/{updateCheck-KVUQB3UY.js → updateCheck-XCRLLMAH.js} +69 -69
  233. package/chunks/{upload-config-EALPYJRO.js → upload-config-QSD3T2AU.js} +10 -8
  234. package/chunks/{useAutoAcceptIndicator-Z2DHJUGG.js → useAutoAcceptIndicator-PJMRWE6O.js} +77 -77
  235. package/chunks/{validateNonInterActiveAuth-6TSH6F5D.js → validateNonInterActiveAuth-SD677WKS.js} +110 -110
  236. package/chunks/{version-T3ODOQJ3.js → version-FD6BAJ7Z.js} +1 -1
  237. package/chunks/{web-fetch-B4MFZK5W.js → web-fetch-4RUI7Y7U.js} +14 -16
  238. package/chunks/{web-search-R3JBN6A5.js → web-search-ROO2Y3AU.js} +12 -13
  239. package/chunks/web-shell-static-OOIIII74.js +1 -1
  240. package/chunks/{workflow-WUNSCM5D.js → workflow-OTLXZKSM.js} +45 -45
  241. package/chunks/{workspace-providers-status-LSYGM3QX.js → workspace-providers-status-E7XZW55K.js} +80 -80
  242. package/chunks/{workspace-registration-store-XF5KJWQP.js → workspace-registration-store-NTRX2N6W.js} +1 -1
  243. package/chunks/{workspace-registry-JPCXXXJR.js → workspace-registry-OKP2RI5C.js} +71 -71
  244. package/chunks/{workspace-runtime-coordinator-VEVP44OL.js → workspace-runtime-coordinator-774UWQBB.js} +72 -72
  245. package/chunks/{workspace-service-VCWHIBVD.js → workspace-service-C3BQFCAC.js} +80 -80
  246. package/chunks/{workspace-skills-status-TVSCRWXV.js → workspace-skills-status-GJFMBOCP.js} +77 -77
  247. package/chunks/{workspace-trust-reconciler-FP7NYY7Z.js → workspace-trust-reconciler-3V6TVY5S.js} +80 -80
  248. package/chunks/{write-file-6FNRAYPO.js → write-file-CE74OWAB.js} +45 -45
  249. package/chunks/{zh-KRQU675V.js → zh-GBDJHFG4.js} +1 -0
  250. package/chunks/{zh-TW-K657U7LC.js → zh-TW-WWN26WO4.js} +1 -0
  251. package/chunks/{zoom-image-UOWJTYWI.js → zoom-image-EK6GNK4H.js} +12 -11
  252. package/cli.js +14 -14
  253. package/execution-worker.js +1 -1
  254. package/export-transcript-document.js +1 -1
  255. package/locales/en.js +94 -2
  256. package/locales/pt.js +96 -2
  257. package/locales/zh-TW.js +2 -0
  258. package/locales/zh.js +2 -0
  259. package/package.json +2 -2
  260. package/release-notes.json +25 -0
  261. package/web-shell/assets/{abnfDiagram-VCTEODGH-hPR_hq_-.js → abnfDiagram-VCTEODGH-B1-jzC8p.js} +1 -1
  262. package/web-shell/assets/{arc-DBIKDXMV.js → arc-CSOZi0KQ.js} +1 -1
  263. package/web-shell/assets/{architectureDiagram-5GKGNRK7-DF6ToCyK.js → architectureDiagram-5GKGNRK7-CPkIznhq.js} +1 -1
  264. package/web-shell/assets/{blockDiagram-NRAW4CY4-D-3ZOodq.js → blockDiagram-NRAW4CY4-B4CmWPlm.js} +1 -1
  265. package/web-shell/assets/{c4Diagram-UCG6FXSJ-Dlgo5UYL.js → c4Diagram-UCG6FXSJ-CfbSKaAp.js} +1 -1
  266. package/web-shell/assets/channel-DtvUnSzo.js +1 -0
  267. package/web-shell/assets/{chunk-2Q5K7J3B-BupVKi2M.js → chunk-2Q5K7J3B-DeXG-4SQ.js} +1 -1
  268. package/web-shell/assets/{chunk-5VM5RSS4-I7UXEM7J.js → chunk-5VM5RSS4-C8diV_rJ.js} +1 -1
  269. package/web-shell/assets/{chunk-F27PBJKO-HQNLQQK-.js → chunk-F27PBJKO-Dfz0hM4f.js} +1 -1
  270. package/web-shell/assets/{chunk-G27WJ6UU-1o4xDSX9.js → chunk-G27WJ6UU-BE_M2PYM.js} +1 -1
  271. package/web-shell/assets/{chunk-JWPE2WC7-AkJIcBLE.js → chunk-JWPE2WC7-CLsWUvS5.js} +1 -1
  272. package/web-shell/assets/{chunk-LCL6LL3I-nfbDS7iE.js → chunk-LCL6LL3I-DeyqYZUf.js} +1 -1
  273. package/web-shell/assets/{chunk-POPQ4Y6H-DtEE_OdH.js → chunk-POPQ4Y6H-C-6z-5n3.js} +1 -1
  274. package/web-shell/assets/{chunk-SVP7TREG-Cj9Lw3Gx.js → chunk-SVP7TREG-DdwfG0ad.js} +1 -1
  275. package/web-shell/assets/{chunk-XXDRQBXY-CUDuWpdQ.js → chunk-XXDRQBXY-X9aD75Ws.js} +1 -1
  276. package/web-shell/assets/classDiagram-DTDB5LWJ-B4Ulnn_s.js +1 -0
  277. package/web-shell/assets/classDiagram-v2-JRS7N3AN-B4Ulnn_s.js +1 -0
  278. package/web-shell/assets/{cose-bilkent-JH36ORCC-DQx9CBLc.js → cose-bilkent-JH36ORCC-DNp5iXJM.js} +1 -1
  279. package/web-shell/assets/{cynefin-OW5HDTMX-B3kEpThT.js → cynefin-OW5HDTMX-DhhzkPLD.js} +1 -1
  280. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-Sv-FRvME.js → cynefinDiagram-5FMLGOSQ-5eATS_mD.js} +1 -1
  281. package/web-shell/assets/{dagre-3AP2YEHR-CH_Z8-Kk.js → dagre-3AP2YEHR-DXUm0J5e.js} +1 -1
  282. package/web-shell/assets/{diagram-S7CK7UJ4-C0oToNP-.js → diagram-S7CK7UJ4-DNrRshkn.js} +1 -1
  283. package/web-shell/assets/{diagram-UQ7AKVKN-BrSK_nkR.js → diagram-UQ7AKVKN-DS2yugJl.js} +1 -1
  284. package/web-shell/assets/{diagram-VSXAHHWV-Dqa3JxKx.js → diagram-VSXAHHWV-Ds2io9aQ.js} +1 -1
  285. package/web-shell/assets/{diagram-VX7I27RA-CMxI_svo.js → diagram-VX7I27RA-CGa-K6oj.js} +1 -1
  286. package/web-shell/assets/{diagram-Z3DM3KII-ms16iRjT.js → diagram-Z3DM3KII-BW68o26L.js} +1 -1
  287. package/web-shell/assets/{ebnfDiagram-PWID7BFC-DlnqAdIV.js → ebnfDiagram-PWID7BFC-BC4P1K1r.js} +1 -1
  288. package/web-shell/assets/{erDiagram-SSCWMZ5O-DLsbP_rs.js → erDiagram-SSCWMZ5O-CLs5DpAu.js} +1 -1
  289. package/web-shell/assets/{flowDiagram-A5DVABFB-CUi1Sjog.js → flowDiagram-A5DVABFB-D76URsL1.js} +1 -1
  290. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-CE_JUTUJ.js → ganttDiagram-EL5Y4UJY-xVE4LPqO.js} +1 -1
  291. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-B5AAvDsM.js → gitGraphDiagram-WWUBYQGX-CIRl0tk3.js} +1 -1
  292. package/web-shell/assets/{index-BHiSoADm.js → index-Bv4OUm3o.js} +1 -1
  293. package/web-shell/assets/{index-70D1m6Hg.js → index-KZq_3onf.js} +3 -3
  294. package/web-shell/assets/{infoDiagram-RXCK75RN-pBmlQkcV.js → infoDiagram-RXCK75RN-CBnubrlE.js} +1 -1
  295. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-BauoqPoz.js → ishikawaDiagram-5VMMS53U-qK-V6061.js} +1 -1
  296. package/web-shell/assets/{journeyDiagram-EYS64GPL-2bt-6t-1.js → journeyDiagram-EYS64GPL-UUJYez4X.js} +1 -1
  297. package/web-shell/assets/{kanban-definition-3QL26DDD-BxxoBXaj.js → kanban-definition-3QL26DDD-BCcGvRtp.js} +1 -1
  298. package/web-shell/assets/{layout-CHPDwyF0.js → layout-CSFWOY9q.js} +1 -1
  299. package/web-shell/assets/{linear-DNvAHeqC.js → linear-WUzB_hII.js} +1 -1
  300. package/web-shell/assets/{mermaid.core-fypPA9cT.js → mermaid.core-eLc_GDkM.js} +6 -6
  301. package/web-shell/assets/{mindmap-definition-FBJOCRG2-6QjAwCGs.js → mindmap-definition-FBJOCRG2-BfzdSe6H.js} +1 -1
  302. package/web-shell/assets/{pegDiagram-XKGWAZYB-CVntv99C.js → pegDiagram-XKGWAZYB-B1kr5DxT.js} +1 -1
  303. package/web-shell/assets/{pieDiagram-E7YTZNPT-BfhvtHAE.js → pieDiagram-E7YTZNPT-CPFq2ZOW.js} +1 -1
  304. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-MiVxa2Zt.js → quadrantDiagram-AXDQQJYC-DuZmXZaP.js} +1 -1
  305. package/web-shell/assets/{railroadDiagram-O6MQD6OU-BwHFJs0H.js → railroadDiagram-O6MQD6OU-DCjBx5S1.js} +1 -1
  306. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-CEJ6r2cM.js → requirementDiagram-EFPCY7ZU-DISKvzR7.js} +1 -1
  307. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-D7uTdG-j.js → sankeyDiagram-P5KCCOFB-BugqzyC1.js} +1 -1
  308. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-CyW16H7w.js → sequenceDiagram-WJ2MYXX4-DLQyc2mn.js} +1 -1
  309. package/web-shell/assets/{sizeCapture-X5ZJPWSS-zoBxvlxI.js → sizeCapture-X5ZJPWSS-CDbelLiH.js} +1 -1
  310. package/web-shell/assets/{stateDiagram-HBIQ2CUA-BceIC-cJ.js → stateDiagram-HBIQ2CUA-Bw4uH6Y6.js} +1 -1
  311. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-UrUNUyaU.js +1 -0
  312. package/web-shell/assets/{swimlanes-XN3QIQJK-QgaLP8Xo.js → swimlanes-XN3QIQJK-BT-heLFQ.js} +1 -1
  313. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-E8v9mXaE.js +8 -0
  314. package/web-shell/assets/{timeline-definition-24CTP7MA-pz8DGpLO.js → timeline-definition-24CTP7MA-ORqZ_woY.js} +1 -1
  315. package/web-shell/assets/{vennDiagram-4TSXK5OY-BoMnG3o9.js → vennDiagram-4TSXK5OY-AgffOwo5.js} +1 -1
  316. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-Bkr9hvxi.js → wardleyDiagram-VM6X3IG4-CcqvB4mV.js} +1 -1
  317. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-Ca7YvQrU.js → xychartDiagram-S5SC5T6Z-BQBX00-a.js} +1 -1
  318. package/web-shell/index.html +1 -1
  319. package/web-shell/sw.js +1 -1
  320. package/chunks/chunk-7USF7X6U.js +0 -584
  321. package/chunks/chunk-ALIO4STD.js +0 -340
  322. package/chunks/chunk-MWFHMYVA.js +0 -93
  323. package/chunks/chunk-QFPNGX7U.js +0 -27
  324. package/chunks/chunk-RCBGIDZU.js +0 -48
  325. package/chunks/chunk-VIAJ74X3.js +0 -410
  326. package/web-shell/assets/channel-aWi28RPH.js +0 -1
  327. package/web-shell/assets/classDiagram-DTDB5LWJ-fHMqSd3A.js +0 -1
  328. package/web-shell/assets/classDiagram-v2-JRS7N3AN-fHMqSd3A.js +0 -1
  329. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BsJAvg6i.js +0 -1
  330. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-DdMnIIJX.js +0 -8
  331. package/chunks/{chunk-BWRP5ZMP.js → chunk-DQZYZDIL.js} +3 -3
  332. package/chunks/{chunk-KV5QCRFB.js → chunk-IC57EPC7.js} +3 -3
  333. package/chunks/{chunk-YJLJUKJ7.js → chunk-IZSIFV6S.js} +3 -3
  334. package/chunks/{chunk-H5L5E5NI.js → chunk-ROO6F2BT.js} +3 -3
  335. package/chunks/{chunk-MDU4BZLN.js → chunk-YSZCVSC3.js} +0 -0
  336. package/chunks/{clip-audio-G2SG55MB.js → clip-audio-BJ42NS5B.js} +4 -4
  337. package/chunks/{clip-image-I3IFRW4Z.js → clip-image-FDBAIKGB.js} +3 -3
  338. package/chunks/{clip-video-XISLKGWO.js → clip-video-6KVC2IFL.js} +4 -4
  339. package/chunks/{convert-image-TXAOAPLS.js → convert-image-AYXBZ3TH.js} +3 -3
  340. package/chunks/{downsample-audio-SBMOSASE.js → downsample-audio-HSPMS25U.js} +4 -4
  341. package/chunks/{downsample-image-S5ZKCZEM.js → downsample-image-BFBX343I.js} +3 -3
  342. package/chunks/{downscale-video-LFLD2MYN.js → downscale-video-GQ5ZMJRX.js} +4 -4
  343. package/chunks/{extract-audio-TY277NLN.js → extract-audio-3LB2Q736.js} +4 -4
  344. package/chunks/{extract-keyframes-CXPABWEU.js → extract-keyframes-6ZP65BJF.js} +4 -4
@@ -0,0 +1,1365 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ redactProxyCredentials
5
+ } from "./chunk-HDGYCLNB.js";
6
+ import {
7
+ createDebugLogger
8
+ } from "./chunk-UK2KIU2V.js";
9
+ import {
10
+ getErrorMessage,
11
+ getErrorStatus,
12
+ isAbortError
13
+ } from "./chunk-JAQAGKIV.js";
14
+ import {
15
+ init_esbuild_shims
16
+ } from "./chunk-S2467S6L.js";
17
+ import {
18
+ __name
19
+ } from "./chunk-J2S4EL5Y.js";
20
+
21
+ // packages/core/src/utils/fetch.ts
22
+ init_esbuild_shims();
23
+
24
+ // packages/core/src/utils/retry.ts
25
+ init_esbuild_shims();
26
+
27
+ // packages/core/src/utils/quotaErrorDetection.ts
28
+ init_esbuild_shims();
29
+ function isApiError(error) {
30
+ return typeof error === "object" && error !== null && "error" in error && typeof error.error === "object" && error.error !== null && "message" in error.error;
31
+ }
32
+ __name(isApiError, "isApiError");
33
+ function isStructuredError(error) {
34
+ return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
35
+ }
36
+ __name(isStructuredError, "isStructuredError");
37
+ var QUOTA_EXHAUSTED_PREFIX = "Quota exhausted: ";
38
+ function getQuotaMessage(error) {
39
+ let message = null;
40
+ if (typeof error === "string") message = error;
41
+ else if (isStructuredError(error)) message = error.message;
42
+ else if (isApiError(error)) message = error.error.message;
43
+ if (message === null) return null;
44
+ const start = message.indexOf("{");
45
+ if (start !== -1) {
46
+ try {
47
+ const parsed = JSON.parse(message.substring(start));
48
+ if (isApiError(parsed)) return parsed.error.message;
49
+ } catch {
50
+ }
51
+ }
52
+ return message;
53
+ }
54
+ __name(getQuotaMessage, "getQuotaMessage");
55
+ function isQuotaExhaustedError(error) {
56
+ const message = getQuotaMessage(error);
57
+ if (!message) return false;
58
+ const lower = message.toLowerCase();
59
+ return lower.includes("quota") && (lower.includes("exhausted") || lower.includes("exceeded")) && (lower.includes("will reset") || lower.includes("reset at"));
60
+ }
61
+ __name(isQuotaExhaustedError, "isQuotaExhaustedError");
62
+ function formatQuotaExhaustedMessage(error) {
63
+ const raw = getQuotaMessage(error) ?? "";
64
+ if (raw.startsWith(QUOTA_EXHAUSTED_PREFIX)) return raw;
65
+ const stripped = raw.replace(/^\d{3}\s+/, "").trim() || "quota has been exhausted";
66
+ return `${QUOTA_EXHAUSTED_PREFIX}${stripped}
67
+
68
+ Please retry after the reset time, or switch to another API key / auth method.`;
69
+ }
70
+ __name(formatQuotaExhaustedMessage, "formatQuotaExhaustedMessage");
71
+
72
+ // packages/core/src/utils/proxy-waits.ts
73
+ init_esbuild_shims();
74
+
75
+ // packages/core/src/utils/rateLimit.ts
76
+ init_esbuild_shims();
77
+
78
+ // packages/core/src/utils/retryPolicy.ts
79
+ init_esbuild_shims();
80
+ var MAX_TIMEOUT_MS = 2147483647;
81
+ function getRetryDelayMs(options) {
82
+ const normalizedAttempt = Math.max(1, options.attempt);
83
+ const delayCeilingMs = Math.min(options.maxDelayMs, MAX_TIMEOUT_MS);
84
+ const exponent = Math.min(normalizedAttempt - 1, 31);
85
+ const cappedExponentialDelayMs = Math.min(
86
+ options.initialDelayMs * Math.pow(2, exponent),
87
+ delayCeilingMs
88
+ );
89
+ const retryAfterMode = options.retryAfterMode ?? "ignore";
90
+ const retryAfterMs = retryAfterMode === "ignore" ? null : getRetryAfterDelayMs(options.error);
91
+ if (retryAfterMs !== null && retryAfterMs > 0) {
92
+ const retryAfterCapMs = Math.min(
93
+ options.retryAfterMaxDelayMs ?? options.maxDelayMs,
94
+ MAX_TIMEOUT_MS
95
+ );
96
+ const cappedRetryAfterMs = Math.min(retryAfterMs, retryAfterCapMs);
97
+ return Math.max(cappedExponentialDelayMs, cappedRetryAfterMs);
98
+ }
99
+ const jitterRatio = options.jitterRatio ?? 0;
100
+ if (jitterRatio <= 0) return cappedExponentialDelayMs;
101
+ const random = options.random ?? Math.random;
102
+ const jitter = cappedExponentialDelayMs * jitterRatio * (random() * 2 - 1);
103
+ return Math.min(
104
+ Math.max(0, cappedExponentialDelayMs + jitter),
105
+ delayCeilingMs
106
+ );
107
+ }
108
+ __name(getRetryDelayMs, "getRetryDelayMs");
109
+ function getRetryAfterDelayMs(error) {
110
+ const millis = getHeaderValue(error, "retry-after-ms") ?? getResponseHeaderValue(error, "retry-after-ms");
111
+ if (millis !== null && /^\d+(\.\d+)?$/.test(millis.trim())) {
112
+ const value2 = Number(millis);
113
+ if (Number.isFinite(value2)) return Math.min(value2, MAX_TIMEOUT_MS);
114
+ }
115
+ const value = getHeaderValue(error, "retry-after") ?? getResponseHeaderValue(error, "retry-after");
116
+ if (value === null) return null;
117
+ const trimmed = value.trim();
118
+ if (/^\d+(\.\d+)?$/.test(trimmed)) {
119
+ const seconds = Number(trimmed);
120
+ if (Number.isFinite(seconds) && seconds >= 0) {
121
+ return Math.min(seconds * 1e3, MAX_TIMEOUT_MS);
122
+ }
123
+ }
124
+ const retryAtMs = Date.parse(trimmed);
125
+ if (!Number.isFinite(retryAtMs)) return null;
126
+ const delayMs = retryAtMs - Date.now();
127
+ return delayMs > 0 ? Math.min(delayMs, MAX_TIMEOUT_MS) : 0;
128
+ }
129
+ __name(getRetryAfterDelayMs, "getRetryAfterDelayMs");
130
+ function getErrorHeader(error, headerName) {
131
+ return getHeaderValue(error, headerName) ?? getResponseHeaderValue(error, headerName);
132
+ }
133
+ __name(getErrorHeader, "getErrorHeader");
134
+ function getHeaderValue(error, headerName) {
135
+ if (!hasHeaders(error)) return null;
136
+ const { headers } = error;
137
+ if (typeof headers.get === "function") {
138
+ const value = headers.get(headerName);
139
+ return typeof value === "string" ? value : null;
140
+ }
141
+ if (typeof headers !== "object" || headers === null) return null;
142
+ const lowerHeaderName = headerName.toLowerCase();
143
+ for (const [key, value] of Object.entries(headers)) {
144
+ if (key.toLowerCase() !== lowerHeaderName) continue;
145
+ return typeof value === "string" ? value : null;
146
+ }
147
+ return null;
148
+ }
149
+ __name(getHeaderValue, "getHeaderValue");
150
+ function getResponseHeaderValue(error, headerName) {
151
+ if (!hasResponseHeaders(error)) return null;
152
+ return getHeaderValue(error.response, headerName);
153
+ }
154
+ __name(getResponseHeaderValue, "getResponseHeaderValue");
155
+ function hasHeaders(error) {
156
+ return typeof error === "object" && error !== null && "headers" in error && error.headers != null;
157
+ }
158
+ __name(hasHeaders, "hasHeaders");
159
+ function hasResponseHeaders(error) {
160
+ return typeof error === "object" && error !== null && "response" in error && typeof error.response === "object" && error.response !== null && "headers" in error.response && error.response.headers != null;
161
+ }
162
+ __name(hasResponseHeaders, "hasResponseHeaders");
163
+
164
+ // packages/core/src/utils/rateLimit.ts
165
+ var RATE_LIMIT_ERROR_CODES = /* @__PURE__ */ new Set([429, 503, 1302, 1305]);
166
+ function isRateLimitError(error, extraCodes) {
167
+ const code = getErrorCode(error);
168
+ if (code === null) return isStatuslessThrottle(error);
169
+ if (RATE_LIMIT_ERROR_CODES.has(code)) return true;
170
+ if (extraCodes && extraCodes.includes(code)) return true;
171
+ return false;
172
+ }
173
+ __name(isRateLimitError, "isRateLimitError");
174
+ function isStatuslessThrottle(error) {
175
+ for (const payload of [error, ...getJsonPayloads(error)]) {
176
+ const selected = providerErrorSource(payload);
177
+ if (!selected) continue;
178
+ const { source } = selected;
179
+ const { type, message } = source;
180
+ if (type === "rate_limit_error" || type === "overloaded_error") return true;
181
+ if (type !== "invalid_request_error" || typeof message !== "string")
182
+ continue;
183
+ const detail = decodeProviderMessage(message)?.["message"] ?? message;
184
+ if (typeof detail === "string" && /^too many requests\b/i.test(detail.trim()) && /\b(?:wait|try(?:ing)? again)\b/i.test(detail)) {
185
+ return true;
186
+ }
187
+ }
188
+ return false;
189
+ }
190
+ __name(isStatuslessThrottle, "isStatuslessThrottle");
191
+ function providerErrorSource(payload) {
192
+ if (typeof payload !== "object" || payload === null) return null;
193
+ const direct = payload;
194
+ const nested = direct["error"];
195
+ const source = typeof nested === "object" && nested !== null ? nested : direct;
196
+ return { source, direct };
197
+ }
198
+ __name(providerErrorSource, "providerErrorSource");
199
+ function decodeProviderMessage(message) {
200
+ try {
201
+ const selected = providerErrorSource(JSON.parse(message));
202
+ if (!selected || typeof selected.source["message"] !== "string") {
203
+ return null;
204
+ }
205
+ return { ...selected.direct, ...selected.source };
206
+ } catch {
207
+ return null;
208
+ }
209
+ }
210
+ __name(decodeProviderMessage, "decodeProviderMessage");
211
+ function getRateLimitErrorDetails(error) {
212
+ const statusCode = getErrorStatus(error);
213
+ const payload = getProviderErrorPayload(error);
214
+ const message = getRawErrorMessage(error);
215
+ const transport = message?.includes("event:error") || message?.includes("HTTP_STATUS/") ? "sse" : statusCode !== void 0 ? "http" : "unknown";
216
+ return {
217
+ ...statusCode !== void 0 ? { statusCode } : {},
218
+ ...payload?.code !== void 0 || payload?.type !== void 0 ? { providerCode: String(payload.code ?? payload.type) } : {},
219
+ ...payload?.type !== void 0 ? { providerType: payload.type } : {},
220
+ ...payload?.message !== void 0 ? { providerMessage: payload.message } : {},
221
+ ...payload?.requestId !== void 0 ? { requestId: payload.requestId } : {},
222
+ transport
223
+ };
224
+ }
225
+ __name(getRateLimitErrorDetails, "getRateLimitErrorDetails");
226
+ function getRateLimitRetryDelayMs(attempt, options) {
227
+ return getRetryDelayMs({
228
+ attempt,
229
+ initialDelayMs: options.initialDelayMs,
230
+ maxDelayMs: options.maxDelayMs,
231
+ retryAfterMode: "minimum",
232
+ retryAfterMaxDelayMs: options.maxDelayMs,
233
+ error: options.error
234
+ });
235
+ }
236
+ __name(getRateLimitRetryDelayMs, "getRateLimitRetryDelayMs");
237
+ function getErrorCode(error) {
238
+ if (isApiError(error)) {
239
+ const n = Number(error.error.code);
240
+ if (Number.isFinite(n) && n > 0) return n;
241
+ }
242
+ const msg = error instanceof Error ? error.message : typeof error === "string" ? error : null;
243
+ if (msg) {
244
+ const i = msg.indexOf("{");
245
+ if (i !== -1) {
246
+ try {
247
+ const p = JSON.parse(msg.substring(i));
248
+ if (isApiError(p)) {
249
+ const n = Number(p.error.code);
250
+ if (Number.isFinite(n) && n > 0) return n;
251
+ }
252
+ } catch {
253
+ }
254
+ }
255
+ }
256
+ if (isStructuredError(error) && typeof error.status === "number") {
257
+ return error.status;
258
+ }
259
+ if (error instanceof Error && "status" in error) {
260
+ const s = error.status;
261
+ if (typeof s === "number") return s;
262
+ }
263
+ return getErrorStatus(error) ?? null;
264
+ }
265
+ __name(getErrorCode, "getErrorCode");
266
+ function getProviderErrorPayload(error) {
267
+ for (const payload of getJsonPayloads(error)) {
268
+ const selected = providerErrorSource(payload);
269
+ if (!selected) continue;
270
+ const { source, direct } = selected;
271
+ const decoded = typeof source["message"] === "string" ? decodeProviderMessage(source["message"]) : null;
272
+ const code = typeof source["code"] === "string" || typeof source["code"] === "number" ? source["code"] : typeof decoded?.["code"] === "string" || typeof decoded?.["code"] === "number" ? decoded["code"] : void 0;
273
+ const type = typeof source["type"] === "string" ? source["type"] : typeof decoded?.["type"] === "string" ? decoded["type"] : void 0;
274
+ const message = typeof decoded?.["message"] === "string" ? decoded["message"] : typeof source["message"] === "string" ? source["message"] : void 0;
275
+ const requestId = typeof source["request_id"] === "string" ? source["request_id"] : typeof source["requestId"] === "string" ? source["requestId"] : typeof direct["request_id"] === "string" ? direct["request_id"] : typeof direct["requestId"] === "string" ? direct["requestId"] : typeof decoded?.["request_id"] === "string" ? decoded["request_id"] : typeof decoded?.["requestId"] === "string" ? decoded["requestId"] : void 0;
276
+ if (code !== void 0 || type !== void 0 || message !== void 0 || requestId !== void 0) {
277
+ return { code, type, message, requestId };
278
+ }
279
+ }
280
+ if (isApiError(error)) {
281
+ const decoded = decodeProviderMessage(error.error.message);
282
+ return {
283
+ code: error.error.code,
284
+ ...typeof decoded?.["type"] === "string" ? { type: decoded["type"] } : {},
285
+ message: typeof decoded?.["message"] === "string" ? decoded["message"] : error.error.message
286
+ };
287
+ }
288
+ return null;
289
+ }
290
+ __name(getProviderErrorPayload, "getProviderErrorPayload");
291
+ function getJsonPayloads(error) {
292
+ const message = getRawErrorMessage(error);
293
+ if (!message) return [];
294
+ const payloads = [];
295
+ for (const line of message.split(/\r?\n/)) {
296
+ if (!line.startsWith("data:")) continue;
297
+ const data = line.slice("data:".length).trim();
298
+ if (!data || data === "[DONE]") continue;
299
+ try {
300
+ payloads.push(JSON.parse(data));
301
+ } catch {
302
+ }
303
+ }
304
+ if (payloads.length > 0) return payloads;
305
+ const jsonStart = message.indexOf("{");
306
+ const jsonEnd = message.lastIndexOf("}");
307
+ if (jsonStart !== -1 && jsonEnd > jsonStart) {
308
+ try {
309
+ payloads.push(
310
+ JSON.parse(message.slice(jsonStart, jsonEnd + 1))
311
+ );
312
+ } catch {
313
+ }
314
+ }
315
+ return payloads;
316
+ }
317
+ __name(getJsonPayloads, "getJsonPayloads");
318
+ function getRawErrorMessage(error) {
319
+ if (error instanceof Error) return error.message;
320
+ if (typeof error === "string") return error;
321
+ return null;
322
+ }
323
+ __name(getRawErrorMessage, "getRawErrorMessage");
324
+
325
+ // packages/core/src/utils/proxy-waits.ts
326
+ var PROXY_LONG_WAIT_MS = 5 * 6e4;
327
+ var PROXY_WAIT_CODES = /* @__PURE__ */ new Set([
328
+ "account_limit_exceeded",
329
+ // The cap the person set on their own credentials (contract §3.5).
330
+ "own_limit",
331
+ "upstream_rate_limited",
332
+ "provider_unavailable",
333
+ "limits_unavailable"
334
+ ]);
335
+ function readProxyWait(error, now = Date.now()) {
336
+ const status = getErrorStatus(error);
337
+ if (status !== 429 && status !== 503) return null;
338
+ const details = getRateLimitErrorDetails(error);
339
+ const limit = getErrorHeader(error, "x-o1gw-limit") ?? void 0;
340
+ const ours = limit !== void 0 || details.providerCode !== void 0 && PROXY_WAIT_CODES.has(details.providerCode) || /usage limit is reached/i.test(details.providerMessage ?? "");
341
+ if (!ours) return null;
342
+ const resetHeader = getErrorHeader(error, "x-o1gw-limit-reset");
343
+ const resetFromHeader = resetHeader ? Date.parse(resetHeader) : NaN;
344
+ const retryAfterMs = getRetryAfterDelayMs(error);
345
+ const waitMs = retryAfterMs ?? (Number.isFinite(resetFromHeader) ? Math.max(0, resetFromHeader - now) : 0);
346
+ const resetAt = new Date(
347
+ Number.isFinite(resetFromHeader) ? resetFromHeader : now + waitMs
348
+ );
349
+ return {
350
+ ...limit ? { limit } : {},
351
+ resetAt,
352
+ waitMs,
353
+ ...details.providerMessage ? { message: details.providerMessage } : {}
354
+ };
355
+ }
356
+ __name(readProxyWait, "readProxyWait");
357
+ function isLongProxyWait(error, now) {
358
+ const wait = readProxyWait(error, now);
359
+ return wait !== null && wait.waitMs > PROXY_LONG_WAIT_MS;
360
+ }
361
+ __name(isLongProxyWait, "isLongProxyWait");
362
+ function formatDuration(ms) {
363
+ const minutes = Math.max(1, Math.round(ms / 6e4));
364
+ const hours = Math.floor(minutes / 60);
365
+ const rest = minutes % 60;
366
+ if (hours === 0) return `${minutes} min`;
367
+ return rest === 0 ? `${hours} h` : `${hours} h ${rest} min`;
368
+ }
369
+ __name(formatDuration, "formatDuration");
370
+ function formatProxyWaitMessage(error, now = Date.now()) {
371
+ const wait = readProxyWait(error, now);
372
+ const reason = wait?.message?.replace(/^\d{3}\s+/, "").trim() || (wait?.limit ? `The account limit ${wait.limit} is reached.` : "The provider asks to wait.");
373
+ const when = wait ? `Try again at ${wait.resetAt.toLocaleTimeString([], {
374
+ hour: "2-digit",
375
+ minute: "2-digit"
376
+ })} (in ${formatDuration(wait.waitMs)}).` : "";
377
+ return `${QUOTA_EXHAUSTED_PREFIX}${reason}
378
+
379
+ ${when} The request was not retried; send it again then, or switch to another model or provider.`.trim();
380
+ }
381
+ __name(formatProxyWaitMessage, "formatProxyWaitMessage");
382
+
383
+ // packages/core/src/utils/retryErrorClassification.ts
384
+ init_esbuild_shims();
385
+
386
+ // packages/core/src/utils/responses-http-error.ts
387
+ init_esbuild_shims();
388
+ var ResponsesHttpError = class extends Error {
389
+ constructor(status, body, responseHeaders, secrets = []) {
390
+ const sanitize = /* @__PURE__ */ __name((value) => {
391
+ let text = redactProxyCredentials(value);
392
+ for (const secret of secrets) {
393
+ if (secret) text = text.split(secret).join("<redacted>");
394
+ }
395
+ return text;
396
+ }, "sanitize");
397
+ const headers = new Headers();
398
+ for (const name of [
399
+ "x-request-id",
400
+ "retry-after",
401
+ "retry-after-ms",
402
+ "x-should-retry"
403
+ ]) {
404
+ const value = responseHeaders?.get(name);
405
+ if (value) headers.set(name, sanitize(value));
406
+ }
407
+ let envelope;
408
+ try {
409
+ envelope = record(JSON.parse(body));
410
+ } catch {
411
+ }
412
+ const upstream = record(envelope?.["error"]);
413
+ const error = {};
414
+ for (const name of ["message", "code", "type", "param"]) {
415
+ const value = upstream?.[name];
416
+ if (typeof value === "string" || typeof value === "number") {
417
+ error[name] = sanitize(String(value));
418
+ }
419
+ }
420
+ const requestId = headers.get("x-request-id") ?? void 0;
421
+ const diagnostic = {
422
+ ...Object.keys(error).length ? { error } : {},
423
+ ...requestId ? { request_id: requestId } : {}
424
+ };
425
+ const excerpt = Object.keys(error).length ? JSON.stringify(diagnostic) : sanitize(body).substring(0, 500);
426
+ super(
427
+ `Responses API error ${status}: ${excerpt}` + (!Object.keys(error).length && requestId ? ` (request_id: ${requestId})` : "")
428
+ );
429
+ this.status = status;
430
+ this.name = "ResponsesHttpError";
431
+ this.headers = headers;
432
+ this.requestId = requestId;
433
+ this.error = Object.keys(error).length ? error : void 0;
434
+ this.code = error["code"];
435
+ this.type = error["type"];
436
+ this.param = error["param"];
437
+ }
438
+ static {
439
+ __name(this, "ResponsesHttpError");
440
+ }
441
+ headers;
442
+ requestId;
443
+ code;
444
+ type;
445
+ param;
446
+ error;
447
+ shouldRetry(extraRetryErrorCodes) {
448
+ const directive = this.headers.get("x-should-retry");
449
+ if (directive === "true") return true;
450
+ if (directive === "false") return false;
451
+ return this.status === 408 || this.status === 409 || this.status === 429 || this.status >= 500 && this.status < 600 || (extraRetryErrorCodes?.includes(this.status) ?? false);
452
+ }
453
+ };
454
+ function record(value) {
455
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
456
+ }
457
+ __name(record, "record");
458
+
459
+ // packages/core/src/utils/retryErrorClassification.ts
460
+ function classifyRetryError(error, context = {}) {
461
+ if (isRetryAbortError(error)) {
462
+ return {
463
+ kind: "abort",
464
+ diagnosis: "fail-fast",
465
+ reason: "aborted"
466
+ };
467
+ }
468
+ const details = getRateLimitErrorDetails(error);
469
+ const statusCode = details.statusCode;
470
+ const providerFields = getProviderFields(error);
471
+ const providerCode = details.providerCode ?? providerFields.providerCode;
472
+ const providerMessage = details.providerMessage ?? providerFields.providerMessage;
473
+ const requestId = details.requestId || providerFields.requestId;
474
+ const common = {
475
+ ...statusCode !== void 0 ? { statusCode } : {},
476
+ ...providerCode !== void 0 ? { providerCode } : {},
477
+ ...providerMessage !== void 0 ? { providerMessage } : {},
478
+ ...requestId !== void 0 ? { requestId } : {}
479
+ };
480
+ if (isAllocatedQuotaExceeded(providerCode)) {
481
+ return {
482
+ kind: "provider-business",
483
+ diagnosis: "fail-fast",
484
+ reason: "allocated-quota-exceeded",
485
+ ...common
486
+ };
487
+ }
488
+ if (error instanceof ResponsesHttpError && (error.headers.has("x-should-retry") || statusCode === 408 || statusCode === 409)) {
489
+ return {
490
+ kind: "http",
491
+ diagnosis: error.shouldRetry(context.extraRetryErrorCodes) ? "retryable" : "fail-fast",
492
+ reason: "responses-http-retry-policy",
493
+ ...common
494
+ };
495
+ }
496
+ if (isRateLimitError(error, context.extraRetryErrorCodes)) {
497
+ const kind = details.transport === "sse" ? "sse-provider" : statusCode !== void 0 ? "http" : "provider";
498
+ return {
499
+ kind,
500
+ diagnosis: "retryable",
501
+ reason: "rate-limit",
502
+ ...common
503
+ };
504
+ }
505
+ const transportCode = getTransportCode(error);
506
+ if (transportCode !== void 0 && (statusCode === void 0 || statusCode >= 500)) {
507
+ return {
508
+ kind: "transport",
509
+ diagnosis: "retryable",
510
+ reason: "transport-error",
511
+ transportCode,
512
+ ...statusCode !== void 0 ? { statusCode } : {}
513
+ };
514
+ }
515
+ if (statusCode !== void 0) {
516
+ const kind = details.transport === "sse" ? "sse-provider" : "http";
517
+ if (statusCode === 529) {
518
+ return {
519
+ kind,
520
+ diagnosis: "retryable",
521
+ reason: "capacity-overload",
522
+ ...common
523
+ };
524
+ }
525
+ if (statusCode === 401 || statusCode === 403) {
526
+ return {
527
+ kind,
528
+ diagnosis: "fail-fast",
529
+ reason: "auth-error",
530
+ ...common
531
+ };
532
+ }
533
+ if (statusCode >= 400 && statusCode < 500) {
534
+ if (providerCode === void 0 && providerMessage === void 0 && hasNetworkFailureCause(error)) {
535
+ return {
536
+ kind: "transport",
537
+ diagnosis: "retryable",
538
+ reason: "network-error",
539
+ ...common
540
+ };
541
+ }
542
+ return {
543
+ kind,
544
+ diagnosis: "fail-fast",
545
+ reason: "client-error",
546
+ ...common
547
+ };
548
+ }
549
+ if (statusCode === 502 && providerCode === "upstream_redirected") {
550
+ return {
551
+ kind,
552
+ diagnosis: "fail-fast",
553
+ reason: "permanent-provider-code",
554
+ ...common
555
+ };
556
+ }
557
+ if (statusCode >= 500 && statusCode < 600) {
558
+ return {
559
+ kind,
560
+ diagnosis: "retryable",
561
+ reason: "server-error",
562
+ ...common
563
+ };
564
+ }
565
+ return {
566
+ kind,
567
+ diagnosis: "unknown",
568
+ reason: "http-status",
569
+ ...common
570
+ };
571
+ }
572
+ const statuslessKind = details.transport === "sse" ? "sse-provider" : "provider";
573
+ if (isPermanentProviderCode(providerCode) || isPermanentProviderCode(providerFields.providerType) || isPermanentProviderCode(details.providerType)) {
574
+ return {
575
+ kind: statuslessKind,
576
+ diagnosis: "fail-fast",
577
+ reason: "permanent-provider-code",
578
+ ...common
579
+ };
580
+ }
581
+ if (requestId !== void 0) {
582
+ return {
583
+ kind: statuslessKind,
584
+ diagnosis: "retryable",
585
+ reason: "upstream-error-without-status",
586
+ ...common
587
+ };
588
+ }
589
+ return {
590
+ kind: "unknown",
591
+ diagnosis: "unknown",
592
+ reason: "unclassified",
593
+ ...common
594
+ };
595
+ }
596
+ __name(classifyRetryError, "classifyRetryError");
597
+ function isRetryAbortError(error) {
598
+ if (isAbortError(error)) {
599
+ return true;
600
+ }
601
+ return error instanceof Error && error.name === "CanceledError";
602
+ }
603
+ __name(isRetryAbortError, "isRetryAbortError");
604
+ var MAX_TRANSPORT_CAUSE_DEPTH = 4;
605
+ function getTransportCode(error) {
606
+ let current = error;
607
+ for (let depth = 0; depth <= MAX_TRANSPORT_CAUSE_DEPTH; depth++) {
608
+ if (typeof current !== "object" || current === null) {
609
+ return void 0;
610
+ }
611
+ const code = current.code;
612
+ if (typeof code === "string" && isTransportCode(code)) {
613
+ return code;
614
+ }
615
+ current = current instanceof Error ? current.cause : void 0;
616
+ }
617
+ return void 0;
618
+ }
619
+ __name(getTransportCode, "getTransportCode");
620
+ function isTransportCode(code) {
621
+ return TRANSPORT_ERROR_CODES.has(code);
622
+ }
623
+ __name(isTransportCode, "isTransportCode");
624
+ var NETWORK_FAILURE_MESSAGE_RE = /network error for request /i;
625
+ function hasNetworkFailureCause(error) {
626
+ let current = error;
627
+ for (let depth = 0; depth <= MAX_TRANSPORT_CAUSE_DEPTH; depth++) {
628
+ if (typeof current !== "object" || current === null) return false;
629
+ const message = current.message;
630
+ if (typeof message === "string" && NETWORK_FAILURE_MESSAGE_RE.test(message)) {
631
+ return true;
632
+ }
633
+ current = current instanceof Error ? current.cause : void 0;
634
+ }
635
+ return false;
636
+ }
637
+ __name(hasNetworkFailureCause, "hasNetworkFailureCause");
638
+ var TRANSPORT_ERROR_CODES = /* @__PURE__ */ new Set([
639
+ "EAI_AGAIN",
640
+ "ECONNABORTED",
641
+ "ECONNREFUSED",
642
+ "ECONNRESET",
643
+ "EHOSTUNREACH",
644
+ "ENETUNREACH",
645
+ "ENOTFOUND",
646
+ "EPIPE",
647
+ "ETIMEDOUT",
648
+ "UND_ERR_BODY_TIMEOUT",
649
+ "UND_ERR_CONNECT_TIMEOUT",
650
+ "UND_ERR_HEADERS_TIMEOUT",
651
+ "UND_ERR_SOCKET"
652
+ ]);
653
+ function isAllocatedQuotaExceeded(providerCode) {
654
+ return providerCode === "Throttling.AllocationQuota";
655
+ }
656
+ __name(isAllocatedQuotaExceeded, "isAllocatedQuotaExceeded");
657
+ var PERMANENT_PROVIDER_CODE_PATTERN = /^(?:response[_-]?data[_-]?inspection[_-]?failed|data[_-]?inspection[_-]?failed|content[_-]?filter|invalid[_-]?api[_-]?key|arrearage|insufficient[_-]?quota|model[._-]?access[_-]?denied|invalid[_-]?request[_-]?error|authentication[_-]?error|permission[_-]?error|not[_-]?found[_-]?error|billing[_-]?error|invalid[_-]?parameter(?:[_-]?error)?|context[_-]?length[_-]?exceeded|request[_-]?too[_-]?large)$/i;
658
+ function isPermanentProviderCode(providerCode) {
659
+ return providerCode !== void 0 && PERMANENT_PROVIDER_CODE_PATTERN.test(providerCode);
660
+ }
661
+ __name(isPermanentProviderCode, "isPermanentProviderCode");
662
+ function getProviderFields(error) {
663
+ if (typeof error !== "object" || error === null) {
664
+ return {};
665
+ }
666
+ const source = error;
667
+ const rawCode = typeof source.code === "string" || typeof source.code === "number" ? String(source.code) : void 0;
668
+ const isHttpStatusEcho = typeof source.code === "number" && source.code >= 100 && source.code < 600;
669
+ const providerCode = error instanceof Error && rawCode?.startsWith("ERR_") || isHttpStatusEcho ? void 0 : rawCode;
670
+ const requestId = firstNonEmptyString(
671
+ source.request_id,
672
+ source.requestId,
673
+ source.requestID
674
+ );
675
+ const providerMessage = typeof source.message === "string" && (!(error instanceof Error) || providerCode !== void 0 || requestId !== void 0) ? source.message : void 0;
676
+ const providerType = firstNonEmptyString(source.type);
677
+ return {
678
+ ...providerCode !== void 0 ? { providerCode } : {},
679
+ ...providerType !== void 0 ? { providerType } : {},
680
+ ...providerMessage !== void 0 ? { providerMessage } : {},
681
+ ...requestId !== void 0 ? { requestId } : {}
682
+ };
683
+ }
684
+ __name(getProviderFields, "getProviderFields");
685
+ var FALLBACK_ELIGIBLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 503, 529]);
686
+ function isFallbackEligible(classification) {
687
+ return classification.kind !== "transport" && classification.statusCode !== void 0 && FALLBACK_ELIGIBLE_STATUS_CODES.has(classification.statusCode) && classification.diagnosis !== "fail-fast" && classification.diagnosis !== "unknown";
688
+ }
689
+ __name(isFallbackEligible, "isFallbackEligible");
690
+ function isRetryableUpstreamError(error, extraRetryErrorCodes) {
691
+ return isRateLimitError(error, extraRetryErrorCodes) || classifyRetryError(error, { extraRetryErrorCodes }).diagnosis === "retryable";
692
+ }
693
+ __name(isRetryableUpstreamError, "isRetryableUpstreamError");
694
+ function firstNonEmptyString(...values) {
695
+ for (const value of values) {
696
+ if (typeof value === "string" && value) {
697
+ return value;
698
+ }
699
+ }
700
+ return void 0;
701
+ }
702
+ __name(firstNonEmptyString, "firstNonEmptyString");
703
+
704
+ // packages/core/src/utils/retryContext.ts
705
+ init_esbuild_shims();
706
+ import { AsyncLocalStorage } from "node:async_hooks";
707
+ var retryContext = new AsyncLocalStorage();
708
+
709
+ // packages/core/src/utils/retry.ts
710
+ var debugLogger = createDebugLogger("RETRY");
711
+ var PERSISTENT_MAX_BACKOFF_MS = 5 * 60 * 1e3;
712
+ var PERSISTENT_CAP_MS = 6 * 60 * 60 * 1e3;
713
+ var HEARTBEAT_INTERVAL_MS = 3e4;
714
+ var DEFAULT_RETRY_OPTIONS = {
715
+ maxAttempts: 7,
716
+ initialDelayMs: 1500,
717
+ maxDelayMs: 3e4,
718
+ // 30 seconds
719
+ shouldRetryOnError: defaultShouldRetry
720
+ };
721
+ function defaultShouldRetry(error, extraRetryErrorCodes) {
722
+ if (error instanceof ResponsesHttpError) {
723
+ return error.shouldRetry(extraRetryErrorCodes);
724
+ }
725
+ const status = getErrorStatus(error);
726
+ if (status !== void 0 && status >= 500 && status < 600) {
727
+ return true;
728
+ }
729
+ return isRetryableUpstreamError(error, extraRetryErrorCodes);
730
+ }
731
+ __name(defaultShouldRetry, "defaultShouldRetry");
732
+ function hasRetryAfterStatus(status) {
733
+ return status === 429 || status === 503;
734
+ }
735
+ __name(hasRetryAfterStatus, "hasRetryAfterStatus");
736
+ function isTransientCapacityError(error) {
737
+ const status = getErrorStatus(error);
738
+ return status === 429 || status === 529;
739
+ }
740
+ __name(isTransientCapacityError, "isTransientCapacityError");
741
+ function isUnattendedMode() {
742
+ const val = process.env["O1CODE_UNATTENDED_RETRY"];
743
+ return val === "true" || val === "1";
744
+ }
745
+ __name(isUnattendedMode, "isUnattendedMode");
746
+ function delay(ms, signal) {
747
+ return new Promise((resolve, reject) => {
748
+ if (signal?.aborted) {
749
+ return reject(new Error("Retry aborted by signal"));
750
+ }
751
+ const cleanup = /* @__PURE__ */ __name(() => {
752
+ signal?.removeEventListener("abort", onAbort);
753
+ }, "cleanup");
754
+ function onAbort() {
755
+ clearTimeout(timeout);
756
+ cleanup();
757
+ reject(new Error("Retry aborted by signal"));
758
+ }
759
+ __name(onAbort, "onAbort");
760
+ const timeout = setTimeout(() => {
761
+ cleanup();
762
+ resolve();
763
+ }, ms);
764
+ signal?.addEventListener("abort", onAbort, { once: true });
765
+ if (signal?.aborted) {
766
+ clearTimeout(timeout);
767
+ cleanup();
768
+ reject(new Error("Retry aborted by signal"));
769
+ }
770
+ });
771
+ }
772
+ __name(delay, "delay");
773
+ async function sleepWithHeartbeat(totalMs, ctx) {
774
+ let remaining = totalMs;
775
+ while (remaining > 0) {
776
+ if (ctx.signal?.aborted) {
777
+ throw new Error("Retry aborted by signal");
778
+ }
779
+ const chunk = Math.max(1, Math.min(remaining, ctx.heartbeatInterval));
780
+ await delay(chunk, ctx.signal);
781
+ remaining -= chunk;
782
+ if (remaining > 0 && ctx.heartbeatFn) {
783
+ ctx.heartbeatFn({
784
+ attempt: ctx.attempt,
785
+ remainingMs: remaining,
786
+ error: ctx.error
787
+ });
788
+ }
789
+ }
790
+ }
791
+ __name(sleepWithHeartbeat, "sleepWithHeartbeat");
792
+ async function retryWithBackoff(fn, options) {
793
+ if (options?.maxAttempts !== void 0 && options.maxAttempts <= 0) {
794
+ throw new Error("maxAttempts must be a positive number.");
795
+ }
796
+ const cleanOptions = options ? Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null)) : {};
797
+ const {
798
+ maxAttempts,
799
+ initialDelayMs,
800
+ maxDelayMs,
801
+ authType,
802
+ extraRetryErrorCodes,
803
+ shouldRetryOnError,
804
+ shouldRetryOnContent,
805
+ persistentMode,
806
+ persistentMaxBackoffMs,
807
+ persistentCapMs,
808
+ heartbeatIntervalMs,
809
+ heartbeatFn,
810
+ signal,
811
+ onRetry
812
+ } = {
813
+ ...DEFAULT_RETRY_OPTIONS,
814
+ ...cleanOptions
815
+ };
816
+ const hasCustomShouldRetryOnError = typeof options?.shouldRetryOnError === "function";
817
+ const persistent = persistentMode ?? false;
818
+ const maxBackoff = persistentMaxBackoffMs ?? PERSISTENT_MAX_BACKOFF_MS;
819
+ const capMs = persistentCapMs ?? PERSISTENT_CAP_MS;
820
+ const heartbeatInterval = heartbeatIntervalMs ?? HEARTBEAT_INTERVAL_MS;
821
+ let attempt = 0;
822
+ let persistentAttempt = 0;
823
+ let currentDelay = initialDelayMs;
824
+ const requestEntryTime = Date.now();
825
+ let iterationCount = 0;
826
+ let retryTotalDelayMs = 0;
827
+ let lastContentResult;
828
+ let hadContentRetry = false;
829
+ while (attempt < maxAttempts) {
830
+ attempt++;
831
+ iterationCount++;
832
+ const requestSetupMs = Date.now() - requestEntryTime;
833
+ try {
834
+ const result = await retryContext.run(
835
+ { attempt: iterationCount, retryTotalDelayMs, requestSetupMs },
836
+ () => fn()
837
+ );
838
+ if (shouldRetryOnContent && shouldRetryOnContent(result)) {
839
+ lastContentResult = result;
840
+ hadContentRetry = true;
841
+ const delayMs = getRetryDelayMs({
842
+ // attempt: 1 — currentDelay already tracks exponential growth;
843
+ // getRetryDelayMs is called here only for jitter calculation.
844
+ attempt: 1,
845
+ initialDelayMs: currentDelay,
846
+ maxDelayMs,
847
+ jitterRatio: 0.3
848
+ });
849
+ debugLogger.warn(
850
+ `Attempt ${iterationCount}: response rejected by content check. Retrying with backoff in ${Math.ceil(delayMs / 1e3)}s...`
851
+ );
852
+ await delay(delayMs, signal);
853
+ retryTotalDelayMs += delayMs;
854
+ currentDelay = Math.min(maxDelayMs, currentDelay * 2);
855
+ continue;
856
+ }
857
+ return result;
858
+ } catch (error) {
859
+ const errorStatus = getErrorStatus(error);
860
+ const retryDiagnostics = classifyRetryError(error, {
861
+ authType,
862
+ extraRetryErrorCodes
863
+ });
864
+ if (retryDiagnostics.kind === "abort") {
865
+ throw error;
866
+ }
867
+ if (isQuotaExhaustedError(error)) {
868
+ debugLogger.error(
869
+ "Quota exhausted, fast-failing",
870
+ retryDiagnostics,
871
+ error
872
+ );
873
+ throw new Error(formatQuotaExhaustedMessage(error), { cause: error });
874
+ }
875
+ if (isLongProxyWait(error)) {
876
+ debugLogger.error("Proxy asks for a long wait, fast-failing", error);
877
+ throw new Error(formatProxyWaitMessage(error), { cause: error });
878
+ }
879
+ const isTransient = isTransientCapacityError(error);
880
+ const callerAllowsRetry = hasCustomShouldRetryOnError ? shouldRetryOnError(error) : defaultShouldRetry(error, extraRetryErrorCodes);
881
+ const isFailFast = retryDiagnostics.diagnosis === "fail-fast";
882
+ const shouldPersist = persistent && isTransient && callerAllowsRetry && !isFailFast;
883
+ if (!shouldPersist) {
884
+ if (attempt >= maxAttempts || !callerAllowsRetry) {
885
+ throw error;
886
+ }
887
+ }
888
+ let delayMs;
889
+ if (shouldPersist) {
890
+ persistentAttempt++;
891
+ const retryAfterMs = hasRetryAfterStatus(errorStatus) || error instanceof ResponsesHttpError ? getRetryAfterDelayMs(error) : null;
892
+ if (retryAfterMs !== null && retryAfterMs > 0) {
893
+ delayMs = Math.min(retryAfterMs, capMs);
894
+ } else {
895
+ delayMs = getRetryDelayMs({
896
+ attempt: persistentAttempt,
897
+ initialDelayMs,
898
+ maxDelayMs: Math.min(maxBackoff, capMs),
899
+ jitterRatio: 0.25
900
+ });
901
+ }
902
+ const reportedAttempt = persistentAttempt;
903
+ debugLogger.warn(
904
+ `[Persistent] Attempt ${reportedAttempt} failed with status ${errorStatus ?? "unknown"}. Retrying in ${Math.ceil(delayMs / 1e3)}s...`,
905
+ retryDiagnostics,
906
+ error
907
+ );
908
+ if (!signal?.aborted) {
909
+ try {
910
+ onRetry?.({
911
+ attempt: iterationCount,
912
+ error,
913
+ errorStatus,
914
+ delayMs
915
+ });
916
+ } catch (cbError) {
917
+ debugLogger.warn(
918
+ `onRetry callback threw (swallowed): ${cbError instanceof Error ? cbError.message : String(cbError)}`
919
+ );
920
+ }
921
+ }
922
+ await sleepWithHeartbeat(delayMs, {
923
+ attempt: reportedAttempt,
924
+ error,
925
+ heartbeatInterval,
926
+ heartbeatFn,
927
+ signal
928
+ });
929
+ retryTotalDelayMs += delayMs;
930
+ if (attempt >= maxAttempts) {
931
+ attempt = maxAttempts - 1;
932
+ }
933
+ } else {
934
+ const retryAfterMs = hasRetryAfterStatus(errorStatus) || error instanceof ResponsesHttpError ? getRetryAfterDelayMs(error) : null;
935
+ let actualDelayMs;
936
+ if (retryAfterMs !== null && retryAfterMs > 0) {
937
+ actualDelayMs = retryAfterMs;
938
+ currentDelay = initialDelayMs;
939
+ logRetryAtStatusLevel(
940
+ `Attempt ${attempt} failed with status ${errorStatus ?? "unknown"}. Retrying after explicit delay of ${retryAfterMs}ms...`,
941
+ retryDiagnostics,
942
+ error,
943
+ errorStatus
944
+ );
945
+ } else {
946
+ actualDelayMs = getRetryDelayMs({
947
+ // attempt: 1 — currentDelay already tracks exponential growth;
948
+ // getRetryDelayMs is called here only for jitter calculation.
949
+ attempt: 1,
950
+ initialDelayMs: currentDelay,
951
+ maxDelayMs,
952
+ jitterRatio: 0.3
953
+ });
954
+ currentDelay = Math.min(maxDelayMs, currentDelay * 2);
955
+ logRetryAttempt(
956
+ attempt,
957
+ error,
958
+ retryDiagnostics,
959
+ errorStatus,
960
+ actualDelayMs
961
+ );
962
+ }
963
+ if (!signal?.aborted) {
964
+ try {
965
+ onRetry?.({
966
+ attempt: iterationCount,
967
+ error,
968
+ errorStatus,
969
+ delayMs: actualDelayMs
970
+ });
971
+ } catch (cbError) {
972
+ debugLogger.warn(
973
+ `onRetry callback threw (swallowed): ${cbError instanceof Error ? cbError.message : String(cbError)}`
974
+ );
975
+ }
976
+ }
977
+ await delay(actualDelayMs, signal);
978
+ retryTotalDelayMs += actualDelayMs;
979
+ }
980
+ }
981
+ }
982
+ if (hadContentRetry) {
983
+ return lastContentResult;
984
+ }
985
+ throw new Error("Retry attempts exhausted");
986
+ }
987
+ __name(retryWithBackoff, "retryWithBackoff");
988
+ function logRetryAttempt(attempt, error, retryDiagnostics, errorStatus, delayMs) {
989
+ const backoff = delayMs !== void 0 ? `Retrying with backoff in ${Math.ceil(delayMs / 1e3)}s...` : "Retrying with backoff...";
990
+ const message = errorStatus ? `Attempt ${attempt} failed with status ${errorStatus}. ${backoff}` : `Attempt ${attempt} failed. ${backoff}`;
991
+ logRetryAtStatusLevel(message, retryDiagnostics, error, errorStatus);
992
+ }
993
+ __name(logRetryAttempt, "logRetryAttempt");
994
+ function logRetryAtStatusLevel(message, retryDiagnostics, error, errorStatus) {
995
+ if (errorStatus !== void 0 && errorStatus >= 500 && errorStatus < 600) {
996
+ debugLogger.error(message, retryDiagnostics, error);
997
+ } else {
998
+ debugLogger.warn(message, retryDiagnostics, error);
999
+ }
1000
+ }
1001
+ __name(logRetryAtStatusLevel, "logRetryAtStatusLevel");
1002
+
1003
+ // packages/core/src/utils/fetch.ts
1004
+ import { URL } from "node:url";
1005
+ var PRIVATE_IP_RANGES = [
1006
+ /^10\./,
1007
+ /^127\./,
1008
+ /^172\.(1[6-9]|2[0-9]|3[0-1])\./,
1009
+ /^192\.168\./,
1010
+ // IPv4 link-local (incl. cloud metadata endpoints) and CGNAT 100.64.0.0/10.
1011
+ /^169\.254\./,
1012
+ /^100\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\./,
1013
+ /^0\.0\.0\.0$/,
1014
+ /^::1$/,
1015
+ /^::$/,
1016
+ // ULA fc00::/7 covers fc00: through fdff: (fd00: is the common prefix in
1017
+ // practice); link-local fe80::/10 covers fe80: through febf:.
1018
+ /^f[cd][0-9a-f]{2}:/i,
1019
+ /^fe[89ab][0-9a-f]:/i
1020
+ ];
1021
+ var TLS_ERROR_CODES = /* @__PURE__ */ new Set([
1022
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
1023
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
1024
+ "SELF_SIGNED_CERT_IN_CHAIN",
1025
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
1026
+ "CERT_HAS_EXPIRED",
1027
+ "ERR_TLS_CERT_ALTNAME_INVALID"
1028
+ ]);
1029
+ var FETCH_TROUBLESHOOTING_ERROR_CODES = /* @__PURE__ */ new Set([
1030
+ ...TLS_ERROR_CODES,
1031
+ "ECONNRESET",
1032
+ "ETIMEDOUT",
1033
+ "ECONNREFUSED",
1034
+ "ENOTFOUND",
1035
+ "EAI_AGAIN",
1036
+ "EHOSTUNREACH",
1037
+ "ENETUNREACH"
1038
+ ]);
1039
+ var FetchError = class extends Error {
1040
+ constructor(message, code) {
1041
+ super(message);
1042
+ this.code = code;
1043
+ this.name = "FetchError";
1044
+ }
1045
+ static {
1046
+ __name(this, "FetchError");
1047
+ }
1048
+ };
1049
+ var CONNECTION_LEVEL_ERROR_CODES = /* @__PURE__ */ new Set([
1050
+ ...TLS_ERROR_CODES,
1051
+ "ECONNREFUSED",
1052
+ "EPROTO",
1053
+ "ERR_SSL_WRONG_VERSION_NUMBER",
1054
+ // Servers that don't speak TLS on 443 often reset during the handshake
1055
+ // rather than refusing the connection. Safe to include: the http fallback
1056
+ // only ever fires for URLs the caller requested as http.
1057
+ "ECONNRESET",
1058
+ "UND_ERR_SOCKET",
1059
+ // Filtered port 443 (silent drop): undici's own bounded connect timeout.
1060
+ // Deliberately NOT the full-budget ETIMEDOUT — that can fire mid-body on
1061
+ // a healthy https server, and a fallback there would double a worst-case
1062
+ // 60s wait for an ambiguous gain.
1063
+ "UND_ERR_CONNECT_TIMEOUT",
1064
+ // No route to the host or network on 443: the network layer refused
1065
+ // before any TLS, as a filtered port does.
1066
+ "EHOSTUNREACH",
1067
+ "ENETUNREACH"
1068
+ ]);
1069
+ function isConnectionLevelError(error) {
1070
+ return error instanceof FetchError && error.code !== void 0 && CONNECTION_LEVEL_ERROR_CODES.has(error.code);
1071
+ }
1072
+ __name(isConnectionLevelError, "isConnectionLevelError");
1073
+ function mappedIpv4(hostname) {
1074
+ const match = /^::ffff:(.+)$/i.exec(hostname);
1075
+ if (!match) return void 0;
1076
+ const tail = match[1];
1077
+ if (tail.includes(".")) return tail;
1078
+ const groups = tail.split(":");
1079
+ if (groups.length !== 2) return void 0;
1080
+ const hi = Number.parseInt(groups[0], 16);
1081
+ const lo = Number.parseInt(groups[1], 16);
1082
+ if (Number.isNaN(hi) || Number.isNaN(lo)) return void 0;
1083
+ return `${hi >> 8}.${hi & 255}.${lo >> 8}.${lo & 255}`;
1084
+ }
1085
+ __name(mappedIpv4, "mappedIpv4");
1086
+ function isPrivateAddress(address) {
1087
+ const bare = address.replace(/^\[|\]$/g, "");
1088
+ const target = mappedIpv4(bare) ?? bare;
1089
+ return PRIVATE_IP_RANGES.some((range) => range.test(target));
1090
+ }
1091
+ __name(isPrivateAddress, "isPrivateAddress");
1092
+ function isPrivateIp(url) {
1093
+ try {
1094
+ return isPrivateAddress(new URL(url).hostname);
1095
+ } catch (_e) {
1096
+ return false;
1097
+ }
1098
+ }
1099
+ __name(isPrivateIp, "isPrivateIp");
1100
+ var INTERNAL_HOST_SUFFIXES = [".local", ".internal", ".lan", ".home.arpa"];
1101
+ function isPrivateHost(url) {
1102
+ try {
1103
+ const hostname = new URL(url).hostname.toLowerCase();
1104
+ return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "host.docker.internal" || // Single-label hostnames (intranet, ci, printserver) are never public.
1105
+ // IPv6 literals are bracketed and dot-free but CAN be public — they
1106
+ // are classified by isPrivateIp below, not by this heuristic.
1107
+ !hostname.includes(".") && !hostname.startsWith("[") || INTERNAL_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix)) || isPrivateIp(url);
1108
+ } catch {
1109
+ return false;
1110
+ }
1111
+ }
1112
+ __name(isPrivateHost, "isPrivateHost");
1113
+ var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
1114
+ function isPermittedRedirect(originalUrl, redirectUrl) {
1115
+ try {
1116
+ const original = new URL(originalUrl);
1117
+ const redirect = new URL(redirectUrl);
1118
+ if (redirect.protocol !== original.protocol) return false;
1119
+ if (redirect.port !== original.port) return false;
1120
+ if (redirect.username || redirect.password) return false;
1121
+ const stripWww = /* @__PURE__ */ __name((hostname) => hostname.replace(/^www\./, ""), "stripWww");
1122
+ return stripWww(original.hostname) === stripWww(redirect.hostname);
1123
+ } catch {
1124
+ return false;
1125
+ }
1126
+ }
1127
+ __name(isPermittedRedirect, "isPermittedRedirect");
1128
+ var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([403, 429]);
1129
+ var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
1130
+ "ECONNRESET",
1131
+ "EAI_AGAIN",
1132
+ "UND_ERR_SOCKET"
1133
+ ]);
1134
+ var RETRY_DELAY_MS = 500;
1135
+ async function fetchWithPolicy(url, options) {
1136
+ const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
1137
+ const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
1138
+ const abortError = /* @__PURE__ */ __name(() => {
1139
+ if (options.signal?.aborted) {
1140
+ return options.signal.reason instanceof Error ? options.signal.reason : new FetchError("Request aborted", "ABORT_ERR");
1141
+ }
1142
+ if (timeoutSignal.aborted) {
1143
+ return new FetchError(
1144
+ `Request timed out after ${options.timeoutMs}ms`,
1145
+ "ETIMEDOUT"
1146
+ );
1147
+ }
1148
+ return void 0;
1149
+ }, "abortError");
1150
+ let first;
1151
+ try {
1152
+ first = await fetchPolicyAttempt(url, options, signal, timeoutSignal);
1153
+ } catch (error) {
1154
+ if (error instanceof FetchError && error.code !== void 0 && RETRYABLE_ERROR_CODES.has(error.code) && !signal.aborted) {
1155
+ try {
1156
+ await delay(RETRY_DELAY_MS, signal);
1157
+ } catch {
1158
+ throw abortError() ?? error;
1159
+ }
1160
+ return fetchPolicyAttempt(url, options, signal, timeoutSignal);
1161
+ }
1162
+ throw error;
1163
+ }
1164
+ if (first.kind === "response" && RETRYABLE_STATUSES.has(first.status) && !signal.aborted) {
1165
+ try {
1166
+ await delay(RETRY_DELAY_MS, signal);
1167
+ return await fetchPolicyAttempt(url, options, signal, timeoutSignal);
1168
+ } catch {
1169
+ const aborted = abortError();
1170
+ if (aborted) throw aborted;
1171
+ return first;
1172
+ }
1173
+ }
1174
+ return first;
1175
+ }
1176
+ __name(fetchWithPolicy, "fetchWithPolicy");
1177
+ async function fetchPolicyAttempt(url, options, signal, timeoutSignal) {
1178
+ const wrapAbort = /* @__PURE__ */ __name((error) => {
1179
+ if (options.signal?.aborted) {
1180
+ throw options.signal.reason instanceof Error ? options.signal.reason : new FetchError("Request aborted", "ABORT_ERR");
1181
+ }
1182
+ if (timeoutSignal.aborted) {
1183
+ throw new FetchError(
1184
+ `Request timed out after ${options.timeoutMs}ms`,
1185
+ "ETIMEDOUT"
1186
+ );
1187
+ }
1188
+ if (error instanceof FetchError) throw error;
1189
+ throw new FetchError(getErrorMessage(error), classifyErrorCode(error));
1190
+ }, "wrapAbort");
1191
+ let currentUrl = url;
1192
+ for (let hop = 0; hop <= options.maxRedirects; hop++) {
1193
+ let response;
1194
+ try {
1195
+ response = await fetch(currentUrl, {
1196
+ signal,
1197
+ headers: options.headers,
1198
+ redirect: "manual"
1199
+ });
1200
+ } catch (error) {
1201
+ return wrapAbort(error);
1202
+ }
1203
+ if (REDIRECT_STATUSES.has(response.status)) {
1204
+ const location = response.headers.get("location");
1205
+ await response.body?.cancel().catch(() => {
1206
+ });
1207
+ if (!location) {
1208
+ throw new FetchError("Redirect response missing Location header");
1209
+ }
1210
+ let redirectUrl;
1211
+ try {
1212
+ redirectUrl = new URL(location, currentUrl).toString();
1213
+ } catch {
1214
+ throw new FetchError(
1215
+ `Redirect response has a malformed Location header: ${location}`
1216
+ );
1217
+ }
1218
+ if (!isPermittedRedirect(currentUrl, redirectUrl)) {
1219
+ return {
1220
+ kind: "cross-host-redirect",
1221
+ originalUrl: currentUrl,
1222
+ redirectUrl,
1223
+ status: response.status
1224
+ };
1225
+ }
1226
+ currentUrl = redirectUrl;
1227
+ continue;
1228
+ }
1229
+ if (response.status < 200 || response.status >= 300) {
1230
+ await response.body?.cancel().catch(() => {
1231
+ });
1232
+ return {
1233
+ kind: "response",
1234
+ status: response.status,
1235
+ statusText: response.statusText,
1236
+ contentType: response.headers.get("content-type") ?? "",
1237
+ contentDisposition: response.headers.get("content-disposition") ?? "",
1238
+ body: Buffer.alloc(0),
1239
+ finalUrl: currentUrl
1240
+ };
1241
+ }
1242
+ const contentLength = Number(response.headers.get("content-length"));
1243
+ if (Number.isFinite(contentLength) && contentLength > options.maxBytes) {
1244
+ await response.body?.cancel().catch(() => {
1245
+ });
1246
+ throw new FetchError(
1247
+ `Response too large: ${contentLength} bytes exceeds the ${options.maxBytes}-byte limit`,
1248
+ "EMSGSIZE"
1249
+ );
1250
+ }
1251
+ const chunks = [];
1252
+ let total = 0;
1253
+ if (response.body) {
1254
+ const reader = response.body.getReader();
1255
+ try {
1256
+ for (; ; ) {
1257
+ const { done, value } = await reader.read();
1258
+ if (done) break;
1259
+ total += value.byteLength;
1260
+ if (total > options.maxBytes) {
1261
+ throw new FetchError(
1262
+ `Response too large: exceeded the ${options.maxBytes}-byte limit while streaming`,
1263
+ "EMSGSIZE"
1264
+ );
1265
+ }
1266
+ chunks.push(value);
1267
+ }
1268
+ } catch (error) {
1269
+ await reader.cancel().catch(() => {
1270
+ });
1271
+ if (error instanceof FetchError) throw error;
1272
+ return wrapAbort(error);
1273
+ } finally {
1274
+ reader.releaseLock();
1275
+ }
1276
+ }
1277
+ return {
1278
+ kind: "response",
1279
+ status: response.status,
1280
+ statusText: response.statusText,
1281
+ contentType: response.headers.get("content-type") ?? "",
1282
+ contentDisposition: response.headers.get("content-disposition") ?? "",
1283
+ body: Buffer.concat(chunks, total),
1284
+ finalUrl: currentUrl
1285
+ };
1286
+ }
1287
+ throw new FetchError(
1288
+ `Too many redirects (exceeded ${options.maxRedirects})`,
1289
+ "EMAXREDIRECTS"
1290
+ );
1291
+ }
1292
+ __name(fetchPolicyAttempt, "fetchPolicyAttempt");
1293
+ function classifyErrorCode(error) {
1294
+ const cause = error instanceof Error ? error.cause : void 0;
1295
+ const attempts = [error, cause].flatMap((candidate) => {
1296
+ const errors = candidate?.errors;
1297
+ return Array.isArray(errors) ? errors : [];
1298
+ });
1299
+ const connectionLevel = attempts.map(getErrorCode2).find(
1300
+ (code) => code !== void 0 && CONNECTION_LEVEL_ERROR_CODES.has(code)
1301
+ );
1302
+ return connectionLevel ?? getErrorCode2(error) ?? getErrorCode2(cause);
1303
+ }
1304
+ __name(classifyErrorCode, "classifyErrorCode");
1305
+ function getErrorCode2(error) {
1306
+ if (!error || typeof error !== "object") {
1307
+ return void 0;
1308
+ }
1309
+ if ("code" in error && typeof error["code"] === "string") {
1310
+ return error["code"];
1311
+ }
1312
+ return void 0;
1313
+ }
1314
+ __name(getErrorCode2, "getErrorCode");
1315
+
1316
+ export {
1317
+ isApiError,
1318
+ isStructuredError,
1319
+ QUOTA_EXHAUSTED_PREFIX,
1320
+ isQuotaExhaustedError,
1321
+ formatQuotaExhaustedMessage,
1322
+ getErrorHeader,
1323
+ isRateLimitError,
1324
+ getRateLimitErrorDetails,
1325
+ getRateLimitRetryDelayMs,
1326
+ ResponsesHttpError,
1327
+ classifyRetryError,
1328
+ getTransportCode,
1329
+ isFallbackEligible,
1330
+ isRetryableUpstreamError,
1331
+ retryContext,
1332
+ isUnattendedMode,
1333
+ delay,
1334
+ retryWithBackoff,
1335
+ isConnectionLevelError,
1336
+ isPrivateHost,
1337
+ isPermittedRedirect,
1338
+ fetchWithPolicy
1339
+ };
1340
+ /**
1341
+ * @license
1342
+ * Copyright 2025 Google LLC
1343
+ * SPDX-License-Identifier: Apache-2.0
1344
+ */
1345
+ /**
1346
+ * @license
1347
+ * Copyright 2026 Google LLC
1348
+ * SPDX-License-Identifier: Apache-2.0
1349
+ */
1350
+ /**
1351
+ * @license
1352
+ * Copyright 2026 o1-code contributors
1353
+ * SPDX-License-Identifier: Apache-2.0
1354
+ */
1355
+ /**
1356
+ * @license
1357
+ * Copyright 2026 Qwen
1358
+ * SPDX-License-Identifier: Apache-2.0
1359
+ */
1360
+ /**
1361
+ * @license
1362
+ * Copyright 2026 Qwen Team
1363
+ * Modified by the o1-code project; see NOTICE.
1364
+ * SPDX-License-Identifier: Apache-2.0
1365
+ */