@qwen-code/qwen-code 0.21.4 → 0.21.5-nightly.20260805.32e274157

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 (260) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +8 -7
  2. package/bundled/qc-helper/docs/configuration/settings.md +16 -16
  3. package/bundled/qc-helper/docs/features/code-review.md +4 -0
  4. package/bundled/qc-helper/docs/features/headless.md +31 -0
  5. package/bundled/qc-helper/docs/features/mcp.md +11 -3
  6. package/bundled/qc-helper/docs/qwen-serve.md +75 -0
  7. package/bundled/review/SKILL.md +90 -52
  8. package/chunks/{MaxSizedBox-5XDFQHTQ.js → MaxSizedBox-H44SGRP7.js} +17 -16
  9. package/chunks/{StandaloneSessionPicker-DLADA54K.js → StandaloneSessionPicker-T5FQMYD3.js} +31 -30
  10. package/chunks/{acpAgent-MVEFZSBS.js → acpAgent-J474KXVM.js} +849 -313
  11. package/chunks/{agent-RB6LCRZX.js → agent-SC23IV5L.js} +17 -16
  12. package/chunks/{agent-headless-272ZACJV.js → agent-headless-2CHR5WJP.js} +17 -16
  13. package/chunks/{artifact-tool-TBOYEKTY.js → artifact-tool-RROCCJDA.js} +1 -1
  14. package/chunks/{askUserQuestion-23Y5WZFJ.js → askUserQuestion-2EPPBPUZ.js} +1 -1
  15. package/chunks/{bridge-GXUXFSHK.js → bridge-BLHYPCCR.js} +21 -19
  16. package/chunks/{channel-settings-store-5UA2SABE.js → channel-settings-store-CDOZ7GCP.js} +22 -21
  17. package/chunks/{channel-worker-group-NDG4WOOZ.js → channel-worker-group-SVGPDH2C.js} +3 -2
  18. package/chunks/{channel-worker-manager-ZCW6UW34.js → channel-worker-manager-72ZK2GTS.js} +3 -2
  19. package/chunks/{channel-worker-supervisor-ATGFTZRN.js → channel-worker-supervisor-NUEDVHX4.js} +2 -1
  20. package/chunks/{chunk-PWCQRLM5.js → chunk-2AGOQ7QO.js} +1 -1
  21. package/chunks/{chunk-AFJSRJTO.js → chunk-2B6FBVWE.js} +1 -1
  22. package/chunks/{chunk-XPAY4EMH.js → chunk-2OSE7Q5O.js} +3 -3
  23. package/chunks/{chunk-DHNFB7NC.js → chunk-2QOLRESU.js} +5 -5
  24. package/chunks/{chunk-UWSXFI6E.js → chunk-2U7GPHA6.js} +6 -2
  25. package/chunks/{chunk-CIUUYB23.js → chunk-3DTM3RPU.js} +1 -1
  26. package/chunks/{chunk-X6QNZOTC.js → chunk-3PRJYMXC.js} +2 -2
  27. package/chunks/{chunk-6KQUOXT5.js → chunk-3XDH6PZM.js} +7 -7
  28. package/chunks/{chunk-DJA7YBLJ.js → chunk-56MC5OM7.js} +2 -2
  29. package/chunks/{chunk-B3EBXISV.js → chunk-5DVP76WL.js} +90 -7
  30. package/chunks/{chunk-2T3RYG4L.js → chunk-5KDLX7ER.js} +919 -323
  31. package/chunks/{chunk-O2ZYHG33.js → chunk-5L6CQ4ZU.js} +131 -67
  32. package/chunks/{chunk-E2SYUEIA.js → chunk-5OAMVWFL.js} +874 -375
  33. package/chunks/{chunk-LPLMUGIM.js → chunk-5X76FZLI.js} +5 -5
  34. package/chunks/{chunk-M2L4TMH3.js → chunk-6HTEECQY.js} +3 -3
  35. package/chunks/{chunk-KHSJSMFS.js → chunk-6I6WUVYI.js} +1 -1
  36. package/chunks/{chunk-LLMGP5IC.js → chunk-6WBWIPBF.js} +2 -2
  37. package/chunks/{chunk-PQ5JFCNL.js → chunk-762UTZQZ.js} +3 -3
  38. package/chunks/{chunk-HBCKZF2A.js → chunk-7EW7CYLA.js} +1 -1
  39. package/chunks/{chunk-4PZ7SPD5.js → chunk-7FKLLD4X.js} +1 -1
  40. package/chunks/{chunk-XSOAW7FC.js → chunk-AE7AKP3E.js} +6 -6
  41. package/chunks/{chunk-UATJZOAJ.js → chunk-ASS3UQB5.js} +3 -3
  42. package/chunks/{chunk-XGA6XHH3.js → chunk-AXOFMDZC.js} +3 -3
  43. package/chunks/chunk-BKHCW2BI.js +41 -0
  44. package/chunks/{chunk-DZPOYHBT.js → chunk-D6FISK43.js} +1 -1
  45. package/chunks/{chunk-CFDR3GNL.js → chunk-D7D7RXIJ.js} +11 -0
  46. package/chunks/{chunk-FPPVCCAH.js → chunk-DNPP267F.js} +1 -1
  47. package/chunks/{chunk-I32URQI7.js → chunk-EA2CKB6L.js} +5 -5
  48. package/chunks/{chunk-C5YFS6VR.js → chunk-EL4W7MGQ.js} +4 -4
  49. package/chunks/{chunk-QXTGHZCX.js → chunk-FDLXWNCE.js} +3 -3
  50. package/chunks/{chunk-PCVMRBLN.js → chunk-FFCSRU3F.js} +1 -1
  51. package/chunks/{chunk-SV5X2EUV.js → chunk-FMU2QVA5.js} +1 -1
  52. package/chunks/{chunk-2ON2O4MD.js → chunk-FV2JYSWS.js} +28 -3
  53. package/chunks/{chunk-KB6VSG2U.js → chunk-GXP44JOS.js} +7 -7
  54. package/chunks/{chunk-BC4LTKEG.js → chunk-HP6MKLWU.js} +1 -1
  55. package/chunks/{chunk-YXEVDA66.js → chunk-HU5TUALO.js} +110 -22
  56. package/chunks/{chunk-2JN5V3I7.js → chunk-ITZK3L4S.js} +1 -1
  57. package/chunks/{chunk-5XGI4IPK.js → chunk-JEVHOCCA.js} +4 -4
  58. package/chunks/{chunk-6ME3PVMM.js → chunk-JNFWMBG6.js} +5 -5
  59. package/chunks/{chunk-3PHUGFPH.js → chunk-JXPOBM4B.js} +1 -1
  60. package/chunks/{chunk-TXZDRD36.js → chunk-LCCBAGRT.js} +5 -5
  61. package/chunks/{chunk-G7XXKQYS.js → chunk-LKRMNRSN.js} +27 -1
  62. package/chunks/{chunk-DOCBJIBL.js → chunk-MB3ILUB7.js} +1 -1
  63. package/chunks/{chunk-HFVW54NL.js → chunk-MBEMTXQT.js} +9 -2
  64. package/chunks/{chunk-RNKGMZEW.js → chunk-MFTOMYE2.js} +1 -1
  65. package/chunks/{chunk-RPYYTL7E.js → chunk-MGSSJT27.js} +2 -2
  66. package/chunks/{chunk-URVJ4AZC.js → chunk-MKMUBBEX.js} +1 -1
  67. package/chunks/{chunk-RL2NPV5E.js → chunk-N5QPOGRQ.js} +1 -1
  68. package/chunks/{chunk-2CCUHZP5.js → chunk-N7PF4KZR.js} +2 -2
  69. package/chunks/{chunk-JDJ7SC4E.js → chunk-NMBDPO63.js} +255 -197
  70. package/chunks/{chunk-M6RNMBUO.js → chunk-NQZ5IVLH.js} +4 -4
  71. package/chunks/{chunk-FV4TUUDE.js → chunk-O4WOWHMZ.js} +1 -1
  72. package/chunks/{chunk-GDREW3U5.js → chunk-OIVG6IHL.js} +2 -2
  73. package/chunks/{chunk-IMGNGOGC.js → chunk-PQ2J56BJ.js} +3 -3
  74. package/chunks/{chunk-EJXATV5R.js → chunk-PWFDZA5A.js} +2 -2
  75. package/chunks/{chunk-OOPFAIWP.js → chunk-Q7EXR3W2.js} +1 -1
  76. package/chunks/{chunk-4CTV3FZH.js → chunk-QJL2AQZI.js} +23 -19
  77. package/chunks/{chunk-SBBHZ3YT.js → chunk-QKWPXGW4.js} +1 -1
  78. package/chunks/{chunk-HI4YGRJD.js → chunk-RDICVTQC.js} +3 -3
  79. package/chunks/{chunk-ZRQY5BBS.js → chunk-REAWLQAU.js} +10 -10
  80. package/chunks/{chunk-BOWKLLWA.js → chunk-SOBA6GIW.js} +3 -3
  81. package/chunks/{chunk-WDLQGFWP.js → chunk-TYWI5NXY.js} +27 -27
  82. package/chunks/{chunk-A7PONO5G.js → chunk-URJHXOSO.js} +2 -2
  83. package/chunks/{chunk-C6FU76AA.js → chunk-V3BNVUFI.js} +1 -1
  84. package/chunks/{chunk-G6KI6B5L.js → chunk-VF6WPN4R.js} +1 -1
  85. package/chunks/{chunk-AWTLFUVN.js → chunk-VT27B2XS.js} +13 -13
  86. package/chunks/{chunk-O4IWFYUW.js → chunk-VY4TEQQ6.js} +4 -4
  87. package/chunks/{chunk-EIAPOG76.js → chunk-WECYW5EE.js} +4 -4
  88. package/chunks/{chunk-PDDYAXL2.js → chunk-WIRAPZ62.js} +7 -0
  89. package/chunks/chunk-WOJZWRAZ.js +123 -0
  90. package/chunks/{chunk-7UXI6P72.js → chunk-WVAESIM6.js} +2 -2
  91. package/chunks/{chunk-P5UJMCVS.js → chunk-XIDYVC4P.js} +4 -4
  92. package/chunks/{chunk-THLV7YGY.js → chunk-XIKKANF4.js} +2 -2
  93. package/chunks/{chunk-FHPKHXHT.js → chunk-XNZBXQCG.js} +4 -0
  94. package/chunks/{chunk-ZLJQIGCH.js → chunk-XZCMQUOF.js} +8 -0
  95. package/chunks/{chunk-PQEIKQXN.js → chunk-YJMFRTLV.js} +24 -6
  96. package/chunks/{chunk-QZQ72YF6.js → chunk-Z26UXKZE.js} +1 -1
  97. package/chunks/{chunk-VA5NLVPT.js → chunk-Z7JILXGX.js} +1 -1
  98. package/chunks/{chunk-UEJESCS7.js → chunk-ZPPP6VCL.js} +1 -1
  99. package/chunks/{computer-use-MDOMIVTL.js → computer-use-ENYMKQAI.js} +17 -16
  100. package/chunks/{config-utils-E3ZQTHGM.js → config-utils-LIRO7NSU.js} +2 -2
  101. package/chunks/{contextCommand-FCK3CB37.js → contextCommand-E7XMHU6M.js} +19 -18
  102. package/chunks/{core-runtime-UHRHHU2O.js → core-runtime-KDIRQ63A.js} +17 -16
  103. package/chunks/{create-sub-session-J32WC64U.js → create-sub-session-6EWLAZD5.js} +1 -1
  104. package/chunks/{create-sub-session-MIXUVLWW.js → create-sub-session-VVEL77UF.js} +17 -16
  105. package/chunks/{cron-create-HMFSHIAR.js → cron-create-CCRIULJE.js} +1 -1
  106. package/chunks/{cron-delete-ZJFHOX57.js → cron-delete-FCFW6BGP.js} +1 -1
  107. package/chunks/{cron-list-ZEX2NBMN.js → cron-list-QDBVCHRF.js} +1 -1
  108. package/chunks/{daemon-status-provider-6LC7LUNR.js → daemon-status-provider-4LMCSLZ4.js} +25 -23
  109. package/chunks/{daemon-trust-policy-Y36HGRAM.js → daemon-trust-policy-XLONWB2C.js} +22 -21
  110. package/chunks/{daemon-trust-policy-monitor-ROTBBDOH.js → daemon-trust-policy-monitor-FHFZ3NNG.js} +22 -21
  111. package/chunks/{deferred-core-runtime-ZQ4JIAJD.js → deferred-core-runtime-QNEBJ3DP.js} +17 -16
  112. package/chunks/{display-image-2WOG27DY.js → display-image-GUJA352B.js} +2 -2
  113. package/chunks/{earlyInputCapture-GPRUNXTP.js → earlyInputCapture-OG5IUF4R.js} +17 -16
  114. package/chunks/{edit-YK3UP6D2.js → edit-E2WNOITJ.js} +18 -17
  115. package/chunks/{enter-worktree-QMVQW7UG.js → enter-worktree-RMCBAAA2.js} +17 -16
  116. package/chunks/{enterPlanMode-TZAYQ5MP.js → enterPlanMode-GISFJA3O.js} +17 -16
  117. package/chunks/{environment-3UQURCZG.js → environment-JXTQGYDN.js} +19 -18
  118. package/chunks/{errors-VBIMTNNI.js → errors-2AYTYCQ3.js} +19 -18
  119. package/chunks/{exit-worktree-4EC7LBBC.js → exit-worktree-HORS3V7Z.js} +17 -16
  120. package/chunks/{exitPlanMode-K5Y3REU2.js → exitPlanMode-V75Y36HJ.js} +17 -16
  121. package/chunks/external-tool-guard-provider-5HTGOPGU.js +273 -0
  122. package/chunks/{fast-path-KS6IE7YR.js → fast-path-HURC6JUT.js} +5 -5
  123. package/chunks/{gemini-LTUCUOJH.js → gemini-WHMD4RGY.js} +70 -55
  124. package/chunks/{geminiContentGenerator-M3HJTHKR.js → geminiContentGenerator-DZB3GPNQ.js} +1 -1
  125. package/chunks/{glob-SKUYGTF2.js → glob-IGTV723M.js} +17 -16
  126. package/chunks/{goal-tools-SPQ5M6D3.js → goal-tools-3AZKX5WQ.js} +2 -18
  127. package/chunks/{grep-SQ7RD7SV.js → grep-SJ2NYUCD.js} +17 -16
  128. package/chunks/{handleAutoUpdate-OK7OX23A.js → handleAutoUpdate-NPBKROGA.js} +21 -20
  129. package/chunks/{i18n-P77YBKY4.js → i18n-CBSMJZ3Z.js} +18 -17
  130. package/chunks/{image-gen-2ZWPS42A.js → image-gen-KNKDTUEN.js} +2 -2
  131. package/chunks/{initializer-PIOYXVW7.js → initializer-JT5P3IQF.js} +22 -21
  132. package/chunks/{installationInfo-IWMM6DPV.js → installationInfo-CZVCKPPZ.js} +18 -17
  133. package/chunks/{list-3DCR4TRI.js → list-MT7T6JVH.js} +25 -24
  134. package/chunks/{list-agents-TWEGRJWO.js → list-agents-GC4BRET7.js} +1 -1
  135. package/chunks/{loadedSettingsAdapter-EJC6CU5N.js → loadedSettingsAdapter-D4JFGYYQ.js} +22 -21
  136. package/chunks/{loggingContentGenerator-2JEFU25T.js → loggingContentGenerator-SFT5CMPU.js} +9 -8
  137. package/chunks/{loop-wakeup-6LLEOQYV.js → loop-wakeup-SQQSBMEY.js} +2 -2
  138. package/chunks/{ls-H5WX22VK.js → ls-63CC3NNX.js} +1 -1
  139. package/chunks/{lsp-G6FXYEIS.js → lsp-P6NVJVNT.js} +1 -1
  140. package/chunks/{managed-npm-update-EGVQPSBR.js → managed-npm-update-YHJW6SGD.js} +18 -17
  141. package/chunks/{mcp-KFFH2MBV.js → mcp-53X2M7XL.js} +22 -21
  142. package/chunks/{monitor-6Y3NDMTI.js → monitor-I43P3MNV.js} +17 -16
  143. package/chunks/{nonInteractiveCli-426IQDPE.js → nonInteractiveCli-UADCDERF.js} +50 -48
  144. package/chunks/{notebook-edit-373IQQLE.js → notebook-edit-WKZUONWV.js} +18 -17
  145. package/chunks/{openaiContentGenerator-PGFSOMIQ.js → openaiContentGenerator-YHF3FIYI.js} +9 -8
  146. package/chunks/{pidfile-Y4INDMHG.js → pidfile-VU37FJS4.js} +17 -16
  147. package/chunks/{processUtils-6BCPCJZW.js → processUtils-VIQVTDWH.js} +2 -2
  148. package/chunks/{qwenContentGenerator-QC3KSHSX.js → qwenContentGenerator-46476NL4.js} +18 -17
  149. package/chunks/{qwenOAuth2-IOAXKJ3L.js → qwenOAuth2-D62OJZFU.js} +1 -1
  150. package/chunks/{read-file-2T54FYZV.js → read-file-6PSNROKB.js} +7 -6
  151. package/chunks/{read-mcp-resource-DRZSI3HE.js → read-mcp-resource-RTSSEER5.js} +1 -1
  152. package/chunks/{record-artifact-IPIRWMFY.js → record-artifact-E6AWQU2Z.js} +2 -2
  153. package/chunks/{resumeHistoryUtils-O62RDCZ3.js → resumeHistoryUtils-QFD6LB7N.js} +20 -19
  154. package/chunks/{ripGrep-3H72KY7S.js → ripGrep-4WZJEOGB.js} +17 -16
  155. package/chunks/{run-qwen-serve-3AIDNNHO.js → run-qwen-serve-SEL3TISE.js} +72 -36
  156. package/chunks/{runtime-AZ4EHHFV.js → runtime-T6JAS7GL.js} +25 -24
  157. package/chunks/{scheduler-L4UUCU4Z.js → scheduler-ZCTDMJJV.js} +17 -16
  158. package/chunks/{sdk-exporters-http-IKNWQJNV.js → sdk-exporters-http-IL2346MJ.js} +6 -2
  159. package/chunks/{sdk-impl-7CUUMQDB.js → sdk-impl-SYKGVWOZ.js} +2 -2
  160. package/chunks/{send-message-LHJLVWFD.js → send-message-TL6FIMMN.js} +3 -3
  161. package/chunks/{serve-CLXGSYOE.js → serve-A7B6VWK7.js} +23 -21
  162. package/chunks/{server-MEAE3WMM.js → server-6CCTTLO4.js} +170 -63
  163. package/chunks/{session-OSLD2LT5.js → session-3YYXW6MZ.js} +51 -49
  164. package/chunks/{settings-ILWAOKA4.js → settings-KWYWA3BS.js} +21 -20
  165. package/chunks/{shell-RT5DBH6B.js → shell-6SUYJURL.js} +17 -16
  166. package/chunks/{skill-LVGA3ATZ.js → skill-ZIQFS6YD.js} +8 -7
  167. package/chunks/{skill-settings-WTZE7EPE.js → skill-settings-23IFV7S3.js} +21 -20
  168. package/chunks/{spawnChannel-BOBS7DVM.js → spawnChannel-AI7QA35U.js} +20 -18
  169. package/chunks/{standalone-update-Y5JB4S2K.js → standalone-update-WNXRFLEA.js} +19 -18
  170. package/chunks/{startInteractiveUI-ZV25CD2S.js → startInteractiveUI-NPZU6YXV.js} +76 -71
  171. package/chunks/{syntheticOutput-EYL7DWO7.js → syntheticOutput-BN7E626U.js} +2 -2
  172. package/chunks/{task-create-4ALZMGP5.js → task-create-2X4UP4F3.js} +4 -4
  173. package/chunks/{task-list-6CVQPORX.js → task-list-WOLJPZ64.js} +1 -1
  174. package/chunks/{task-stop-Y5ZTFVRX.js → task-stop-TNXRNAL2.js} +1 -1
  175. package/chunks/{task-update-IKCEEWJ6.js → task-update-VDUSN36E.js} +4 -4
  176. package/chunks/{team-create-ZVPQIXCP.js → team-create-CMF2RRF2.js} +17 -16
  177. package/chunks/{team-delete-CE7DC53R.js → team-delete-D2VMSDOT.js} +1 -1
  178. package/chunks/{team-plan-approval-5UHUBY3W.js → team-plan-approval-5EET4S3I.js} +17 -16
  179. package/chunks/{terminal-image-renderer-NWC2RALG.js → terminal-image-renderer-TCEAHDFE.js} +18 -17
  180. package/chunks/{theme-manager-5KICSBOB.js → theme-manager-RPYRQJLX.js} +17 -16
  181. package/chunks/{todoWrite-FTZWQRZH.js → todoWrite-MHWHO5UO.js} +1 -1
  182. package/chunks/{tool-search-2AOU77H4.js → tool-search-HJN53LCN.js} +9 -8
  183. package/chunks/{total-session-admission-FR7RMHVL.js → total-session-admission-4FZK4PCR.js} +21 -19
  184. package/chunks/{trustedFolders-V7UUPQXO.js → trustedFolders-RIYUQQJC.js} +18 -17
  185. package/chunks/{update-relaunch-TBWRMQD6.js → update-relaunch-3HVSJU2T.js} +5 -5
  186. package/chunks/{updateCheck-42SPCLH7.js → updateCheck-EE2XXQNJ.js} +20 -19
  187. package/chunks/{useAutoAcceptIndicator-4C2KM345.js → useAutoAcceptIndicator-RRV7MW47.js} +23 -22
  188. package/chunks/{validateNonInterActiveAuth-UVFRXV3Z.js → validateNonInterActiveAuth-3QRII2BS.js} +47 -45
  189. package/chunks/{version-HKTV6TPN.js → version-4KUHPDAC.js} +1 -1
  190. package/chunks/{web-fetch-ZRXSV5AN.js → web-fetch-MXA6HQ42.js} +7 -6
  191. package/chunks/{web-search-WOLV3L6T.js → web-search-YENHOBMC.js} +5 -4
  192. package/chunks/{workflow-F63ES3OB.js → workflow-RYEVBM4L.js} +18 -17
  193. package/chunks/{workspace-providers-status-PJMGMYMC.js → workspace-providers-status-SBTU5TWO.js} +25 -24
  194. package/chunks/{workspace-registration-store-LNBOX5TJ.js → workspace-registration-store-VUMOTODR.js} +1 -1
  195. package/chunks/{workspace-registry-4PR7VDQ3.js → workspace-registry-OZ5ZUBJ6.js} +21 -19
  196. package/chunks/{workspace-service-PVI3VUNQ.js → workspace-service-Y3IGAN4K.js} +26 -25
  197. package/chunks/{workspace-skills-status-2Q5ZISO6.js → workspace-skills-status-FXOIDGOS.js} +23 -22
  198. package/chunks/{workspace-trust-reconciler-NOILUH3C.js → workspace-trust-reconciler-DQI7MYJS.js} +26 -24
  199. package/chunks/{write-file-MOM4JDHG.js → write-file-NK4C3GFC.js} +17 -16
  200. package/chunks/{zoom-image-E3VHRCFU.js → zoom-image-4Y6Y6DAX.js} +7 -6
  201. package/cli-entry.js +14 -0
  202. package/cli.js +16 -12
  203. package/package.json +3 -3
  204. package/web-shell/assets/{arc-GpdmhIxr.js → arc-DtI1rZcQ.js} +1 -1
  205. package/web-shell/assets/{architectureDiagram-3BPJPVTR-C-LhCgH_.js → architectureDiagram-3BPJPVTR-BPZwSVct.js} +1 -1
  206. package/web-shell/assets/{blockDiagram-GPEHLZMM-CzNdTCm-.js → blockDiagram-GPEHLZMM-BIQ03j4C.js} +1 -1
  207. package/web-shell/assets/{c4Diagram-AAUBKEIU-Ce7hbrRM.js → c4Diagram-AAUBKEIU-CB0RyFGm.js} +1 -1
  208. package/web-shell/assets/channel-vfbVFuM1.js +1 -0
  209. package/web-shell/assets/{chunk-2J33WTMH-BBSEn1PK.js → chunk-2J33WTMH-B3WoS-4H.js} +1 -1
  210. package/web-shell/assets/{chunk-4BX2VUAB-_llgjfe5.js → chunk-4BX2VUAB-C98xYZ1X.js} +1 -1
  211. package/web-shell/assets/{chunk-55IACEB6-9fJZ_oZE.js → chunk-55IACEB6-CbTIWRwQ.js} +1 -1
  212. package/web-shell/assets/{chunk-727SXJPM-DgEzQWOu.js → chunk-727SXJPM-DWGnKTPu.js} +1 -1
  213. package/web-shell/assets/{chunk-AQP2D5EJ-B4RthUTc.js → chunk-AQP2D5EJ-4__QyCEX.js} +1 -1
  214. package/web-shell/assets/{chunk-FMBD7UC4-CDI-emMW.js → chunk-FMBD7UC4-DFtG1YCW.js} +1 -1
  215. package/web-shell/assets/{chunk-ND2GUHAM-jM2-yOd8.js → chunk-ND2GUHAM-rvAhW51N.js} +1 -1
  216. package/web-shell/assets/{chunk-QZHKN3VN-XGZHlKPF.js → chunk-QZHKN3VN-DfiU9pwZ.js} +1 -1
  217. package/web-shell/assets/classDiagram-4FO5ZUOK-Cvr8atq3.js +1 -0
  218. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Cvr8atq3.js +1 -0
  219. package/web-shell/assets/{cose-bilkent-S5V4N54A-90nbW1xQ.js → cose-bilkent-S5V4N54A-Cc4EIdxu.js} +1 -1
  220. package/web-shell/assets/{dagre-BM42HDAG-BtzlyqZ9.js → dagre-BM42HDAG-CZNj4dGW.js} +1 -1
  221. package/web-shell/assets/{diagram-2AECGRRQ-DAaqGWaH.js → diagram-2AECGRRQ-D5tiqQCr.js} +1 -1
  222. package/web-shell/assets/{diagram-5GNKFQAL-CxlzSIFa.js → diagram-5GNKFQAL-pwzw0jVO.js} +1 -1
  223. package/web-shell/assets/{diagram-KO2AKTUF-8kj-1H6u.js → diagram-KO2AKTUF-4CWiM00x.js} +1 -1
  224. package/web-shell/assets/{diagram-LMA3HP47-6NhjFwRF.js → diagram-LMA3HP47-Dd7rc7Qf.js} +1 -1
  225. package/web-shell/assets/{diagram-OG6HWLK6-Bn9kvInz.js → diagram-OG6HWLK6-_vzV52ml.js} +1 -1
  226. package/web-shell/assets/{erDiagram-TEJ5UH35-CaRoGsAt.js → erDiagram-TEJ5UH35-CqbE2bx_.js} +1 -1
  227. package/web-shell/assets/{flowDiagram-I6XJVG4X-TkLweHdf.js → flowDiagram-I6XJVG4X-CaxNr7w4.js} +1 -1
  228. package/web-shell/assets/{ganttDiagram-6RSMTGT7-ruwhCKBl.js → ganttDiagram-6RSMTGT7-AGjrtfUA.js} +1 -1
  229. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-DNI_PxoU.js → gitGraphDiagram-PVQCEYII-ADG2zSkc.js} +1 -1
  230. package/web-shell/assets/{index-p1gz-sxE.js → index-BOryKCqt.js} +1 -1
  231. package/web-shell/assets/index-Cb1LjsCv.css +5 -0
  232. package/web-shell/assets/{index-T4KluHvu.js → index-CvJDaIy8.js} +329 -329
  233. package/web-shell/assets/{infoDiagram-5YYISTIA-DarXq1-A.js → infoDiagram-5YYISTIA-CE3B_IoZ.js} +1 -1
  234. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-GxDaDlT0.js → ishikawaDiagram-YF4QCWOH-CN-Frhoi.js} +1 -1
  235. package/web-shell/assets/{journeyDiagram-JHISSGLW-mDEoGBzY.js → journeyDiagram-JHISSGLW-CGgezS93.js} +1 -1
  236. package/web-shell/assets/{kanban-definition-UN3LZRKU-Ds0t-Mup.js → kanban-definition-UN3LZRKU-BqWijky5.js} +1 -1
  237. package/web-shell/assets/{linear-05nJ0xZ7.js → linear-D8sfpZf6.js} +1 -1
  238. package/web-shell/assets/{mermaid.core-Bua24ThM.js → mermaid.core-3PA4QrzM.js} +5 -5
  239. package/web-shell/assets/{mindmap-definition-RKZ34NQL-D_zRdvUS.js → mindmap-definition-RKZ34NQL-D9QxwiCY.js} +1 -1
  240. package/web-shell/assets/{pieDiagram-4H26LBE5-DZHr1x16.js → pieDiagram-4H26LBE5-Bioaf6uE.js} +1 -1
  241. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-HA06Wf0h.js → quadrantDiagram-W4KKPZXB-DBb2AS73.js} +1 -1
  242. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DH3urmJf.js → requirementDiagram-4Y6WPE33-DXOvZ3KB.js} +1 -1
  243. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-C4xgz0TT.js → sankeyDiagram-5OEKKPKP-D9qg09Dm.js} +1 -1
  244. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DAUoZWgv.js → sequenceDiagram-3UESZ5HK-DSAUIfpw.js} +1 -1
  245. package/web-shell/assets/{stateDiagram-AJRCARHV-v7NzXy4l.js → stateDiagram-AJRCARHV-BPZkzfQ3.js} +1 -1
  246. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DInOqnhZ.js +1 -0
  247. package/web-shell/assets/{timeline-definition-PNZ67QCA-B3GTYR2W.js → timeline-definition-PNZ67QCA-UDaQp9sP.js} +1 -1
  248. package/web-shell/assets/{vennDiagram-CIIHVFJN-BWHjSPAq.js → vennDiagram-CIIHVFJN-2ouhAnHO.js} +1 -1
  249. package/web-shell/assets/{wardley-L42UT6IY-m9r6IUBC.js → wardley-L42UT6IY-Cq_WEvTK.js} +1 -1
  250. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-kT0FkVfK.js → wardleyDiagram-YWT4CUSO-Dt24aXOM.js} +1 -1
  251. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CYRm10z5.js → xychartDiagram-2RQKCTM6-A5Xk2WCH.js} +1 -1
  252. package/web-shell/index.html +2 -2
  253. package/bundled/review/DESIGN.md +0 -724
  254. package/web-shell/assets/channel-95y6Rcp3.js +0 -1
  255. package/web-shell/assets/classDiagram-4FO5ZUOK-pfzVkmjQ.js +0 -1
  256. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-pfzVkmjQ.js +0 -1
  257. package/web-shell/assets/index-WxSvj2tI.css +0 -5
  258. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CtdFexEf.js +0 -1
  259. package/chunks/{channel-management-service-UHX56NBO.js → channel-management-service-5XPPTWUQ.js} +3 -3
  260. package/chunks/{chunk-LEZFUYPM.js → chunk-7GYP5COR.js} +3 -3
@@ -40,7 +40,7 @@ import {
40
40
  CronScheduler,
41
41
  DEFAULT_RECURRING_MAX_AGE_DAYS,
42
42
  normalizeRecurringMaxAge
43
- } from "./chunk-VA5NLVPT.js";
43
+ } from "./chunk-Z7JILXGX.js";
44
44
  import {
45
45
  consumeUnread,
46
46
  forwardApproval,
@@ -71,13 +71,13 @@ import {
71
71
  RUNTIME_SNAPSHOT_PREFIX,
72
72
  buildModelIdContext,
73
73
  resolveModelId
74
- } from "./chunk-DZPOYHBT.js";
74
+ } from "./chunk-D6FISK43.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-X6QNZOTC.js";
80
+ } from "./chunk-3PRJYMXC.js";
81
81
  import {
82
82
  promptIdContext,
83
83
  todoWorkChainContext
@@ -139,7 +139,7 @@ import {
139
139
  goalRequiresExactPermit,
140
140
  goalTurnContext,
141
141
  parseGoalStateRecordPayloadV2
142
- } from "./chunk-HFVW54NL.js";
142
+ } from "./chunk-MBEMTXQT.js";
143
143
  import {
144
144
  APPROVAL_MODES,
145
145
  SUBAGENT_PLAN_LIFECYCLE_TOOLS,
@@ -163,7 +163,7 @@ import {
163
163
  runWithRuntimeContentGenerator,
164
164
  shouldUsePlanOnlyReminderInSubagentContext,
165
165
  spawnBlockReason
166
- } from "./chunk-LLMGP5IC.js";
166
+ } from "./chunk-6WBWIPBF.js";
167
167
  import {
168
168
  getTeammateContext,
169
169
  isTeammate,
@@ -202,7 +202,7 @@ import {
202
202
  selectForkHistory,
203
203
  stripSystemReminderBlocks,
204
204
  validateForkToolList
205
- } from "./chunk-7UXI6P72.js";
205
+ } from "./chunk-WVAESIM6.js";
206
206
  import {
207
207
  collectAvailableSkillEntries,
208
208
  renderAvailableSkillsBlock
@@ -223,7 +223,7 @@ import {
223
223
  } from "./chunk-432XCUHF.js";
224
224
  import {
225
225
  DashScopeOpenAICompatibleProvider
226
- } from "./chunk-YXEVDA66.js";
226
+ } from "./chunk-HU5TUALO.js";
227
227
  import {
228
228
  openBrowserSecurely,
229
229
  shouldAttemptBrowserLaunch
@@ -248,7 +248,7 @@ import {
248
248
  addToolArgumentsAttributes,
249
249
  addToolCallResultAttributes,
250
250
  addUserPromptAttributes
251
- } from "./chunk-RPYYTL7E.js";
251
+ } from "./chunk-MGSSJT27.js";
252
252
  import {
253
253
  InvalidStreamError,
254
254
  getThoughtSummary
@@ -302,7 +302,6 @@ import {
302
302
  _recoverObjectsFromLine,
303
303
  addMCPStatusChangeListener,
304
304
  collectText,
305
- defaultModalities,
306
305
  detectFileType,
307
306
  exists,
308
307
  fileExists,
@@ -383,7 +382,10 @@ import {
383
382
  updateMCPServerStatus,
384
383
  writeLine,
385
384
  writeLineSync
386
- } from "./chunk-JDJ7SC4E.js";
385
+ } from "./chunk-NMBDPO63.js";
386
+ import {
387
+ defaultModalities
388
+ } from "./chunk-WOJZWRAZ.js";
387
389
  import {
388
390
  E_TIMEOUT,
389
391
  Mutex,
@@ -411,13 +413,14 @@ import {
411
413
  } from "./chunk-E4WHKETF.js";
412
414
  import {
413
415
  STRUCTURED_OUTPUT_REDACTED_ARGS
414
- } from "./chunk-UEJESCS7.js";
416
+ } from "./chunk-ZPPP6VCL.js";
415
417
  import {
416
418
  AgentStatistics,
417
419
  BaseDeclarativeTool,
418
420
  BaseToolInvocation,
419
421
  CONCURRENCY_SAFE_KINDS,
420
422
  SchemaValidator,
423
+ StructuredToolError,
421
424
  ToolDisplayNames,
422
425
  ToolDisplayNamesMigration,
423
426
  ToolNames,
@@ -428,7 +431,7 @@ import {
428
431
  require_dist,
429
432
  require_fast_deep_equal,
430
433
  require_fast_uri
431
- } from "./chunk-CFDR3GNL.js";
434
+ } from "./chunk-D7D7RXIJ.js";
432
435
  import {
433
436
  AUTH_ENV_MAPPINGS,
434
437
  AuthType,
@@ -442,7 +445,7 @@ import {
442
445
  createContentGenerator,
443
446
  resetPreloadedContentGenerator,
444
447
  resolveContentGeneratorConfigWithSources
445
- } from "./chunk-TXZDRD36.js";
448
+ } from "./chunk-LCCBAGRT.js";
446
449
  import {
447
450
  normalizeMcpToolName,
448
451
  sanitizeToolNameForProvider
@@ -494,15 +497,28 @@ import {
494
497
  startToolExecutionSpan,
495
498
  startToolSpan,
496
499
  truncateSpanError
497
- } from "./chunk-O2ZYHG33.js";
500
+ } from "./chunk-5L6CQ4ZU.js";
498
501
  import {
499
502
  safeJsonStringify
500
503
  } from "./chunk-W4RQUHY3.js";
501
504
  import {
502
505
  DEFAULT_SENSITIVE_SPAN_ATTRIBUTE_MAX_LENGTH,
503
506
  SENSITIVE_SPAN_ATTRIBUTE_MAX_LENGTH_LIMIT,
507
+ TOOL_FAILURE_KIND_ATTRIBUTE,
508
+ TOOL_FAILURE_KIND_BACKGROUND_AGENT_DENIED,
509
+ TOOL_FAILURE_KIND_CANCELLED,
510
+ TOOL_FAILURE_KIND_INVOCATION_GUARD_DENIED,
511
+ TOOL_FAILURE_KIND_NON_INTERACTIVE_DENIED,
512
+ TOOL_FAILURE_KIND_PERMISSION_DENIED,
513
+ TOOL_FAILURE_KIND_PERMISSION_HOOK_DENIED,
514
+ TOOL_FAILURE_KIND_PLAN_MODE_BLOCKED,
515
+ TOOL_FAILURE_KIND_POST_HOOK_STOPPED,
516
+ TOOL_FAILURE_KIND_PRE_HOOK_BLOCKED,
517
+ TOOL_FAILURE_KIND_TIMEOUT,
518
+ TOOL_FAILURE_KIND_TOOL_ERROR,
519
+ TOOL_FAILURE_KIND_TOOL_EXCEPTION,
504
520
  isValidSensitiveSpanAttributeMaxLength
505
- } from "./chunk-G7XXKQYS.js";
521
+ } from "./chunk-LKRMNRSN.js";
506
522
  import {
507
523
  FatalConfigError,
508
524
  PATH_ARG_KEYS,
@@ -20571,6 +20587,9 @@ function buildKeptFilePaths(history, refs, keepRefs, callIdToFilePath) {
20571
20587
  if (!keepRefs.has(refKey(ref))) continue;
20572
20588
  const part = getPart(history, ref);
20573
20589
  if (!part || isErrorResponse(part) || isAlreadyCleared(part)) continue;
20590
+ if (part.functionResponse?.name !== ToolNames.WRITE_FILE) {
20591
+ continue;
20592
+ }
20574
20593
  const paths = getFilePathsForResponse(part, callIdToFilePath);
20575
20594
  if (paths?.length === 1) {
20576
20595
  kept.add(paths[0]);
@@ -20584,6 +20603,7 @@ function planSizeBasedClearing(history, settings, keepRecent, pendingContent, pr
20584
20603
  if (!Number.isFinite(threshold) || threshold < 0) {
20585
20604
  return null;
20586
20605
  }
20606
+ const lowWatermark = Math.floor(threshold / 2);
20587
20607
  const pending = normalizePendingContent(pendingContent);
20588
20608
  const virtualHistory = pending.length > 0 ? [...history, ...pending] : history;
20589
20609
  const { tool } = collectCompactablePartRefs(virtualHistory);
@@ -20606,11 +20626,16 @@ function planSizeBasedClearing(history, settings, keepRecent, pendingContent, pr
20606
20626
  const compactableToolRefs = tool.filter(
20607
20627
  (ref) => !preservedToolRefs.has(refKey(ref))
20608
20628
  );
20609
- const keepToolRefs = buildKeepRefs(compactableToolRefs, keepRecent);
20629
+ const keepToolRefs = buildKeepRefs(
20630
+ compactableToolRefs.filter(
20631
+ (ref) => ref.contentIndex < history.length && charsByRef.has(refKey(ref))
20632
+ ),
20633
+ keepRecent
20634
+ );
20610
20635
  const clearRefs = [];
20611
20636
  let remainingChars = totalChars;
20612
20637
  for (const ref of compactableToolRefs) {
20613
- if (remainingChars <= threshold) break;
20638
+ if (remainingChars <= lowWatermark) break;
20614
20639
  const key = refKey(ref);
20615
20640
  const chars = charsByRef.get(key) ?? 0;
20616
20641
  if (chars <= 0 || ref.contentIndex >= history.length || keepToolRefs.has(key)) {
@@ -20626,7 +20651,8 @@ function planSizeBasedClearing(history, settings, keepRecent, pendingContent, pr
20626
20651
  toolResultCharsBefore: totalChars,
20627
20652
  toolResultCharsAfter: remainingChars - pendingChars,
20628
20653
  pendingToolResultChars: pendingChars,
20629
- toolResultsTotalCharsThreshold: threshold
20654
+ toolResultsTotalCharsThreshold: threshold,
20655
+ toolResultsLowWatermark: lowWatermark
20630
20656
  };
20631
20657
  }
20632
20658
  __name(planSizeBasedClearing, "planSizeBasedClearing");
@@ -20646,6 +20672,7 @@ function microcompactHistory(history, lastApiCompletionTimestamp, settings, opts
20646
20672
  let toolResultCharsAfter;
20647
20673
  let pendingToolResultChars;
20648
20674
  let toolResultsTotalCharsThreshold;
20675
+ let toolResultsLowWatermark;
20649
20676
  let keptPathHistory = history;
20650
20677
  let keptPathRefs = [];
20651
20678
  if (opts?.force) {
@@ -20665,13 +20692,28 @@ function microcompactHistory(history, lastApiCompletionTimestamp, settings, opts
20665
20692
  history,
20666
20693
  opts?.preserveReadFileResult
20667
20694
  ));
20695
+ const keepToolRefs = buildKeepRefs(
20696
+ tool.filter((ref) => {
20697
+ const part = getPart(history, ref);
20698
+ return getToolOutputChars(part) > 0 || !!part && hasNestedMedia(part);
20699
+ }),
20700
+ keepRecent
20701
+ );
20668
20702
  keepRefs = /* @__PURE__ */ new Set([
20669
- ...tool.slice(-keepRecent).map(refKey),
20703
+ ...keepToolRefs,
20670
20704
  ...media.slice(-keepRecent).map(refKey),
20671
20705
  ...nestedMedia.slice(-keepRecent).map(refKey)
20672
20706
  ]);
20673
20707
  const allRefs = [...tool, ...media, ...nestedMedia];
20674
- clearRefs = allRefs.filter((r) => !keepRefs.has(refKey(r)));
20708
+ const toolKeys = new Set(tool.map(refKey));
20709
+ clearRefs = allRefs.filter((r) => {
20710
+ if (keepRefs.has(refKey(r))) return false;
20711
+ const part = getPart(history, r);
20712
+ if (toolKeys.has(refKey(r)) && getToolOutputChars(part) === 0 && !(part && hasNestedMedia(part))) {
20713
+ return false;
20714
+ }
20715
+ return true;
20716
+ });
20675
20717
  keptPathRefs = tool;
20676
20718
  } else {
20677
20719
  const pending = normalizePendingContent(opts?.pendingContent);
@@ -20695,6 +20737,7 @@ function microcompactHistory(history, lastApiCompletionTimestamp, settings, opts
20695
20737
  toolResultCharsAfter = sizePlan.toolResultCharsAfter;
20696
20738
  pendingToolResultChars = sizePlan.pendingToolResultChars;
20697
20739
  toolResultsTotalCharsThreshold = sizePlan.toolResultsTotalCharsThreshold;
20740
+ toolResultsLowWatermark = sizePlan.toolResultsLowWatermark;
20698
20741
  }
20699
20742
  if (clearRefs.length === 0 && triggerReason !== "size") {
20700
20743
  return { history };
@@ -20784,6 +20827,7 @@ function microcompactHistory(history, lastApiCompletionTimestamp, settings, opts
20784
20827
  toolResultCharsAfter,
20785
20828
  pendingToolResultChars,
20786
20829
  toolResultsTotalCharsThreshold,
20830
+ toolResultsLowWatermark,
20787
20831
  toolsCleared,
20788
20832
  mediaCleared,
20789
20833
  toolsKept,
@@ -22441,6 +22485,9 @@ Okay, I can write those tests. First, I'll read someFile.ts to understand its fu
22441
22485
  Now I'll look for existing or related test files to understand current testing conventions and dependencies.
22442
22486
  [tool_call: ${ToolNames.READ_FILE} for file_path '/path/to/existingTest.test.ts']
22443
22487
  (After reviewing existing tests and the file content)
22488
+ I'll check whether the intended test file already exists.
22489
+ [tool_call: ${ToolNames.READ_FILE} for file_path '/path/to/someFile.test.ts']
22490
+ (After read_file reports that /path/to/someFile.test.ts does not exist)
22444
22491
  [tool_call: ${ToolNames.WRITE_FILE} for file_path '/path/to/someFile.test.ts' with content '(test code content)']
22445
22492
  I've written the tests. Now I'll run the project's test command to verify them.
22446
22493
  [tool_call: ${ToolNames.SHELL} for 'npm run test']
@@ -22580,6 +22627,15 @@ Now I'll look for existing or related test files to understand current testing c
22580
22627
  </function>
22581
22628
  </tool_call>
22582
22629
  (After reviewing existing tests and the file content)
22630
+ I'll check whether the intended test file already exists.
22631
+ <tool_call>
22632
+ <function=${ToolNames.READ_FILE}>
22633
+ <parameter=file_path>
22634
+ /path/to/someFile.test.ts
22635
+ </parameter>
22636
+ </function>
22637
+ </tool_call>
22638
+ (After read_file reports that /path/to/someFile.test.ts does not exist)
22583
22639
  <tool_call>
22584
22640
  <function=${ToolNames.WRITE_FILE}>
22585
22641
  <parameter=file_path>
@@ -22693,6 +22749,11 @@ Now I'll look for existing or related test files to understand current testing c
22693
22749
  {"name": "${ToolNames.READ_FILE}", "arguments": {"file_path": "/path/to/existingTest.test.ts"}}
22694
22750
  </tool_call>
22695
22751
  (After reviewing existing tests and the file content)
22752
+ I'll check whether the intended test file already exists.
22753
+ <tool_call>
22754
+ {"name": "${ToolNames.READ_FILE}", "arguments": {"file_path": "/path/to/someFile.test.ts"}}
22755
+ </tool_call>
22756
+ (After read_file reports that /path/to/someFile.test.ts does not exist)
22696
22757
  <tool_call>
22697
22758
  {"name": "${ToolNames.WRITE_FILE}", "arguments": {"file_path": "/path/to/someFile.test.ts", "content": "(test code content)"}}
22698
22759
  </tool_call>
@@ -22774,6 +22835,9 @@ Okay, I can write those tests. First, I'll read someFile.ts to understand its fu
22774
22835
  Now I'll look for existing or related test files to understand current testing conventions and dependencies.
22775
22836
  <|tool_call>call:${ToolNames.READ_FILE}{file_path:<|"|>/path/to/existingTest.test.ts<|"|>}<tool_call|>
22776
22837
  (After reviewing existing tests and the file content)
22838
+ I'll check whether the intended test file already exists.
22839
+ <|tool_call>call:${ToolNames.READ_FILE}{file_path:<|"|>/path/to/someFile.test.ts<|"|>}<tool_call|>
22840
+ (After read_file reports that /path/to/someFile.test.ts does not exist)
22777
22841
  <|tool_call>call:${ToolNames.WRITE_FILE}{file_path:<|"|>/path/to/someFile.test.ts<|"|>,content:<|"|>(test code content)<|"|>}<tool_call|>
22778
22842
  I've written the tests. Now I'll run the project's test command to verify them.
22779
22843
  <|tool_call>call:${ToolNames.SHELL}{command:<|"|>npm run test<|"|>}<tool_call|>
@@ -35090,7 +35154,8 @@ function createDuplicateProviderToolCallResponse(request) {
35090
35154
  ],
35091
35155
  resultDisplay: message,
35092
35156
  error: new Error(message),
35093
- errorType: "execution_failed" /* EXECUTION_FAILED */
35157
+ errorType: "execution_failed" /* EXECUTION_FAILED */,
35158
+ executionStatus: "not_started"
35094
35159
  };
35095
35160
  }
35096
35161
  __name(createDuplicateProviderToolCallResponse, "createDuplicateProviderToolCallResponse");
@@ -35702,6 +35767,7 @@ __name(composePostCompactHistory, "composePostCompactHistory");
35702
35767
  // packages/core/src/services/chatCompressionService.ts
35703
35768
  var debugLogger20 = createDebugLogger("COMPRESSION");
35704
35769
  var COMPACT_MAX_OUTPUT_TOKENS = 2e4;
35770
+ var COMPRESSION_REQUEST_DIRECTIVE = "First, reason in your <analysis> block. Then, produce the <state_snapshot> XML.";
35705
35771
  var DEFAULT_PCT = 0.85;
35706
35772
  var SUMMARY_RESERVE = COMPACT_MAX_OUTPUT_TOKENS;
35707
35773
  var AUTOCOMPACT_BUFFER = 13e3;
@@ -35809,6 +35875,8 @@ var ChatCompressionService = class {
35809
35875
  const chatCompressionSettings = config.getChatCompression();
35810
35876
  const slimmingConfig = resolveSlimmingConfig(chatCompressionSettings);
35811
35877
  const tuning = resolveCompactionTuning(chatCompressionSettings);
35878
+ const contentGeneratorConfig = config.getContentGeneratorConfig();
35879
+ const contextLimit = contentGeneratorConfig.contextWindowSize ?? DEFAULT_TOKEN_LIMIT;
35812
35880
  if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES && !force) {
35813
35881
  return {
35814
35882
  newHistory: null,
@@ -35820,7 +35888,6 @@ var ChatCompressionService = class {
35820
35888
  };
35821
35889
  }
35822
35890
  if (!force) {
35823
- const contextLimit = config.getContentGeneratorConfig()?.contextWindowSize ?? DEFAULT_TOKEN_LIMIT;
35824
35891
  const { auto } = computeThresholds(
35825
35892
  contextLimit,
35826
35893
  config.getAutoCompactThreshold()
@@ -35901,12 +35968,11 @@ var ChatCompressionService = class {
35901
35968
  [opts.pendingUserMessage],
35902
35969
  slimmingConfig.imageTokenEstimate
35903
35970
  ) : 0;
35904
- const slim = slimCompactionInput(sideQueryHistory);
35905
- if (slim.stats.imagesStripped > 0 || slim.stats.documentsStripped > 0) {
35906
- config.getDebugLogger().debug(
35907
- `[chat-compression] slimmed ${slim.stats.imagesStripped} image(s) and ${slim.stats.documentsStripped} document(s) from side-query payload`
35908
- );
35909
- }
35971
+ let coldInput;
35972
+ const getColdInput = /* @__PURE__ */ __name(() => {
35973
+ coldInput ??= slimCompactionInput(sideQueryHistory);
35974
+ return coldInput;
35975
+ }, "getColdInput");
35910
35976
  const systemInstruction = buildCompressionSystemPrompt(
35911
35977
  opts.customInstructions,
35912
35978
  hookExtraInstructions
@@ -35920,7 +35986,7 @@ var ChatCompressionService = class {
35920
35986
  const entry = models.find((m2) => m2.id === resolved.modelId);
35921
35987
  const window2 = entry?.contextWindowSize;
35922
35988
  const slimmedTokenEstimate = estimateContentTokens(
35923
- slim.slimmedHistory,
35989
+ getColdInput().slimmedHistory,
35924
35990
  slimmingConfig.imageTokenEstimate
35925
35991
  ) + Math.ceil(systemInstruction.length / CHARS_PER_TOKEN) + COMPACT_MAX_OUTPUT_TOKENS;
35926
35992
  if (window2 && window2 > 0 && slimmedTokenEstimate > window2) {
@@ -35932,49 +35998,72 @@ var ChatCompressionService = class {
35932
35998
  }
35933
35999
  const abortSignal = signal ?? new AbortController().signal;
35934
36000
  abortSignal.throwIfAborted();
35935
- const runColdCompression = /* @__PURE__ */ __name(() => runSideQuery(config, {
35936
- purpose: "chat-compression",
35937
- skipOutputLanguagePreference: true,
35938
- model: effectiveCompactionModel,
35939
- // Compression uses the compaction model (config.getCompactionModel?.()) to reduce cost.
35940
- // Falls back to the main model if not set or if the payload exceeds the
35941
- // compaction model's context window.
35942
- // See https://github.com/QwenLM/qwen-code/issues/5956
35943
- // Stream so a slow compression inference keeps the HTTP connection alive.
35944
- // Non-streaming returns no bytes until the whole summary is generated, so
35945
- // behind a BFF gateway with a short `proxy_read_timeout` a long inference
35946
- // is killed with a 504 (surfaced as a 422) mid-compression, breaking the
35947
- // session. See https://github.com/QwenLM/qwen-code/issues/5861.
35948
- stream: true,
35949
- // Best-effort: failures fall back to NOOP and the next turn re-triggers
35950
- // compression anyway, so don't burn 7 retries blocking the user mid-turn.
35951
- maxAttempts: 1,
35952
- systemInstruction,
35953
- contents: [
35954
- ...slim.slimmedHistory,
35955
- {
35956
- role: "user",
35957
- parts: [
35958
- {
35959
- text: "First, reason in your <analysis> block. Then, produce the <state_snapshot> XML."
35960
- }
35961
- ]
35962
- }
35963
- ],
35964
- // Compression output is bounded by maxOutputTokens to guarantee a predictable
35965
- // reserve across providers (see docs/design/auto-compaction-threshold-redesign.md).
35966
- // Thinking is disabled because per-provider thinking-budget semantics are
35967
- // inconsistent (Anthropic/OpenAI count it separately, Gemini varies by model).
35968
- config: {
35969
- thinkingConfig: { includeThoughts: false },
35970
- maxOutputTokens: COMPACT_MAX_OUTPUT_TOKENS
35971
- },
35972
- abortSignal,
35973
- promptId
35974
- }), "runColdCompression");
36001
+ const runColdCompression = /* @__PURE__ */ __name(() => {
36002
+ const slim = getColdInput();
36003
+ if (slim.stats.imagesStripped > 0 || slim.stats.documentsStripped > 0) {
36004
+ config.getDebugLogger().debug(
36005
+ `[chat-compression] slimmed ${slim.stats.imagesStripped} image(s) and ${slim.stats.documentsStripped} document(s) from side-query payload`
36006
+ );
36007
+ }
36008
+ return runSideQuery(config, {
36009
+ purpose: "chat-compression",
36010
+ skipOutputLanguagePreference: true,
36011
+ model: effectiveCompactionModel,
36012
+ // Compression uses the compaction model (config.getCompactionModel?.()) to reduce cost.
36013
+ // Falls back to the main model if not set or if the payload exceeds the
36014
+ // compaction model's context window.
36015
+ // See https://github.com/QwenLM/qwen-code/issues/5956
36016
+ // Stream so a slow compression inference keeps the HTTP connection alive.
36017
+ // Non-streaming returns no bytes until the whole summary is generated, so
36018
+ // behind a BFF gateway with a short `proxy_read_timeout` a long inference
36019
+ // is killed with a 504 (surfaced as a 422) mid-compression, breaking the
36020
+ // session. See https://github.com/QwenLM/qwen-code/issues/5861.
36021
+ stream: true,
36022
+ // Best-effort: failures fall back to NOOP and the next turn re-triggers
36023
+ // compression anyway, so don't burn 7 retries blocking the user mid-turn.
36024
+ maxAttempts: 1,
36025
+ systemInstruction,
36026
+ contents: [
36027
+ ...slim.slimmedHistory,
36028
+ {
36029
+ role: "user",
36030
+ parts: [
36031
+ {
36032
+ text: COMPRESSION_REQUEST_DIRECTIVE
36033
+ }
36034
+ ]
36035
+ }
36036
+ ],
36037
+ // Compression output is bounded by maxOutputTokens to guarantee a predictable
36038
+ // reserve across providers (see docs/design/auto-compaction-threshold-redesign.md).
36039
+ // Thinking is disabled because per-provider thinking-budget semantics are
36040
+ // inconsistent (Anthropic/OpenAI count it separately, Gemini varies by model).
36041
+ config: {
36042
+ thinkingConfig: { includeThoughts: false },
36043
+ maxOutputTokens: COMPACT_MAX_OUTPUT_TOKENS
36044
+ },
36045
+ abortSignal,
36046
+ promptId
36047
+ });
36048
+ }, "runColdCompression");
35975
36049
  let summaryResult;
35976
36050
  let usedCacheSharing = false;
35977
- const canShareCache = effectiveCompactionModel === config.getModel() && slim.stats.imagesStripped === 0 && slim.stats.documentsStripped === 0 && supportsCompressionCacheSharing(config);
36051
+ const sharedRequestText = `${systemInstruction}
36052
+
36053
+ Do not call tools; tool execution is disabled for this request. ` + COMPRESSION_REQUEST_DIRECTIVE;
36054
+ const sharedPromptTokenCount = opts.precomputedEffectiveTokens ?? originalTokenCount + (chat.getLastOutputTokenCount?.() ?? 0);
36055
+ const sharedDirectiveTokenCount = Math.ceil(
36056
+ sharedRequestText.length / CHARS_PER_TOKEN
36057
+ );
36058
+ const usesMainModel = effectiveCompactionModel === config.getModel();
36059
+ const providerSupportsCacheSharing = supportsCompressionCacheSharing(config);
36060
+ const hasProviderTokenCount = (chat.getLastPromptTokenCount?.() ?? 0) > 0;
36061
+ const sharedRequestFits = sharedPromptTokenCount + sharedDirectiveTokenCount + COMPACT_MAX_OUTPUT_TOKENS <= contextLimit;
36062
+ const canShareCache = usesMainModel && providerSupportsCacheSharing && hasProviderTokenCount && sharedRequestFits;
36063
+ if (!canShareCache) {
36064
+ const reason = !usesMainModel ? "distinct compaction model" : !providerSupportsCacheSharing ? "provider does not support cache sharing" : !hasProviderTokenCount ? "no provider token-count anchor" : `shared request exceeds context window: prompt=${sharedPromptTokenCount}, directive=${sharedDirectiveTokenCount}, reserve=${COMPACT_MAX_OUTPUT_TOKENS}, window=${contextLimit}`;
36065
+ debugLogger20.debug(`[compaction] skipping cache sharing: ${reason}`);
36066
+ }
35978
36067
  if (canShareCache) {
35979
36068
  try {
35980
36069
  const generationConfig = {
@@ -35991,9 +36080,7 @@ var ChatCompressionService = class {
35991
36080
  role: "user",
35992
36081
  parts: [
35993
36082
  {
35994
- text: `${systemInstruction}
35995
-
35996
- Do not call tools; tool execution is disabled for this request. First, reason in your <analysis> block. Then, produce the <state_snapshot> XML.`
36083
+ text: sharedRequestText
35997
36084
  }
35998
36085
  ]
35999
36086
  }
@@ -36002,7 +36089,7 @@ Do not call tools; tool execution is disabled for this request. First, reason in
36002
36089
  systemInstruction: mainSystemInstruction,
36003
36090
  config: {
36004
36091
  ...generationConfig,
36005
- ...config.getContentGeneratorConfig().authType === "anthropic" /* USE_ANTHROPIC */ ? {
36092
+ ...contentGeneratorConfig.authType === "anthropic" /* USE_ANTHROPIC */ ? {
36006
36093
  thinkingConfig: {
36007
36094
  ...generationConfig.thinkingConfig,
36008
36095
  // Manual Anthropic thinking requires budget_tokens to be
@@ -37723,6 +37810,10 @@ var GeminiChat = class {
37723
37810
  getLastPromptTokenCount() {
37724
37811
  return this.lastPromptTokenCount;
37725
37812
  }
37813
+ /** Previous model-response tokens used by the next prompt estimate. */
37814
+ getLastOutputTokenCount() {
37815
+ return this.lastOutputTokenCount;
37816
+ }
37726
37817
  /**
37727
37818
  * Builds request contents for the content generator without deep-cloning the
37728
37819
  * whole chat history. This is an internal hot path: long sessions can make a
@@ -38434,6 +38525,7 @@ var GeminiChat = class {
38434
38525
  params.config?.abortSignal,
38435
38526
  {
38436
38527
  originalTokenCountOverride: reactiveOriginalTokenCount,
38528
+ precomputedEffectiveTokens: reactiveOriginalTokenCount,
38437
38529
  requestGenerationConfig: params.config,
38438
38530
  trigger: "auto"
38439
38531
  }
@@ -52240,7 +52332,12 @@ async function evaluateToolInvocationGuard(guard, context2) {
52240
52332
  });
52241
52333
  const decision = await guard({
52242
52334
  ...context2,
52243
- args: structuredClone(context2.args)
52335
+ args: structuredClone(context2.args),
52336
+ ...context2.invocationContext ? {
52337
+ invocationContext: Object.freeze({
52338
+ ...context2.invocationContext
52339
+ })
52340
+ } : {}
52244
52341
  });
52245
52342
  if (context2.signal.aborted) {
52246
52343
  return { allowed: false, reason: FAILED_MESSAGE };
@@ -74585,16 +74682,6 @@ __name(toReadTextFileResponse, "toReadTextFileResponse");
74585
74682
  // packages/core/src/tools/priorReadEnforcement.ts
74586
74683
  init_esbuild_shims();
74587
74684
  import * as fs26 from "node:fs";
74588
- var StructuredToolError = class extends Error {
74589
- constructor(message, errorType) {
74590
- super(message);
74591
- this.errorType = errorType;
74592
- }
74593
- static {
74594
- __name(this, "StructuredToolError");
74595
- }
74596
- name = "StructuredToolError";
74597
- };
74598
74685
  async function checkPriorRead(cache, filePath, verb, options2 = {}) {
74599
74686
  let stats;
74600
74687
  try {
@@ -75120,7 +75207,7 @@ var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
75120
75207
  super(
75121
75208
  _WriteFileTool.Name,
75122
75209
  ToolDisplayNames.WRITE_FILE,
75123
- `Writes content to a specified file in the local filesystem. The file_path argument MUST be an absolute path. Always construct it by combining the project root with the file's relative path (e.g. project root '/path/to/project/' + relative 'foo/bar.txt' = '/path/to/project/foo/bar.txt'). If the user provides a relative path, resolve it against the project root first.
75210
+ `Writes content to a specified file in the local filesystem. A request to create or generate a file does not establish that the target path is new. Unless the target's absence or current text contents have already been established in this session, you MUST use the ${ToolNames.READ_FILE} tool first; if the file does not exist, then create it. With prior-read enforcement enabled, blind overwrites are rejected. The file_path argument MUST be an absolute path. Always construct it by combining the project root with the file's relative path (e.g. project root '/path/to/project/' + relative 'foo/bar.txt' = '/path/to/project/foo/bar.txt'). If the user provides a relative path, resolve it against the project root first.
75124
75211
 
75125
75212
  The user has the ability to modify \`content\`. If modified, this will be stated in the response.`,
75126
75213
  "edit" /* Edit */,
@@ -114599,13 +114686,15 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
114599
114686
  const invocation = tool.build(args);
114600
114687
  const toolInvocationGuard = config.getToolInvocationGuard?.();
114601
114688
  if (toolInvocationGuard) {
114689
+ const invocationContext = getInvocationContext();
114602
114690
  const guardDecision = await evaluateToolInvocationGuard(
114603
114691
  toolInvocationGuard,
114604
114692
  {
114605
114693
  callId: persistenceCallId,
114606
114694
  toolName: canonicalToolName2(name),
114607
114695
  args: invocation.params,
114608
- signal: state.abortController.signal
114696
+ signal: state.abortController.signal,
114697
+ ...invocationContext ? { invocationContext } : {}
114609
114698
  }
114610
114699
  );
114611
114700
  if (state.abortController.signal.aborted) {
@@ -130612,18 +130701,6 @@ function extractTextFromPartListUnion(c) {
130612
130701
  return "";
130613
130702
  }
130614
130703
  __name(extractTextFromPartListUnion, "extractTextFromPartListUnion");
130615
- var TOOL_FAILURE_KIND_ATTRIBUTE = "tool.failure_kind";
130616
- var TOOL_FAILURE_KIND_PRE_HOOK_BLOCKED = "pre_hook_blocked";
130617
- var TOOL_FAILURE_KIND_INVOCATION_GUARD_DENIED = "invocation_guard_denied";
130618
- var TOOL_FAILURE_KIND_POST_HOOK_STOPPED = "post_hook_stopped";
130619
- var TOOL_FAILURE_KIND_TOOL_ERROR = "tool_error";
130620
- var TOOL_FAILURE_KIND_TOOL_EXCEPTION = "tool_exception";
130621
- var TOOL_FAILURE_KIND_CANCELLED = "cancelled";
130622
- var TOOL_FAILURE_KIND_PERMISSION_DENIED = "permission_denied";
130623
- var TOOL_FAILURE_KIND_PERMISSION_HOOK_DENIED = "permission_hook_denied";
130624
- var TOOL_FAILURE_KIND_PLAN_MODE_BLOCKED = "plan_mode_blocked";
130625
- var TOOL_FAILURE_KIND_NON_INTERACTIVE_DENIED = "non_interactive_denied";
130626
- var TOOL_FAILURE_KIND_BACKGROUND_AGENT_DENIED = "background_agent_denied";
130627
130704
  var TOOL_SPAN_STATUS_PRE_HOOK_BLOCKED = "Tool execution blocked by hook";
130628
130705
  var TOOL_SPAN_STATUS_INVOCATION_GUARD_DENIED = "Tool execution blocked by host policy";
130629
130706
  var TOOL_SPAN_STATUS_POST_HOOK_STOPPED = "Tool execution stopped by hook";
@@ -130635,8 +130712,9 @@ var TOOL_SPAN_STATUS_BACKGROUND_AGENT_DENIED = "Background agent cannot prompt f
130635
130712
  var TOOL_SPAN_STATUS_TOOL_ERROR = "Tool execution failed";
130636
130713
  var TOOL_SPAN_STATUS_TOOL_EXCEPTION = "Tool execution failed with exception";
130637
130714
  var TOOL_SPAN_STATUS_TOOL_CANCELLED = "Tool execution cancelled by user";
130638
- var TOOL_FAILURE_KIND_TIMEOUT = "timeout";
130639
130715
  var TOOL_SPAN_STATUS_TOOL_TIMEOUT = "Tool execution timed out";
130716
+ var TOOL_CANCELLED_BEFORE_COMPLETION_MESSAGE = "User cancelled tool execution.";
130717
+ var TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE = "The tool had already completed; its output was discarded.";
130640
130718
  function createToolTimeoutResult(timeoutMs) {
130641
130719
  const display = timeoutMs >= 1e3 ? `${Math.round(timeoutMs / 1e3)}s` : `${timeoutMs}ms`;
130642
130720
  const message = `Tool execution timed out after ${display}. The tool may be stuck or operating on too large a scope.`;
@@ -130914,7 +130992,7 @@ __name(toParts2, "toParts");
130914
130992
  var VALIDATION_RETRY_LOOP_THRESHOLD = 3;
130915
130993
  var RETRY_LOOP_STOP_DIRECTIVE = "\n\n\u26A0 RETRY LOOP DETECTED: This tool call has failed validation multiple times with the same error. STOP retrying the same approach. Re-examine the tool schema and parameter requirements, then try a fundamentally different approach. If you cannot resolve the validation error, explain the issue to the user instead of retrying.";
130916
130994
  var TRUNCATION_RETRY_LOOP_DIRECTIVE = "\n\n\u26A0 RETRY LOOP DETECTED: The same truncated file write has been rejected multiple times. STOP resending the same large content. Either split it into smaller write_file + incremental edit calls, or explain to the user that the content is too large to write safely in one call.";
130917
- var createErrorResponse = /* @__PURE__ */ __name((request, error, errorType, artifacts, resultDisplay) => ({
130995
+ var createErrorResponse = /* @__PURE__ */ __name((request, error, errorType, executionStatus, artifacts, resultDisplay) => ({
130918
130996
  callId: request.callId,
130919
130997
  error,
130920
130998
  responseParts: [
@@ -130928,10 +131006,11 @@ var createErrorResponse = /* @__PURE__ */ __name((request, error, errorType, art
130928
131006
  ],
130929
131007
  resultDisplay: resultDisplay ?? error.message,
130930
131008
  errorType,
131009
+ executionStatus,
130931
131010
  contentLength: error.message.length,
130932
131011
  ...artifacts && artifacts.length > 0 ? { artifacts } : {}
130933
131012
  }), "createErrorResponse");
130934
- var createCancelledResponse = /* @__PURE__ */ __name((request, reason, artifacts) => {
131013
+ var createCancelledResponse = /* @__PURE__ */ __name((request, reason, executionStatus, artifacts, persistedOutputFiles, visionBridgeNotice) => {
130935
131014
  const errorMessage = `[Operation Cancelled] Reason: ${reason}`;
130936
131015
  return {
130937
131016
  callId: request.callId,
@@ -130947,8 +131026,11 @@ var createCancelledResponse = /* @__PURE__ */ __name((request, reason, artifacts
130947
131026
  resultDisplay: void 0,
130948
131027
  error: void 0,
130949
131028
  errorType: void 0,
131029
+ executionStatus,
130950
131030
  contentLength: errorMessage.length,
130951
- ...artifacts && artifacts.length > 0 ? { artifacts } : {}
131031
+ ...artifacts && artifacts.length > 0 ? { artifacts } : {},
131032
+ ...persistedOutputFiles !== void 0 ? { persistedOutputFiles } : {},
131033
+ ...visionBridgeNotice !== void 0 ? { visionBridgeNotice } : {}
130952
131034
  };
130953
131035
  }, "createCancelledResponse");
130954
131036
  function isToolCallResponseInfo(value) {
@@ -130965,6 +131047,7 @@ function serializeToolResponse(response) {
130965
131047
  result_display: response.resultDisplay,
130966
131048
  error: response.error?.message,
130967
131049
  error_type: response.errorType,
131050
+ execution_status: response.executionStatus,
130968
131051
  content_length: response.contentLength,
130969
131052
  ...response.visionBridgeNotice !== void 0 ? { vision_bridge_notice: response.visionBridgeNotice } : {}
130970
131053
  };
@@ -131097,15 +131180,19 @@ function withPostToolBatchStop(completedCalls, stopReason) {
131097
131180
  }
131098
131181
  const calls = [...completedCalls];
131099
131182
  const lastCall = calls[calls.length - 1];
131183
+ const executionStatus = lastCall.response.executionStatus;
131184
+ const { executionStatus: _es, ...baseResponse } = createErrorResponse(
131185
+ lastCall.request,
131186
+ new Error(stopReason),
131187
+ "execution_denied" /* EXECUTION_DENIED */,
131188
+ executionStatus ?? "not_started"
131189
+ );
131190
+ const response = executionStatus !== void 0 ? { ...baseResponse, executionStatus } : baseResponse;
131100
131191
  calls[calls.length - 1] = {
131101
131192
  status: "error",
131102
131193
  request: lastCall.request,
131103
131194
  tool: lastCall.tool,
131104
- response: createErrorResponse(
131105
- lastCall.request,
131106
- new Error(stopReason),
131107
- "execution_denied" /* EXECUTION_DENIED */
131108
- ),
131195
+ response,
131109
131196
  durationMs: lastCall.durationMs,
131110
131197
  outcome: void 0
131111
131198
  };
@@ -131167,6 +131254,9 @@ var CoreToolScheduler = class {
131167
131254
  chatRecordingService;
131168
131255
  onToolResultFullTurnModel;
131169
131256
  isFinalizingToolCalls = false;
131257
+ postToolBatchEnabledForBatch = false;
131258
+ postToolBatchSpanCallId;
131259
+ postToolBatchConfigWarned = false;
131170
131260
  isScheduling = false;
131171
131261
  validationRetryCounts = /* @__PURE__ */ new Map();
131172
131262
  autoModeFallbackCallIds = /* @__PURE__ */ new Set();
@@ -131249,7 +131339,7 @@ var CoreToolScheduler = class {
131249
131339
  ...notices.length > 0 ? { visionBridgeNotice: notices.join("\n") } : {}
131250
131340
  };
131251
131341
  }
131252
- setStatusInternal(targetCallId, newStatus, auxiliaryData) {
131342
+ setStatusInternal(targetCallId, newStatus, auxiliaryData, executionStatus) {
131253
131343
  this.toolCalls = this.toolCalls.map((currentCall) => {
131254
131344
  if (currentCall.request.callId !== targetCallId || currentCall.status === "success" || currentCall.status === "error" || currentCall.status === "cancelled") {
131255
131345
  return currentCall;
@@ -131330,8 +131420,11 @@ var CoreToolScheduler = class {
131330
131420
  }
131331
131421
  const preservedResultDisplay = this.compactResultDisplayForInteractiveHistory(resultDisplay);
131332
131422
  const errorMessage = `[Operation Cancelled] Reason: ${auxiliaryData}`;
131333
- const response = isToolCallResponseInfo(auxiliaryData) ? {
131423
+ const response = isToolCallResponseInfo(
131424
+ auxiliaryData
131425
+ ) ? {
131334
131426
  ...auxiliaryData,
131427
+ executionStatus: auxiliaryData.executionStatus ?? executionStatus ?? "not_started",
131335
131428
  resultDisplay: auxiliaryData.resultDisplay ?? preservedResultDisplay
131336
131429
  } : {
131337
131430
  callId: currentCall.request.callId,
@@ -131349,6 +131442,7 @@ var CoreToolScheduler = class {
131349
131442
  resultDisplay: preservedResultDisplay,
131350
131443
  error: void 0,
131351
131444
  errorType: void 0,
131445
+ executionStatus: executionStatus ?? "not_started",
131352
131446
  contentLength: errorMessage.length
131353
131447
  };
131354
131448
  return {
@@ -131394,8 +131488,10 @@ var CoreToolScheduler = class {
131394
131488
  });
131395
131489
  }
131396
131490
  setArgsInternal(targetCallId, args) {
131491
+ let invocationError;
131492
+ let argsUpdated = false;
131397
131493
  this.toolCalls = this.toolCalls.map((call) => {
131398
- if (call.request.callId !== targetCallId || call.status === "error") {
131494
+ if (call.request.callId !== targetCallId || call.status === "success" || call.status === "error" || call.status === "cancelled") {
131399
131495
  return call;
131400
131496
  }
131401
131497
  const invocationOrError = runInRequestGoalContext(
@@ -131408,10 +131504,12 @@ var CoreToolScheduler = class {
131408
131504
  )
131409
131505
  );
131410
131506
  if (invocationOrError instanceof Error) {
131507
+ invocationError = invocationOrError;
131411
131508
  const response = createErrorResponse(
131412
131509
  call.request,
131413
131510
  invocationOrError,
131414
- "invalid_tool_params" /* INVALID_TOOL_PARAMS */
131511
+ "invalid_tool_params" /* INVALID_TOOL_PARAMS */,
131512
+ "not_started"
131415
131513
  );
131416
131514
  return {
131417
131515
  request: { ...call.request, args },
@@ -131420,18 +131518,54 @@ var CoreToolScheduler = class {
131420
131518
  response
131421
131519
  };
131422
131520
  }
131521
+ argsUpdated = true;
131423
131522
  return {
131424
131523
  ...call,
131425
131524
  request: { ...call.request, args },
131426
131525
  invocation: invocationOrError
131427
131526
  };
131428
131527
  });
131528
+ if (invocationError) {
131529
+ this.finalizeBlockedSpan(targetCallId, "error", "system");
131530
+ const toolSpan = this.toolSpans.get(targetCallId);
131531
+ if (toolSpan) {
131532
+ setToolSpanFailure(
131533
+ toolSpan,
131534
+ TOOL_FAILURE_KIND_TOOL_EXCEPTION,
131535
+ invocationError.message
131536
+ );
131537
+ }
131538
+ this.finalizeToolSpan(targetCallId);
131539
+ this.notifyToolCallsUpdate();
131540
+ void this.checkAndNotifyCompletion().catch((error) => {
131541
+ debugLogger122.warn(
131542
+ `setArgsInternal completion notification failed: ${error instanceof Error ? error.message : String(error)}`
131543
+ );
131544
+ });
131545
+ return false;
131546
+ }
131547
+ return argsUpdated;
131429
131548
  }
131430
131549
  isRunning() {
131431
131550
  return this.isFinalizingToolCalls || this.toolCalls.some(
131432
131551
  (call) => call.status === "executing" || call.status === "awaiting_approval"
131433
131552
  );
131434
131553
  }
131554
+ cancelPreExecutionIfAborted(callId, signal, toolSpan = this.toolSpans.get(callId)) {
131555
+ if (!signal.aborted) return false;
131556
+ this.setStatusInternal(
131557
+ callId,
131558
+ "cancelled",
131559
+ "Tool call cancelled by user.",
131560
+ "not_started"
131561
+ );
131562
+ this.finalizeBlockedSpan(callId, "aborted", "system");
131563
+ if (toolSpan) {
131564
+ setToolSpanCancelled(toolSpan);
131565
+ }
131566
+ this.finalizeToolSpan(callId);
131567
+ return true;
131568
+ }
131435
131569
  /**
131436
131570
  * End the tool span for `callId` (if any) and remove it from the map.
131437
131571
  * Centralizes terminal-state cleanup so every cancel/error/success path
@@ -131441,10 +131575,12 @@ var CoreToolScheduler = class {
131441
131575
  * No `metadata` parameter: every caller pre-sets span status via
131442
131576
  * `setToolSpan{Failure,Cancelled,Ok}` before this call (#4321 review).
131443
131577
  */
131444
- finalizeToolSpan(callId) {
131578
+ finalizeToolSpan(callId, force = false) {
131445
131579
  this.bouncedAwaitingApproval.delete(callId);
131446
131580
  this.bouncedToolUseId.delete(callId);
131581
+ this.autoModeFallbackCallIds.delete(callId);
131447
131582
  this.runtimeContentGeneratorViews.delete(callId);
131583
+ if (callId === this.postToolBatchSpanCallId && !force) return;
131448
131584
  const span = this.toolSpans.get(callId);
131449
131585
  if (!span) return;
131450
131586
  this.toolSpans.delete(callId);
@@ -131521,7 +131657,8 @@ var CoreToolScheduler = class {
131521
131657
  this.setStatusInternal(
131522
131658
  callId,
131523
131659
  "cancelled",
131524
- "Tool call cancelled by user."
131660
+ "Tool call cancelled by user.",
131661
+ "not_started"
131525
131662
  );
131526
131663
  if (this.blockedSpans.has(callId)) {
131527
131664
  this.finalizeBlockedSpan(callId, "aborted", "system");
@@ -131529,7 +131666,7 @@ var CoreToolScheduler = class {
131529
131666
  const span = this.toolSpans.get(callId);
131530
131667
  if (span) {
131531
131668
  setToolSpanCancelled(span);
131532
- this.finalizeToolSpan(callId);
131669
+ this.finalizeToolSpan(callId, true);
131533
131670
  }
131534
131671
  this.callIdToPostToolBatchSignal.delete(callId);
131535
131672
  this.autoModeFallbackCallIds.delete(callId);
@@ -131729,6 +131866,13 @@ var CoreToolScheduler = class {
131729
131866
  }
131730
131867
  return this._schedule(request, signal, runtimeView);
131731
131868
  }
131869
+ drainRequestQueueIfIdle() {
131870
+ if (this.requestQueue.length === 0 || this.isScheduling || this.isRunning()) {
131871
+ return;
131872
+ }
131873
+ const next = this.requestQueue.shift();
131874
+ this._schedule(next.request, next.signal, next.runtimeView).then(next.resolve).catch(next.reject);
131875
+ }
131732
131876
  /**
131733
131877
  * Removes all validation retry counters for the given tool. Keys are
131734
131878
  * "<toolName>:<errorMessage>", so a plain `Map.delete(toolName)` would not
@@ -131820,147 +131964,220 @@ var CoreToolScheduler = class {
131820
131964
  return count;
131821
131965
  }, "recordBatchRetryableToolError");
131822
131966
  for (const [requestIndex, reqInfo] of requestsToProcess.entries()) {
131823
- if (planModeEntryBoundaryIndex !== void 0 && requestIndex !== planModeEntryBoundaryIndex) {
131967
+ let resolvedTool;
131968
+ let resolvedInvocation;
131969
+ const recordPrevalidationCancellation = /* @__PURE__ */ __name(() => {
131970
+ if (!signal.aborted) return false;
131824
131971
  newToolCalls.push({
131825
- status: "error",
131826
- request: reqInfo,
131827
- response: createErrorResponse(
131828
- reqInfo,
131829
- new Error(PLAN_MODE_ENTRY_SIBLING_SKIP_MESSAGE),
131830
- "execution_denied" /* EXECUTION_DENIED */
131831
- ),
131832
- durationMs: 0
131833
- });
131834
- continue;
131835
- }
131836
- const canonicalName = canonicalToolName2(reqInfo.name);
131837
- const pm = this.config.getPermissionManager?.();
131838
- if (pm && !await pm.isToolEnabled(canonicalName)) {
131839
- const matchingRule = pm.findMatchingDenyRule({
131840
- toolName: canonicalName
131841
- });
131842
- const ruleInfo = matchingRule ? ` Matching deny rule: "${matchingRule}".` : "";
131843
- const permissionErrorMessage = `Qwen Code requires permission to use "${reqInfo.name}", but that permission was declined.${ruleInfo}`;
131844
- newToolCalls.push({
131845
- status: "error",
131972
+ status: "cancelled",
131846
131973
  request: reqInfo,
131847
- response: createErrorResponse(
131974
+ response: createCancelledResponse(
131848
131975
  reqInfo,
131849
- new Error(permissionErrorMessage),
131850
- "execution_denied" /* EXECUTION_DENIED */
131976
+ "Tool call cancelled before execution.",
131977
+ "not_started"
131851
131978
  ),
131979
+ ...resolvedTool ? { tool: resolvedTool } : {},
131980
+ ...resolvedInvocation ? { invocation: resolvedInvocation } : {},
131852
131981
  durationMs: 0
131853
131982
  });
131854
- continue;
131855
- }
131856
- if (!pm) {
131857
- const excludeTools = this.config.getPermissionsDeny?.() ?? void 0;
131858
- if (excludeTools && excludeTools.length > 0) {
131859
- const normalizedToolName = canonicalName.toLowerCase().trim();
131860
- const excludedMatch = excludeTools.find(
131861
- (excludedTool) => excludedTool.toLowerCase().trim() === normalizedToolName
131862
- );
131863
- if (excludedMatch) {
131864
- const permissionErrorMessage = `Qwen Code requires permission to use ${excludedMatch}, but that permission was declined.`;
131865
- newToolCalls.push({
131866
- status: "error",
131867
- request: reqInfo,
131868
- response: createErrorResponse(
131869
- reqInfo,
131870
- new Error(permissionErrorMessage),
131871
- "execution_denied" /* EXECUTION_DENIED */
131872
- ),
131873
- durationMs: 0
131874
- });
131875
- continue;
131983
+ return true;
131984
+ }, "recordPrevalidationCancellation");
131985
+ try {
131986
+ if (recordPrevalidationCancellation()) continue;
131987
+ if (planModeEntryBoundaryIndex !== void 0 && requestIndex !== planModeEntryBoundaryIndex) {
131988
+ newToolCalls.push({
131989
+ status: "error",
131990
+ request: reqInfo,
131991
+ response: createErrorResponse(
131992
+ reqInfo,
131993
+ new Error(PLAN_MODE_ENTRY_SIBLING_SKIP_MESSAGE),
131994
+ "execution_denied" /* EXECUTION_DENIED */,
131995
+ "not_started"
131996
+ ),
131997
+ durationMs: 0
131998
+ });
131999
+ continue;
132000
+ }
132001
+ const canonicalName = canonicalToolName2(reqInfo.name);
132002
+ const pm = this.config.getPermissionManager?.();
132003
+ const permissionEnabled = pm ? await pm.isToolEnabled(canonicalName) : true;
132004
+ if (recordPrevalidationCancellation()) continue;
132005
+ if (pm && !permissionEnabled) {
132006
+ const matchingRule = pm.findMatchingDenyRule({
132007
+ toolName: canonicalName
132008
+ });
132009
+ const ruleInfo = matchingRule ? ` Matching deny rule: "${matchingRule}".` : "";
132010
+ const permissionErrorMessage = `Qwen Code requires permission to use "${reqInfo.name}", but that permission was declined.${ruleInfo}`;
132011
+ newToolCalls.push({
132012
+ status: "error",
132013
+ request: reqInfo,
132014
+ response: createErrorResponse(
132015
+ reqInfo,
132016
+ new Error(permissionErrorMessage),
132017
+ "execution_denied" /* EXECUTION_DENIED */,
132018
+ "not_started"
132019
+ ),
132020
+ durationMs: 0
132021
+ });
132022
+ continue;
132023
+ }
132024
+ if (!pm) {
132025
+ const excludeTools = this.config.getPermissionsDeny?.() ?? void 0;
132026
+ if (excludeTools && excludeTools.length > 0) {
132027
+ const normalizedToolName = canonicalName.toLowerCase().trim();
132028
+ const excludedMatch = excludeTools.find(
132029
+ (excludedTool) => excludedTool.toLowerCase().trim() === normalizedToolName
132030
+ );
132031
+ if (excludedMatch) {
132032
+ const permissionErrorMessage = `Qwen Code requires permission to use ${excludedMatch}, but that permission was declined.`;
132033
+ newToolCalls.push({
132034
+ status: "error",
132035
+ request: reqInfo,
132036
+ response: createErrorResponse(
132037
+ reqInfo,
132038
+ new Error(permissionErrorMessage),
132039
+ "execution_denied" /* EXECUTION_DENIED */,
132040
+ "not_started"
132041
+ ),
132042
+ durationMs: 0
132043
+ });
132044
+ continue;
132045
+ }
131876
132046
  }
131877
132047
  }
131878
- }
131879
- const toolInstance = await runInRequestGoalContext(
131880
- reqInfo,
131881
- () => this.toolRegistry.ensureTool(canonicalName)
131882
- );
131883
- if (!toolInstance) {
131884
- const errorMessage = await runInRequestGoalContext(
132048
+ const toolInstance = await runInRequestGoalContext(
131885
132049
  reqInfo,
131886
- () => this.getToolNotFoundMessage(reqInfo.name)
132050
+ () => this.toolRegistry.ensureTool(canonicalName)
131887
132051
  );
131888
- newToolCalls.push({
131889
- status: "error",
131890
- request: reqInfo,
131891
- response: createErrorResponse(
132052
+ resolvedTool = toolInstance;
132053
+ if (recordPrevalidationCancellation()) continue;
132054
+ if (!toolInstance) {
132055
+ const errorMessage = await runInRequestGoalContext(
131892
132056
  reqInfo,
131893
- new Error(errorMessage),
131894
- "tool_not_registered" /* TOOL_NOT_REGISTERED */
131895
- ),
131896
- durationMs: 0
131897
- });
131898
- continue;
131899
- }
131900
- if (reqInfo.wasOutputTruncated && toolInstance.kind === "edit" /* Edit */) {
131901
- const count = recordBatchRetryableToolError(
131902
- reqInfo.name,
131903
- TRUNCATION_EDIT_REJECTION
131904
- );
131905
- const truncationError = new Error(
131906
- count >= VALIDATION_RETRY_LOOP_THRESHOLD ? `${TRUNCATION_EDIT_REJECTION}${TRUNCATION_RETRY_LOOP_DIRECTIVE}` : TRUNCATION_EDIT_REJECTION
132057
+ () => this.getToolNotFoundMessage(reqInfo.name)
132058
+ );
132059
+ if (recordPrevalidationCancellation()) continue;
132060
+ newToolCalls.push({
132061
+ status: "error",
132062
+ request: reqInfo,
132063
+ response: createErrorResponse(
132064
+ reqInfo,
132065
+ new Error(errorMessage),
132066
+ "tool_not_registered" /* TOOL_NOT_REGISTERED */,
132067
+ "not_started"
132068
+ ),
132069
+ durationMs: 0
132070
+ });
132071
+ continue;
132072
+ }
132073
+ if (reqInfo.wasOutputTruncated && toolInstance.kind === "edit" /* Edit */) {
132074
+ const count = recordBatchRetryableToolError(
132075
+ reqInfo.name,
132076
+ TRUNCATION_EDIT_REJECTION
132077
+ );
132078
+ const truncationError = new Error(
132079
+ count >= VALIDATION_RETRY_LOOP_THRESHOLD ? `${TRUNCATION_EDIT_REJECTION}${TRUNCATION_RETRY_LOOP_DIRECTIVE}` : TRUNCATION_EDIT_REJECTION
132080
+ );
132081
+ newToolCalls.push({
132082
+ status: "error",
132083
+ request: reqInfo,
132084
+ tool: toolInstance,
132085
+ response: createErrorResponse(
132086
+ reqInfo,
132087
+ truncationError,
132088
+ "output_truncated" /* OUTPUT_TRUNCATED */,
132089
+ "not_started"
132090
+ ),
132091
+ durationMs: 0
132092
+ });
132093
+ continue;
132094
+ }
132095
+ const invocationOrError = runInRequestGoalContext(
132096
+ reqInfo,
132097
+ () => this.buildInvocation(
132098
+ toolInstance,
132099
+ reqInfo.args,
132100
+ reqInfo.callId,
132101
+ reqInfo.prompt_id
132102
+ )
131907
132103
  );
132104
+ if (recordPrevalidationCancellation()) continue;
132105
+ if (invocationOrError instanceof Error) {
132106
+ const displayError = reqInfo.wasOutputTruncated ? new Error(
132107
+ `${invocationOrError.message} ${TRUNCATION_PARAM_GUIDANCE}`
132108
+ ) : invocationOrError;
132109
+ const count = recordBatchRetryableToolError(
132110
+ reqInfo.name,
132111
+ invocationOrError.message
132112
+ );
132113
+ const finalError = count >= VALIDATION_RETRY_LOOP_THRESHOLD ? new Error(
132114
+ `${invocationOrError.message}${RETRY_LOOP_STOP_DIRECTIVE}`
132115
+ ) : displayError;
132116
+ newToolCalls.push({
132117
+ status: "error",
132118
+ request: reqInfo,
132119
+ tool: toolInstance,
132120
+ response: createErrorResponse(
132121
+ reqInfo,
132122
+ finalError,
132123
+ "invalid_tool_params" /* INVALID_TOOL_PARAMS */,
132124
+ "not_started"
132125
+ ),
132126
+ durationMs: 0
132127
+ });
132128
+ continue;
132129
+ }
132130
+ resolvedInvocation = invocationOrError;
132131
+ this.clearRetryCountsForTool(reqInfo.name);
131908
132132
  newToolCalls.push({
131909
- status: "error",
132133
+ status: "validating",
131910
132134
  request: reqInfo,
131911
132135
  tool: toolInstance,
131912
- response: createErrorResponse(
131913
- reqInfo,
131914
- truncationError,
131915
- "output_truncated" /* OUTPUT_TRUNCATED */
131916
- ),
131917
- durationMs: 0
132136
+ invocation: invocationOrError,
132137
+ startTime: Date.now()
131918
132138
  });
131919
- continue;
131920
- }
131921
- const invocationOrError = runInRequestGoalContext(
131922
- reqInfo,
131923
- () => this.buildInvocation(
131924
- toolInstance,
131925
- reqInfo.args,
131926
- reqInfo.callId,
131927
- reqInfo.prompt_id
131928
- )
131929
- );
131930
- if (invocationOrError instanceof Error) {
131931
- const displayError = reqInfo.wasOutputTruncated ? new Error(
131932
- `${invocationOrError.message} ${TRUNCATION_PARAM_GUIDANCE}`
131933
- ) : invocationOrError;
131934
- const count = recordBatchRetryableToolError(
131935
- reqInfo.name,
131936
- invocationOrError.message
131937
- );
131938
- const finalError = count >= VALIDATION_RETRY_LOOP_THRESHOLD ? new Error(
131939
- `${invocationOrError.message}${RETRY_LOOP_STOP_DIRECTIVE}`
131940
- ) : displayError;
132139
+ } catch (error) {
132140
+ if (recordPrevalidationCancellation()) continue;
132141
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
131941
132142
  newToolCalls.push({
131942
132143
  status: "error",
131943
132144
  request: reqInfo,
131944
- tool: toolInstance,
131945
132145
  response: createErrorResponse(
131946
132146
  reqInfo,
131947
- finalError,
131948
- "invalid_tool_params" /* INVALID_TOOL_PARAMS */
132147
+ normalizedError,
132148
+ error?.errorType ?? "unhandled_exception" /* UNHANDLED_EXCEPTION */,
132149
+ "not_started"
131949
132150
  ),
132151
+ ...resolvedTool ? { tool: resolvedTool } : {},
131950
132152
  durationMs: 0
131951
132153
  });
131952
- continue;
131953
132154
  }
131954
- this.clearRetryCountsForTool(reqInfo.name);
131955
- newToolCalls.push({
131956
- status: "validating",
131957
- request: reqInfo,
131958
- tool: toolInstance,
131959
- invocation: invocationOrError,
131960
- startTime: Date.now()
131961
- });
131962
132155
  }
131963
132156
  this.toolCalls = this.toolCalls.concat(newToolCalls);
132157
+ for (const toolCall of newToolCalls) {
132158
+ this.callIdToPostToolBatchSignal.set(toolCall.request.callId, signal);
132159
+ }
132160
+ const postToolBatchParentCallId = newToolCalls.findLast(
132161
+ (toolCall) => toolCall.status === "validating"
132162
+ )?.request.callId;
132163
+ this.postToolBatchEnabledForBatch = false;
132164
+ this.postToolBatchSpanCallId = void 0;
132165
+ try {
132166
+ this.postToolBatchEnabledForBatch = !this.config.getDisableAllHooks() && (this.config.hasHooksForEvent?.("PostToolBatch") ?? false);
132167
+ if (this.postToolBatchEnabledForBatch) {
132168
+ this.postToolBatchSpanCallId = postToolBatchParentCallId;
132169
+ }
132170
+ } catch (configError) {
132171
+ this.postToolBatchEnabledForBatch = true;
132172
+ this.postToolBatchSpanCallId = postToolBatchParentCallId;
132173
+ if (!this.postToolBatchConfigWarned) {
132174
+ this.postToolBatchConfigWarned = true;
132175
+ debugLogger122.warn(
132176
+ "PostToolBatch hook detection failed; deferring span as a precaution:",
132177
+ configError
132178
+ );
132179
+ }
132180
+ }
131964
132181
  this.notifyToolCallsUpdate();
131965
132182
  const batchState = {
131966
132183
  signal,
@@ -131988,16 +132205,8 @@ var CoreToolScheduler = class {
131988
132205
  this.toolSpans.set(reqInfo.callId, toolSpan);
131989
132206
  batchState.callIds.add(reqInfo.callId);
131990
132207
  this.callIdToBatch.set(reqInfo.callId, batchState);
131991
- this.callIdToPostToolBatchSignal.set(reqInfo.callId, signal);
131992
132208
  try {
131993
- if (signal.aborted) {
131994
- this.setStatusInternal(
131995
- reqInfo.callId,
131996
- "cancelled",
131997
- "Tool call cancelled by user."
131998
- );
131999
- setToolSpanCancelled(toolSpan);
132000
- this.finalizeToolSpan(reqInfo.callId);
132209
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132001
132210
  continue;
132002
132211
  }
132003
132212
  let toolParams = invocation.params;
@@ -132010,6 +132219,9 @@ var CoreToolScheduler = class {
132010
132219
  toolParams
132011
132220
  )
132012
132221
  );
132222
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132223
+ continue;
132224
+ }
132013
132225
  const {
132014
132226
  defaultPermission,
132015
132227
  finalPermission,
@@ -132054,7 +132266,8 @@ var CoreToolScheduler = class {
132054
132266
  createErrorResponse(
132055
132267
  reqInfo,
132056
132268
  new Error(message),
132057
- "execution_denied" /* EXECUTION_DENIED */
132269
+ "execution_denied" /* EXECUTION_DENIED */,
132270
+ "not_started"
132058
132271
  )
132059
132272
  );
132060
132273
  setToolSpanFailure(
@@ -132072,7 +132285,8 @@ var CoreToolScheduler = class {
132072
132285
  createErrorResponse(
132073
132286
  reqInfo,
132074
132287
  new Error(denyMessage ?? `Tool "${reqInfo.name}" is denied.`),
132075
- "execution_denied" /* EXECUTION_DENIED */
132288
+ "execution_denied" /* EXECUTION_DENIED */,
132289
+ "not_started"
132076
132290
  )
132077
132291
  );
132078
132292
  setToolSpanFailure(
@@ -132105,12 +132319,16 @@ var CoreToolScheduler = class {
132105
132319
  signal
132106
132320
  })
132107
132321
  ) : { classification: "not-applicable" };
132322
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132323
+ continue;
132324
+ }
132108
132325
  const rejectPlanShell = /* @__PURE__ */ __name((message) => {
132109
132326
  this.setStatusInternal(reqInfo.callId, "error", {
132110
132327
  ...createErrorResponse(
132111
132328
  reqInfo,
132112
132329
  new Error(message),
132113
- "execution_denied" /* EXECUTION_DENIED */
132330
+ "execution_denied" /* EXECUTION_DENIED */,
132331
+ "not_started"
132114
132332
  ),
132115
132333
  resultDisplay: message
132116
132334
  });
@@ -132132,6 +132350,9 @@ var CoreToolScheduler = class {
132132
132350
  signal
132133
132351
  })
132134
132352
  );
132353
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132354
+ continue;
132355
+ }
132135
132356
  if (initialPlanShellError) {
132136
132357
  rejectPlanShell(initialPlanShellError);
132137
132358
  continue;
@@ -132172,6 +132393,9 @@ var CoreToolScheduler = class {
132172
132393
  skipClassifierReason: fallback.fallback ? fallback.reason : void 0
132173
132394
  })
132174
132395
  );
132396
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132397
+ continue;
132398
+ }
132175
132399
  const outcome = applyAutoModeDecision(
132176
132400
  decision,
132177
132401
  this.config,
@@ -132196,6 +132420,9 @@ var CoreToolScheduler = class {
132196
132420
  );
132197
132421
  }
132198
132422
  }
132423
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132424
+ continue;
132425
+ }
132199
132426
  switch (outcome.kind) {
132200
132427
  case "approved":
132201
132428
  this.setToolCallOutcome(
@@ -132214,9 +132441,16 @@ var CoreToolScheduler = class {
132214
132441
  createErrorResponse(
132215
132442
  reqInfo,
132216
132443
  new Error(outcome.errorMessage),
132217
- "execution_denied" /* EXECUTION_DENIED */
132444
+ "execution_denied" /* EXECUTION_DENIED */,
132445
+ "not_started"
132218
132446
  )
132219
132447
  );
132448
+ setToolSpanFailure(
132449
+ toolSpan,
132450
+ TOOL_FAILURE_KIND_PERMISSION_DENIED,
132451
+ outcome.errorMessage
132452
+ );
132453
+ this.finalizeToolSpan(reqInfo.callId);
132220
132454
  continue;
132221
132455
  case "fallback":
132222
132456
  if (isDenialFallbackReason(outcome.reason) || outcome.reason === "classifier_unavailable") {
@@ -132251,6 +132485,9 @@ var CoreToolScheduler = class {
132251
132485
  reqInfo,
132252
132486
  () => invocation.getConfirmationDetails(signal)
132253
132487
  );
132488
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132489
+ continue;
132490
+ }
132254
132491
  if (autoModeFallbackMessage) {
132255
132492
  confirmationDetails = decorateClassifierUnavailableConfirmation(
132256
132493
  confirmationDetails,
@@ -132268,6 +132505,13 @@ var CoreToolScheduler = class {
132268
132505
  signal
132269
132506
  })
132270
132507
  );
132508
+ if (this.cancelPreExecutionIfAborted(
132509
+ reqInfo.callId,
132510
+ signal,
132511
+ toolSpan
132512
+ )) {
132513
+ continue;
132514
+ }
132271
132515
  if (preDisplayPlanShellError) {
132272
132516
  rejectPlanShell(preDisplayPlanShellError);
132273
132517
  continue;
@@ -132301,7 +132545,8 @@ var CoreToolScheduler = class {
132301
132545
  ...createErrorResponse(
132302
132546
  reqInfo,
132303
132547
  planModeError,
132304
- "execution_denied" /* EXECUTION_DENIED */
132548
+ "execution_denied" /* EXECUTION_DENIED */,
132549
+ "not_started"
132305
132550
  ),
132306
132551
  resultDisplay: "Plan mode blocked a non-read-only tool call."
132307
132552
  });
@@ -132334,7 +132579,8 @@ var CoreToolScheduler = class {
132334
132579
  createErrorResponse(
132335
132580
  reqInfo,
132336
132581
  new Error(errorMessage),
132337
- "execution_denied" /* EXECUTION_DENIED */
132582
+ "execution_denied" /* EXECUTION_DENIED */,
132583
+ "not_started"
132338
132584
  )
132339
132585
  );
132340
132586
  setToolSpanFailure(
@@ -132361,6 +132607,13 @@ var CoreToolScheduler = class {
132361
132607
  signal
132362
132608
  )
132363
132609
  );
132610
+ if (this.cancelPreExecutionIfAborted(
132611
+ reqInfo.callId,
132612
+ signal,
132613
+ toolSpan
132614
+ )) {
132615
+ continue;
132616
+ }
132364
132617
  if (hookResult.hasDecision && (!hookResult.shouldAllow || !requiresUserInteraction)) {
132365
132618
  if (hookResult.shouldAllow) {
132366
132619
  if (planShellDecision.classification !== "not-applicable") {
@@ -132376,6 +132629,13 @@ var CoreToolScheduler = class {
132376
132629
  payload: hookResult.updatedInput ? { updatedInput: hookResult.updatedInput } : void 0
132377
132630
  })
132378
132631
  );
132632
+ if (this.cancelPreExecutionIfAborted(
132633
+ reqInfo.callId,
132634
+ signal,
132635
+ toolSpan
132636
+ )) {
132637
+ continue;
132638
+ }
132379
132639
  if (approval.outcome === "cancel" /* Cancel */) {
132380
132640
  await runInRequestGoalContext(
132381
132641
  reqInfo,
@@ -132384,6 +132644,13 @@ var CoreToolScheduler = class {
132384
132644
  approval.payload
132385
132645
  )
132386
132646
  );
132647
+ if (this.cancelPreExecutionIfAborted(
132648
+ reqInfo.callId,
132649
+ signal,
132650
+ toolSpan
132651
+ )) {
132652
+ continue;
132653
+ }
132387
132654
  rejectPlanShell(
132388
132655
  approval.payload?.cancelMessage ?? planShellDecision.noApprovalMessage
132389
132656
  );
@@ -132396,6 +132663,13 @@ var CoreToolScheduler = class {
132396
132663
  approval.payload
132397
132664
  )
132398
132665
  );
132666
+ if (this.cancelPreExecutionIfAborted(
132667
+ reqInfo.callId,
132668
+ signal,
132669
+ toolSpan
132670
+ )) {
132671
+ continue;
132672
+ }
132399
132673
  this.recordAutoModeFallbackResolution(
132400
132674
  reqInfo.callId,
132401
132675
  approval.outcome
@@ -132405,10 +132679,12 @@ var CoreToolScheduler = class {
132405
132679
  continue;
132406
132680
  }
132407
132681
  if (hookResult.updatedInput && typeof reqInfo.args === "object") {
132408
- this.setArgsInternal(
132682
+ if (!this.setArgsInternal(
132409
132683
  reqInfo.callId,
132410
132684
  hookResult.updatedInput
132411
- );
132685
+ )) {
132686
+ continue;
132687
+ }
132412
132688
  }
132413
132689
  await runInRequestGoalContext(
132414
132690
  reqInfo,
@@ -132416,6 +132692,13 @@ var CoreToolScheduler = class {
132416
132692
  "proceed_once" /* ProceedOnce */
132417
132693
  )
132418
132694
  );
132695
+ if (this.cancelPreExecutionIfAborted(
132696
+ reqInfo.callId,
132697
+ signal,
132698
+ toolSpan
132699
+ )) {
132700
+ continue;
132701
+ }
132419
132702
  this.recordAutoModeFallbackResolution(
132420
132703
  reqInfo.callId,
132421
132704
  "proceed_once" /* ProceedOnce */
@@ -132434,6 +132717,13 @@ var CoreToolScheduler = class {
132434
132717
  cancelPayload
132435
132718
  )
132436
132719
  );
132720
+ if (this.cancelPreExecutionIfAborted(
132721
+ reqInfo.callId,
132722
+ signal,
132723
+ toolSpan
132724
+ )) {
132725
+ continue;
132726
+ }
132437
132727
  this.recordAutoModeFallbackResolution(
132438
132728
  reqInfo.callId,
132439
132729
  "cancel" /* Cancel */
@@ -132450,7 +132740,8 @@ var CoreToolScheduler = class {
132450
132740
  new Error(
132451
132741
  hookResult.denyMessage || `Permission denied by hook for "${reqInfo.name}"`
132452
132742
  ),
132453
- "execution_denied" /* EXECUTION_DENIED */
132743
+ "execution_denied" /* EXECUTION_DENIED */,
132744
+ "not_started"
132454
132745
  )
132455
132746
  );
132456
132747
  setToolSpanFailure(
@@ -132475,7 +132766,8 @@ var CoreToolScheduler = class {
132475
132766
  createErrorResponse(
132476
132767
  reqInfo,
132477
132768
  new Error(errorMessage),
132478
- "execution_denied" /* EXECUTION_DENIED */
132769
+ "execution_denied" /* EXECUTION_DENIED */,
132770
+ "not_started"
132479
132771
  )
132480
132772
  );
132481
132773
  setToolSpanFailure(
@@ -132486,14 +132778,7 @@ var CoreToolScheduler = class {
132486
132778
  this.finalizeToolSpan(reqInfo.callId);
132487
132779
  continue;
132488
132780
  }
132489
- if (signal.aborted) {
132490
- this.setStatusInternal(
132491
- reqInfo.callId,
132492
- "cancelled",
132493
- "Tool call cancelled by user."
132494
- );
132495
- setToolSpanCancelled(toolSpan);
132496
- this.finalizeToolSpan(reqInfo.callId);
132781
+ if (this.cancelPreExecutionIfAborted(reqInfo.callId, signal, toolSpan)) {
132497
132782
  continue;
132498
132783
  }
132499
132784
  if (planShellDecision.classification !== "not-applicable") {
@@ -132507,6 +132792,13 @@ var CoreToolScheduler = class {
132507
132792
  signal
132508
132793
  })
132509
132794
  );
132795
+ if (this.cancelPreExecutionIfAborted(
132796
+ reqInfo.callId,
132797
+ signal,
132798
+ toolSpan
132799
+ )) {
132800
+ continue;
132801
+ }
132510
132802
  if (finalPreDisplayPlanShellError) {
132511
132803
  rejectPlanShell(finalPreDisplayPlanShellError);
132512
132804
  continue;
@@ -132593,7 +132885,8 @@ var CoreToolScheduler = class {
132593
132885
  this.setStatusInternal(
132594
132886
  reqInfo.callId,
132595
132887
  "cancelled",
132596
- "Tool call cancelled by user."
132888
+ "Tool call cancelled by user.",
132889
+ "not_started"
132597
132890
  );
132598
132891
  this.finalizeBlockedSpan(reqInfo.callId, "aborted", "system");
132599
132892
  setToolSpanCancelled(toolSpan);
@@ -132607,7 +132900,8 @@ var CoreToolScheduler = class {
132607
132900
  createErrorResponse(
132608
132901
  reqInfo,
132609
132902
  error instanceof Error ? error : new Error(String(error)),
132610
- explicitErrorType ?? "unhandled_exception" /* UNHANDLED_EXCEPTION */
132903
+ explicitErrorType ?? "unhandled_exception" /* UNHANDLED_EXCEPTION */,
132904
+ "not_started"
132611
132905
  )
132612
132906
  );
132613
132907
  this.finalizeBlockedSpan(reqInfo.callId, "error", "system");
@@ -132630,6 +132924,7 @@ var CoreToolScheduler = class {
132630
132924
  }
132631
132925
  } finally {
132632
132926
  this.isScheduling = false;
132927
+ this.drainRequestQueueIfIdle();
132633
132928
  }
132634
132929
  }
132635
132930
  async handleConfirmationResponse(callId, originalOnConfirm, outcome, signal, payload) {
@@ -132673,6 +132968,25 @@ var CoreToolScheduler = class {
132673
132968
  );
132674
132969
  } catch (error) {
132675
132970
  const aborted = signal.aborted;
132971
+ if (aborted) {
132972
+ this.setStatusInternal(
132973
+ callId,
132974
+ "cancelled",
132975
+ "Tool call cancelled by user.",
132976
+ "not_started"
132977
+ );
132978
+ } else {
132979
+ this.setStatusInternal(
132980
+ callId,
132981
+ "error",
132982
+ createErrorResponse(
132983
+ toolCall.request,
132984
+ error instanceof Error ? error : new Error(String(error)),
132985
+ "unhandled_exception" /* UNHANDLED_EXCEPTION */,
132986
+ "not_started"
132987
+ )
132988
+ );
132989
+ }
132676
132990
  this.finalizeBlockedSpan(callId, aborted ? "aborted" : "error", "system");
132677
132991
  const toolSpan = this.toolSpans.get(callId);
132678
132992
  if (toolSpan) {
@@ -132716,7 +133030,7 @@ var CoreToolScheduler = class {
132716
133030
  this.recordAutoModeFallbackResolution(callId, outcome);
132717
133031
  if (outcome === "cancel" /* Cancel */ || signal.aborted) {
132718
133032
  const cancelMessage = payload?.cancelMessage || "User did not allow tool call";
132719
- this.setStatusInternal(callId, "cancelled", cancelMessage);
133033
+ this.setStatusInternal(callId, "cancelled", cancelMessage, "not_started");
132720
133034
  const toolSpan = this.toolSpans.get(callId);
132721
133035
  if (toolSpan) {
132722
133036
  setToolSpanCancelled(toolSpan);
@@ -132771,7 +133085,7 @@ var CoreToolScheduler = class {
132771
133085
  signal,
132772
133086
  this.onEditorClose
132773
133087
  );
132774
- this.setArgsInternal(callId, updatedParams);
133088
+ if (!this.setArgsInternal(callId, updatedParams)) return;
132775
133089
  this.setStatusInternal(callId, "awaiting_approval", {
132776
133090
  ...waitingToolCall.confirmationDetails,
132777
133091
  fileDiff: updatedDiff,
@@ -132780,11 +133094,13 @@ var CoreToolScheduler = class {
132780
133094
  }
132781
133095
  } else {
132782
133096
  if (payload?.newContent && toolCall) {
132783
- await this._applyInlineModify(
133097
+ if (!await this._applyInlineModify(
132784
133098
  toolCall,
132785
133099
  payload,
132786
133100
  signal
132787
- );
133101
+ )) {
133102
+ return;
133103
+ }
132788
133104
  }
132789
133105
  this.setStatusInternal(callId, "scheduled");
132790
133106
  const decision = outcome === "proceed_once" /* ProceedOnce */ ? "proceed_once" : "proceed_always";
@@ -132868,7 +133184,7 @@ var CoreToolScheduler = class {
132868
133184
  async _applyInlineModify(toolCall, payload, signal) {
132869
133185
  const confirmDetails = toolCall.confirmationDetails;
132870
133186
  if (confirmDetails.type !== "edit" || !isModifiableDeclarativeTool(toolCall.tool) || !payload.newContent) {
132871
- return;
133187
+ return true;
132872
133188
  }
132873
133189
  const currentContent = confirmDetails.originalContent ?? "";
132874
133190
  const modifyContext = toolCall.tool.getModifyContext(signal);
@@ -132884,11 +133200,14 @@ var CoreToolScheduler = class {
132884
133200
  "Current",
132885
133201
  "Proposed"
132886
133202
  );
132887
- this.setArgsInternal(toolCall.request.callId, updatedParams);
133203
+ if (!this.setArgsInternal(toolCall.request.callId, updatedParams)) {
133204
+ return false;
133205
+ }
132888
133206
  this.setStatusInternal(toolCall.request.callId, "awaiting_approval", {
132889
133207
  ...confirmDetails,
132890
133208
  fileDiff: updatedDiff
132891
133209
  });
133210
+ return true;
132892
133211
  }
132893
133212
  async attemptExecutionOfScheduledCalls(signal) {
132894
133213
  while (true) {
@@ -133002,10 +133321,10 @@ var CoreToolScheduler = class {
133002
133321
  createErrorResponse(
133003
133322
  scheduledCall.request,
133004
133323
  error instanceof Error ? error : new Error(errorMessage),
133005
- "unhandled_exception" /* UNHANDLED_EXCEPTION */
133324
+ "unhandled_exception" /* UNHANDLED_EXCEPTION */,
133325
+ this.toolCalls.find((call) => call.request.callId === callId)?.status === "executing" ? "error" : "not_started"
133006
133326
  )
133007
133327
  );
133008
- throw error;
133009
133328
  } finally {
133010
133329
  if (!this.bouncedAwaitingApproval.has(callId)) {
133011
133330
  this.finalizeToolSpan(callId);
@@ -133145,7 +133464,7 @@ var CoreToolScheduler = class {
133145
133464
  hasAdditionalContext: !!r.additionalContext
133146
133465
  }
133147
133466
  );
133148
- if (!preHookResult.shouldProceed) {
133467
+ if (!signal.aborted && !preHookResult.shouldProceed) {
133149
133468
  if (preHookResult.blockType === "ask" && !signal.aborted && this.canPromptForAskBounce()) {
133150
133469
  this.bouncedToolUseId.set(callId, toolUseId);
133151
133470
  this.bounceToAwaitingApprovalForAsk(
@@ -133160,7 +133479,8 @@ var CoreToolScheduler = class {
133160
133479
  const errorResponse = createErrorResponse(
133161
133480
  scheduledCall.request,
133162
133481
  new Error(blockMessage),
133163
- "execution_denied" /* EXECUTION_DENIED */
133482
+ "execution_denied" /* EXECUTION_DENIED */,
133483
+ "not_started"
133164
133484
  );
133165
133485
  this.setStatusInternal(callId, "error", errorResponse);
133166
133486
  setToolSpanFailure(
@@ -133173,29 +133493,38 @@ var CoreToolScheduler = class {
133173
133493
  }
133174
133494
  const toolInvocationGuard = this.config.getToolInvocationGuard?.();
133175
133495
  if (toolInvocationGuard) {
133496
+ const invocationContext = getInvocationContext();
133176
133497
  const guardDecision = await evaluateToolInvocationGuard(
133177
133498
  toolInvocationGuard,
133178
133499
  {
133179
133500
  callId,
133180
133501
  toolName: canonicalName,
133181
133502
  args: invocation.params,
133182
- signal
133503
+ signal,
133504
+ ...invocationContext ? { invocationContext } : {}
133183
133505
  }
133184
133506
  );
133185
133507
  if (signal.aborted) {
133186
133508
  this.setStatusInternal(
133187
133509
  callId,
133188
133510
  "cancelled",
133189
- "Tool call cancelled by user."
133511
+ createCancelledResponse(
133512
+ scheduledCall.request,
133513
+ "Tool call cancelled before execution.",
133514
+ "not_started"
133515
+ )
133190
133516
  );
133191
- setToolSpanCancelled(span);
133517
+ if (this.toolSpans.has(callId)) {
133518
+ setToolSpanCancelled(span);
133519
+ }
133192
133520
  return;
133193
133521
  }
133194
133522
  if (!guardDecision.allowed) {
133195
133523
  const errorResponse = createErrorResponse(
133196
133524
  scheduledCall.request,
133197
133525
  new Error(guardDecision.reason),
133198
- "execution_denied" /* EXECUTION_DENIED */
133526
+ "execution_denied" /* EXECUTION_DENIED */,
133527
+ "not_started"
133199
133528
  );
133200
133529
  this.setStatusInternal(callId, "error", errorResponse);
133201
133530
  setToolSpanFailure(
@@ -133206,7 +133535,26 @@ var CoreToolScheduler = class {
133206
133535
  return;
133207
133536
  }
133208
133537
  }
133209
- this.setStatusInternal(callId, "executing");
133538
+ if (signal.aborted) {
133539
+ const currentCall = this.toolCalls.find(
133540
+ (call) => call.request.callId === callId
133541
+ );
133542
+ if (currentCall && currentCall.status !== "success" && currentCall.status !== "error" && currentCall.status !== "cancelled") {
133543
+ this.setStatusInternal(
133544
+ callId,
133545
+ "cancelled",
133546
+ createCancelledResponse(
133547
+ scheduledCall.request,
133548
+ "Tool call cancelled before execution.",
133549
+ "not_started"
133550
+ )
133551
+ );
133552
+ if (this.toolSpans.has(callId)) {
133553
+ setToolSpanCancelled(span);
133554
+ }
133555
+ }
133556
+ return;
133557
+ }
133210
133558
  const liveOutputCallback = scheduledCall.tool.canUpdateOutput ? (outputChunk) => {
133211
133559
  if (isShellProgressData(outputChunk)) {
133212
133560
  if (this.outputUpdateHandler) {
@@ -133224,12 +133572,14 @@ var CoreToolScheduler = class {
133224
133572
  this.notifyToolCallsUpdate();
133225
133573
  } : void 0;
133226
133574
  const shellExecutionConfig = this.config.getShellExecutionConfig();
133227
- const execSpan = startToolExecutionSpan();
133228
133575
  const sleepInhibitorHandle = acquireSleepInhibitor(
133229
133576
  this.config,
133230
133577
  `Qwen Code is executing tool ${canonicalName}`
133231
133578
  );
133232
133579
  let removeParentAbortForward;
133580
+ let executionStatus = "not_started";
133581
+ let executionSettled = false;
133582
+ let execSpan;
133233
133583
  try {
133234
133584
  let promise;
133235
133585
  const toolExecutionTimeoutMs = Math.min(
@@ -133280,30 +133630,40 @@ var CoreToolScheduler = class {
133280
133630
  this.safelyAddToolArgumentsAttributes(span, invocation.params);
133281
133631
  promise = todoWorkChainContext.run(
133282
133632
  todoWorkChainId,
133283
- () => promptIdContext.run(
133284
- scheduledCall.request.prompt_id,
133285
- () => invocation.execute(
133633
+ () => promptIdContext.run(scheduledCall.request.prompt_id, () => {
133634
+ this.setStatusInternal(callId, "executing");
133635
+ execSpan = startToolExecutionSpan({
133636
+ toolName: canonicalName,
133637
+ callId
133638
+ });
133639
+ executionStatus = "error";
133640
+ return invocation.execute(
133286
133641
  execSignal,
133287
133642
  liveOutputCallback,
133288
133643
  shellExecutionConfig,
133289
133644
  setPidCallback,
133290
133645
  setPromoteAbortControllerCallback,
133291
133646
  canPromoteForegroundShell
133292
- )
133293
- )
133647
+ );
133648
+ })
133294
133649
  );
133295
133650
  } else {
133296
133651
  this.safelyAddToolArgumentsAttributes(span, invocation.params);
133297
133652
  promise = todoWorkChainContext.run(
133298
133653
  todoWorkChainId,
133299
- () => promptIdContext.run(
133300
- scheduledCall.request.prompt_id,
133301
- () => invocation.execute(
133654
+ () => promptIdContext.run(scheduledCall.request.prompt_id, () => {
133655
+ this.setStatusInternal(callId, "executing");
133656
+ execSpan = startToolExecutionSpan({
133657
+ toolName: canonicalName,
133658
+ callId
133659
+ });
133660
+ executionStatus = "error";
133661
+ return invocation.execute(
133302
133662
  execSignal,
133303
133663
  liveOutputCallback,
133304
133664
  shellExecutionConfig
133305
- )
133306
- )
133665
+ );
133666
+ })
133307
133667
  );
133308
133668
  }
133309
133669
  let toolResult;
@@ -133338,14 +133698,24 @@ var CoreToolScheduler = class {
133338
133698
  toolResult = await promise;
133339
133699
  }
133340
133700
  const isTimeout = toolResult.error?.type === "execution_timeout" /* EXECUTION_TIMEOUT */ && (!schedulerTimeoutResultSelected || schedulerTimeoutWon);
133341
- const aborted = signal.aborted && !isTimeout;
133342
- endToolExecutionSpan(execSpan, {
133343
- success: toolResult.error === void 0 && !aborted,
133344
- error: aborted ? TOOL_SPAN_STATUS_TOOL_CANCELLED : isTimeout ? TOOL_SPAN_STATUS_TOOL_TIMEOUT : toolResult.error ? TOOL_SPAN_STATUS_TOOL_ERROR : void 0,
133345
- cancelled: aborted
133346
- });
133701
+ const parentAbortedAtExecutionSettle = signal.aborted;
133702
+ const aborted = parentAbortedAtExecutionSettle && !isTimeout;
133703
+ const executionErrorType = toolResult.error ? toolResult.error.type ?? (scheduledCall.tool instanceof DiscoveredMCPTool ? "mcp_tool_error" /* MCP_TOOL_ERROR */ : "unknown" /* UNKNOWN */) : void 0;
133704
+ executionStatus = aborted ? "cancelled" : toolResult.error ? "error" : "success";
133705
+ executionSettled = true;
133706
+ if (execSpan) {
133707
+ const completedExecSpan = execSpan;
133708
+ execSpan = void 0;
133709
+ endToolExecutionSpan(completedExecSpan, {
133710
+ success: executionStatus === "success",
133711
+ error: aborted ? TOOL_SPAN_STATUS_TOOL_CANCELLED : isTimeout ? TOOL_SPAN_STATUS_TOOL_TIMEOUT : toolResult.error ? TOOL_SPAN_STATUS_TOOL_ERROR : void 0,
133712
+ cancelled: aborted,
133713
+ executionStatus,
133714
+ errorType: executionErrorType
133715
+ });
133716
+ }
133347
133717
  if (aborted) {
133348
- let cancelMessage = "User cancelled tool execution.";
133718
+ let cancelMessage = TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE;
133349
133719
  let failureHookArtifacts;
133350
133720
  if (hooksEnabled && messageBus) {
133351
133721
  const failureHookResult = await this.withHookSpan(
@@ -133377,15 +133747,37 @@ ${failureHookResult.additionalContext}`;
133377
133747
  this.setStatusInternal(
133378
133748
  callId,
133379
133749
  "cancelled",
133380
- failureHookArtifacts && failureHookArtifacts.length > 0 ? createCancelledResponse(
133750
+ createCancelledResponse(
133381
133751
  scheduledCall.request,
133382
133752
  cancelMessage,
133383
- failureHookArtifacts
133384
- ) : cancelMessage
133753
+ executionStatus,
133754
+ failureHookArtifacts,
133755
+ toolResult.persistedOutputFiles
133756
+ )
133385
133757
  );
133386
133758
  setToolSpanCancelled(span);
133387
133759
  return;
133388
133760
  }
133761
+ const cancelAfterPostProcessing = /* @__PURE__ */ __name((artifacts, preserved) => {
133762
+ if (!signal.aborted || isTimeout && parentAbortedAtExecutionSettle) {
133763
+ return false;
133764
+ }
133765
+ this.setStatusInternal(
133766
+ callId,
133767
+ "cancelled",
133768
+ createCancelledResponse(
133769
+ scheduledCall.request,
133770
+ // Reached only after `execute()` settled with a result.
133771
+ TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE,
133772
+ executionStatus,
133773
+ artifacts,
133774
+ preserved?.persistedOutputFiles,
133775
+ preserved?.visionBridgeNotice
133776
+ )
133777
+ );
133778
+ setToolSpanCancelled(span);
133779
+ return true;
133780
+ }, "cancelAfterPostProcessing");
133389
133781
  if (toolResult.error === void 0) {
133390
133782
  let content = toolResult.llmContent ?? "";
133391
133783
  let persistedOutputFiles = toolResult.persistedOutputFiles ? [...toolResult.persistedOutputFiles] : toolResult.persistedOutputFiles;
@@ -133442,12 +133834,21 @@ ${failureHookResult.additionalContext}`;
133442
133834
  postToolUseArtifacts = postHookResult.artifacts;
133443
133835
  }
133444
133836
  if (postHookResult.shouldStop) {
133837
+ if (cancelAfterPostProcessing(postHookResult.artifacts, {
133838
+ persistedOutputFiles
133839
+ })) {
133840
+ return;
133841
+ }
133445
133842
  const stopMessage = postHookResult.stopReason || "Execution stopped by hook";
133446
133843
  const errorResponse = createErrorResponse(
133447
133844
  scheduledCall.request,
133448
133845
  new Error(stopMessage),
133449
- "execution_denied" /* EXECUTION_DENIED */
133846
+ "execution_denied" /* EXECUTION_DENIED */,
133847
+ executionStatus
133450
133848
  );
133849
+ if (persistedOutputFiles !== void 0) {
133850
+ errorResponse.persistedOutputFiles = persistedOutputFiles;
133851
+ }
133451
133852
  this.setStatusInternal(callId, "error", errorResponse);
133452
133853
  setToolSpanFailure(
133453
133854
  span,
@@ -133613,6 +134014,7 @@ ${body}
133613
134014
  ),
133614
134015
  error: void 0,
133615
134016
  errorType: void 0,
134017
+ executionStatus,
133616
134018
  contentLength,
133617
134019
  ...persistedOutputFiles !== void 0 ? { persistedOutputFiles } : {},
133618
134020
  // Propagate modelOverride from skill tools. Use `in` to distinguish
@@ -133644,6 +134046,12 @@ ${body}
133644
134046
  );
133645
134047
  }
133646
134048
  }
134049
+ if (cancelAfterPostProcessing(artifacts, {
134050
+ persistedOutputFiles: successResponse.persistedOutputFiles,
134051
+ visionBridgeNotice: successResponse.visionBridgeNotice
134052
+ })) {
134053
+ return;
134054
+ }
133647
134055
  this.setStatusInternal(callId, "success", successResponse);
133648
134056
  safeSetStatus(span, { code: SpanStatusCode.OK });
133649
134057
  try {
@@ -133732,6 +134140,12 @@ ${failureHookResult.additionalContext}`;
133732
134140
  ...timeoutContent.persistedOutputFiles ?? []
133733
134141
  ])
133734
134142
  );
134143
+ if (cancelAfterPostProcessing(artifacts, {
134144
+ persistedOutputFiles: timeoutPersistedOutputFiles,
134145
+ visionBridgeNotice: processedImages.visionBridgeNotice
134146
+ })) {
134147
+ return;
134148
+ }
133735
134149
  this.setStatusInternal(callId, "error", {
133736
134150
  callId,
133737
134151
  responseParts,
@@ -133740,6 +134154,7 @@ ${failureHookResult.additionalContext}`;
133740
134154
  ),
133741
134155
  error: new Error(operationalErrorMessage),
133742
134156
  errorType: "execution_timeout" /* EXECUTION_TIMEOUT */,
134157
+ executionStatus,
133743
134158
  contentLength,
133744
134159
  ...timeoutPersistedOutputFiles !== void 0 ? { persistedOutputFiles: timeoutPersistedOutputFiles } : {},
133745
134160
  ...processedImages.modelOverride !== void 0 ? { modelOverride: processedImages.modelOverride } : {},
@@ -133773,7 +134188,8 @@ ${failureHookResult.additionalContext}`;
133773
134188
  let errorResponse = createErrorResponse(
133774
134189
  scheduledCall.request,
133775
134190
  error,
133776
- toolResult.error.type ?? "unknown" /* UNKNOWN */,
134191
+ executionErrorType ?? "unknown" /* UNKNOWN */,
134192
+ executionStatus,
133777
134193
  failureHookArtifacts,
133778
134194
  typeof toolResult.returnDisplay === "string" ? void 0 : this.compactResultDisplayForInteractiveHistory(
133779
134195
  toolResult.returnDisplay
@@ -133821,6 +134237,15 @@ ${failureHookResult.additionalContext}`;
133821
134237
  };
133822
134238
  }
133823
134239
  }
134240
+ if (cancelAfterPostProcessing(
134241
+ [...toolResult.artifacts ?? [], ...failureHookArtifacts ?? []],
134242
+ {
134243
+ persistedOutputFiles: errorResponse.persistedOutputFiles,
134244
+ visionBridgeNotice: errorResponse.visionBridgeNotice
134245
+ }
134246
+ )) {
134247
+ return;
134248
+ }
133824
134249
  this.setStatusInternal(callId, "error", errorResponse);
133825
134250
  setToolSpanFailure(
133826
134251
  span,
@@ -133830,14 +134255,28 @@ ${failureHookResult.additionalContext}`;
133830
134255
  }
133831
134256
  } catch (executionError) {
133832
134257
  const errorMessage = executionError instanceof Error ? executionError.message : String(executionError);
133833
- const aborted = signal.aborted;
133834
- endToolExecutionSpan(execSpan, {
133835
- success: false,
133836
- error: aborted ? TOOL_SPAN_STATUS_TOOL_CANCELLED : TOOL_SPAN_STATUS_TOOL_EXCEPTION,
133837
- cancelled: aborted
133838
- });
134258
+ const executionThrew = !executionSettled && executionStatus !== "not_started";
134259
+ const explicitErrorType = executionError?.errorType;
134260
+ const executionTimedOut = executionThrew && explicitErrorType === "execution_timeout" /* EXECUTION_TIMEOUT */;
134261
+ const aborted = signal.aborted && !executionTimedOut;
134262
+ if (executionThrew) {
134263
+ executionStatus = aborted ? "cancelled" : "error";
134264
+ executionSettled = true;
134265
+ }
134266
+ const exceptionErrorType = explicitErrorType ?? (executionThrew && scheduledCall.tool instanceof DiscoveredMCPTool ? "mcp_tool_error" /* MCP_TOOL_ERROR */ : "unhandled_exception" /* UNHANDLED_EXCEPTION */);
134267
+ if (execSpan) {
134268
+ const failedExecSpan = execSpan;
134269
+ execSpan = void 0;
134270
+ endToolExecutionSpan(failedExecSpan, {
134271
+ success: false,
134272
+ error: aborted ? TOOL_SPAN_STATUS_TOOL_CANCELLED : executionTimedOut ? TOOL_SPAN_STATUS_TOOL_TIMEOUT : TOOL_SPAN_STATUS_TOOL_EXCEPTION,
134273
+ cancelled: aborted,
134274
+ executionStatus,
134275
+ errorType: executionStatus === "error" ? exceptionErrorType : void 0
134276
+ });
134277
+ }
133839
134278
  if (aborted) {
133840
- let cancelMessage = "User cancelled tool execution.";
134279
+ let cancelMessage = executionThrew ? TOOL_CANCELLED_BEFORE_COMPLETION_MESSAGE : TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE;
133841
134280
  let failureHookArtifacts;
133842
134281
  if (hooksEnabled && messageBus) {
133843
134282
  const failureHookResult = await this.withHookSpan(
@@ -133869,11 +134308,12 @@ ${failureHookResult.additionalContext}`;
133869
134308
  this.setStatusInternal(
133870
134309
  callId,
133871
134310
  "cancelled",
133872
- failureHookArtifacts && failureHookArtifacts.length > 0 ? createCancelledResponse(
134311
+ createCancelledResponse(
133873
134312
  scheduledCall.request,
133874
134313
  cancelMessage,
134314
+ executionStatus,
133875
134315
  failureHookArtifacts
133876
- ) : cancelMessage
134316
+ )
133877
134317
  );
133878
134318
  setToolSpanCancelled(span);
133879
134319
  return;
@@ -133907,13 +134347,30 @@ ${failureHookResult.additionalContext}`;
133907
134347
  }
133908
134348
  failureHookArtifacts = failureHookResult.artifacts;
133909
134349
  }
134350
+ if (signal.aborted && !executionTimedOut) {
134351
+ this.setStatusInternal(
134352
+ callId,
134353
+ "cancelled",
134354
+ createCancelledResponse(
134355
+ scheduledCall.request,
134356
+ // The abort landed while the failure hook was running; the
134357
+ // tool's own outcome is still what `executionThrew` says.
134358
+ executionThrew ? TOOL_CANCELLED_BEFORE_COMPLETION_MESSAGE : TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE,
134359
+ executionStatus,
134360
+ failureHookArtifacts
134361
+ )
134362
+ );
134363
+ setToolSpanCancelled(span);
134364
+ return;
134365
+ }
133910
134366
  this.setStatusInternal(
133911
134367
  callId,
133912
134368
  "error",
133913
134369
  createErrorResponse(
133914
134370
  scheduledCall.request,
133915
134371
  executionError instanceof Error ? new Error(exceptionErrorMessage) : new Error(String(executionError)),
133916
- "unhandled_exception" /* UNHANDLED_EXCEPTION */,
134372
+ exceptionErrorType,
134373
+ executionStatus,
133917
134374
  failureHookArtifacts
133918
134375
  )
133919
134376
  );
@@ -133944,8 +134401,7 @@ ${failureHookResult.additionalContext}`;
133944
134401
  }
133945
134402
  let messageBus;
133946
134403
  try {
133947
- const shouldFirePostToolBatch = !this.config.getDisableAllHooks() && (this.config.hasHooksForEvent?.("PostToolBatch") ?? false);
133948
- messageBus = shouldFirePostToolBatch ? this.config.getMessageBus() : void 0;
134404
+ messageBus = this.postToolBatchEnabledForBatch ? this.config.getMessageBus() : void 0;
133949
134405
  } catch (error) {
133950
134406
  debugLogger122.warn(
133951
134407
  `PostToolBatch hook setup failed: ${error instanceof Error ? error.message : String(error)}`
@@ -133959,7 +134415,7 @@ ${failureHookResult.additionalContext}`;
133959
134415
  if (messageBus) {
133960
134416
  const batchToolCalls = completedCalls.map(toPostToolBatchToolCall);
133961
134417
  const permissionMode = this.config.getApprovalMode();
133962
- const batchHookResult = await this.withHookSpan(
134418
+ const fireBatchHook = /* @__PURE__ */ __name(() => this.withHookSpan(
133963
134419
  { hookEvent: "PostToolBatch", toolName: "batch" },
133964
134420
  () => firePostToolBatchHook(
133965
134421
  messageBus,
@@ -133981,15 +134437,28 @@ ${failureHookResult.additionalContext}`;
133981
134437
  postBatchStop: r.shouldStop,
133982
134438
  postBatchStopReason: r.shouldStop ? r.stopReason || "no reason given" : void 0
133983
134439
  }
133984
- );
134440
+ ), "fireBatchHook");
134441
+ const batchParentSpan = this.postToolBatchSpanCallId ? this.toolSpans.get(this.postToolBatchSpanCallId) : void 0;
134442
+ const batchHookResult = await (batchParentSpan ? runInToolSpanContext(batchParentSpan, fireBatchHook) : fireBatchHook());
133985
134443
  if (batchHookResult.shouldStop) {
134444
+ const stopMessage = batchHookResult.stopReason || "Execution stopped by PostToolBatch hook";
133986
134445
  debugLogger122.info(
133987
134446
  `PostToolBatch hook stopped batch (${completedCalls.length} calls): ${batchHookResult.stopReason || "no reason given"}`
133988
134447
  );
133989
- completedCalls = withPostToolBatchStop(
133990
- completedCalls,
133991
- batchHookResult.stopReason || "Execution stopped by PostToolBatch hook"
133992
- );
134448
+ completedCalls = withPostToolBatchStop(completedCalls, stopMessage);
134449
+ const stoppedCall = completedCalls.at(-1);
134450
+ const stoppedSpan = stoppedCall ? this.toolSpans.get(stoppedCall.request.callId) : void 0;
134451
+ if (stoppedSpan) {
134452
+ setToolSpanFailure(
134453
+ stoppedSpan,
134454
+ TOOL_FAILURE_KIND_POST_HOOK_STOPPED,
134455
+ stopMessage
134456
+ );
134457
+ } else {
134458
+ debugLogger122.debug(
134459
+ `PostToolBatch stop: no tool span for stopped call ${stoppedCall?.request.callId}; post_hook_stopped not recorded`
134460
+ );
134461
+ }
133993
134462
  }
133994
134463
  completedCalls = withPostToolBatchAdditionalContext(
133995
134464
  completedCalls,
@@ -134001,6 +134470,9 @@ ${failureHookResult.additionalContext}`;
134001
134470
  );
134002
134471
  }
134003
134472
  completedCalls = await this.applyBatchOutputBudget(completedCalls);
134473
+ for (const call of completedCalls) {
134474
+ this.finalizeToolSpan(call.request.callId, true);
134475
+ }
134004
134476
  for (const call of completedCalls) {
134005
134477
  this.runtimeContentGeneratorViews.delete(call.request.callId);
134006
134478
  logToolCall(this.config, new ToolCallEvent(call));
@@ -134011,13 +134483,15 @@ ${failureHookResult.additionalContext}`;
134011
134483
  }
134012
134484
  } finally {
134013
134485
  try {
134486
+ for (const call of completedCalls) {
134487
+ this.finalizeToolSpan(call.request.callId, true);
134488
+ }
134489
+ this.postToolBatchEnabledForBatch = false;
134490
+ this.postToolBatchSpanCallId = void 0;
134014
134491
  this.notifyToolCallsUpdate();
134015
134492
  } finally {
134016
134493
  this.isFinalizingToolCalls = false;
134017
- if (this.requestQueue.length > 0) {
134018
- const next = this.requestQueue.shift();
134019
- this._schedule(next.request, next.signal, next.runtimeView).then(next.resolve).catch(next.reject);
134020
- }
134494
+ this.drainRequestQueueIfIdle();
134021
134495
  }
134022
134496
  }
134023
134497
  }
@@ -134082,6 +134556,7 @@ ${failureHookResult.additionalContext}`;
134082
134556
  const result = {
134083
134557
  callId: call.request.callId,
134084
134558
  status: call.status,
134559
+ executionStatus: call.response.executionStatus,
134085
134560
  resultDisplay: call.response.resultDisplay,
134086
134561
  ...call.response.visionBridgeNotice !== void 0 ? { visionBridgeNotice: call.response.visionBridgeNotice } : {},
134087
134562
  error: call.response.error,
@@ -134109,8 +134584,15 @@ ${failureHookResult.additionalContext}`;
134109
134584
  }
134110
134585
  }
134111
134586
  notifyToolCallsUpdate() {
134112
- if (this.onToolCallsUpdate) {
134587
+ if (!this.onToolCallsUpdate) {
134588
+ return;
134589
+ }
134590
+ try {
134113
134591
  this.onToolCallsUpdate([...this.toolCalls]);
134592
+ } catch (error) {
134593
+ debugLogger122.error(
134594
+ `Tool call update observer failed: ${error instanceof Error ? error.message : String(error)}`
134595
+ );
134114
134596
  }
134115
134597
  }
134116
134598
  setToolCallOutcome(callId, outcome) {
@@ -134133,6 +134615,9 @@ ${failureHookResult.additionalContext}`;
134133
134615
  );
134134
134616
  for (const pendingTool of pendingTools) {
134135
134617
  try {
134618
+ if (this.cancelPreExecutionIfAborted(pendingTool.request.callId, signal)) {
134619
+ continue;
134620
+ }
134136
134621
  const toolParams = pendingTool.invocation.params;
134137
134622
  const flowResult = await runInRequestGoalContext(
134138
134623
  pendingTool.request,
@@ -134143,6 +134628,9 @@ ${failureHookResult.additionalContext}`;
134143
134628
  toolParams
134144
134629
  )
134145
134630
  );
134631
+ if (this.cancelPreExecutionIfAborted(pendingTool.request.callId, signal)) {
134632
+ continue;
134633
+ }
134146
134634
  const { finalPermission, pmForcedAsk, pmCtx, requiresUserInteraction } = flowResult;
134147
134635
  if (requiresUserInteraction) {
134148
134636
  continue;
@@ -134170,6 +134658,9 @@ ${failureHookResult.additionalContext}`;
134170
134658
  skipClassifierReason: fallback.fallback ? fallback.reason : void 0
134171
134659
  })
134172
134660
  );
134661
+ if (this.cancelPreExecutionIfAborted(pendingTool.request.callId, signal)) {
134662
+ continue;
134663
+ }
134173
134664
  const outcome = applyAutoModeDecision(
134174
134665
  decision,
134175
134666
  this.config,
@@ -134194,6 +134685,9 @@ ${failureHookResult.additionalContext}`;
134194
134685
  );
134195
134686
  }
134196
134687
  }
134688
+ if (this.cancelPreExecutionIfAborted(pendingTool.request.callId, signal)) {
134689
+ continue;
134690
+ }
134197
134691
  switch (outcome.kind) {
134198
134692
  case "approved":
134199
134693
  this.setToolCallOutcome(
@@ -134214,7 +134708,8 @@ ${failureHookResult.additionalContext}`;
134214
134708
  createErrorResponse(
134215
134709
  pendingTool.request,
134216
134710
  new Error(outcome.errorMessage),
134217
- "execution_denied" /* EXECUTION_DENIED */
134711
+ "execution_denied" /* EXECUTION_DENIED */,
134712
+ "not_started"
134218
134713
  )
134219
134714
  );
134220
134715
  this.finalizeBlockedSpan(
@@ -134273,6 +134768,9 @@ ${failureHookResult.additionalContext}`;
134273
134768
  );
134274
134769
  }
134275
134770
  } catch (error) {
134771
+ if (this.cancelPreExecutionIfAborted(pendingTool.request.callId, signal)) {
134772
+ continue;
134773
+ }
134276
134774
  debugLogger122.error(
134277
134775
  `Error checking confirmation for tool ${pendingTool.request.callId}:`,
134278
134776
  error
@@ -142730,8 +143228,10 @@ var GeminiClient = class _GeminiClient {
142730
143228
  }
142731
143229
  if (m2.triggerReason === "size") {
142732
143230
  const pendingNote = m2.pendingToolResultChars && m2.pendingToolResultChars > 0 ? ` (+${m2.pendingToolResultChars} pending)` : "";
143231
+ const virtualAfter = (m2.toolResultCharsAfter ?? 0) + (m2.pendingToolResultChars ?? 0);
143232
+ const targetNote = m2.toolResultsLowWatermark !== void 0 ? `, target ${m2.toolResultsLowWatermark}` + (virtualAfter > m2.toolResultsLowWatermark ? " (soft-exceeded)" : "") : "";
142733
143233
  debugLogger132.info(
142734
- `[TOOL-RESULT MC] tool result chars ${m2.toolResultCharsBefore} > ${m2.toolResultsTotalCharsThreshold}, cleared ${m2.toolsCleared} tool result(s) (~${m2.tokensSaved} tokens), history now ${m2.toolResultCharsAfter}${pendingNote}, kept ${m2.toolsKept} tool result(s)`
143234
+ `[TOOL-RESULT MC] tool result chars ${m2.toolResultCharsBefore} > ${m2.toolResultsTotalCharsThreshold}, cleared ${m2.toolsCleared} tool result(s) (~${m2.tokensSaved} tokens), history now ${m2.toolResultCharsAfter}${pendingNote}${targetNote}, kept ${m2.toolsKept} tool result(s)`
142735
143235
  );
142736
143236
  } else {
142737
143237
  debugLogger132.info(
@@ -150331,7 +150831,7 @@ var Config = class _Config {
150331
150831
  }
150332
150832
  if (!enabled) return;
150333
150833
  registry.registerFactory(ToolNames.IMAGE_GEN, async () => {
150334
- const { ImageGenTool } = await import("./image-gen-2ZWPS42A.js");
150834
+ const { ImageGenTool } = await import("./image-gen-KNKDTUEN.js");
150335
150835
  return new ImageGenTool(this);
150336
150836
  });
150337
150837
  }
@@ -150361,36 +150861,36 @@ var Config = class _Config {
150361
150861
  if (options2?.forSubAgent) return;
150362
150862
  const schema = this.jsonSchema;
150363
150863
  await registerLazy(ToolNames.STRUCTURED_OUTPUT, async () => {
150364
- const { SyntheticOutputTool } = await import("./syntheticOutput-EYL7DWO7.js");
150864
+ const { SyntheticOutputTool } = await import("./syntheticOutput-BN7E626U.js");
150365
150865
  return new SyntheticOutputTool(schema);
150366
150866
  });
150367
150867
  }, "registerStructuredOutputIfRequested");
150368
150868
  const registerGoalWorkerTools = /* @__PURE__ */ __name(async () => {
150369
150869
  if (options2?.forSubAgent) return;
150370
150870
  await registerLazy(ToolNames.GET_GOAL, async () => {
150371
- const { GetGoalTool } = await import("./goal-tools-SPQ5M6D3.js");
150871
+ const { GetGoalTool } = await import("./goal-tools-3AZKX5WQ.js");
150372
150872
  return new GetGoalTool(this);
150373
150873
  });
150374
150874
  await registerLazy(ToolNames.UPDATE_GOAL, async () => {
150375
- const { UpdateGoalTool } = await import("./goal-tools-SPQ5M6D3.js");
150875
+ const { UpdateGoalTool } = await import("./goal-tools-3AZKX5WQ.js");
150376
150876
  return new UpdateGoalTool(this);
150377
150877
  });
150378
150878
  }, "registerGoalWorkerTools");
150379
150879
  if (this.getBareMode()) {
150380
150880
  await registerLazy(ToolNames.READ_FILE, async () => {
150381
- const { ReadFileTool } = await import("./read-file-2T54FYZV.js");
150881
+ const { ReadFileTool } = await import("./read-file-6PSNROKB.js");
150382
150882
  return new ReadFileTool(this);
150383
150883
  });
150384
150884
  await registerLazy(ToolNames.EDIT, async () => {
150385
- const { EditTool } = await import("./edit-YK3UP6D2.js");
150885
+ const { EditTool } = await import("./edit-E2WNOITJ.js");
150386
150886
  return new EditTool(this);
150387
150887
  });
150388
150888
  await registerLazy(ToolNames.NOTEBOOK_EDIT, async () => {
150389
- const { NotebookEditTool } = await import("./notebook-edit-373IQQLE.js");
150889
+ const { NotebookEditTool } = await import("./notebook-edit-WKZUONWV.js");
150390
150890
  return new NotebookEditTool(this);
150391
150891
  });
150392
150892
  await registerLazy(ToolNames.SHELL, async () => {
150393
- const { ShellTool: ShellTool2 } = await import("./shell-RT5DBH6B.js");
150893
+ const { ShellTool: ShellTool2 } = await import("./shell-6SUYJURL.js");
150394
150894
  return new ShellTool2(this);
150395
150895
  });
150396
150896
  await registerGoalWorkerTools();
@@ -150402,43 +150902,43 @@ var Config = class _Config {
150402
150902
  }
150403
150903
  await registerGoalWorkerTools();
150404
150904
  await registerLazy(ToolNames.TOOL_SEARCH, async () => {
150405
- const { ToolSearchTool } = await import("./tool-search-2AOU77H4.js");
150905
+ const { ToolSearchTool } = await import("./tool-search-HJN53LCN.js");
150406
150906
  return new ToolSearchTool(this);
150407
150907
  });
150408
150908
  await registerLazy(ToolNames.READ_MCP_RESOURCE, async () => {
150409
- const { ReadMcpResourceTool } = await import("./read-mcp-resource-DRZSI3HE.js");
150909
+ const { ReadMcpResourceTool } = await import("./read-mcp-resource-RTSSEER5.js");
150410
150910
  return new ReadMcpResourceTool(this);
150411
150911
  });
150412
150912
  await registerLazy(ToolNames.AGENT, async () => {
150413
- const { AgentTool: AgentTool2 } = await import("./agent-RB6LCRZX.js");
150913
+ const { AgentTool: AgentTool2 } = await import("./agent-SC23IV5L.js");
150414
150914
  return new AgentTool2(this);
150415
150915
  });
150416
150916
  await registerLazy(ToolNames.LIST_AGENTS, async () => {
150417
- const { ListAgentsTool } = await import("./list-agents-TWEGRJWO.js");
150917
+ const { ListAgentsTool } = await import("./list-agents-GC4BRET7.js");
150418
150918
  return new ListAgentsTool(this);
150419
150919
  });
150420
150920
  await registerLazy(ToolNames.TASK_STOP, async () => {
150421
- const { TaskStopTool } = await import("./task-stop-Y5ZTFVRX.js");
150921
+ const { TaskStopTool } = await import("./task-stop-TNXRNAL2.js");
150422
150922
  return new TaskStopTool(this);
150423
150923
  });
150424
150924
  await registerLazy(ToolNames.SEND_MESSAGE, async () => {
150425
- const { SendMessageTool } = await import("./send-message-LHJLVWFD.js");
150925
+ const { SendMessageTool } = await import("./send-message-TL6FIMMN.js");
150426
150926
  return new SendMessageTool(this);
150427
150927
  });
150428
150928
  await registerLazy(ToolNames.SKILL, async () => {
150429
- const { SkillTool } = await import("./skill-LVGA3ATZ.js");
150929
+ const { SkillTool } = await import("./skill-ZIQFS6YD.js");
150430
150930
  return new SkillTool(this);
150431
150931
  });
150432
150932
  await registerLazy(ToolNames.LS, async () => {
150433
- const { LSTool } = await import("./ls-H5WX22VK.js");
150933
+ const { LSTool } = await import("./ls-63CC3NNX.js");
150434
150934
  return new LSTool(this);
150435
150935
  });
150436
150936
  await registerLazy(ToolNames.READ_FILE, async () => {
150437
- const { ReadFileTool } = await import("./read-file-2T54FYZV.js");
150937
+ const { ReadFileTool } = await import("./read-file-6PSNROKB.js");
150438
150938
  return new ReadFileTool(this);
150439
150939
  });
150440
150940
  await registerLazy(ToolNames.ZOOM_IMAGE, async () => {
150441
- const { ZoomImageTool } = await import("./zoom-image-E3VHRCFU.js");
150941
+ const { ZoomImageTool } = await import("./zoom-image-4Y6Y6DAX.js");
150442
150942
  return new ZoomImageTool(this);
150443
150943
  });
150444
150944
  if (this.getUseRipgrep()) {
@@ -150453,7 +150953,7 @@ var Config = class _Config {
150453
150953
  recordStartupEvent("config_initialize_ripgrep_probe_end");
150454
150954
  if (useRipgrep) {
150455
150955
  await registerLazy(ToolNames.GREP, async () => {
150456
- const { RipGrepTool: RipGrepTool2 } = await import("./ripGrep-3H72KY7S.js");
150956
+ const { RipGrepTool: RipGrepTool2 } = await import("./ripGrep-4WZJEOGB.js");
150457
150957
  return new RipGrepTool2(this);
150458
150958
  });
150459
150959
  } else {
@@ -150466,7 +150966,7 @@ var Config = class _Config {
150466
150966
  )
150467
150967
  );
150468
150968
  await registerLazy(ToolNames.GREP, async () => {
150469
- const { GrepTool } = await import("./grep-SQ7RD7SV.js");
150969
+ const { GrepTool } = await import("./grep-SJ2NYUCD.js");
150470
150970
  return new GrepTool(this);
150471
150971
  });
150472
150972
  }
@@ -150474,77 +150974,77 @@ var Config = class _Config {
150474
150974
  recordStartupEvent("config_initialize_ripgrep_probe_start");
150475
150975
  recordStartupEvent("config_initialize_ripgrep_probe_end");
150476
150976
  await registerLazy(ToolNames.GREP, async () => {
150477
- const { GrepTool } = await import("./grep-SQ7RD7SV.js");
150977
+ const { GrepTool } = await import("./grep-SJ2NYUCD.js");
150478
150978
  return new GrepTool(this);
150479
150979
  });
150480
150980
  }
150481
150981
  await registerLazy(ToolNames.GLOB, async () => {
150482
- const { GlobTool } = await import("./glob-SKUYGTF2.js");
150982
+ const { GlobTool } = await import("./glob-IGTV723M.js");
150483
150983
  return new GlobTool(this);
150484
150984
  });
150485
150985
  await registerLazy(ToolNames.EDIT, async () => {
150486
- const { EditTool } = await import("./edit-YK3UP6D2.js");
150986
+ const { EditTool } = await import("./edit-E2WNOITJ.js");
150487
150987
  return new EditTool(this);
150488
150988
  });
150489
150989
  await registerLazy(ToolNames.NOTEBOOK_EDIT, async () => {
150490
- const { NotebookEditTool } = await import("./notebook-edit-373IQQLE.js");
150990
+ const { NotebookEditTool } = await import("./notebook-edit-WKZUONWV.js");
150491
150991
  return new NotebookEditTool(this);
150492
150992
  });
150493
150993
  await registerLazy(ToolNames.WRITE_FILE, async () => {
150494
- const { WriteFileTool: WriteFileTool2 } = await import("./write-file-MOM4JDHG.js");
150994
+ const { WriteFileTool: WriteFileTool2 } = await import("./write-file-NK4C3GFC.js");
150495
150995
  return new WriteFileTool2(this);
150496
150996
  });
150497
150997
  await registerLazy(ToolNames.SHELL, async () => {
150498
- const { ShellTool: ShellTool2 } = await import("./shell-RT5DBH6B.js");
150998
+ const { ShellTool: ShellTool2 } = await import("./shell-6SUYJURL.js");
150499
150999
  return new ShellTool2(this);
150500
151000
  });
150501
151001
  await registerLazy(ToolNames.TODO_WRITE, async () => {
150502
- const { TodoWriteTool } = await import("./todoWrite-FTZWQRZH.js");
151002
+ const { TodoWriteTool } = await import("./todoWrite-MHWHO5UO.js");
150503
151003
  return new TodoWriteTool(this);
150504
151004
  });
150505
151005
  const supportsUserInteraction = resolveInteractionMode(this) !== "headless";
150506
151006
  if (supportsUserInteraction) {
150507
151007
  await registerLazy(ToolNames.ASK_USER_QUESTION, async () => {
150508
- const { AskUserQuestionTool } = await import("./askUserQuestion-23Y5WZFJ.js");
151008
+ const { AskUserQuestionTool } = await import("./askUserQuestion-2EPPBPUZ.js");
150509
151009
  return new AskUserQuestionTool(this);
150510
151010
  });
150511
151011
  }
150512
151012
  if (!this.sdkMode && (supportsUserInteraction || options2?.forSubAgent)) {
150513
151013
  await registerLazy(ToolNames.EXIT_PLAN_MODE, async () => {
150514
- const { ExitPlanModeTool: ExitPlanModeTool2 } = await import("./exitPlanMode-K5Y3REU2.js");
151014
+ const { ExitPlanModeTool: ExitPlanModeTool2 } = await import("./exitPlanMode-V75Y36HJ.js");
150515
151015
  return new ExitPlanModeTool2(this);
150516
151016
  });
150517
151017
  }
150518
151018
  if (!this.sdkMode && supportsUserInteraction) {
150519
151019
  await registerLazy(ToolNames.ENTER_PLAN_MODE, async () => {
150520
- const { EnterPlanModeTool } = await import("./enterPlanMode-TZAYQ5MP.js");
151020
+ const { EnterPlanModeTool } = await import("./enterPlanMode-GISFJA3O.js");
150521
151021
  return new EnterPlanModeTool(this);
150522
151022
  });
150523
151023
  }
150524
151024
  await registerLazy(ToolNames.ENTER_WORKTREE, async () => {
150525
- const { EnterWorktreeTool } = await import("./enter-worktree-QMVQW7UG.js");
151025
+ const { EnterWorktreeTool } = await import("./enter-worktree-RMCBAAA2.js");
150526
151026
  return new EnterWorktreeTool(this);
150527
151027
  });
150528
151028
  await registerLazy(ToolNames.EXIT_WORKTREE, async () => {
150529
- const { ExitWorktreeTool } = await import("./exit-worktree-4EC7LBBC.js");
151029
+ const { ExitWorktreeTool } = await import("./exit-worktree-HORS3V7Z.js");
150530
151030
  return new ExitWorktreeTool(this);
150531
151031
  });
150532
151032
  await registerLazy(ToolNames.WEB_FETCH, async () => {
150533
- const { WebFetchTool } = await import("./web-fetch-ZRXSV5AN.js");
151033
+ const { WebFetchTool } = await import("./web-fetch-MXA6HQ42.js");
150534
151034
  return new WebFetchTool(this);
150535
151035
  });
150536
151036
  if (resolveInteractionMode(this) === "interactive" && !this.sdkMode && !this.getScreenReader() && !options2?.forSubAgent) {
150537
151037
  await registerLazy(ToolNames.DISPLAY_IMAGE, async () => {
150538
- const { DisplayImageTool } = await import("./display-image-2WOG27DY.js");
151038
+ const { DisplayImageTool } = await import("./display-image-GUJA352B.js");
150539
151039
  return new DisplayImageTool(this);
150540
151040
  });
150541
151041
  }
150542
151042
  if (this.webSearchSettings?.enabled) {
150543
- const { evaluateWebSearchGate } = await import("./web-search-WOLV3L6T.js");
151043
+ const { evaluateWebSearchGate } = await import("./web-search-YENHOBMC.js");
150544
151044
  const gate = evaluateWebSearchGate(this);
150545
151045
  if (gate.ok) {
150546
151046
  await registerLazy(ToolNames.WEB_SEARCH, async () => {
150547
- const { WebSearchTool } = await import("./web-search-WOLV3L6T.js");
151047
+ const { WebSearchTool } = await import("./web-search-YENHOBMC.js");
150548
151048
  return new WebSearchTool(this);
150549
151049
  });
150550
151050
  } else if (!this.webSearchNoticeEmitted && !options2?.forSubAgent) {
@@ -150555,83 +151055,83 @@ var Config = class _Config {
150555
151055
  await this.registerImageGenerationTool(registry);
150556
151056
  if (this.isArtifactEnabled()) {
150557
151057
  await registerLazy(ToolNames.ARTIFACT, async () => {
150558
- const { ArtifactTool } = await import("./artifact-tool-TBOYEKTY.js");
151058
+ const { ArtifactTool } = await import("./artifact-tool-RROCCJDA.js");
150559
151059
  return new ArtifactTool(this);
150560
151060
  });
150561
151061
  }
150562
151062
  if (this.isRecordArtifactEnabled()) {
150563
151063
  await registerLazy(ToolNames.RECORD_ARTIFACT, async () => {
150564
- const { RecordArtifactTool } = await import("./record-artifact-IPIRWMFY.js");
151064
+ const { RecordArtifactTool } = await import("./record-artifact-E6AWQU2Z.js");
150565
151065
  return new RecordArtifactTool();
150566
151066
  });
150567
151067
  }
150568
151068
  if (this.isLspEnabled() && this.getLspClient()) {
150569
151069
  await registerLazy(ToolNames.LSP, async () => {
150570
- const { LspTool } = await import("./lsp-G6FXYEIS.js");
151070
+ const { LspTool } = await import("./lsp-P6NVJVNT.js");
150571
151071
  return new LspTool(this);
150572
151072
  });
150573
151073
  }
150574
151074
  await registerStructuredOutputIfRequested();
150575
151075
  if (this.isCronEnabled()) {
150576
151076
  await registerLazy(ToolNames.CRON_CREATE, async () => {
150577
- const { CronCreateTool } = await import("./cron-create-HMFSHIAR.js");
151077
+ const { CronCreateTool } = await import("./cron-create-CCRIULJE.js");
150578
151078
  return new CronCreateTool(this);
150579
151079
  });
150580
151080
  await registerLazy(ToolNames.CRON_LIST, async () => {
150581
- const { CronListTool } = await import("./cron-list-ZEX2NBMN.js");
151081
+ const { CronListTool } = await import("./cron-list-QDBVCHRF.js");
150582
151082
  return new CronListTool(this);
150583
151083
  });
150584
151084
  await registerLazy(ToolNames.CRON_DELETE, async () => {
150585
- const { CronDeleteTool } = await import("./cron-delete-ZJFHOX57.js");
151085
+ const { CronDeleteTool } = await import("./cron-delete-FCFW6BGP.js");
150586
151086
  return new CronDeleteTool(this);
150587
151087
  });
150588
151088
  await registerLazy(ToolNames.LOOP_WAKEUP, async () => {
150589
- const { LoopWakeupTool } = await import("./loop-wakeup-6LLEOQYV.js");
151089
+ const { LoopWakeupTool } = await import("./loop-wakeup-SQQSBMEY.js");
150590
151090
  return new LoopWakeupTool(this);
150591
151091
  });
150592
151092
  }
150593
151093
  await registerLazy(ToolNames.CREATE_SUB_SESSION, async () => {
150594
- const { CreateSubSessionTool } = await import("./create-sub-session-J32WC64U.js");
151094
+ const { CreateSubSessionTool } = await import("./create-sub-session-6EWLAZD5.js");
150595
151095
  return new CreateSubSessionTool(this);
150596
151096
  });
150597
151097
  if (this.isAgentTeamEnabled()) {
150598
151098
  await registerLazy(ToolNames.TEAM_CREATE, async () => {
150599
- const { TeamCreateTool } = await import("./team-create-ZVPQIXCP.js");
151099
+ const { TeamCreateTool } = await import("./team-create-CMF2RRF2.js");
150600
151100
  return new TeamCreateTool(this);
150601
151101
  });
150602
151102
  await registerLazy(ToolNames.TEAM_DELETE, async () => {
150603
- const { TeamDeleteTool } = await import("./team-delete-CE7DC53R.js");
151103
+ const { TeamDeleteTool } = await import("./team-delete-D2VMSDOT.js");
150604
151104
  return new TeamDeleteTool(this);
150605
151105
  });
150606
151106
  await registerLazy(ToolNames.TEAM_PLAN_APPROVAL, async () => {
150607
- const { TeamPlanApprovalTool } = await import("./team-plan-approval-5UHUBY3W.js");
151107
+ const { TeamPlanApprovalTool } = await import("./team-plan-approval-5EET4S3I.js");
150608
151108
  return new TeamPlanApprovalTool(this);
150609
151109
  });
150610
151110
  await registerLazy(ToolNames.TASK_CREATE, async () => {
150611
- const { TaskCreateTool } = await import("./task-create-4ALZMGP5.js");
151111
+ const { TaskCreateTool } = await import("./task-create-2X4UP4F3.js");
150612
151112
  return new TaskCreateTool(this);
150613
151113
  });
150614
151114
  await registerLazy(ToolNames.TASK_UPDATE, async () => {
150615
- const { TaskUpdateTool } = await import("./task-update-IKCEEWJ6.js");
151115
+ const { TaskUpdateTool } = await import("./task-update-VDUSN36E.js");
150616
151116
  return new TaskUpdateTool(this);
150617
151117
  });
150618
151118
  await registerLazy(ToolNames.TASK_LIST, async () => {
150619
- const { TaskListTool } = await import("./task-list-6CVQPORX.js");
151119
+ const { TaskListTool } = await import("./task-list-WOLJPZ64.js");
150620
151120
  return new TaskListTool(this);
150621
151121
  });
150622
151122
  }
150623
151123
  if (this.isWorkflowsEnabled()) {
150624
151124
  await registerLazy(ToolNames.WORKFLOW, async () => {
150625
- const { WorkflowTool } = await import("./workflow-F63ES3OB.js");
151125
+ const { WorkflowTool } = await import("./workflow-RYEVBM4L.js");
150626
151126
  return new WorkflowTool(this);
150627
151127
  });
150628
151128
  }
150629
151129
  if (this.isComputerUseEnabled()) {
150630
- const { registerComputerUseTools } = await import("./computer-use-MDOMIVTL.js");
151130
+ const { registerComputerUseTools } = await import("./computer-use-ENYMKQAI.js");
150631
151131
  await registerComputerUseTools(registerLazy, this);
150632
151132
  }
150633
151133
  await registerLazy(ToolNames.MONITOR, async () => {
150634
- const { MonitorTool } = await import("./monitor-6Y3NDMTI.js");
151134
+ const { MonitorTool } = await import("./monitor-I43P3MNV.js");
150635
151135
  return new MonitorTool(this);
150636
151136
  });
150637
151137
  if (this.pendingMcpBudgetCallback) {
@@ -151071,7 +151571,6 @@ export {
151071
151571
  findPlanModeEntryBatchBoundaryIndex,
151072
151572
  finalizeToolResponses,
151073
151573
  parseAndFormatApiError,
151074
- StructuredToolError,
151075
151574
  checkPriorRead,
151076
151575
  PLAN_EXIT_APPROVED_LLM_CONTENT_PREFIXES,
151077
151576
  ExitPlanModeTool,