nolo-cli 0.149.0-alpha.1 → 0.151.0-alpha.2

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 (258) hide show
  1. package/{_executeModel-OW3H7ICR.js → _executeModel-XHAFJ2MM.js} +134 -91
  2. package/accountResolver-7RYB4D2P.js +300 -0
  3. package/action-SXJD5N5R.js +23 -0
  4. package/{addContentAction-B2DRF7P6.js → addContentAction-ZV774PHH.js} +20 -14
  5. package/{addDialogAgentAction-2P2FLTLD.js → addDialogAgentAction-A6SMKAGH.js} +26 -22
  6. package/{agentDeleteCommand-7IDWF6E3.js → agentDeleteCommand-DPUUS56Z.js} +181 -93
  7. package/{agentEmailCommands-A6XBQZBN.js → agentEmailCommands-V4P5EFLP.js} +132 -112
  8. package/{agentGrantCommands-M3XFO6EN.js → agentGrantCommands-HOJ3JBBQ.js} +3 -3
  9. package/agentListCommands-TWFLUYIZ.js +802 -0
  10. package/{agentMachineCommands-DQPUIMAC.js → agentMachineCommands-MELPAZZI.js} +58 -62
  11. package/{agentProviderCommands-YK2BIIXZ.js → agentProviderCommands-HL6MBLCL.js} +149 -2
  12. package/{agentPullCommand-HF4A42D4.js → agentPullCommand-FA43RBRU.js} +7 -7
  13. package/agentRecordCommands-FSWSSQIO.js +154 -0
  14. package/agentRunCommand-GDBJVOAT.js +183 -0
  15. package/{agentRunControl-2SKCR4SB.js → agentRunControl-IFM7IGMG.js} +10 -2
  16. package/{agentRuntimeLocal-AK2QVJHY.js → agentRuntimeLocal-KKSQJMTE.js} +47 -50
  17. package/{agentSlice-O4RUQUMT.js → agentSlice-YO2ZLJMD.js} +23 -16
  18. package/{appDeleteCommands-N3XEVVYC.js → appDeleteCommands-4PL4KYRN.js} +58 -59
  19. package/{appDeployCommands-AWFIXYVW.js → appDeployCommands-EEEXCEB6.js} +67 -63
  20. package/{appDeployStatusCommands-CZRON2FO.js → appDeployStatusCommands-35ZX7T66.js} +56 -56
  21. package/{appGetCommands-XQIUY4TD.js → appGetCommands-WFCHXJWF.js} +56 -56
  22. package/{appListCommands-NNG4H36Y.js → appListCommands-XY2U6DPF.js} +57 -59
  23. package/{authCommand-UBJ4EWYZ.js → authCommand-QYN47CQD.js} +371 -68
  24. package/{authCommands-H6WKKCRW.js → authCommands-77CHYBGF.js} +12 -9
  25. package/{builtinSkillRegistry-ZMF6YGNO.js → builtinSkillRegistry-TDQ6JB2E.js} +13 -11
  26. package/{chromeCommands-2N6MEWRU.js → chromeCommands-OBBNJCLS.js} +314 -13
  27. package/chromeOpsCommands-3Z34RKSE.js +472 -0
  28. package/{chunk-ALXHV7NK.js → chunk-2GGXHQIW.js} +43 -4
  29. package/{localRuntimeAuthority-5W6IJRAD.js → chunk-2IXDJNZI.js} +154 -75
  30. package/{chunk-IVZJWTDI.js → chunk-36OMEXXR.js} +89 -21
  31. package/{chunk-H6A6X4EK.js → chunk-3MZAGMYY.js} +16 -0
  32. package/chunk-3PVYUPXK.js +40 -0
  33. package/chunk-3SZA4U64.js +1192 -0
  34. package/{chunk-GNMAFAIS.js → chunk-44WXLHFI.js} +1 -1
  35. package/{chunk-AGGIDPCZ.js → chunk-4JH2UMJR.js} +6 -0
  36. package/chunk-4LCOCOR5.js +50 -0
  37. package/chunk-4YRTZIVN.js +871 -0
  38. package/chunk-556RW72X.js +14110 -0
  39. package/{chunk-N7J63Q6C.js → chunk-56GBUMO5.js} +10 -1
  40. package/{chunk-W7XHHYWM.js → chunk-5BHQICF2.js} +5 -1
  41. package/{chunk-XUWRURDF.js → chunk-5EBLANFT.js} +1 -1
  42. package/{chunk-3AH7LNUB.js → chunk-5EMSBTQ6.js} +33 -14
  43. package/{chunk-YRRASA5Q.js → chunk-5MM7NNO6.js} +113 -52
  44. package/chunk-5MMAK75Q.js +15 -0
  45. package/{chunk-M5PVFLD4.js → chunk-64K7WX26.js} +90 -21
  46. package/{chunk-AKG5W4LG.js → chunk-6CCFTVBP.js} +76 -221
  47. package/chunk-6MJNEXUU.js +614 -0
  48. package/{chunk-62IL3KQV.js → chunk-6MXDOUMH.js} +15 -3
  49. package/{chunk-QOKAKDPE.js → chunk-6Q7UTJKR.js} +6 -94
  50. package/chunk-6QDYSCPW.js +223 -0
  51. package/{chunk-HYZIYH2H.js → chunk-74RAWNQN.js} +56 -63
  52. package/chunk-7DPNBQSV.js +9 -0
  53. package/chunk-7MOXKPHC.js +119 -0
  54. package/{chunk-ZUEK6A6C.js → chunk-7XKL25PW.js} +1973 -754
  55. package/{chunk-IAESIMK7.js → chunk-A4MW3YZL.js} +10 -14
  56. package/chunk-AGIM7IMJ.js +147 -0
  57. package/{chunk-7CHC4W22.js → chunk-AIZE5TDM.js} +3 -3
  58. package/{chunk-YAQJJDC2.js → chunk-AOCM7HPT.js} +214 -51
  59. package/{chunk-5GVBDNTO.js → chunk-AU7AXHUL.js} +1 -1
  60. package/{chunk-4H22P2JV.js → chunk-AUIJZACN.js} +2073 -1275
  61. package/{chunk-CIF4X6ZM.js → chunk-AWVFQMOV.js} +25 -3
  62. package/{chunk-RYZINGPM.js → chunk-BPMPOFWP.js} +347 -235
  63. package/{chunk-YUNJN43V.js → chunk-BU2YQBV4.js} +215 -28
  64. package/{chunk-XPRWFQQK.js → chunk-CBHGZRCE.js} +38 -12
  65. package/{chunk-Y3PMXGLH.js → chunk-CHCS6XPJ.js} +365 -144
  66. package/chunk-CHOZJMJS.js +78 -0
  67. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  68. package/{chunk-3SV7RM24.js → chunk-D2QN6CTI.js} +117 -72
  69. package/{chunk-5TEEECZM.js → chunk-E2AKSW7L.js} +10 -7
  70. package/{chunk-RSEEDUMS.js → chunk-EDX5XSJM.js} +2 -2
  71. package/{chunk-ATLTFRYJ.js → chunk-ES633ZS5.js} +280 -98
  72. package/{chunk-QDSINZM3.js → chunk-EUGTFFO6.js} +2 -23
  73. package/{chunk-UNYJU5L6.js → chunk-EYLGAEB4.js} +5 -1
  74. package/{chunk-CU3QB4HW.js → chunk-EYWJT7A2.js} +12 -12
  75. package/{chunk-BNGW5ASC.js → chunk-EZVK3N5L.js} +66 -18
  76. package/{chunk-6FGTMQCL.js → chunk-F32Z66T4.js} +6 -10
  77. package/chunk-FJMRBOPO.js +11507 -0
  78. package/{chunk-ZOVKKMF6.js → chunk-FY4SDK2E.js} +1 -1
  79. package/chunk-G6OOUQWJ.js +417 -0
  80. package/{chunk-PQWU42UQ.js → chunk-GCKHQECX.js} +6 -6
  81. package/chunk-GKXCHNTE.js +15 -0
  82. package/{chunk-TXH4IWJL.js → chunk-GQN2WLAI.js} +20 -11
  83. package/{chunk-P6GMCCAT.js → chunk-GQV5KHJU.js} +78 -12
  84. package/{chunk-B2XUQXQX.js → chunk-HIQ4GF53.js} +191 -68
  85. package/{chunk-MST6R3E4.js → chunk-HKX3ULQB.js} +34 -22
  86. package/{chunk-GMZLP5DV.js → chunk-HNUWUO75.js} +30 -19
  87. package/{chunk-5UTFL4QJ.js → chunk-I2ZMGXXF.js} +10 -5
  88. package/chunk-I42VC5KR.js +15 -0
  89. package/{chunk-3BXNTXYI.js → chunk-I4SN4NUQ.js} +1199 -56
  90. package/chunk-IA7TRNNR.js +11 -0
  91. package/{chunk-WIWM4FE3.js → chunk-IJERIUXS.js} +55 -748
  92. package/{chunk-CPUFH46E.js → chunk-ILU2NPWY.js} +10 -10
  93. package/{chunk-SLLGJZDT.js → chunk-ISQL4V7C.js} +4 -4
  94. package/chunk-IT3ZZRJE.js +12 -0
  95. package/{chunk-TZZ2WRBL.js → chunk-IZ7OJB6K.js} +20 -16
  96. package/{chunk-DY7ANLKG.js → chunk-JKMLSTZK.js} +43 -12
  97. package/{chunk-6TPOEJMQ.js → chunk-JZX2XLKC.js} +64 -23
  98. package/{chunk-27ONFIEY.js → chunk-K2AER7RX.js} +19 -12
  99. package/{chunk-O2OWEFII.js → chunk-KFHQQ3NO.js} +1 -1
  100. package/{chunk-QXGPFY6J.js → chunk-LGN377P3.js} +27 -17
  101. package/{chunk-L36OWPP3.js → chunk-LIQJTQRN.js} +118 -139
  102. package/{chunk-UASIEDKM.js → chunk-LTRUTOHX.js} +36 -31
  103. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  104. package/{chunk-5J3PYNUP.js → chunk-NYYFIKHI.js} +17 -3
  105. package/{chunk-6O4IK4V2.js → chunk-OFFL4DCR.js} +1 -1
  106. package/{chunk-B6SAMB33.js → chunk-OWYYDMGJ.js} +209 -9
  107. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  108. package/{chunk-CTUQJVQM.js → chunk-P5QACQDK.js} +1 -1
  109. package/{chunk-DXHL7G2L.js → chunk-PCKVQXYV.js} +274 -93
  110. package/{chunk-4JMDLJAD.js → chunk-PJNFNEJE.js} +114 -37
  111. package/{chunk-Z4CSIXYP.js → chunk-PLSVXHSA.js} +3 -3
  112. package/{chunk-BIDGLJQ3.js → chunk-PLXDDGBK.js} +45 -8
  113. package/chunk-PWTNI4N7.js +47 -0
  114. package/chunk-QFEW2ULV.js +42 -0
  115. package/{chunk-RGNEEJ3Y.js → chunk-QLQ573SU.js} +35 -9
  116. package/chunk-QQ56R7KS.js +88 -0
  117. package/chunk-QYPE3TS3.js +43 -0
  118. package/{chunk-4DPP773Q.js → chunk-RSHPU4PD.js} +59 -11
  119. package/chunk-RVWMAFIT.js +134 -0
  120. package/{chunk-ESHYE7WU.js → chunk-S73EPYNC.js} +10 -7
  121. package/{chunk-UQNS32WZ.js → chunk-SCMHQUMK.js} +1 -1
  122. package/{chunk-HTVYCXBP.js → chunk-SMENBO3M.js} +354 -120
  123. package/{chunk-OMRJYNCI.js → chunk-SSFDFOVT.js} +26 -31
  124. package/chunk-SW4S4XYB.js +1794 -0
  125. package/{chunk-TB3MIBRC.js → chunk-T6X3D7NB.js} +572 -430
  126. package/chunk-TY3TIUJK.js +89 -0
  127. package/{chunk-X2QRZXZH.js → chunk-TYJ5XFEA.js} +4 -4
  128. package/{chunk-ALFH24P3.js → chunk-TYYRSFBG.js} +197 -155
  129. package/{chunk-7KVZ5LDQ.js → chunk-UBUH2TCC.js} +18 -4
  130. package/chunk-UEILX4EV.js +15 -0
  131. package/chunk-UHTDNB5Y.js +140 -0
  132. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  133. package/{chunk-OHOVNO7I.js → chunk-UOKFKFPO.js} +6 -3
  134. package/{chunk-XISEYOGH.js → chunk-USHQX6VT.js} +5 -5
  135. package/chunk-UUPR3TD7.js +53 -0
  136. package/{chunk-HDLLCBRF.js → chunk-VEA7H5FG.js} +2 -2
  137. package/chunk-VHGD6FHV.js +116 -0
  138. package/chunk-VIWDGTDA.js +8 -0
  139. package/{chunk-GOH6RW6F.js → chunk-VJXHL6MH.js} +34 -11
  140. package/{chunk-4XEYAFLY.js → chunk-VL5KOY2C.js} +623 -94
  141. package/{chunk-EADNWBAZ.js → chunk-VP3BINY7.js} +13 -0
  142. package/{chunk-EOARMOVD.js → chunk-W4S6OTSC.js} +6 -3
  143. package/chunk-WD4XYDYC.js +567 -0
  144. package/chunk-WJZOQR2J.js +151 -0
  145. package/{chunk-AUDNYVRC.js → chunk-XETG4RIX.js} +5 -5
  146. package/{chunk-MX574M24.js → chunk-XI7DGLUK.js} +4 -4
  147. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  148. package/chunk-XRUSXPCQ.js +514 -0
  149. package/{chunk-I4OPU5TK.js → chunk-XS47QOFV.js} +273 -11
  150. package/{chunk-S5XGT6GB.js → chunk-XZNCX52W.js} +30 -9
  151. package/{chunk-ID7LNBWR.js → chunk-Y2DXOPSO.js} +1920 -644
  152. package/{chunk-5OA5HMTL.js → chunk-YLMMECCH.js} +1 -1
  153. package/{chunk-CFT5HBGW.js → chunk-YVLQXTUB.js} +448 -12
  154. package/chunk-YVPQATSC.js +709 -0
  155. package/{chunk-3DAVPNFT.js → chunk-Z7OJUX6S.js} +122 -107
  156. package/chunk-ZEZC7IIM.js +126 -0
  157. package/{chunk-ALGORS6Y.js → chunk-ZF6526IQ.js} +43 -8
  158. package/chunk-ZIWPQEFU.js +165 -0
  159. package/chunk-ZKZ5X2HS.js +7012 -0
  160. package/chunk-ZRAU6T47.js +56 -0
  161. package/{cliExecutor-AWYR3T33.js → cliExecutor-BWBF2MTI.js} +4 -3
  162. package/{clipboardy-BX4NMYHE.js → clipboardy-GCO3GT3I.js} +3 -8
  163. package/{commandRegistry-2KBOXZQC.js → commandRegistry-XN7C5GHO.js} +183 -107
  164. package/contentThunks-5L7YQI3S.js +84 -0
  165. package/{cooldownCommands-ZLEPIB4A.js → cooldownCommands-JFKTYS2D.js} +2 -2
  166. package/{createAgentAutomationAction-5UGTB26P.js → createAgentAutomationAction-QOPOLCRK.js} +53 -44
  167. package/createDialogAction-MZ66VY5Q.js +76 -0
  168. package/{createPageAction-CDLDKPRM.js → createPageAction-VQDJIXMY.js} +65 -54
  169. package/cursorProvider-YGGNMVWX.js +6123 -0
  170. package/{db-VQSAOWAO.js → db-2QOTXYGH.js} +11 -5
  171. package/{dbSlice-DQ32LYTJ.js → dbSlice-J37OGIXH.js} +19 -13
  172. package/{deleteFile-NX6QHCWZ.js → deleteFile-6JWDDRVP.js} +10 -6
  173. package/dialogCommands-YZLSJB6X.js +113 -0
  174. package/{dialogSlice-N3YB65G5.js → dialogSlice-6RODVYCK.js} +53 -39
  175. package/{docCreateCommands-ZSLGVBZT.js → docCreateCommands-JB2RRMRJ.js} +54 -57
  176. package/{docDeleteCommands-5N4GVZBG.js → docDeleteCommands-AQENULNM.js} +56 -58
  177. package/{docReadCommands-YJSAA7AV.js → docReadCommands-DYD25YLQ.js} +53 -56
  178. package/{docStore-E3CEOV5Q.js → docStore-ZZA3OPM5.js} +25 -16
  179. package/{docUpdateCommands-WEMLSW6W.js → docUpdateCommands-3GVS23QL.js} +54 -57
  180. package/{fetchMessages-67MEFPZR.js → fetchMessages-IIJWQ3HR.js} +5 -4
  181. package/{getPricing-NMMFT3YI.js → getPricing-FKK3F5EJ.js} +11 -9
  182. package/{handleSendMessageAction-DQAD5ERJ.js → handleSendMessageAction-DVG5U26T.js} +422 -118
  183. package/index.js +11 -7
  184. package/{lib-FRRS27KN.js → lib-4YTWAGY7.js} +581 -248
  185. package/{localDialogRead-EBRS242U.js → localDialogRead-FSOMOPDZ.js} +2 -2
  186. package/localRuntimeAdapter-HXRHFKRC.js +244 -0
  187. package/localRuntimeAuthority-JDAD7CB6.js +16 -0
  188. package/{localRuntimeDb-3LRMNLCM.js → localRuntimeDb-CVC62PM5.js} +1 -1
  189. package/{machineCommands-HAP75VSG.js → machineCommands-5KBF4RCC.js} +503 -161
  190. package/{machineInfo-66ZFUMLE.js → machineInfo-UKPTZO5Y.js} +2 -2
  191. package/machineWsRunDispatch-4OQDEDOR.js +169 -0
  192. package/{memberThunks-5ZXPR63F.js → memberThunks-66DH6ABQ.js} +25 -18
  193. package/{models-ZPU5EDF4.js → models-LAS4B2B5.js} +2 -2
  194. package/package.json +1 -1
  195. package/{providerPresetApply-DD6NGWW6.js → providerPresetApply-MY66I6NT.js} +10 -10
  196. package/{providerRegistry-XDRLMYGJ.js → providerRegistry-QOE2FT57.js} +13 -9
  197. package/{read-EPTJRAEF.js → read-DC4NUGN6.js} +12 -8
  198. package/{readDocTool-W4NDXNEX.js → readDocTool-NCJ5NT25.js} +1 -1
  199. package/{readlineWorkspace-7BC66QSX.js → readlineWorkspace-RIE62QVZ.js} +5022 -921
  200. package/{removeDialogAgentAction-OSYNZRX7.js → removeDialogAgentAction-E2H3OZU6.js} +29 -28
  201. package/{runAgentClientLoop-6E6UC3CE.js → runAgentClientLoop-KLUUXBZS.js} +154 -97
  202. package/{runtimeDoctorCommands-ID23PNNZ.js → runtimeDoctorCommands-GIOGC5SC.js} +17 -17
  203. package/secretCommands-ZXZRLR3R.js +700 -0
  204. package/setDialogExtraReferencesAction-SITRPMYU.js +37 -0
  205. package/{setPrimaryDialogAgentAction-WZ7KI3YA.js → setPrimaryDialogAgentAction-U7N45TGC.js} +30 -29
  206. package/{chunk-SONWNI3L.js → settingThunks-Y7SVJOMZ.js} +223 -928
  207. package/{skillDiscovery-ZBU76COE.js → skillDiscovery-QC35EQY4.js} +2 -2
  208. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  209. package/{spaceCommands-UJOVU4XI.js → spaceCommands-ZR5BR3GX.js} +59 -59
  210. package/{streamAgentChatTurn-3UXPYFNX.js → streamAgentChatTurn-MN2SSPGA.js} +309 -165
  211. package/{switchDialogAgentAction-GMR7WN3P.js → switchDialogAgentAction-OMGBD3N2.js} +26 -22
  212. package/{tableCommands-G7RV3RU3.js → tableCommands-U3QDY4L6.js} +19 -17
  213. package/{toolApiClient-CVGWM4PN.js → toolApiClient-7WSJJJBV.js} +6 -5
  214. package/tools-W2MOLERY.js +124 -0
  215. package/tuiSummaryLlmCaller-BM3VSTBU.js +130 -0
  216. package/{updateCommands-4EHDLF5J.js → updateCommands-NQXAGFM7.js} +3 -3
  217. package/{updateDialogTitleAction-UPFV7TDT.js → updateDialogTitleAction-Z4JX6REN.js} +102 -57
  218. package/workloadLifecycle-36DXRZKU.js +320 -0
  219. package/action-GI44T4DR.js +0 -31
  220. package/agentListCommands-IW3GQVUP.js +0 -427
  221. package/agentRecordCommands-VCA76W6B.js +0 -134
  222. package/agentRunCommand-YNLDKVR7.js +0 -161
  223. package/browser-image-compression-MFDTD7K6.js +0 -1763
  224. package/chatQueueReduxAdapter-TJRMXMYA.js +0 -186
  225. package/chromeOpsCommands-IXRLN57H.js +0 -289
  226. package/chunk-36KZDDO5.js +0 -2415
  227. package/chunk-ACQD6YI2.js +0 -25363
  228. package/chunk-CQ3WA2NE.js +0 -299
  229. package/chunk-CYSYR67N.js +0 -93
  230. package/chunk-JBTJAPUF.js +0 -35
  231. package/chunk-K2CSUCHJ.js +0 -620
  232. package/chunk-LTRXGFMS.js +0 -83
  233. package/chunk-M76ECQRD.js +0 -13658
  234. package/chunk-MEYIRKDN.js +0 -8967
  235. package/chunk-OCZKATRC.js +0 -129
  236. package/chunk-OTGFTBLI.js +0 -13
  237. package/chunk-PUOC4YRO.js +0 -394
  238. package/chunk-PZZTFEKK.js +0 -34
  239. package/chunk-URMS4XY2.js +0 -10
  240. package/chunk-UV6VISQJ.js +0 -20
  241. package/chunk-VJVNU77E.js +0 -83
  242. package/chunk-XYJSY4KG.js +0 -13807
  243. package/chunk-Y5GCAMGP.js +0 -9
  244. package/chunk-YPREESF4.js +0 -225
  245. package/contentThunks-BDIQRZR6.js +0 -73
  246. package/createDialogAction-B7VGVEVU.js +0 -66
  247. package/dialogCommands-G7YBVAMC.js +0 -102
  248. package/levelLazyShim-GZBKODGI.js +0 -7
  249. package/machineWsRunDispatch-L32G7C4P.js +0 -149
  250. package/serverStoreFactory-YMXDF4NI.js +0 -20
  251. package/setDialogExtraReferencesAction-M32UYNCG.js +0 -30
  252. package/settingSlice-Q6EKL7EQ.js +0 -204
  253. package/syncMapping-N6RGXGBW.js +0 -437
  254. package/tools-MKYDMWA4.js +0 -111
  255. package/tuiSummaryLlmCaller-3YFNHCTW.js +0 -128
  256. package/{chunk-SV5IJK6K.js → chunk-NBTY7YJF.js} +3 -3
  257. package/{chunk-2SYTUTLI.js → chunk-YBNHPX4S.js} +3 -3
  258. package/{offlineMarxistsAgentCommand-HGXZV4XJ.js → offlineMarxistsAgentCommand-2QTHJCHV.js} +4 -4
@@ -5,21 +5,25 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-3DAVPNFT.js";
9
- import {
10
- parseApiError
11
- } from "./chunk-OCZKATRC.js";
8
+ } from "./chunk-Z7OJUX6S.js";
12
9
  import {
10
+ CONFIRMATION_INPUT_KEYS,
13
11
  INVALID_TOOL_ARGS_REPLACEMENT,
14
12
  buildInvalidToolCallSelfHealResult,
15
13
  parseToolCallArguments,
16
14
  performFetchRequest,
17
- sanitizeOutboundMessages
18
- } from "./chunk-YAQJJDC2.js";
15
+ sanitizeOutboundMessages,
16
+ stripModelToolArgs
17
+ } from "./chunk-AOCM7HPT.js";
19
18
  import {
20
19
  findToolExecutor,
21
20
  toolDefinitionsByName
22
- } from "./chunk-ID7LNBWR.js";
21
+ } from "./chunk-Y2DXOPSO.js";
22
+ import {
23
+ classifyApiError,
24
+ classifyGenerationError,
25
+ extractErrorDiagnostics
26
+ } from "./chunk-SMENBO3M.js";
23
27
  import {
24
28
  createSSEParser,
25
29
  createToolRunId,
@@ -28,27 +32,48 @@ import {
28
32
  toolRunSetPending,
29
33
  toolRunStarted,
30
34
  toolRunSucceeded
31
- } from "./chunk-ATLTFRYJ.js";
35
+ } from "./chunk-ES633ZS5.js";
32
36
  import {
33
- getCurrentSpaceId
34
- } from "./chunk-ZJ7UHBJS.js";
37
+ getPublicImageAgentMode
38
+ } from "./chunk-VIDPVFP3.js";
35
39
  import {
36
40
  addToolMessage,
37
41
  messageStreamEnd,
38
42
  messageStreaming,
43
+ toolResultNeedsUserConfirmation,
39
44
  updateToolMessage
40
- } from "./chunk-ACQD6YI2.js";
45
+ } from "./chunk-556RW72X.js";
41
46
  import {
42
47
  streamAgentChatTurn
43
- } from "./chunk-TZZ2WRBL.js";
48
+ } from "./chunk-IZ7OJB6K.js";
49
+ import {
50
+ getCurrentSpaceId
51
+ } from "./chunk-ZJ7UHBJS.js";
44
52
  import {
45
53
  addActiveController,
46
54
  removeActiveController,
47
55
  tokenUsageLiveUpdate
48
- } from "./chunk-B6SAMB33.js";
56
+ } from "./chunk-OWYYDMGJ.js";
49
57
  import {
50
- getPublicImageAgentMode
51
- } from "./chunk-VIDPVFP3.js";
58
+ selectCurrentServer
59
+ } from "./chunk-QFEW2ULV.js";
60
+ import {
61
+ write
62
+ } from "./chunk-74RAWNQN.js";
63
+ import {
64
+ createAsyncThunk
65
+ } from "./chunk-IJERIUXS.js";
66
+ import {
67
+ selectIdentityToken
68
+ } from "./chunk-SEJ5OS6F.js";
69
+ import {
70
+ classifyOutboundErrorCategory,
71
+ createOutboundDiagnosticCall,
72
+ deriveRequestFactsFromBody,
73
+ projectUserPartForModel,
74
+ resolveOutboundDiagnosticSink,
75
+ resolveOutboundWire
76
+ } from "./chunk-G6OOUQWJ.js";
52
77
  import {
53
78
  accumulateToolCallDelta,
54
79
  createThinkParserState,
@@ -57,46 +82,39 @@ import {
57
82
  flushToolCallTextParserIntoCallback,
58
83
  processContentChunkWithToolCallStripping,
59
84
  processThinkChunk
60
- } from "./chunk-N7J63Q6C.js";
85
+ } from "./chunk-56GBUMO5.js";
61
86
  import {
62
- EMPTY_ASSISTANT_REPAIR_PROMPT,
63
- getModelInfo
64
- } from "./chunk-AKG5W4LG.js";
87
+ normalizeChatCompletionsBodyForProvider
88
+ } from "./chunk-3SZA4U64.js";
65
89
  import {
66
- toErrorMessage
67
- } from "./chunk-HNMXYYJR.js";
90
+ EMPTY_ASSISTANT_REPAIR_PROMPT
91
+ } from "./chunk-6CCFTVBP.js";
68
92
  import {
69
- getApiEndpoint
70
- } from "./chunk-3BXNTXYI.js";
93
+ getModelInfo
94
+ } from "./chunk-BPMPOFWP.js";
71
95
  import {
72
- selectCurrentServer
73
- } from "./chunk-SONWNI3L.js";
96
+ isAbortError
97
+ } from "./chunk-7DPNBQSV.js";
74
98
  import {
75
- write
76
- } from "./chunk-HYZIYH2H.js";
99
+ extractCustomId
100
+ } from "./chunk-M2EJHDJP.js";
77
101
  import {
78
102
  createDialogMessageKeyAndId,
79
103
  dialogMessageKey,
80
104
  toTrimmedString
81
- } from "./chunk-3AH7LNUB.js";
105
+ } from "./chunk-5EMSBTQ6.js";
82
106
  import {
83
- createAsyncThunk
84
- } from "./chunk-WIWM4FE3.js";
85
- import {
86
- isAbortError
87
- } from "./chunk-QOKAKDPE.js";
88
- import {
89
- selectIdentityToken
90
- } from "./chunk-SEJ5OS6F.js";
107
+ getApiEndpoint
108
+ } from "./chunk-I4SN4NUQ.js";
91
109
  import {
92
110
  isRecord
93
111
  } from "./chunk-KUG52IAP.js";
94
- import {
95
- extractCustomId
96
- } from "./chunk-M2EJHDJP.js";
97
112
  import {
98
113
  asTrimmedString
99
114
  } from "./chunk-3EUW3WEO.js";
115
+ import {
116
+ toErrorMessage
117
+ } from "./chunk-HNMXYYJR.js";
100
118
  import {
101
119
  asOptionalTrimmedString
102
120
  } from "./chunk-G3SUCT4W.js";
@@ -123,11 +141,12 @@ var extractContent = (msg) => {
123
141
  }
124
142
  if (typeof msg.content === "string") return msg.content;
125
143
  if (Array.isArray(msg.content)) {
126
- const parts = msg.content.filter(isValidMessagePart);
144
+ const parts = msg.role === "user" ? msg.content.flatMap((part) => projectUserPartForModel(part)) : msg.content.filter(isValidMessagePart);
127
145
  return parts.length > 0 ? parts : null;
128
146
  }
129
- if (msg.content && typeof msg.content === "object" && isValidMessagePart(msg.content)) {
130
- return [msg.content];
147
+ if (msg.content && typeof msg.content === "object") {
148
+ const projected = msg.role === "user" ? projectUserPartForModel(msg.content) : isValidMessagePart(msg.content) ? [msg.content] : [];
149
+ return projected.length ? projected : null;
131
150
  }
132
151
  return null;
133
152
  };
@@ -280,7 +299,7 @@ async function persistToolMessage(dispatch, message, options = {}) {
280
299
  }
281
300
  throw err;
282
301
  }
283
- const { controller: _controller, ...rest } = message;
302
+ const { controller: _controller, dialogId: _dialogId, ...rest } = message;
284
303
  const isStreaming = options.isStreaming !== void 0 ? options.isStreaming : Boolean(rest.isStreaming);
285
304
  try {
286
305
  const writeRequest = dispatch(
@@ -419,6 +438,23 @@ var defaultSummary = (toolName, status) => {
419
438
  if (status === "failed") return `\u274C ${toolName} \u6267\u884C\u5931\u8D25`;
420
439
  return `\u2705 ${toolName} \u6267\u884C\u5B8C\u6210`;
421
440
  };
441
+ var RAW_DATA_FALLBACK_MAX_TOTAL_BYTES = 4e3;
442
+ var RAW_DATA_FALLBACK_MAX_HEAD_BYTES = 1e3;
443
+ var RAW_DATA_FALLBACK_MAX_TAIL_BYTES = 2500;
444
+ var buildRawDataLlmContextFallback = (rawData, toolCallId) => {
445
+ const serialized = typeof rawData === "string" ? rawData.trim() : rawData === void 0 ? "" : JSON.stringify(rawData);
446
+ if (!serialized) return void 0;
447
+ const clipped = clipHeadAndTail(serialized, {
448
+ maxHeadBytes: RAW_DATA_FALLBACK_MAX_HEAD_BYTES,
449
+ maxTailBytes: RAW_DATA_FALLBACK_MAX_TAIL_BYTES,
450
+ maxTotalBytes: RAW_DATA_FALLBACK_MAX_TOTAL_BYTES,
451
+ // 完整 rawData 已随 tool message content 原样落盘,无需另写临时日志;
452
+ // 浏览器 stub 本就忽略该选项。
453
+ saveTempLog: false,
454
+ ...toolCallId ? { toolCallId } : {}
455
+ });
456
+ return asOptionalTrimmedString(clipped.content);
457
+ };
422
458
  var processToolData = createAsyncThunk(
423
459
  "message/processToolData",
424
460
  async (args, thunkApi) => {
@@ -451,7 +487,8 @@ var processToolData = createAsyncThunk(
451
487
  }
452
488
  }
453
489
  const activity = isRecord(toolArgs) && isRecord(toolArgs._activity) ? toolArgs._activity : void 0;
454
- const executionToolArgs = isRecord(toolArgs) && Object.prototype.hasOwnProperty.call(toolArgs, "_activity") ? (({ _activity: _ignored, ...rest }) => rest)(toolArgs) : toolArgs;
490
+ const withoutActivity = isRecord(toolArgs) && Object.prototype.hasOwnProperty.call(toolArgs, "_activity") ? (({ _activity: _ignored, ...rest }) => rest)(toolArgs) : toolArgs;
491
+ const executionToolArgs = stripModelToolArgs(canonicalName, withoutActivity);
455
492
  const inputSummary = JSON.stringify(executionToolArgs).slice(0, 400);
456
493
  toolRunStarted({
457
494
  id: toolRunId,
@@ -478,6 +515,7 @@ var processToolData = createAsyncThunk(
478
515
  const toolPayload = {
479
516
  toolName: canonicalName,
480
517
  status: "pending",
518
+ interaction,
481
519
  input: executionToolArgs,
482
520
  rawToolCall: toolCall,
483
521
  toolRunId,
@@ -539,19 +577,28 @@ var processToolData = createAsyncThunk(
539
577
  });
540
578
  const rawData = toolResult?.rawData ?? toolResult;
541
579
  const llmContext = asOptionalTrimmedString(toolResult?.llmContext);
542
- const summary = asOptionalTrimmedString(toolResult?.displayData) || defaultSummary(canonicalName, "succeeded");
543
- toolRunSucceeded({
544
- id: toolRunId,
545
- outputSummary: summary
546
- });
580
+ const displayData = asOptionalTrimmedString(toolResult?.displayData);
581
+ const awaitingUserConfirmation = toolResultNeedsUserConfirmation(canonicalName, rawData);
582
+ const summary = displayData || defaultSummary(canonicalName, awaitingUserConfirmation ? "pending" : "succeeded");
583
+ const llmContextFallback = llmContext || displayData || awaitingUserConfirmation ? void 0 : buildRawDataLlmContextFallback(rawData, toolCallId);
584
+ const effectiveLlmContext = llmContext ?? llmContextFallback;
585
+ if (!awaitingUserConfirmation) {
586
+ toolRunSucceeded({
587
+ id: toolRunId,
588
+ outputSummary: summary
589
+ });
590
+ } else {
591
+ toolRunSetPending({ id: toolRunId });
592
+ }
547
593
  const toolPayload = {
548
594
  toolName: canonicalName,
549
- status: "succeeded",
595
+ status: awaitingUserConfirmation ? "pending" : "succeeded",
596
+ interaction,
550
597
  input: executionToolArgs,
551
598
  rawToolCall: toolCall,
552
599
  toolRunId,
553
600
  summary,
554
- ...llmContext ? { llmContext } : {},
601
+ ...effectiveLlmContext ? { llmContext: effectiveLlmContext } : {},
555
602
  ...activity ? { activity } : {}
556
603
  };
557
604
  const isUiAskChoice = canonicalName === "ask_user";
@@ -569,11 +616,11 @@ var processToolData = createAsyncThunk(
569
616
  } catch (e) {
570
617
  const errorMessage = toErrorMessage(e);
571
618
  const structured = getToolResultErrorData(e);
572
- const requiresConfirmation = structured?.code === "self_evolution_requires_confirmation" || structured?.code === "agent_update_requires_confirmation";
573
- if (requiresConfirmation) {
619
+ const confirmationKey = structured?.code ? CONFIRMATION_INPUT_KEYS[structured.code] : void 0;
620
+ if (confirmationKey) {
574
621
  const confirmedInput = {
575
622
  ...executionToolArgs ?? {},
576
- __confirmedSelfEvolution: true
623
+ [confirmationKey]: true
577
624
  };
578
625
  const summary2 = typeof structured?.displayData === "string" && structured.displayData.trim() || `\u26A0\uFE0F ${canonicalName} \u9700\u8981\u786E\u8BA4\u540E\u6267\u884C`;
579
626
  toolRunStarted({
@@ -589,6 +636,7 @@ var processToolData = createAsyncThunk(
589
636
  const toolPayload2 = {
590
637
  toolName: canonicalName,
591
638
  status: "pending",
639
+ interaction: "confirm",
592
640
  input: confirmedInput,
593
641
  rawToolCall: toolCall,
594
642
  toolRunId,
@@ -597,7 +645,11 @@ var processToolData = createAsyncThunk(
597
645
  };
598
646
  return {
599
647
  toolCallId,
600
- rawResult: structured?.rawData !== void 0 ? structured.rawData : { error: "self_evolution_requires_confirmation" },
648
+ rawResult: structured?.rawData !== void 0 ? structured.rawData : (
649
+ // 按实际确认码回填(此分支内 code 必在 CONFIRMATION_INPUT_KEYS 中),
650
+ // 不再对所有工具写死 self_evolution 文案。
651
+ { error: structured?.code }
652
+ ),
601
653
  summary: summary2,
602
654
  toolName: canonicalName,
603
655
  toolRunId,
@@ -666,6 +718,9 @@ var handleToolCalls = createAsyncThunk(
666
718
  const runningToolMessage = {
667
719
  id: runningToolMessageId,
668
720
  dbKey: runningToolDbKey,
721
+ // Explicit identity: tool results belong to the run's dialog, and the
722
+ // message-key parse is ambiguous once a message id contains "-msg-".
723
+ dialogId,
669
724
  role: "tool",
670
725
  content: JSON.stringify({ pending: true }),
671
726
  toolCallId,
@@ -869,8 +924,8 @@ async function readStreamChunk(reader, options) {
869
924
 
870
925
  // packages/ai/agent/utils/imageOutput.ts
871
926
  var LEGACY_IMAGE_MODELS = /* @__PURE__ */ new Set([
872
- "google/gemini-3-pro-image-preview",
873
- "google/gemini-3.1-flash-image-preview"
927
+ "google/gemini-3-pro-image",
928
+ "google/gemini-nano-banana-2.1"
874
929
  ]);
875
930
  function supportsImageGeneration(agent) {
876
931
  if (agent.hasImageOutput === true) return true;
@@ -916,8 +971,6 @@ function getStreamErrorMessage(data) {
916
971
  if (message) return message;
917
972
  const code = asOptionalTrimmedString(data?.error?.code) ?? asOptionalTrimmedString(data?.code);
918
973
  if (code) return code;
919
- const type = asOptionalTrimmedString(data?.error?.type);
920
- if (type) return type;
921
974
  return "Unknown error";
922
975
  }
923
976
  function formatStreamErrorMessage(data) {
@@ -1017,11 +1070,7 @@ function buildRequestBodyWithTools(bodyData, agentConfig, disableToolsForThisReq
1017
1070
  }
1018
1071
  const tools = prepareTools(rawTools, { provider: agentConfig.provider });
1019
1072
  if (!tools.length) return baseBody;
1020
- return {
1021
- ...baseBody,
1022
- tools,
1023
- tool_choice: baseBody.tool_choice ?? "auto"
1024
- };
1073
+ return { ...baseBody, tools, tool_choice: baseBody.tool_choice ?? "auto" };
1025
1074
  }
1026
1075
  async function finalizeStream(state, ctx) {
1027
1076
  if (state.hasHandedOff || state.alreadyFinalized) return state;
@@ -1068,7 +1117,7 @@ async function finalizeStream(state, ctx) {
1068
1117
  alreadyFinalized: true
1069
1118
  };
1070
1119
  }
1071
- var EMPTY_UPSTREAM_STREAM_MESSAGE = "\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94\uFF0C\u8BF7\u91CD\u8BD5\u6216\u5207\u6362\u5176\u4ED6\u6A21\u578B";
1120
+ var EMPTY_UPSTREAM_STREAM_MESSAGE = "\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u68C0\u67E5\u670D\u52A1\u54CD\u5E94\u3002";
1072
1121
  function markEmptyCompletionAsError(state, ctx) {
1073
1122
  const producedNothing = state.contentBuffer.length === 0 && !state.reasoningBuffer.trim() && (state.assistantToolCalls?.length ?? 0) === 0;
1074
1123
  if (!producedNothing || state.hasHandedOff || state.alreadyFinalized) {
@@ -1084,13 +1133,20 @@ function markEmptyCompletionAsError(state, ctx) {
1084
1133
  billingFailed: true
1085
1134
  };
1086
1135
  }
1087
- function markStreamMessageAborted(ctx, errorMessage) {
1136
+ function markStreamMessageAborted(ctx, errorMessage, classification = classifyGenerationError(errorMessage)) {
1088
1137
  const base = ctx.messageMetadata ?? {};
1089
1138
  const previousMetadata = base.metadata && typeof base.metadata === "object" ? base.metadata : {};
1090
1139
  ctx.messageMetadata = {
1091
1140
  ...base,
1141
+ errorMeta: {
1142
+ kind: classification.category,
1143
+ summary: classification.message,
1144
+ retryable: classification.retryable,
1145
+ actions: classification.actions
1146
+ },
1092
1147
  metadata: {
1093
1148
  ...previousMetadata,
1149
+ providerError: { category: classification.category, ...classification.diagnostic },
1094
1150
  error: true,
1095
1151
  message: errorMessage
1096
1152
  }
@@ -1120,6 +1176,8 @@ function applyDelta(state, delta) {
1120
1176
  ...next,
1121
1177
  accumulatedToolCalls: accumulated,
1122
1178
  assistantToolCalls: accumulated.map((call) => ({
1179
+ ...call.thought_signature !== void 0 ? { thought_signature: call.thought_signature } : {},
1180
+ ...call.extra_content ? { extra_content: call.extra_content } : {},
1123
1181
  id: call.id,
1124
1182
  type: "function",
1125
1183
  function: {
@@ -1265,6 +1323,8 @@ function syncAssistantToolCallsAfterSanitize(state, invalidCalls) {
1265
1323
  if (call?.id) invalidById.set(call.id, call);
1266
1324
  }
1267
1325
  const base = Array.isArray(state.assistantToolCalls) ? state.assistantToolCalls : state.accumulatedToolCalls.map((call) => ({
1326
+ ...call.thought_signature !== void 0 ? { thought_signature: call.thought_signature } : {},
1327
+ ...call.extra_content ? { extra_content: call.extra_content } : {},
1268
1328
  id: call.id,
1269
1329
  type: "function",
1270
1330
  function: {
@@ -1298,6 +1358,7 @@ async function persistInvalidToolCallResults(invalidCalls, ctx, startIndex) {
1298
1358
  const toolMessage = {
1299
1359
  id: runningToolMessageId,
1300
1360
  dbKey: runningToolDbKey,
1361
+ dialogId: ctx.dialogId,
1301
1362
  role: "tool",
1302
1363
  content: selfHealContent,
1303
1364
  toolCallId: callId,
@@ -1451,7 +1512,8 @@ var sendOpenAICompletionsRequest = async ({
1451
1512
  messageMetadata,
1452
1513
  disableToolsForThisRequest = false,
1453
1514
  quickChatPerfStartedAt,
1454
- streamThrottlerOptions
1515
+ streamThrottlerOptions,
1516
+ outboundDiagnostics
1455
1517
  }) => {
1456
1518
  const { dispatch, getState, signal: thunkSignal } = thunkApi;
1457
1519
  const dialogId = extractCustomId(dialogKey);
@@ -1471,11 +1533,11 @@ var sendOpenAICompletionsRequest = async ({
1471
1533
  }
1472
1534
  dispatch(addActiveController({ messageId, controller, dialogKey }));
1473
1535
  const requestBody = await inlineImageUrlsForCustomProvider(
1474
- buildRequestBodyWithTools(
1475
- bodyData,
1476
- agentConfig,
1477
- disableToolsForThisRequest
1478
- ),
1536
+ normalizeChatCompletionsBodyForProvider({
1537
+ body: buildRequestBodyWithTools(bodyData, agentConfig, disableToolsForThisRequest),
1538
+ provider: agentConfig.provider ?? "",
1539
+ model: agentConfig.model
1540
+ }),
1479
1541
  {
1480
1542
  shouldInline: shouldInlineImageUrlsForAgent(agentConfig)
1481
1543
  }
@@ -1517,6 +1579,31 @@ var sendOpenAICompletionsRequest = async ({
1517
1579
  usage: streamState.totalUsage ?? void 0,
1518
1580
  billingFailed: streamState.billingFailed
1519
1581
  });
1582
+ const diagnosticSink = resolveOutboundDiagnosticSink(outboundDiagnostics);
1583
+ let diagnosticCall;
1584
+ let diagnosticOutcome = "completed";
1585
+ let diagnosticStreamStarted = false;
1586
+ let diagnosticAttemptCount = 0;
1587
+ let diagnosticCurrentAttempt = 0;
1588
+ let diagnosticCurrentAttemptClosed = false;
1589
+ const beginDiagnosticAttempt = (attemptBody) => {
1590
+ if (!diagnosticCall) return 0;
1591
+ diagnosticAttemptCount += 1;
1592
+ diagnosticCurrentAttempt = diagnosticAttemptCount;
1593
+ diagnosticCurrentAttemptClosed = false;
1594
+ diagnosticStreamStarted = false;
1595
+ diagnosticOutcome = "completed";
1596
+ diagnosticCall.dispatch(
1597
+ diagnosticCurrentAttempt,
1598
+ deriveRequestFactsFromBody(attemptBody)
1599
+ );
1600
+ return diagnosticCurrentAttempt;
1601
+ };
1602
+ const closeDiagnosticAttempt = (attempt, outcome) => {
1603
+ if (!diagnosticCall || attempt <= 0) return;
1604
+ diagnosticCall.terminal(attempt, outcome);
1605
+ if (attempt === diagnosticCurrentAttempt) diagnosticCurrentAttemptClosed = true;
1606
+ };
1520
1607
  try {
1521
1608
  if (!parentMessageId) {
1522
1609
  dispatch(
@@ -1535,6 +1622,18 @@ var sendOpenAICompletionsRequest = async ({
1535
1622
  );
1536
1623
  }
1537
1624
  const api = getApiEndpoint(agentConfig);
1625
+ diagnosticCall = diagnosticSink ? createOutboundDiagnosticCall({
1626
+ sink: diagnosticSink,
1627
+ seam: "chat",
1628
+ host: outboundDiagnostics?.host ?? "client",
1629
+ wire: resolveOutboundWire(api),
1630
+ provider: agentConfig?.provider,
1631
+ model: agentConfig?.model,
1632
+ callId: outboundDiagnostics?.callId
1633
+ }) : void 0;
1634
+ if (diagnosticCall) {
1635
+ beginDiagnosticAttempt(requestBody);
1636
+ }
1538
1637
  const token = selectIdentityToken(getState()) ?? "";
1539
1638
  logQuickChatPerfStage(quickChatPerfStartedAt, "openai-completions-fetch-starting", {
1540
1639
  api,
@@ -1592,7 +1691,47 @@ var sendOpenAICompletionsRequest = async ({
1592
1691
  );
1593
1692
  }
1594
1693
  if (!response.ok) {
1595
- const errorMessage = await parseApiError(response);
1694
+ const rawBody = await response.text();
1695
+ let errorData;
1696
+ try {
1697
+ errorData = JSON.parse(rawBody);
1698
+ } catch {
1699
+ errorData = { message: rawBody };
1700
+ }
1701
+ diagnosticOutcome = "http-error";
1702
+ diagnosticCall?.httpResult(diagnosticCurrentAttempt, {
1703
+ status: response.status,
1704
+ headers: response.headers,
1705
+ errorCategory: classifyOutboundErrorCategory(response.status, rawBody)
1706
+ });
1707
+ const errorJson = errorData?.error ?? errorData;
1708
+ const apiErrorMessage = errorJson?.message || errorJson?.msg || (typeof rawBody === "string" ? rawBody : "") || `\u72B6\u6001\u7801 ${response.status} ${response.statusText}`;
1709
+ const apiErrorCode = errorJson?.code || `E${response.status}`;
1710
+ const legacyClassified = classifyApiError({
1711
+ status: response.status,
1712
+ statusText: response.statusText,
1713
+ message: apiErrorMessage,
1714
+ body: rawBody,
1715
+ code: apiErrorCode
1716
+ });
1717
+ let classified;
1718
+ if (legacyClassified.kind === "context_overflow" || legacyClassified.kind === "context_too_large" || legacyClassified.kind === "auth" || legacyClassified.code === "MISSING_PROVIDER_API_KEY") {
1719
+ classified = {
1720
+ category: legacyClassified.kind,
1721
+ message: legacyClassified.message,
1722
+ retryable: legacyClassified.retryable ?? false,
1723
+ actions: legacyClassified.actions ?? [],
1724
+ diagnostic: {
1725
+ ...legacyClassified.code ? { code: legacyClassified.code } : {},
1726
+ status: response.status
1727
+ }
1728
+ };
1729
+ } else {
1730
+ classified = classifyGenerationError(errorData, response.status);
1731
+ }
1732
+ classified.diagnostic = { ...classified.diagnostic, ...extractErrorDiagnostics(errorData, response.status) };
1733
+ const errorMessage = classified.message;
1734
+ markStreamMessageAborted(finalizeCtx, errorMessage, classified);
1596
1735
  streamState = {
1597
1736
  ...streamState,
1598
1737
  contentBuffer: appendTextChunk(
@@ -1604,8 +1743,14 @@ var sendOpenAICompletionsRequest = async ({
1604
1743
  streamState = await finalizeStream(streamState, finalizeCtx);
1605
1744
  return buildMeta();
1606
1745
  }
1746
+ diagnosticStreamStarted = true;
1747
+ diagnosticCall?.httpResult(diagnosticCurrentAttempt, {
1748
+ status: response.status,
1749
+ headers: response.headers
1750
+ });
1607
1751
  reader = response.body?.getReader();
1608
1752
  if (!reader) {
1753
+ diagnosticOutcome = "stream-error";
1609
1754
  streamState = markEmptyCompletionAsError(streamState, finalizeCtx);
1610
1755
  streamState = await finalizeStream(streamState, finalizeCtx);
1611
1756
  return buildMeta();
@@ -1621,22 +1766,31 @@ var sendOpenAICompletionsRequest = async ({
1621
1766
  const producedNothing = streamState.contentBuffer.length === 0 && !streamState.reasoningBuffer.trim() && (streamState.assistantToolCalls?.length ?? 0) === 0;
1622
1767
  if (producedNothing && !emptyCompletionRetryUsed && !streamState.hasHandedOff && !streamState.alreadyFinalized && !signal.aborted) {
1623
1768
  emptyCompletionRetryUsed = true;
1769
+ closeDiagnosticAttempt(diagnosticCurrentAttempt, "stream-error");
1770
+ const repairRequestBody = {
1771
+ ...requestBody,
1772
+ messages: [
1773
+ ...requestBody.messages ?? [],
1774
+ { role: "user", content: EMPTY_ASSISTANT_REPAIR_PROMPT }
1775
+ ]
1776
+ };
1777
+ const repairAttempt = beginDiagnosticAttempt(repairRequestBody);
1624
1778
  const retryResponse = await performFetchRequest({
1625
1779
  agentConfig,
1626
1780
  api,
1627
- bodyData: {
1628
- ...requestBody,
1629
- messages: [
1630
- ...requestBody.messages ?? [],
1631
- { role: "user", content: EMPTY_ASSISTANT_REPAIR_PROMPT }
1632
- ]
1633
- },
1781
+ bodyData: repairRequestBody,
1634
1782
  currentServer: selectCurrentServer(getState()),
1635
1783
  signal,
1636
1784
  token,
1637
1785
  dialogId
1638
1786
  });
1787
+ diagnosticCall?.httpResult(repairAttempt, {
1788
+ status: retryResponse.status,
1789
+ headers: retryResponse.headers,
1790
+ ...retryResponse.ok ? {} : { errorCategory: classifyOutboundErrorCategory(retryResponse.status) }
1791
+ });
1639
1792
  if (retryResponse.ok && retryResponse.body) {
1793
+ diagnosticStreamStarted = true;
1640
1794
  throttler.cancel();
1641
1795
  streamState = createInitialStreamState();
1642
1796
  parseSSE = createSSEParser();
@@ -1644,6 +1798,9 @@ var sendOpenAICompletionsRequest = async ({
1644
1798
  reader = retryResponse.body.getReader();
1645
1799
  continue;
1646
1800
  }
1801
+ diagnosticOutcome = retryResponse.ok ? "stream-error" : "http-error";
1802
+ } else if (producedNothing && !signal.aborted && !streamState.hasHandedOff && !streamState.alreadyFinalized) {
1803
+ diagnosticOutcome = "stream-error";
1647
1804
  }
1648
1805
  const completion = await handleStreamCompletion(
1649
1806
  streamState,
@@ -1688,7 +1845,10 @@ var sendOpenAICompletionsRequest = async ({
1688
1845
  }
1689
1846
  if (data.error) {
1690
1847
  throttler.flush();
1691
- const errorMsg = `Error: ${formatStreamErrorMessage(data)}`;
1848
+ diagnosticOutcome = "stream-error";
1849
+ const classified = classifyGenerationError(data);
1850
+ markStreamMessageAborted(finalizeCtx, classified.message, classified);
1851
+ const errorMsg = classified.message;
1692
1852
  streamState = {
1693
1853
  ...streamState,
1694
1854
  contentBuffer: appendTextChunk(
@@ -1730,17 +1890,33 @@ var sendOpenAICompletionsRequest = async ({
1730
1890
  if (finishReason === "tool_calls") {
1731
1891
  throttler.flush();
1732
1892
  } else if (finishReason !== "stop") {
1733
- const finishErrorMessage = finishReason === "error" ? getChoiceFinishErrorMessage(data, choice) : null;
1734
- streamState = {
1735
- ...streamState,
1736
- contentBuffer: appendTextChunk(
1737
- streamState.contentBuffer,
1738
- finishErrorMessage ? `
1739
- [API Error] Error: ${finishErrorMessage}` : finishReason === "error" ? "\n[API Error] Error: \u6A21\u578B\u54CD\u5E94\u4EE5 error \u7ED3\u675F\uFF0C\u4F46\u4E0A\u6E38\u672A\u8FD4\u56DE\u5177\u4F53\u9519\u8BEF\u3002\u8BF7\u91CD\u8BD5\uFF0C\u6216\u5207\u6362\u5230\u5176\u4ED6\u652F\u6301\u56FE\u7247\u8F93\u5165\u7684\u6A21\u578B\u3002" : `
1893
+ if (finishReason === "error") {
1894
+ const finishErrorMessage = getChoiceFinishErrorMessage(data, choice);
1895
+ const errorText = finishErrorMessage ? `[API Error] Error: ${finishErrorMessage}` : "[API Error] Error: \u6A21\u578B\u54CD\u5E94\u4EE5 error \u7ED3\u675F\uFF0C\u4F46\u4E0A\u6E38\u672A\u8FD4\u56DE\u5177\u4F53\u9519\u8BEF\u3002\u8BF7\u91CD\u8BD5\uFF0C\u6216\u5207\u6362\u5230\u5176\u4ED6\u652F\u6301\u56FE\u7247\u8F93\u5165\u7684\u6A21\u578B\u3002";
1896
+ const classified = classifyGenerationError(
1897
+ choice.error ? choice : data.error ? data : { code: "UPSTREAM_FINISH_ERROR" }
1898
+ );
1899
+ markStreamMessageAborted(finalizeCtx, errorText, classified);
1900
+ diagnosticOutcome = "stream-error";
1901
+ streamState = {
1902
+ ...streamState,
1903
+ contentBuffer: appendTextChunk(
1904
+ streamState.contentBuffer,
1905
+ `
1906
+ ${errorText}`
1907
+ ),
1908
+ billingFailed: true
1909
+ };
1910
+ } else {
1911
+ streamState = {
1912
+ ...streamState,
1913
+ contentBuffer: appendTextChunk(
1914
+ streamState.contentBuffer,
1915
+ `
1740
1916
  [\u6D41\u7ED3\u675F\u539F\u56E0: ${finishReason}]`
1741
- ),
1742
- ...finishReason === "error" ? { billingFailed: true } : {}
1743
- };
1917
+ )
1918
+ };
1919
+ }
1744
1920
  }
1745
1921
  }
1746
1922
  }
@@ -1750,12 +1926,13 @@ var sendOpenAICompletionsRequest = async ({
1750
1926
  throttler.flush();
1751
1927
  let errorText;
1752
1928
  const isAbort = isAbortError(error);
1929
+ diagnosticOutcome = isAbort ? "aborted" : diagnosticStreamStarted ? "stream-error" : "network-error";
1753
1930
  const skipBilling = shouldSkipBillingForUserAbort(error, streamState.totalUsage);
1754
1931
  if (isAbort) {
1755
1932
  errorText = "\n[\u7528\u6237\u4E2D\u65AD]";
1756
1933
  } else {
1757
1934
  errorText = `
1758
- [\u9519\u8BEF: ${toErrorMessage(error)}]`;
1935
+ [\u9519\u8BEF: ${classifyGenerationError(toErrorMessage(error)).message}]`;
1759
1936
  }
1760
1937
  console.error("[SSE] sendOpenAICompletionsRequest error:", error);
1761
1938
  streamState = {
@@ -1767,7 +1944,8 @@ var sendOpenAICompletionsRequest = async ({
1767
1944
  if (!isAbort) {
1768
1945
  markStreamMessageAborted(
1769
1946
  finalizeCtx,
1770
- toErrorMessage(error)
1947
+ classifyGenerationError(toErrorMessage(error)).message,
1948
+ classifyGenerationError(toErrorMessage(error))
1771
1949
  );
1772
1950
  }
1773
1951
  streamState = await finalizeStream(streamState, finalizeCtx);
@@ -1781,6 +1959,9 @@ var sendOpenAICompletionsRequest = async ({
1781
1959
  await reader?.cancel();
1782
1960
  } catch (_e) {
1783
1961
  }
1962
+ if (diagnosticCall && diagnosticCurrentAttempt > 0 && !diagnosticCurrentAttemptClosed) {
1963
+ closeDiagnosticAttempt(diagnosticCurrentAttempt, diagnosticOutcome);
1964
+ }
1784
1965
  }
1785
1966
  return buildMeta();
1786
1967
  };