@qwen-code/qwen-code 0.21.4 → 0.21.5

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 (242) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +8 -7
  2. package/bundled/qc-helper/docs/configuration/settings.md +1 -1
  3. package/bundled/qc-helper/docs/features/code-review.md +2 -0
  4. package/bundled/qc-helper/docs/features/mcp.md +11 -3
  5. package/bundled/review/SKILL.md +32 -1
  6. package/chunks/{MaxSizedBox-5XDFQHTQ.js → MaxSizedBox-2MWU5JYB.js} +16 -16
  7. package/chunks/{StandaloneSessionPicker-DLADA54K.js → StandaloneSessionPicker-B6MI5NTB.js} +30 -30
  8. package/chunks/{acpAgent-MVEFZSBS.js → acpAgent-MRPYN6FH.js} +674 -290
  9. package/chunks/{agent-RB6LCRZX.js → agent-NAOXNW4I.js} +16 -16
  10. package/chunks/{agent-headless-272ZACJV.js → agent-headless-L4PPVFKW.js} +16 -16
  11. package/chunks/{artifact-tool-TBOYEKTY.js → artifact-tool-RROCCJDA.js} +1 -1
  12. package/chunks/{askUserQuestion-23Y5WZFJ.js → askUserQuestion-2EPPBPUZ.js} +1 -1
  13. package/chunks/{bridge-GXUXFSHK.js → bridge-LHXGYNCO.js} +17 -17
  14. package/chunks/{channel-settings-store-5UA2SABE.js → channel-settings-store-QB54TLYE.js} +21 -21
  15. package/chunks/{chunk-PWCQRLM5.js → chunk-2AGOQ7QO.js} +1 -1
  16. package/chunks/{chunk-XSOAW7FC.js → chunk-2JBETW4S.js} +5 -5
  17. package/chunks/{chunk-O4IWFYUW.js → chunk-3GOCVBYR.js} +4 -4
  18. package/chunks/{chunk-3PHUGFPH.js → chunk-3H5RFLTS.js} +1 -1
  19. package/chunks/{chunk-OOPFAIWP.js → chunk-3P4GP4S2.js} +1 -1
  20. package/chunks/{chunk-YXEVDA66.js → chunk-4LLUH3A7.js} +19 -18
  21. package/chunks/{chunk-ZRQY5BBS.js → chunk-4NEBUDWS.js} +10 -10
  22. package/chunks/{chunk-C5YFS6VR.js → chunk-4NNR24EP.js} +4 -4
  23. package/chunks/{chunk-RL2NPV5E.js → chunk-4O6HLCOF.js} +1 -1
  24. package/chunks/{chunk-AFJSRJTO.js → chunk-5HWAJ4BK.js} +1 -1
  25. package/chunks/{chunk-O2ZYHG33.js → chunk-5L6CQ4ZU.js} +131 -67
  26. package/chunks/{chunk-AWTLFUVN.js → chunk-5XNO4AW7.js} +13 -13
  27. package/chunks/{chunk-LLMGP5IC.js → chunk-6WBWIPBF.js} +2 -2
  28. package/chunks/{chunk-4CTV3FZH.js → chunk-7M2RLFNX.js} +23 -19
  29. package/chunks/{chunk-X6QNZOTC.js → chunk-7MFQLOHZ.js} +1 -1
  30. package/chunks/{chunk-DZPOYHBT.js → chunk-7W5KOBYU.js} +1 -1
  31. package/chunks/{chunk-SBBHZ3YT.js → chunk-AEWOKOJY.js} +1 -1
  32. package/chunks/{chunk-2CCUHZP5.js → chunk-B2RBYP7Z.js} +2 -2
  33. package/chunks/{chunk-URVJ4AZC.js → chunk-B3EBIZUY.js} +1 -1
  34. package/chunks/{chunk-GDREW3U5.js → chunk-BWLUCN35.js} +1 -1
  35. package/chunks/{chunk-DJA7YBLJ.js → chunk-C6ARWPCG.js} +2 -2
  36. package/chunks/{chunk-RNKGMZEW.js → chunk-CAX76R46.js} +1 -1
  37. package/chunks/{chunk-CFDR3GNL.js → chunk-D7D7RXIJ.js} +11 -0
  38. package/chunks/{chunk-PCVMRBLN.js → chunk-D7QAZ5DF.js} +1 -1
  39. package/chunks/{chunk-THLV7YGY.js → chunk-EXHQZBVJ.js} +2 -2
  40. package/chunks/{chunk-DOCBJIBL.js → chunk-FEUXV3DC.js} +1 -1
  41. package/chunks/{chunk-QZQ72YF6.js → chunk-G2UXFO2B.js} +1 -1
  42. package/chunks/{chunk-QXTGHZCX.js → chunk-GBY3ODW7.js} +3 -3
  43. package/chunks/{chunk-LPLMUGIM.js → chunk-GEP54CHX.js} +5 -5
  44. package/chunks/{chunk-2T3RYG4L.js → chunk-GP4IMBX5.js} +420 -94
  45. package/chunks/{chunk-XPAY4EMH.js → chunk-IK3RYLAD.js} +3 -3
  46. package/chunks/{chunk-I32URQI7.js → chunk-IWGMDSC3.js} +5 -5
  47. package/chunks/{chunk-WDLQGFWP.js → chunk-IWYXZAGT.js} +27 -27
  48. package/chunks/{chunk-HBCKZF2A.js → chunk-IZ2CMEYO.js} +1 -1
  49. package/chunks/{chunk-PQEIKQXN.js → chunk-J7I2BZHS.js} +4 -3
  50. package/chunks/{chunk-PQ5JFCNL.js → chunk-JDNWIXHJ.js} +3 -3
  51. package/chunks/{chunk-KHSJSMFS.js → chunk-K2ETEWG6.js} +1 -1
  52. package/chunks/{chunk-FV4TUUDE.js → chunk-K64OI7S7.js} +1 -1
  53. package/chunks/{chunk-C6FU76AA.js → chunk-K6VEL5KP.js} +1 -1
  54. package/chunks/{chunk-B3EBXISV.js → chunk-KH2BIJ4H.js} +3 -3
  55. package/chunks/{chunk-G7XXKQYS.js → chunk-LKRMNRSN.js} +27 -1
  56. package/chunks/{chunk-G6KI6B5L.js → chunk-LMNM37OE.js} +1 -1
  57. package/chunks/{chunk-SV5X2EUV.js → chunk-LSYVASZS.js} +1 -1
  58. package/chunks/{chunk-4PZ7SPD5.js → chunk-LYPXNRBX.js} +1 -1
  59. package/chunks/{chunk-HFVW54NL.js → chunk-MBEMTXQT.js} +9 -2
  60. package/chunks/{chunk-RPYYTL7E.js → chunk-MGSSJT27.js} +2 -2
  61. package/chunks/{chunk-M2L4TMH3.js → chunk-N3RERU5N.js} +3 -3
  62. package/chunks/{chunk-HI4YGRJD.js → chunk-NLQIEY6W.js} +3 -3
  63. package/chunks/{chunk-UATJZOAJ.js → chunk-OGAARVN7.js} +3 -3
  64. package/chunks/{chunk-6KQUOXT5.js → chunk-OIGB253L.js} +6 -6
  65. package/chunks/{chunk-EIAPOG76.js → chunk-P3SLTSNY.js} +3 -3
  66. package/chunks/{chunk-BC4LTKEG.js → chunk-Q2V4AOQL.js} +1 -1
  67. package/chunks/{chunk-KB6VSG2U.js → chunk-RM3F46UT.js} +6 -6
  68. package/chunks/{chunk-6ME3PVMM.js → chunk-SJMCYCUQ.js} +5 -5
  69. package/chunks/{chunk-2JN5V3I7.js → chunk-SQTA6PAY.js} +1 -1
  70. package/chunks/{chunk-2ON2O4MD.js → chunk-SVIEVA3L.js} +3 -3
  71. package/chunks/{chunk-FPPVCCAH.js → chunk-TCOJPG2P.js} +1 -1
  72. package/chunks/{chunk-BOWKLLWA.js → chunk-TJ56V3AR.js} +2 -2
  73. package/chunks/{chunk-A7PONO5G.js → chunk-URJHXOSO.js} +2 -2
  74. package/chunks/{chunk-EJXATV5R.js → chunk-VJPF6GF2.js} +2 -2
  75. package/chunks/{chunk-5XGI4IPK.js → chunk-VOA2UPZM.js} +3 -3
  76. package/chunks/{chunk-XGA6XHH3.js → chunk-WTM5QONI.js} +3 -3
  77. package/chunks/{chunk-IMGNGOGC.js → chunk-WU5NBSLD.js} +3 -3
  78. package/chunks/{chunk-7UXI6P72.js → chunk-WVAESIM6.js} +2 -2
  79. package/chunks/{chunk-TXZDRD36.js → chunk-XD2PNH3K.js} +5 -5
  80. package/chunks/{chunk-E2SYUEIA.js → chunk-YLL3SC5S.js} +743 -312
  81. package/chunks/{chunk-M6RNMBUO.js → chunk-YMUZQ3MQ.js} +4 -4
  82. package/chunks/{chunk-DHNFB7NC.js → chunk-YO4JI7B4.js} +5 -5
  83. package/chunks/{chunk-VA5NLVPT.js → chunk-Z7JILXGX.js} +1 -1
  84. package/chunks/{chunk-P5UJMCVS.js → chunk-ZLGPHA34.js} +4 -4
  85. package/chunks/{chunk-JDJ7SC4E.js → chunk-ZPGMDT4S.js} +237 -106
  86. package/chunks/{chunk-UEJESCS7.js → chunk-ZPPP6VCL.js} +1 -1
  87. package/chunks/{computer-use-MDOMIVTL.js → computer-use-XDOGP2KA.js} +16 -16
  88. package/chunks/{contextCommand-FCK3CB37.js → contextCommand-N3LQDCYJ.js} +18 -18
  89. package/chunks/{core-runtime-UHRHHU2O.js → core-runtime-STAFP45W.js} +16 -16
  90. package/chunks/{create-sub-session-MIXUVLWW.js → create-sub-session-2B3JENWD.js} +16 -16
  91. package/chunks/{create-sub-session-J32WC64U.js → create-sub-session-6EWLAZD5.js} +1 -1
  92. package/chunks/{cron-create-HMFSHIAR.js → cron-create-CCRIULJE.js} +1 -1
  93. package/chunks/{cron-delete-ZJFHOX57.js → cron-delete-FCFW6BGP.js} +1 -1
  94. package/chunks/{cron-list-ZEX2NBMN.js → cron-list-QDBVCHRF.js} +1 -1
  95. package/chunks/{daemon-status-provider-6LC7LUNR.js → daemon-status-provider-PPAH3ATF.js} +21 -21
  96. package/chunks/{daemon-trust-policy-Y36HGRAM.js → daemon-trust-policy-X6XL3MB4.js} +21 -21
  97. package/chunks/{daemon-trust-policy-monitor-ROTBBDOH.js → daemon-trust-policy-monitor-M5LBL2HD.js} +21 -21
  98. package/chunks/{deferred-core-runtime-ZQ4JIAJD.js → deferred-core-runtime-O54YPTBU.js} +16 -16
  99. package/chunks/{display-image-2WOG27DY.js → display-image-GUJA352B.js} +2 -2
  100. package/chunks/{earlyInputCapture-GPRUNXTP.js → earlyInputCapture-CBIT2RGT.js} +16 -16
  101. package/chunks/{edit-YK3UP6D2.js → edit-KW2TOC6A.js} +17 -17
  102. package/chunks/{enter-worktree-QMVQW7UG.js → enter-worktree-YL34NEU5.js} +16 -16
  103. package/chunks/{enterPlanMode-TZAYQ5MP.js → enterPlanMode-JFJTDASQ.js} +16 -16
  104. package/chunks/{environment-3UQURCZG.js → environment-IATU5GXG.js} +18 -18
  105. package/chunks/{errors-VBIMTNNI.js → errors-SAVRDE7Q.js} +18 -18
  106. package/chunks/{exit-worktree-4EC7LBBC.js → exit-worktree-5M43QPBB.js} +16 -16
  107. package/chunks/{exitPlanMode-K5Y3REU2.js → exitPlanMode-W4EICZ4N.js} +16 -16
  108. package/chunks/{fast-path-KS6IE7YR.js → fast-path-YQJPIKMP.js} +2 -2
  109. package/chunks/{gemini-LTUCUOJH.js → gemini-FUF5SSPR.js} +47 -47
  110. package/chunks/{geminiContentGenerator-M3HJTHKR.js → geminiContentGenerator-LLLZBOUG.js} +1 -1
  111. package/chunks/{glob-SKUYGTF2.js → glob-LJFFMN4D.js} +16 -16
  112. package/chunks/{goal-tools-SPQ5M6D3.js → goal-tools-3AZKX5WQ.js} +2 -18
  113. package/chunks/{grep-SQ7RD7SV.js → grep-Q64EAM73.js} +16 -16
  114. package/chunks/{handleAutoUpdate-OK7OX23A.js → handleAutoUpdate-QBMPRTSQ.js} +20 -20
  115. package/chunks/{i18n-P77YBKY4.js → i18n-LDUW5DMN.js} +17 -17
  116. package/chunks/{image-gen-2ZWPS42A.js → image-gen-G7RLG3KR.js} +2 -2
  117. package/chunks/{initializer-PIOYXVW7.js → initializer-74A7DMMD.js} +21 -21
  118. package/chunks/{installationInfo-IWMM6DPV.js → installationInfo-OFDYLDFD.js} +17 -17
  119. package/chunks/{list-3DCR4TRI.js → list-JA2EWRHJ.js} +24 -24
  120. package/chunks/{list-agents-TWEGRJWO.js → list-agents-GC4BRET7.js} +1 -1
  121. package/chunks/{loadedSettingsAdapter-EJC6CU5N.js → loadedSettingsAdapter-2GNJOQ3L.js} +21 -21
  122. package/chunks/{loggingContentGenerator-2JEFU25T.js → loggingContentGenerator-B6B5EGB3.js} +8 -8
  123. package/chunks/{loop-wakeup-6LLEOQYV.js → loop-wakeup-SQQSBMEY.js} +2 -2
  124. package/chunks/{ls-H5WX22VK.js → ls-63CC3NNX.js} +1 -1
  125. package/chunks/{lsp-G6FXYEIS.js → lsp-P6NVJVNT.js} +1 -1
  126. package/chunks/{managed-npm-update-EGVQPSBR.js → managed-npm-update-4YZHLUER.js} +17 -17
  127. package/chunks/{mcp-KFFH2MBV.js → mcp-LLK5YJVH.js} +21 -21
  128. package/chunks/{monitor-6Y3NDMTI.js → monitor-NYJPAWVP.js} +16 -16
  129. package/chunks/{nonInteractiveCli-426IQDPE.js → nonInteractiveCli-HZBBBDJD.js} +45 -45
  130. package/chunks/{notebook-edit-373IQQLE.js → notebook-edit-LLM6UXFX.js} +17 -17
  131. package/chunks/{openaiContentGenerator-PGFSOMIQ.js → openaiContentGenerator-2AEXDN55.js} +8 -8
  132. package/chunks/{pidfile-Y4INDMHG.js → pidfile-3JUWX7G2.js} +16 -16
  133. package/chunks/{processUtils-6BCPCJZW.js → processUtils-JLLRVZHT.js} +2 -2
  134. package/chunks/{qwenContentGenerator-QC3KSHSX.js → qwenContentGenerator-2FESCF27.js} +17 -17
  135. package/chunks/{qwenOAuth2-IOAXKJ3L.js → qwenOAuth2-2KKPYA5J.js} +1 -1
  136. package/chunks/{read-file-2T54FYZV.js → read-file-5GVXLY74.js} +6 -6
  137. package/chunks/{read-mcp-resource-DRZSI3HE.js → read-mcp-resource-RTSSEER5.js} +1 -1
  138. package/chunks/{record-artifact-IPIRWMFY.js → record-artifact-L3BAHQFN.js} +2 -2
  139. package/chunks/{resumeHistoryUtils-O62RDCZ3.js → resumeHistoryUtils-Z4OFBXPM.js} +19 -19
  140. package/chunks/{ripGrep-3H72KY7S.js → ripGrep-TKOJTIAB.js} +16 -16
  141. package/chunks/{run-qwen-serve-3AIDNNHO.js → run-qwen-serve-K5W6MM6M.js} +27 -27
  142. package/chunks/{runtime-AZ4EHHFV.js → runtime-IADXMRCY.js} +22 -22
  143. package/chunks/{scheduler-L4UUCU4Z.js → scheduler-T7AV37LD.js} +16 -16
  144. package/chunks/{sdk-exporters-http-IKNWQJNV.js → sdk-exporters-http-IL2346MJ.js} +6 -2
  145. package/chunks/{sdk-impl-7CUUMQDB.js → sdk-impl-SYKGVWOZ.js} +2 -2
  146. package/chunks/{send-message-LHJLVWFD.js → send-message-TL6FIMMN.js} +3 -3
  147. package/chunks/{serve-CLXGSYOE.js → serve-ROEGMS3I.js} +21 -21
  148. package/chunks/{server-MEAE3WMM.js → server-NGXMRODI.js} +40 -40
  149. package/chunks/{session-OSLD2LT5.js → session-RCDLDJA4.js} +46 -46
  150. package/chunks/{settings-ILWAOKA4.js → settings-E6H3AURD.js} +20 -20
  151. package/chunks/{shell-RT5DBH6B.js → shell-RHGGJ6BE.js} +16 -16
  152. package/chunks/{skill-LVGA3ATZ.js → skill-GQ7PBS25.js} +7 -7
  153. package/chunks/{skill-settings-WTZE7EPE.js → skill-settings-E2F7OCBL.js} +20 -20
  154. package/chunks/{spawnChannel-BOBS7DVM.js → spawnChannel-Q2IQBHME.js} +16 -16
  155. package/chunks/{standalone-update-Y5JB4S2K.js → standalone-update-NYYZEHLD.js} +18 -18
  156. package/chunks/{startInteractiveUI-ZV25CD2S.js → startInteractiveUI-IX6I3Y2Z.js} +62 -59
  157. package/chunks/{syntheticOutput-EYL7DWO7.js → syntheticOutput-BN7E626U.js} +2 -2
  158. package/chunks/{task-create-4ALZMGP5.js → task-create-2X4UP4F3.js} +4 -4
  159. package/chunks/{task-list-6CVQPORX.js → task-list-WOLJPZ64.js} +1 -1
  160. package/chunks/{task-stop-Y5ZTFVRX.js → task-stop-TNXRNAL2.js} +1 -1
  161. package/chunks/{task-update-IKCEEWJ6.js → task-update-VDUSN36E.js} +4 -4
  162. package/chunks/{team-create-ZVPQIXCP.js → team-create-UTRVUEDA.js} +16 -16
  163. package/chunks/{team-delete-CE7DC53R.js → team-delete-D2VMSDOT.js} +1 -1
  164. package/chunks/{team-plan-approval-5UHUBY3W.js → team-plan-approval-YZNB4U5U.js} +16 -16
  165. package/chunks/{terminal-image-renderer-NWC2RALG.js → terminal-image-renderer-QRSCS2BE.js} +17 -17
  166. package/chunks/{theme-manager-5KICSBOB.js → theme-manager-EKZBY34I.js} +16 -16
  167. package/chunks/{todoWrite-FTZWQRZH.js → todoWrite-MHWHO5UO.js} +1 -1
  168. package/chunks/{tool-search-2AOU77H4.js → tool-search-N2R7LVMC.js} +8 -8
  169. package/chunks/{total-session-admission-FR7RMHVL.js → total-session-admission-HBIYARPO.js} +17 -17
  170. package/chunks/{trustedFolders-V7UUPQXO.js → trustedFolders-ZQLYRCSY.js} +17 -17
  171. package/chunks/{update-relaunch-TBWRMQD6.js → update-relaunch-PJWXMPCR.js} +5 -5
  172. package/chunks/{updateCheck-42SPCLH7.js → updateCheck-ZXRCGY66.js} +19 -19
  173. package/chunks/{useAutoAcceptIndicator-4C2KM345.js → useAutoAcceptIndicator-ZYQW5SGJ.js} +22 -22
  174. package/chunks/{validateNonInterActiveAuth-UVFRXV3Z.js → validateNonInterActiveAuth-M7J7OTRH.js} +42 -42
  175. package/chunks/{version-HKTV6TPN.js → version-2AOHMPK3.js} +1 -1
  176. package/chunks/{web-fetch-ZRXSV5AN.js → web-fetch-DS34CJ3R.js} +6 -6
  177. package/chunks/{web-search-WOLV3L6T.js → web-search-ITFPD7V4.js} +4 -4
  178. package/chunks/{workflow-F63ES3OB.js → workflow-LZQ4PGNS.js} +17 -17
  179. package/chunks/{workspace-providers-status-PJMGMYMC.js → workspace-providers-status-ZPTLKOBM.js} +23 -23
  180. package/chunks/{workspace-registration-store-LNBOX5TJ.js → workspace-registration-store-OTFKSGG7.js} +1 -1
  181. package/chunks/{workspace-registry-4PR7VDQ3.js → workspace-registry-YZ3OXPHP.js} +17 -17
  182. package/chunks/{workspace-service-PVI3VUNQ.js → workspace-service-OCZXOOSQ.js} +24 -24
  183. package/chunks/{workspace-skills-status-2Q5ZISO6.js → workspace-skills-status-K2ALGUCD.js} +21 -21
  184. package/chunks/{workspace-trust-reconciler-NOILUH3C.js → workspace-trust-reconciler-KMRZISJP.js} +22 -22
  185. package/chunks/{write-file-MOM4JDHG.js → write-file-AWBI4GJS.js} +16 -16
  186. package/chunks/{zoom-image-E3VHRCFU.js → zoom-image-NHKN6F77.js} +6 -6
  187. package/cli.js +12 -12
  188. package/package.json +3 -3
  189. package/web-shell/assets/{arc-GpdmhIxr.js → arc-Dpg66jw7.js} +1 -1
  190. package/web-shell/assets/{architectureDiagram-3BPJPVTR-C-LhCgH_.js → architectureDiagram-3BPJPVTR-BJ4FIBxN.js} +1 -1
  191. package/web-shell/assets/{blockDiagram-GPEHLZMM-CzNdTCm-.js → blockDiagram-GPEHLZMM-VXmYdtYT.js} +1 -1
  192. package/web-shell/assets/{c4Diagram-AAUBKEIU-Ce7hbrRM.js → c4Diagram-AAUBKEIU-BNLDb8FE.js} +1 -1
  193. package/web-shell/assets/channel-Bd9wOnaA.js +1 -0
  194. package/web-shell/assets/{chunk-2J33WTMH-BBSEn1PK.js → chunk-2J33WTMH-DR5yHxr0.js} +1 -1
  195. package/web-shell/assets/{chunk-4BX2VUAB-_llgjfe5.js → chunk-4BX2VUAB-Czkq8UZU.js} +1 -1
  196. package/web-shell/assets/{chunk-55IACEB6-9fJZ_oZE.js → chunk-55IACEB6-DugUgM6s.js} +1 -1
  197. package/web-shell/assets/{chunk-727SXJPM-DgEzQWOu.js → chunk-727SXJPM-Dw6quA1K.js} +1 -1
  198. package/web-shell/assets/{chunk-AQP2D5EJ-B4RthUTc.js → chunk-AQP2D5EJ-BoVYOTTz.js} +1 -1
  199. package/web-shell/assets/{chunk-FMBD7UC4-CDI-emMW.js → chunk-FMBD7UC4--Amcse-j.js} +1 -1
  200. package/web-shell/assets/{chunk-ND2GUHAM-jM2-yOd8.js → chunk-ND2GUHAM-ajaEYAC8.js} +1 -1
  201. package/web-shell/assets/{chunk-QZHKN3VN-XGZHlKPF.js → chunk-QZHKN3VN-CUNDZ7im.js} +1 -1
  202. package/web-shell/assets/classDiagram-4FO5ZUOK-XhCT8FE3.js +1 -0
  203. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-XhCT8FE3.js +1 -0
  204. package/web-shell/assets/{cose-bilkent-S5V4N54A-90nbW1xQ.js → cose-bilkent-S5V4N54A-BnfkD-m1.js} +1 -1
  205. package/web-shell/assets/{dagre-BM42HDAG-BtzlyqZ9.js → dagre-BM42HDAG-BuUdFk7Z.js} +1 -1
  206. package/web-shell/assets/{diagram-2AECGRRQ-DAaqGWaH.js → diagram-2AECGRRQ-B2ZXxoab.js} +1 -1
  207. package/web-shell/assets/{diagram-5GNKFQAL-CxlzSIFa.js → diagram-5GNKFQAL-BsgOICzM.js} +1 -1
  208. package/web-shell/assets/{diagram-KO2AKTUF-8kj-1H6u.js → diagram-KO2AKTUF-DTTjG6U-.js} +1 -1
  209. package/web-shell/assets/{diagram-LMA3HP47-6NhjFwRF.js → diagram-LMA3HP47-temLf1x7.js} +1 -1
  210. package/web-shell/assets/{diagram-OG6HWLK6-Bn9kvInz.js → diagram-OG6HWLK6-CRFjScs2.js} +1 -1
  211. package/web-shell/assets/{erDiagram-TEJ5UH35-CaRoGsAt.js → erDiagram-TEJ5UH35-D4oaY-rQ.js} +1 -1
  212. package/web-shell/assets/{flowDiagram-I6XJVG4X-TkLweHdf.js → flowDiagram-I6XJVG4X-BqG8B49b.js} +1 -1
  213. package/web-shell/assets/{ganttDiagram-6RSMTGT7-ruwhCKBl.js → ganttDiagram-6RSMTGT7-DffQBdd5.js} +1 -1
  214. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-DNI_PxoU.js → gitGraphDiagram-PVQCEYII-CMDPfseF.js} +1 -1
  215. package/web-shell/assets/{index-T4KluHvu.js → index-2F4RsNzd.js} +322 -322
  216. package/web-shell/assets/index-CaucmEO_.css +5 -0
  217. package/web-shell/assets/{index-p1gz-sxE.js → index-qTQR_smP.js} +1 -1
  218. package/web-shell/assets/{infoDiagram-5YYISTIA-DarXq1-A.js → infoDiagram-5YYISTIA-Cn3T83MA.js} +1 -1
  219. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-GxDaDlT0.js → ishikawaDiagram-YF4QCWOH-ijFs7e25.js} +1 -1
  220. package/web-shell/assets/{journeyDiagram-JHISSGLW-mDEoGBzY.js → journeyDiagram-JHISSGLW-CINTv8VB.js} +1 -1
  221. package/web-shell/assets/{kanban-definition-UN3LZRKU-Ds0t-Mup.js → kanban-definition-UN3LZRKU-CMGRZCxx.js} +1 -1
  222. package/web-shell/assets/{linear-05nJ0xZ7.js → linear-Co-2_37d.js} +1 -1
  223. package/web-shell/assets/{mermaid.core-Bua24ThM.js → mermaid.core-DijbyaN5.js} +5 -5
  224. package/web-shell/assets/{mindmap-definition-RKZ34NQL-D_zRdvUS.js → mindmap-definition-RKZ34NQL-k_sDYDPZ.js} +1 -1
  225. package/web-shell/assets/{pieDiagram-4H26LBE5-DZHr1x16.js → pieDiagram-4H26LBE5-CG-oz8V3.js} +1 -1
  226. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-HA06Wf0h.js → quadrantDiagram-W4KKPZXB-Baq7HIG2.js} +1 -1
  227. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DH3urmJf.js → requirementDiagram-4Y6WPE33-CDM3ZvBt.js} +1 -1
  228. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-C4xgz0TT.js → sankeyDiagram-5OEKKPKP-C2dJbWKN.js} +1 -1
  229. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DAUoZWgv.js → sequenceDiagram-3UESZ5HK-Cf1_h59p.js} +1 -1
  230. package/web-shell/assets/{stateDiagram-AJRCARHV-v7NzXy4l.js → stateDiagram-AJRCARHV-CI5clUEc.js} +1 -1
  231. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BDc8asKD.js +1 -0
  232. package/web-shell/assets/{timeline-definition-PNZ67QCA-B3GTYR2W.js → timeline-definition-PNZ67QCA-B2O8cAZX.js} +1 -1
  233. package/web-shell/assets/{vennDiagram-CIIHVFJN-BWHjSPAq.js → vennDiagram-CIIHVFJN-BLsJ_h9s.js} +1 -1
  234. package/web-shell/assets/{wardley-L42UT6IY-m9r6IUBC.js → wardley-L42UT6IY-BlPU4FTA.js} +1 -1
  235. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-kT0FkVfK.js → wardleyDiagram-YWT4CUSO-D_U-RdU4.js} +1 -1
  236. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CYRm10z5.js → xychartDiagram-2RQKCTM6-BynXGSTl.js} +1 -1
  237. package/web-shell/index.html +2 -2
  238. package/web-shell/assets/channel-95y6Rcp3.js +0 -1
  239. package/web-shell/assets/classDiagram-4FO5ZUOK-pfzVkmjQ.js +0 -1
  240. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-pfzVkmjQ.js +0 -1
  241. package/web-shell/assets/index-WxSvj2tI.css +0 -5
  242. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CtdFexEf.js +0 -1
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  recomputeMcpGating
5
- } from "./chunk-M6RNMBUO.js";
5
+ } from "./chunk-YMUZQ3MQ.js";
6
6
  import {
7
7
  classifyApiError,
8
8
  fireSessionDeleteHook
@@ -16,14 +16,14 @@ import {
16
16
  matchMcpServerByRef,
17
17
  parseExtensionRef,
18
18
  parseMcpServerRef
19
- } from "./chunk-PQ5JFCNL.js";
19
+ } from "./chunk-JDNWIXHJ.js";
20
20
  import {
21
21
  getAvailableCommands,
22
22
  handleSlashCommand,
23
23
  insertAfterFunctionResponses,
24
24
  isSlashCommand,
25
25
  normalizePartList
26
- } from "./chunk-WDLQGFWP.js";
26
+ } from "./chunk-IWYXZAGT.js";
27
27
  import {
28
28
  SessionIdConflictError,
29
29
  appEvents,
@@ -31,23 +31,23 @@ import {
31
31
  cleanupReviewWorktreeLeases,
32
32
  loadCliConfig,
33
33
  normalizeDisabledToolList
34
- } from "./chunk-2T3RYG4L.js";
34
+ } from "./chunk-GP4IMBX5.js";
35
35
  import "./chunk-NYX53SV4.js";
36
36
  import {
37
37
  collectContextData,
38
38
  formatContextUsageText
39
- } from "./chunk-C5YFS6VR.js";
39
+ } from "./chunk-4NNR24EP.js";
40
40
  import {
41
41
  getCommandSubcommandNames
42
- } from "./chunk-QZQ72YF6.js";
42
+ } from "./chunk-G2UXFO2B.js";
43
43
  import {
44
44
  getEffectiveSupportedModes
45
- } from "./chunk-DJA7YBLJ.js";
45
+ } from "./chunk-C6ARWPCG.js";
46
46
  import "./chunk-3LGZEYOF.js";
47
47
  import "./chunk-4WGODMVR.js";
48
- import "./chunk-THLV7YGY.js";
48
+ import "./chunk-EXHQZBVJ.js";
49
49
  import "./chunk-KKN2IE7Q.js";
50
- import "./chunk-2ON2O4MD.js";
50
+ import "./chunk-SVIEVA3L.js";
51
51
  import "./chunk-6H67XLET.js";
52
52
  import {
53
53
  beginAcpBootstrapConfigProfiling,
@@ -55,8 +55,8 @@ import {
55
55
  endAcpBootstrapConfigProfiling,
56
56
  markAcpStartup
57
57
  } from "./chunk-M744OFVE.js";
58
- import "./chunk-P5UJMCVS.js";
59
- import "./chunk-EJXATV5R.js";
58
+ import "./chunk-ZLGPHA34.js";
59
+ import "./chunk-VJPF6GF2.js";
60
60
  import "./chunk-YAF2MQZ6.js";
61
61
  import {
62
62
  GENERATION_MAX_PROMPT_BYTES,
@@ -78,7 +78,7 @@ import {
78
78
  shouldSuppressRememberErrorDetails,
79
79
  workspaceMemoryFailureCode,
80
80
  workspaceMemoryFailureDiagnostics
81
- } from "./chunk-I32URQI7.js";
81
+ } from "./chunk-IWGMDSC3.js";
82
82
  import {
83
83
  HistoryReplayer,
84
84
  MessageEmitter,
@@ -88,10 +88,10 @@ import {
88
88
  goalTerminalEventToHistoryItem,
89
89
  recordGoalStatusItem,
90
90
  restoreGoalFromHistory
91
- } from "./chunk-DHNFB7NC.js";
91
+ } from "./chunk-YO4JI7B4.js";
92
92
  import "./chunk-DYA25Y7U.js";
93
93
  import "./chunk-4NFY2S7N.js";
94
- import "./chunk-AFJSRJTO.js";
94
+ import "./chunk-5HWAJ4BK.js";
95
95
  import "./chunk-2MIN6GRR.js";
96
96
  import "./chunk-QHTIBUWB.js";
97
97
  import {
@@ -112,32 +112,32 @@ import {
112
112
  buildPermissionSettings,
113
113
  normalizePermissionRules,
114
114
  readPermissionRuleSet
115
- } from "./chunk-RL2NPV5E.js";
115
+ } from "./chunk-4O6HLCOF.js";
116
116
  import {
117
117
  MAX_AUDIO_BYTES,
118
118
  sanitizeVoiceErrorMessage,
119
119
  transcribeVoiceAudio
120
- } from "./chunk-G6KI6B5L.js";
120
+ } from "./chunk-LMNM37OE.js";
121
121
  import {
122
122
  readVoiceModel
123
- } from "./chunk-FPPVCCAH.js";
123
+ } from "./chunk-TCOJPG2P.js";
124
124
  import "./chunk-JELIWHXD.js";
125
125
  import {
126
126
  resolveSkillSettings
127
127
  } from "./chunk-Z4X5MTRT.js";
128
- import "./chunk-5XGI4IPK.js";
129
- import "./chunk-O4IWFYUW.js";
128
+ import "./chunk-VOA2UPZM.js";
129
+ import "./chunk-3GOCVBYR.js";
130
130
  import "./chunk-57OAHC2Y.js";
131
131
  import {
132
132
  createLoadedSettingsAdapter
133
- } from "./chunk-C6FU76AA.js";
133
+ } from "./chunk-K6VEL5KP.js";
134
134
  import "./chunk-VXZBKKQR.js";
135
- import "./chunk-XPAY4EMH.js";
135
+ import "./chunk-IK3RYLAD.js";
136
136
  import "./chunk-3SH53ANB.js";
137
137
  import {
138
138
  SESSION_SOURCE_META_KEY,
139
139
  parseSessionSource
140
- } from "./chunk-B3EBXISV.js";
140
+ } from "./chunk-KH2BIJ4H.js";
141
141
  import "./chunk-GLWP3FDB.js";
142
142
  import "./chunk-XCGIMOLN.js";
143
143
  import "./chunk-OCPBI7J5.js";
@@ -152,7 +152,7 @@ import {
152
152
  parseAcpModelOption,
153
153
  resolveAcpModelOption,
154
154
  sanitizeProviderBaseUrl
155
- } from "./chunk-IMGNGOGC.js";
155
+ } from "./chunk-WU5NBSLD.js";
156
156
  import {
157
157
  ACP_PREFLIGHT_KINDS,
158
158
  IDLE_HOOK_EVENTS,
@@ -207,7 +207,7 @@ import {
207
207
  import {
208
208
  assembleMcpServers,
209
209
  loadMcpApprovals
210
- } from "./chunk-6ME3PVMM.js";
210
+ } from "./chunk-SJMCYCUQ.js";
211
211
  import {
212
212
  getOutputLanguageFilePath,
213
213
  getPersistScopeForModelSelection,
@@ -215,7 +215,7 @@ import {
215
215
  resolveOutputLanguageOrPreserveAuto,
216
216
  updateOutputLanguageFile,
217
217
  writeOutputLanguageAndRegisterPath
218
- } from "./chunk-KB6VSG2U.js";
218
+ } from "./chunk-RM3F46UT.js";
219
219
  import "./chunk-RKUWKYED.js";
220
220
  import "./chunk-GOXKNSDZ.js";
221
221
  import "./chunk-IDS7MSUP.js";
@@ -223,19 +223,19 @@ import {
223
223
  SUPPORTED_LANGUAGES,
224
224
  getCurrentLanguage,
225
225
  setLanguageAsync
226
- } from "./chunk-FV4TUUDE.js";
226
+ } from "./chunk-K64OI7S7.js";
227
227
  import {
228
228
  reloadEnvironment
229
- } from "./chunk-4PZ7SPD5.js";
229
+ } from "./chunk-LYPXNRBX.js";
230
230
  import "./chunk-6PEXNQTX.js";
231
- import "./chunk-RNKGMZEW.js";
232
- import "./chunk-HBCKZF2A.js";
231
+ import "./chunk-CAX76R46.js";
232
+ import "./chunk-IZ2CMEYO.js";
233
233
  import "./chunk-VJNBRRZG.js";
234
234
  import {
235
235
  isFolderTrustEnabled,
236
236
  isWorkspaceTrusted,
237
237
  loadTrustedFolders
238
- } from "./chunk-URVJ4AZC.js";
238
+ } from "./chunk-B3EBIZUY.js";
239
239
  import "./chunk-ALGGS7UH.js";
240
240
  import "./chunk-MR3PXB6E.js";
241
241
  import "./chunk-XFSFZCM5.js";
@@ -363,25 +363,25 @@ import {
363
363
  validatePlanModeShellApproval,
364
364
  validatePlanModeShellContext,
365
365
  wrapUserPromptSubmitContext
366
- } from "./chunk-E2SYUEIA.js";
366
+ } from "./chunk-YLL3SC5S.js";
367
367
  import "./chunk-GOFAQQZA.js";
368
368
  import "./chunk-5M6IDOMF.js";
369
369
  import "./chunk-TWPJO254.js";
370
370
  import {
371
371
  external_exports
372
372
  } from "./chunk-H6XPXXMH.js";
373
- import "./chunk-VA5NLVPT.js";
373
+ import "./chunk-Z7JILXGX.js";
374
374
  import "./chunk-I7JDGNG6.js";
375
375
  import "./chunk-A6SX5TAH.js";
376
376
  import "./chunk-33FNCQSY.js";
377
377
  import {
378
378
  parsePositiveIntegerEnv
379
379
  } from "./chunk-6PVPNMXU.js";
380
- import "./chunk-DZPOYHBT.js";
380
+ import "./chunk-7W5KOBYU.js";
381
381
  import "./chunk-IRH27ZC2.js";
382
382
  import "./chunk-QHWCP53L.js";
383
383
  import "./chunk-MOHAWIAW.js";
384
- import "./chunk-X6QNZOTC.js";
384
+ import "./chunk-7MFQLOHZ.js";
385
385
  import {
386
386
  promptIdContext,
387
387
  todoWorkChainContext
@@ -397,21 +397,21 @@ import {
397
397
  } from "./chunk-A5YZ3FA2.js";
398
398
  import "./chunk-YAVY33G4.js";
399
399
  import "./chunk-2UISUFHQ.js";
400
- import "./chunk-HFVW54NL.js";
400
+ import "./chunk-MBEMTXQT.js";
401
401
  import {
402
402
  APPROVAL_MODES,
403
403
  runWithRuntimeContentGenerator
404
- } from "./chunk-LLMGP5IC.js";
404
+ } from "./chunk-6WBWIPBF.js";
405
405
  import "./chunk-S6LOFUVP.js";
406
406
  import {
407
407
  FORK_SUBAGENT_TYPE,
408
408
  getStartupContextLength,
409
409
  isSystemReminderContent
410
- } from "./chunk-7UXI6P72.js";
410
+ } from "./chunk-WVAESIM6.js";
411
411
  import "./chunk-K623ENWT.js";
412
412
  import "./chunk-AQ37AY7B.js";
413
413
  import "./chunk-432XCUHF.js";
414
- import "./chunk-YXEVDA66.js";
414
+ import "./chunk-4LLUH3A7.js";
415
415
  import {
416
416
  clearCachedCredentialFile,
417
417
  qwenOAuth2Events
@@ -423,7 +423,7 @@ import "./chunk-DGEIYUC3.js";
423
423
  import "./chunk-MPHPFVKK.js";
424
424
  import "./chunk-GLNBDYUX.js";
425
425
  import "./chunk-DJ2GSRLV.js";
426
- import "./chunk-SBBHZ3YT.js";
426
+ import "./chunk-AEWOKOJY.js";
427
427
  import {
428
428
  addToolArgumentsAttributes,
429
429
  addToolCallResultAttributes,
@@ -431,7 +431,7 @@ import {
431
431
  registerAcpEventLoopLagGauge,
432
432
  startEventLoopLagMonitor,
433
433
  withDaemonSpan
434
- } from "./chunk-RPYYTL7E.js";
434
+ } from "./chunk-MGSSJT27.js";
435
435
  import "./chunk-2J3OJGTL.js";
436
436
  import "./chunk-P3QQPMQA.js";
437
437
  import "./chunk-6O5DVH27.js";
@@ -469,22 +469,22 @@ import {
469
469
  shouldRunVisionBridge,
470
470
  splitImageParts,
471
471
  uiTelemetryService
472
- } from "./chunk-JDJ7SC4E.js";
472
+ } from "./chunk-ZPGMDT4S.js";
473
473
  import "./chunk-VGC4I5JJ.js";
474
474
  import {
475
475
  getAutoMemoryRoot,
476
476
  getUserAutoMemoryRoot
477
477
  } from "./chunk-E4WHKETF.js";
478
- import "./chunk-UEJESCS7.js";
478
+ import "./chunk-ZPPP6VCL.js";
479
479
  import {
480
480
  ToolConfirmationOutcome,
481
481
  ToolNames,
482
482
  isShellProgressData
483
- } from "./chunk-CFDR3GNL.js";
483
+ } from "./chunk-D7D7RXIJ.js";
484
484
  import {
485
485
  AuthType,
486
486
  preloadContentGenerator
487
- } from "./chunk-TXZDRD36.js";
487
+ } from "./chunk-XD2PNH3K.js";
488
488
  import "./chunk-46UV252V.js";
489
489
  import {
490
490
  DEFAULT_TOKEN_LIMIT,
@@ -501,9 +501,9 @@ import {
501
501
  startToolExecutionSpan,
502
502
  startToolSpan,
503
503
  withInteractionSpan
504
- } from "./chunk-O2ZYHG33.js";
504
+ } from "./chunk-5L6CQ4ZU.js";
505
505
  import "./chunk-W4RQUHY3.js";
506
- import "./chunk-G7XXKQYS.js";
506
+ import "./chunk-LKRMNRSN.js";
507
507
  import {
508
508
  Storage,
509
509
  createDebugLogger,
@@ -512,10 +512,10 @@ import {
512
512
  isSubpath
513
513
  } from "./chunk-3RXUYQJI.js";
514
514
  import "./chunk-VOQXFAY5.js";
515
- import "./chunk-KHSJSMFS.js";
515
+ import "./chunk-K2ETEWG6.js";
516
516
  import {
517
517
  runExitCleanup
518
- } from "./chunk-SV5X2EUV.js";
518
+ } from "./chunk-LSYVASZS.js";
519
519
  import {
520
520
  writeStderrLine,
521
521
  writeStderrLineSafe
@@ -1242,6 +1242,11 @@ var SubAgentTracker = class {
1242
1242
  callId: event.callId,
1243
1243
  args: event.args,
1244
1244
  subagentMeta: this.subagentMeta
1245
+ }).catch((error) => {
1246
+ debugLogger2.debug(
1247
+ `Failed to emit subagent tool start for ${event.name}:`,
1248
+ error
1249
+ );
1245
1250
  });
1246
1251
  };
1247
1252
  }
@@ -1261,6 +1266,11 @@ var SubAgentTracker = class {
1261
1266
  resultDisplay: event.resultDisplay,
1262
1267
  args: state?.args,
1263
1268
  subagentMeta: this.subagentMeta
1269
+ }).catch((error) => {
1270
+ debugLogger2.debug(
1271
+ `Failed to emit subagent tool result for ${event.name}:`,
1272
+ error
1273
+ );
1264
1274
  });
1265
1275
  this.toolStates.delete(event.callId);
1266
1276
  };
@@ -1314,7 +1324,7 @@ var SubAgentTracker = class {
1314
1324
  await event.respond(outcome, {
1315
1325
  answers: "answers" in output ? output.answers : void 0
1316
1326
  });
1317
- if (outcome === "cancel" /* Cancel */) {
1327
+ if (outcome === "cancel" /* Cancel */ && !abortSignal.aborted) {
1318
1328
  this.onPermissionCancel?.();
1319
1329
  }
1320
1330
  } catch (error) {
@@ -1322,7 +1332,9 @@ var SubAgentTracker = class {
1322
1332
  `Permission request failed for subagent tool ${event.name}:`,
1323
1333
  error
1324
1334
  );
1325
- this.onPermissionCancel?.();
1335
+ if (!abortSignal.aborted) {
1336
+ this.onPermissionCancel?.();
1337
+ }
1326
1338
  try {
1327
1339
  await event.respond("cancel" /* Cancel */);
1328
1340
  } catch (respondError) {
@@ -1341,12 +1353,9 @@ var SubAgentTracker = class {
1341
1353
  return (...args) => {
1342
1354
  const event = args[0];
1343
1355
  if (abortSignal.aborted) return;
1344
- this.messageEmitter.emitUsageMetadata(
1345
- event.usage,
1346
- "",
1347
- event.durationMs,
1348
- this.subagentMeta
1349
- );
1356
+ void this.messageEmitter.emitUsageMetadata(event.usage, "", event.durationMs, this.subagentMeta).catch((error) => {
1357
+ debugLogger2.debug("Failed to emit subagent usage metadata:", error);
1358
+ });
1350
1359
  };
1351
1360
  }
1352
1361
  /**
@@ -1363,7 +1372,9 @@ var SubAgentTracker = class {
1363
1372
  event.thought ?? false,
1364
1373
  void 0,
1365
1374
  this.subagentMeta
1366
- );
1375
+ ).catch((error) => {
1376
+ debugLogger2.debug("Failed to emit subagent stream text:", error);
1377
+ });
1367
1378
  };
1368
1379
  }
1369
1380
  };
@@ -1912,6 +1923,8 @@ var DAEMON_INVALID_TOOL_PARAMS_THRESHOLD = 3;
1912
1923
  var PERMISSION_CANCEL_SKIP_MESSAGE = "Skipped because a permission request was cancelled before the user answered; user input is required before continuing.";
1913
1924
  var LOOP_DETECTED_SKIP_MESSAGE = "Skipped because loop detection stopped the current turn before this tool call could run.";
1914
1925
  var LOOP_DETECTED_CONTEXT_MESSAGE = "System: this turn was terminated because the model exceeded tool-call safety limits. Try a different approach on the next turn.";
1926
+ var TOOL_EXECUTION_CANCELLED_MESSAGE = "Tool execution was cancelled.";
1927
+ var TOOL_POST_EXECUTION_CANCELLED_MESSAGE = "The tool had already completed; its output was discarded.";
1915
1928
  function createDaemonToolLoopState() {
1916
1929
  return {
1917
1930
  totalToolCalls: 0,
@@ -1924,7 +1937,14 @@ function recordDaemonLoopDetected(config, promptId, loopType, message, loopState
1924
1937
  if (!loopState.loopDetected) {
1925
1938
  loopState.loopDetected = true;
1926
1939
  debugLogger5.warn(message);
1927
- logLoopDetected(config, new LoopDetectedEvent(loopType, promptId));
1940
+ try {
1941
+ logLoopDetected(config, new LoopDetectedEvent(loopType, promptId));
1942
+ } catch (error) {
1943
+ debugLogger5.debug(
1944
+ "[Session] Failed to record loop detection telemetry",
1945
+ error
1946
+ );
1947
+ }
1928
1948
  }
1929
1949
  return true;
1930
1950
  }
@@ -3961,7 +3981,7 @@ ${this.pendingRecoveredAgentsNotice}
3961
3981
  onFullTurnModel
3962
3982
  )
3963
3983
  );
3964
- if (toolRun.stopAfterPermissionCancel) {
3984
+ if (toolRun.stopAfterPermissionCancel || pendingSend.signal.aborted) {
3965
3985
  this.todoStopGuard.suspend();
3966
3986
  await this.#preserveStoppedToolRun(
3967
3987
  toolRun,
@@ -4700,7 +4720,7 @@ ${this.pendingRecoveredAgentsNotice}
4700
4720
  options.onFullTurnModel
4701
4721
  )
4702
4722
  );
4703
- if (toolRun.stopAfterPermissionCancel || toolRun.loopDetected) {
4723
+ if (toolRun.stopAfterPermissionCancel || toolRun.loopDetected || pendingSend.signal.aborted) {
4704
4724
  this.todoStopGuard.suspend();
4705
4725
  await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
4706
4726
  return {
@@ -5661,7 +5681,7 @@ ${this.pendingRecoveredAgentsNotice}
5661
5681
  functionCalls,
5662
5682
  toolLoopState
5663
5683
  );
5664
- if (toolRun.stopAfterPermissionCancel) {
5684
+ if (toolRun.stopAfterPermissionCancel || ac.signal.aborted) {
5665
5685
  this.todoStopGuard.suspend();
5666
5686
  await this.#preserveStoppedToolRun(toolRun, ac.signal);
5667
5687
  return;
@@ -6067,7 +6087,7 @@ ${this.pendingRecoveredAgentsNotice}
6067
6087
  functionCalls,
6068
6088
  toolLoopState
6069
6089
  );
6070
- if (toolRun.stopAfterPermissionCancel) {
6090
+ if (toolRun.stopAfterPermissionCancel || ac.signal.aborted) {
6071
6091
  this.todoStopGuard.suspend();
6072
6092
  await this.#preserveStoppedToolRun(toolRun, ac.signal);
6073
6093
  await this.#emitBackgroundNotificationEndTurn(
@@ -6493,9 +6513,10 @@ ${this.pendingRecoveredAgentsNotice}
6493
6513
  metadata: {
6494
6514
  callId,
6495
6515
  status: "error",
6516
+ executionStatus: "not_started",
6496
6517
  resultDisplay: void 0,
6497
6518
  error,
6498
- errorType
6519
+ errorType: errorType ?? "execution_denied" /* EXECUTION_DENIED */
6499
6520
  }
6500
6521
  });
6501
6522
  if (emitStart) {
@@ -6521,7 +6542,12 @@ ${this.pendingRecoveredAgentsNotice}
6521
6542
  return await finalizeRunToolResult({
6522
6543
  parts: await Promise.all(
6523
6544
  dedupedFunctionCalls.map(
6524
- (fc) => recordSkippedToolCall(fc, LOOP_DETECTED_SKIP_MESSAGE, false)
6545
+ (fc) => recordSkippedToolCall(
6546
+ fc,
6547
+ LOOP_DETECTED_SKIP_MESSAGE,
6548
+ false,
6549
+ "unknown" /* UNKNOWN */
6550
+ )
6525
6551
  )
6526
6552
  ),
6527
6553
  stopAfterPermissionCancel: false,
@@ -6563,38 +6589,47 @@ ${this.pendingRecoveredAgentsNotice}
6563
6589
  }, "pushDuplicateBatch");
6564
6590
  const emitDuplicateBatch = /* @__PURE__ */ __name(async (batch) => {
6565
6591
  const { request, response } = batch;
6566
- if (request.name === ToolNames.TODO_WRITE) {
6567
- const provenance = ToolCallEmitter.resolveToolProvenance(request.name);
6568
- await this.sendUpdate({
6569
- sessionUpdate: "tool_call_update",
6570
- toolCallId: response.callId,
6571
- status: "failed",
6572
- content: [
6573
- {
6574
- type: "content",
6575
- content: {
6576
- type: "text",
6577
- text: response.error?.message ?? String(response.resultDisplay)
6592
+ try {
6593
+ if (request.name === ToolNames.TODO_WRITE) {
6594
+ const provenance = ToolCallEmitter.resolveToolProvenance(
6595
+ request.name
6596
+ );
6597
+ await this.sendUpdate({
6598
+ sessionUpdate: "tool_call_update",
6599
+ toolCallId: response.callId,
6600
+ status: "failed",
6601
+ content: [
6602
+ {
6603
+ type: "content",
6604
+ content: {
6605
+ type: "text",
6606
+ text: response.error?.message ?? String(response.resultDisplay)
6607
+ }
6578
6608
  }
6609
+ ],
6610
+ rawOutput: response.resultDisplay,
6611
+ _meta: {
6612
+ toolName: request.name,
6613
+ provenance: provenance.provenance,
6614
+ ...provenance.serverId ? { serverId: provenance.serverId } : {}
6579
6615
  }
6580
- ],
6581
- rawOutput: response.resultDisplay,
6582
- _meta: {
6616
+ });
6617
+ } else {
6618
+ await this.toolCallEmitter.emitResult({
6619
+ callId: response.callId,
6583
6620
  toolName: request.name,
6584
- provenance: provenance.provenance,
6585
- ...provenance.serverId ? { serverId: provenance.serverId } : {}
6586
- }
6587
- });
6588
- } else {
6589
- await this.toolCallEmitter.emitResult({
6590
- callId: response.callId,
6591
- toolName: request.name,
6592
- args: request.args,
6593
- message: response.responseParts,
6594
- resultDisplay: response.resultDisplay,
6595
- error: response.error,
6596
- success: false
6597
- });
6621
+ args: request.args,
6622
+ message: response.responseParts,
6623
+ resultDisplay: response.resultDisplay,
6624
+ error: response.error,
6625
+ success: false
6626
+ });
6627
+ }
6628
+ } catch (emitError) {
6629
+ debugLogger5.debug(
6630
+ "[Session.runToolCalls] Failed to emit duplicate tool update",
6631
+ emitError
6632
+ );
6598
6633
  }
6599
6634
  queueToolResultRecord(batch.fc, {
6600
6635
  callId: response.callId,
@@ -6604,6 +6639,7 @@ ${this.pendingRecoveredAgentsNotice}
6604
6639
  metadata: {
6605
6640
  callId: response.callId,
6606
6641
  status: "error",
6642
+ executionStatus: response.executionStatus ?? "not_started",
6607
6643
  resultDisplay: response.resultDisplay,
6608
6644
  error: response.error,
6609
6645
  errorType: response.errorType
@@ -6642,10 +6678,12 @@ ${this.pendingRecoveredAgentsNotice}
6642
6678
  executableCalls.map((call) => call.name)
6643
6679
  );
6644
6680
  const planModeEntryBoundary = planModeEntryBoundaryIndex === void 0 ? void 0 : executableCalls[planModeEntryBoundaryIndex];
6645
- const appendSkippedAfter = /* @__PURE__ */ __name(async (parts2, fc, message = PERMISSION_CANCEL_SKIP_MESSAGE) => {
6681
+ const appendSkippedAfter = /* @__PURE__ */ __name(async (parts2, fc, message = PERMISSION_CANCEL_SKIP_MESSAGE, errorType) => {
6646
6682
  const startIndex = dedupedFunctionCalls.indexOf(fc) + 1;
6647
6683
  for (const remainingCall of dedupedFunctionCalls.slice(startIndex)) {
6648
- parts2.push(await recordSkippedToolCall(remainingCall, message));
6684
+ parts2.push(
6685
+ await recordSkippedToolCall(remainingCall, message, true, errorType)
6686
+ );
6649
6687
  }
6650
6688
  }, "appendSkippedAfter");
6651
6689
  const memoryWriteCandidates = [];
@@ -6675,7 +6713,12 @@ ${this.pendingRecoveredAgentsNotice}
6675
6713
  if (results[i]) continue;
6676
6714
  results[i] = {
6677
6715
  parts: [
6678
- await recordSkippedToolCall(calls[i], LOOP_DETECTED_SKIP_MESSAGE)
6716
+ await recordSkippedToolCall(
6717
+ calls[i],
6718
+ LOOP_DETECTED_SKIP_MESSAGE,
6719
+ true,
6720
+ "unknown" /* UNKNOWN */
6721
+ )
6679
6722
  ],
6680
6723
  stopAfterPermissionCancel: false,
6681
6724
  loopDetected: true
@@ -6839,7 +6882,8 @@ ${this.pendingRecoveredAgentsNotice}
6839
6882
  await appendSkippedAfter(
6840
6883
  parts,
6841
6884
  batch.calls[batch.calls.length - 1],
6842
- LOOP_DETECTED_SKIP_MESSAGE
6885
+ LOOP_DETECTED_SKIP_MESSAGE,
6886
+ "unknown" /* UNKNOWN */
6843
6887
  );
6844
6888
  return await finalizeRunToolResult({
6845
6889
  parts,
@@ -6876,7 +6920,12 @@ ${this.pendingRecoveredAgentsNotice}
6876
6920
  parts.push(...r.parts);
6877
6921
  collectMemoryWriteCandidates(r);
6878
6922
  if (r.loopDetected) {
6879
- await appendSkippedAfter(parts, fc, LOOP_DETECTED_SKIP_MESSAGE);
6923
+ await appendSkippedAfter(
6924
+ parts,
6925
+ fc,
6926
+ LOOP_DETECTED_SKIP_MESSAGE,
6927
+ "unknown" /* UNKNOWN */
6928
+ );
6880
6929
  return await finalizeRunToolResult({
6881
6930
  parts,
6882
6931
  stopAfterPermissionCancel: false,
@@ -6939,10 +6988,21 @@ ${this.pendingRecoveredAgentsNotice}
6939
6988
  async runTool(abortSignal, promptId, fc, onStopAfterPermissionCancel, toolLoopState, recordSkippedToolCall, queueToolResultRecord, generatedCallId, onFullTurnModel) {
6940
6989
  const callId = fc.id ?? generatedCallId ?? `${fc.name}-${Date.now()}`;
6941
6990
  let args = fc.args ?? {};
6991
+ let executionStatus = "not_started";
6992
+ let executionErrorType;
6993
+ let executeReturned = false;
6994
+ let terminalStatus;
6995
+ let toolType = "native";
6996
+ let mcpServerName = void 0;
6942
6997
  if (toolLoopState?.loopDetected) {
6943
6998
  return {
6944
6999
  parts: [
6945
- recordSkippedToolCall ? await recordSkippedToolCall(fc, LOOP_DETECTED_SKIP_MESSAGE, false) : {
7000
+ recordSkippedToolCall ? await recordSkippedToolCall(
7001
+ fc,
7002
+ LOOP_DETECTED_SKIP_MESSAGE,
7003
+ false,
7004
+ "unknown" /* UNKNOWN */
7005
+ ) : {
6946
7006
  functionResponse: {
6947
7007
  id: callId,
6948
7008
  name: fc.name ?? "unknown_tool",
@@ -6967,51 +7027,80 @@ ${this.pendingRecoveredAgentsNotice}
6967
7027
  removeAgentToolAbortPropagation?.();
6968
7028
  removeAgentToolAbortPropagation = void 0;
6969
7029
  }, "cleanupAgentToolResources");
6970
- const errorResponse = /* @__PURE__ */ __name((error) => {
7030
+ const errorResponse = /* @__PURE__ */ __name((error, toolName2, status, errorType) => {
6971
7031
  const durationMs = Date.now() - startTime;
6972
- logToolCall(this.config, {
6973
- "event.name": "tool_call",
6974
- "event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
6975
- prompt_id: promptId,
6976
- function_name: fc.name ?? "",
6977
- function_args: args,
6978
- duration_ms: durationMs,
6979
- // An aborted signal means the call was cancelled, not a genuine error.
6980
- status: activeToolAbortSignal.aborted ? "cancelled" : "error",
6981
- success: false,
6982
- error: error.message,
6983
- tool_type: typeof tool !== "undefined" && tool instanceof DiscoveredMCPTool ? "mcp" : "native"
6984
- });
7032
+ try {
7033
+ logToolCall(this.config, {
7034
+ "event.name": "tool_call",
7035
+ "event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7036
+ call_id: callId,
7037
+ prompt_id: promptId,
7038
+ function_name: toolName2,
7039
+ function_args: args,
7040
+ duration_ms: durationMs,
7041
+ status,
7042
+ execution_status: executionStatus,
7043
+ success: false,
7044
+ ...status === "error" ? {
7045
+ error: error.message,
7046
+ error_type: errorType
7047
+ } : {},
7048
+ tool_type: toolType,
7049
+ mcp_server_name: mcpServerName
7050
+ });
7051
+ } catch (telemetryError) {
7052
+ debugLogger5.debug(
7053
+ "[Session.runTool] Failed to record terminal tool telemetry",
7054
+ telemetryError
7055
+ );
7056
+ }
6985
7057
  return [
6986
7058
  {
6987
7059
  functionResponse: {
6988
7060
  id: callId,
6989
- name: fc.name ?? "",
7061
+ name: toolName2,
6990
7062
  response: { error: error.message }
6991
7063
  }
6992
7064
  }
6993
7065
  ];
6994
7066
  }, "errorResponse");
6995
7067
  const earlyErrorResponse = /* @__PURE__ */ __name(async (error, toolName2 = fc.name ?? "unknown_tool", opts) => {
6996
- spanError = error.message;
7068
+ executionStatus = opts.executionStatus;
7069
+ terminalStatus = opts.status;
7070
+ spanError = opts.status === "error" ? error.message : void 0;
6997
7071
  cleanupAgentToolResources();
6998
7072
  if (toolName2 !== ToolNames.TODO_WRITE) {
6999
- await this.toolCallEmitter.emitError(callId, toolName2, error);
7073
+ try {
7074
+ await this.toolCallEmitter.emitError(callId, toolName2, error);
7075
+ } catch (emitError) {
7076
+ debugLogger5.debug(
7077
+ "[Session.runTool] Failed to emit terminal tool update",
7078
+ emitError
7079
+ );
7080
+ }
7000
7081
  }
7001
- const errorParts = errorResponse(error);
7082
+ const errorParts = errorResponse(
7083
+ error,
7084
+ toolName2,
7085
+ opts.status,
7086
+ opts.errorType
7087
+ );
7002
7088
  queueToolResultRecord?.(fc, {
7003
7089
  callId,
7004
7090
  toolName: toolName2,
7005
7091
  responseParts: errorParts,
7006
7092
  metadata: {
7007
7093
  callId,
7008
- status: opts?.status ?? "error",
7094
+ status: opts.status,
7095
+ executionStatus,
7009
7096
  resultDisplay: void 0,
7010
- error,
7011
- errorType: opts?.errorType
7097
+ error: opts.status === "error" ? error : void 0,
7098
+ errorType: opts.status === "error" ? opts.errorType : void 0
7012
7099
  }
7013
7100
  });
7014
- const loopDetected = opts?.recordInvalidToolParams === true && !activeToolAbortSignal.aborted && !opts?.stopAfterPermissionCancel && recordDaemonInvalidToolParams(
7101
+ const loopDetected = opts.recordInvalidToolParams === true && !activeToolAbortSignal.aborted && // A permission cancellation is the user declining, not the model
7102
+ // re-sending invalid params, so it must not feed loop detection.
7103
+ !opts.stopAfterPermissionCancel && recordDaemonInvalidToolParams(
7015
7104
  this.config,
7016
7105
  promptId,
7017
7106
  toolLoopState,
@@ -7020,14 +7109,32 @@ ${this.pendingRecoveredAgentsNotice}
7020
7109
  );
7021
7110
  return {
7022
7111
  parts: errorParts,
7023
- stopAfterPermissionCancel: opts?.stopAfterPermissionCancel ?? false,
7112
+ stopAfterPermissionCancel: opts.stopAfterPermissionCancel ?? false,
7024
7113
  loopDetected
7025
7114
  };
7026
7115
  }, "earlyErrorResponse");
7116
+ const cancelBeforeExecutionIfAborted = /* @__PURE__ */ __name((toolName2 = fc.name ?? "unknown_tool") => activeToolAbortSignal.aborted ? earlyErrorResponse(
7117
+ new Error("Tool call was cancelled before execution."),
7118
+ toolName2,
7119
+ {
7120
+ status: "cancelled",
7121
+ errorType: void 0,
7122
+ executionStatus: "not_started"
7123
+ }
7124
+ ) : void 0, "cancelBeforeExecutionIfAborted");
7125
+ const initialCancellation = cancelBeforeExecutionIfAborted();
7126
+ if (initialCancellation) return initialCancellation;
7027
7127
  if (!fc.name) {
7028
- return earlyErrorResponse(new Error("Missing function name"), void 0, {
7029
- recordInvalidToolParams: true
7030
- });
7128
+ return earlyErrorResponse(
7129
+ new Error("Missing function name"),
7130
+ "unknown_tool",
7131
+ {
7132
+ status: "error",
7133
+ errorType: "invalid_tool_params" /* INVALID_TOOL_PARAMS */,
7134
+ executionStatus: "not_started",
7135
+ recordInvalidToolParams: true
7136
+ }
7137
+ );
7031
7138
  }
7032
7139
  const toolName = fc.name;
7033
7140
  const toolRegistry = this.config.getToolRegistry();
@@ -7036,9 +7143,16 @@ ${this.pendingRecoveredAgentsNotice}
7036
7143
  return earlyErrorResponse(
7037
7144
  new Error(`Tool "${toolName}" not found in registry.`),
7038
7145
  toolName,
7039
- { recordInvalidToolParams: true }
7146
+ {
7147
+ status: "error",
7148
+ errorType: "tool_not_registered" /* TOOL_NOT_REGISTERED */,
7149
+ executionStatus: "not_started",
7150
+ recordInvalidToolParams: true
7151
+ }
7040
7152
  );
7041
7153
  }
7154
+ toolType = tool instanceof DiscoveredMCPTool ? "mcp" : "native";
7155
+ mcpServerName = tool instanceof DiscoveredMCPTool ? tool.serverName : void 0;
7042
7156
  const policyToolName = tool.name;
7043
7157
  const originalPolicyRequestArgs = policyToolName === ToolNames.SHELL || policyToolName === ToolNames.MONITOR ? structuredClone(args) : args;
7044
7158
  const toolSpan = startToolSpan(
@@ -7055,14 +7169,23 @@ ${this.pendingRecoveredAgentsNotice}
7055
7169
  tool.description,
7056
7170
  promptId
7057
7171
  );
7058
- let spanSuccess = false;
7059
7172
  try {
7060
7173
  return await runInToolSpanContext(toolSpan, async () => {
7174
+ const entryCancellation = cancelBeforeExecutionIfAborted(toolName);
7175
+ if (entryCancellation) return entryCancellation;
7061
7176
  const pm = this.config.getPermissionManager?.();
7062
- if (pm && !await pm.isToolEnabled(policyToolName)) {
7177
+ const toolEnabled = pm ? await pm.isToolEnabled(policyToolName) : true;
7178
+ const enablementCancellation = cancelBeforeExecutionIfAborted(toolName);
7179
+ if (enablementCancellation) return enablementCancellation;
7180
+ if (pm && !toolEnabled) {
7063
7181
  return earlyErrorResponse(
7064
7182
  new Error(`Tool "${toolName}" is disabled.`),
7065
- toolName
7183
+ toolName,
7184
+ {
7185
+ status: "error",
7186
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7187
+ executionStatus: "not_started"
7188
+ }
7066
7189
  );
7067
7190
  }
7068
7191
  const isTodoWriteTool = tool.name === ToolNames.TODO_WRITE;
@@ -7124,6 +7247,8 @@ ${this.pendingRecoveredAgentsNotice}
7124
7247
  policyToolName,
7125
7248
  toolParams
7126
7249
  );
7250
+ const permissionFlowCancellation = cancelBeforeExecutionIfAborted(toolName);
7251
+ if (permissionFlowCancellation) return permissionFlowCancellation;
7127
7252
  const {
7128
7253
  finalPermission,
7129
7254
  pmForcedAsk,
@@ -7137,7 +7262,12 @@ ${this.pendingRecoveredAgentsNotice}
7137
7262
  if (finalPermission === "deny") {
7138
7263
  return earlyErrorResponse(
7139
7264
  new Error(denyMessage ?? `Tool "${toolName}" is denied.`),
7140
- toolName
7265
+ toolName,
7266
+ {
7267
+ status: "error",
7268
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7269
+ executionStatus: "not_started"
7270
+ }
7141
7271
  );
7142
7272
  }
7143
7273
  let planShellAmbientWorkingDirectory;
@@ -7159,6 +7289,8 @@ ${this.pendingRecoveredAgentsNotice}
7159
7289
  ambientWorkingDirectory: planShellAmbientWorkingDirectory,
7160
7290
  signal: activeToolAbortSignal
7161
7291
  }) : { classification: "not-applicable" };
7292
+ const planPolicyCancellation = cancelBeforeExecutionIfAborted(toolName);
7293
+ if (planPolicyCancellation) return planPolicyCancellation;
7162
7294
  if (planShellDecision.classification !== "not-applicable") {
7163
7295
  const initialPlanShellError = await validatePlanModeShellContext({
7164
7296
  config: this.config,
@@ -7167,17 +7299,31 @@ ${this.pendingRecoveredAgentsNotice}
7167
7299
  invocationParams: invocation.params,
7168
7300
  signal: activeToolAbortSignal
7169
7301
  });
7302
+ const initialPlanValidationCancellation = cancelBeforeExecutionIfAborted(toolName);
7303
+ if (initialPlanValidationCancellation) {
7304
+ return initialPlanValidationCancellation;
7305
+ }
7170
7306
  if (initialPlanShellError) {
7171
7307
  return earlyErrorResponse(
7172
7308
  new Error(initialPlanShellError),
7173
- toolName
7309
+ toolName,
7310
+ {
7311
+ status: "error",
7312
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7313
+ executionStatus: "not_started"
7314
+ }
7174
7315
  );
7175
7316
  }
7176
7317
  }
7177
7318
  if (planShellDecision.classification === "write") {
7178
7319
  return earlyErrorResponse(
7179
7320
  new Error(planShellDecision.writeBlockMessage),
7180
- toolName
7321
+ toolName,
7322
+ {
7323
+ status: "error",
7324
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7325
+ executionStatus: "not_started"
7326
+ }
7181
7327
  );
7182
7328
  }
7183
7329
  const planShellRequiresConfirmation = planShellDecision.classification === "unknown";
@@ -7212,6 +7358,8 @@ ${this.pendingRecoveredAgentsNotice}
7212
7358
  signal: abortSignal,
7213
7359
  skipClassifierReason: fallback.fallback ? fallback.reason : void 0
7214
7360
  });
7361
+ const autoModeCancellation = cancelBeforeExecutionIfAborted(toolName);
7362
+ if (autoModeCancellation) return autoModeCancellation;
7215
7363
  const outcome = applyAutoModeDecision(
7216
7364
  decision,
7217
7365
  this.config,
@@ -7226,6 +7374,10 @@ ${this.pendingRecoveredAgentsNotice}
7226
7374
  callId,
7227
7375
  abortSignal
7228
7376
  );
7377
+ const permissionDeniedHookCancellation = cancelBeforeExecutionIfAborted(toolName);
7378
+ if (permissionDeniedHookCancellation) {
7379
+ return permissionDeniedHookCancellation;
7380
+ }
7229
7381
  switch (outcome.kind) {
7230
7382
  case "approved":
7231
7383
  autoModeAllowed = true;
@@ -7236,7 +7388,12 @@ ${this.pendingRecoveredAgentsNotice}
7236
7388
  );
7237
7389
  return earlyErrorResponse(
7238
7390
  new Error(outcome.errorMessage),
7239
- toolName
7391
+ toolName,
7392
+ {
7393
+ status: "error",
7394
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7395
+ executionStatus: "not_started"
7396
+ }
7240
7397
  );
7241
7398
  case "fallback":
7242
7399
  wasAutoModeManualFallback = isDenialFallbackReason(outcome.reason) || outcome.reason === "classifier_unavailable";
@@ -7280,6 +7437,10 @@ ${this.pendingRecoveredAgentsNotice}
7280
7437
  confirmationDetails = await invocation.getConfirmationDetails(
7281
7438
  activeToolAbortSignal
7282
7439
  );
7440
+ const confirmationDetailsCancellation = cancelBeforeExecutionIfAborted(toolName);
7441
+ if (confirmationDetailsCancellation) {
7442
+ return confirmationDetailsCancellation;
7443
+ }
7283
7444
  if (autoModeFallbackMessage) {
7284
7445
  confirmationDetails = decorateClassifierUnavailableConfirmation(
7285
7446
  confirmationDetails,
@@ -7294,10 +7455,19 @@ ${this.pendingRecoveredAgentsNotice}
7294
7455
  invocationParams: invocation.params,
7295
7456
  signal: activeToolAbortSignal
7296
7457
  });
7458
+ const preDisplayValidationCancellation = cancelBeforeExecutionIfAborted(toolName);
7459
+ if (preDisplayValidationCancellation) {
7460
+ return preDisplayValidationCancellation;
7461
+ }
7297
7462
  if (preDisplayPlanShellError) {
7298
7463
  return earlyErrorResponse(
7299
7464
  new Error(preDisplayPlanShellError),
7300
- toolName
7465
+ toolName,
7466
+ {
7467
+ status: "error",
7468
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7469
+ executionStatus: "not_started"
7470
+ }
7301
7471
  );
7302
7472
  }
7303
7473
  }
@@ -7310,7 +7480,12 @@ ${this.pendingRecoveredAgentsNotice}
7310
7480
  if (planShellDecision.classification === "unknown") {
7311
7481
  return earlyErrorResponse(
7312
7482
  new Error(planShellDecision.noApprovalMessage),
7313
- toolName
7483
+ toolName,
7484
+ {
7485
+ status: "error",
7486
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7487
+ executionStatus: "not_started"
7488
+ }
7314
7489
  );
7315
7490
  }
7316
7491
  throw new Error("Unable to prepare shell confirmation.");
@@ -7327,7 +7502,12 @@ ${this.pendingRecoveredAgentsNotice}
7327
7502
  new Error(
7328
7503
  `Plan mode is active. The tool "${toolName}" cannot be executed because it modifies the system. Please use the exit_plan_mode tool to present your plan and exit plan mode before making changes.`
7329
7504
  ),
7330
- toolName
7505
+ toolName,
7506
+ {
7507
+ status: "error",
7508
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7509
+ executionStatus: "not_started"
7510
+ }
7331
7511
  );
7332
7512
  }
7333
7513
  const messageBus = this.config.getMessageBus?.();
@@ -7342,6 +7522,10 @@ ${this.pendingRecoveredAgentsNotice}
7342
7522
  void 0,
7343
7523
  activeToolAbortSignal
7344
7524
  );
7525
+ const permissionHookCancellation = cancelBeforeExecutionIfAborted(toolName);
7526
+ if (permissionHookCancellation) {
7527
+ return permissionHookCancellation;
7528
+ }
7345
7529
  if (hookResult.hasDecision && (!hookResult.shouldAllow || !requiresUserInteraction)) {
7346
7530
  hookHandled = true;
7347
7531
  if (hookResult.shouldAllow) {
@@ -7355,16 +7539,29 @@ ${this.pendingRecoveredAgentsNotice}
7355
7539
  outcome: "proceed_once" /* ProceedOnce */,
7356
7540
  payload: hookResult.updatedInput ? { updatedInput: hookResult.updatedInput } : void 0
7357
7541
  });
7542
+ const hookPlanApprovalCancellation = cancelBeforeExecutionIfAborted(toolName);
7543
+ if (hookPlanApprovalCancellation) {
7544
+ return hookPlanApprovalCancellation;
7545
+ }
7358
7546
  await confirmationDetails.onConfirm(
7359
7547
  approval.outcome,
7360
7548
  approval.payload
7361
7549
  );
7550
+ const hookPlanConfirmationCancellation = cancelBeforeExecutionIfAborted(toolName);
7551
+ if (hookPlanConfirmationCancellation) {
7552
+ return hookPlanConfirmationCancellation;
7553
+ }
7362
7554
  if (approval.outcome === "cancel" /* Cancel */) {
7363
7555
  return earlyErrorResponse(
7364
7556
  new Error(
7365
7557
  approval.payload?.cancelMessage ?? planShellDecision.noApprovalMessage
7366
7558
  ),
7367
- toolName
7559
+ toolName,
7560
+ {
7561
+ status: "error",
7562
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7563
+ executionStatus: "not_started"
7564
+ }
7368
7565
  );
7369
7566
  }
7370
7567
  recordAutoModeFallbackResolution(approval.outcome);
@@ -7376,6 +7573,10 @@ ${this.pendingRecoveredAgentsNotice}
7376
7573
  await confirmationDetails.onConfirm(
7377
7574
  "proceed_once" /* ProceedOnce */
7378
7575
  );
7576
+ const hookConfirmationCancellation = cancelBeforeExecutionIfAborted(toolName);
7577
+ if (hookConfirmationCancellation) {
7578
+ return hookConfirmationCancellation;
7579
+ }
7379
7580
  recordAutoModeFallbackResolution(
7380
7581
  "proceed_once" /* ProceedOnce */
7381
7582
  );
@@ -7385,7 +7586,12 @@ ${this.pendingRecoveredAgentsNotice}
7385
7586
  new Error(
7386
7587
  hookResult.denyMessage || `Permission denied by hook for "${toolName}"`
7387
7588
  ),
7388
- toolName
7589
+ toolName,
7590
+ {
7591
+ status: "error",
7592
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7593
+ executionStatus: "not_started"
7594
+ }
7389
7595
  );
7390
7596
  }
7391
7597
  }
@@ -7400,10 +7606,19 @@ ${this.pendingRecoveredAgentsNotice}
7400
7606
  invocationParams: invocation.params,
7401
7607
  signal: activeToolAbortSignal
7402
7608
  });
7609
+ const finalPlanValidationCancellation = cancelBeforeExecutionIfAborted(toolName);
7610
+ if (finalPlanValidationCancellation) {
7611
+ return finalPlanValidationCancellation;
7612
+ }
7403
7613
  if (finalPreDisplayPlanShellError) {
7404
7614
  return earlyErrorResponse(
7405
7615
  new Error(finalPreDisplayPlanShellError),
7406
- toolName
7616
+ toolName,
7617
+ {
7618
+ status: "error",
7619
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7620
+ executionStatus: "not_started"
7621
+ }
7407
7622
  );
7408
7623
  }
7409
7624
  }
@@ -7456,7 +7671,12 @@ ${this.pendingRecoveredAgentsNotice}
7456
7671
  message ?? `Tool "${toolName}" was canceled by the user.`
7457
7672
  ),
7458
7673
  toolName,
7459
- { stopAfterPermissionCancel: true }
7674
+ {
7675
+ status: "cancelled",
7676
+ errorType: void 0,
7677
+ executionStatus: "not_started",
7678
+ stopAfterPermissionCancel: true
7679
+ }
7460
7680
  );
7461
7681
  }, "stopAfterPermissionCancel");
7462
7682
  let output;
@@ -7466,6 +7686,10 @@ ${this.pendingRecoveredAgentsNotice}
7466
7686
  params,
7467
7687
  activeToolAbortSignal
7468
7688
  );
7689
+ const permissionRequestCancellation = cancelBeforeExecutionIfAborted(toolName);
7690
+ if (permissionRequestCancellation) {
7691
+ return permissionRequestCancellation;
7692
+ }
7469
7693
  outcome = resolvePermissionOutcome(
7470
7694
  output,
7471
7695
  offeredPermissionOptions
@@ -7485,16 +7709,26 @@ ${this.pendingRecoveredAgentsNotice}
7485
7709
  confirmError
7486
7710
  );
7487
7711
  }
7488
- onStopAfterPermissionCancel?.();
7712
+ const wasAborted = activeToolAbortSignal.aborted;
7713
+ if (!wasAborted) {
7714
+ onStopAfterPermissionCancel?.();
7715
+ }
7489
7716
  const permissionFailureMessage = isExitPlanModeTool ? "The host could not present plan-exit approval. Plan mode remains active; use the host mode selector or /plan exit to leave plan mode." : planShellDecision.classification === "unknown" ? `Plan mode could not complete approval for this shell command: ${this.#formatError(
7490
7717
  error
7491
7718
  )}. The command was not run; Plan mode remains active.` : `Permission request failed for "${toolName}": ${this.#formatError(
7492
7719
  error
7493
7720
  )}`;
7494
7721
  return earlyErrorResponse(
7495
- new Error(permissionFailureMessage),
7722
+ new Error(
7723
+ wasAborted ? "Tool call was cancelled before execution." : permissionFailureMessage
7724
+ ),
7496
7725
  toolName,
7497
- { stopAfterPermissionCancel: true }
7726
+ {
7727
+ status: wasAborted ? "cancelled" : "error",
7728
+ errorType: wasAborted ? void 0 : "unhandled_exception" /* UNHANDLED_EXCEPTION */,
7729
+ executionStatus: "not_started",
7730
+ stopAfterPermissionCancel: !wasAborted
7731
+ }
7498
7732
  );
7499
7733
  }
7500
7734
  let confirmationPayload = {
@@ -7510,6 +7744,10 @@ ${this.pendingRecoveredAgentsNotice}
7510
7744
  outcome,
7511
7745
  payload: confirmationPayload
7512
7746
  });
7747
+ const planApprovalCancellation = cancelBeforeExecutionIfAborted(toolName);
7748
+ if (planApprovalCancellation) {
7749
+ return planApprovalCancellation;
7750
+ }
7513
7751
  outcome = approval.outcome;
7514
7752
  confirmationPayload = approval.payload;
7515
7753
  }
@@ -7523,6 +7761,10 @@ ${this.pendingRecoveredAgentsNotice}
7523
7761
  outcome,
7524
7762
  confirmationPayload
7525
7763
  );
7764
+ const confirmationCancellation = cancelBeforeExecutionIfAborted(toolName);
7765
+ if (confirmationCancellation) {
7766
+ return confirmationCancellation;
7767
+ }
7526
7768
  } catch (error) {
7527
7769
  if (outcome !== "cancel" /* Cancel */) {
7528
7770
  throw error;
@@ -7536,6 +7778,8 @@ ${this.pendingRecoveredAgentsNotice}
7536
7778
  if (shouldSwitchToDefault) {
7537
7779
  this.config.setApprovalMode("default" /* DEFAULT */);
7538
7780
  await this.sendCurrentModeUpdateNotification();
7781
+ const modeUpdateCancellation = cancelBeforeExecutionIfAborted(toolName);
7782
+ if (modeUpdateCancellation) return modeUpdateCancellation;
7539
7783
  }
7540
7784
  if (outcome === "proceed_always" /* ProceedAlways */ || outcome === "proceed_always_project" /* ProceedAlwaysProject */ || outcome === "proceed_always_user" /* ProceedAlwaysUser */) {
7541
7785
  await persistPermissionOutcome(
@@ -7545,9 +7789,17 @@ ${this.pendingRecoveredAgentsNotice}
7545
7789
  this.config.getPermissionManager?.(),
7546
7790
  confirmationPayload
7547
7791
  );
7792
+ const permissionPersistenceCancellation = cancelBeforeExecutionIfAborted(toolName);
7793
+ if (permissionPersistenceCancellation) {
7794
+ return permissionPersistenceCancellation;
7795
+ }
7548
7796
  }
7549
7797
  if (confirmationDetails.type === "edit" && outcome === "proceed_always" /* ProceedAlways */) {
7550
7798
  await this.sendCurrentModeUpdateNotification();
7799
+ const editModeUpdateCancellation = cancelBeforeExecutionIfAborted(toolName);
7800
+ if (editModeUpdateCancellation) {
7801
+ return editModeUpdateCancellation;
7802
+ }
7551
7803
  }
7552
7804
  switch (outcome) {
7553
7805
  case "proceed_once_and_switch_to_default" /* ProceedOnceAndSwitchToDefault */:
@@ -7581,7 +7833,16 @@ ${this.pendingRecoveredAgentsNotice}
7581
7833
  args,
7582
7834
  status: "in_progress"
7583
7835
  };
7584
- await this.toolCallEmitter.emitStart(startParams);
7836
+ try {
7837
+ await this.toolCallEmitter.emitStart(startParams);
7838
+ } catch (emitError) {
7839
+ debugLogger5.debug(
7840
+ "[Session.runTool] Failed to emit tool start update",
7841
+ emitError
7842
+ );
7843
+ }
7844
+ const startEmissionCancellation = cancelBeforeExecutionIfAborted(toolName);
7845
+ if (startEmissionCancellation) return startEmissionCancellation;
7585
7846
  }
7586
7847
  const hooksEnabledForTool = !this.config.getDisableAllHooks?.();
7587
7848
  const messageBusForTool = this.config.getMessageBus?.();
@@ -7596,12 +7857,27 @@ ${this.pendingRecoveredAgentsNotice}
7596
7857
  activeToolAbortSignal,
7597
7858
  callId
7598
7859
  );
7860
+ const preHookCancellation = cancelBeforeExecutionIfAborted(toolName);
7861
+ if (preHookCancellation) return preHookCancellation;
7599
7862
  if (!preHookResult.shouldProceed) {
7600
7863
  const blockReason = preHookResult.blockReason || "Blocked by PreToolUse hook";
7601
- await this.messageEmitter.emitAgentMessage(
7602
- `\u2717 **PreToolUse blocked**: ${toolName} - ${blockReason}`
7603
- );
7604
- return earlyErrorResponse(new Error(blockReason), toolName);
7864
+ try {
7865
+ await this.messageEmitter.emitAgentMessage(
7866
+ `\u2717 **PreToolUse blocked**: ${toolName} - ${blockReason}`
7867
+ );
7868
+ } catch (emitError) {
7869
+ debugLogger5.debug(
7870
+ "[Session.runTool] Failed to emit PreToolUse block message",
7871
+ emitError
7872
+ );
7873
+ }
7874
+ const blockMessageCancellation = cancelBeforeExecutionIfAborted(toolName);
7875
+ if (blockMessageCancellation) return blockMessageCancellation;
7876
+ return earlyErrorResponse(new Error(blockReason), toolName, {
7877
+ status: "error",
7878
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7879
+ executionStatus: "not_started"
7880
+ });
7605
7881
  }
7606
7882
  if (preHookResult.additionalContext) {
7607
7883
  debugLogger5.debug(
@@ -7624,17 +7900,29 @@ ${this.pendingRecoveredAgentsNotice}
7624
7900
  return earlyErrorResponse(
7625
7901
  new Error("Tool invocation was cancelled"),
7626
7902
  toolName,
7627
- { status: "cancelled" }
7903
+ {
7904
+ status: "cancelled",
7905
+ errorType: void 0,
7906
+ executionStatus: "not_started"
7907
+ }
7628
7908
  );
7629
7909
  }
7630
7910
  if (!guardDecision.allowed) {
7631
7911
  return earlyErrorResponse(
7632
7912
  new Error(guardDecision.reason),
7633
7913
  toolName,
7634
- { errorType: "execution_denied" /* EXECUTION_DENIED */ }
7914
+ {
7915
+ status: "error",
7916
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
7917
+ executionStatus: "not_started"
7918
+ }
7635
7919
  );
7636
7920
  }
7637
7921
  }
7922
+ const executionBoundaryCancellation = cancelBeforeExecutionIfAborted(toolName);
7923
+ if (executionBoundaryCancellation) {
7924
+ return executionBoundaryCancellation;
7925
+ }
7638
7926
  const continuedAgentId = toolName === ToolNames.SEND_MESSAGE && typeof args["task_id"] === "string" && args["task_id"].length > 0 ? args["task_id"] : void 0;
7639
7927
  const provisionalRelatedAgent = continuedAgentId !== void 0 && !this.relatedAgentIds.has(continuedAgentId);
7640
7928
  if (provisionalRelatedAgent) {
@@ -7662,9 +7950,9 @@ ${this.pendingRecoveredAgentsNotice}
7662
7950
  this.relatedAgentIds.add(continuedAgentId);
7663
7951
  }
7664
7952
  }, "settleRelatedAgent");
7665
- const execSpan = startToolExecutionSpan();
7666
7953
  let toolResult;
7667
7954
  let isExecutionTimeout = false;
7955
+ let parentAbortedAtExecutionSettle = false;
7668
7956
  let aborted = false;
7669
7957
  let toolSettled = false;
7670
7958
  let heartbeatCount = 0;
@@ -7694,49 +7982,66 @@ ${this.pendingRecoveredAgentsNotice}
7694
7982
  }
7695
7983
  }
7696
7984
  } : void 0, "heartbeatSpanAttributes");
7985
+ const sleepInhibitorHandle = acquireSleepInhibitor(
7986
+ this.config,
7987
+ `Qwen Code is executing tool ${toolName}`
7988
+ );
7697
7989
  try {
7698
- const sleepInhibitorHandle = acquireSleepInhibitor(
7699
- this.config,
7700
- `Qwen Code is executing tool ${toolName}`
7701
- );
7702
7990
  try {
7703
- try {
7704
- addToolArgumentsAttributes(
7705
- this.config,
7706
- toolSpan,
7707
- invocation.params
7708
- );
7709
- } catch {
7710
- debugLogger5.debug(
7711
- "[Session.runTool] Failed to record tool arguments telemetry"
7712
- );
7713
- }
7991
+ addToolArgumentsAttributes(
7992
+ this.config,
7993
+ toolSpan,
7994
+ invocation.params
7995
+ );
7996
+ } catch {
7997
+ debugLogger5.debug(
7998
+ "[Session.runTool] Failed to record tool arguments telemetry"
7999
+ );
8000
+ }
8001
+ const execSpan = startToolExecutionSpan({
8002
+ toolName: policyToolName,
8003
+ callId
8004
+ });
8005
+ executionStatus = "error";
8006
+ try {
7714
8007
  toolResult = await invocation.execute(
7715
8008
  activeToolAbortSignal,
7716
8009
  onToolProgress
7717
8010
  );
7718
- } finally {
7719
- toolSettled = true;
7720
- sleepInhibitorHandle.release();
8011
+ executeReturned = true;
8012
+ parentAbortedAtExecutionSettle = activeToolAbortSignal.aborted;
8013
+ isExecutionTimeout = toolResult.error?.type === "execution_timeout" /* EXECUTION_TIMEOUT */;
8014
+ aborted = parentAbortedAtExecutionSettle && !isExecutionTimeout;
8015
+ executionStatus = aborted ? "cancelled" : toolResult.error ? "error" : "success";
8016
+ executionErrorType = toolResult.error ? toolResult.error.type ?? (toolType === "mcp" ? "mcp_tool_error" /* MCP_TOOL_ERROR */ : "unknown" /* UNKNOWN */) : void 0;
8017
+ settleRelatedAgent(executionStatus === "success");
8018
+ endToolExecutionSpan(execSpan, {
8019
+ success: executionStatus === "success",
8020
+ error: aborted ? "tool_cancelled" : isExecutionTimeout ? "tool_timeout" : toolResult.error ? "tool_error" : void 0,
8021
+ cancelled: aborted,
8022
+ executionStatus,
8023
+ errorType: executionErrorType,
8024
+ ...heartbeatSpanAttributes()
8025
+ });
8026
+ } catch (execError) {
8027
+ const explicitErrorType = execError?.errorType;
8028
+ const executionTimedOut = explicitErrorType === "execution_timeout" /* EXECUTION_TIMEOUT */;
8029
+ executionStatus = activeToolAbortSignal.aborted && !executionTimedOut ? "cancelled" : "error";
8030
+ executionErrorType = executionStatus === "error" ? explicitErrorType ?? (toolType === "mcp" ? "mcp_tool_error" /* MCP_TOOL_ERROR */ : "unhandled_exception" /* UNHANDLED_EXCEPTION */) : void 0;
8031
+ settleRelatedAgent(false);
8032
+ endToolExecutionSpan(execSpan, {
8033
+ success: false,
8034
+ error: executionStatus === "cancelled" ? "tool_cancelled" : executionTimedOut ? "tool_timeout" : "tool_exception",
8035
+ cancelled: executionStatus === "cancelled",
8036
+ executionStatus,
8037
+ errorType: executionErrorType,
8038
+ ...heartbeatSpanAttributes()
8039
+ });
8040
+ throw execError;
7721
8041
  }
7722
- isExecutionTimeout = toolResult.error?.type === "execution_timeout" /* EXECUTION_TIMEOUT */;
7723
- aborted = activeToolAbortSignal.aborted && !isExecutionTimeout;
7724
- settleRelatedAgent(!toolResult.error && !aborted);
7725
- endToolExecutionSpan(execSpan, {
7726
- success: !toolResult.error && !aborted,
7727
- error: aborted ? "tool_cancelled" : isExecutionTimeout ? "tool_timeout" : toolResult.error ? "tool_error" : void 0,
7728
- cancelled: aborted,
7729
- ...heartbeatSpanAttributes()
7730
- });
7731
- } catch (execError) {
7732
- settleRelatedAgent(false);
7733
- endToolExecutionSpan(execSpan, {
7734
- success: false,
7735
- error: activeToolAbortSignal.aborted ? "tool_cancelled" : "tool_exception",
7736
- cancelled: activeToolAbortSignal.aborted,
7737
- ...heartbeatSpanAttributes()
7738
- });
7739
- throw execError;
8042
+ } finally {
8043
+ toolSettled = true;
8044
+ sleepInhibitorHandle.release();
7740
8045
  }
7741
8046
  cleanupAgentToolResources();
7742
8047
  if ((isEnterPlanModeTool || isExitPlanModeTool) && !toolResult.error && this.config.getApprovalMode() !== approvalMode) {
@@ -7745,7 +8050,12 @@ ${this.pendingRecoveredAgentsNotice}
7745
8050
  this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
7746
8051
  }
7747
8052
  }
7748
- let responseParts = toolResult.error ? convertToFunctionErrorResponse(
8053
+ let responseParts = aborted ? convertToFunctionErrorResponse(
8054
+ toolName,
8055
+ callId,
8056
+ TOOL_EXECUTION_CANCELLED_MESSAGE,
8057
+ TOOL_EXECUTION_CANCELLED_MESSAGE
8058
+ ) : toolResult.error ? convertToFunctionErrorResponse(
7749
8059
  toolName,
7750
8060
  callId,
7751
8061
  toolResult.llmContent,
@@ -7755,9 +8065,7 @@ ${this.pendingRecoveredAgentsNotice}
7755
8065
  callId,
7756
8066
  toolResult.llmContent
7757
8067
  );
7758
- const status = aborted ? "cancelled" : toolResult.error ? "error" : "success";
7759
- const succeeded = status === "success";
7760
- const responseError = toolResult.error ? new Error(toolResult.error.message) : aborted ? new Error("Tool execution was cancelled") : void 0;
8068
+ let status = aborted ? "cancelled" : toolResult.error ? "error" : "success";
7761
8069
  if (isTrustedTodoWriteTool && !toolResult.error) {
7762
8070
  this.todoStopGuard.observeTodoWrite(
7763
8071
  toolResult.returnDisplay,
@@ -7780,13 +8088,28 @@ ${this.pendingRecoveredAgentsNotice}
7780
8088
  activeToolAbortSignal,
7781
8089
  callId
7782
8090
  );
8091
+ if (activeToolAbortSignal.aborted) {
8092
+ return earlyErrorResponse(
8093
+ new Error(TOOL_POST_EXECUTION_CANCELLED_MESSAGE),
8094
+ toolName,
8095
+ {
8096
+ status: "cancelled",
8097
+ errorType: void 0,
8098
+ executionStatus
8099
+ }
8100
+ );
8101
+ }
7783
8102
  if (postHookResult.shouldStop) {
7784
8103
  const stopMessage = postHookResult.stopReason || "Execution stopped by PostToolUse hook";
7785
8104
  debugLogger5.info(
7786
8105
  `PostToolUse hook requested stop for ${toolName}: ${stopMessage}`
7787
8106
  );
7788
8107
  this.todoStopGuard.suspend();
7789
- return earlyErrorResponse(new Error(stopMessage), toolName);
8108
+ return earlyErrorResponse(new Error(stopMessage), toolName, {
8109
+ status: "error",
8110
+ errorType: "execution_denied" /* EXECUTION_DENIED */,
8111
+ executionStatus
8112
+ });
7790
8113
  }
7791
8114
  if (postHookResult.additionalContext) {
7792
8115
  const contextPart = { text: postHookResult.additionalContext };
@@ -7800,28 +8123,35 @@ ${this.pendingRecoveredAgentsNotice}
7800
8123
  });
7801
8124
  } else if (hooksEnabledForTool && messageBusForTool && (toolResult.error || aborted)) {
7802
8125
  const isInterrupt = aborted;
7803
- const failureHookResult = await firePostToolUseFailureHook(
7804
- messageBusForTool,
7805
- toolUseId,
7806
- policyToolName,
7807
- args,
7808
- toolResult.error?.message ?? "Tool execution was cancelled",
7809
- isInterrupt,
7810
- permissionMode,
7811
- activeToolAbortSignal,
7812
- callId
7813
- );
7814
- if (failureHookResult.additionalContext) {
8126
+ try {
8127
+ const failureHookResult = await firePostToolUseFailureHook(
8128
+ messageBusForTool,
8129
+ toolUseId,
8130
+ policyToolName,
8131
+ args,
8132
+ toolResult.error?.message ?? TOOL_EXECUTION_CANCELLED_MESSAGE,
8133
+ isInterrupt,
8134
+ permissionMode,
8135
+ activeToolAbortSignal,
8136
+ callId
8137
+ );
8138
+ if (failureHookResult.additionalContext) {
8139
+ debugLogger5.debug(
8140
+ `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
8141
+ );
8142
+ }
8143
+ await this.emitHookArtifactsNotification({
8144
+ hookEventName: "PostToolUseFailure",
8145
+ toolName,
8146
+ toolCallId: callId,
8147
+ artifacts: failureHookResult.artifacts
8148
+ });
8149
+ } catch (hookError) {
7815
8150
  debugLogger5.debug(
7816
- `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
8151
+ "[Session.runTool] PostToolUseFailure hook failed",
8152
+ hookError
7817
8153
  );
7818
8154
  }
7819
- await this.emitHookArtifactsNotification({
7820
- hookEventName: "PostToolUseFailure",
7821
- toolName,
7822
- toolCallId: callId,
7823
- artifacts: failureHookResult.artifacts
7824
- });
7825
8155
  }
7826
8156
  const visionBridgeNotices = [];
7827
8157
  responseParts = await bridgeToolResultImages({
@@ -7833,7 +8163,29 @@ ${this.pendingRecoveredAgentsNotice}
7833
8163
  });
7834
8164
  const visionBridgeNotice = visionBridgeNotices.length > 0 ? visionBridgeNotices.join("\n") : void 0;
7835
8165
  if (visionBridgeNotice) {
7836
- await this.messageEmitter.emitAgentMessage(visionBridgeNotice);
8166
+ try {
8167
+ await this.messageEmitter.emitAgentMessage(visionBridgeNotice);
8168
+ } catch (emitError) {
8169
+ debugLogger5.debug(
8170
+ "[Session.runTool] Failed to emit vision bridge notice",
8171
+ emitError
8172
+ );
8173
+ }
8174
+ }
8175
+ if (activeToolAbortSignal.aborted && !(isExecutionTimeout && parentAbortedAtExecutionSettle)) {
8176
+ status = "cancelled";
8177
+ responseParts = convertToFunctionErrorResponse(
8178
+ toolName,
8179
+ callId,
8180
+ TOOL_POST_EXECUTION_CANCELLED_MESSAGE,
8181
+ TOOL_POST_EXECUTION_CANCELLED_MESSAGE
8182
+ );
8183
+ }
8184
+ terminalStatus = status;
8185
+ const succeeded = status === "success";
8186
+ const responseError = status === "error" && toolResult.error ? new Error(toolResult.error.message) : status === "cancelled" ? new Error(TOOL_POST_EXECUTION_CANCELLED_MESSAGE) : void 0;
8187
+ if (isTrustedTodoWriteTool && status === "cancelled") {
8188
+ this.todoStopGuard.suspend();
7837
8189
  }
7838
8190
  if (isTodoWriteTool) {
7839
8191
  const plan = this.planEmitter.extractPlan(
@@ -7841,34 +8193,60 @@ ${this.pendingRecoveredAgentsNotice}
7841
8193
  succeeded ? args : void 0
7842
8194
  );
7843
8195
  if (plan && (plan.todos.length > 0 || Array.isArray(args["todos"]))) {
7844
- await this.planEmitter.emitPlan(plan, callId);
8196
+ try {
8197
+ await this.planEmitter.emitPlan(plan, callId);
8198
+ } catch (emitError) {
8199
+ debugLogger5.debug(
8200
+ "[Session.runTool] Failed to emit plan update",
8201
+ emitError
8202
+ );
8203
+ }
7845
8204
  }
7846
8205
  } else if (!isTodoWriteTool) {
7847
- await this.toolCallEmitter.emitResult({
7848
- callId,
7849
- toolName,
7850
- args,
7851
- message: responseParts,
7852
- resultDisplay: toolResult.returnDisplay,
7853
- error: responseError,
8206
+ try {
8207
+ await this.toolCallEmitter.emitResult({
8208
+ callId,
8209
+ toolName,
8210
+ args,
8211
+ message: responseParts,
8212
+ resultDisplay: toolResult.returnDisplay,
8213
+ error: responseError,
8214
+ success: succeeded,
8215
+ artifacts: toolResult.artifacts
8216
+ });
8217
+ } catch (emitError) {
8218
+ debugLogger5.debug(
8219
+ "[Session.runTool] Failed to emit terminal tool update",
8220
+ emitError
8221
+ );
8222
+ }
8223
+ }
8224
+ const durationMs = Date.now() - startTime;
8225
+ try {
8226
+ logToolCall(this.config, {
8227
+ "event.name": "tool_call",
8228
+ "event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
8229
+ call_id: callId,
8230
+ function_name: toolName,
8231
+ function_args: args,
8232
+ duration_ms: durationMs,
8233
+ status,
8234
+ execution_status: executionStatus,
7854
8235
  success: succeeded,
7855
- artifacts: toolResult.artifacts
8236
+ ...status === "error" ? {
8237
+ error: toolResult.error?.message,
8238
+ error_type: executionErrorType
8239
+ } : {},
8240
+ prompt_id: promptId,
8241
+ tool_type: toolType,
8242
+ mcp_server_name: mcpServerName
7856
8243
  });
8244
+ } catch (telemetryError) {
8245
+ debugLogger5.debug(
8246
+ "[Session.runTool] Failed to record terminal tool telemetry",
8247
+ telemetryError
8248
+ );
7857
8249
  }
7858
- const durationMs = Date.now() - startTime;
7859
- logToolCall(this.config, {
7860
- "event.name": "tool_call",
7861
- "event.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7862
- function_name: toolName,
7863
- function_args: args,
7864
- duration_ms: durationMs,
7865
- status,
7866
- success: succeeded,
7867
- error: toolResult.error?.message,
7868
- error_type: toolResult.error?.type,
7869
- prompt_id: promptId,
7870
- tool_type: typeof tool !== "undefined" && tool instanceof DiscoveredMCPTool ? "mcp" : "native"
7871
- });
7872
8250
  queueToolResultRecord?.(fc, {
7873
8251
  callId,
7874
8252
  toolName,
@@ -7877,13 +8255,13 @@ ${this.pendingRecoveredAgentsNotice}
7877
8255
  metadata: {
7878
8256
  callId,
7879
8257
  status,
8258
+ executionStatus,
7880
8259
  resultDisplay: toolResult.returnDisplay,
7881
8260
  ...visionBridgeNotice !== void 0 ? { visionBridgeNotice } : {},
7882
- error: toolResult.error ? new Error(toolResult.error.message) : void 0,
7883
- errorType: toolResult.error?.type
8261
+ error: status === "error" && toolResult.error ? new Error(toolResult.error.message) : void 0,
8262
+ errorType: status === "error" ? executionErrorType : void 0
7884
8263
  }
7885
8264
  });
7886
- spanSuccess = succeeded;
7887
8265
  if (succeeded && !nestedPermissionCancelled) {
7888
8266
  const result = responseParts.find(
7889
8267
  (part) => part.functionResponse !== void 0
@@ -7898,10 +8276,8 @@ ${this.pendingRecoveredAgentsNotice}
7898
8276
  }
7899
8277
  }
7900
8278
  }
7901
- if (toolResult.error) {
8279
+ if (status === "error" && toolResult.error) {
7902
8280
  spanError = toolResult.error.message;
7903
- } else if (aborted) {
7904
- spanError = "Tool execution was cancelled";
7905
8281
  }
7906
8282
  return {
7907
8283
  parts: responseParts,
@@ -7915,66 +8291,74 @@ ${this.pendingRecoveredAgentsNotice}
7915
8291
  ] : void 0
7916
8292
  };
7917
8293
  } catch (e) {
7918
- cleanupAgentToolResources();
7919
8294
  const error = e instanceof Error ? e : new Error(String(e));
7920
- spanError = error.message;
7921
8295
  const hooksEnabledForError = !this.config.getDisableAllHooks?.();
7922
8296
  const messageBusForError = this.config.getMessageBus?.();
7923
- const isInterrupt = activeToolAbortSignal.aborted;
8297
+ const executionTimeoutException = !executeReturned && executionErrorType === "execution_timeout" /* EXECUTION_TIMEOUT */;
8298
+ let status = executionStatus === "cancelled" || activeToolAbortSignal.aborted && !executionTimeoutException ? "cancelled" : "error";
8299
+ const isInterrupt = status === "cancelled";
7924
8300
  if (hooksEnabledForError && messageBusForError) {
7925
- const failureHookResult = await firePostToolUseFailureHook(
7926
- messageBusForError,
7927
- toolUseId,
7928
- policyToolName,
7929
- args,
7930
- error.message,
7931
- isInterrupt,
7932
- String(approvalMode),
7933
- activeToolAbortSignal,
7934
- callId
7935
- );
7936
- if (failureHookResult.additionalContext) {
8301
+ try {
8302
+ const failureHookResult = await firePostToolUseFailureHook(
8303
+ messageBusForError,
8304
+ toolUseId,
8305
+ policyToolName,
8306
+ args,
8307
+ error.message,
8308
+ isInterrupt,
8309
+ String(approvalMode),
8310
+ activeToolAbortSignal,
8311
+ callId
8312
+ );
8313
+ if (failureHookResult.additionalContext) {
8314
+ debugLogger5.debug(
8315
+ `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
8316
+ );
8317
+ }
8318
+ await this.emitHookArtifactsNotification({
8319
+ hookEventName: "PostToolUseFailure",
8320
+ toolName,
8321
+ toolCallId: callId,
8322
+ artifacts: failureHookResult.artifacts
8323
+ });
8324
+ } catch (hookError) {
7937
8325
  debugLogger5.debug(
7938
- `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
8326
+ "[Session.runTool] PostToolUseFailure hook failed",
8327
+ hookError
7939
8328
  );
7940
8329
  }
7941
- await this.emitHookArtifactsNotification({
7942
- hookEventName: "PostToolUseFailure",
7943
- toolName,
7944
- toolCallId: callId,
7945
- artifacts: failureHookResult.artifacts
7946
- });
7947
8330
  }
7948
- await this.toolCallEmitter.emitError(callId, toolName, error);
7949
- const loopDetected = !activeToolAbortSignal.aborted && !toolBuildSucceeded && recordDaemonInvalidToolParams(
7950
- this.config,
7951
- promptId,
7952
- toolLoopState,
7953
- toolName,
7954
- error
7955
- );
7956
- const responseParts = errorResponse(error);
7957
- queueToolResultRecord?.(fc, {
7958
- callId,
7959
- toolName,
7960
- responseParts,
7961
- metadata: {
7962
- callId,
7963
- status: activeToolAbortSignal.aborted ? "cancelled" : "error",
7964
- resultDisplay: void 0,
7965
- error,
7966
- errorType: void 0
7967
- }
8331
+ if (activeToolAbortSignal.aborted && !executionTimeoutException) {
8332
+ status = "cancelled";
8333
+ }
8334
+ const explicitErrorType = e?.errorType;
8335
+ const errorType = status === "cancelled" ? void 0 : explicitErrorType ?? (executeReturned ? "unhandled_exception" /* UNHANDLED_EXCEPTION */ : executionErrorType ?? (!toolBuildSucceeded ? "invalid_tool_params" /* INVALID_TOOL_PARAMS */ : "unhandled_exception" /* UNHANDLED_EXCEPTION */));
8336
+ return earlyErrorResponse(error, toolName, {
8337
+ status,
8338
+ errorType,
8339
+ executionStatus,
8340
+ recordInvalidToolParams: !toolBuildSucceeded,
8341
+ stopAfterPermissionCancel: nestedPermissionCancelled
7968
8342
  });
7969
- return {
7970
- parts: responseParts,
7971
- stopAfterPermissionCancel: nestedPermissionCancelled,
7972
- loopDetected
7973
- };
7974
8343
  }
7975
8344
  });
8345
+ } catch (e) {
8346
+ const error = e instanceof Error ? e : new Error(String(e));
8347
+ const status = activeToolAbortSignal.aborted ? "cancelled" : "error";
8348
+ return await earlyErrorResponse(error, toolName, {
8349
+ status,
8350
+ errorType: status === "error" ? "unhandled_exception" /* UNHANDLED_EXCEPTION */ : void 0,
8351
+ executionStatus
8352
+ });
7976
8353
  } finally {
7977
- endToolSpan(toolSpan, { success: spanSuccess, error: spanError });
8354
+ if (terminalStatus === "cancelled") {
8355
+ endToolSpan(toolSpan, { success: false, cancelled: true });
8356
+ } else {
8357
+ endToolSpan(toolSpan, {
8358
+ success: terminalStatus === "success",
8359
+ error: spanError
8360
+ });
8361
+ }
7978
8362
  }
7979
8363
  }
7980
8364
  #emitGoalStatusItems(result) {
@@ -11528,7 +11912,7 @@ var QwenAgent = class {
11528
11912
  }
11529
11913
  this.clientCapabilities = args.clientCapabilities;
11530
11914
  const authMethods = buildAuthMethods();
11531
- const version = "0.21.4";
11915
+ const version = "0.21.5";
11532
11916
  const response = {
11533
11917
  protocolVersion: PROTOCOL_VERSION,
11534
11918
  agentInfo: {