@qwen-code/qwen-code 0.21.12-preview.5 → 0.21.13

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 (347) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +7 -5
  2. package/bundled/qc-helper/docs/features/channels/overview.md +1 -1
  3. package/bundled/qc-helper/docs/features/channels/plugins.md +11 -11
  4. package/bundled/qc-helper/docs/features/code-review.md +13 -12
  5. package/bundled/qc-helper/docs/qwen-serve.md +65 -0
  6. package/bundled/review/SKILL.md +96 -68
  7. package/chunks/{MaxSizedBox-6STELMXN.js → MaxSizedBox-UQALOVVT.js} +46 -46
  8. package/chunks/{StandaloneSessionPicker-LXMGCAIF.js → StandaloneSessionPicker-KEGXNUG6.js} +68 -69
  9. package/chunks/{acp-startup-profiler-TVI2OVUN.js → acp-startup-profiler-NMDXYGDN.js} +2 -2
  10. package/chunks/{acpAgent-NFRP4O5A.js → acpAgent-XPES32S7.js} +804 -380
  11. package/chunks/{agent-4AGYD6I6.js → agent-DPTOZFEM.js} +42 -42
  12. package/chunks/{agent-headless-GH4UIDXU.js → agent-headless-GJCQMURW.js} +42 -42
  13. package/chunks/{anthropicContentGenerator-ZBBX5VMY.js → anthropicContentGenerator-G7BVXTKN.js} +25 -25
  14. package/chunks/{artifact-tool-RWJAKYBZ.js → artifact-tool-GEXTOPVO.js} +5 -5
  15. package/chunks/{askUserQuestion-IQCA2SOX.js → askUserQuestion-B33XRSB7.js} +2 -2
  16. package/chunks/{bridge-3S4SKXSQ.js → bridge-YNQBAA4Z.js} +48 -48
  17. package/chunks/{build-RZS65IIX.js → build-GDBLPA24.js} +1 -1
  18. package/chunks/{channel-management-service-5ZYX4ROW.js → channel-management-service-GWY2GAIC.js} +4 -4
  19. package/chunks/{channel-settings-store-62E3TWVK.js → channel-settings-store-WNWYFHG7.js} +49 -49
  20. package/chunks/{channel-worker-group-QFJKXO7R.js → channel-worker-group-7LXCMZ77.js} +6 -6
  21. package/chunks/{channel-worker-manager-PWD2UURZ.js → channel-worker-manager-RYEME4ZZ.js} +6 -6
  22. package/chunks/{channel-worker-supervisor-XQJBGFCM.js → channel-worker-supervisor-OEVWBHGT.js} +4 -4
  23. package/chunks/{chunk-LHOG4E6Y.js → chunk-22C7BQ6D.js} +3 -3
  24. package/chunks/{chunk-KTWUFHS4.js → chunk-25EYDK42.js} +3 -3
  25. package/chunks/{chunk-QEWAHAW2.js → chunk-2B2BF7P7.js} +3 -3
  26. package/chunks/{chunk-2SB4SLKC.js → chunk-2IIJTXYF.js} +1 -3
  27. package/chunks/{chunk-6LDLDK6E.js → chunk-2M55OBEB.js} +1 -3
  28. package/chunks/{chunk-V3NMFQD2.js → chunk-3EZLLVDF.js} +2 -2
  29. package/chunks/{chunk-HUDUANHL.js → chunk-3U3VAL47.js} +1 -1
  30. package/chunks/{chunk-BKHCW2BI.js → chunk-3VUENPWF.js} +10 -0
  31. package/chunks/{chunk-XY7DGTIC.js → chunk-45NQKMYB.js} +1 -1
  32. package/chunks/{chunk-VGGNHRYZ.js → chunk-4PKCUT7F.js} +7 -7
  33. package/chunks/{chunk-T7YMWGFY.js → chunk-4S5337WV.js} +1491 -711
  34. package/chunks/{chunk-FVHLDSQS.js → chunk-4W5U2TUT.js} +3 -3
  35. package/chunks/{chunk-6SU6OW5Z.js → chunk-5CVO7YES.js} +1 -1
  36. package/chunks/{chunk-OZTGLK53.js → chunk-5EYKMUUY.js} +1 -1
  37. package/chunks/{chunk-ZRT36RSF.js → chunk-6HY6IF3Z.js} +1 -1
  38. package/chunks/{chunk-HRAFAUM7.js → chunk-6ORZ2EDC.js} +3 -3
  39. package/chunks/{chunk-JOVJCXN4.js → chunk-6QFDQMQX.js} +1 -1
  40. package/chunks/{chunk-CPTIJGUK.js → chunk-6YKYPVDV.js} +4 -4
  41. package/chunks/{chunk-62OKKUOX.js → chunk-76J3IJ3M.js} +9 -7
  42. package/chunks/{chunk-JVY7FHUZ.js → chunk-7U5G6JXI.js} +9 -0
  43. package/chunks/{chunk-TIM7NVEO.js → chunk-7UXUJ5T3.js} +1 -1
  44. package/chunks/{chunk-YCGXJ4Q3.js → chunk-A267JX7H.js} +6 -6
  45. package/chunks/{chunk-4JS2QK7P.js → chunk-A4MFR4C5.js} +1 -1
  46. package/chunks/{chunk-TN3REXN4.js → chunk-A4QRWUDE.js} +79 -36
  47. package/chunks/{chunk-JW5UEE3V.js → chunk-A6NRNRKE.js} +1 -1
  48. package/chunks/{chunk-T4G33L3W.js → chunk-AA2BEKV3.js} +3 -3
  49. package/chunks/{chunk-M3DWLXEO.js → chunk-AFSG32D5.js} +1 -1
  50. package/chunks/{chunk-R4YAQULI.js → chunk-AS5IN4GK.js} +5 -5
  51. package/chunks/{chunk-ADJDLEVO.js → chunk-AW27A43Y.js} +9 -11
  52. package/chunks/{chunk-RIDUB2GC.js → chunk-AW4TRXOC.js} +1 -1
  53. package/chunks/{chunk-XL6GYJL2.js → chunk-AXN7UPYQ.js} +2 -2
  54. package/chunks/{chunk-M4NWDIFU.js → chunk-AZQ3DT76.js} +1 -1
  55. package/chunks/{chunk-OSA2TFDI.js → chunk-BHILXOC3.js} +3 -3
  56. package/chunks/{chunk-YMIQ24FR.js → chunk-BKPPWD33.js} +2 -2
  57. package/chunks/{chunk-YMB77M76.js → chunk-BUQDLC2G.js} +59 -0
  58. package/chunks/{chunk-DXXYMK2U.js → chunk-BVJS5BSP.js} +1 -1
  59. package/chunks/{chunk-EGB2PIYM.js → chunk-BZ263IKX.js} +1 -1
  60. package/chunks/{chunk-6OJDN5ZT.js → chunk-CHHABXPE.js} +1 -1
  61. package/chunks/{chunk-ZPZANKVP.js → chunk-CKSJECTU.js} +4 -4
  62. package/chunks/{chunk-H6BFLALJ.js → chunk-CPHEPGAO.js} +1 -1
  63. package/chunks/{chunk-V6PERRH4.js → chunk-CU6GJD55.js} +1 -1
  64. package/chunks/{chunk-ZZ7RUTJ4.js → chunk-CZBYX5MY.js} +1 -1
  65. package/chunks/{chunk-2OFDCPMS.js → chunk-DGK6P3BQ.js} +13 -13
  66. package/chunks/{chunk-NM33GGOM.js → chunk-DGZEMW5R.js} +3 -3
  67. package/chunks/{chunk-UPUAGRKY.js → chunk-DXIBNLBZ.js} +2 -4
  68. package/chunks/{chunk-J5SUM3ZJ.js → chunk-E23IPNGS.js} +25 -2
  69. package/chunks/{chunk-TNETSI2A.js → chunk-E3DYKPYZ.js} +3 -3
  70. package/chunks/{chunk-3MJ44LNC.js → chunk-EL5SXY3T.js} +265 -138
  71. package/chunks/{chunk-AFKOAHC3.js → chunk-EZ5RP345.js} +13 -11
  72. package/chunks/{chunk-PSTHNTHF.js → chunk-FAAUPSY2.js} +1 -1
  73. package/chunks/{chunk-NW7SPXVG.js → chunk-FDGGZIYW.js} +1 -1
  74. package/chunks/{chunk-6YSSQFHQ.js → chunk-GGDBMYGZ.js} +5 -5
  75. package/chunks/{chunk-CDDLHCC2.js → chunk-GMIEIY3Y.js} +5 -5
  76. package/chunks/{chunk-6JFPUJ2O.js → chunk-GO7STP6N.js} +4 -4
  77. package/chunks/{chunk-7JL5YBSA.js → chunk-H4A72DE5.js} +1 -1
  78. package/chunks/{chunk-I3UEXUWJ.js → chunk-HUTNYWBG.js} +2 -2
  79. package/chunks/{chunk-UQPLUR4A.js → chunk-IA2K2HJE.js} +2 -2
  80. package/chunks/{chunk-Q7VJUIIB.js → chunk-IGGGG5CX.js} +4104 -1293
  81. package/chunks/{chunk-VE2UV7IN.js → chunk-IWPYVAO2.js} +4 -4
  82. package/chunks/{chunk-HAR4G5K2.js → chunk-JNDY2MDR.js} +2 -2
  83. package/chunks/{chunk-UALXTL5Y.js → chunk-JOOFMXGF.js} +6 -6
  84. package/chunks/{chunk-HOXEJHJQ.js → chunk-JUEPY766.js} +3 -3
  85. package/chunks/{chunk-Q7YDKOGY.js → chunk-JVEGA3MM.js} +1 -1
  86. package/chunks/{chunk-QBJYSIQ4.js → chunk-K3LPAED5.js} +53 -12
  87. package/chunks/{chunk-UHF5VBKO.js → chunk-KBXKR5R2.js} +1 -1
  88. package/chunks/{chunk-32SNBMNP.js → chunk-KD5BOPLP.js} +27 -27
  89. package/chunks/{chunk-67F2BEYW.js → chunk-KV27IEHM.js} +1 -1
  90. package/chunks/{chunk-DLDVO2NY.js → chunk-LJQAUZMR.js} +360 -174
  91. package/chunks/{chunk-BNRIQWXW.js → chunk-M732YJPW.js} +7 -7
  92. package/chunks/{chunk-JRTJEGSP.js → chunk-MA2HEDVP.js} +1 -1
  93. package/chunks/{chunk-5IW3FJGD.js → chunk-MC4TLKEI.js} +2 -2
  94. package/chunks/{chunk-2ASWIM4A.js → chunk-MIPFDQAF.js} +1 -1
  95. package/chunks/{chunk-6GTKI2YX.js → chunk-MLPXSYXR.js} +133 -28
  96. package/chunks/{chunk-KRXPRVGL.js → chunk-MLXTMF7H.js} +0 -1
  97. package/chunks/{chunk-NNGCKJAD.js → chunk-MRMJCLIY.js} +3 -3
  98. package/chunks/{chunk-E7XJWIWC.js → chunk-N5YPT6PH.js} +7 -7
  99. package/chunks/{chunk-72SKJ3E7.js → chunk-NEFOOD54.js} +3 -3
  100. package/chunks/{chunk-2U3UCXZ3.js → chunk-NHDR76JX.js} +45 -13
  101. package/chunks/{chunk-QLFTWYTO.js → chunk-NM5V5OVW.js} +3 -3
  102. package/chunks/{chunk-N4LVA3S6.js → chunk-NNHNLJ2X.js} +840 -60
  103. package/chunks/chunk-NYWWQ437.js +24 -0
  104. package/chunks/{chunk-DGNQ5AFX.js → chunk-O4D7SPJN.js} +2 -2
  105. package/chunks/{chunk-YY23TR4M.js → chunk-O565M6A4.js} +411 -10
  106. package/chunks/{chunk-VUTOV2HG.js → chunk-OD2WU5QY.js} +4 -3
  107. package/chunks/{chunk-B66LYK4B.js → chunk-OMLJNPBE.js} +42 -12
  108. package/chunks/{chunk-WAF6AR5Y.js → chunk-OOQUVWIG.js} +4 -4
  109. package/chunks/{chunk-A6GQUQ7I.js → chunk-OVZPVYZB.js} +2 -2
  110. package/chunks/{chunk-VPZMLGD3.js → chunk-OXCMMLED.js} +5 -5
  111. package/chunks/{chunk-646ZB2TS.js → chunk-OY5RNSV4.js} +3 -3
  112. package/chunks/{chunk-V7RNNPGC.js → chunk-P5Y23G2L.js} +18 -1
  113. package/chunks/{chunk-O6SLWH4X.js → chunk-P7MPQI75.js} +2 -2
  114. package/chunks/{chunk-3HXLH5QV.js → chunk-PP4FUZNV.js} +47 -4
  115. package/chunks/{chunk-4XX2LZ3E.js → chunk-PQ36L4F5.js} +1 -1
  116. package/chunks/{chunk-SKRHR6N2.js → chunk-PT4I7NBA.js} +1 -1
  117. package/chunks/{chunk-KQLW7LLV.js → chunk-QF2NHSPB.js} +603 -66
  118. package/chunks/{chunk-KK3FEHPJ.js → chunk-QFJ5JHQR.js} +1 -1
  119. package/chunks/{chunk-N2G4RA77.js → chunk-QIH2HAEN.js} +1 -1
  120. package/chunks/{chunk-QSWDGAIC.js → chunk-QILD6R27.js} +1 -1
  121. package/chunks/{chunk-NHZF4VCD.js → chunk-QNQAPSN2.js} +1 -1
  122. package/chunks/{chunk-6DH5YA3X.js → chunk-QRCNA3SR.js} +8 -8
  123. package/chunks/{chunk-3RC5Q66G.js → chunk-QV5YN5YD.js} +7 -5
  124. package/chunks/{chunk-7TKNMQ6L.js → chunk-RIAABG2K.js} +2 -2
  125. package/chunks/{chunk-LYRA6ZTI.js → chunk-RLKC46YT.js} +138 -11
  126. package/chunks/{chunk-YI5G32RU.js → chunk-ROIYNTHJ.js} +3 -3
  127. package/chunks/{chunk-UAAWNTOC.js → chunk-RVOJ2FBP.js} +12 -12
  128. package/chunks/{chunk-SNHBRO4C.js → chunk-RWDNJBWN.js} +2 -2
  129. package/chunks/{chunk-UFHPAMAV.js → chunk-S5DWMTHO.js} +11 -1
  130. package/chunks/{chunk-TROB4PZY.js → chunk-SG7ZP5PG.js} +4 -4
  131. package/chunks/{chunk-E74YSVIN.js → chunk-SXCOEJO4.js} +1 -1
  132. package/chunks/{chunk-U5C2GIN2.js → chunk-TIGA2IVL.js} +117 -3
  133. package/chunks/chunk-TS6625XH.js +488 -0
  134. package/chunks/{chunk-EHXS5MAC.js → chunk-TUGSVUJB.js} +7 -7
  135. package/chunks/{chunk-E3GLDLYB.js → chunk-TYAMGABM.js} +0 -6
  136. package/chunks/{chunk-ZLX7FTZQ.js → chunk-U3VNBPUO.js} +3 -3
  137. package/chunks/{chunk-F7PTQFTB.js → chunk-UKMR3CKV.js} +4 -4
  138. package/chunks/{chunk-7WUMS2UA.js → chunk-UPDOZBWO.js} +1 -1
  139. package/chunks/{chunk-YK4O72LT.js → chunk-UZPM4XHR.js} +4 -4
  140. package/chunks/{chunk-VKEA37IR.js → chunk-V26NVGAU.js} +1 -1
  141. package/chunks/{chunk-IJCZP2MA.js → chunk-V57QC6WW.js} +3 -3
  142. package/chunks/{chunk-LSMCI42W.js → chunk-WFSTRPRO.js} +3 -3
  143. package/chunks/{chunk-5KZNWF2M.js → chunk-WGHHA7ZH.js} +1 -1
  144. package/chunks/{chunk-A4BAHMJF.js → chunk-WSH6GRKG.js} +4 -4
  145. package/chunks/{chunk-OK727E5D.js → chunk-X26JYGTD.js} +1 -1
  146. package/chunks/{chunk-VAPNUDD5.js → chunk-XHRY7BXD.js} +4 -4
  147. package/chunks/{chunk-XNL23MGG.js → chunk-XIT3GURH.js} +3 -3
  148. package/chunks/{chunk-2RTRFLWH.js → chunk-XLLKYULU.js} +6 -6
  149. package/chunks/{chunk-C2DR57L6.js → chunk-XUJNK7Y6.js} +1 -1
  150. package/chunks/{chunk-AAZWJAPQ.js → chunk-Y3YCSWG5.js} +2 -2
  151. package/chunks/{chunk-ZTBFA7I6.js → chunk-YEYY7TEP.js} +7 -7
  152. package/chunks/{chunk-FTGU6G45.js → chunk-YZHRN3CF.js} +2 -2
  153. package/chunks/{chunk-2N6CV4PW.js → chunk-YZOSNW4R.js} +1 -1
  154. package/chunks/{chunk-U7ROFHSH.js → chunk-ZLCT4C5A.js} +1 -1
  155. package/chunks/{chunk-VBKTP7TH.js → chunk-ZYBBISBY.js} +15 -34
  156. package/chunks/{chunk-7ATQGA6V.js → chunk-ZYYTZUI2.js} +6 -6
  157. package/chunks/{chunk-RXX5T3IF.js → chunk-ZZO74WKW.js} +44 -8
  158. package/chunks/{computer-use-ZFBJYSR3.js → computer-use-77C5FHMW.js} +45 -45
  159. package/chunks/{config-utils-7JZQN6L2.js → config-utils-IVHRSXWI.js} +4 -4
  160. package/chunks/{contextCommand-G3TAIY7T.js → contextCommand-PJ77GBWL.js} +44 -44
  161. package/chunks/{core-runtime-K3MQVNSF.js → core-runtime-7VMIKUTG.js} +42 -42
  162. package/chunks/{create-sub-session-DMTLJPDG.js → create-sub-session-2L5MQRN4.js} +42 -42
  163. package/chunks/{create-sub-session-23ULO5PO.js → create-sub-session-KRQULJE6.js} +2 -2
  164. package/chunks/{cron-create-5WUTNKNF.js → cron-create-H7UEPDSN.js} +4 -4
  165. package/chunks/{cron-delete-JEQ27YPS.js → cron-delete-6SZK7YFM.js} +4 -4
  166. package/chunks/{cron-list-IXGCA7UR.js → cron-list-H25JIHEZ.js} +4 -4
  167. package/chunks/{daemon-UBVOQMWY.js → daemon-2KTG7ZBN.js} +108 -9
  168. package/chunks/daemon-git-worktree-guard-DXYIMWFT.js +2062 -0
  169. package/chunks/{daemon-status-provider-KFLEZGD7.js → daemon-status-provider-ZDOYJCU6.js} +52 -53
  170. package/chunks/{daemon-trust-policy-ZZ6DRDAC.js → daemon-trust-policy-E67OYUK2.js} +48 -48
  171. package/chunks/{daemon-trust-policy-monitor-CIKHNV2K.js → daemon-trust-policy-monitor-RYYGCQ3J.js} +48 -48
  172. package/chunks/{deferred-core-runtime-MM7X7UYR.js → deferred-core-runtime-3SGXFXEQ.js} +44 -44
  173. package/chunks/{devtools-X6ROTKHE.js → devtools-4QFYJT6U.js} +1 -1
  174. package/chunks/discovery-ORA5J7YP.js +27 -0
  175. package/chunks/{display-image-CAD7RAUM.js → display-image-ON3EYFRD.js} +4 -4
  176. package/chunks/{dist-B3ODKYEB.js → dist-4ZPG4BY6.js} +2 -2
  177. package/chunks/{dist-CCUH2Z4C.js → dist-BROOP2EG.js} +1 -1
  178. package/chunks/{dist-DANKRAB3.js → dist-IYYN3RUT.js} +2 -2
  179. package/chunks/{dist-5VDE7U3A.js → dist-JWMKPWT5.js} +3 -1
  180. package/chunks/{dist-6RK4U6VU.js → dist-K7IQB53U.js} +1 -1
  181. package/chunks/{dist-EZHCZSW6.js → dist-MAQXAQ2Y.js} +1 -1
  182. package/chunks/{dist-362MN6CP.js → dist-WJ4BHIEW.js} +2 -2
  183. package/chunks/{dist-M3XMEIP2.js → dist-YEPL4RAW.js} +1 -1
  184. package/chunks/{earlyInputCapture-O77TUBIF.js → earlyInputCapture-KJMLFVQV.js} +43 -43
  185. package/chunks/{edit-CZ23AVP6.js → edit-I4LQFAEC.js} +50 -49
  186. package/chunks/{enter-worktree-4EMS7IRL.js → enter-worktree-YNPOJSRH.js} +47 -47
  187. package/chunks/{enterPlanMode-TS6KO6DU.js → enterPlanMode-XCPK62ER.js} +47 -47
  188. package/chunks/{environment-7JAXEU6I.js → environment-S7CTIHMX.js} +44 -44
  189. package/chunks/{errors-NBABPF4S.js → errors-7HB2AIDS.js} +44 -44
  190. package/chunks/{exit-worktree-Q3NFHYUI.js → exit-worktree-AIIY7SR6.js} +47 -47
  191. package/chunks/{exitPlanMode-4JH6WLKL.js → exitPlanMode-R4JY7V2O.js} +42 -42
  192. package/chunks/{external-tool-guard-provider-5HTGOPGU.js → external-tool-guard-provider-TE4DRY36.js} +1 -1
  193. package/chunks/{fast-path-5LFDLPHJ.js → fast-path-NDJV3ZFJ.js} +3 -3
  194. package/chunks/{gemini-MB4S7YLN.js → gemini-RSUFP5OE.js} +108 -103
  195. package/chunks/{geminiContentGenerator-EQY2QU7K.js → geminiContentGenerator-SQ5XBPZ7.js} +11 -11
  196. package/chunks/{glob-LA5XO2H7.js → glob-J4RUJAHX.js} +49 -49
  197. package/chunks/{goal-tools-LQFO4BRY.js → goal-tools-VHTNVOKK.js} +56 -12
  198. package/chunks/{grep-KYBZMY36.js → grep-VJWPLFOT.js} +47 -47
  199. package/chunks/{handleAutoUpdate-HZJSAUNC.js → handleAutoUpdate-POCX2MNB.js} +46 -46
  200. package/chunks/{i18n-BSCIN4J4.js → i18n-RM5YOICI.js} +43 -43
  201. package/chunks/{image-gen-HGURQAHX.js → image-gen-EXECB5XM.js} +11 -11
  202. package/chunks/{initializer-WUHJXIB3.js → initializer-Z2AFGBNR.js} +49 -49
  203. package/chunks/{installationInfo-G3PDBWG2.js → installationInfo-4I5FXNMH.js} +43 -43
  204. package/chunks/{keychain-token-storage-GU75J2T2.js → keychain-token-storage-3XFJ5ZB2.js} +2 -2
  205. package/chunks/{list-IC7KDSZ6.js → list-ZMBFIGZA.js} +51 -51
  206. package/chunks/{list-agents-5PNMK2AM.js → list-agents-OSVDFI6S.js} +2 -2
  207. package/chunks/{loadedSettingsAdapter-Z3GOJRI7.js → loadedSettingsAdapter-T6TV4YJ7.js} +48 -48
  208. package/chunks/{loggingContentGenerator-E2QENFPH.js → loggingContentGenerator-WF4ZOJEZ.js} +99 -66
  209. package/chunks/{loop-wakeup-OV65FEGR.js → loop-wakeup-WQS6JYAG.js} +5 -5
  210. package/chunks/{ls-RPRSX26R.js → ls-D3HUFHDP.js} +6 -6
  211. package/chunks/{lsp-IWTJWFLT.js → lsp-3QDDJTCS.js} +2 -2
  212. package/chunks/{managed-npm-update-MX2OPCW4.js → managed-npm-update-E7IW6N7V.js} +43 -43
  213. package/chunks/{mcp-QQEWPNWV.js → mcp-6UNYX4HG.js} +48 -48
  214. package/chunks/{monitor-SV64FNV3.js → monitor-EE2UYMGE.js} +47 -47
  215. package/chunks/{node-YSOU44FX.js → node-UUDY34IG.js} +3 -3
  216. package/chunks/nonInteractiveCli-WAY237O4.js +163 -0
  217. package/chunks/{notebook-edit-QPYSWPRI.js → notebook-edit-NTDY4QDU.js} +47 -47
  218. package/chunks/{openaiContentGenerator-CMZXOSVA.js → openaiContentGenerator-YNFVJMRJ.js} +30 -30
  219. package/chunks/{pidfile-D5UXVVAI.js → pidfile-4XSFLYBZ.js} +43 -43
  220. package/chunks/{processUtils-ZEIMIVPX.js → processUtils-WDA2MJFD.js} +2 -2
  221. package/chunks/proper-lockfile-3LHWIM44.js +8 -0
  222. package/chunks/{qwenContentGenerator-JAXZKB7R.js → qwenContentGenerator-434M7QKY.js} +50 -50
  223. package/chunks/{qwenOAuth2-C2QWTD2G.js → qwenOAuth2-GMYZOO6A.js} +10 -10
  224. package/chunks/{read-file-2V5GE6ZW.js → read-file-TAFBKMNI.js} +11 -11
  225. package/chunks/{read-mcp-resource-THCSZHXO.js → read-mcp-resource-XD54ZQMC.js} +2 -2
  226. package/chunks/{record-artifact-76YYQA5F.js → record-artifact-SEYFJEJF.js} +3 -3
  227. package/chunks/{resumeHistoryUtils-UZ7GHPNY.js → resumeHistoryUtils-EVG3WYK2.js} +50 -50
  228. package/chunks/{ripGrep-MUTMPQSV.js → ripGrep-WOEK2PXS.js} +42 -42
  229. package/chunks/{run-qwen-serve-WU43JKEA.js → run-qwen-serve-3QSGRXAN.js} +417 -208
  230. package/chunks/{runtime-YLOFDP2P.js → runtime-5MLLZ7DC.js} +53 -53
  231. package/chunks/{scheduler-G44OPSZE.js → scheduler-RPBJ63CH.js} +44 -44
  232. package/chunks/{sdk-exporters-grpc-4QKV6MCX.js → sdk-exporters-grpc-54L4LS5L.js} +2 -2
  233. package/chunks/{sdk-exporters-http-A7XLKZO7.js → sdk-exporters-http-XUVP63H6.js} +12 -12
  234. package/chunks/{sdk-impl-XO4UF6PR.js → sdk-impl-YXUEN2Z2.js} +8 -8
  235. package/chunks/{send-message-P5SLP57G.js → send-message-VZENRWRH.js} +6 -6
  236. package/chunks/{serve-CZQDBDYV.js → serve-HS3XLPXU.js} +50 -50
  237. package/chunks/{server-HGI2KF3Y.js → server-TC4A7AAZ.js} +3850 -1630
  238. package/chunks/{session-OVMSHAO5.js → session-UBOFXVMN.js} +92 -95
  239. package/chunks/{settings-TWX6ROGP.js → settings-D5644OM5.js} +47 -47
  240. package/chunks/{shell-JDSWGVC7.js → shell-3PZULQQV.js} +42 -42
  241. package/chunks/{skill-QILHTMYJ.js → skill-PEVVXQ3L.js} +22 -22
  242. package/chunks/{skill-settings-RKRD34RZ.js → skill-settings-J65JKKES.js} +47 -47
  243. package/chunks/{spawnChannel-V5PYSDEI.js → spawnChannel-IYGXRHSQ.js} +45 -47
  244. package/chunks/{standalone-update-Y52CWCGG.js → standalone-update-IFM53PE7.js} +44 -44
  245. package/chunks/{startInteractiveUI-RVA62ZM6.js → startInteractiveUI-3AVH7L6H.js} +3340 -2460
  246. package/chunks/{syntheticOutput-SEW4NA47.js → syntheticOutput-7GWFIDXT.js} +3 -3
  247. package/chunks/{task-create-247EAVF7.js → task-create-FCBDX7UH.js} +12 -12
  248. package/chunks/{task-list-ZJN4QHLK.js → task-list-YIYIUFUA.js} +6 -6
  249. package/chunks/{task-stop-MAYQJ42I.js → task-stop-X37KYTKB.js} +2 -2
  250. package/chunks/{task-update-SU5TMZGG.js → task-update-MYPFVOVM.js} +12 -12
  251. package/chunks/{team-create-YMWUDIE3.js → team-create-ZAIA7KAV.js} +47 -47
  252. package/chunks/{team-delete-3XVRPQBP.js → team-delete-6UMU4XLS.js} +6 -6
  253. package/chunks/{team-plan-approval-3GPZAW46.js → team-plan-approval-UNIUS7OD.js} +47 -47
  254. package/chunks/{terminal-image-renderer-UGQKWDM3.js → terminal-image-renderer-G343P2RV.js} +44 -44
  255. package/chunks/{theme-manager-KRG4GGFY.js → theme-manager-Z3RIT7DB.js} +43 -43
  256. package/chunks/{todoWrite-IE2YTCK7.js → todoWrite-U2R4NVF4.js} +4 -4
  257. package/chunks/{tool-search-SZRO5G72.js → tool-search-5R2OE4C7.js} +17 -17
  258. package/chunks/{total-session-admission-JYHYOKWX.js → total-session-admission-4KBHMQQ2.js} +48 -48
  259. package/chunks/{trustedFolders-2BDCB5NJ.js → trustedFolders-LK6T4XC7.js} +43 -43
  260. package/chunks/{update-relaunch-XSYVPSDL.js → update-relaunch-UBKROIC6.js} +5 -5
  261. package/chunks/{updateCheck-SMMJ27GG.js → updateCheck-W4Y2GFSD.js} +45 -45
  262. package/chunks/{useAutoAcceptIndicator-HPG4UFIZ.js → useAutoAcceptIndicator-C7BEICBF.js} +51 -51
  263. package/chunks/{validateNonInterActiveAuth-IIL774NT.js → validateNonInterActiveAuth-LTEI2TB6.js} +84 -86
  264. package/chunks/{version-WSGAB2PA.js → version-G5A5DGVS.js} +1 -1
  265. package/chunks/{web-fetch-LKC2F5DM.js → web-fetch-RTEQTR5Z.js} +20 -20
  266. package/chunks/{web-search-BHMAMXEU.js → web-search-5OXHEZPV.js} +16 -16
  267. package/chunks/{workflow-A7AQ52HO.js → workflow-ISQJHPG2.js} +54 -53
  268. package/chunks/{workspace-providers-status-JRT57TLL.js → workspace-providers-status-2ZPZPUPZ.js} +51 -51
  269. package/chunks/{workspace-registration-store-EACJNCM5.js → workspace-registration-store-CYNY6IP6.js} +2 -2
  270. package/chunks/{workspace-registry-OV5SI4ES.js → workspace-registry-34GTUUHB.js} +50 -49
  271. package/chunks/{workspace-service-PUHU4EEK.js → workspace-service-XCDQLE2Y.js} +53 -53
  272. package/chunks/{workspace-skills-status-YAJE3UW3.js → workspace-skills-status-RS4O7AIJ.js} +49 -49
  273. package/chunks/{workspace-trust-reconciler-JP5UR2H6.js → workspace-trust-reconciler-AYGXC7A3.js} +57 -56
  274. package/chunks/{write-file-UBIHUP5M.js → write-file-EWXKVVXF.js} +42 -42
  275. package/chunks/{zoom-image-4QTKAMTP.js → zoom-image-4BFYJ3HG.js} +11 -11
  276. package/cli.js +18 -17
  277. package/package.json +3 -3
  278. package/web-shell/assets/{arc-lZ04kynw.js → arc-CgOpDKvm.js} +1 -1
  279. package/web-shell/assets/{architectureDiagram-3BPJPVTR-B1wZVhzD.js → architectureDiagram-3BPJPVTR-0Ag_m34F.js} +1 -1
  280. package/web-shell/assets/{blockDiagram-GPEHLZMM-CO0e0yJt.js → blockDiagram-GPEHLZMM-IwTwFau0.js} +1 -1
  281. package/web-shell/assets/{c4Diagram-AAUBKEIU-Dfpo6Qie.js → c4Diagram-AAUBKEIU-DLa5GUv8.js} +1 -1
  282. package/web-shell/assets/channel-BrGVBa2L.js +1 -0
  283. package/web-shell/assets/{chunk-2J33WTMH-BvxArftT.js → chunk-2J33WTMH-DcYP-WFG.js} +1 -1
  284. package/web-shell/assets/{chunk-4BX2VUAB-BS2XXjGY.js → chunk-4BX2VUAB-C8MVPMiQ.js} +1 -1
  285. package/web-shell/assets/{chunk-55IACEB6-CYL6h3Ph.js → chunk-55IACEB6-BUi4Yfv3.js} +1 -1
  286. package/web-shell/assets/{chunk-727SXJPM-C-cWPX30.js → chunk-727SXJPM-Cy3Su2YY.js} +1 -1
  287. package/web-shell/assets/{chunk-AQP2D5EJ-CJLxNbVV.js → chunk-AQP2D5EJ-Dp8Teqv6.js} +1 -1
  288. package/web-shell/assets/{chunk-FMBD7UC4-DwfzKywA.js → chunk-FMBD7UC4-BDTDM-4j.js} +1 -1
  289. package/web-shell/assets/{chunk-ND2GUHAM-BI5raYHQ.js → chunk-ND2GUHAM-7HfDt0r2.js} +1 -1
  290. package/web-shell/assets/{chunk-QZHKN3VN-_GkNI90J.js → chunk-QZHKN3VN-BIBU0uCF.js} +1 -1
  291. package/web-shell/assets/classDiagram-4FO5ZUOK-B5TUzJzI.js +1 -0
  292. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-B5TUzJzI.js +1 -0
  293. package/web-shell/assets/{cose-bilkent-S5V4N54A-BAVLNxh9.js → cose-bilkent-S5V4N54A-DRLdcg9p.js} +1 -1
  294. package/web-shell/assets/{dagre-BM42HDAG-BD4XNLqp.js → dagre-BM42HDAG-DCCgDwqW.js} +1 -1
  295. package/web-shell/assets/{diagram-2AECGRRQ-WO567p8w.js → diagram-2AECGRRQ-CsBTBmk3.js} +1 -1
  296. package/web-shell/assets/{diagram-5GNKFQAL-mAk23VWO.js → diagram-5GNKFQAL-C9qjH8Lt.js} +1 -1
  297. package/web-shell/assets/{diagram-KO2AKTUF-YQEeHKze.js → diagram-KO2AKTUF-Brjs_lj2.js} +1 -1
  298. package/web-shell/assets/{diagram-LMA3HP47-CMVjxAjv.js → diagram-LMA3HP47-DtiWCl_F.js} +1 -1
  299. package/web-shell/assets/{diagram-OG6HWLK6-42hPvbM-.js → diagram-OG6HWLK6-DmfKLkBT.js} +1 -1
  300. package/web-shell/assets/{erDiagram-TEJ5UH35-CXU_cPfu.js → erDiagram-TEJ5UH35-Bve_4deH.js} +1 -1
  301. package/web-shell/assets/{flowDiagram-I6XJVG4X-D-3TdhMT.js → flowDiagram-I6XJVG4X-C2_kXCcV.js} +1 -1
  302. package/web-shell/assets/{ganttDiagram-6RSMTGT7-CsgkXolz.js → ganttDiagram-6RSMTGT7-BSBIjiTF.js} +1 -1
  303. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-B6Q3PBLD.js → gitGraphDiagram-PVQCEYII-CyebwI55.js} +1 -1
  304. package/web-shell/assets/index-CIDsgxTe.js +1792 -0
  305. package/web-shell/assets/index-DiQnWi_E.css +5 -0
  306. package/web-shell/assets/{index-BFrkGj2B.js → index-d0yfnV1M.js} +1 -1
  307. package/web-shell/assets/{infoDiagram-5YYISTIA-jiAfSXp8.js → infoDiagram-5YYISTIA-CSDGnWxU.js} +1 -1
  308. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-BWif5KeJ.js → ishikawaDiagram-YF4QCWOH-BK4jU13p.js} +1 -1
  309. package/web-shell/assets/{journeyDiagram-JHISSGLW-B-GAZthS.js → journeyDiagram-JHISSGLW-D_W6j-oF.js} +1 -1
  310. package/web-shell/assets/{kanban-definition-UN3LZRKU-9TEuATdL.js → kanban-definition-UN3LZRKU-C7xf-SdC.js} +1 -1
  311. package/web-shell/assets/{linear-dy_QPfyE.js → linear-DQmzxpxd.js} +1 -1
  312. package/web-shell/assets/{mermaid.core-DB2uLAnq.js → mermaid.core-9P7AGOLG.js} +5 -5
  313. package/web-shell/assets/{mindmap-definition-RKZ34NQL-ey_dyxi-.js → mindmap-definition-RKZ34NQL-DgcgMyPk.js} +1 -1
  314. package/web-shell/assets/{pieDiagram-4H26LBE5-_6BuMdDj.js → pieDiagram-4H26LBE5-3wWGb9eG.js} +1 -1
  315. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-B2rM19W2.js → quadrantDiagram-W4KKPZXB-BeCXnQw9.js} +1 -1
  316. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DWj8b7vW.js → requirementDiagram-4Y6WPE33-Bi1UOHDz.js} +1 -1
  317. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-D5dtYh0N.js → sankeyDiagram-5OEKKPKP-lrLUjjbb.js} +1 -1
  318. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DVkdn_qW.js → sequenceDiagram-3UESZ5HK-BFuqKz6Q.js} +1 -1
  319. package/web-shell/assets/{stateDiagram-AJRCARHV-DgwD_fi6.js → stateDiagram-AJRCARHV-8DemQLhu.js} +1 -1
  320. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DhM5ixYd.js +1 -0
  321. package/web-shell/assets/{timeline-definition-PNZ67QCA-vNr_1UNX.js → timeline-definition-PNZ67QCA-uzEuVQXg.js} +1 -1
  322. package/web-shell/assets/{vennDiagram-CIIHVFJN-ChFcGAcu.js → vennDiagram-CIIHVFJN-BQTeZ_-o.js} +1 -1
  323. package/web-shell/assets/{wardley-L42UT6IY-C8PXoSWk.js → wardley-L42UT6IY-B6yM5Im7.js} +1 -1
  324. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-C2nqOV6i.js → wardleyDiagram-YWT4CUSO-ChM8bmgn.js} +1 -1
  325. package/web-shell/assets/{xychartDiagram-2RQKCTM6-BntaqhSB.js → xychartDiagram-2RQKCTM6-oNG6HyB1.js} +1 -1
  326. package/web-shell/index.html +2 -2
  327. package/chunks/chunk-5PLOQW7H.js +0 -830
  328. package/chunks/chunk-DMODRHNL.js +0 -649
  329. package/chunks/chunk-L34XSHIZ.js +0 -28
  330. package/chunks/chunk-N2TNM3QB.js +0 -9
  331. package/chunks/chunk-RECPKBBD.js +0 -622
  332. package/chunks/chunk-WLML6VIA.js +0 -18
  333. package/chunks/chunk-ZBBVBZBR.js +0 -137
  334. package/chunks/chunk-bdqvmfwv-OHYAFAAO.js +0 -17446
  335. package/chunks/discovery-XLHITE74.js +0 -220
  336. package/chunks/dispatch-FW7DX2CR.js +0 -43
  337. package/chunks/nonInteractiveCli-3XFIFXBR.js +0 -166
  338. package/chunks/opentui-entry-TEHHLGN7.js +0 -52419
  339. package/chunks/runtime-gate-T4ICWGQJ.js +0 -89
  340. package/chunks/wrapper-46Z24CTM.js +0 -35
  341. package/web-shell/assets/channel-BxvRq3pV.js +0 -1
  342. package/web-shell/assets/classDiagram-4FO5ZUOK-tL8nAxYf.js +0 -1
  343. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-tL8nAxYf.js +0 -1
  344. package/web-shell/assets/index-BgjULKyF.css +0 -5
  345. package/web-shell/assets/index-CxXlPYfl.js +0 -1789
  346. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BWGkVGVB.js +0 -1
  347. /package/chunks/{chunk-44CTCCLY.js → chunk-NWNEANAT.js} +0 -0
@@ -40,7 +40,7 @@ import {
40
40
  CronScheduler,
41
41
  DEFAULT_RECURRING_MAX_AGE_DAYS,
42
42
  normalizeRecurringMaxAge
43
- } from "./chunk-NM33GGOM.js";
43
+ } from "./chunk-DGZEMW5R.js";
44
44
  import {
45
45
  consumeUnread,
46
46
  forwardApproval,
@@ -49,13 +49,13 @@ import {
49
49
  sendStructuredMessage,
50
50
  wrapConfirmWithBadge,
51
51
  writeMessage
52
- } from "./chunk-A4BAHMJF.js";
52
+ } from "./chunk-WSH6GRKG.js";
53
53
  import {
54
54
  claimTask,
55
55
  listTasks,
56
56
  onTasksUpdated,
57
57
  unassignTeammateTasks
58
- } from "./chunk-ZPZANKVP.js";
58
+ } from "./chunk-CKSJECTU.js";
59
59
  import {
60
60
  assignTeammateColor,
61
61
  classifyShutdownResponse,
@@ -63,7 +63,7 @@ import {
63
63
  formatAgentId,
64
64
  generateUniqueTeammateName,
65
65
  writeTeamFile
66
- } from "./chunk-A6GQUQ7I.js";
66
+ } from "./chunk-OVZPVYZB.js";
67
67
  import {
68
68
  parsePositiveIntegerEnv
69
69
  } from "./chunk-6PVPNMXU.js";
@@ -71,13 +71,13 @@ import {
71
71
  RUNTIME_SNAPSHOT_PREFIX,
72
72
  buildModelIdContext,
73
73
  resolveModelId
74
- } from "./chunk-OZTGLK53.js";
74
+ } from "./chunk-5EYKMUUY.js";
75
75
  import {
76
76
  ARTIFACT_TITLE_MAX_LENGTH,
77
77
  ARTIFACT_WORKSPACE_PATH_MAX_LENGTH,
78
78
  hasControlCharacter,
79
79
  hasUnsafeDisplayPayload
80
- } from "./chunk-7WUMS2UA.js";
80
+ } from "./chunk-UPDOZBWO.js";
81
81
  import {
82
82
  promptIdContext,
83
83
  todoWorkChainContext
@@ -101,7 +101,7 @@ import {
101
101
  isPlanRequiredTeammatePreApprovalAllowedTool,
102
102
  isSubagentLikeExecutionContext,
103
103
  shouldUsePlanOnlyReminderInSubagentContext
104
- } from "./chunk-SNHBRO4C.js";
104
+ } from "./chunk-RWDNJBWN.js";
105
105
  import {
106
106
  SKILL_FILE_NAME,
107
107
  SKILL_NAME_PATTERN,
@@ -121,10 +121,7 @@ import {
121
121
  require_dist as require_dist2,
122
122
  stringify,
123
123
  validateSkillName
124
- } from "./chunk-KTWUFHS4.js";
125
- import {
126
- require_proper_lockfile
127
- } from "./chunk-KRXPRVGL.js";
124
+ } from "./chunk-25EYDK42.js";
128
125
  import {
129
126
  DefaultHookOutput,
130
127
  HOOKS_CONFIG_FIELDS,
@@ -139,15 +136,18 @@ import {
139
136
  createHookOutput,
140
137
  getHookKey,
141
138
  isToolArtifactLike
142
- } from "./chunk-2ASWIM4A.js";
139
+ } from "./chunk-MIPFDQAF.js";
140
+ import {
141
+ require_proper_lockfile
142
+ } from "./chunk-MLXTMF7H.js";
143
143
  import {
144
144
  BaseTokenStorage,
145
145
  KeychainTokenStorage
146
- } from "./chunk-67F2BEYW.js";
146
+ } from "./chunk-KV27IEHM.js";
147
147
  import {
148
148
  normalizeImageGenerationBaseUrl,
149
149
  resolveNetworkTarget
150
- } from "./chunk-TNETSI2A.js";
150
+ } from "./chunk-E3DYKPYZ.js";
151
151
  import {
152
152
  EvidenceSourceUnavailableError,
153
153
  GoalEvidenceCheckpointAccumulator,
@@ -173,22 +173,24 @@ import {
173
173
  validateTranscriptRecord,
174
174
  walkTranscriptUuidChain,
175
175
  wrapUserPromptSubmitContext
176
- } from "./chunk-B66LYK4B.js";
176
+ } from "./chunk-OMLJNPBE.js";
177
177
  import {
178
+ AgentOutputMessageCapture,
178
179
  DEFAULT_OTLP_ENDPOINT,
179
180
  DEFAULT_TELEMETRY_TARGET,
181
+ addAgentInputMessageAttributes,
180
182
  addDaemonRequestAttribute,
181
183
  addToolArgumentsAttributes,
182
184
  addToolCallResultAttributes,
183
185
  addUserPromptAttributes
184
- } from "./chunk-U5C2GIN2.js";
186
+ } from "./chunk-TIGA2IVL.js";
185
187
  import {
186
188
  supportsOpenAIPrefixCaching
187
189
  } from "./chunk-SAH4BD2J.js";
188
190
  import {
189
191
  DashScopeOpenAICompatibleProvider,
190
192
  selectDashScopeThinkingKnob
191
- } from "./chunk-2RTRFLWH.js";
193
+ } from "./chunk-XLLKYULU.js";
192
194
  import {
193
195
  childLaunchDepth,
194
196
  getCurrentAgentDepth,
@@ -199,7 +201,7 @@ import {
199
201
  runWithAgentContext,
200
202
  runWithRuntimeContentGenerator,
201
203
  spawnBlockReason
202
- } from "./chunk-SKRHR6N2.js";
204
+ } from "./chunk-PT4I7NBA.js";
203
205
  import {
204
206
  getTeammateContext,
205
207
  isTeammate,
@@ -209,6 +211,92 @@ import {
209
211
  InvalidStreamError,
210
212
  getThoughtSummary
211
213
  } from "./chunk-2J3OJGTL.js";
214
+ import {
215
+ BUBBLE_APPROVAL_MODE,
216
+ FORK_AGENT,
217
+ FORK_DEFAULT_MAX_TURNS,
218
+ FORK_PLACEHOLDER_RESULT,
219
+ FORK_SUBAGENT_TYPE,
220
+ SubagentError,
221
+ SubagentErrorCode,
222
+ buildAvailableSkillsReminder,
223
+ buildChangedAgentsReminder,
224
+ buildChangedMcpToolsReminder,
225
+ buildChangedSkillsReminder,
226
+ buildChildMessage,
227
+ buildDeferredToolsReminder,
228
+ buildForkExecutionAllowlist,
229
+ buildForkedMessages,
230
+ buildFunctionResponseParts,
231
+ buildMcpServerInstructionsReminder,
232
+ buildPinnedWorktreeNotice,
233
+ buildWorktreeNotice,
234
+ formatDateForContext,
235
+ getDirectoryContextString,
236
+ getFolderStructure,
237
+ getInitialChatHistory,
238
+ getStartupContextLength,
239
+ isSystemReminderContent,
240
+ normalizeForkTurns,
241
+ registerForkDisplayImageForCache,
242
+ resolveForkExecutionAllowedTools,
243
+ runInForkContext,
244
+ selectForkHistory,
245
+ stripSystemReminderBlocks,
246
+ validateForkToolList
247
+ } from "./chunk-SG7ZP5PG.js";
248
+ import {
249
+ collectAvailableSkillEntries,
250
+ renderAvailableSkillsBlock
251
+ } from "./chunk-K623ENWT.js";
252
+ import {
253
+ escapeSystemReminderTags,
254
+ escapeXml
255
+ } from "./chunk-AQ37AY7B.js";
256
+ import {
257
+ DEFAULT_FILE_FILTERING_OPTIONS,
258
+ DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES,
259
+ QwenIgnoreParser,
260
+ WorkspaceContext,
261
+ formatQwenIgnoreFileNames,
262
+ getQwenIgnoreFileNames,
263
+ isPathWithinRoot,
264
+ require_ignore
265
+ } from "./chunk-KBXKR5R2.js";
266
+ import {
267
+ openBrowserSecurely,
268
+ shouldAttemptBrowserLaunch
269
+ } from "./chunk-NAVJD2PQ.js";
270
+ import {
271
+ isUnattendedMode,
272
+ retryWithBackoff
273
+ } from "./chunk-2B2BF7P7.js";
274
+ import {
275
+ classifyRetryError,
276
+ isFallbackEligible
277
+ } from "./chunk-YZHRN3CF.js";
278
+ import {
279
+ QUOTA_EXHAUSTED_PREFIX,
280
+ formatQuotaExhaustedMessage,
281
+ getRateLimitErrorDetails,
282
+ getRateLimitRetryDelayMs,
283
+ isApiError,
284
+ isQuotaExhaustedError,
285
+ isRateLimitError,
286
+ isStructuredError
287
+ } from "./chunk-FAAUPSY2.js";
288
+ import {
289
+ DEFAULT_OPENAI_BASE_URL
290
+ } from "./chunk-AXMWHKXA.js";
291
+ import {
292
+ getToolCallPreparations,
293
+ setToolCallPreparations
294
+ } from "./chunk-GLCZKT5V.js";
295
+ import {
296
+ combineAbortSignals,
297
+ createAbortController,
298
+ createChildAbortController
299
+ } from "./chunk-DJ2GSRLV.js";
212
300
  import {
213
301
  ApiRetryEvent,
214
302
  COMBINED_PASS_TOLERANCE_FACTOR,
@@ -326,7 +414,7 @@ import {
326
414
  updateMCPServerStatus,
327
415
  writeLine,
328
416
  writeLineSync
329
- } from "./chunk-UAAWNTOC.js";
417
+ } from "./chunk-RVOJ2FBP.js";
330
418
  import {
331
419
  defaultModalities,
332
420
  isTieredEffortWireModel
@@ -355,65 +443,13 @@ import {
355
443
  isManagedMemoryPath,
356
444
  isTeamAutoMemPath,
357
445
  isUserAutoMemPath
358
- } from "./chunk-6OJDN5ZT.js";
446
+ } from "./chunk-CHHABXPE.js";
359
447
  import {
360
448
  runSideQuery
361
- } from "./chunk-JRTJEGSP.js";
449
+ } from "./chunk-MA2HEDVP.js";
362
450
  import {
363
451
  STRUCTURED_OUTPUT_REDACTED_ARGS
364
- } from "./chunk-C2DR57L6.js";
365
- import {
366
- BUBBLE_APPROVAL_MODE,
367
- FORK_AGENT,
368
- FORK_DEFAULT_MAX_TURNS,
369
- FORK_PLACEHOLDER_RESULT,
370
- FORK_SUBAGENT_TYPE,
371
- SubagentError,
372
- SubagentErrorCode,
373
- buildAvailableSkillsReminder,
374
- buildChangedAgentsReminder,
375
- buildChangedMcpToolsReminder,
376
- buildChangedSkillsReminder,
377
- buildChildMessage,
378
- buildDeferredToolsReminder,
379
- buildForkExecutionAllowlist,
380
- buildForkedMessages,
381
- buildFunctionResponseParts,
382
- buildMcpServerInstructionsReminder,
383
- buildPinnedWorktreeNotice,
384
- buildWorktreeNotice,
385
- formatDateForContext,
386
- getDirectoryContextString,
387
- getFolderStructure,
388
- getInitialChatHistory,
389
- getStartupContextLength,
390
- isSystemReminderContent,
391
- normalizeForkTurns,
392
- registerForkDisplayImageForCache,
393
- resolveForkExecutionAllowedTools,
394
- runInForkContext,
395
- selectForkHistory,
396
- stripSystemReminderBlocks,
397
- validateForkToolList
398
- } from "./chunk-TROB4PZY.js";
399
- import {
400
- collectAvailableSkillEntries,
401
- renderAvailableSkillsBlock
402
- } from "./chunk-K623ENWT.js";
403
- import {
404
- escapeSystemReminderTags,
405
- escapeXml
406
- } from "./chunk-AQ37AY7B.js";
407
- import {
408
- DEFAULT_FILE_FILTERING_OPTIONS,
409
- DEFAULT_QWEN_CUSTOM_IGNORE_FILE_NAMES,
410
- QwenIgnoreParser,
411
- WorkspaceContext,
412
- formatQwenIgnoreFileNames,
413
- getQwenIgnoreFileNames,
414
- isPathWithinRoot,
415
- require_ignore
416
- } from "./chunk-UHF5VBKO.js";
452
+ } from "./chunk-XUJNK7Y6.js";
417
453
  import {
418
454
  AgentStatistics,
419
455
  BaseDeclarativeTool,
@@ -432,29 +468,7 @@ import {
432
468
  require_dist,
433
469
  require_fast_deep_equal,
434
470
  require_fast_uri
435
- } from "./chunk-ZRT36RSF.js";
436
- import {
437
- openBrowserSecurely,
438
- shouldAttemptBrowserLaunch
439
- } from "./chunk-NAVJD2PQ.js";
440
- import {
441
- isUnattendedMode,
442
- retryWithBackoff
443
- } from "./chunk-QEWAHAW2.js";
444
- import {
445
- classifyRetryError,
446
- isFallbackEligible
447
- } from "./chunk-FTGU6G45.js";
448
- import {
449
- QUOTA_EXHAUSTED_PREFIX,
450
- formatQuotaExhaustedMessage,
451
- getRateLimitErrorDetails,
452
- getRateLimitRetryDelayMs,
453
- isApiError,
454
- isQuotaExhaustedError,
455
- isRateLimitError,
456
- isStructuredError
457
- } from "./chunk-PSTHNTHF.js";
471
+ } from "./chunk-6HY6IF3Z.js";
458
472
  import {
459
473
  AUTH_ENV_MAPPINGS,
460
474
  AuthType,
@@ -466,24 +480,11 @@ import {
466
480
  createContentGenerator,
467
481
  resetPreloadedContentGenerator,
468
482
  resolveContentGeneratorConfigWithSources
469
- } from "./chunk-VGGNHRYZ.js";
483
+ } from "./chunk-4PKCUT7F.js";
470
484
  import {
471
485
  DEFAULT_QWEN_EMBEDDING_MODEL,
472
486
  DEFAULT_QWEN_MODEL
473
487
  } from "./chunk-F6WFNA7U.js";
474
- import {
475
- atomicWriteFile,
476
- atomicWriteFileSync,
477
- atomicWriteJSON,
478
- renameWithRetry
479
- } from "./chunk-NW7SPXVG.js";
480
- import {
481
- DEFAULT_OPENAI_BASE_URL
482
- } from "./chunk-AXMWHKXA.js";
483
- import {
484
- getToolCallPreparations,
485
- setToolCallPreparations
486
- } from "./chunk-GLCZKT5V.js";
487
488
  import {
488
489
  normalizeMcpToolName,
489
490
  sanitizeToolNameForProvider
@@ -497,18 +498,19 @@ import {
497
498
  parsePositiveIntegerEnvValue,
498
499
  tokenLimit
499
500
  } from "./chunk-FPGTNKCP.js";
500
- import {
501
- combineAbortSignals,
502
- createAbortController,
503
- createChildAbortController
504
- } from "./chunk-DJ2GSRLV.js";
505
501
  import {
506
502
  getOrCreateMcpDispatcher,
507
503
  loadUndici,
508
504
  preloadRuntimeFetchModule,
509
505
  redactProxyError,
510
506
  setResolvedProxyUrlForRuntimeFetch
511
- } from "./chunk-H6BFLALJ.js";
507
+ } from "./chunk-CPHEPGAO.js";
508
+ import {
509
+ atomicWriteFile,
510
+ atomicWriteFileSync,
511
+ atomicWriteJSON,
512
+ renameWithRetry
513
+ } from "./chunk-FDGGZIYW.js";
512
514
  import {
513
515
  endHookSpan,
514
516
  endInteractionSpan,
@@ -518,10 +520,14 @@ import {
518
520
  endToolSpan,
519
521
  getActiveInteractionSpan,
520
522
  initializeTelemetry,
523
+ isBinary,
521
524
  isPerformanceMonitoringActive,
522
525
  isTelemetrySdkInitialized,
526
+ normalizeContent,
523
527
  recordCpuUsage,
528
+ recordInteractionActivity,
524
529
  recordMemoryUsage,
530
+ redactUrlCredentials,
525
531
  refreshSessionContext,
526
532
  runInSubagentSpanContext,
527
533
  runInToolSpanContext,
@@ -533,8 +539,9 @@ import {
533
539
  startToolBlockedOnUserSpan,
534
540
  startToolExecutionSpan,
535
541
  startToolSpan,
542
+ stripAnsiAndControl,
536
543
  truncateSpanError
537
- } from "./chunk-3MJ44LNC.js";
544
+ } from "./chunk-EL5SXY3T.js";
538
545
  import {
539
546
  safeJsonStringify
540
547
  } from "./chunk-HHJLM3WQ.js";
@@ -576,6 +583,7 @@ import {
576
583
  formatTraceparent,
577
584
  getErrorMessage,
578
585
  getErrorStatus,
586
+ getErrorType,
579
587
  getProjectHash,
580
588
  getTraceContext,
581
589
  isAbortError,
@@ -591,7 +599,7 @@ import {
591
599
  tildeifyPath,
592
600
  toFriendlyError,
593
601
  unescapePath
594
- } from "./chunk-YMB77M76.js";
602
+ } from "./chunk-BUQDLC2G.js";
595
603
  import {
596
604
  require_src
597
605
  } from "./chunk-AMDSOFFV.js";
@@ -931,7 +939,7 @@ var require_scan = __commonJS({
931
939
  const scanToEnd = opts.parts === true || opts.scanToEnd === true;
932
940
  const slashes = [];
933
941
  const tokens = [];
934
- const parts = [];
942
+ const parts2 = [];
935
943
  let str = input;
936
944
  let index = -1;
937
945
  let start = 0;
@@ -1188,13 +1196,13 @@ var require_scan = __commonJS({
1188
1196
  state.maxDepth += tokens[idx].depth;
1189
1197
  }
1190
1198
  if (idx !== 0 || value !== "") {
1191
- parts.push(value);
1199
+ parts2.push(value);
1192
1200
  }
1193
1201
  prevIndex = i;
1194
1202
  }
1195
1203
  if (prevIndex && prevIndex + 1 < input.length) {
1196
1204
  const value = input.slice(prevIndex + 1);
1197
- parts.push(value);
1205
+ parts2.push(value);
1198
1206
  if (opts.tokens) {
1199
1207
  tokens[tokens.length - 1].value = value;
1200
1208
  depth(tokens[tokens.length - 1]);
@@ -1202,7 +1210,7 @@ var require_scan = __commonJS({
1202
1210
  }
1203
1211
  }
1204
1212
  state.slashes = slashes;
1205
- state.parts = parts;
1213
+ state.parts = parts2;
1206
1214
  }
1207
1215
  return state;
1208
1216
  }, "scan");
@@ -1241,7 +1249,7 @@ var require_parse = __commonJS({
1241
1249
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1242
1250
  }, "syntaxError");
1243
1251
  var splitTopLevel = /* @__PURE__ */ __name((input) => {
1244
- const parts = [];
1252
+ const parts2 = [];
1245
1253
  let bracket = 0;
1246
1254
  let paren = 0;
1247
1255
  let quote2 = 0;
@@ -1274,7 +1282,7 @@ var require_parse = __commonJS({
1274
1282
  } else if (ch === ")" && paren > 0) {
1275
1283
  paren--;
1276
1284
  } else if (ch === "|" && paren === 0) {
1277
- parts.push(value);
1285
+ parts2.push(value);
1278
1286
  value = "";
1279
1287
  continue;
1280
1288
  }
@@ -1282,8 +1290,8 @@ var require_parse = __commonJS({
1282
1290
  }
1283
1291
  value += ch;
1284
1292
  }
1285
- parts.push(value);
1286
- return parts;
1293
+ parts2.push(value);
1294
+ return parts2;
1287
1295
  }, "splitTopLevel");
1288
1296
  var isPlainBranch = /* @__PURE__ */ __name((branch) => {
1289
1297
  let escaped = false;
@@ -9443,7 +9451,7 @@ var require_brace_expansion = __commonJS({
9443
9451
  function parseCommaParts(str) {
9444
9452
  if (!str)
9445
9453
  return [""];
9446
- var parts = [];
9454
+ var parts2 = [];
9447
9455
  var m2 = balanced("{", "}", str);
9448
9456
  if (!m2)
9449
9457
  return str.split(",");
@@ -9457,8 +9465,8 @@ var require_brace_expansion = __commonJS({
9457
9465
  p2[p2.length - 1] += postParts.shift();
9458
9466
  p2.push.apply(p2, postParts);
9459
9467
  }
9460
- parts.push.apply(parts, p2);
9461
- return parts;
9468
+ parts2.push.apply(parts2, p2);
9469
+ return parts2;
9462
9470
  }
9463
9471
  __name(parseCommaParts, "parseCommaParts");
9464
9472
  function expandTop(str, options2) {
@@ -13964,12 +13972,12 @@ var require_datepart = __commonJS({
13964
13972
  constructor({
13965
13973
  token,
13966
13974
  date,
13967
- parts,
13975
+ parts: parts2,
13968
13976
  locales
13969
13977
  }) {
13970
13978
  this.token = token;
13971
13979
  this.date = date || /* @__PURE__ */ new Date();
13972
- this.parts = parts || [this];
13980
+ this.parts = parts2 || [this];
13973
13981
  this.locales = locales || {};
13974
13982
  }
13975
13983
  up() {
@@ -13983,9 +13991,9 @@ var require_datepart = __commonJS({
13983
13991
  setTo(val) {
13984
13992
  }
13985
13993
  prev() {
13986
- let parts = [].concat(this.parts).reverse();
13987
- const currentIdx = parts.indexOf(this);
13988
- return parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
13994
+ let parts2 = [].concat(this.parts).reverse();
13995
+ const currentIdx = parts2.indexOf(this);
13996
+ return parts2.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
13989
13997
  }
13990
13998
  toString() {
13991
13999
  return String(this.date);
@@ -14390,13 +14398,13 @@ var require_date = __commonJS({
14390
14398
  locales: this.locales
14391
14399
  }) : result[idx] || match2);
14392
14400
  }
14393
- let parts = this.parts.reduce((arr, i) => {
14401
+ let parts2 = this.parts.reduce((arr, i) => {
14394
14402
  if (typeof i === "string" && typeof arr[arr.length - 1] === "string") arr[arr.length - 1] += i;
14395
14403
  else arr.push(i);
14396
14404
  return arr;
14397
14405
  }, []);
14398
14406
  this.parts.splice(0);
14399
- this.parts.push(...parts);
14407
+ this.parts.push(...parts2);
14400
14408
  this.reset();
14401
14409
  }
14402
14410
  moveCursor(n) {
@@ -16499,10 +16507,10 @@ var require_datepart2 = __commonJS({
16499
16507
  static {
16500
16508
  __name(this, "DatePart");
16501
16509
  }
16502
- constructor({ token, date, parts, locales }) {
16510
+ constructor({ token, date, parts: parts2, locales }) {
16503
16511
  this.token = token;
16504
16512
  this.date = date || /* @__PURE__ */ new Date();
16505
- this.parts = parts || [this];
16513
+ this.parts = parts2 || [this];
16506
16514
  this.locales = locales || {};
16507
16515
  }
16508
16516
  up() {
@@ -16516,9 +16524,9 @@ var require_datepart2 = __commonJS({
16516
16524
  setTo(val) {
16517
16525
  }
16518
16526
  prev() {
16519
- let parts = [].concat(this.parts).reverse();
16520
- const currentIdx = parts.indexOf(this);
16521
- return parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
16527
+ let parts2 = [].concat(this.parts).reverse();
16528
+ const currentIdx = parts2.indexOf(this);
16529
+ return parts2.find((part, idx) => idx > currentIdx && part instanceof _DatePart);
16522
16530
  }
16523
16531
  toString() {
16524
16532
  return String(this.date);
@@ -16870,14 +16878,14 @@ var require_date2 = __commonJS({
16870
16878
  let idx = result.findIndex((gr2) => gr2 != null);
16871
16879
  this.parts.push(idx in regexGroups ? regexGroups[idx]({ token: result[idx] || match2, date: this.date, parts: this.parts, locales: this.locales }) : result[idx] || match2);
16872
16880
  }
16873
- let parts = this.parts.reduce((arr, i) => {
16881
+ let parts2 = this.parts.reduce((arr, i) => {
16874
16882
  if (typeof i === "string" && typeof arr[arr.length - 1] === "string")
16875
16883
  arr[arr.length - 1] += i;
16876
16884
  else arr.push(i);
16877
16885
  return arr;
16878
16886
  }, []);
16879
16887
  this.parts.splice(0);
16880
- this.parts.push(...parts);
16888
+ this.parts.push(...parts2);
16881
16889
  this.reset();
16882
16890
  }
16883
16891
  moveCursor(n) {
@@ -19438,9 +19446,9 @@ function getResponseText(response) {
19438
19446
  return null;
19439
19447
  }
19440
19448
  __name(getResponseText, "getResponseText");
19441
- async function flatMapTextParts(parts, transform) {
19449
+ async function flatMapTextParts(parts2, transform) {
19442
19450
  const result = [];
19443
- const partArray = Array.isArray(parts) ? parts : typeof parts === "string" ? [{ text: parts }] : [parts];
19451
+ const partArray = Array.isArray(parts2) ? parts2 : typeof parts2 === "string" ? [{ text: parts2 }] : [parts2];
19444
19452
  for (const part of partArray) {
19445
19453
  let textToProcess;
19446
19454
  if (typeof part === "string") {
@@ -19508,11 +19516,11 @@ function prependToFirstTextPart(prompt, textToPrepend, separator = "\n\n") {
19508
19516
  __name(prependToFirstTextPart, "prependToFirstTextPart");
19509
19517
 
19510
19518
  // packages/core/src/utils/generateContentResponseUtilities.ts
19511
- function getResponseTextFromParts(parts) {
19512
- if (!parts) {
19519
+ function getResponseTextFromParts(parts2) {
19520
+ if (!parts2) {
19513
19521
  return void 0;
19514
19522
  }
19515
- const textSegments = parts.map((part) => part.text).filter((text) => typeof text === "string");
19523
+ const textSegments = parts2.map((part) => part.text).filter((text) => typeof text === "string");
19516
19524
  if (textSegments.length === 0) {
19517
19525
  return void 0;
19518
19526
  }
@@ -19528,12 +19536,12 @@ function sanitizeMediaLabel(value) {
19528
19536
  return cleaned.length > 0 ? cleaned : void 0;
19529
19537
  }
19530
19538
  __name(sanitizeMediaLabel, "sanitizeMediaLabel");
19531
- function getToolResponseDisplayText(parts) {
19532
- if (!parts || parts.length === 0) {
19539
+ function getToolResponseDisplayText(parts2) {
19540
+ if (!parts2 || parts2.length === 0) {
19533
19541
  return void 0;
19534
19542
  }
19535
19543
  const segments = [];
19536
- for (const part of parts) {
19544
+ for (const part of parts2) {
19537
19545
  const fr2 = part.functionResponse;
19538
19546
  if (!fr2) {
19539
19547
  if (typeof part.text === "string" && part.text.length > 0) {
@@ -19568,11 +19576,11 @@ function getToolResponseDisplayText(parts) {
19568
19576
  }
19569
19577
  __name(getToolResponseDisplayText, "getToolResponseDisplayText");
19570
19578
  function getFunctionCalls(response) {
19571
- const parts = response.candidates?.[0]?.content?.parts;
19572
- if (!parts) {
19579
+ const parts2 = response.candidates?.[0]?.content?.parts;
19580
+ if (!parts2) {
19573
19581
  return void 0;
19574
19582
  }
19575
- const functionCallParts = parts.filter((part) => !!part.functionCall).map((part) => part.functionCall);
19583
+ const functionCallParts = parts2.filter((part) => !!part.functionCall).map((part) => part.functionCall);
19576
19584
  if (functionCallParts.length === 2) {
19577
19585
  const [first, second] = functionCallParts;
19578
19586
  const firstHasNameOnly = first.name && (!first.args || Object.keys(first.args).length === 0);
@@ -19943,9 +19951,9 @@ var BaseLlmClient = class {
19943
19951
  );
19944
19952
  }, "onRetry")
19945
19953
  });
19946
- const functionCalls = getFunctionCalls(result);
19947
- if (functionCalls && functionCalls.length > 0) {
19948
- const functionCall = functionCalls.find(
19954
+ const functionCalls2 = getFunctionCalls(result);
19955
+ if (functionCalls2 && functionCalls2.length > 0) {
19956
+ const functionCall = functionCalls2.find(
19949
19957
  (call) => call.name === "respond_in_schema"
19950
19958
  );
19951
19959
  if (functionCall && functionCall.args) {
@@ -20591,12 +20599,12 @@ __name(buildKeepRefs, "buildKeepRefs");
20591
20599
  function buildClearMap(clearRefs) {
20592
20600
  const clearMap = /* @__PURE__ */ new Map();
20593
20601
  for (const ref of clearRefs) {
20594
- let parts = clearMap.get(ref.contentIndex);
20595
- if (!parts) {
20596
- parts = /* @__PURE__ */ new Map();
20597
- clearMap.set(ref.contentIndex, parts);
20602
+ let parts2 = clearMap.get(ref.contentIndex);
20603
+ if (!parts2) {
20604
+ parts2 = /* @__PURE__ */ new Map();
20605
+ clearMap.set(ref.contentIndex, parts2);
20598
20606
  }
20599
- parts.set(ref.partIndex, ref.kind);
20607
+ parts2.set(ref.partIndex, ref.kind);
20600
20608
  }
20601
20609
  return clearMap;
20602
20610
  }
@@ -22577,9 +22585,9 @@ function collectTextSlots(entries, includeTopLevelText = true, excludeBudgetExem
22577
22585
  const slots = [];
22578
22586
  for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
22579
22587
  const entry = entries[entryIndex];
22580
- const parts = entry.responseParts;
22581
- for (let partIndex = 0; partIndex < parts.length; partIndex++) {
22582
- const part = parts[partIndex];
22588
+ const parts2 = entry.responseParts;
22589
+ for (let partIndex = 0; partIndex < parts2.length; partIndex++) {
22590
+ const part = parts2[partIndex];
22583
22591
  if (includeTopLevelText && typeof part.text === "string") {
22584
22592
  slots.push({
22585
22593
  entryIndex,
@@ -22731,9 +22739,9 @@ function replaceTextSlots(entries, slots, allocations) {
22731
22739
  return result;
22732
22740
  }
22733
22741
  __name(replaceTextSlots, "replaceTextSlots");
22734
- function toolResponseTextLength(parts) {
22742
+ function toolResponseTextLength(parts2) {
22735
22743
  return collectTextSlots(
22736
- [{ callId: "", toolName: "", responseParts: parts }],
22744
+ [{ callId: "", toolName: "", responseParts: parts2 }],
22737
22745
  true,
22738
22746
  false
22739
22747
  ).reduce((total, slot) => total + slot.text.length, 0);
@@ -23443,15 +23451,15 @@ init_esbuild_shims();
23443
23451
 
23444
23452
  // packages/core/src/hooks/user-prompt-submit-context.ts
23445
23453
  init_esbuild_shims();
23446
- function stripTrailingUserPromptSubmitContextPart(parts) {
23447
- if (parts.length <= 1) {
23448
- return parts;
23454
+ function stripTrailingUserPromptSubmitContextPart(parts2) {
23455
+ if (parts2.length <= 1) {
23456
+ return parts2;
23449
23457
  }
23450
- const last = parts[parts.length - 1];
23458
+ const last = parts2[parts2.length - 1];
23451
23459
  if (!last || typeof last.text !== "string" || !isUserPromptSubmitContextPartText(last.text)) {
23452
- return parts;
23460
+ return parts2;
23453
23461
  }
23454
- return parts.slice(0, -1);
23462
+ return parts2.slice(0, -1);
23455
23463
  }
23456
23464
  __name(stripTrailingUserPromptSubmitContextPart, "stripTrailingUserPromptSubmitContextPart");
23457
23465
 
@@ -24252,20 +24260,20 @@ wordDiff.equals = function(left, right, options2) {
24252
24260
  };
24253
24261
  wordDiff.tokenize = function(value) {
24254
24262
  var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
24255
- var parts;
24263
+ var parts2;
24256
24264
  if (options2.intlSegmenter) {
24257
24265
  if (options2.intlSegmenter.resolvedOptions().granularity != "word") {
24258
24266
  throw new Error('The segmenter passed must have a granularity of "word"');
24259
24267
  }
24260
- parts = Array.from(options2.intlSegmenter.segment(value), function(segment) {
24268
+ parts2 = Array.from(options2.intlSegmenter.segment(value), function(segment) {
24261
24269
  return segment.segment;
24262
24270
  });
24263
24271
  } else {
24264
- parts = value.match(tokenizeIncludingWhitespace) || [];
24272
+ parts2 = value.match(tokenizeIncludingWhitespace) || [];
24265
24273
  }
24266
24274
  var tokens = [];
24267
24275
  var prevPart = null;
24268
- parts.forEach(function(part) {
24276
+ parts2.forEach(function(part) {
24269
24277
  if (/\s/.test(part)) {
24270
24278
  if (prevPart == null) {
24271
24279
  tokens.push(part);
@@ -25582,17 +25590,17 @@ var MAX_LOG_LIMIT = 200;
25582
25590
  var DEFAULT_LOG_LIMIT = 50;
25583
25591
  var LOG_FORMAT = "%H%x00%h%x00%an%x00%ae%x00%at%x00%s%x00%D%x00%P";
25584
25592
  var LOG_DETAIL_FORMAT = "%H%x00%h%x00%an%x00%ae%x00%at%x00%s%x00%D%x00%P%x00%b";
25585
- function parseLogFields(parts) {
25586
- if (parts.length !== 8) return null;
25593
+ function parseLogFields(parts2) {
25594
+ if (parts2.length !== 8) return null;
25587
25595
  return {
25588
- sha: parts[0],
25589
- shortSha: parts[1],
25590
- authorName: parts[2],
25591
- authorEmail: parts[3],
25592
- authorDate: parseInt(parts[4], 10) || 0,
25593
- subject: parts[5],
25594
- refs: parts[6],
25595
- parents: parts[7] ? parts[7].split(" ").filter(Boolean) : []
25596
+ sha: parts2[0],
25597
+ shortSha: parts2[1],
25598
+ authorName: parts2[2],
25599
+ authorEmail: parts2[3],
25600
+ authorDate: parseInt(parts2[4], 10) || 0,
25601
+ subject: parts2[5],
25602
+ refs: parts2[6],
25603
+ parents: parts2[7] ? parts2[7].split(" ").filter(Boolean) : []
25596
25604
  };
25597
25605
  }
25598
25606
  __name(parseLogFields, "parseLogFields");
@@ -25650,10 +25658,10 @@ async function fetchGitCommitDetail(cwd, sha) {
25650
25658
  gitRoot
25651
25659
  );
25652
25660
  if (metaRaw === null) return null;
25653
- const parts = metaRaw.split("\0");
25654
- if (parts.at(-1) === "") parts.pop();
25655
- if (parts.length !== 9) return null;
25656
- const parents = parts[7] ? parts[7].split(" ").filter(Boolean) : [];
25661
+ const parts2 = metaRaw.split("\0");
25662
+ if (parts2.at(-1) === "") parts2.pop();
25663
+ if (parts2.length !== 9) return null;
25664
+ const parents = parts2[7] ? parts2[7].split(" ").filter(Boolean) : [];
25657
25665
  const diffTreeArgs = parents.length > 1 ? [
25658
25666
  "--no-optional-locks",
25659
25667
  "diff-tree",
@@ -25706,15 +25714,15 @@ async function fetchGitCommitDetail(cwd, sha) {
25706
25714
  });
25707
25715
  }
25708
25716
  return {
25709
- sha: parts[0],
25710
- shortSha: parts[1],
25711
- authorName: parts[2],
25712
- authorEmail: parts[3],
25713
- authorDate: parseInt(parts[4], 10) || 0,
25714
- subject: parts[5],
25715
- refs: parts[6],
25717
+ sha: parts2[0],
25718
+ shortSha: parts2[1],
25719
+ authorName: parts2[2],
25720
+ authorEmail: parts2[3],
25721
+ authorDate: parseInt(parts2[4], 10) || 0,
25722
+ subject: parts2[5],
25723
+ refs: parts2[6],
25716
25724
  parents,
25717
- body: parts[8].replace(/\n$/, ""),
25725
+ body: parts2[8].replace(/\n$/, ""),
25718
25726
  files,
25719
25727
  filesCount,
25720
25728
  linesAdded,
@@ -28565,6 +28573,245 @@ function isUserPromptRecord(record2) {
28565
28573
  }
28566
28574
  __name(isUserPromptRecord, "isUserPromptRecord");
28567
28575
 
28576
+ // packages/core/src/services/branch-points.ts
28577
+ init_esbuild_shims();
28578
+ function nonEmptyString(value) {
28579
+ return typeof value === "string" && value.length > 0 ? value : void 0;
28580
+ }
28581
+ __name(nonEmptyString, "nonEmptyString");
28582
+ function parts(record2) {
28583
+ return (record2.message?.parts ?? []).filter(
28584
+ (part) => part !== null && typeof part === "object"
28585
+ );
28586
+ }
28587
+ __name(parts, "parts");
28588
+ function functionCalls(record2) {
28589
+ return parts(record2).flatMap((part) => {
28590
+ const call = part.functionCall;
28591
+ if (!call) return [];
28592
+ return [
28593
+ {
28594
+ ...nonEmptyString(call.id) ? { id: call.id } : {},
28595
+ ...nonEmptyString(call.name) ? { name: call.name } : {}
28596
+ }
28597
+ ];
28598
+ });
28599
+ }
28600
+ __name(functionCalls, "functionCalls");
28601
+ function functionResponses(record2) {
28602
+ return parts(record2).flatMap((part) => {
28603
+ const response = part.functionResponse;
28604
+ if (!response) return [];
28605
+ return [
28606
+ {
28607
+ ...nonEmptyString(response.id) ? { id: response.id } : {},
28608
+ ...nonEmptyString(response.name) ? { name: response.name } : {}
28609
+ }
28610
+ ];
28611
+ });
28612
+ }
28613
+ __name(functionResponses, "functionResponses");
28614
+ function hasVisibleText(record2) {
28615
+ return parts(record2).some(
28616
+ (part) => part.thought !== true && typeof part.text === "string" && part.text.trim().length > 0
28617
+ );
28618
+ }
28619
+ __name(hasVisibleText, "hasVisibleText");
28620
+ function uniqueNameMatch(pending, matchingIndexes) {
28621
+ if (matchingIndexes.length === 1) return matchingIndexes[0];
28622
+ const freshIndexes = matchingIndexes.filter(
28623
+ (candidateIndex) => pending[candidateIndex]?.carriedFromPrefix !== true
28624
+ );
28625
+ return freshIndexes.length === 1 ? freshIndexes[0] : -1;
28626
+ }
28627
+ __name(uniqueNameMatch, "uniqueNameMatch");
28628
+ function closeToolCall(pending, response) {
28629
+ let index = -1;
28630
+ if (response.id !== void 0) {
28631
+ index = pending.findIndex((call) => call.id === response.id);
28632
+ if (index < 0 && response.name !== void 0) {
28633
+ const matchingIndexes = pending.flatMap(
28634
+ (call, candidateIndex) => call.id === void 0 && call.name === response.name ? [candidateIndex] : []
28635
+ );
28636
+ index = uniqueNameMatch(pending, matchingIndexes);
28637
+ }
28638
+ } else if (response.name !== void 0) {
28639
+ const matchingIndexes = pending.flatMap(
28640
+ (call, candidateIndex) => call.name === response.name ? [candidateIndex] : []
28641
+ );
28642
+ index = uniqueNameMatch(pending, matchingIndexes);
28643
+ }
28644
+ if (index < 0) return false;
28645
+ pending.splice(index, 1);
28646
+ return true;
28647
+ }
28648
+ __name(closeToolCall, "closeToolCall");
28649
+ function resolveCompletedTurnBranchCandidateInRange(input) {
28650
+ const {
28651
+ activeChain,
28652
+ startIndex,
28653
+ endIndex,
28654
+ startExclusiveRecordUuid,
28655
+ pendingCallsAtStart
28656
+ } = input;
28657
+ const pendingCalls = pendingCallsAtStart.map((call) => ({
28658
+ ...call,
28659
+ carriedFromPrefix: true
28660
+ }));
28661
+ let lastToolResultIndex = startIndex;
28662
+ for (let index = startIndex + 1; index <= endIndex; index++) {
28663
+ const record2 = activeChain[index];
28664
+ pendingCalls.push(...functionCalls(record2));
28665
+ const responses = functionResponses(record2);
28666
+ if (record2.type === "tool_result" || responses.length > 0) {
28667
+ lastToolResultIndex = index;
28668
+ }
28669
+ for (const response of responses) {
28670
+ if (!closeToolCall(pendingCalls, response)) return void 0;
28671
+ }
28672
+ }
28673
+ if (pendingCalls.some((call) => !call.carriedFromPrefix)) return void 0;
28674
+ let assistantRecordUuid;
28675
+ for (let index = lastToolResultIndex + 1; index <= endIndex; index++) {
28676
+ const record2 = activeChain[index];
28677
+ if (record2.type !== "assistant" || functionCalls(record2).length > 0 || !hasVisibleText(record2)) {
28678
+ continue;
28679
+ }
28680
+ if (assistantRecordUuid !== void 0) return void 0;
28681
+ assistantRecordUuid = record2.uuid;
28682
+ }
28683
+ if (assistantRecordUuid === void 0) return void 0;
28684
+ return {
28685
+ startExclusiveRecordUuid,
28686
+ endInclusiveRecordUuid: activeChain[endIndex].uuid,
28687
+ assistantRecordUuid
28688
+ };
28689
+ }
28690
+ __name(resolveCompletedTurnBranchCandidateInRange, "resolveCompletedTurnBranchCandidateInRange");
28691
+ function updatePendingBranchToolCalls(pendingCalls, record2) {
28692
+ pendingCalls.push(...functionCalls(record2));
28693
+ for (const response of functionResponses(record2)) {
28694
+ closeToolCall(pendingCalls, response);
28695
+ }
28696
+ }
28697
+ __name(updatePendingBranchToolCalls, "updatePendingBranchToolCalls");
28698
+ function collectPendingBranchToolCalls(records) {
28699
+ const pendingCalls = [];
28700
+ for (const record2 of records) {
28701
+ updatePendingBranchToolCalls(pendingCalls, record2);
28702
+ }
28703
+ return pendingCalls;
28704
+ }
28705
+ __name(collectPendingBranchToolCalls, "collectPendingBranchToolCalls");
28706
+ function resolveCompletedTurnBranchCandidateFromRecords(input) {
28707
+ if (input.records.length === 0) return void 0;
28708
+ return resolveCompletedTurnBranchCandidateInRange({
28709
+ activeChain: input.records,
28710
+ startIndex: -1,
28711
+ endIndex: input.records.length - 1,
28712
+ startExclusiveRecordUuid: input.startExclusiveRecordUuid,
28713
+ pendingCallsAtStart: input.pendingCallsAtStart
28714
+ });
28715
+ }
28716
+ __name(resolveCompletedTurnBranchCandidateFromRecords, "resolveCompletedTurnBranchCandidateFromRecords");
28717
+ function parseBranchCheckpointPayload(value) {
28718
+ if (!value || typeof value !== "object") return void 0;
28719
+ const payload = value;
28720
+ const start = payload["startExclusiveRecordUuid"];
28721
+ const assistantRecordUuid = payload["assistantRecordUuid"];
28722
+ if (payload["v"] !== 1 || start !== null && (typeof start !== "string" || start.length === 0) || typeof assistantRecordUuid !== "string" || assistantRecordUuid.length === 0) {
28723
+ return void 0;
28724
+ }
28725
+ return {
28726
+ v: 1,
28727
+ startExclusiveRecordUuid: start,
28728
+ assistantRecordUuid
28729
+ };
28730
+ }
28731
+ __name(parseBranchCheckpointPayload, "parseBranchCheckpointPayload");
28732
+ function resolveBranchPoints(activeChain) {
28733
+ const points = /* @__PURE__ */ new Map();
28734
+ const recordIndexes = /* @__PURE__ */ new Map();
28735
+ for (let index = 0; index < activeChain.length; index++) {
28736
+ const record2 = activeChain[index];
28737
+ if (typeof record2.uuid !== "string" || record2.uuid.length === 0 || recordIndexes.has(record2.uuid)) {
28738
+ return points;
28739
+ }
28740
+ recordIndexes.set(record2.uuid, index);
28741
+ }
28742
+ const checkpoints = [];
28743
+ const boundaryIndexes = /* @__PURE__ */ new Set();
28744
+ for (let index = 0; index < activeChain.length; index++) {
28745
+ const checkpoint = activeChain[index];
28746
+ if (checkpoint.type !== "system" || checkpoint.subtype !== "branch_checkpoint" || checkpoint.parentUuid === null || activeChain[index - 1]?.uuid !== checkpoint.parentUuid) {
28747
+ continue;
28748
+ }
28749
+ const payload = parseBranchCheckpointPayload(checkpoint.systemPayload);
28750
+ if (!payload) continue;
28751
+ const startIndex = payload.startExclusiveRecordUuid === null ? -1 : recordIndexes.get(payload.startExclusiveRecordUuid) ?? -1;
28752
+ if (payload.startExclusiveRecordUuid !== null && (startIndex < 0 || startIndex >= index - 1)) {
28753
+ continue;
28754
+ }
28755
+ checkpoints.push({
28756
+ checkpoint,
28757
+ checkpointIndex: index,
28758
+ startIndex,
28759
+ payload
28760
+ });
28761
+ if (startIndex >= 0) boundaryIndexes.add(startIndex);
28762
+ }
28763
+ const pendingCallsAtBoundary = /* @__PURE__ */ new Map();
28764
+ const pendingCalls = [];
28765
+ for (let index = 0; index < activeChain.length; index++) {
28766
+ const record2 = activeChain[index];
28767
+ pendingCalls.push(...functionCalls(record2));
28768
+ for (const response of functionResponses(record2)) {
28769
+ closeToolCall(pendingCalls, response);
28770
+ }
28771
+ if (boundaryIndexes.has(index)) {
28772
+ pendingCallsAtBoundary.set(
28773
+ index,
28774
+ pendingCalls.map((call) => ({ ...call }))
28775
+ );
28776
+ }
28777
+ }
28778
+ const checkpointByAssistantUuid = /* @__PURE__ */ new Map();
28779
+ for (const {
28780
+ checkpoint,
28781
+ checkpointIndex,
28782
+ startIndex,
28783
+ payload
28784
+ } of checkpoints) {
28785
+ const candidate = resolveCompletedTurnBranchCandidateInRange({
28786
+ activeChain,
28787
+ startIndex,
28788
+ endIndex: checkpointIndex - 1,
28789
+ startExclusiveRecordUuid: payload.startExclusiveRecordUuid,
28790
+ pendingCallsAtStart: startIndex < 0 ? [] : pendingCallsAtBoundary.get(startIndex) ?? []
28791
+ });
28792
+ if (!candidate || candidate.assistantRecordUuid !== payload.assistantRecordUuid) {
28793
+ continue;
28794
+ }
28795
+ const previousCheckpoint = checkpointByAssistantUuid.get(
28796
+ candidate.assistantRecordUuid
28797
+ );
28798
+ if (previousCheckpoint !== void 0) {
28799
+ points.delete(previousCheckpoint);
28800
+ continue;
28801
+ }
28802
+ points.set(checkpoint.uuid, {
28803
+ ...candidate,
28804
+ checkpointUuid: checkpoint.uuid
28805
+ });
28806
+ checkpointByAssistantUuid.set(
28807
+ candidate.assistantRecordUuid,
28808
+ checkpoint.uuid
28809
+ );
28810
+ }
28811
+ return points;
28812
+ }
28813
+ __name(resolveBranchPoints, "resolveBranchPoints");
28814
+
28568
28815
  // packages/core/src/services/session-transcript-reader.ts
28569
28816
  var SESSION_TRANSCRIPT_DEFAULT_LIMIT = 100;
28570
28817
  var SESSION_TRANSCRIPT_MAX_LIMIT = 500;
@@ -28731,6 +28978,63 @@ function getExpandedPageBytes() {
28731
28978
  return expandedPageBytesForTest ?? SESSION_TRANSCRIPT_MAX_EXPANDED_PAGE_BYTES;
28732
28979
  }
28733
28980
  __name(getExpandedPageBytes, "getExpandedPageBytes");
28981
+ function projectBranchPointParts(record2) {
28982
+ return (record2.message?.parts ?? []).flatMap((rawPart) => {
28983
+ const projected = [];
28984
+ if (rawPart === null || typeof rawPart !== "object") return projected;
28985
+ const part = rawPart;
28986
+ if (part.functionCall) {
28987
+ projected.push({
28988
+ functionCall: {
28989
+ ...part.functionCall.id !== void 0 ? { id: part.functionCall.id } : {},
28990
+ ...part.functionCall.name !== void 0 ? { name: part.functionCall.name } : {}
28991
+ }
28992
+ });
28993
+ }
28994
+ if (part.functionResponse) {
28995
+ projected.push({
28996
+ functionResponse: {
28997
+ ...part.functionResponse.id !== void 0 ? { id: part.functionResponse.id } : {},
28998
+ ...part.functionResponse.name !== void 0 ? { name: part.functionResponse.name } : {}
28999
+ }
29000
+ });
29001
+ }
29002
+ if (record2.type === "assistant" && part.thought !== true && typeof part.text === "string" && part.text.trim().length > 0) {
29003
+ projected.push({ text: "visible" });
29004
+ }
29005
+ return projected;
29006
+ });
29007
+ }
29008
+ __name(projectBranchPointParts, "projectBranchPointParts");
29009
+ function projectBranchPointRecord(record2) {
29010
+ const parts2 = projectBranchPointParts(record2);
29011
+ return {
29012
+ uuid: record2.uuid,
29013
+ parentUuid: record2.parentUuid,
29014
+ type: record2.type,
29015
+ ...record2.subtype !== void 0 ? { subtype: record2.subtype } : {},
29016
+ ...parts2.length > 0 ? { message: { parts: parts2 } } : {},
29017
+ ...record2.subtype === "branch_checkpoint" ? { systemPayload: record2.systemPayload } : {}
29018
+ };
29019
+ }
29020
+ __name(projectBranchPointRecord, "projectBranchPointRecord");
29021
+ function appendBranchPointRecord(records, record2) {
29022
+ const projected = projectBranchPointRecord(record2);
29023
+ const existing = records.get(record2.uuid);
29024
+ if (!existing) {
29025
+ records.set(record2.uuid, projected);
29026
+ return;
29027
+ }
29028
+ const parts2 = [
29029
+ ...existing.message?.parts ?? [],
29030
+ ...projected.message?.parts ?? []
29031
+ ];
29032
+ records.set(record2.uuid, {
29033
+ ...existing,
29034
+ ...parts2.length > 0 ? { message: { parts: parts2 } } : {}
29035
+ });
29036
+ }
29037
+ __name(appendBranchPointRecord, "appendBranchPointRecord");
28734
29038
  function makeSessionTranscriptNotFoundError(sessionId) {
28735
29039
  const error = new Error(
28736
29040
  `ENOENT: no such file or directory, open '${sessionId}.jsonl'`
@@ -29180,6 +29484,12 @@ function estimateIndexCacheBytes(index) {
29180
29484
  for (const [uuid, entry] of index.byUuid) {
29181
29485
  total += INDEX_ENTRY_BASE_BYTES + INDEX_HINT_BASE_BYTES * 2 + (entry.goalEvidenceHint.parsedGoalContext ? INDEX_HINT_BASE_BYTES : 0) + INDEX_MAP_ENTRY_BYTES + INDEX_CONTAINER_BASE_BYTES + entry.segments.length * INDEX_CONTAINER_SLOT_BYTES + estimateStringBytes(uuid) + estimateStringBytes(entry.parentUuid) + estimateStringBytes(entry.type) + estimateStringBytes(entry.subtype) + estimateStringBytes(entry.turnHint.turnParentUuid) + estimateStringBytes(entry.turnHint.backgroundNotificationTaskId) + estimateStringBytes(entry.goalEvidenceHint.parsedGoalContext?.goalId) + estimateStringBytes(entry.goalEvidenceHint.parsedGoalContext?.turnId) + estimateStringBytes(entry.goalEvidenceHint.claimedGoalId) + estimateStringBytes(entry.goalEvidenceHint.provenance) + entry.segments.length * INDEX_SEGMENT_BYTES;
29182
29486
  }
29487
+ for (const [
29488
+ assistantUuid,
29489
+ checkpointUuid
29490
+ ] of index.branchPointsByAssistantUuid) {
29491
+ total += INDEX_ENTRY_BASE_BYTES + estimateStringBytes(assistantUuid) + estimateStringBytes(checkpointUuid);
29492
+ }
29183
29493
  return total;
29184
29494
  }
29185
29495
  __name(estimateIndexCacheBytes, "estimateIndexCacheBytes");
@@ -29416,6 +29726,7 @@ async function buildIndex(params) {
29416
29726
  `index build start session=${sessionId} snapshotSize=${snapshotSize}`
29417
29727
  );
29418
29728
  const byUuid = /* @__PURE__ */ new Map();
29729
+ const branchPointRecords = /* @__PURE__ */ new Map();
29419
29730
  const goalEvidenceAccumulators = /* @__PURE__ */ new Map();
29420
29731
  let sequence = 0;
29421
29732
  const physicalRecords = [];
@@ -29442,6 +29753,10 @@ async function buildIndex(params) {
29442
29753
  }
29443
29754
  const sideTaskSource = record2.type === "system" && record2.subtype === "session_source" && isObjectRecord(record2.systemPayload) && record2.systemPayload["sourceType"] === "side_task";
29444
29755
  if (isTranscriptConversationRecord(record2)) {
29756
+ appendBranchPointRecord(
29757
+ branchPointRecords,
29758
+ record2
29759
+ );
29445
29760
  if (record2.timestamp) startTime ??= record2.timestamp;
29446
29761
  leafUuid = record2.uuid;
29447
29762
  }
@@ -29557,8 +29872,18 @@ async function buildIndex(params) {
29557
29872
  `active chain terminated: cycle session=${sessionId} uuid=${chain.cycleUuid}`
29558
29873
  );
29559
29874
  }
29875
+ const branchPointsByAssistantUuid = new Map(
29876
+ [
29877
+ ...resolveBranchPoints(
29878
+ replayUuids.flatMap((uuid) => {
29879
+ const record2 = branchPointRecords.get(uuid);
29880
+ return record2 ? [record2] : [];
29881
+ })
29882
+ ).values()
29883
+ ].map((point) => [point.assistantRecordUuid, point.checkpointUuid])
29884
+ );
29560
29885
  debugLogger14.debug(
29561
- `index build complete session=${sessionId} records=${byUuid.size} runtime=${runtimeUuids.length} replay=${replayUuids.length} gaps=${gaps.length}`
29886
+ `index build complete session=${sessionId} records=${byUuid.size} runtime=${runtimeUuids.length} replay=${replayUuids.length} gaps=${gaps.length} branchPoints=${branchPointsByAssistantUuid.size}`
29562
29887
  );
29563
29888
  await indexBuildCompleteHookForTest?.(filePath);
29564
29889
  return {
@@ -29575,7 +29900,8 @@ async function buildIndex(params) {
29575
29900
  restoreStartTime,
29576
29901
  startTime,
29577
29902
  lastUpdated,
29578
- byUuid
29903
+ byUuid,
29904
+ branchPointsByAssistantUuid
29579
29905
  };
29580
29906
  }
29581
29907
  __name(buildIndex, "buildIndex");
@@ -30350,6 +30676,13 @@ var SessionTranscriptReader = class {
30350
30676
  const pageUuids = backwardPage?.uuids ?? selectPageUuids(index, position, limit, maxBytes);
30351
30677
  const nextPosition = backwardPage?.nextPosition ?? position + pageUuids.length;
30352
30678
  const records = await readAggregatedRecords(index, pageUuids);
30679
+ const pageBranchPoints = /* @__PURE__ */ Object.create(null);
30680
+ for (const record2 of records) {
30681
+ const checkpointUuid = index.branchPointsByAssistantUuid.get(record2.uuid);
30682
+ if (checkpointUuid !== void 0) {
30683
+ pageBranchPoints[record2.uuid] = checkpointUuid;
30684
+ }
30685
+ }
30353
30686
  const backwardGoalState = direction === "backward" ? await readGoalStatePayloadBeforePosition(index, nextPosition) : void 0;
30354
30687
  const hasMore = direction === "backward" ? nextPosition > 0 : nextPosition < index.replayUuids.length;
30355
30688
  const nextCursorState = hasMore ? {
@@ -30381,7 +30714,8 @@ var SessionTranscriptReader = class {
30381
30714
  }
30382
30715
  } : cursor?.replay !== void 0 ? { replay: cursor.replay } : {},
30383
30716
  startTime: index.startTime,
30384
- lastUpdated: index.lastUpdated
30717
+ lastUpdated: index.lastUpdated,
30718
+ ...Object.keys(pageBranchPoints).length > 0 ? { branchPointsByAssistantUuid: pageBranchPoints } : {}
30385
30719
  };
30386
30720
  }
30387
30721
  };
@@ -32312,58 +32646,150 @@ var SessionWriterLease = class _SessionWriterLease {
32312
32646
 
32313
32647
  // packages/core/src/services/sessionService.ts
32314
32648
  var debugLogger16 = createDebugLogger("SESSION");
32649
+ var BranchPointInvalidError = class extends Error {
32650
+ constructor(recordId) {
32651
+ super(`Invalid or inactive branch point: ${recordId}`);
32652
+ this.recordId = recordId;
32653
+ this.name = "BranchPointInvalidError";
32654
+ }
32655
+ static {
32656
+ __name(this, "BranchPointInvalidError");
32657
+ }
32658
+ };
32315
32659
  var MAX_FILES_TO_PROCESS = 1e4;
32316
32660
  var SESSION_LIST_CANCEL_YIELD_INTERVAL = 128;
32317
32661
  var SESSION_TITLE_MAX_LENGTH = 200;
32318
32662
  var SESSION_FILE_PATTERN = /^[0-9a-fA-F-]{32,36}\.jsonl$/;
32319
32663
  var MAX_PROMPT_SCAN_LINES = 10;
32320
32664
  var TAIL_READ_SIZE = 64 * 1024;
32321
- async function copyFileHistoryBackups(sourceSessionId, targetSessionId) {
32322
- const fsPromises7 = await import("node:fs/promises");
32665
+ async function pathExists2(filePath) {
32666
+ try {
32667
+ await fs12.promises.access(filePath);
32668
+ return true;
32669
+ } catch (error) {
32670
+ if (error.code === "ENOENT") return false;
32671
+ throw error;
32672
+ }
32673
+ }
32674
+ __name(pathExists2, "pathExists");
32675
+ async function fsyncPath(filePath) {
32676
+ const handle = await fs12.promises.open(filePath, "r");
32677
+ try {
32678
+ await handle.sync();
32679
+ } finally {
32680
+ await handle.close();
32681
+ }
32682
+ }
32683
+ __name(fsyncPath, "fsyncPath");
32684
+ async function fsyncDirectoryBestEffort(directory) {
32685
+ try {
32686
+ await fsyncPath(directory);
32687
+ } catch (error) {
32688
+ if (process.platform !== "win32") throw error;
32689
+ }
32690
+ }
32691
+ __name(fsyncDirectoryBestEffort, "fsyncDirectoryBestEffort");
32692
+ function validatedBackupPath(directory, name) {
32693
+ if (name.length === 0 || path12.basename(name) !== name) {
32694
+ throw new Error(`Invalid file-history backup name: ${name}`);
32695
+ }
32696
+ const resolvedDirectory = path12.resolve(directory);
32697
+ const resolved = path12.resolve(directory, name);
32698
+ if (path12.dirname(resolved) !== resolvedDirectory) {
32699
+ throw new Error(`File-history backup escapes its directory: ${name}`);
32700
+ }
32701
+ return resolved;
32702
+ }
32703
+ __name(validatedBackupPath, "validatedBackupPath");
32704
+ async function copyFileHistoryBackupsToStaging(sourceSessionId, targetDirectory, backupNames, onMissing) {
32705
+ const copiedNames = /* @__PURE__ */ new Set();
32706
+ if (backupNames.size === 0) return copiedNames;
32323
32707
  const sourceDir = path12.join(
32324
32708
  Storage.getGlobalQwenDir(),
32325
32709
  FILE_HISTORY_DIR,
32326
32710
  sourceSessionId
32327
32711
  );
32328
- const targetDir = path12.join(
32329
- Storage.getGlobalQwenDir(),
32330
- FILE_HISTORY_DIR,
32331
- targetSessionId
32332
- );
32333
- let entries;
32334
- try {
32335
- entries = await fsPromises7.readdir(sourceDir);
32336
- } catch (e) {
32337
- if (e.code === "ENOENT") return;
32338
- debugLogger16.warn(`copyFileHistoryBackups: readdir failed: ${e}`);
32339
- return;
32340
- }
32341
- if (entries.length === 0) return;
32342
- try {
32343
- await fsPromises7.mkdir(targetDir, { recursive: true });
32344
- } catch (e) {
32345
- debugLogger16.warn(`copyFileHistoryBackups: mkdir failed: ${e}`);
32346
- return;
32347
- }
32348
- await Promise.all(
32349
- entries.map(async (name) => {
32350
- const src = path12.join(sourceDir, name);
32351
- const dst = path12.join(targetDir, name);
32712
+ const copyBuffer = Buffer.alloc(64 * 1024);
32713
+ let stagingCreated = false;
32714
+ const ensureStaging = /* @__PURE__ */ __name(async () => {
32715
+ if (stagingCreated) return;
32716
+ await fs12.promises.mkdir(targetDirectory, {
32717
+ recursive: false,
32718
+ mode: 448
32719
+ });
32720
+ stagingCreated = true;
32721
+ }, "ensureStaging");
32722
+ for (const name of backupNames) {
32723
+ const source = validatedBackupPath(sourceDir, name);
32724
+ const target = validatedBackupPath(targetDirectory, name);
32725
+ let sourceHandle;
32726
+ try {
32727
+ sourceHandle = await fs12.promises.open(
32728
+ source,
32729
+ fs12.constants.O_RDONLY | (process.platform === "win32" ? 0 : fs12.constants.O_NOFOLLOW)
32730
+ );
32731
+ } catch (error) {
32732
+ const code = error.code;
32733
+ if (code === "ENOENT" || code === "ELOOP") {
32734
+ onMissing(name);
32735
+ continue;
32736
+ }
32737
+ throw error;
32738
+ }
32739
+ try {
32740
+ const sourceStat = await sourceHandle.stat();
32741
+ let pathStat;
32352
32742
  try {
32353
- await fsPromises7.link(src, dst);
32354
- } catch {
32355
- try {
32356
- await fsPromises7.copyFile(src, dst);
32357
- } catch (copyErr) {
32358
- debugLogger16.warn(
32359
- `copyFileHistoryBackups: failed to copy ${name}: ${copyErr}`
32743
+ pathStat = await fs12.promises.lstat(source);
32744
+ } catch (error) {
32745
+ if (error.code !== "ENOENT") throw error;
32746
+ onMissing(name);
32747
+ continue;
32748
+ }
32749
+ if (!sourceStat.isFile() || !pathStat.isFile() || sourceStat.dev !== pathStat.dev || sourceStat.ino !== pathStat.ino) {
32750
+ onMissing(name);
32751
+ continue;
32752
+ }
32753
+ await ensureStaging();
32754
+ const targetHandle = await fs12.promises.open(target, "wx", 384);
32755
+ try {
32756
+ let sourceOffset = 0;
32757
+ while (true) {
32758
+ const { bytesRead } = await sourceHandle.read(
32759
+ copyBuffer,
32760
+ 0,
32761
+ copyBuffer.length,
32762
+ sourceOffset
32360
32763
  );
32764
+ if (bytesRead === 0) break;
32765
+ let written = 0;
32766
+ while (written < bytesRead) {
32767
+ const result = await targetHandle.write(
32768
+ copyBuffer,
32769
+ written,
32770
+ bytesRead - written,
32771
+ null
32772
+ );
32773
+ if (result.bytesWritten === 0) {
32774
+ throw new Error(`Failed to copy file-history backup: ${name}`);
32775
+ }
32776
+ written += result.bytesWritten;
32777
+ }
32778
+ sourceOffset += bytesRead;
32361
32779
  }
32780
+ await targetHandle.chmod(sourceStat.mode & 4095);
32781
+ await targetHandle.sync();
32782
+ } finally {
32783
+ await targetHandle.close();
32362
32784
  }
32363
- })
32364
- );
32785
+ copiedNames.add(name);
32786
+ } finally {
32787
+ await sourceHandle.close();
32788
+ }
32789
+ }
32790
+ return copiedNames;
32365
32791
  }
32366
- __name(copyFileHistoryBackups, "copyFileHistoryBackups");
32792
+ __name(copyFileHistoryBackupsToStaging, "copyFileHistoryBackupsToStaging");
32367
32793
  var SessionService = class {
32368
32794
  static {
32369
32795
  __name(this, "SessionService");
@@ -33151,7 +33577,7 @@ var SessionService = class {
33151
33577
  );
33152
33578
  }
33153
33579
  const lastMessage = messages[messages.length - 1];
33154
- stats ??= fs12.statSync(filePath);
33580
+ stats ??= await fs12.promises.stat(filePath);
33155
33581
  const conversation = {
33156
33582
  sessionId: firstRecord.sessionId,
33157
33583
  projectHash: this.projectHash,
@@ -33498,11 +33924,33 @@ var SessionService = class {
33498
33924
  `Source session does not belong to current project: ${sourceSessionId}`
33499
33925
  );
33500
33926
  }
33501
- const { messages: activeMessages } = this.reconstructHistory(records);
33502
- const sourceRecords = includeActiveSideArtifactRecords(
33503
- records,
33927
+ const { messages: currentActiveMessages } = this.reconstructHistory(records);
33928
+ let boundedRecords = records;
33929
+ let activeMessages = currentActiveMessages;
33930
+ if (options2.atRecordId !== void 0) {
33931
+ const point = resolveBranchPoints(currentActiveMessages).get(
33932
+ options2.atRecordId
33933
+ );
33934
+ if (!point) throw new BranchPointInvalidError(options2.atRecordId);
33935
+ const matchingIndex = records.findIndex(
33936
+ (record2) => record2.uuid === options2.atRecordId
33937
+ );
33938
+ if (matchingIndex < 0) {
33939
+ throw new BranchPointInvalidError(options2.atRecordId);
33940
+ }
33941
+ boundedRecords = records.slice(0, matchingIndex + 1);
33942
+ activeMessages = this.reconstructHistory(boundedRecords, {
33943
+ leafUuid: options2.atRecordId
33944
+ }).messages;
33945
+ if (activeMessages.at(-1)?.uuid !== options2.atRecordId) {
33946
+ throw new BranchPointInvalidError(options2.atRecordId);
33947
+ }
33948
+ }
33949
+ const preFilterRecords = includeActiveSideArtifactRecords(
33950
+ boundedRecords,
33504
33951
  activeMessages
33505
- ).filter(
33952
+ );
33953
+ const sourceRecords = preFilterRecords.filter(
33506
33954
  // A fork is a fresh top-level session with its own creation metadata.
33507
33955
  // Inheriting either record would falsely attribute the fork to the
33508
33956
  // source session's parent or creator.
@@ -33527,22 +33975,47 @@ var SessionService = class {
33527
33975
  } : void 0;
33528
33976
  let prevUuid = sourceRecord?.uuid ?? null;
33529
33977
  const remappedArtifactIds = /* @__PURE__ */ new Map();
33978
+ const retainedUuids = new Set(sourceRecords.map((record2) => record2.uuid));
33979
+ const nearestRetainedPredecessor = /* @__PURE__ */ new Map();
33980
+ {
33981
+ let lastRetained = null;
33982
+ for (const record2 of preFilterRecords) {
33983
+ if (retainedUuids.has(record2.uuid) && !isSessionArtifactRecord(record2)) {
33984
+ lastRetained = record2.uuid;
33985
+ } else {
33986
+ nearestRetainedPredecessor.set(record2.uuid, lastRetained);
33987
+ }
33988
+ }
33989
+ }
33530
33990
  const forked = [
33531
33991
  ...sourceRecord ? [sourceRecord] : [],
33532
33992
  ...sourceRecords.map((record2) => {
33533
33993
  const isArtifactRecord = isSessionArtifactRecord(record2);
33534
- const systemPayload = remapSystemPayloadForFork(
33994
+ let systemPayload = remapSystemPayloadForFork(
33535
33995
  record2,
33536
33996
  sourceSessionId,
33537
33997
  newSessionId,
33538
33998
  remappedArtifactIds
33539
33999
  );
34000
+ if (record2.subtype === "branch_checkpoint") {
34001
+ const checkpoint = parseBranchCheckpointPayload(systemPayload);
34002
+ if (checkpoint) {
34003
+ let boundary = checkpoint.startExclusiveRecordUuid;
34004
+ if (boundary !== null && !retainedUuids.has(boundary)) {
34005
+ boundary = nearestRetainedPredecessor.get(boundary) ?? null;
34006
+ }
34007
+ systemPayload = {
34008
+ ...checkpoint,
34009
+ startExclusiveRecordUuid: boundary
34010
+ };
34011
+ }
34012
+ }
33540
34013
  const next = {
33541
34014
  ...record2,
33542
34015
  sessionId: newSessionId,
33543
34016
  cwd: this.projectRoot,
33544
34017
  systemPayload,
33545
- parentUuid: isArtifactRecord ? record2.parentUuid : prevUuid,
34018
+ parentUuid: isArtifactRecord && record2.parentUuid !== null && retainedUuids.has(record2.parentUuid) ? record2.parentUuid : prevUuid,
33546
34019
  forkedFrom: {
33547
34020
  sessionId: sourceSessionId,
33548
34021
  messageUuid: record2.uuid
@@ -33554,7 +34027,7 @@ var SessionService = class {
33554
34027
  return next;
33555
34028
  })
33556
34029
  ];
33557
- const sourceSession = await this.loadSession(sourceSessionId);
34030
+ const sourceSession = options2.atRecordId === void 0 ? await this.loadSession(sourceSessionId) : void 0;
33558
34031
  const existingSnapshotPromptIds = collectFileHistorySnapshotPromptIds(forked);
33559
34032
  const remappedSnapshots = sourceSession?.fileHistorySnapshots?.map(
33560
34033
  (snapshot) => remapSnapshotPromptId(snapshot, sourceSessionId, newSessionId)
@@ -33574,43 +34047,129 @@ var SessionService = class {
33574
34047
  }
33575
34048
  };
33576
34049
  forked.push(snapshotRecord);
34050
+ prevUuid = snapshotRecord.uuid;
33577
34051
  }
33578
- fs12.mkdirSync(chatsDir, { recursive: true });
34052
+ if (options2.title !== void 0) {
34053
+ const titleRecord = {
34054
+ uuid: randomUUID3(),
34055
+ parentUuid: prevUuid,
34056
+ sessionId: newSessionId,
34057
+ type: "system",
34058
+ subtype: "custom_title",
34059
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
34060
+ cwd: this.projectRoot,
34061
+ version: records[0].version,
34062
+ systemPayload: {
34063
+ customTitle: options2.title,
34064
+ titleSource: "manual"
34065
+ }
34066
+ };
34067
+ forked.push(titleRecord);
34068
+ prevUuid = titleRecord.uuid;
34069
+ }
34070
+ const validateTargetBranchPoint = /* @__PURE__ */ __name(() => {
34071
+ if (options2.atRecordId === void 0) return;
34072
+ const targetActive = this.reconstructHistory(forked).messages;
34073
+ if (!resolveBranchPoints(targetActive).has(options2.atRecordId)) {
34074
+ throw new BranchPointInvalidError(options2.atRecordId);
34075
+ }
34076
+ }, "validateTargetBranchPoint");
34077
+ validateTargetBranchPoint();
33579
34078
  const body = forked.map((r) => JSON.stringify(r)).join("\n") + "\n";
33580
- let fd;
34079
+ const operationId = randomUUID3();
34080
+ const stagedTranscriptPath = path12.join(
34081
+ chatsDir,
34082
+ `.${newSessionId}.${operationId}.tmp`
34083
+ );
34084
+ const backupRoot = path12.join(Storage.getGlobalQwenDir(), FILE_HISTORY_DIR);
34085
+ const stagedBackupPath = path12.join(
34086
+ backupRoot,
34087
+ `.${newSessionId}.${operationId}.tmp`
34088
+ );
34089
+ const targetBackupPath = path12.join(backupRoot, newSessionId);
34090
+ const backupNames = collectReferencedFileHistoryBackupNames(forked);
34091
+ await Promise.all([
34092
+ fs12.promises.mkdir(chatsDir, { recursive: true }),
34093
+ fs12.promises.mkdir(backupRoot, { recursive: true, mode: 448 })
34094
+ ]);
34095
+ let backupPublished = false;
34096
+ let committed = false;
33581
34097
  try {
33582
- fd = fs12.openSync(targetPath, "wx", 384);
33583
- } catch (err) {
33584
- if (err.code === "EEXIST") {
33585
- throw new Error(`Target session file already exists: ${newSessionId}`);
34098
+ if (await pathExists2(targetPath) || await pathExists2(targetBackupPath)) {
34099
+ throw new Error(`Target session already exists: ${newSessionId}`);
33586
34100
  }
33587
- throw err;
33588
- }
33589
- let targetComplete = false;
33590
- try {
34101
+ const stagedHandle = await fs12.promises.open(
34102
+ stagedTranscriptPath,
34103
+ "wx",
34104
+ 384
34105
+ );
33591
34106
  try {
33592
- fs12.writeFileSync(fd, body, { encoding: "utf8" });
34107
+ await stagedHandle.writeFile(body, { encoding: "utf8" });
34108
+ await stagedHandle.sync();
33593
34109
  } finally {
33594
- fs12.closeSync(fd);
34110
+ await stagedHandle.close();
33595
34111
  }
33596
- await copyFileHistoryBackups(sourceSessionId, newSessionId);
33597
- targetComplete = true;
33598
- } finally {
33599
- if (!targetComplete) {
33600
- try {
33601
- this.removeFileIfExists(targetPath);
33602
- } catch (cleanupError) {
33603
- this.warn(
33604
- `forkSession: failed to clean up incomplete target ${newSessionId}: ${cleanupError}`
33605
- );
34112
+ if (backupNames.size > 0) {
34113
+ const copiedBackupNames = await copyFileHistoryBackupsToStaging(
34114
+ sourceSessionId,
34115
+ stagedBackupPath,
34116
+ backupNames,
34117
+ (name) => {
34118
+ this.warn(
34119
+ `branch ${newSessionId} omitted missing file-history backup ${name}; rewind data for that snapshot is unavailable`
34120
+ );
34121
+ }
34122
+ );
34123
+ if (copiedBackupNames.size > 0) {
34124
+ if (await pathExists2(targetBackupPath)) {
34125
+ throw new Error(`Target session already exists: ${newSessionId}`);
34126
+ }
34127
+ await fs12.promises.rename(stagedBackupPath, targetBackupPath);
34128
+ backupPublished = true;
33606
34129
  }
33607
- try {
33608
- this.removeFileHistoryBackups(newSessionId);
33609
- } catch (cleanupError) {
33610
- this.warn(
33611
- `forkSession: failed to clean up file history for incomplete target ${newSessionId}: ${cleanupError}`
33612
- );
34130
+ }
34131
+ try {
34132
+ await fs12.promises.link(stagedTranscriptPath, targetPath);
34133
+ } catch (error) {
34134
+ const code = error.code;
34135
+ if (code === "EEXIST") {
34136
+ throw new Error(`Target session already exists: ${newSessionId}`);
34137
+ }
34138
+ if (await pathExists2(targetPath)) {
34139
+ throw new Error(`Target session already exists: ${newSessionId}`);
33613
34140
  }
34141
+ await fs12.promises.rename(stagedTranscriptPath, targetPath);
34142
+ }
34143
+ committed = true;
34144
+ try {
34145
+ await fsyncDirectoryBestEffort(chatsDir);
34146
+ } catch (error) {
34147
+ this.warn(
34148
+ `branch committed session=${newSessionId} but final durability confirmation failed: ${error instanceof Error ? error.message : String(error)}`
34149
+ );
34150
+ }
34151
+ } finally {
34152
+ const cleanupFailures = [];
34153
+ await fs12.promises.unlink(stagedTranscriptPath).catch((error) => {
34154
+ if (error.code !== "ENOENT") {
34155
+ cleanupFailures.push(`transcript staging: ${String(error)}`);
34156
+ }
34157
+ });
34158
+ await fs12.promises.rm(stagedBackupPath, { recursive: true, force: true }).catch((error) => {
34159
+ cleanupFailures.push(`backup staging: ${String(error)}`);
34160
+ });
34161
+ if (!committed && backupPublished) {
34162
+ await fs12.promises.rm(targetBackupPath, {
34163
+ recursive: true,
34164
+ force: true
34165
+ }).catch((error) => {
34166
+ cleanupFailures.push(`published backup: ${String(error)}`);
34167
+ });
34168
+ }
34169
+ if (cleanupFailures.length > 0) {
34170
+ this.warn(
34171
+ `branch cleanup incomplete session=${newSessionId}: ${cleanupFailures.join("; ")}`
34172
+ );
33614
34173
  }
33615
34174
  }
33616
34175
  return { filePath: targetPath, copiedCount: forked.length };
@@ -33736,8 +34295,9 @@ var SessionService = class {
33736
34295
  const filePath = path12.join(chatsDir, name);
33737
34296
  const titleInfo = this.readSessionTitleInfoFromFile(filePath);
33738
34297
  if (!titleInfo.title) continue;
33739
- const normalizedTitle = titleInfo.title.toLowerCase().trim();
33740
- if (!normalizedTitle.startsWith(normalizedPrefix)) continue;
34298
+ if (!titleInfo.title.toLowerCase().trim().startsWith(normalizedPrefix)) {
34299
+ continue;
34300
+ }
33741
34301
  try {
33742
34302
  const records = await readLines(filePath, 1);
33743
34303
  if (records.length === 0) continue;
@@ -33896,6 +34456,28 @@ function collectFileHistorySnapshotPromptIds(records) {
33896
34456
  return ids;
33897
34457
  }
33898
34458
  __name(collectFileHistorySnapshotPromptIds, "collectFileHistorySnapshotPromptIds");
34459
+ function collectReferencedFileHistoryBackupNames(records) {
34460
+ const names = /* @__PURE__ */ new Set();
34461
+ for (const record2 of records) {
34462
+ if (record2.type !== "system" || record2.subtype !== "file_history_snapshot" || !record2.systemPayload) {
34463
+ continue;
34464
+ }
34465
+ const payload = record2.systemPayload;
34466
+ if (!Array.isArray(payload.snapshots)) continue;
34467
+ for (const snapshot of payload.snapshots) {
34468
+ if (!snapshot || typeof snapshot !== "object" || !snapshot.trackedFileBackups || typeof snapshot.trackedFileBackups !== "object") {
34469
+ continue;
34470
+ }
34471
+ for (const backup of Object.values(snapshot.trackedFileBackups)) {
34472
+ if (backup && backup.failed !== true && typeof backup.backupFileName === "string" && backup.backupFileName.length > 0 && backup.backupFileName !== "." && backup.backupFileName !== ".." && path12.basename(backup.backupFileName) === backup.backupFileName) {
34473
+ names.add(backup.backupFileName);
34474
+ }
34475
+ }
34476
+ }
34477
+ }
34478
+ return names;
34479
+ }
34480
+ __name(collectReferencedFileHistoryBackupNames, "collectReferencedFileHistoryBackupNames");
33899
34481
  function replayUiTelemetryFromConversation(conversation, sessionId) {
33900
34482
  if (sessionId) {
33901
34483
  uiTelemetryService.resetSession(sessionId);
@@ -34065,8 +34647,8 @@ function filterToDialog(history) {
34065
34647
  for (const msg of history.slice(getStartupContextLength(history))) {
34066
34648
  if (msg.role !== "user" && msg.role !== "model") continue;
34067
34649
  const textParts = [];
34068
- const parts = stripTrailingUserPromptSubmitContextPart(msg.parts ?? []);
34069
- for (const part of parts) {
34650
+ const parts2 = stripTrailingUserPromptSubmitContextPart(msg.parts ?? []);
34651
+ for (const part of parts2) {
34070
34652
  if (typeof part?.text !== "string" || part.text.trim() === "" || part.thought || part.thoughtSignature) {
34071
34653
  continue;
34072
34654
  }
@@ -34256,6 +34838,12 @@ var ChatRecordingService = class {
34256
34838
  lastRecordUuid = null;
34257
34839
  /** UUID of the last active-tail record confirmed written to disk. */
34258
34840
  lastPersistedRecordUuid = null;
34841
+ /** Active chain mirrored in memory so end-of-turn validation is incremental. */
34842
+ activeBranchRecords = [];
34843
+ /** Parent of the first mirrored record, or the restored tail before appends. */
34844
+ activeBranchBaseUuid = null;
34845
+ /** Unclosed tool calls at the current active tail. */
34846
+ pendingBranchToolCalls = [];
34259
34847
  config;
34260
34848
  /**
34261
34849
  * Tracks the `lastRecordUuid` value just before each user turn was recorded.
@@ -34278,6 +34866,8 @@ var ChatRecordingService = class {
34278
34866
  acceptingWrites = false;
34279
34867
  closePromise;
34280
34868
  handoffRequested = false;
34869
+ /** Prevents asynchronous metadata writers from becoming checkpoint siblings. */
34870
+ topologyFence;
34281
34871
  /** First async JSONL write failure; permanently degrades this recorder. */
34282
34872
  writeFailure;
34283
34873
  integrityFailure;
@@ -34414,6 +35004,9 @@ var ChatRecordingService = class {
34414
35004
  this.currentParentSessionId = void 0;
34415
35005
  this.currentSourceType = void 0;
34416
35006
  this.currentSourceId = void 0;
35007
+ this.activeBranchRecords = [];
35008
+ this.activeBranchBaseUuid = null;
35009
+ this.pendingBranchToolCalls = [];
34417
35010
  this.userDisplayTextsForTitle.length = 0;
34418
35011
  if (!sessionData) return;
34419
35012
  this.rebuildTurnBoundaries(sessionData.conversation.messages);
@@ -34453,6 +35046,7 @@ var ChatRecordingService = class {
34453
35046
  restoreProjectedState(state) {
34454
35047
  this.lastRecordUuid = state.lastCompletedUuid;
34455
35048
  this.lastPersistedRecordUuid = state.lastCompletedUuid;
35049
+ this.activeBranchBaseUuid = state.lastCompletedUuid;
34456
35050
  this.turnParentUuids = [...state.turnParentUuids];
34457
35051
  this.currentCustomTitle = state.customTitle;
34458
35052
  this.currentTitleSource = state.titleSource;
@@ -34532,6 +35126,23 @@ var ChatRecordingService = class {
34532
35126
  }
34533
35127
  return this.integrityFailure ?? this.writeFailure;
34534
35128
  }
35129
+ updateActiveBranch(record2) {
35130
+ const currentTail = this.activeBranchRecords.at(-1)?.uuid ?? null;
35131
+ if (record2.parentUuid !== currentTail) {
35132
+ const parentIndex = record2.parentUuid === null ? -1 : this.activeBranchRecords.findIndex(
35133
+ (candidate) => candidate.uuid === record2.parentUuid
35134
+ );
35135
+ this.activeBranchRecords = parentIndex < 0 ? [] : this.activeBranchRecords.slice(0, parentIndex + 1);
35136
+ if (parentIndex < 0) {
35137
+ this.activeBranchBaseUuid = record2.parentUuid ?? null;
35138
+ }
35139
+ this.pendingBranchToolCalls = collectPendingBranchToolCalls(
35140
+ this.activeBranchRecords
35141
+ );
35142
+ }
35143
+ this.activeBranchRecords.push(record2);
35144
+ updatePendingBranchToolCalls(this.pendingBranchToolCalls, record2);
35145
+ }
34535
35146
  enqueueRecordWrite(record2, legacyConversationFile, updateActiveTail = true) {
34536
35147
  const pendingWrite = this.operationTail.then(async () => {
34537
35148
  if (this.writeFailure) throw this.writeFailure;
@@ -34563,26 +35174,41 @@ var ChatRecordingService = class {
34563
35174
  * descendants are skipped and later fire-and-forget calls become no-ops.
34564
35175
  */
34565
35176
  appendRecord(record2, options2) {
34566
- if (this.writeFailure || !this.acceptingWrites || this.state !== "active") {
35177
+ if (this.writeFailure || !this.acceptingWrites || this.state !== "active")
35178
+ return;
35179
+ if (this.topologyFence) {
35180
+ this.topologyFence.buffered.push({ record: record2, options: options2 });
34567
35181
  return;
34568
35182
  }
34569
35183
  const legacyConversationFile = this.writerLeaseRequired ? void 0 : this.ensureConversationFile();
34570
35184
  const updateActiveTail = options2?.updateActiveTail !== false;
34571
35185
  if (updateActiveTail) {
34572
35186
  this.lastRecordUuid = record2.uuid;
35187
+ this.updateActiveBranch(record2);
34573
35188
  }
34574
35189
  this.enqueueRecordWrite(record2, legacyConversationFile, updateActiveTail);
34575
35190
  this.updateTitleAnchorTracking(record2);
34576
35191
  }
34577
35192
  async appendRecordStrict(record2, options2) {
34578
35193
  if (this.writeFailure) throw this.writeFailure;
34579
- if (!this.acceptingWrites || this.state !== "active") {
35194
+ if (!this.acceptingWrites || this.state !== "active")
34580
35195
  throw new SessionWriterUnavailableError();
35196
+ if (this.topologyFence) {
35197
+ await new Promise((resolve41, reject) => {
35198
+ this.topologyFence.buffered.push({
35199
+ record: record2,
35200
+ options: options2,
35201
+ resolve: resolve41,
35202
+ reject
35203
+ });
35204
+ });
35205
+ return;
34581
35206
  }
34582
35207
  const updateActiveTail = options2?.updateActiveTail !== false;
34583
35208
  const legacyConversationFile = this.writerLeaseRequired ? void 0 : this.ensureConversationFile();
34584
35209
  if (updateActiveTail) {
34585
35210
  this.lastRecordUuid = record2.uuid;
35211
+ this.updateActiveBranch(record2);
34586
35212
  }
34587
35213
  const pendingWrite = this.enqueueRecordWrite(
34588
35214
  record2,
@@ -34592,6 +35218,21 @@ var ChatRecordingService = class {
34592
35218
  this.updateTitleAnchorTracking(record2);
34593
35219
  await pendingWrite;
34594
35220
  }
35221
+ releaseTopologyFence(fence) {
35222
+ if (this.topologyFence !== fence) return;
35223
+ this.topologyFence = void 0;
35224
+ for (const intent of fence.buffered) {
35225
+ intent.record.parentUuid = this.lastRecordUuid;
35226
+ if (intent.resolve && intent.reject) {
35227
+ void this.appendRecordStrict(intent.record, intent.options).then(
35228
+ intent.resolve,
35229
+ intent.reject
35230
+ );
35231
+ } else {
35232
+ this.appendRecord(intent.record, intent.options);
35233
+ }
35234
+ }
35235
+ }
34595
35236
  /**
34596
35237
  * Maintain the "title is always in the tail window" invariant by
34597
35238
  * counting bytes accepted since the last `custom_title` record and
@@ -34669,6 +35310,17 @@ var ChatRecordingService = class {
34669
35310
  await this.operationTail;
34670
35311
  if (this.writeFailure) throw this.writeFailure;
34671
35312
  }
35313
+ async readActiveTranscriptChain() {
35314
+ await this.flush();
35315
+ const sessionId = this.getSessionId();
35316
+ const session = await this.config.getSessionService().loadSession(sessionId);
35317
+ if (!session) {
35318
+ throw new Error(
35319
+ `Unable to load active transcript for session ${sessionId}`
35320
+ );
35321
+ }
35322
+ return session.conversation.messages;
35323
+ }
34672
35324
  async runWithWriteBarrier(operation) {
34673
35325
  if (this.writeFailure) throw this.writeFailure;
34674
35326
  if (!this.acceptingWrites || this.state !== "active") {
@@ -34768,20 +35420,63 @@ var ChatRecordingService = class {
34768
35420
  hasWriteOwnership() {
34769
35421
  return this.binding !== void 0;
34770
35422
  }
34771
- async readActiveTranscriptChain() {
34772
- await this.flush();
34773
- const sessionId = this.getSessionId();
34774
- const session = await this.config.getSessionService().loadSession(sessionId);
34775
- if (!session) {
34776
- throw new Error(
34777
- `Unable to load active transcript for session ${sessionId}`
34778
- );
34779
- }
34780
- return session.conversation.messages;
34781
- }
34782
35423
  getTranscriptCursor() {
34783
35424
  return { recordId: this.lastRecordUuid };
34784
35425
  }
35426
+ getBranchCheckpointCursor() {
35427
+ return {
35428
+ recordId: this.lastRecordUuid,
35429
+ activeRecordCount: this.activeBranchRecords.length,
35430
+ pendingToolCalls: this.pendingBranchToolCalls.map((call) => ({
35431
+ ...call
35432
+ }))
35433
+ };
35434
+ }
35435
+ async recordBranchCheckpointTransaction(input) {
35436
+ if (input.stopReason !== "end_turn") return void 0;
35437
+ if (this.writeFailure) throw this.writeFailure;
35438
+ if (this.state !== "active") throw new SessionWriterUnavailableError();
35439
+ if (this.topologyFence) {
35440
+ throw new Error("Transcript topology transaction already active");
35441
+ }
35442
+ const fence = { buffered: [] };
35443
+ this.topologyFence = fence;
35444
+ try {
35445
+ await this.flush();
35446
+ const endInclusiveRecordUuid = this.lastRecordUuid;
35447
+ if (endInclusiveRecordUuid === null) return void 0;
35448
+ const cursorRecordId = input.cursor.activeRecordCount === 0 ? this.activeBranchBaseUuid : this.activeBranchRecords[input.cursor.activeRecordCount - 1]?.uuid;
35449
+ if (cursorRecordId !== input.cursor.recordId || this.activeBranchRecords.at(-1)?.uuid !== endInclusiveRecordUuid) {
35450
+ throw new Error("Transcript changed while recording branch checkpoint");
35451
+ }
35452
+ const candidate = resolveCompletedTurnBranchCandidateFromRecords({
35453
+ records: this.activeBranchRecords.slice(input.cursor.activeRecordCount),
35454
+ startExclusiveRecordUuid: input.cursor.recordId,
35455
+ pendingCallsAtStart: input.cursor.pendingToolCalls
35456
+ });
35457
+ if (!candidate) return void 0;
35458
+ const checkpointUuid = randomUUID4();
35459
+ const checkpoint = {
35460
+ ...this.createBaseRecord("system"),
35461
+ uuid: checkpointUuid,
35462
+ parentUuid: endInclusiveRecordUuid,
35463
+ type: "system",
35464
+ subtype: "branch_checkpoint",
35465
+ systemPayload: {
35466
+ v: 1,
35467
+ startExclusiveRecordUuid: input.cursor.recordId,
35468
+ assistantRecordUuid: candidate.assistantRecordUuid
35469
+ }
35470
+ };
35471
+ this.topologyFence = void 0;
35472
+ const checkpointWrite = this.appendRecordStrict(checkpoint);
35473
+ this.topologyFence = fence;
35474
+ await checkpointWrite;
35475
+ return { ...candidate, checkpointUuid };
35476
+ } finally {
35477
+ this.releaseTopologyFence(fence);
35478
+ }
35479
+ }
34785
35480
  async recordGoalState(recordUuid, payload) {
34786
35481
  const record2 = {
34787
35482
  ...this.createBaseRecord("system"),
@@ -35184,6 +35879,9 @@ var ChatRecordingService = class {
35184
35879
  */
35185
35880
  rebuildTurnBoundaries(messages) {
35186
35881
  this.turnParentUuids = [];
35882
+ this.activeBranchRecords = [...messages];
35883
+ this.activeBranchBaseUuid = messages[0]?.parentUuid ?? null;
35884
+ this.pendingBranchToolCalls = collectPendingBranchToolCalls(messages);
35187
35885
  for (let i = 0; i < messages.length; i++) {
35188
35886
  const record2 = messages[i];
35189
35887
  if (record2.type === "user" && record2.subtype !== "goal_runtime" && record2.subtype !== "notification" && record2.subtype !== "cron" && record2.subtype !== "mid_turn_user_message" && record2.subtype !== "realtime_message") {
@@ -35529,9 +36227,9 @@ function collectToolCallIdsFromHistory(history) {
35529
36227
  return ids;
35530
36228
  }
35531
36229
  __name(collectToolCallIdsFromHistory, "collectToolCallIdsFromHistory");
35532
- function normalizeModelToolCallIds(parts, usedIds, rawIdsInCurrentTurn, reservedIds) {
36230
+ function normalizeModelToolCallIds(parts2, usedIds, rawIdsInCurrentTurn, reservedIds) {
35533
36231
  const normalized2 = [];
35534
- for (const part of parts) {
36232
+ for (const part of parts2) {
35535
36233
  const functionCall = part.functionCall;
35536
36234
  if (!functionCall) {
35537
36235
  normalized2.push(part);
@@ -35585,10 +36283,10 @@ function getProviderToolCallId(functionCall) {
35585
36283
  return functionCall[PROVIDER_TOOL_CALL_ID];
35586
36284
  }
35587
36285
  __name(getProviderToolCallId, "getProviderToolCallId");
35588
- function dedupeToolCallsById(functionCalls) {
36286
+ function dedupeToolCallsById(functionCalls2) {
35589
36287
  const seenIds = /* @__PURE__ */ new Set();
35590
36288
  const deduped = [];
35591
- for (const functionCall of functionCalls) {
36289
+ for (const functionCall of functionCalls2) {
35592
36290
  const id = functionCall.id;
35593
36291
  if (id) {
35594
36292
  if (seenIds.has(id)) {
@@ -35607,20 +36305,20 @@ __name(dedupeToolCallsById, "dedupeToolCallsById");
35607
36305
  var ERROR_REPORT_HISTORY_TAIL_COUNT = 8;
35608
36306
  var ERROR_REPORT_TEXT_PREVIEW_CHARS = 200;
35609
36307
  function normalizeRequestParts(req) {
35610
- const parts = Array.isArray(req) ? req : [req];
35611
- return parts.map(
36308
+ const parts2 = Array.isArray(req) ? req : [req];
36309
+ return parts2.map(
35612
36310
  (part) => typeof part === "string" ? { text: part } : part
35613
36311
  );
35614
36312
  }
35615
36313
  __name(normalizeRequestParts, "normalizeRequestParts");
35616
- function summarizeParts(parts) {
36314
+ function summarizeParts(parts2) {
35617
36315
  return {
35618
- partCount: parts.length,
35619
- functionCalls: parts.map((part) => part.functionCall?.name).filter((name) => typeof name === "string"),
35620
- functionResponses: parts.map((part) => part.functionResponse?.name).filter((name) => typeof name === "string"),
36316
+ partCount: parts2.length,
36317
+ functionCalls: parts2.map((part) => part.functionCall?.name).filter((name) => typeof name === "string"),
36318
+ functionResponses: parts2.map((part) => part.functionResponse?.name).filter((name) => typeof name === "string"),
35621
36319
  textPreview: (() => {
35622
36320
  let textPreview = "";
35623
- for (const part of parts) {
36321
+ for (const part of parts2) {
35624
36322
  if (typeof part.text !== "string" || part.thought) continue;
35625
36323
  const remaining = ERROR_REPORT_TEXT_PREVIEW_CHARS - textPreview.length;
35626
36324
  if (remaining <= 0) break;
@@ -35710,9 +36408,9 @@ var CompressionStatus = /* @__PURE__ */ ((CompressionStatus2) => {
35710
36408
  return CompressionStatus2;
35711
36409
  })(CompressionStatus || {});
35712
36410
  function getDisplayContentParts(response) {
35713
- const parts = response.candidates?.[0]?.content?.parts ?? [];
36411
+ const parts2 = response.candidates?.[0]?.content?.parts ?? [];
35714
36412
  const displayParts = [];
35715
- for (const part of parts) {
36413
+ for (const part of parts2) {
35716
36414
  if (part.thought) {
35717
36415
  continue;
35718
36416
  }
@@ -35820,8 +36518,8 @@ var Turn = class {
35820
36518
  ...hasImage ? { parts: displayParts } : {}
35821
36519
  };
35822
36520
  }
35823
- const functionCalls = resp.functionCalls ?? [];
35824
- for (const fnCall of functionCalls) {
36521
+ const functionCalls2 = resp.functionCalls ?? [];
36522
+ for (const fnCall of functionCalls2) {
35825
36523
  const event = this.handlePendingFunctionCall(fnCall);
35826
36524
  if (event) {
35827
36525
  yield event;
@@ -35860,6 +36558,7 @@ ${[...this.pendingCitations].sort().join("\n")}`
35860
36558
  yield { type: "user_cancelled" /* UserCancelled */ };
35861
36559
  return;
35862
36560
  }
36561
+ const originalStatus = getErrorStatus(e);
35863
36562
  const error = toFriendlyError(e);
35864
36563
  if (error instanceof UnauthorizedError) {
35865
36564
  throw error;
@@ -35883,10 +36582,9 @@ ${[...this.pendingCitations].sort().join("\n")}`
35883
36582
  "Turn.run-sendMessageStream",
35884
36583
  { contextAlreadySummarized: true }
35885
36584
  );
35886
- const status = typeof error === "object" && error !== null && "status" in error && typeof error.status === "number" ? error.status : void 0;
35887
36585
  const structuredError = {
35888
36586
  message: getErrorMessage(error),
35889
- status
36587
+ status: getErrorStatus(error) ?? originalStatus
35890
36588
  };
35891
36589
  await this.chat.maybeIncludeSchemaDepthContext(structuredError);
35892
36590
  yield { type: "error" /* Error */, value: { error: structuredError } };
@@ -35976,9 +36674,9 @@ function extractRecentFilePaths(history, maxFiles) {
35976
36674
  for (let i = history.length - 1; i >= 0; i--) {
35977
36675
  const content = history[i];
35978
36676
  if (content.role !== "model") continue;
35979
- const parts = content.parts ?? [];
35980
- for (let j2 = parts.length - 1; j2 >= 0; j2--) {
35981
- const part = parts[j2];
36677
+ const parts2 = content.parts ?? [];
36678
+ for (let j2 = parts2.length - 1; j2 >= 0; j2--) {
36679
+ const part = parts2[j2];
35982
36680
  const call = part.functionCall;
35983
36681
  if (!call || !FILE_TOUCHING_TOOLS.has(call.name ?? "")) continue;
35984
36682
  if (call.id && failedCallIds.has(call.id)) continue;
@@ -35994,9 +36692,9 @@ function extractRecentFilePaths(history, maxFiles) {
35994
36692
  __name(extractRecentFilePaths, "extractRecentFilePaths");
35995
36693
  function imagePartsInContentReverse(content) {
35996
36694
  const result = [];
35997
- const parts = content.parts ?? [];
35998
- for (let j2 = parts.length - 1; j2 >= 0; j2--) {
35999
- const part = parts[j2];
36695
+ const parts2 = content.parts ?? [];
36696
+ for (let j2 = parts2.length - 1; j2 >= 0; j2--) {
36697
+ const part = parts2[j2];
36000
36698
  if (part.inlineData?.mimeType?.startsWith("image/")) {
36001
36699
  result.push(part);
36002
36700
  continue;
@@ -36248,15 +36946,15 @@ function buildSubagentSnapshotPart(snaps) {
36248
36946
  }
36249
36947
  __name(buildSubagentSnapshotPart, "buildSubagentSnapshotPart");
36250
36948
  function buildStateReminderParts(options2) {
36251
- const parts = [];
36949
+ const parts2 = [];
36252
36950
  if (options2.planModeActive) {
36253
- parts.push(buildPlanModeReminderPart());
36951
+ parts2.push(buildPlanModeReminderPart());
36254
36952
  }
36255
36953
  if (options2.runningSubagents && options2.runningSubagents.length > 0) {
36256
36954
  const snap = buildSubagentSnapshotPart(options2.runningSubagents);
36257
- if (snap) parts.push(snap);
36955
+ if (snap) parts2.push(snap);
36258
36956
  }
36259
- return parts;
36957
+ return parts2;
36260
36958
  }
36261
36959
  __name(buildStateReminderParts, "buildStateReminderParts");
36262
36960
  async function composePostCompactHistory(history, summary, options2 = {}) {
@@ -36367,18 +37065,18 @@ function collectActiveSubagents(config) {
36367
37065
  __name(collectActiveSubagents, "collectActiveSubagents");
36368
37066
  function buildCompressionSystemPrompt(userInstructions, hookInstructions) {
36369
37067
  const base = getCompressionPrompt();
36370
- const parts = [];
37068
+ const parts2 = [];
36371
37069
  if (userInstructions && userInstructions.trim().length > 0) {
36372
- parts.push(userInstructions.trim());
37070
+ parts2.push(userInstructions.trim());
36373
37071
  }
36374
37072
  if (hookInstructions.length > 0) {
36375
- parts.push(hookInstructions);
37073
+ parts2.push(hookInstructions);
36376
37074
  }
36377
- if (parts.length === 0) return base;
37075
+ if (parts2.length === 0) return base;
36378
37076
  return `${base}
36379
37077
 
36380
37078
  Additional Instructions:
36381
- ${parts.join("\n\n")}`;
37079
+ ${parts2.join("\n\n")}`;
36382
37080
  }
36383
37081
  __name(buildCompressionSystemPrompt, "buildCompressionSystemPrompt");
36384
37082
  function supportsCompressionCacheSharing(config) {
@@ -37527,9 +38225,9 @@ function hasNonThoughtCandidateParts(response) {
37527
38225
  );
37528
38226
  }
37529
38227
  __name(hasNonThoughtCandidateParts, "hasNonThoughtCandidateParts");
37530
- function syncFunctionCallsField(response, parts) {
37531
- const functionCalls = parts.map((part) => part.functionCall).filter((call) => Boolean(call));
37532
- const value = functionCalls.length > 0 ? functionCalls : void 0;
38228
+ function syncFunctionCallsField(response, parts2) {
38229
+ const functionCalls2 = parts2.map((part) => part.functionCall).filter((call) => Boolean(call));
38230
+ const value = functionCalls2.length > 0 ? functionCalls2 : void 0;
37533
38231
  let owner = response;
37534
38232
  let descriptor2;
37535
38233
  while (owner && !descriptor2) {
@@ -37580,7 +38278,7 @@ function redactApprovedPlansInHistory(history, savedPlanContent, planPath) {
37580
38278
  const out = history.map((entry) => {
37581
38279
  if (entry?.role !== "model" || !entry.parts) return entry;
37582
38280
  let entryChanged = false;
37583
- const parts = entry.parts.map((part) => {
38281
+ const parts2 = entry.parts.map((part) => {
37584
38282
  const fc = part.functionCall;
37585
38283
  if (!fc?.id || canonicalPlanToolName(fc.name) !== ToolNames.EXIT_PLAN_MODE)
37586
38284
  return part;
@@ -37597,7 +38295,7 @@ function redactApprovedPlansInHistory(history, savedPlanContent, planPath) {
37597
38295
  });
37598
38296
  if (!entryChanged) return entry;
37599
38297
  changed = true;
37600
- return { ...entry, parts };
38298
+ return { ...entry, parts: parts2 };
37601
38299
  });
37602
38300
  return changed ? out : null;
37603
38301
  }
@@ -37776,8 +38474,8 @@ function isPlainTextPart(part) {
37776
38474
  return part !== void 0 && isValidNonThoughtTextPart(part);
37777
38475
  }
37778
38476
  __name(isPlainTextPart, "isPlainTextPart");
37779
- function getPlainTextFromParts(parts) {
37780
- return (parts ?? []).filter(isPlainTextPart).map((part) => part.text).join("");
38477
+ function getPlainTextFromParts(parts2) {
38478
+ return (parts2 ?? []).filter(isPlainTextPart).map((part) => part.text).join("");
37781
38479
  }
37782
38480
  __name(getPlainTextFromParts, "getPlainTextFromParts");
37783
38481
  function sanitizeRecoverySuffixTail(tail) {
@@ -37835,9 +38533,9 @@ function appendRecoveryContinuationParts(previousParts, continuationParts) {
37835
38533
  return [...mergedParts, ...nextParts];
37836
38534
  }
37837
38535
  __name(appendRecoveryContinuationParts, "appendRecoveryContinuationParts");
37838
- function findLastPlainTextPartIndex(parts) {
37839
- for (let i = parts.length - 1; i >= 0; i -= 1) {
37840
- if (isPlainTextPart(parts[i])) {
38536
+ function findLastPlainTextPartIndex(parts2) {
38537
+ for (let i = parts2.length - 1; i >= 0; i -= 1) {
38538
+ if (isPlainTextPart(parts2[i])) {
37841
38539
  return i;
37842
38540
  }
37843
38541
  }
@@ -37978,13 +38676,13 @@ function stripThoughtPartsFromContent(content) {
37978
38676
  if (!content.parts) {
37979
38677
  return content;
37980
38678
  }
37981
- const parts = content.parts.filter((part) => !part.thought);
37982
- if (parts.length === 0) {
38679
+ const parts2 = content.parts.filter((part) => !part.thought);
38680
+ if (parts2.length === 0) {
37983
38681
  return null;
37984
38682
  }
37985
38683
  return {
37986
38684
  ...content,
37987
- parts
38685
+ parts: parts2
37988
38686
  };
37989
38687
  }
37990
38688
  __name(stripThoughtPartsFromContent, "stripThoughtPartsFromContent");
@@ -38092,9 +38790,9 @@ function scanModelTurn(history, modelIdx) {
38092
38790
  const matched = /* @__PURE__ */ new Map();
38093
38791
  let scanIdx = modelIdx + 1;
38094
38792
  while (scanIdx < history.length && history[scanIdx]?.role === "user") {
38095
- const parts = history[scanIdx].parts ?? [];
38096
- for (let pIdx = 0; pIdx < parts.length; pIdx++) {
38097
- const part = parts[pIdx];
38793
+ const parts2 = history[scanIdx].parts ?? [];
38794
+ for (let pIdx = 0; pIdx < parts2.length; pIdx++) {
38795
+ const part = parts2[pIdx];
38098
38796
  const id = part.functionResponse?.id;
38099
38797
  if (id) {
38100
38798
  const list2 = matched.get(id);
@@ -40020,10 +40718,10 @@ This error was probably caused by cyclic schema references in one of the followi
40020
40718
  const protocolTagDetector = new LeadingProtocolTagLeakDetector();
40021
40719
  let pendingProtocolParts = [];
40022
40720
  const takePendingProtocolParts = /* @__PURE__ */ __name(() => {
40023
- const parts = pendingProtocolParts;
40721
+ const parts2 = pendingProtocolParts;
40024
40722
  pendingProtocolParts = [];
40025
40723
  const released = [];
40026
- for (const part of parts) {
40724
+ for (const part of parts2) {
40027
40725
  const previous = released.at(-1);
40028
40726
  if (previous && isValidNonThoughtTextPart(previous) && isValidNonThoughtTextPart(part)) {
40029
40727
  previous.text += part.text;
@@ -40063,12 +40761,12 @@ This error was probably caused by cyclic schema references in one of the followi
40063
40761
  if (protocolTagDetector.leaked) {
40064
40762
  pendingProtocolParts = [];
40065
40763
  } else {
40066
- const parts = takePendingProtocolParts();
40067
- if (parts.length > 0) {
40764
+ const parts2 = takePendingProtocolParts();
40765
+ if (parts2.length > 0) {
40068
40766
  content = {
40069
40767
  ...content,
40070
40768
  role: content?.role ?? "model",
40071
- parts
40769
+ parts: parts2
40072
40770
  };
40073
40771
  candidate.content = content;
40074
40772
  }
@@ -40193,18 +40891,18 @@ This error was probably caused by cyclic schema references in one of the followi
40193
40891
  if (protocolTagDetector.leaked) {
40194
40892
  pendingProtocolParts = [];
40195
40893
  } else {
40196
- const parts = normalizeModelToolCallIds(
40894
+ const parts2 = normalizeModelToolCallIds(
40197
40895
  takePendingProtocolParts(),
40198
40896
  usedToolCallIds,
40199
40897
  rawToolCallIdsInCurrentTurn,
40200
40898
  reservedToolCallIds
40201
40899
  );
40202
40900
  const chunk = {
40203
- candidates: [{ content: { role: "model", parts } }]
40901
+ candidates: [{ content: { role: "model", parts: parts2 } }]
40204
40902
  };
40205
- syncFunctionCallsField(chunk, parts);
40206
- hasToolCall ||= parts.some((part) => part.functionCall);
40207
- allModelParts.push(...parts);
40903
+ syncFunctionCallsField(chunk, parts2);
40904
+ hasToolCall ||= parts2.some((part) => part.functionCall);
40905
+ allModelParts.push(...parts2);
40208
40906
  yield chunk;
40209
40907
  }
40210
40908
  }
@@ -41199,9 +41897,9 @@ function isGeneratedFile(filePath) {
41199
41897
  if (EXCLUDED_EXTENSIONS.has(ext2)) {
41200
41898
  return true;
41201
41899
  }
41202
- const parts = fileName.split(".");
41203
- if (parts.length > 2) {
41204
- const compoundExt = "." + parts.slice(-2).join(".");
41900
+ const parts2 = fileName.split(".");
41901
+ if (parts2.length > 2) {
41902
+ const compoundExt = "." + parts2.slice(-2).join(".");
41205
41903
  if (EXCLUDED_EXTENSIONS.has(compoundExt)) {
41206
41904
  return true;
41207
41905
  }
@@ -42348,10 +43046,10 @@ function parseRule(raw) {
42348
43046
  let specifier = rawSpecifier;
42349
43047
  let toolParamMatchers;
42350
43048
  if (specifierKind === "literal" && !canonicalName.startsWith("mcp__") && rawSpecifier.includes(":")) {
42351
- const parts = rawSpecifier.split(",").map((p2) => p2.trim());
43049
+ const parts2 = rawSpecifier.split(",").map((p2) => p2.trim());
42352
43050
  const plainParts = [];
42353
43051
  const matchers = [];
42354
- for (const part of parts) {
43052
+ for (const part of parts2) {
42355
43053
  const colonIdx = part.indexOf(":");
42356
43054
  if (colonIdx > 0) {
42357
43055
  const key = part.substring(0, colonIdx).trim();
@@ -42468,19 +43166,19 @@ function buildPermissionRules(ctx) {
42468
43166
  if (canonicalName.startsWith("mcp__")) {
42469
43167
  return [displayName];
42470
43168
  }
42471
- const parts = [];
42472
- if (ctx.specifier) parts.push(ctx.specifier);
43169
+ const parts2 = [];
43170
+ if (ctx.specifier) parts2.push(ctx.specifier);
42473
43171
  const stableParamKeys = /* @__PURE__ */ new Set(["model", "subagent_type", "skill"]);
42474
43172
  if (ctx.toolParams) {
42475
43173
  for (const key of stableParamKeys) {
42476
43174
  const v2 = ctx.toolParams[key];
42477
43175
  if (typeof v2 === "string" || typeof v2 === "number") {
42478
43176
  if (ctx.specifier && String(v2) === ctx.specifier) continue;
42479
- parts.push(`${key}:${v2}`);
43177
+ parts2.push(`${key}:${v2}`);
42480
43178
  }
42481
43179
  }
42482
43180
  }
42483
- if (parts.length > 0) return [`${displayName}(${parts.join(",")})`];
43181
+ if (parts2.length > 0) return [`${displayName}(${parts2.join(",")})`];
42484
43182
  return [displayName];
42485
43183
  }
42486
43184
  }
@@ -42515,12 +43213,12 @@ function cleanPathSpecifier(specifier) {
42515
43213
  __name(cleanPathSpecifier, "cleanPathSpecifier");
42516
43214
  function buildHumanReadableRuleLabel(rules) {
42517
43215
  if (!rules.length) return "";
42518
- const parts = [];
43216
+ const parts2 = [];
42519
43217
  for (const rule of rules) {
42520
43218
  const parenIdx = rule.indexOf("(");
42521
43219
  if (parenIdx === -1) {
42522
43220
  const verb2 = DISPLAY_NAME_TO_VERB[rule] ?? rule.toLowerCase();
42523
- parts.push(verb2);
43221
+ parts2.push(verb2);
42524
43222
  continue;
42525
43223
  }
42526
43224
  const displayName = rule.substring(0, parenIdx);
@@ -42533,25 +43231,25 @@ function buildHumanReadableRuleLabel(rules) {
42533
43231
  switch (kind) {
42534
43232
  case "path": {
42535
43233
  const cleanPath = cleanPathSpecifier(specifier);
42536
- parts.push(`${verb} in ${cleanPath}`);
43234
+ parts2.push(`${verb} in ${cleanPath}`);
42537
43235
  break;
42538
43236
  }
42539
43237
  case "command": {
42540
43238
  const cmdVerb = DISPLAY_NAME_TO_VERB[displayName] ?? "run";
42541
43239
  const verbWord = cmdVerb.split(" ")[0];
42542
- parts.push(`${verbWord} '${specifier}' commands`);
43240
+ parts2.push(`${verbWord} '${specifier}' commands`);
42543
43241
  break;
42544
43242
  }
42545
43243
  case "domain":
42546
- parts.push(`${verb} ${specifier}`);
43244
+ parts2.push(`${verb} ${specifier}`);
42547
43245
  break;
42548
43246
  case "literal":
42549
43247
  default:
42550
- parts.push(`${verb} "${specifier}"`);
43248
+ parts2.push(`${verb} "${specifier}"`);
42551
43249
  break;
42552
43250
  }
42553
43251
  }
42554
- return parts.join(", ");
43252
+ return parts2.join(", ");
42555
43253
  }
42556
43254
  __name(buildHumanReadableRuleLabel, "buildHumanReadableRuleLabel");
42557
43255
  var SHELL_OPERATORS = ["&&", "||", ";;", "|&", "|", ";", "&", "\n"];
@@ -44961,6 +45659,19 @@ function detectCommandSubstitution(command) {
44961
45659
  }
44962
45660
  }
44963
45661
  if (char === "\\" && !inSingleQuotes) {
45662
+ if (nextChar === "\n" && command[i - 1] === "$") {
45663
+ let dollarStart = i - 1;
45664
+ while (dollarStart > 0 && command[dollarStart - 1] === "$") {
45665
+ dollarStart--;
45666
+ }
45667
+ let escapeStart = dollarStart;
45668
+ while (escapeStart > 0 && command[escapeStart - 1] === "\\") {
45669
+ escapeStart--;
45670
+ }
45671
+ if ((i - dollarStart) % 2 === 1 && (dollarStart - escapeStart) % 2 === 0 && command[i + 2] === "(") {
45672
+ return true;
45673
+ }
45674
+ }
44964
45675
  i += 2;
44965
45676
  continue;
44966
45677
  }
@@ -44983,6 +45694,9 @@ function detectCommandSubstitution(command) {
44983
45694
  if (char === "$" && nextChar === "(") {
44984
45695
  return true;
44985
45696
  }
45697
+ if (char === "$" && nextChar === "{" && /^\$\{[A-Za-z_][A-Za-z0-9_]*@P\}/.test(command.slice(i))) {
45698
+ return true;
45699
+ }
44986
45700
  if (char === "<" && nextChar === "(" && !inDoubleQuotes && !inBackticks) {
44987
45701
  return true;
44988
45702
  }
@@ -44998,7 +45712,7 @@ function detectCommandSubstitution(command) {
44998
45712
  return false;
44999
45713
  }
45000
45714
  __name(detectCommandSubstitution, "detectCommandSubstitution");
45001
- var COMMAND_SUBSTITUTION_WARNING = "Contains command substitution ($(...), backticks, <(...), or >(...)).";
45715
+ var COMMAND_SUBSTITUTION_WARNING = "Contains command substitution ($(...), backticks, <(...), >(...), or ${parameter@P}).";
45002
45716
  function hasShellSubstitution(rawCommand) {
45003
45717
  if (typeof rawCommand !== "string" || rawCommand.length === 0) return false;
45004
45718
  if (detectCommandSubstitution(rawCommand)) return true;
@@ -45018,7 +45732,7 @@ async function checkCommandPermissions(command, config, sessionAllowlist) {
45018
45732
  return {
45019
45733
  allAllowed: false,
45020
45734
  disallowedCommands: [command],
45021
- blockReason: "Command substitution using $(), `` ` ``, <(), or >() is not allowed for security reasons",
45735
+ blockReason: "Command substitution using $(), `` ` ``, <(), >(), or ${parameter@P} is not allowed for security reasons",
45022
45736
  isHardDenial: true
45023
45737
  };
45024
45738
  }
@@ -47894,7 +48608,16 @@ function evaluateSubstitutions(node) {
47894
48608
  /* @__PURE__ */ new Set(["command_substitution", "process_substitution"]),
47895
48609
  true
47896
48610
  );
47897
- if (substitutions.length === 0) return "read-only";
48611
+ if (substitutions.length === 0) {
48612
+ for (const expansion of collectDescendants(node, /* @__PURE__ */ new Set(["expansion"]))) {
48613
+ for (let i = 0; i < expansion.childCount - 1; i++) {
48614
+ if (expansion.child(i)?.type === "@" && expansion.child(i + 1)?.type === "P") {
48615
+ return "unknown";
48616
+ }
48617
+ }
48618
+ }
48619
+ return "read-only";
48620
+ }
47898
48621
  return mergeSafety(
47899
48622
  "unknown",
47900
48623
  ...substitutions.flatMap((substitution) => substitution.namedChildren).map(evaluateStatementSafety)
@@ -48042,6 +48765,13 @@ async function classifyInternal(command, cwd) {
48042
48765
  const safety = mergeSafety(
48043
48766
  ...root.namedChildren.map(evaluateStatementSafety)
48044
48767
  );
48768
+ if (safety === "read-only" && command.includes("\\\n")) {
48769
+ const normalizedSafety = await classifyInternal(
48770
+ command.replaceAll("\\\n", ""),
48771
+ cwd
48772
+ );
48773
+ if (normalizedSafety !== "read-only") return "unknown";
48774
+ }
48045
48775
  if (safety !== "read-only" || !cwd) return safety;
48046
48776
  return localGitConfigMakesCommandUnsafe(root, cwd) ? "unknown" : "read-only";
48047
48777
  } finally {
@@ -52859,14 +53589,14 @@ function detectTurnInterruption(history) {
52859
53589
  trailingUserEntries.unshift(entry);
52860
53590
  }
52861
53591
  const allParts = trailingUserEntries.flatMap((entry) => entry.parts ?? []);
52862
- const parts = [
53592
+ const parts2 = [
52863
53593
  ...allParts.filter((part) => part.functionResponse),
52864
53594
  ...allParts.filter((part) => !part.functionResponse)
52865
53595
  ];
52866
- if (parts.length === 0) {
53596
+ if (parts2.length === 0) {
52867
53597
  return { kind: "none" };
52868
53598
  }
52869
- return { kind: "interrupted_prompt", parts: structuredClone(parts) };
53599
+ return { kind: "interrupted_prompt", parts: structuredClone(parts2) };
52870
53600
  }
52871
53601
  if (last.role === "model") {
52872
53602
  const danglingCalls = [];
@@ -59606,13 +60336,13 @@ var FileTokenStorage = class extends BaseTokenStorage {
59606
60336
  return iv.toString("hex") + ":" + authTag.toString("hex") + ":" + encrypted;
59607
60337
  }
59608
60338
  decrypt(encryptedData) {
59609
- const parts = encryptedData.split(":");
59610
- if (parts.length !== 3) {
60339
+ const parts2 = encryptedData.split(":");
60340
+ if (parts2.length !== 3) {
59611
60341
  throw new Error("Invalid encrypted data format");
59612
60342
  }
59613
- const iv = Buffer.from(parts[0], "hex");
59614
- const authTag = Buffer.from(parts[1], "hex");
59615
- const encrypted = parts[2];
60343
+ const iv = Buffer.from(parts2[0], "hex");
60344
+ const authTag = Buffer.from(parts2[1], "hex");
60345
+ const encrypted = parts2[2];
59616
60346
  const decipher = crypto3.createDecipheriv(
59617
60347
  "aes-256-gcm",
59618
60348
  this.encryptionKey,
@@ -59802,7 +60532,7 @@ var HybridTokenStorage = class extends BaseTokenStorage {
59802
60532
  const forceFileStorage = process.env[FORCE_FILE_STORAGE_ENV_VAR] === "true";
59803
60533
  if (!forceFileStorage) {
59804
60534
  try {
59805
- const { KeychainTokenStorage: KeychainTokenStorage2 } = await import("./keychain-token-storage-GU75J2T2.js");
60535
+ const { KeychainTokenStorage: KeychainTokenStorage2 } = await import("./keychain-token-storage-3XFJ5ZB2.js");
59806
60536
  const keychainStorage = new KeychainTokenStorage2(this.serviceName);
59807
60537
  const isAvailable = await keychainStorage.isAvailable();
59808
60538
  if (isAvailable) {
@@ -61949,7 +62679,7 @@ function populateMcpServerCommand(mcpServers, mcpServerCommand, cwd) {
61949
62679
  __name(populateMcpServerCommand, "populateMcpServerCommand");
61950
62680
  async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig, opts) {
61951
62681
  try {
61952
- const { mcpToTool } = await import("./node-YSOU44FX.js");
62682
+ const { mcpToTool } = await import("./node-UUDY34IG.js");
61953
62683
  const mcpCallableTool = mcpToTool(mcpClient, {
61954
62684
  timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC
61955
62685
  });
@@ -67839,26 +68569,26 @@ var GrepToolInvocation = class extends BaseToolInvocation {
67839
68569
  let includedLines = 0;
67840
68570
  const visibleLines = [];
67841
68571
  if (Number.isFinite(charLimit)) {
67842
- const parts = [];
68572
+ const parts2 = [];
67843
68573
  let currentLength = 0;
67844
68574
  for (const line of linesToInclude) {
67845
68575
  const sep24 = includedLines > 0 ? 1 : 0;
67846
68576
  const projectedLength = currentLength + line.rawLine.length + sep24;
67847
68577
  if (projectedLength <= charLimit) {
67848
- parts.push(line.rawLine);
68578
+ parts2.push(line.rawLine);
67849
68579
  visibleLines.push(line);
67850
68580
  includedLines++;
67851
68581
  currentLength = projectedLength;
67852
68582
  } else {
67853
68583
  const remaining = Math.max(charLimit - currentLength - sep24, 10);
67854
68584
  const partialLine = line.rawLine.slice(0, remaining);
67855
- parts.push(partialLine + "...");
68585
+ parts2.push(partialLine + "...");
67856
68586
  visibleLines.push(line);
67857
68587
  truncatedByCharLimit = true;
67858
68588
  break;
67859
68589
  }
67860
68590
  }
67861
- grepOutput = parts.join("\n");
68591
+ grepOutput = parts2.join("\n");
67862
68592
  } else {
67863
68593
  grepOutput = linesToInclude.map((line) => line.rawLine).join("\n");
67864
68594
  visibleLines.push(...linesToInclude);
@@ -69196,8 +69926,8 @@ var AST = class {
69196
69926
  }
69197
69927
  return this;
69198
69928
  }
69199
- push(...parts) {
69200
- for (const p2 of parts) {
69929
+ push(...parts2) {
69930
+ for (const p2 of parts2) {
69201
69931
  if (p2 === "")
69202
69932
  continue;
69203
69933
  if (typeof p2 !== "string" && !(p2 instanceof _a && p2.#parent === this)) {
@@ -69305,7 +70035,7 @@ var AST = class {
69305
70035
  }
69306
70036
  let i = pos + 1;
69307
70037
  let part = new _a(null, ast);
69308
- const parts = [];
70038
+ const parts2 = [];
69309
70039
  let acc = "";
69310
70040
  while (i < str.length) {
69311
70041
  const c = str.charAt(i++);
@@ -69345,7 +70075,7 @@ var AST = class {
69345
70075
  if (c === "|") {
69346
70076
  part.push(acc);
69347
70077
  acc = "";
69348
- parts.push(part);
70078
+ parts2.push(part);
69349
70079
  part = new _a(null, ast);
69350
70080
  continue;
69351
70081
  }
@@ -69355,7 +70085,7 @@ var AST = class {
69355
70085
  }
69356
70086
  part.push(acc);
69357
70087
  acc = "";
69358
- ast.push(...parts, part);
70088
+ ast.push(...parts2, part);
69359
70089
  return i;
69360
70090
  }
69361
70091
  acc += c;
@@ -69971,24 +70701,24 @@ var Minimatch = class {
69971
70701
  }
69972
70702
  // just get rid of adjascent ** portions
69973
70703
  adjascentGlobstarOptimize(globParts) {
69974
- return globParts.map((parts) => {
70704
+ return globParts.map((parts2) => {
69975
70705
  let gs2 = -1;
69976
- while (-1 !== (gs2 = parts.indexOf("**", gs2 + 1))) {
70706
+ while (-1 !== (gs2 = parts2.indexOf("**", gs2 + 1))) {
69977
70707
  let i = gs2;
69978
- while (parts[i + 1] === "**") {
70708
+ while (parts2[i + 1] === "**") {
69979
70709
  i++;
69980
70710
  }
69981
70711
  if (i !== gs2) {
69982
- parts.splice(gs2, i - gs2);
70712
+ parts2.splice(gs2, i - gs2);
69983
70713
  }
69984
70714
  }
69985
- return parts;
70715
+ return parts2;
69986
70716
  });
69987
70717
  }
69988
70718
  // get rid of adjascent ** and resolve .. portions
69989
70719
  levelOneOptimize(globParts) {
69990
- return globParts.map((parts) => {
69991
- parts = parts.reduce((set, part) => {
70720
+ return globParts.map((parts2) => {
70721
+ parts2 = parts2.reduce((set, part) => {
69992
70722
  const prev = set[set.length - 1];
69993
70723
  if (part === "**" && prev === "**") {
69994
70724
  return set;
@@ -70002,43 +70732,43 @@ var Minimatch = class {
70002
70732
  set.push(part);
70003
70733
  return set;
70004
70734
  }, []);
70005
- return parts.length === 0 ? [""] : parts;
70735
+ return parts2.length === 0 ? [""] : parts2;
70006
70736
  });
70007
70737
  }
70008
- levelTwoFileOptimize(parts) {
70009
- if (!Array.isArray(parts)) {
70010
- parts = this.slashSplit(parts);
70738
+ levelTwoFileOptimize(parts2) {
70739
+ if (!Array.isArray(parts2)) {
70740
+ parts2 = this.slashSplit(parts2);
70011
70741
  }
70012
70742
  let didSomething = false;
70013
70743
  do {
70014
70744
  didSomething = false;
70015
70745
  if (!this.preserveMultipleSlashes) {
70016
- for (let i = 1; i < parts.length - 1; i++) {
70017
- const p2 = parts[i];
70018
- if (i === 1 && p2 === "" && parts[0] === "")
70746
+ for (let i = 1; i < parts2.length - 1; i++) {
70747
+ const p2 = parts2[i];
70748
+ if (i === 1 && p2 === "" && parts2[0] === "")
70019
70749
  continue;
70020
70750
  if (p2 === "." || p2 === "") {
70021
70751
  didSomething = true;
70022
- parts.splice(i, 1);
70752
+ parts2.splice(i, 1);
70023
70753
  i--;
70024
70754
  }
70025
70755
  }
70026
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
70756
+ if (parts2[0] === "." && parts2.length === 2 && (parts2[1] === "." || parts2[1] === "")) {
70027
70757
  didSomething = true;
70028
- parts.pop();
70758
+ parts2.pop();
70029
70759
  }
70030
70760
  }
70031
70761
  let dd = 0;
70032
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
70033
- const p2 = parts[dd - 1];
70762
+ while (-1 !== (dd = parts2.indexOf("..", dd + 1))) {
70763
+ const p2 = parts2[dd - 1];
70034
70764
  if (p2 && p2 !== "." && p2 !== ".." && p2 !== "**") {
70035
70765
  didSomething = true;
70036
- parts.splice(dd - 1, 2);
70766
+ parts2.splice(dd - 1, 2);
70037
70767
  dd -= 2;
70038
70768
  }
70039
70769
  }
70040
70770
  } while (didSomething);
70041
- return parts.length === 0 ? [""] : parts;
70771
+ return parts2.length === 0 ? [""] : parts2;
70042
70772
  }
70043
70773
  // First phase: single-pattern processing
70044
70774
  // <pre> is 1 or more portions
@@ -70062,57 +70792,57 @@ var Minimatch = class {
70062
70792
  let didSomething = false;
70063
70793
  do {
70064
70794
  didSomething = false;
70065
- for (let parts of globParts) {
70795
+ for (let parts2 of globParts) {
70066
70796
  let gs2 = -1;
70067
- while (-1 !== (gs2 = parts.indexOf("**", gs2 + 1))) {
70797
+ while (-1 !== (gs2 = parts2.indexOf("**", gs2 + 1))) {
70068
70798
  let gss = gs2;
70069
- while (parts[gss + 1] === "**") {
70799
+ while (parts2[gss + 1] === "**") {
70070
70800
  gss++;
70071
70801
  }
70072
70802
  if (gss > gs2) {
70073
- parts.splice(gs2 + 1, gss - gs2);
70803
+ parts2.splice(gs2 + 1, gss - gs2);
70074
70804
  }
70075
- let next = parts[gs2 + 1];
70076
- const p2 = parts[gs2 + 2];
70077
- const p22 = parts[gs2 + 3];
70805
+ let next = parts2[gs2 + 1];
70806
+ const p2 = parts2[gs2 + 2];
70807
+ const p22 = parts2[gs2 + 3];
70078
70808
  if (next !== "..")
70079
70809
  continue;
70080
70810
  if (!p2 || p2 === "." || p2 === ".." || !p22 || p22 === "." || p22 === "..") {
70081
70811
  continue;
70082
70812
  }
70083
70813
  didSomething = true;
70084
- parts.splice(gs2, 1);
70085
- const other2 = parts.slice(0);
70814
+ parts2.splice(gs2, 1);
70815
+ const other2 = parts2.slice(0);
70086
70816
  other2[gs2] = "**";
70087
70817
  globParts.push(other2);
70088
70818
  gs2--;
70089
70819
  }
70090
70820
  if (!this.preserveMultipleSlashes) {
70091
- for (let i = 1; i < parts.length - 1; i++) {
70092
- const p2 = parts[i];
70093
- if (i === 1 && p2 === "" && parts[0] === "")
70821
+ for (let i = 1; i < parts2.length - 1; i++) {
70822
+ const p2 = parts2[i];
70823
+ if (i === 1 && p2 === "" && parts2[0] === "")
70094
70824
  continue;
70095
70825
  if (p2 === "." || p2 === "") {
70096
70826
  didSomething = true;
70097
- parts.splice(i, 1);
70827
+ parts2.splice(i, 1);
70098
70828
  i--;
70099
70829
  }
70100
70830
  }
70101
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
70831
+ if (parts2[0] === "." && parts2.length === 2 && (parts2[1] === "." || parts2[1] === "")) {
70102
70832
  didSomething = true;
70103
- parts.pop();
70833
+ parts2.pop();
70104
70834
  }
70105
70835
  }
70106
70836
  let dd = 0;
70107
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
70108
- const p2 = parts[dd - 1];
70837
+ while (-1 !== (dd = parts2.indexOf("..", dd + 1))) {
70838
+ const p2 = parts2[dd - 1];
70109
70839
  if (p2 && p2 !== "." && p2 !== ".." && p2 !== "**") {
70110
70840
  didSomething = true;
70111
- const needDot = dd === 1 && parts[dd + 1] === "**";
70841
+ const needDot = dd === 1 && parts2[dd + 1] === "**";
70112
70842
  const splin = needDot ? ["."] : [];
70113
- parts.splice(dd - 1, 2, ...splin);
70114
- if (parts.length === 0)
70115
- parts.push("");
70843
+ parts2.splice(dd - 1, 2, ...splin);
70844
+ if (parts2.length === 0)
70845
+ parts2.push("");
70116
70846
  dd -= 2;
70117
70847
  }
70118
70848
  }
@@ -76549,25 +77279,25 @@ function resolveOwnsModel(config) {
76549
77279
  }
76550
77280
  __name(resolveOwnsModel, "resolveOwnsModel");
76551
77281
  function buildGenerationConfig(spec) {
76552
- const parts = {};
77282
+ const parts2 = {};
76553
77283
  let hasAny = false;
76554
77284
  if (spec.enableThinking) {
76555
- parts.extra_body = { enable_thinking: true };
77285
+ parts2.extra_body = { enable_thinking: true };
76556
77286
  hasAny = true;
76557
77287
  }
76558
77288
  if (spec.thinkingMandatory) {
76559
- parts.thinkingMandatory = true;
77289
+ parts2.thinkingMandatory = true;
76560
77290
  hasAny = true;
76561
77291
  }
76562
77292
  if (spec.contextWindowSize) {
76563
- parts.contextWindowSize = spec.contextWindowSize;
77293
+ parts2.contextWindowSize = spec.contextWindowSize;
76564
77294
  hasAny = true;
76565
77295
  }
76566
77296
  if (spec.modalities && Object.values(spec.modalities).some(Boolean)) {
76567
- parts.modalities = spec.modalities;
77297
+ parts2.modalities = spec.modalities;
76568
77298
  hasAny = true;
76569
77299
  }
76570
- return hasAny ? parts : void 0;
77300
+ return hasAny ? parts2 : void 0;
76571
77301
  }
76572
77302
  __name(buildGenerationConfig, "buildGenerationConfig");
76573
77303
  function buildAdvancedGenerationConfig(advCfg) {
@@ -79717,8 +80447,8 @@ ${WORKTREES_DIR}/
79717
80447
  init_esbuild_shims();
79718
80448
  var debugLogger56 = createDebugLogger("TOOL_RESULT_VISION_BRIDGE");
79719
80449
  function getNestedParts(part) {
79720
- const parts = part.functionResponse?.parts;
79721
- return Array.isArray(parts) ? parts : void 0;
80450
+ const parts2 = part.functionResponse?.parts;
80451
+ return Array.isArray(parts2) ? parts2 : void 0;
79722
80452
  }
79723
80453
  __name(getNestedParts, "getNestedParts");
79724
80454
  function appendResponseText(response, text) {
@@ -80064,8 +80794,8 @@ ${body}`;
80064
80794
  }
80065
80795
  return this.visibleTextParts(projection.parts);
80066
80796
  }
80067
- visibleTextParts(parts) {
80068
- return parts.filter((p2) => !p2.thought && p2.text).map((p2) => p2.text).join("").trim();
80797
+ visibleTextParts(parts2) {
80798
+ return parts2.filter((p2) => !p2.thought && p2.text).map((p2) => p2.text).join("").trim();
80069
80799
  }
80070
80800
  static TITLE_MAX_LENGTH = 80;
80071
80801
  deriveTitle(records) {
@@ -80420,9 +81150,8 @@ init_esbuild_shims();
80420
81150
 
80421
81151
  // packages/core/src/utils/getPty.ts
80422
81152
  init_esbuild_shims();
80423
- var BUN_FORCE_PTY_ENV_VAR = "QWEN_TUI_FORCE_PTY";
80424
81153
  var getPty = /* @__PURE__ */ __name(async () => {
80425
- if ("bun" in process.versions && process.env[BUN_FORCE_PTY_ENV_VAR] !== "1") {
81154
+ if ("bun" in process.versions) {
80426
81155
  return null;
80427
81156
  }
80428
81157
  try {
@@ -80445,45 +81174,6 @@ import { spawn as cpSpawn, spawnSync as spawnSync3 } from "node:child_process";
80445
81174
  import { TextDecoder as TextDecoder2 } from "node:util";
80446
81175
  import os11 from "node:os";
80447
81176
 
80448
- // packages/core/src/utils/textUtils.ts
80449
- init_esbuild_shims();
80450
- import { stripVTControlCharacters as stripVTControlCharacters2 } from "node:util";
80451
- var CONTROL_CHARS_RE = /[\u0000-\u001f\u007f-\u009f]/g;
80452
- function stripAnsiAndControl(text) {
80453
- return stripVTControlCharacters2(text).replace(CONTROL_CHARS_RE, "");
80454
- }
80455
- __name(stripAnsiAndControl, "stripAnsiAndControl");
80456
- function safeLiteralReplace(str, oldString, newString) {
80457
- if (oldString === "" || !str.includes(oldString)) {
80458
- return str;
80459
- }
80460
- if (!newString.includes("$")) {
80461
- return str.replaceAll(oldString, newString);
80462
- }
80463
- const escapedNewString = newString.replaceAll("$", "$$$$");
80464
- return str.replaceAll(oldString, escapedNewString);
80465
- }
80466
- __name(safeLiteralReplace, "safeLiteralReplace");
80467
- function isBinary(data, sampleSize = 512) {
80468
- if (!data) {
80469
- return false;
80470
- }
80471
- const sample = data.length > sampleSize ? data.subarray(0, sampleSize) : data;
80472
- for (const byte of sample) {
80473
- if (byte === 0) {
80474
- return true;
80475
- }
80476
- }
80477
- return false;
80478
- }
80479
- __name(isBinary, "isBinary");
80480
- function normalizeContent(content) {
80481
- let normalized2 = content.replace(/^\uFEFF/, "");
80482
- normalized2 = normalized2.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
80483
- return normalized2;
80484
- }
80485
- __name(normalizeContent, "normalizeContent");
80486
-
80487
81177
  // packages/core/src/utils/load-xterm-headless.ts
80488
81178
  init_esbuild_shims();
80489
81179
  var xtermHeadlessModulePromise;
@@ -82764,14 +83454,14 @@ function attachJsonlTranscriptWriter(emitter, jsonlPath, options2) {
82764
83454
  }
82765
83455
  }, "appendStreamText");
82766
83456
  const onRoundText = /* @__PURE__ */ __name((event) => {
82767
- const parts = [
83457
+ const parts2 = [
82768
83458
  ...event.thoughtText ? [{ text: event.thoughtText, thought: true }] : [],
82769
83459
  ...event.text ? [{ text: event.text }] : []
82770
83460
  ];
82771
- if (parts.length === 0 && !event.usageMetadata) return;
83461
+ if (parts2.length === 0 && !event.usageMetadata) return;
82772
83462
  append({
82773
83463
  ...baseFields("assistant"),
82774
- message: { role: "model", parts },
83464
+ message: { role: "model", parts: parts2 },
82775
83465
  usageMetadata: event.usageMetadata,
82776
83466
  agentRunId: event.runId ?? streamRunId,
82777
83467
  agentRound: event.round
@@ -83339,8 +84029,8 @@ var BackgroundShellRegistry = class {
83339
84029
  /**
83340
84030
  * Subscribe to new-entry events. Called synchronously inside `register()`.
83341
84031
  * Setting `undefined` clears the existing subscriber. Single-subscriber on
83342
- * purpose — the UI hook is the only consumer in the codebase, and a list
83343
- * would invite drift in error-handling.
84032
+ * purpose — each runtime installs one owner callback, and a list would
84033
+ * invite drift in error-handling.
83344
84034
  */
83345
84035
  setRegisterCallback(cb) {
83346
84036
  this.registerCallback = cb;
@@ -83349,14 +84039,19 @@ var BackgroundShellRegistry = class {
83349
84039
  this.notificationCallback = cb;
83350
84040
  }
83351
84041
  /**
83352
- * Subscribe to status transitions (running → terminal). Called
83353
- * synchronously inside `complete()` / `fail()` / `cancel()` after the
83354
- * entry has been mutated. Same single-subscriber rationale as
83355
- * `setRegisterCallback`.
84042
+ * Subscribe to registration and status transitions (running → terminal).
84043
+ * Called synchronously after the registry has been mutated. Same
84044
+ * single-subscriber rationale as `setRegisterCallback`.
83356
84045
  */
83357
84046
  setStatusChangeCallback(cb) {
83358
84047
  this.statusChangeCallback = cb;
83359
84048
  }
84049
+ /** Retract `cb` only if it is still the installed callback. */
84050
+ clearStatusChangeCallback(cb) {
84051
+ if (this.statusChangeCallback === cb) {
84052
+ this.statusChangeCallback = void 0;
84053
+ }
84054
+ }
83360
84055
  register(registration) {
83361
84056
  const entry = registration;
83362
84057
  entry.id = registration.shellId;
@@ -83612,8 +84307,8 @@ var BackgroundShellRegistry = class {
83612
84307
  * statusChange callback exactly once after the loop. The per-entry
83613
84308
  * `cancel()` path would have triggered both side channels for every
83614
84309
  * running shell — wasteful on shutdown / `/clear` where the only
83615
- * subscriber (`useBackgroundTaskView`) just re-pulls `getAll()`
83616
- * regardless of the entry argument.
84310
+ * current subscriber just re-pulls the registry regardless of the entry
84311
+ * argument.
83617
84312
  */
83618
84313
  abortAll() {
83619
84314
  const endTime = Date.now();
@@ -88034,8 +88729,8 @@ async function getProcessInfo(pid) {
88034
88729
  if (!trimmedStdout) {
88035
88730
  return { parentPid: 0, name: "", command: "" };
88036
88731
  }
88037
- const parts = trimmedStdout.split(/\s+/);
88038
- const ppidString = parts[0];
88732
+ const parts2 = trimmedStdout.split(/\s+/);
88733
+ const ppidString = parts2[0];
88039
88734
  const parentPid = parseInt(ppidString, 10);
88040
88735
  const fullCommand = trimmedStdout.substring(ppidString.length).trim();
88041
88736
  const processName = path48.basename(fullCommand.split(" ")[0]);
@@ -90655,8 +91350,8 @@ var LspResponseNormalizer = class {
90655
91350
  return contents;
90656
91351
  }
90657
91352
  if (Array.isArray(contents)) {
90658
- const parts = contents.map((item) => this.normalizeHoverContents(item)).map((item) => item.trim()).filter((item) => item.length > 0);
90659
- return parts.join("\n");
91353
+ const parts2 = contents.map((item) => this.normalizeHoverContents(item)).map((item) => item.trim()).filter((item) => item.length > 0);
91354
+ return parts2.join("\n");
90660
91355
  }
90661
91356
  if (typeof contents === "object") {
90662
91357
  const contentsObj = contents;
@@ -96570,16 +97265,6 @@ import * as fs52 from "node:fs";
96570
97265
  import * as path55 from "node:path";
96571
97266
  import * as os16 from "node:os";
96572
97267
 
96573
- // packages/core/src/extension/redaction.ts
96574
- init_esbuild_shims();
96575
- var REDACTED_URL_CREDENTIAL = "***REDACTED***";
96576
- var URL_CREDENTIALS_PATTERN = /\b([a-z][a-z0-9+.-]*:\/\/)(?:[^/\s]+@)+/gi;
96577
- var UPLOAD_IDENTITY_PATTERN = /\bupload:v1:[0-9a-fA-F-]+:/gu;
96578
- function redactUrlCredentials(source) {
96579
- return source.replace(UPLOAD_IDENTITY_PATTERN, "upload:").replace(URL_CREDENTIALS_PATTERN, `$1${REDACTED_URL_CREDENTIAL}@`);
96580
- }
96581
- __name(redactUrlCredentials, "redactUrlCredentials");
96582
-
96583
97268
  // packages/core/src/extension/http-client.ts
96584
97269
  init_esbuild_shims();
96585
97270
  import * as http2 from "node:http";
@@ -98833,14 +99518,14 @@ async function cloneFromGit(installMetadata, destination, signal) {
98833
99518
  __name(cloneFromGit, "cloneFromGit");
98834
99519
  function parseGitHubRepoForReleases(source) {
98835
99520
  const parsedUrl = URL.parse(source, "https://github.com");
98836
- const parts = parsedUrl?.pathname.substring(1).split("/");
98837
- if (parts?.length !== 2 || parsedUrl?.host !== "github.com") {
99521
+ const parts2 = parsedUrl?.pathname.substring(1).split("/");
99522
+ if (parts2?.length !== 2 || parsedUrl?.host !== "github.com") {
98838
99523
  throw new Error(
98839
99524
  `Invalid GitHub repository source: ${redactUrlCredentials(source)}. Expected "owner/repo" or a github repo uri.`
98840
99525
  );
98841
99526
  }
98842
- const owner = parts[0];
98843
- const repo = parts[1].replace(/\.git$/, "");
99527
+ const owner = parts2[0];
99528
+ const repo = parts2[1].replace(/\.git$/, "");
98844
99529
  if (owner.startsWith("git@github.com")) {
98845
99530
  throw new Error(
98846
99531
  `GitHub release-based extensions are not supported for SSH. You must use an HTTPS URI with a personal access token to download releases from private repositories. You can set your personal access token in the GITHUB_TOKEN environment variable and install the extension via SSH.`
@@ -104960,7 +105645,7 @@ var ExtensionManager = class _ExtensionManager {
104960
105645
  } catch {
104961
105646
  return "dir:-";
104962
105647
  }
104963
- const parts = [];
105648
+ const parts2 = [];
104964
105649
  for (const entry of entries) {
104965
105650
  const extensionRoot = path72.join(this.configDir, entry);
104966
105651
  const installMetadata = this.loadInstallMetadata(extensionRoot);
@@ -104983,9 +105668,9 @@ var ExtensionManager = class _ExtensionManager {
104983
105668
  followManifestSymlink
104984
105669
  );
104985
105670
  if (stamp === "-") continue;
104986
- parts.push(`ext:${entry}:${stamp}`);
105671
+ parts2.push(`ext:${entry}:${stamp}`);
104987
105672
  }
104988
- return parts.sort().join("|");
105673
+ return parts2.sort().join("|");
104989
105674
  }
104990
105675
  /**
104991
105676
  * Fingerprints the enablement file and the store's activation state — where
@@ -107484,9 +108169,9 @@ var WatchHelper = class {
107484
108169
  this.watchPath = watchPath;
107485
108170
  this.fullWatchPath = sysPath2.resolve(watchPath);
107486
108171
  this.dirParts = [];
107487
- this.dirParts.forEach((parts) => {
107488
- if (parts.length > 1)
107489
- parts.pop();
108172
+ this.dirParts.forEach((parts2) => {
108173
+ if (parts2.length > 1)
108174
+ parts2.pop();
107490
108175
  });
107491
108176
  this.followSymlinks = follow;
107492
108177
  this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
@@ -112959,24 +113644,24 @@ ${_TeamManager.escapeEnvelopeTags(m2.text)}
112959
113644
  }
112960
113645
  }
112961
113646
  }
112962
- const parts = [
113647
+ const parts2 = [
112963
113648
  "<team_status>",
112964
113649
  `${active} active, ${completed} completed` + (stalled > 0 ? `, ${stalled} stalled.` : "."),
112965
113650
  ...lines
112966
113651
  ];
112967
113652
  if (stalled > 0 && active === 0) {
112968
- parts.push(
113653
+ parts2.push(
112969
113654
  "",
112970
113655
  "All remaining teammates are stalled. Proceed with the results you have \u2014 write your report now."
112971
113656
  );
112972
113657
  } else {
112973
- parts.push(
113658
+ parts2.push(
112974
113659
  "",
112975
113660
  "Do NOT call task_list to check on teammates. Their results will arrive as messages. Wait patiently or proceed with other work."
112976
113661
  );
112977
113662
  }
112978
- parts.push("</team_status>");
112979
- return parts.join("\n");
113663
+ parts2.push("</team_status>");
113664
+ return parts2.join("\n");
112980
113665
  }
112981
113666
  /**
112982
113667
  * Returns true if all non-terminal teammates are stalled
@@ -114773,9 +115458,9 @@ function reconstructHistory(records, leafUuid) {
114773
115458
  return uuids.map((uuid) => firstByUuid.get(uuid)).filter((record2) => !!record2);
114774
115459
  }
114775
115460
  __name(reconstructHistory, "reconstructHistory");
114776
- function extractText(parts) {
114777
- if (!parts?.length) return "";
114778
- return parts.map((part) => "text" in part && part.text ? part.text : "").join("\n").trim();
115461
+ function extractText(parts2) {
115462
+ if (!parts2?.length) return "";
115463
+ return parts2.map((part) => "text" in part && part.text ? part.text : "").join("\n").trim();
114779
115464
  }
114780
115465
  __name(extractText, "extractText");
114781
115466
  function coalesceAdjacentUserHistory(messages) {
@@ -116639,8 +117324,8 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116639
117324
  if (state.abortController?.signal.aborted) break;
116640
117325
  if (event.type !== "chunk" /* CHUNK */) continue;
116641
117326
  const response = event.value;
116642
- const parts = response.candidates?.[0]?.content?.parts ?? [];
116643
- for (const part of parts) {
117327
+ const parts2 = response.candidates?.[0]?.content?.parts ?? [];
117328
+ for (const part of parts2) {
116644
117329
  if (part.text && !part["thought"]) {
116645
117330
  modelParts.push({ text: part.text });
116646
117331
  }
@@ -116659,16 +117344,16 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116659
117344
  if (modelParts.length === 0) break;
116660
117345
  const modelMsg = { role: "model", parts: modelParts };
116661
117346
  messages.push(modelMsg);
116662
- const functionCalls = modelParts.filter(
117347
+ const functionCalls2 = modelParts.filter(
116663
117348
  (p2) => p2.functionCall !== void 0
116664
117349
  );
116665
- if (functionCalls.length === 0) {
117350
+ if (functionCalls2.length === 0) {
116666
117351
  break;
116667
117352
  }
116668
- let functionResponses = [];
117353
+ let functionResponses2 = [];
116669
117354
  const responseEntries = [];
116670
117355
  let hitBoundary = false;
116671
- for (const part of functionCalls) {
117356
+ for (const part of functionCalls2) {
116672
117357
  const fc = part.functionCall;
116673
117358
  const name = fc.name ?? "";
116674
117359
  const id = fc.id;
@@ -116704,7 +117389,7 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116704
117389
  response: { error: `Tool '${name}' not found` }
116705
117390
  }
116706
117391
  };
116707
- functionResponses.push(responsePart);
117392
+ functionResponses2.push(responsePart);
116708
117393
  responseEntries.push({
116709
117394
  callId: persistenceCallId,
116710
117395
  toolName: name,
@@ -116723,6 +117408,8 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116723
117408
  toolName: canonicalToolName(name),
116724
117409
  args: invocation.params,
116725
117410
  signal: state.abortController.signal,
117411
+ sessionId: config.getSessionId(),
117412
+ cwd: config.getTargetDir(),
116726
117413
  ...invocationContext ? { invocationContext } : {}
116727
117414
  }
116728
117415
  );
@@ -116758,7 +117445,7 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116758
117445
  const { id: _id, ...functionResponse } = responsePart.functionResponse;
116759
117446
  return { ...responsePart, functionResponse };
116760
117447
  });
116761
- functionResponses.push(...responseParts);
117448
+ functionResponses2.push(...responseParts);
116762
117449
  responseEntries.push({
116763
117450
  callId: persistenceCallId,
116764
117451
  toolName: name,
@@ -116775,7 +117462,7 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116775
117462
  }
116776
117463
  }
116777
117464
  };
116778
- functionResponses.push(responsePart);
117465
+ functionResponses2.push(responsePart);
116779
117466
  responseEntries.push({
116780
117467
  callId: persistenceCallId,
116781
117468
  toolName: name,
@@ -116785,14 +117472,14 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116785
117472
  }
116786
117473
  if (responseEntries.length > 0) {
116787
117474
  const finalized = await finalizeToolResponses(config, responseEntries);
116788
- functionResponses = finalized.flatMap((entry) => entry.responseParts);
117475
+ functionResponses2 = finalized.flatMap((entry) => entry.responseParts);
116789
117476
  }
116790
117477
  if (hitBoundary) {
116791
- if (functionResponses.length > 0) {
117478
+ if (functionResponses2.length > 0) {
116792
117479
  let keptFunctionCalls = 0;
116793
117480
  const keptModelParts = modelParts.filter((p2) => {
116794
117481
  if (!p2.functionCall) return true;
116795
- if (keptFunctionCalls < functionResponses.length) {
117482
+ if (keptFunctionCalls < functionResponses2.length) {
116796
117483
  keptFunctionCalls++;
116797
117484
  return true;
116798
117485
  }
@@ -116803,7 +117490,7 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116803
117490
  role: "model",
116804
117491
  parts: keptModelParts
116805
117492
  };
116806
- messages.push({ role: "user", parts: functionResponses });
117493
+ messages.push({ role: "user", parts: functionResponses2 });
116807
117494
  } else {
116808
117495
  messages.pop();
116809
117496
  }
@@ -116829,8 +117516,8 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
116829
117516
  }
116830
117517
  };
116831
117518
  }
116832
- if (functionResponses.length > 0) {
116833
- const resultMsg = { role: "user", parts: functionResponses };
117519
+ if (functionResponses2.length > 0) {
117520
+ const resultMsg = { role: "user", parts: functionResponses2 };
116834
117521
  messages.push(resultMsg);
116835
117522
  }
116836
117523
  }
@@ -117328,14 +118015,14 @@ function redactArgsForLog(args) {
117328
118015
  }
117329
118016
  __name(redactArgsForLog, "redactArgsForLog");
117330
118017
  function logCommandProblem(kind, command, args, detail) {
117331
- const parts = [`[crawler] ${kind}:`, command, redactArgsForLog(args)];
118018
+ const parts2 = [`[crawler] ${kind}:`, command, redactArgsForLog(args)];
117332
118019
  if (detail.code !== void 0 && detail.code !== null) {
117333
- parts.push(`exit=${String(detail.code)}`);
118020
+ parts2.push(`exit=${String(detail.code)}`);
117334
118021
  }
117335
118022
  if (detail.stderr && detail.stderr.length > 0) {
117336
- parts.push(truncateStderrSnippet(detail.stderr));
118023
+ parts2.push(truncateStderrSnippet(detail.stderr));
117337
118024
  }
117338
- console.warn(parts.join(" "));
118025
+ console.warn(parts2.join(" "));
117339
118026
  }
117340
118027
  __name(logCommandProblem, "logCommandProblem");
117341
118028
  function withSafeGitConfig(args) {
@@ -118150,10 +118837,10 @@ function buildResultsFromFileSet(files, extraDirectories = []) {
118150
118837
  dirSet.add(dir);
118151
118838
  }
118152
118839
  for (const file of files) {
118153
- const parts = file.split("/");
118840
+ const parts2 = file.split("/");
118154
118841
  let current = "";
118155
- for (let i = 0; i < parts.length - 1; i++) {
118156
- current = current ? current + "/" + parts[i] : parts[i];
118842
+ for (let i = 0; i < parts2.length - 1; i++) {
118843
+ current = current ? current + "/" + parts2[i] : parts2[i];
118157
118844
  dirSet.add(current + "/");
118158
118845
  }
118159
118846
  }
@@ -120043,16 +120730,16 @@ __name(fetchGitBranches, "fetchGitBranches");
120043
120730
  function parseBranchLines(raw) {
120044
120731
  if (!raw.trim()) return [];
120045
120732
  return raw.trim().split("\n").filter(Boolean).filter((line) => {
120046
- const parts = line.split(SEPARATOR);
120047
- return !(parts[6] ?? "");
120733
+ const parts2 = line.split(SEPARATOR);
120734
+ return !(parts2[6] ?? "");
120048
120735
  }).map((line) => {
120049
- const parts = line.split(SEPARATOR);
120050
- const name = parts[0] ?? "";
120051
- const isHead = parts[1] === "*";
120052
- const upstream = parts[2] || void 0;
120053
- const track = parts[3] ?? "";
120054
- const commitDate = parseInt(parts[4] ?? "0", 10) || 0;
120055
- const commitSubject = parts[5] ?? "";
120736
+ const parts2 = line.split(SEPARATOR);
120737
+ const name = parts2[0] ?? "";
120738
+ const isHead = parts2[1] === "*";
120739
+ const upstream = parts2[2] || void 0;
120740
+ const track = parts2[3] ?? "";
120741
+ const commitDate = parseInt(parts2[4] ?? "0", 10) || 0;
120742
+ const commitSubject = parts2[5] ?? "";
120056
120743
  let ahead = 0;
120057
120744
  let behind = 0;
120058
120745
  const aheadMatch = /ahead (\d+)/.exec(track);
@@ -120074,11 +120761,11 @@ __name(parseBranchLines, "parseBranchLines");
120074
120761
  function parseTagLines(raw) {
120075
120762
  if (!raw.trim()) return [];
120076
120763
  return raw.trim().split("\n").filter(Boolean).map((line) => {
120077
- const parts = line.split(SEPARATOR);
120764
+ const parts2 = line.split(SEPARATOR);
120078
120765
  return {
120079
- name: parts[0] ?? "",
120080
- date: parseInt(parts[1] ?? "0", 10) || 0,
120081
- subject: parts[2] ?? ""
120766
+ name: parts2[0] ?? "",
120767
+ date: parseInt(parts2[1] ?? "0", 10) || 0,
120768
+ subject: parts2[2] ?? ""
120082
120769
  };
120083
120770
  });
120084
120771
  }
@@ -125127,9 +125814,9 @@ function isMetadataAddress(address) {
125127
125814
  }
125128
125815
  __name(isMetadataAddress, "isMetadataAddress");
125129
125816
  function isBlockedV4(address) {
125130
- const parts = address.split(".").map(Number);
125131
- const [a, b2] = parts;
125132
- if (parts.length !== 4 || a === void 0 || b2 === void 0 || parts.some((n) => Number.isNaN(n))) {
125817
+ const parts2 = address.split(".").map(Number);
125818
+ const [a, b2] = parts2;
125819
+ if (parts2.length !== 4 || a === void 0 || b2 === void 0 || parts2.some((n) => Number.isNaN(n))) {
125133
125820
  return false;
125134
125821
  }
125135
125822
  if (a === 127) return false;
@@ -129740,8 +130427,8 @@ function applySedSubstitution(content, sedInfo) {
129740
130427
  const replaceAll = sedInfo.flags.includes("g");
129741
130428
  try {
129742
130429
  const globalRegex = new RegExp(jsPattern, "g");
129743
- const parts = content.split(/(\n)/);
129744
- const processableParts = content.endsWith("\n") ? parts.slice(0, -1) : parts;
130430
+ const parts2 = content.split(/(\n)/);
130431
+ const processableParts = content.endsWith("\n") ? parts2.slice(0, -1) : parts2;
129745
130432
  return processableParts.map((part, index) => {
129746
130433
  if (index % 2 === 1) {
129747
130434
  return part;
@@ -129876,6 +130563,11 @@ __name(buildReplacement, "buildReplacement");
129876
130563
 
129877
130564
  // packages/core/src/tools/shell.ts
129878
130565
  var debugLogger125 = createDebugLogger("SHELL");
130566
+ var DEFAULT_SHELL_OUTPUT_THRESHOLD = 3e4;
130567
+ function getShellOutputThreshold(config) {
130568
+ return config.isTruncateToolOutputThresholdExplicit() ? config.getTruncateToolOutputThreshold() : DEFAULT_SHELL_OUTPUT_THRESHOLD;
130569
+ }
130570
+ __name(getShellOutputThreshold, "getShellOutputThreshold");
129879
130571
  function statusFileGuidance(outputPath) {
129880
130572
  return `status file: ${statusFilePathFor(outputPath)}
129881
130573
  To check whether this process is still running, Read the status file (status: running|completed|failed|cancelled). Do NOT infer liveness from the output file: programs often block-buffer stdout when not attached to a TTY, so an empty output file is normal while the process is alive (for live output, re-run with e.g. \`python -u\` or \`stdbuf -oL\`).`;
@@ -131531,6 +132223,7 @@ ${result.output}` : result.output;
131531
132223
  let persistedOutputFiles;
131532
132224
  if (typeof llmContent === "string") {
131533
132225
  const originalLlmContent = llmContent;
132226
+ const outputThreshold = getShellOutputThreshold(this.config);
131534
132227
  const truncatedResult = await truncateToolOutput(
131535
132228
  this.config,
131536
132229
  ShellTool.Name,
@@ -131541,11 +132234,11 @@ ${result.output}` : result.output;
131541
132234
  // scheduler) so the long-run hint below is appended OUTSIDE the
131542
132235
  // truncation envelope; the scheduler's sentinel makes its later pass a
131543
132236
  // no-op here. lines: Infinity keeps this char-only so the global line
131544
- // cap can't undercut the declared 30k char budget — many short lines
132237
+ // cap can't undercut the effective Shell char budget — many short lines
131545
132238
  // (e.g. `find /`, `ls -R`) would otherwise truncate while chars remain.
131546
132239
  {
131547
- threshold: 3e4,
131548
- previewChars: 4e3,
132240
+ threshold: outputThreshold,
132241
+ previewChars: Math.min(4e3, outputThreshold),
131549
132242
  keep: "both",
131550
132243
  lines: Number.POSITIVE_INFINITY
131551
132244
  }
@@ -132379,10 +133072,10 @@ To inspect: /tasks (text) or the interactive Background tasks dialog (focus the
132379
133072
  deletedFiles.add(line.slice(2).trim());
132380
133073
  continue;
132381
133074
  }
132382
- const parts = line.split(" ");
132383
- const status = parts[0] ?? "";
132384
- if (status.startsWith("R") && parts.length >= 3) {
132385
- renamedFiles.set(parts[1].trim(), parts[2].trim());
133075
+ const parts2 = line.split(" ");
133076
+ const status = parts2[0] ?? "";
133077
+ if (status.startsWith("R") && parts2.length >= 3) {
133078
+ renamedFiles.set(parts2[1].trim(), parts2[2].trim());
132386
133079
  }
132387
133080
  }
132388
133081
  const diffSizes = parseNumstat(numstatOutput);
@@ -132743,7 +133436,7 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
132743
133436
  }
132744
133437
  static Name = ToolNames.SHELL;
132745
133438
  get maxOutputChars() {
132746
- return 3e4;
133439
+ return getShellOutputThreshold(this.config);
132747
133440
  }
132748
133441
  validateToolParamValues(params) {
132749
133442
  if (!params.command.trim()) {
@@ -132842,8 +133535,8 @@ var GATE_EXEMPT_TOOLS = /* @__PURE__ */ new Set([
132842
133535
  function extractTextFromPartListUnion(c) {
132843
133536
  if (typeof c === "string") return c;
132844
133537
  if (Array.isArray(c)) {
132845
- const parts = toParts2(c);
132846
- return parts.map((p2) => p2.text ?? "").join("\n");
133538
+ const parts2 = toParts2(c);
133539
+ return parts2.map((p2) => p2.text ?? "").join("\n");
132847
133540
  }
132848
133541
  if (c && typeof c === "object") {
132849
133542
  if ("text" in c) {
@@ -132892,6 +133585,7 @@ var TRUNCATION_EDIT_REJECTION = "Your previous response was truncated due to max
132892
133585
  function setToolSpanFailure(span, failureKind, message) {
132893
133586
  try {
132894
133587
  span.setAttribute(TOOL_FAILURE_KIND_ATTRIBUTE, failureKind);
133588
+ span.setAttribute("error.type", failureKind);
132895
133589
  span.setAttribute("success", false);
132896
133590
  } catch {
132897
133591
  }
@@ -133136,15 +133830,15 @@ function convertToFunctionErrorResponse(toolName, callId, llmContent, fallbackEr
133136
133830
  }
133137
133831
  __name(convertToFunctionErrorResponse, "convertToFunctionErrorResponse");
133138
133832
  function toParts2(input) {
133139
- const parts = [];
133833
+ const parts2 = [];
133140
133834
  for (const part of Array.isArray(input) ? input : [input]) {
133141
133835
  if (typeof part === "string") {
133142
- parts.push({ text: part });
133836
+ parts2.push({ text: part });
133143
133837
  } else if (part) {
133144
- parts.push(part);
133838
+ parts2.push(part);
133145
133839
  }
133146
133840
  }
133147
- return parts;
133841
+ return parts2;
133148
133842
  }
133149
133843
  __name(toParts2, "toParts");
133150
133844
  var VALIDATION_RETRY_LOOP_THRESHOLD = 3;
@@ -133731,7 +134425,8 @@ var CoreToolScheduler = class {
133731
134425
  * second call for the same callId is a no-op.
133732
134426
  *
133733
134427
  * No `metadata` parameter: every caller pre-sets span status via
133734
- * `setToolSpan{Failure,Cancelled,Ok}` before this call (#4321 review).
134428
+ * `setToolSpan{Failure,Cancelled}` or the success path before this call
134429
+ * (#4321 review).
133735
134430
  */
133736
134431
  finalizeToolSpan(callId, force = false) {
133737
134432
  this.bouncedAwaitingApproval.delete(callId);
@@ -135660,6 +136355,8 @@ var CoreToolScheduler = class {
135660
136355
  toolName: canonicalName,
135661
136356
  args: invocation.params,
135662
136357
  signal,
136358
+ sessionId: this.config.getSessionId(),
136359
+ cwd: this.config.getTargetDir(),
135663
136360
  ...invocationContext ? { invocationContext } : {}
135664
136361
  }
135665
136362
  );
@@ -136212,7 +136909,6 @@ ${body}
136212
136909
  return;
136213
136910
  }
136214
136911
  this.setStatusInternal(callId, "success", successResponse);
136215
- safeSetStatus(span, { code: SpanStatusCode.OK });
136216
136912
  try {
136217
136913
  span.setAttribute("success", true);
136218
136914
  } catch {
@@ -137431,7 +138127,7 @@ var AgentCore = class {
137431
138127
  promptId,
137432
138128
  timestamp: Date.now()
137433
138129
  });
137434
- const functionCalls = [];
138130
+ const functionCalls2 = [];
137435
138131
  let roundText = "";
137436
138132
  let roundThoughtText = "";
137437
138133
  let lastUsage = void 0;
@@ -137455,7 +138151,7 @@ var AgentCore = class {
137455
138151
  if (streamEvent.maxOutputTokensEscalated !== void 0) {
137456
138152
  stickyMaxOutputTokens = streamEvent.maxOutputTokensEscalated;
137457
138153
  }
137458
- functionCalls.length = 0;
138154
+ functionCalls2.length = 0;
137459
138155
  roundText = "";
137460
138156
  roundThoughtText = "";
137461
138157
  lastUsage = void 0;
@@ -137475,13 +138171,13 @@ var AgentCore = class {
137475
138171
  currentResponseId = resp.responseId;
137476
138172
  }
137477
138173
  const chunkFunctionCalls = resp.functionCalls ?? [];
137478
- functionCalls.push(...chunkFunctionCalls);
138174
+ functionCalls2.push(...chunkFunctionCalls);
137479
138175
  if (resp.candidates?.[0]?.finishReason === FinishReason.MAX_TOKENS) {
137480
138176
  wasOutputTruncated = true;
137481
138177
  }
137482
138178
  const content = resp.candidates?.[0]?.content;
137483
- const parts = content?.parts || [];
137484
- for (const p2 of parts) {
138179
+ const parts2 = content?.parts || [];
138180
+ for (const p2 of parts2) {
137485
138181
  const txt = p2.text;
137486
138182
  const isThought = p2.thought ?? false;
137487
138183
  if (txt && isThought) roundThoughtText += txt;
@@ -137577,9 +138273,9 @@ var AgentCore = class {
137577
138273
  if (lastUsage) {
137578
138274
  this.recordTokenUsage(lastUsage, turnCounter, roundStreamStart);
137579
138275
  }
137580
- if (functionCalls.length > 0) {
138276
+ if (functionCalls2.length > 0) {
137581
138277
  const toolCallResult = await this.processFunctionCalls(
137582
- functionCalls,
138278
+ functionCalls2,
137583
138279
  roundAbortController,
137584
138280
  promptId,
137585
138281
  turnCounter,
@@ -137864,9 +138560,9 @@ ${text}` : text;
137864
138560
  *
137865
138561
  * Validates each call, schedules authorized calls, collects results, and emits events.
137866
138562
  */
137867
- async processFunctionCalls(functionCalls, abortController, promptId, currentRound, toolsList, responseId, wasOutputTruncated = false, handledProviderToolCallIds = /* @__PURE__ */ new Set(), duplicateProviderToolCallResponseIds = /* @__PURE__ */ new Set()) {
138563
+ async processFunctionCalls(functionCalls2, abortController, promptId, currentRound, toolsList, responseId, wasOutputTruncated = false, handledProviderToolCallIds = /* @__PURE__ */ new Set(), duplicateProviderToolCallResponseIds = /* @__PURE__ */ new Set()) {
137868
138564
  const responseByCallId = /* @__PURE__ */ new Map();
137869
- const uniqueFunctionCalls = dedupeToolCallsById(functionCalls);
138565
+ const uniqueFunctionCalls = dedupeToolCallsById(functionCalls2);
137870
138566
  const generatedCallIdBase = randomUUID12();
137871
138567
  const callIdByFunctionCall = new Map(
137872
138568
  uniqueFunctionCalls.map((functionCall, index) => [
@@ -138199,7 +138895,7 @@ ${text}` : text;
138199
138895
  }
138200
138896
  ];
138201
138897
  });
138202
- if (functionCalls.length > 0 && orderedResponses.length === 0) {
138898
+ if (functionCalls2.length > 0 && orderedResponses.length === 0) {
138203
138899
  orderedResponses.push({
138204
138900
  callId: "tool-call-batch",
138205
138901
  toolName: "tool-call-batch",
@@ -141584,13 +142280,13 @@ async function runForkedAgent(params) {
141584
142280
  for await (const event of stream2) {
141585
142281
  if (event.type !== "chunk" /* CHUNK */) continue;
141586
142282
  const response = event.value;
141587
- const parts = response.candidates?.[0]?.content?.parts ?? [];
141588
- if (preserveTools && parts.some((p2) => p2["functionCall"])) {
142283
+ const parts2 = response.candidates?.[0]?.content?.parts ?? [];
142284
+ if (preserveTools && parts2.some((p2) => p2["functionCall"])) {
141589
142285
  debugLogger128.warn(
141590
142286
  "Cache-path forked query received functionCall with preserveTools; discarding."
141591
142287
  );
141592
142288
  }
141593
- const text = parts.filter((p2) => !p2["thought"]).filter((p2) => !p2["functionCall"]).map((p2) => p2.text ?? "").join("");
142289
+ const text = parts2.filter((p2) => !p2["thought"]).filter((p2) => !p2["functionCall"]).map((p2) => p2.text ?? "").join("");
141594
142290
  if (text) fullText += text;
141595
142291
  if (response.usageMetadata)
141596
142292
  usage = extractQueryUsage(response.usageMetadata);
@@ -142689,10 +143385,10 @@ function toolAliases(toolName) {
142689
143385
  aliases.push(normalized2.split("::").at(-1) ?? "");
142690
143386
  }
142691
143387
  if (normalized2.startsWith("mcp__")) {
142692
- const parts = normalized2.split("__");
142693
- if (parts.length >= 3) {
142694
- aliases.push(parts.slice(2).join("__"));
142695
- aliases.push(parts.at(-1) ?? "");
143388
+ const parts2 = normalized2.split("__");
143389
+ if (parts2.length >= 3) {
143390
+ aliases.push(parts2.slice(2).join("__"));
143391
+ aliases.push(parts2.at(-1) ?? "");
142696
143392
  }
142697
143393
  }
142698
143394
  return Array.from(
@@ -144123,6 +144819,7 @@ var GeminiClient = class _GeminiClient {
144123
144819
  surfacedRelevantAutoMemoryPaths = /* @__PURE__ */ new Set();
144124
144820
  shutdownRequested = false;
144125
144821
  settledSteerInputs = /* @__PURE__ */ new WeakSet();
144822
+ interactionStartTypeByOwner = /* @__PURE__ */ new WeakMap();
144126
144823
  loopDetector;
144127
144824
  lastPromptId = void 0;
144128
144825
  activeTodoWorkChainPromptId;
@@ -145506,6 +146203,35 @@ var GeminiClient = class _GeminiClient {
145506
146203
  }
145507
146204
  async *sendMessageStream(request, callerSignal, prompt_id, options2, turns = MAX_TURNS2) {
145508
146205
  const messageType = options2?.type ?? "userQuery" /* UserQuery */;
146206
+ const startsInteraction = messageType === "userQuery" /* UserQuery */ || messageType === "retry" /* Retry */ || messageType === "cron" /* Cron */ || messageType === "notification" /* Notification */ || messageType === "teammate" /* Teammate */ || messageType === "goal" /* Goal */;
146207
+ let interactionOwner = startsInteraction ? void 0 : getActiveInteractionSpan(prompt_id);
146208
+ if (interactionOwner) {
146209
+ recordInteractionActivity(prompt_id, interactionOwner);
146210
+ }
146211
+ const agentOutput = new AgentOutputMessageCapture(this.config);
146212
+ const endCurrentInteraction = /* @__PURE__ */ __name((status, errorMessage, errorType) => {
146213
+ if (!interactionOwner || getActiveInteractionSpan(prompt_id) !== interactionOwner) {
146214
+ return;
146215
+ }
146216
+ const interactionStartType = this.interactionStartTypeByOwner.get(interactionOwner);
146217
+ const ownsStructuredOutputContract = interactionStartType === "userQuery" /* UserQuery */ || interactionStartType === "retry" /* Retry */;
146218
+ if (status === "ok" && ownsStructuredOutputContract && this.config.getJsonSchema?.()) {
146219
+ endInteractionSpan("error", {
146220
+ promptId: prompt_id,
146221
+ errorMessage: "model did not produce structured output",
146222
+ errorType: "structured_output_missing"
146223
+ });
146224
+ return;
146225
+ }
146226
+ if (status === "ok") {
146227
+ agentOutput.writeToSpan(interactionOwner);
146228
+ }
146229
+ endInteractionSpan(status, {
146230
+ promptId: prompt_id,
146231
+ ...errorMessage ? { errorMessage } : {},
146232
+ ...errorType ? { errorType } : {}
146233
+ });
146234
+ }, "endCurrentInteraction");
145509
146235
  if (messageType === "userQuery" /* UserQuery */ || messageType === "cron" /* Cron */ || messageType === "notification" /* Notification */ || messageType === "teammate" /* Teammate */) {
145510
146236
  await this.config.assertCanStartTurn();
145511
146237
  }
@@ -145663,9 +146389,30 @@ var GeminiClient = class _GeminiClient {
145663
146389
  pushCountAfterStrip = currentPushCount();
145664
146390
  }
145665
146391
  const preHookUserPromptText = messageType === "userQuery" /* UserQuery */ ? partToString(request) : void 0;
146392
+ if (startsInteraction) {
146393
+ this.loopDetector.reset(prompt_id);
146394
+ this.lastPromptId = prompt_id;
146395
+ startInteractionSpan(this.config, {
146396
+ promptId: prompt_id,
146397
+ model: options2?.modelOverride ?? this.config.getModel(),
146398
+ messageType
146399
+ });
146400
+ interactionOwner = getActiveInteractionSpan(prompt_id);
146401
+ if (interactionOwner && !this.interactionStartTypeByOwner.has(interactionOwner)) {
146402
+ this.interactionStartTypeByOwner.set(interactionOwner, messageType);
146403
+ }
146404
+ if (interactionOwner && messageType === "userQuery" /* UserQuery */ && typeof options2?.submittedPrompt === "string") {
146405
+ addAgentInputMessageAttributes(
146406
+ this.config,
146407
+ interactionOwner,
146408
+ options2.submittedPrompt
146409
+ );
146410
+ }
146411
+ }
145666
146412
  let userPromptRecordPayload;
145667
146413
  let hooksEnabled;
145668
146414
  let messageBus;
146415
+ let userPromptSubmitFailureMessage = "UserPromptSubmit hook failed";
145669
146416
  try {
145670
146417
  hooksEnabled = !this.config.getDisableAllHooks();
145671
146418
  messageBus = this.config.getMessageBus();
@@ -145690,6 +146437,7 @@ var GeminiClient = class _GeminiClient {
145690
146437
  const hookOutput = response.output ? createHookOutput("UserPromptSubmit", response.output) : void 0;
145691
146438
  if (hookOutput?.isBlockingDecision() || hookOutput?.shouldStopExecution()) {
145692
146439
  if (goalPermit) {
146440
+ userPromptSubmitFailureMessage = "Goal turn finalization failed";
145693
146441
  const runtime = await loadGoalRuntime(true);
145694
146442
  if (!runtime || !goalTurnKey) {
145695
146443
  throw new Error("Goal turn admission is unavailable");
@@ -145703,9 +146451,12 @@ var GeminiClient = class _GeminiClient {
145703
146451
  await runtime.finishTurn(goalPermit);
145704
146452
  goalPermitReleased = true;
145705
146453
  closeGoalStateEvents();
146454
+ endCurrentInteraction("cancelled");
145706
146455
  for (const goalEvent of takePendingGoalEvents()) {
145707
146456
  yield goalEvent;
145708
146457
  }
146458
+ } else {
146459
+ endCurrentInteraction("cancelled");
145709
146460
  }
145710
146461
  yield {
145711
146462
  type: "user_prompt_submit_blocked" /* UserPromptSubmitBlocked */,
@@ -145733,6 +146484,11 @@ var GeminiClient = class _GeminiClient {
145733
146484
  }
145734
146485
  }
145735
146486
  } catch (error) {
146487
+ endCurrentInteraction(
146488
+ signal.aborted ? "cancelled" : "error",
146489
+ signal.aborted ? void 0 : userPromptSubmitFailureMessage,
146490
+ signal.aborted ? void 0 : getErrorType(error)
146491
+ );
145736
146492
  for (const goalEvent of await finalizeInterruptedGoalTurn()) {
145737
146493
  yield goalEvent;
145738
146494
  }
@@ -145782,6 +146538,11 @@ var GeminiClient = class _GeminiClient {
145782
146538
  }
145783
146539
  if (goalRuntime) bindGoalStateEvents(goalRuntime);
145784
146540
  } catch (error) {
146541
+ endCurrentInteraction(
146542
+ signal.aborted ? "cancelled" : "error",
146543
+ signal.aborted ? void 0 : "Goal turn admission failed",
146544
+ signal.aborted ? void 0 : getErrorType(error)
146545
+ );
145785
146546
  for (const goalEvent of await finalizeInterruptedGoalTurn()) {
145786
146547
  yield goalEvent;
145787
146548
  }
@@ -145813,20 +146574,12 @@ var GeminiClient = class _GeminiClient {
145813
146574
  );
145814
146575
  this.activeAutomaticTodoWorkChainPromptIds.add(prompt_id);
145815
146576
  }
145816
- const isTopLevelInteraction = messageType === "userQuery" /* UserQuery */ || messageType === "cron" /* Cron */ || messageType === "notification" /* Notification */ || messageType === "teammate" /* Teammate */;
145817
146577
  if (messageType === "goal" /* Goal */) {
145818
146578
  this.loopDetector.reset(prompt_id);
145819
146579
  this.lastPromptId = prompt_id;
145820
146580
  }
145821
- if (isTopLevelInteraction) {
145822
- this.loopDetector.reset(prompt_id);
145823
- this.lastPromptId = prompt_id;
145824
- startInteractionSpan(this.config, {
145825
- promptId: prompt_id,
145826
- model: options2?.modelOverride ?? this.config.getModel(),
145827
- messageType
145828
- });
145829
- const interactionSpan = getActiveInteractionSpan();
146581
+ if (startsInteraction) {
146582
+ const interactionSpan = interactionOwner;
145830
146583
  if (interactionSpan && this.config.getTelemetryIncludeSensitiveSpanAttributes?.()) {
145831
146584
  addUserPromptAttributes(
145832
146585
  this.config,
@@ -145960,18 +146713,18 @@ var GeminiClient = class _GeminiClient {
145960
146713
  if (this.config.getMaxSessionTurns() > 0 && this.sessionTurnCount > this.config.getMaxSessionTurns()) {
145961
146714
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
145962
146715
  yield { type: "max_session_turns" /* MaxSessionTurns */ };
145963
- if (isTopLevelInteraction)
145964
- endInteractionSpan("error", {
145965
- errorMessage: "max session turns exceeded"
145966
- });
146716
+ endCurrentInteraction(
146717
+ "error",
146718
+ "max session turns exceeded",
146719
+ "max_session_turns"
146720
+ );
145967
146721
  return new Turn(this.getChat(), prompt_id);
145968
146722
  }
145969
146723
  }
145970
146724
  const boundedTurns = messageType === "goal" /* Goal */ ? MAX_TURNS2 : Math.min(turns, MAX_TURNS2);
145971
146725
  if (!boundedTurns) {
145972
146726
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
145973
- if (isTopLevelInteraction)
145974
- endInteractionSpan("error", { errorMessage: "max turns exhausted" });
146727
+ endCurrentInteraction("error", "max turns exhausted", "max_turns");
145975
146728
  return new Turn(this.getChat(), prompt_id);
145976
146729
  }
145977
146730
  const takeSteerInput = /* @__PURE__ */ __name(async (nextTurnBudget) => {
@@ -146005,10 +146758,11 @@ var GeminiClient = class _GeminiClient {
146005
146758
  message: `Session token limit exceeded: ${lastPromptTokenCount} tokens > ${sessionTokenLimit} limit. Please start a new session or increase the sessionTokenLimit in your settings.json.`
146006
146759
  }
146007
146760
  };
146008
- if (isTopLevelInteraction)
146009
- endInteractionSpan("error", {
146010
- errorMessage: "session token limit exceeded"
146011
- });
146761
+ endCurrentInteraction(
146762
+ "error",
146763
+ "session token limit exceeded",
146764
+ "session_token_limit"
146765
+ );
146012
146766
  return new Turn(this.getChat(), prompt_id);
146013
146767
  }
146014
146768
  }
@@ -146042,7 +146796,7 @@ var GeminiClient = class _GeminiClient {
146042
146796
  );
146043
146797
  await arenaAgentClient.reportCancelled();
146044
146798
  this.cancelPendingMemoryPrefetch("abort");
146045
- if (isTopLevelInteraction) endInteractionSpan("cancelled");
146799
+ endCurrentInteraction("cancelled");
146046
146800
  return new Turn(this.getChat(), prompt_id);
146047
146801
  }
146048
146802
  }
@@ -146177,6 +146931,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146177
146931
  signal,
146178
146932
  (message) => this.config.getDebugLogger().warn(message)
146179
146933
  ) : null;
146934
+ agentOutput.beginResponse();
146180
146935
  const resultStream = turn.run(model, requestToSend, signal);
146181
146936
  let didUpdateIdeContextState = false;
146182
146937
  let steerInputSettled = false;
@@ -146190,6 +146945,14 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146190
146945
  hasToolCalls = true;
146191
146946
  } else if (event.type === "retry" /* Retry */ || event.type === "model_fallback" /* ModelFallback */) {
146192
146947
  hasToolCalls = false;
146948
+ agentOutput.restartAttempt(
146949
+ event.type === "retry" /* Retry */ && event.isContinuation === true
146950
+ );
146951
+ }
146952
+ if (event.type === "content" /* Content */) {
146953
+ agentOutput.appendText(event.value);
146954
+ } else if (event.type === "finished" /* Finished */) {
146955
+ agentOutput.observeFinishReason(event.value?.reason);
146193
146956
  }
146194
146957
  if (messageDisplay && event.type === "content" /* Content */) {
146195
146958
  messageDisplay.addChunk(event.value);
@@ -146214,8 +146977,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146214
146977
  await arenaAgentClient.reportError("Loop detected");
146215
146978
  }
146216
146979
  this.lastApiCompletionTimestamp = Date.now();
146217
- if (isTopLevelInteraction)
146218
- endInteractionSpan("error", { errorMessage: "loop detected" });
146980
+ endCurrentInteraction("error", "loop detected", "loop_detected");
146219
146981
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
146220
146982
  this.fireLoopDetectedStopFailure(loopType);
146221
146983
  return turn;
@@ -146235,8 +146997,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146235
146997
  await arenaAgentClient.reportError("Loop detected");
146236
146998
  }
146237
146999
  this.lastApiCompletionTimestamp = Date.now();
146238
- if (isTopLevelInteraction)
146239
- endInteractionSpan("error", { errorMessage: "loop detected" });
147000
+ endCurrentInteraction("error", "loop detected", "loop_detected");
146240
147001
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
146241
147002
  this.fireLoopDetectedStopFailure(loopType);
146242
147003
  return turn;
@@ -146279,14 +147040,16 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146279
147040
  if (event.type === "error" /* Error */) {
146280
147041
  this.forceFullIdeContext = true;
146281
147042
  if (arenaAgentClient) {
146282
- const errorMsg = event.value instanceof Error ? event.value.message : "Unknown error";
146283
- await arenaAgentClient.reportError(errorMsg);
147043
+ const status = event.value.error?.status;
147044
+ const arenaError = status === 401 || status === 403 ? "Authentication failed" : status === 429 ? "Rate limit exceeded" : status !== void 0 && status >= 500 ? "Provider service unavailable" : status !== void 0 ? `API request failed (${status})` : "Provider request failed";
147045
+ try {
147046
+ await arenaAgentClient.reportError(arenaError);
147047
+ } catch {
147048
+ this.config.getDebugLogger().warn("Failed to report Arena provider error");
147049
+ }
146284
147050
  }
146285
147051
  this.lastApiCompletionTimestamp = Date.now();
146286
- if (isTopLevelInteraction) {
146287
- const errMsg = event.value instanceof Error ? "[API error]" : "unknown error";
146288
- endInteractionSpan("error", { errorMessage: errMsg });
146289
- }
147052
+ endCurrentInteraction("error", "unknown error", "api_error");
146290
147053
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
146291
147054
  return turn;
146292
147055
  }
@@ -146294,6 +147057,9 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146294
147057
  } finally {
146295
147058
  await messageDisplay?.finish();
146296
147059
  }
147060
+ agentOutput.commitResponse(
147061
+ hasToolCalls || turn.pendingToolCalls.length > 0
147062
+ );
146297
147063
  for (const goalEvent of signal.aborted ? await finalizeInterruptedGoalTurn() : takePendingGoalEvents()) {
146298
147064
  yield goalEvent;
146299
147065
  }
@@ -146320,9 +147086,10 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146320
147086
  } finally {
146321
147087
  settleSteerInput(steerInput, pushCountBefore);
146322
147088
  }
146323
- if (isTopLevelInteraction)
146324
- endInteractionSpan(signal.aborted ? "cancelled" : "ok");
146325
147089
  hasToolCalls = steeredTurn.pendingToolCalls.length > 0;
147090
+ if (!hasToolCalls) {
147091
+ endCurrentInteraction(signal.aborted ? "cancelled" : "ok");
147092
+ }
146326
147093
  normalCompletion = true;
146327
147094
  return steeredTurn;
146328
147095
  }
@@ -146360,7 +147127,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146360
147127
  if (activeGoalEvent2) {
146361
147128
  yield activeGoalEvent2;
146362
147129
  }
146363
- if (isTopLevelInteraction) endInteractionSpan("cancelled");
147130
+ endCurrentInteraction("cancelled");
146364
147131
  return turn;
146365
147132
  }
146366
147133
  const hookOutput = response.output ? createHookOutput("Stop", response.output) : void 0;
@@ -146392,7 +147159,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146392
147159
  for (const goalEvent of await finalizeInterruptedGoalTurn()) {
146393
147160
  yield goalEvent;
146394
147161
  }
146395
- if (isTopLevelInteraction) endInteractionSpan("ok");
147162
+ endCurrentInteraction("ok");
146396
147163
  return turn;
146397
147164
  } else {
146398
147165
  for (const goalEvent of takePendingGoalEvents()) {
@@ -146416,7 +147183,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146416
147183
  for (const goalEvent of await finalizeInterruptedGoalTurn()) {
146417
147184
  yield goalEvent;
146418
147185
  }
146419
- if (isTopLevelInteraction) endInteractionSpan("cancelled");
147186
+ endCurrentInteraction("cancelled");
146420
147187
  return turn;
146421
147188
  }
146422
147189
  const continueRequest = [{ text: continueReason }];
@@ -146445,8 +147212,9 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146445
147212
  } finally {
146446
147213
  settleSteerInput(pendingSteer, pushCountBefore);
146447
147214
  }
146448
- if (isTopLevelInteraction) {
146449
- endInteractionSpan(signal.aborted ? "cancelled" : "ok");
147215
+ hasToolCalls = hookTurn.pendingToolCalls.length > 0;
147216
+ if (!hasToolCalls) {
147217
+ endCurrentInteraction(signal.aborted ? "cancelled" : "ok");
146450
147218
  }
146451
147219
  normalCompletion = true;
146452
147220
  return hookTurn;
@@ -146460,7 +147228,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146460
147228
  if (activeGoalEvent3) {
146461
147229
  yield activeGoalEvent3;
146462
147230
  }
146463
- if (isTopLevelInteraction) endInteractionSpan("cancelled");
147231
+ endCurrentInteraction("cancelled");
146464
147232
  return turn;
146465
147233
  }
146466
147234
  const continueReason = getStopHookContinuationReason(stopOutput);
@@ -146492,7 +147260,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146492
147260
  value: warning
146493
147261
  };
146494
147262
  debugLogger136.warn(warning);
146495
- if (isTopLevelInteraction) endInteractionSpan("ok");
147263
+ endCurrentInteraction("ok");
146496
147264
  return turn;
146497
147265
  }
146498
147266
  const activeGoalEvent2 = maybeEmitActiveGoalChange(
@@ -146527,7 +147295,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146527
147295
  const discardGoalContinuation = goalContinuationChanged && response.hasNonGoalBlockingStopHook === false;
146528
147296
  const continuationReasonAfterSteer = discardGoalContinuation ? void 0 : goalContinuationChanged && response.hasNonGoalBlockingStopHook === true ? response.nonGoalBlockingStopReason || "No reason provided" : continueReason;
146529
147297
  if (!continuationReasonAfterSteer && !pendingSteer) {
146530
- if (isTopLevelInteraction) endInteractionSpan("ok");
147298
+ endCurrentInteraction("ok");
146531
147299
  normalCompletion = true;
146532
147300
  return turn;
146533
147301
  }
@@ -146563,9 +147331,10 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146563
147331
  } finally {
146564
147332
  settleSteerInput(pendingSteer, pushCountBefore);
146565
147333
  }
146566
- if (isTopLevelInteraction)
146567
- endInteractionSpan(signal.aborted ? "cancelled" : "ok");
146568
147334
  hasToolCalls = hookTurn.pendingToolCalls.length > 0;
147335
+ if (!hasToolCalls) {
147336
+ endCurrentInteraction(signal.aborted ? "cancelled" : "ok");
147337
+ }
146569
147338
  normalCompletion = true;
146570
147339
  return hookTurn;
146571
147340
  }
@@ -146590,6 +147359,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146590
147359
  for (const goalEvent of takePendingGoalEvents()) {
146591
147360
  yield goalEvent;
146592
147361
  }
147362
+ endCurrentInteraction("ok");
146593
147363
  normalCompletion = true;
146594
147364
  return turn;
146595
147365
  }
@@ -146619,7 +147389,7 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146619
147389
  if (arenaAgentClient) {
146620
147390
  await arenaAgentClient.reportCompleted();
146621
147391
  }
146622
- if (isTopLevelInteraction) endInteractionSpan("ok");
147392
+ endCurrentInteraction("ok");
146623
147393
  return turn;
146624
147394
  }
146625
147395
  const nextSpeakerCheck = await checkNextSpeaker(
@@ -146658,9 +147428,10 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146658
147428
  } finally {
146659
147429
  settleSteerInput(pendingSteer, pushCountBefore);
146660
147430
  }
146661
- if (isTopLevelInteraction)
146662
- endInteractionSpan(signal.aborted ? "cancelled" : "ok");
146663
147431
  hasToolCalls = continueTurn.pendingToolCalls.length > 0;
147432
+ if (!hasToolCalls) {
147433
+ endCurrentInteraction(signal.aborted ? "cancelled" : "ok");
147434
+ }
146664
147435
  normalCompletion = true;
146665
147436
  return continueTurn;
146666
147437
  }
@@ -146674,8 +147445,8 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146674
147445
  if (signal?.aborted && arenaAgentClient) {
146675
147446
  await arenaAgentClient.reportCancelled();
146676
147447
  }
146677
- if (isTopLevelInteraction) {
146678
- endInteractionSpan(signal?.aborted ? "cancelled" : "ok");
147448
+ if (!hasToolCalls) {
147449
+ endCurrentInteraction(signal?.aborted ? "cancelled" : "ok");
146679
147450
  }
146680
147451
  if (!hasToolCalls) {
146681
147452
  this.cancelPendingMemoryPrefetch("no_safe_delivery_point");
@@ -146689,6 +147460,13 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146689
147460
  for (const goalEvent of await finalizeInterruptedGoalTurn()) {
146690
147461
  yield goalEvent;
146691
147462
  }
147463
+ if (error instanceof UnauthorizedError && messageType !== "hook" /* Hook */ && messageType !== "steer" /* Steer */) {
147464
+ try {
147465
+ await this.config.getArenaAgentClient()?.reportError("Authentication failed");
147466
+ } catch {
147467
+ this.config.getDebugLogger().warn("Failed to report Arena authentication error");
147468
+ }
147469
+ }
146692
147470
  throw error;
146693
147471
  } finally {
146694
147472
  if (this.activeAutomaticTodoWorkChainPromptIds.has(prompt_id) && (!normalCompletion || !hasToolCalls)) {
@@ -146707,10 +147485,12 @@ The current date is: ${today}. Note: This is the authoritative current date \u20
146707
147485
  signal?.aborted ? "abort" : "no_safe_delivery_point"
146708
147486
  );
146709
147487
  }
146710
- if (isTopLevelInteraction) {
146711
- endInteractionSpan(signal?.aborted ? "cancelled" : "error", {
146712
- errorMessage: "unexpected exit"
146713
- });
147488
+ if (!normalCompletion) {
147489
+ endCurrentInteraction(
147490
+ signal?.aborted ? "cancelled" : "error",
147491
+ signal?.aborted ? void 0 : "unexpected exit",
147492
+ signal?.aborted ? void 0 : "unexpected_exit"
147493
+ );
146714
147494
  }
146715
147495
  }
146716
147496
  }
@@ -148711,6 +149491,7 @@ var Config = class _Config {
148711
149491
  runtimeStatusWrite = Promise.resolve();
148712
149492
  fileExclusions;
148713
149493
  truncateToolOutputThreshold;
149494
+ truncateToolOutputThresholdExplicit;
148714
149495
  truncateToolOutputLines;
148715
149496
  toolOutputBatchBudget;
148716
149497
  shellDefaultTimeoutMs;
@@ -148963,6 +149744,7 @@ var Config = class _Config {
148963
149744
  maxBufferedOutputBytes: params.shellExecutionConfig?.maxBufferedOutputBytes
148964
149745
  };
148965
149746
  this.truncateToolOutputThreshold = params.truncateToolOutputThreshold ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD;
149747
+ this.truncateToolOutputThresholdExplicit = params.truncateToolOutputThreshold != null;
148966
149748
  this.truncateToolOutputLines = params.truncateToolOutputLines ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES;
148967
149749
  this.toolOutputBatchBudget = params.toolOutputBatchBudget ?? DEFAULT_TOOL_OUTPUT_BATCH_BUDGET;
148968
149750
  this.shellDefaultTimeoutMs = params.shellDefaultTimeoutMs !== void 0 && Number.isInteger(params.shellDefaultTimeoutMs) && params.shellDefaultTimeoutMs >= 0 && params.shellDefaultTimeoutMs <= 2147483647 ? params.shellDefaultTimeoutMs : void 0;
@@ -151048,10 +151830,10 @@ var Config = class _Config {
151048
151830
  return this.systemPrompt;
151049
151831
  }
151050
151832
  getAppendSystemPrompt() {
151051
- const parts = [this.appendSystemPrompt, this.liveAppendSystemPrompt].filter(
151833
+ const parts2 = [this.appendSystemPrompt, this.liveAppendSystemPrompt].filter(
151052
151834
  (part) => Boolean(part?.trim())
151053
151835
  );
151054
- return parts.length > 0 ? parts.join("\n\n") : void 0;
151836
+ return parts2.length > 0 ? parts2.join("\n\n") : void 0;
151055
151837
  }
151056
151838
  setLiveAppendSystemPrompt(prompt) {
151057
151839
  this.liveAppendSystemPrompt = prompt;
@@ -152820,6 +153602,9 @@ var Config = class _Config {
152820
153602
  }
152821
153603
  return this.truncateToolOutputThreshold;
152822
153604
  }
153605
+ isTruncateToolOutputThresholdExplicit() {
153606
+ return this.truncateToolOutputThresholdExplicit;
153607
+ }
152823
153608
  getTruncateToolOutputLines() {
152824
153609
  if (this.truncateToolOutputLines <= 0) {
152825
153610
  return Number.POSITIVE_INFINITY;
@@ -153370,7 +154155,7 @@ var Config = class _Config {
153370
154155
  }
153371
154156
  if (!enabled) return;
153372
154157
  registry.registerFactory(ToolNames.IMAGE_GEN, async () => {
153373
- const { ImageGenTool } = await import("./image-gen-HGURQAHX.js");
154158
+ const { ImageGenTool } = await import("./image-gen-EXECB5XM.js");
153374
154159
  return new ImageGenTool(this);
153375
154160
  });
153376
154161
  }
@@ -153400,36 +154185,36 @@ var Config = class _Config {
153400
154185
  if (options2?.forSubAgent) return;
153401
154186
  const schema = this.jsonSchema;
153402
154187
  await registerLazy(ToolNames.STRUCTURED_OUTPUT, async () => {
153403
- const { SyntheticOutputTool } = await import("./syntheticOutput-SEW4NA47.js");
154188
+ const { SyntheticOutputTool } = await import("./syntheticOutput-7GWFIDXT.js");
153404
154189
  return new SyntheticOutputTool(schema);
153405
154190
  });
153406
154191
  }, "registerStructuredOutputIfRequested");
153407
154192
  const registerGoalWorkerTools = /* @__PURE__ */ __name(async () => {
153408
154193
  if (options2?.forSubAgent) return;
153409
154194
  await registerLazy(ToolNames.GET_GOAL, async () => {
153410
- const { GetGoalTool } = await import("./goal-tools-LQFO4BRY.js");
154195
+ const { GetGoalTool } = await import("./goal-tools-VHTNVOKK.js");
153411
154196
  return new GetGoalTool(this);
153412
154197
  });
153413
154198
  await registerLazy(ToolNames.UPDATE_GOAL, async () => {
153414
- const { UpdateGoalTool } = await import("./goal-tools-LQFO4BRY.js");
154199
+ const { UpdateGoalTool } = await import("./goal-tools-VHTNVOKK.js");
153415
154200
  return new UpdateGoalTool(this);
153416
154201
  });
153417
154202
  }, "registerGoalWorkerTools");
153418
154203
  if (this.getBareMode()) {
153419
154204
  await registerLazy(ToolNames.READ_FILE, async () => {
153420
- const { ReadFileTool } = await import("./read-file-2V5GE6ZW.js");
154205
+ const { ReadFileTool } = await import("./read-file-TAFBKMNI.js");
153421
154206
  return new ReadFileTool(this);
153422
154207
  });
153423
154208
  await registerLazy(ToolNames.EDIT, async () => {
153424
- const { EditTool } = await import("./edit-CZ23AVP6.js");
154209
+ const { EditTool } = await import("./edit-I4LQFAEC.js");
153425
154210
  return new EditTool(this);
153426
154211
  });
153427
154212
  await registerLazy(ToolNames.NOTEBOOK_EDIT, async () => {
153428
- const { NotebookEditTool } = await import("./notebook-edit-QPYSWPRI.js");
154213
+ const { NotebookEditTool } = await import("./notebook-edit-NTDY4QDU.js");
153429
154214
  return new NotebookEditTool(this);
153430
154215
  });
153431
154216
  await registerLazy(ToolNames.SHELL, async () => {
153432
- const { ShellTool: ShellTool2 } = await import("./shell-JDSWGVC7.js");
154217
+ const { ShellTool: ShellTool2 } = await import("./shell-3PZULQQV.js");
153433
154218
  return new ShellTool2(this);
153434
154219
  });
153435
154220
  await registerGoalWorkerTools();
@@ -153441,43 +154226,43 @@ var Config = class _Config {
153441
154226
  }
153442
154227
  await registerGoalWorkerTools();
153443
154228
  await registerLazy(ToolNames.TOOL_SEARCH, async () => {
153444
- const { ToolSearchTool } = await import("./tool-search-SZRO5G72.js");
154229
+ const { ToolSearchTool } = await import("./tool-search-5R2OE4C7.js");
153445
154230
  return new ToolSearchTool(this);
153446
154231
  });
153447
154232
  await registerLazy(ToolNames.READ_MCP_RESOURCE, async () => {
153448
- const { ReadMcpResourceTool } = await import("./read-mcp-resource-THCSZHXO.js");
154233
+ const { ReadMcpResourceTool } = await import("./read-mcp-resource-XD54ZQMC.js");
153449
154234
  return new ReadMcpResourceTool(this);
153450
154235
  });
153451
154236
  await registerLazy(ToolNames.AGENT, async () => {
153452
- const { AgentTool: AgentTool2 } = await import("./agent-4AGYD6I6.js");
154237
+ const { AgentTool: AgentTool2 } = await import("./agent-DPTOZFEM.js");
153453
154238
  return new AgentTool2(this);
153454
154239
  });
153455
154240
  await registerLazy(ToolNames.LIST_AGENTS, async () => {
153456
- const { ListAgentsTool } = await import("./list-agents-5PNMK2AM.js");
154241
+ const { ListAgentsTool } = await import("./list-agents-OSVDFI6S.js");
153457
154242
  return new ListAgentsTool(this);
153458
154243
  });
153459
154244
  await registerLazy(ToolNames.TASK_STOP, async () => {
153460
- const { TaskStopTool } = await import("./task-stop-MAYQJ42I.js");
154245
+ const { TaskStopTool } = await import("./task-stop-X37KYTKB.js");
153461
154246
  return new TaskStopTool(this);
153462
154247
  });
153463
154248
  await registerLazy(ToolNames.SEND_MESSAGE, async () => {
153464
- const { SendMessageTool } = await import("./send-message-P5SLP57G.js");
154249
+ const { SendMessageTool } = await import("./send-message-VZENRWRH.js");
153465
154250
  return new SendMessageTool(this);
153466
154251
  });
153467
154252
  await registerLazy(ToolNames.SKILL, async () => {
153468
- const { SkillTool } = await import("./skill-QILHTMYJ.js");
154253
+ const { SkillTool } = await import("./skill-PEVVXQ3L.js");
153469
154254
  return new SkillTool(this);
153470
154255
  });
153471
154256
  await registerLazy(ToolNames.LS, async () => {
153472
- const { LSTool } = await import("./ls-RPRSX26R.js");
154257
+ const { LSTool } = await import("./ls-D3HUFHDP.js");
153473
154258
  return new LSTool(this);
153474
154259
  });
153475
154260
  await registerLazy(ToolNames.READ_FILE, async () => {
153476
- const { ReadFileTool } = await import("./read-file-2V5GE6ZW.js");
154261
+ const { ReadFileTool } = await import("./read-file-TAFBKMNI.js");
153477
154262
  return new ReadFileTool(this);
153478
154263
  });
153479
154264
  await registerLazy(ToolNames.ZOOM_IMAGE, async () => {
153480
- const { ZoomImageTool } = await import("./zoom-image-4QTKAMTP.js");
154265
+ const { ZoomImageTool } = await import("./zoom-image-4BFYJ3HG.js");
153481
154266
  return new ZoomImageTool(this);
153482
154267
  });
153483
154268
  if (this.getUseRipgrep()) {
@@ -153492,7 +154277,7 @@ var Config = class _Config {
153492
154277
  recordStartupEvent("config_initialize_ripgrep_probe_end");
153493
154278
  if (useRipgrep) {
153494
154279
  await registerLazy(ToolNames.GREP, async () => {
153495
- const { RipGrepTool: RipGrepTool2 } = await import("./ripGrep-MUTMPQSV.js");
154280
+ const { RipGrepTool: RipGrepTool2 } = await import("./ripGrep-WOEK2PXS.js");
153496
154281
  return new RipGrepTool2(this);
153497
154282
  });
153498
154283
  } else {
@@ -153505,7 +154290,7 @@ var Config = class _Config {
153505
154290
  )
153506
154291
  );
153507
154292
  await registerLazy(ToolNames.GREP, async () => {
153508
- const { GrepTool } = await import("./grep-KYBZMY36.js");
154293
+ const { GrepTool } = await import("./grep-VJWPLFOT.js");
153509
154294
  return new GrepTool(this);
153510
154295
  });
153511
154296
  }
@@ -153513,77 +154298,77 @@ var Config = class _Config {
153513
154298
  recordStartupEvent("config_initialize_ripgrep_probe_start");
153514
154299
  recordStartupEvent("config_initialize_ripgrep_probe_end");
153515
154300
  await registerLazy(ToolNames.GREP, async () => {
153516
- const { GrepTool } = await import("./grep-KYBZMY36.js");
154301
+ const { GrepTool } = await import("./grep-VJWPLFOT.js");
153517
154302
  return new GrepTool(this);
153518
154303
  });
153519
154304
  }
153520
154305
  await registerLazy(ToolNames.GLOB, async () => {
153521
- const { GlobTool } = await import("./glob-LA5XO2H7.js");
154306
+ const { GlobTool } = await import("./glob-J4RUJAHX.js");
153522
154307
  return new GlobTool(this);
153523
154308
  });
153524
154309
  await registerLazy(ToolNames.EDIT, async () => {
153525
- const { EditTool } = await import("./edit-CZ23AVP6.js");
154310
+ const { EditTool } = await import("./edit-I4LQFAEC.js");
153526
154311
  return new EditTool(this);
153527
154312
  });
153528
154313
  await registerLazy(ToolNames.NOTEBOOK_EDIT, async () => {
153529
- const { NotebookEditTool } = await import("./notebook-edit-QPYSWPRI.js");
154314
+ const { NotebookEditTool } = await import("./notebook-edit-NTDY4QDU.js");
153530
154315
  return new NotebookEditTool(this);
153531
154316
  });
153532
154317
  await registerLazy(ToolNames.WRITE_FILE, async () => {
153533
- const { WriteFileTool: WriteFileTool2 } = await import("./write-file-UBIHUP5M.js");
154318
+ const { WriteFileTool: WriteFileTool2 } = await import("./write-file-EWXKVVXF.js");
153534
154319
  return new WriteFileTool2(this);
153535
154320
  });
153536
154321
  await registerLazy(ToolNames.SHELL, async () => {
153537
- const { ShellTool: ShellTool2 } = await import("./shell-JDSWGVC7.js");
154322
+ const { ShellTool: ShellTool2 } = await import("./shell-3PZULQQV.js");
153538
154323
  return new ShellTool2(this);
153539
154324
  });
153540
154325
  await registerLazy(ToolNames.TODO_WRITE, async () => {
153541
- const { TodoWriteTool } = await import("./todoWrite-IE2YTCK7.js");
154326
+ const { TodoWriteTool } = await import("./todoWrite-U2R4NVF4.js");
153542
154327
  return new TodoWriteTool(this);
153543
154328
  });
153544
154329
  const supportsUserInteraction = resolveInteractionMode(this) !== "headless";
153545
154330
  if (supportsUserInteraction) {
153546
154331
  await registerLazy(ToolNames.ASK_USER_QUESTION, async () => {
153547
- const { AskUserQuestionTool } = await import("./askUserQuestion-IQCA2SOX.js");
154332
+ const { AskUserQuestionTool } = await import("./askUserQuestion-B33XRSB7.js");
153548
154333
  return new AskUserQuestionTool(this);
153549
154334
  });
153550
154335
  }
153551
154336
  if (!this.sdkMode && (supportsUserInteraction || options2?.forSubAgent)) {
153552
154337
  await registerLazy(ToolNames.EXIT_PLAN_MODE, async () => {
153553
- const { ExitPlanModeTool: ExitPlanModeTool2 } = await import("./exitPlanMode-4JH6WLKL.js");
154338
+ const { ExitPlanModeTool: ExitPlanModeTool2 } = await import("./exitPlanMode-R4JY7V2O.js");
153554
154339
  return new ExitPlanModeTool2(this);
153555
154340
  });
153556
154341
  }
153557
154342
  if (!this.sdkMode && supportsUserInteraction) {
153558
154343
  await registerLazy(ToolNames.ENTER_PLAN_MODE, async () => {
153559
- const { EnterPlanModeTool } = await import("./enterPlanMode-TS6KO6DU.js");
154344
+ const { EnterPlanModeTool } = await import("./enterPlanMode-XCPK62ER.js");
153560
154345
  return new EnterPlanModeTool(this);
153561
154346
  });
153562
154347
  }
153563
154348
  await registerLazy(ToolNames.ENTER_WORKTREE, async () => {
153564
- const { EnterWorktreeTool } = await import("./enter-worktree-4EMS7IRL.js");
154349
+ const { EnterWorktreeTool } = await import("./enter-worktree-YNPOJSRH.js");
153565
154350
  return new EnterWorktreeTool(this);
153566
154351
  });
153567
154352
  await registerLazy(ToolNames.EXIT_WORKTREE, async () => {
153568
- const { ExitWorktreeTool } = await import("./exit-worktree-Q3NFHYUI.js");
154353
+ const { ExitWorktreeTool } = await import("./exit-worktree-AIIY7SR6.js");
153569
154354
  return new ExitWorktreeTool(this);
153570
154355
  });
153571
154356
  await registerLazy(ToolNames.WEB_FETCH, async () => {
153572
- const { WebFetchTool } = await import("./web-fetch-LKC2F5DM.js");
154357
+ const { WebFetchTool } = await import("./web-fetch-RTEQTR5Z.js");
153573
154358
  return new WebFetchTool(this);
153574
154359
  });
153575
154360
  if (resolveInteractionMode(this) === "interactive" && !this.sdkMode && !this.getScreenReader() && !options2?.forSubAgent) {
153576
154361
  await registerLazy(ToolNames.DISPLAY_IMAGE, async () => {
153577
- const { DisplayImageTool } = await import("./display-image-CAD7RAUM.js");
154362
+ const { DisplayImageTool } = await import("./display-image-ON3EYFRD.js");
153578
154363
  return new DisplayImageTool(this);
153579
154364
  });
153580
154365
  }
153581
154366
  if (this.webSearchSettings?.enabled) {
153582
- const { evaluateWebSearchGate } = await import("./web-search-BHMAMXEU.js");
154367
+ const { evaluateWebSearchGate } = await import("./web-search-5OXHEZPV.js");
153583
154368
  const gate = evaluateWebSearchGate(this);
153584
154369
  if (gate.ok) {
153585
154370
  await registerLazy(ToolNames.WEB_SEARCH, async () => {
153586
- const { WebSearchTool } = await import("./web-search-BHMAMXEU.js");
154371
+ const { WebSearchTool } = await import("./web-search-5OXHEZPV.js");
153587
154372
  return new WebSearchTool(this);
153588
154373
  });
153589
154374
  } else if (!this.webSearchNoticeEmitted && !options2?.forSubAgent) {
@@ -153594,83 +154379,83 @@ var Config = class _Config {
153594
154379
  await this.registerImageGenerationTool(registry);
153595
154380
  if (this.isArtifactEnabled()) {
153596
154381
  await registerLazy(ToolNames.ARTIFACT, async () => {
153597
- const { ArtifactTool } = await import("./artifact-tool-RWJAKYBZ.js");
154382
+ const { ArtifactTool } = await import("./artifact-tool-GEXTOPVO.js");
153598
154383
  return new ArtifactTool(this);
153599
154384
  });
153600
154385
  }
153601
154386
  if (this.isRecordArtifactEnabled()) {
153602
154387
  await registerLazy(ToolNames.RECORD_ARTIFACT, async () => {
153603
- const { RecordArtifactTool } = await import("./record-artifact-76YYQA5F.js");
154388
+ const { RecordArtifactTool } = await import("./record-artifact-SEYFJEJF.js");
153604
154389
  return new RecordArtifactTool();
153605
154390
  });
153606
154391
  }
153607
154392
  if (this.isLspEnabled() && this.getLspClient()) {
153608
154393
  await registerLazy(ToolNames.LSP, async () => {
153609
- const { LspTool } = await import("./lsp-IWTJWFLT.js");
154394
+ const { LspTool } = await import("./lsp-3QDDJTCS.js");
153610
154395
  return new LspTool(this);
153611
154396
  });
153612
154397
  }
153613
154398
  await registerStructuredOutputIfRequested();
153614
154399
  if (this.isCronEnabled()) {
153615
154400
  await registerLazy(ToolNames.CRON_CREATE, async () => {
153616
- const { CronCreateTool } = await import("./cron-create-5WUTNKNF.js");
154401
+ const { CronCreateTool } = await import("./cron-create-H7UEPDSN.js");
153617
154402
  return new CronCreateTool(this);
153618
154403
  });
153619
154404
  await registerLazy(ToolNames.CRON_LIST, async () => {
153620
- const { CronListTool } = await import("./cron-list-IXGCA7UR.js");
154405
+ const { CronListTool } = await import("./cron-list-H25JIHEZ.js");
153621
154406
  return new CronListTool(this);
153622
154407
  });
153623
154408
  await registerLazy(ToolNames.CRON_DELETE, async () => {
153624
- const { CronDeleteTool } = await import("./cron-delete-JEQ27YPS.js");
154409
+ const { CronDeleteTool } = await import("./cron-delete-6SZK7YFM.js");
153625
154410
  return new CronDeleteTool(this);
153626
154411
  });
153627
154412
  await registerLazy(ToolNames.LOOP_WAKEUP, async () => {
153628
- const { LoopWakeupTool } = await import("./loop-wakeup-OV65FEGR.js");
154413
+ const { LoopWakeupTool } = await import("./loop-wakeup-WQS6JYAG.js");
153629
154414
  return new LoopWakeupTool(this);
153630
154415
  });
153631
154416
  }
153632
154417
  await registerLazy(ToolNames.CREATE_SUB_SESSION, async () => {
153633
- const { CreateSubSessionTool } = await import("./create-sub-session-23ULO5PO.js");
154418
+ const { CreateSubSessionTool } = await import("./create-sub-session-KRQULJE6.js");
153634
154419
  return new CreateSubSessionTool(this);
153635
154420
  });
153636
154421
  if (this.isAgentTeamEnabled()) {
153637
154422
  await registerLazy(ToolNames.TEAM_CREATE, async () => {
153638
- const { TeamCreateTool } = await import("./team-create-YMWUDIE3.js");
154423
+ const { TeamCreateTool } = await import("./team-create-ZAIA7KAV.js");
153639
154424
  return new TeamCreateTool(this);
153640
154425
  });
153641
154426
  await registerLazy(ToolNames.TEAM_DELETE, async () => {
153642
- const { TeamDeleteTool } = await import("./team-delete-3XVRPQBP.js");
154427
+ const { TeamDeleteTool } = await import("./team-delete-6UMU4XLS.js");
153643
154428
  return new TeamDeleteTool(this);
153644
154429
  });
153645
154430
  await registerLazy(ToolNames.TEAM_PLAN_APPROVAL, async () => {
153646
- const { TeamPlanApprovalTool } = await import("./team-plan-approval-3GPZAW46.js");
154431
+ const { TeamPlanApprovalTool } = await import("./team-plan-approval-UNIUS7OD.js");
153647
154432
  return new TeamPlanApprovalTool(this);
153648
154433
  });
153649
154434
  await registerLazy(ToolNames.TASK_CREATE, async () => {
153650
- const { TaskCreateTool } = await import("./task-create-247EAVF7.js");
154435
+ const { TaskCreateTool } = await import("./task-create-FCBDX7UH.js");
153651
154436
  return new TaskCreateTool(this);
153652
154437
  });
153653
154438
  await registerLazy(ToolNames.TASK_UPDATE, async () => {
153654
- const { TaskUpdateTool } = await import("./task-update-SU5TMZGG.js");
154439
+ const { TaskUpdateTool } = await import("./task-update-MYPFVOVM.js");
153655
154440
  return new TaskUpdateTool(this);
153656
154441
  });
153657
154442
  await registerLazy(ToolNames.TASK_LIST, async () => {
153658
- const { TaskListTool } = await import("./task-list-ZJN4QHLK.js");
154443
+ const { TaskListTool } = await import("./task-list-YIYIUFUA.js");
153659
154444
  return new TaskListTool(this);
153660
154445
  });
153661
154446
  }
153662
154447
  if (this.isWorkflowsEnabled()) {
153663
154448
  await registerLazy(ToolNames.WORKFLOW, async () => {
153664
- const { WorkflowTool } = await import("./workflow-A7AQ52HO.js");
154449
+ const { WorkflowTool } = await import("./workflow-ISQJHPG2.js");
153665
154450
  return new WorkflowTool(this);
153666
154451
  });
153667
154452
  }
153668
154453
  if (this.isComputerUseEnabled()) {
153669
- const { registerComputerUseTools } = await import("./computer-use-ZFBJYSR3.js");
154454
+ const { registerComputerUseTools } = await import("./computer-use-77C5FHMW.js");
153670
154455
  await registerComputerUseTools(registerLazy, this);
153671
154456
  }
153672
154457
  await registerLazy(ToolNames.MONITOR, async () => {
153673
- const { MonitorTool } = await import("./monitor-SV64FNV3.js");
154458
+ const { MonitorTool } = await import("./monitor-EE2UYMGE.js");
153674
154459
  return new MonitorTool(this);
153675
154460
  });
153676
154461
  if (this.pendingMcpBudgetCallback) {
@@ -154156,6 +154941,7 @@ export {
154156
154941
  SessionWriterError,
154157
154942
  SESSION_WRITER_RPC_CODES,
154158
154943
  SessionWriterUnavailableError,
154944
+ BranchPointInvalidError,
154159
154945
  SESSION_TITLE_MAX_LENGTH,
154160
154946
  SessionService,
154161
154947
  computeUniqueBranchTitle,
@@ -154231,10 +155017,6 @@ export {
154231
155017
  isEditorAvailable,
154232
155018
  createPatchSmart,
154233
155019
  getDiffStat,
154234
- stripAnsiAndControl,
154235
- safeLiteralReplace,
154236
- isBinary,
154237
- normalizeContent,
154238
155020
  sanitizeChildEnv,
154239
155021
  formatMemoryUsage,
154240
155022
  getShellContextEnvVars,
@@ -154282,6 +155064,7 @@ export {
154282
155064
  DEFAULT_BUILTIN_SUBAGENT_TYPE,
154283
155065
  BuiltinAgentRegistry,
154284
155066
  toModelVisibleSubagentResult,
155067
+ sanitizeFilenameComponent,
154285
155068
  getSubagentsRootDir,
154286
155069
  getSubagentSessionDir,
154287
155070
  readAgentMeta,
@@ -154307,8 +155090,6 @@ export {
154307
155090
  MessageDisplayDispatcher,
154308
155091
  collectMemoryDiagnostics,
154309
155092
  MCPOAuthTokenStorage,
154310
- OAUTH_DISPLAY_MESSAGE_EVENT,
154311
- OAUTH_AUTH_URL_EVENT,
154312
155093
  MCPOAuthProvider,
154313
155094
  mcpServerRequiresOAuth,
154314
155095
  getMCPDiscoveryState,
@@ -154331,7 +155112,6 @@ export {
154331
155112
  isTerminalWorkflowStatus,
154332
155113
  EXTENSIONS_CONFIG_FILENAME,
154333
155114
  So,
154334
- redactUrlCredentials,
154335
155115
  require_toml,
154336
155116
  convertTomlToMarkdown,
154337
155117
  normalizeClaudeMcpServer,