@qwen-code/qwen-code 0.21.7 → 0.21.8

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 (314) hide show
  1. package/README.md +2 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +43 -30
  3. package/bundled/qc-helper/docs/features/channels/dingtalk.md +40 -2
  4. package/bundled/qc-helper/docs/features/channels/feishu.md +13 -2
  5. package/bundled/qc-helper/docs/features/channels/github.md +13 -11
  6. package/bundled/qc-helper/docs/features/channels/gitlab.md +13 -11
  7. package/bundled/qc-helper/docs/features/channels/overview.md +49 -31
  8. package/bundled/qc-helper/docs/features/channels/plugins.md +2 -2
  9. package/bundled/qc-helper/docs/features/channels/qqbot.md +4 -2
  10. package/bundled/qc-helper/docs/features/channels/telegram.md +4 -2
  11. package/bundled/qc-helper/docs/features/channels/wecom.md +1 -1
  12. package/bundled/qc-helper/docs/features/code-review.md +4 -0
  13. package/bundled/qc-helper/docs/features/commands.md +1 -1
  14. package/bundled/qc-helper/docs/features/hooks.md +52 -0
  15. package/bundled/qc-helper/docs/integration-jetbrains.md +1 -0
  16. package/bundled/qc-helper/docs/qwen-serve.md +4 -1
  17. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +50 -36
  18. package/bundled/review/SKILL.md +28 -5
  19. package/chunks/{MaxSizedBox-ANWZBPTS.js → MaxSizedBox-7PM6BGJ5.js} +26 -22
  20. package/chunks/{StandaloneSessionPicker-XKS3VU3A.js → StandaloneSessionPicker-3UQHM7GV.js} +44 -40
  21. package/chunks/{acp-startup-profiler-ORIQ2CCQ.js → acp-startup-profiler-B5BYAMYQ.js} +2 -2
  22. package/chunks/{acpAgent-KUAZ3GCZ.js → acpAgent-5UWLFV6V.js} +534 -262
  23. package/chunks/{agent-T6PTGX5R.js → agent-624T2BLO.js} +26 -22
  24. package/chunks/{agent-headless-PR7YCB7S.js → agent-headless-2EE5J2KX.js} +26 -22
  25. package/chunks/{artifact-tool-U4VOZIK5.js → artifact-tool-N652YE4L.js} +1 -1
  26. package/chunks/{askUserQuestion-XOBQLPFA.js → askUserQuestion-ONW74PKJ.js} +1 -1
  27. package/chunks/{bridge-NU6YEEHK.js → bridge-JENKGFFP.js} +29 -25
  28. package/chunks/{ca-NYKNH222.js → ca-ZLKAB4K3.js} +6 -0
  29. package/chunks/{channel-management-service-FSQ7SHYI.js → channel-management-service-DDWUPHMU.js} +19 -10
  30. package/chunks/{channel-settings-store-35VQVUVV.js → channel-settings-store-SA6JZSPH.js} +34 -30
  31. package/chunks/{channel-worker-group-JWQK224X.js → channel-worker-group-E67EN3RV.js} +5 -5
  32. package/chunks/{channel-worker-manager-77E3OXRQ.js → channel-worker-manager-SW4C45CF.js} +5 -5
  33. package/chunks/{channel-worker-supervisor-62YWUGP2.js → channel-worker-supervisor-5SRD24FG.js} +3 -3
  34. package/chunks/{chunk-CJXIIILK.js → chunk-2FRY5CRX.js} +1 -1
  35. package/chunks/{chunk-ZJ3VGYHK.js → chunk-2ILAOM2I.js} +34 -17
  36. package/chunks/{chunk-6XJMFJ4D.js → chunk-2M4K4KYS.js} +177 -120
  37. package/chunks/{chunk-CNIID3TV.js → chunk-2UUMVNYT.js} +1 -1
  38. package/chunks/{chunk-22NBYCPD.js → chunk-3P2LV43B.js} +1 -1
  39. package/chunks/{chunk-2U3WZGZG.js → chunk-3PY4LPJF.js} +19 -131
  40. package/chunks/{chunk-SPMY6CX6.js → chunk-3SE7J4DR.js} +3 -3
  41. package/chunks/{chunk-6UWFTUQL.js → chunk-3WNQOYHQ.js} +66 -22
  42. package/chunks/{chunk-KXSDEOFU.js → chunk-4ALIARFY.js} +1 -1
  43. package/chunks/{chunk-D3UEZIQH.js → chunk-4DU3NCHG.js} +48 -55
  44. package/chunks/{chunk-BGG4MBYD.js → chunk-4PYCZH2V.js} +4 -187
  45. package/chunks/{chunk-H2UQ2M5Z.js → chunk-4WU6NY7F.js} +96 -22
  46. package/chunks/{chunk-TLV2IMHR.js → chunk-5ZGR6RKJ.js} +3 -3
  47. package/chunks/{chunk-3K7FH2KQ.js → chunk-67N6HB5H.js} +1310 -171
  48. package/chunks/{chunk-EORNAQDT.js → chunk-6TR7CFXH.js} +1 -1
  49. package/chunks/{chunk-NG2R4N5O.js → chunk-6ZRFAKXK.js} +1 -1
  50. package/chunks/{chunk-P2AJ7FTI.js → chunk-757GB46F.js} +1 -1
  51. package/chunks/{chunk-72LNFGUY.js → chunk-77QVBFCU.js} +3 -3
  52. package/chunks/{chunk-OH2VKQXH.js → chunk-7DVT4LVV.js} +37 -30
  53. package/chunks/{chunk-KKJJB5X6.js → chunk-7VUERJHS.js} +1503 -815
  54. package/chunks/{chunk-VOARQPTA.js → chunk-B52AWKBB.js} +65 -21
  55. package/chunks/{chunk-Y4EWSQF7.js → chunk-BF224XHL.js} +2 -2
  56. package/chunks/{chunk-PJOBIWUG.js → chunk-BF52U4XJ.js} +1 -1
  57. package/chunks/{chunk-55LYDVPU.js → chunk-C5VWPTGT.js} +1 -1
  58. package/chunks/{chunk-W7U4ESW2.js → chunk-CG3WBKJK.js} +1 -1
  59. package/chunks/chunk-COBO5EBO.js +135 -0
  60. package/chunks/chunk-CPG6P4GG.js +82 -0
  61. package/chunks/{chunk-DIEFUBV6.js → chunk-DIWZNWZT.js} +205 -35
  62. package/chunks/{chunk-AE77C5ZU.js → chunk-DQSDACD2.js} +1 -1
  63. package/chunks/{chunk-P3LEG54R.js → chunk-DX5W5AON.js} +2 -2
  64. package/chunks/{chunk-EUQTXRKZ.js → chunk-E4ZBKMSF.js} +5 -5
  65. package/chunks/{chunk-FPM27XN4.js → chunk-EIVICVHM.js} +4 -4
  66. package/chunks/{chunk-YHEEE624.js → chunk-EN2TKTFH.js} +1 -1
  67. package/chunks/chunk-F6WFNA7U.js +22 -0
  68. package/chunks/{chunk-FZBZSYKU.js → chunk-FN6YXJOP.js} +1 -1
  69. package/chunks/{chunk-KR4ZSC7K.js → chunk-FWBXMANW.js} +3 -3
  70. package/chunks/{chunk-LA7YLSR6.js → chunk-FYAXKJK7.js} +327 -67
  71. package/chunks/{chunk-CSZEXZBE.js → chunk-GBDINRIL.js} +3 -3
  72. package/chunks/{chunk-SCI7K3GM.js → chunk-GOEVOFQI.js} +19 -10
  73. package/chunks/{chunk-LEMXGVEP.js → chunk-GQCEQPYQ.js} +3 -3
  74. package/chunks/{chunk-Y7E5LNLO.js → chunk-GXSNGY5M.js} +1027 -876
  75. package/chunks/{chunk-6XU3PH66.js → chunk-HA3SAB64.js} +22 -69
  76. package/chunks/{chunk-Y4NGLFGJ.js → chunk-HUWENAHO.js} +1 -1
  77. package/chunks/{chunk-3ULCB3NE.js → chunk-HV76SFIA.js} +1 -1
  78. package/chunks/{chunk-CB2464BK.js → chunk-HWX5HPUG.js} +14 -4
  79. package/chunks/{chunk-LZC3B5N2.js → chunk-IA7TGCN2.js} +2 -2
  80. package/chunks/{chunk-RERATVSK.js → chunk-IBYULW65.js} +6 -6
  81. package/chunks/{chunk-HYRDKNUY.js → chunk-IUQ52YJK.js} +1 -1
  82. package/chunks/{chunk-TDXGKHDN.js → chunk-IYES5WOT.js} +2 -2
  83. package/chunks/{chunk-RGSBTHSU.js → chunk-KAQCJO6Y.js} +131 -4
  84. package/chunks/{chunk-VWOVHOTT.js → chunk-KJZ26VBX.js} +1 -1
  85. package/chunks/{chunk-6GONZVLS.js → chunk-KKDVZLGL.js} +1 -1
  86. package/chunks/{chunk-MKVZE4ZJ.js → chunk-KTJFU7RT.js} +3 -2
  87. package/chunks/{chunk-R574ATRM.js → chunk-M2PNLYGY.js} +41 -0
  88. package/chunks/{chunk-6EOI4HOK.js → chunk-M3STHEMM.js} +12 -17
  89. package/chunks/chunk-NGYI5EF5.js +244 -0
  90. package/chunks/{chunk-ALGGS7UH.js → chunk-NPQ5ZKRP.js} +82 -1
  91. package/chunks/{chunk-HQB2KUAN.js → chunk-NPUXXRJI.js} +1 -1
  92. package/chunks/{chunk-QETYKPMG.js → chunk-NVRDQFCX.js} +1 -1
  93. package/chunks/{chunk-PQBHU2IA.js → chunk-OHKJVAKG.js} +10 -10
  94. package/chunks/{chunk-CYR3HI5X.js → chunk-OQTXYMKW.js} +2 -2
  95. package/chunks/{chunk-DBOFL3LQ.js → chunk-PG62DFWD.js} +10 -10
  96. package/chunks/{chunk-2VSTGY6M.js → chunk-PJRW65JO.js} +1 -1
  97. package/chunks/{chunk-33ACCIIY.js → chunk-PLFATELK.js} +1 -1
  98. package/chunks/{chunk-IC4Z6LX6.js → chunk-PYQADEFD.js} +5 -0
  99. package/chunks/{chunk-MAJS7AT4.js → chunk-QGHSP65Z.js} +2 -2
  100. package/chunks/{chunk-OHJLEW5J.js → chunk-QQWD7LZV.js} +4 -4
  101. package/chunks/{chunk-ZXU5UHMI.js → chunk-QXVSWG66.js} +2 -2
  102. package/chunks/{chunk-E33LOKRA.js → chunk-RPWVIXDB.js} +18 -1
  103. package/chunks/{chunk-TYKC75AX.js → chunk-S3Y3GBFD.js} +1 -1
  104. package/chunks/{chunk-7UFKAV7Y.js → chunk-S6HYI3MF.js} +2 -2
  105. package/chunks/chunk-SAH4BD2J.js +92 -0
  106. package/chunks/{chunk-OMKQH5C5.js → chunk-SNRT2TJJ.js} +6 -23
  107. package/chunks/chunk-SR7RZ4MS.js +202 -0
  108. package/chunks/{chunk-CXE7E23H.js → chunk-TE3ZAJE7.js} +45 -17
  109. package/chunks/{chunk-S7CV4KO6.js → chunk-TKSZJ5BV.js} +3 -3
  110. package/chunks/{chunk-3NB7TSE2.js → chunk-U5SLIG7E.js} +1 -1
  111. package/chunks/chunk-UA5H3DS2.js +203 -0
  112. package/chunks/{chunk-24ER7UV4.js → chunk-UFALT4LK.js} +1 -1
  113. package/chunks/{chunk-YJQCUTT2.js → chunk-VWMUDKLC.js} +3 -3
  114. package/chunks/{chunk-RMH5OWLD.js → chunk-VXZ5HAOV.js} +1 -1
  115. package/chunks/{chunk-BVWVWGLE.js → chunk-WAUGQKUU.js} +4 -64
  116. package/chunks/{chunk-SHZYHGQH.js → chunk-WG6542MA.js} +1 -1
  117. package/chunks/{chunk-5KH532V7.js → chunk-WV5J6Q6N.js} +1 -1
  118. package/chunks/{chunk-RNVQB725.js → chunk-XHD7CRP2.js} +2 -2
  119. package/chunks/{chunk-W4B7UBUS.js → chunk-XZKQT2B2.js} +5 -5
  120. package/chunks/{chunk-6HVUFDS2.js → chunk-Y4TETC74.js} +22 -13
  121. package/chunks/{chunk-RZHU3ILK.js → chunk-YEF7XEO2.js} +4 -4
  122. package/chunks/{chunk-RUL4S3K3.js → chunk-YHJFF7KH.js} +146 -45
  123. package/chunks/{chunk-23RZCH76.js → chunk-YOM7DEGB.js} +3 -3
  124. package/chunks/{chunk-OFI7IGST.js → chunk-ZCLLJARV.js} +9 -9
  125. package/chunks/{chunk-GSS34377.js → chunk-ZHA242R4.js} +2 -2
  126. package/chunks/{chunk-TRLYP7OF.js → chunk-ZPLALRXZ.js} +17 -9
  127. package/chunks/{chunk-WUC6ZFXO.js → chunk-ZWBUH5UP.js} +1 -1
  128. package/chunks/{computer-use-KEAPATUY.js → computer-use-ESQYJ3JY.js} +26 -22
  129. package/chunks/{config-utils-K7SCOWHD.js → config-utils-XQHBJP7G.js} +4 -4
  130. package/chunks/{contextCommand-ZJA6A5K5.js → contextCommand-CX3YF4ZE.js} +28 -24
  131. package/chunks/{core-runtime-QMJPWHCI.js → core-runtime-DIAU7JMG.js} +30 -26
  132. package/chunks/{create-sub-session-DJE6XICH.js → create-sub-session-HDPD6HOA.js} +26 -22
  133. package/chunks/{create-sub-session-E4PBYXV5.js → create-sub-session-QIDZUOPU.js} +1 -1
  134. package/chunks/{cron-create-GRBWYMIJ.js → cron-create-VONA5JYY.js} +1 -1
  135. package/chunks/{cron-delete-4CMKBR2M.js → cron-delete-5JXSP2MI.js} +1 -1
  136. package/chunks/{cron-list-W7K4ASOA.js → cron-list-KE4F2CIR.js} +1 -1
  137. package/chunks/{daemon-SCTQMM7Z.js → daemon-VZBGJUNL.js} +30 -0
  138. package/chunks/{daemon-status-provider-FSWDPE2G.js → daemon-status-provider-H6O4UQ4F.js} +33 -29
  139. package/chunks/{daemon-trust-policy-P5L5VFAY.js → daemon-trust-policy-BNUXG6MT.js} +33 -29
  140. package/chunks/{daemon-trust-policy-monitor-73JYN6ET.js → daemon-trust-policy-monitor-E4EQ7GF4.js} +33 -29
  141. package/chunks/{de-VL76CPLV.js → de-LIW4XVLN.js} +5 -0
  142. package/chunks/{deferred-core-runtime-BWRCCFTE.js → deferred-core-runtime-CBMSHPAU.js} +26 -22
  143. package/chunks/{display-image-O2XFPQTC.js → display-image-NQRSIBXM.js} +2 -2
  144. package/chunks/{dist-DPPHJAVL.js → dist-EEEQGCZA.js} +918 -142
  145. package/chunks/{dist-K4WWQBHS.js → dist-HIACTZEK.js} +55 -15
  146. package/chunks/{dist-3BMEUGTG.js → dist-IRL7WA5Z.js} +1 -1
  147. package/chunks/{dist-HVBMEYWK.js → dist-KVISB2O2.js} +1 -1
  148. package/chunks/{dist-KS4O2NKE.js → dist-MBF3I5MX.js} +14 -8
  149. package/chunks/{dist-SFQ34F4M.js → dist-MKX5OSFF.js} +5 -4
  150. package/chunks/{dist-7JGAAQSC.js → dist-RCH3I7SS.js} +2 -2
  151. package/chunks/{dist-C5U4LJKW.js → dist-TUSWNE2I.js} +5 -4
  152. package/chunks/{earlyInputCapture-L5ST23A6.js → earlyInputCapture-UIOP7OIN.js} +26 -22
  153. package/chunks/{edit-LHHRFNFK.js → edit-ITMZYFKA.js} +26 -22
  154. package/chunks/{en-IRJ2WN5T.js → en-SY5GTIGX.js} +6 -0
  155. package/chunks/{enter-worktree-6NXCRZPF.js → enter-worktree-S4PL5UV6.js} +26 -22
  156. package/chunks/{enterPlanMode-ZVQT4U7D.js → enterPlanMode-YV52NNJT.js} +26 -22
  157. package/chunks/{environment-GJ2HWJOS.js → environment-NGOWPRZV.js} +30 -26
  158. package/chunks/{errors-6RLH3XXC.js → errors-BU26DTDX.js} +28 -24
  159. package/chunks/{exit-worktree-I2YLUHHY.js → exit-worktree-XRM6LH5F.js} +26 -22
  160. package/chunks/{exitPlanMode-7CCWKO7I.js → exitPlanMode-ZLI5F7KR.js} +26 -22
  161. package/chunks/{fast-path-DVFD4HQD.js → fast-path-UJWORIED.js} +23 -3
  162. package/chunks/{fast-path-settings-WQJU2LAT.js → fast-path-settings-37WQD5B2.js} +6 -3
  163. package/chunks/{fr-GK3HQYVB.js → fr-RQFO7U4P.js} +5 -0
  164. package/chunks/{gemini-7FWGOYD4.js → gemini-ZSKNDUMU.js} +77 -65
  165. package/chunks/{geminiContentGenerator-V2WVLIXU.js → geminiContentGenerator-YGEXOEKD.js} +1 -1
  166. package/chunks/{glob-3N6GGI75.js → glob-7KZG44BR.js} +26 -22
  167. package/chunks/{goal-tools-APOW6UXL.js → goal-tools-PXWN5VK3.js} +4 -2
  168. package/chunks/{grep-V43ILZVX.js → grep-6ZFC7RJ5.js} +26 -22
  169. package/chunks/{handleAutoUpdate-A5WFVWIA.js → handleAutoUpdate-KSEL3TQS.js} +30 -26
  170. package/chunks/{i18n-PLVQ4FBZ.js → i18n-ZIUXBW5V.js} +27 -23
  171. package/chunks/{image-gen-7C6IK6DC.js → image-gen-AUIZJJNK.js} +7 -5
  172. package/chunks/{initializer-CVAIKZYL.js → initializer-7AHY3N6Q.js} +33 -29
  173. package/chunks/{installationInfo-J6QDHNTK.js → installationInfo-VGBXMYLY.js} +27 -23
  174. package/chunks/{ja-3FA46IKD.js → ja-KOZKHJHZ.js} +5 -0
  175. package/chunks/{list-ZZ4OUUWV.js → list-PSFKQHLB.js} +36 -32
  176. package/chunks/{list-agents-KFFIIS2G.js → list-agents-Z4WABFDZ.js} +1 -1
  177. package/chunks/{loadedSettingsAdapter-QRYRJSWL.js → loadedSettingsAdapter-FTMRCTOF.js} +33 -29
  178. package/chunks/{loggingContentGenerator-OJCO75HM.js → loggingContentGenerator-MZAN52UV.js} +7 -5
  179. package/chunks/{loop-wakeup-TLMJPMMP.js → loop-wakeup-UZ5RL5Y2.js} +2 -2
  180. package/chunks/{ls-UVVE2XGE.js → ls-TVHDGIES.js} +1 -1
  181. package/chunks/{lsp-QMEA2VLB.js → lsp-CVN6OQPI.js} +1 -1
  182. package/chunks/{managed-npm-update-PCOSCP2N.js → managed-npm-update-O4NHK45X.js} +27 -23
  183. package/chunks/{mcp-M3WKKWKY.js → mcp-6CFP2AYQ.js} +33 -29
  184. package/chunks/{monitor-GN24FH6C.js → monitor-DAKD6OU4.js} +26 -22
  185. package/chunks/{nonInteractiveCli-KPTU3VSQ.js → nonInteractiveCli-RC7VIUZL.js} +66 -60
  186. package/chunks/{notebook-edit-4YM65BBO.js → notebook-edit-474DPMRL.js} +34 -22
  187. package/chunks/{openaiContentGenerator-EDQT6GTV.js → openaiContentGenerator-2NFY2MWO.js} +19 -9
  188. package/chunks/{pidfile-JOIIRN2C.js → pidfile-KBFVDNQP.js} +26 -22
  189. package/chunks/{process-registry-2CHQBXH5.js → process-registry-PMJOA5CO.js} +15 -0
  190. package/chunks/{processUtils-5SV4MX3Q.js → processUtils-6GRYH4Y3.js} +2 -2
  191. package/chunks/{pt-3AOBKPIJ.js → pt-U6AOCTMF.js} +5 -0
  192. package/chunks/{qwenContentGenerator-ODRJSUGR.js → qwenContentGenerator-KAHU6IZY.js} +33 -28
  193. package/chunks/{qwenOAuth2-NESCMZ47.js → qwenOAuth2-RRQTCP4W.js} +7 -5
  194. package/chunks/{read-file-HPSODLPK.js → read-file-3M6WXDXP.js} +6 -4
  195. package/chunks/{read-mcp-resource-2TNSJTC3.js → read-mcp-resource-PZ4ZF6YL.js} +1 -1
  196. package/chunks/{record-artifact-RAON52FC.js → record-artifact-P4HFMS7X.js} +2 -2
  197. package/chunks/{resumeHistoryUtils-TXCOFFMQ.js → resumeHistoryUtils-D6TAY3HX.js} +30 -26
  198. package/chunks/{ripGrep-ZKQGTQAO.js → ripGrep-PLPENT3E.js} +26 -22
  199. package/chunks/{ru-VJRAMC4W.js → ru-CMX4UMYP.js} +5 -0
  200. package/chunks/{run-qwen-serve-ZPKPKECF.js → run-qwen-serve-ZAFIJKJC.js} +168 -54
  201. package/chunks/{runtime-2FLNNM36.js → runtime-ZED7CYOZ.js} +38 -34
  202. package/chunks/{scheduler-365PJHNR.js → scheduler-MD3AL2W5.js} +26 -22
  203. package/chunks/{send-message-ZM7MRUGP.js → send-message-CAMSLG2L.js} +4 -3
  204. package/chunks/{serve-QD2RNLKJ.js → serve-E3VUDRZN.js} +33 -29
  205. package/chunks/{server-XLJVLTYM.js → server-OWMEMAKR.js} +450 -231
  206. package/chunks/{session-3VTUHH4Q.js → session-HZ57QK7K.js} +158 -97
  207. package/chunks/{settings-KULVPCQC.js → settings-V7BR3RKP.js} +32 -28
  208. package/chunks/{shell-3SWW22MH.js → shell-23OMNMW6.js} +26 -22
  209. package/chunks/{skill-KDHWYS7W.js → skill-6HBDYZRS.js} +7 -5
  210. package/chunks/{skill-settings-NMY4JEJC.js → skill-settings-HWJLTU7M.js} +32 -28
  211. package/chunks/{spawnChannel-ZKS4Q5OU.js → spawnChannel-N6KKUW5B.js} +27 -23
  212. package/chunks/{standalone-update-7CXPGAQ4.js → standalone-update-QGIKHATD.js} +28 -24
  213. package/chunks/{startInteractiveUI-2QQLEKM6.js → startInteractiveUI-GX2CRL42.js} +365 -155
  214. package/chunks/{syntheticOutput-ZLCUTKO2.js → syntheticOutput-PEBJQYJV.js} +2 -2
  215. package/chunks/{task-create-CQP5UEA3.js → task-create-5NWCQSJF.js} +5 -4
  216. package/chunks/{task-list-XLEZOJXP.js → task-list-53265TRZ.js} +1 -1
  217. package/chunks/{task-stop-7ZQM5CFF.js → task-stop-FPCOIRYX.js} +1 -1
  218. package/chunks/{task-update-JA75U2SN.js → task-update-5HN577LS.js} +5 -4
  219. package/chunks/{team-create-2WTNGAOX.js → team-create-CFFKU7KL.js} +26 -22
  220. package/chunks/{team-delete-MHY3UZGY.js → team-delete-MMQB4OSC.js} +1 -1
  221. package/chunks/{team-plan-approval-LZTYLEG4.js → team-plan-approval-6EFOKR6A.js} +26 -22
  222. package/chunks/{terminal-image-renderer-R5HHAFJN.js → terminal-image-renderer-TLDNACQY.js} +28 -24
  223. package/chunks/{theme-manager-PAUCSJFF.js → theme-manager-5LJ3H7VO.js} +26 -22
  224. package/chunks/{todoWrite-UPVOHYGD.js → todoWrite-JGV6VLOX.js} +1 -1
  225. package/chunks/{tool-search-2BFCGLI6.js → tool-search-UJV3A24H.js} +9 -6
  226. package/chunks/{total-session-admission-MK4SINFK.js → total-session-admission-D63QYXGO.js} +29 -25
  227. package/chunks/{trustedFolders-TJ5S26N7.js → trustedFolders-KZCOB53W.js} +30 -24
  228. package/chunks/{update-relaunch-N7AYLARF.js → update-relaunch-IFILM3SA.js} +5 -5
  229. package/chunks/{updateCheck-QRZ3DVT5.js → updateCheck-YZ2CRCFC.js} +29 -25
  230. package/chunks/{useAutoAcceptIndicator-DBJ7Y5AF.js → useAutoAcceptIndicator-AXEVNA3Q.js} +35 -31
  231. package/chunks/{validateNonInterActiveAuth-6ZQWUDS3.js → validateNonInterActiveAuth-3WTOJFWA.js} +61 -57
  232. package/chunks/{version-AJQGQWXC.js → version-GXK7OHZY.js} +1 -1
  233. package/chunks/{web-fetch-QWJYRXFL.js → web-fetch-ILB4GAVR.js} +12 -8
  234. package/chunks/{web-search-2AOXJGHU.js → web-search-HKRPGPZZ.js} +8 -6
  235. package/chunks/{workflow-ERH3SJG2.js → workflow-FXIPRQQA.js} +750 -147
  236. package/chunks/{workspace-providers-status-HZ474RA4.js → workspace-providers-status-NYHC7HSR.js} +35 -31
  237. package/chunks/{workspace-registration-store-6EUP4JXG.js → workspace-registration-store-AKEB7OMW.js} +1 -1
  238. package/chunks/{workspace-registry-R4APRRNC.js → workspace-registry-CDAS5TVZ.js} +29 -25
  239. package/chunks/{workspace-service-HFIFDMU7.js → workspace-service-PAMUKMAV.js} +36 -32
  240. package/chunks/{workspace-skills-status-HAHEIHGK.js → workspace-skills-status-YQSHCCMS.js} +33 -29
  241. package/chunks/{workspace-trust-reconciler-65GTAGDK.js → workspace-trust-reconciler-RPTXOIY2.js} +36 -32
  242. package/chunks/{write-file-B34CDELV.js → write-file-CGS57TS4.js} +26 -22
  243. package/chunks/{zh-ARWDLDLR.js → zh-AGL2FVBI.js} +6 -0
  244. package/chunks/{zh-TW-Y4RGI3P7.js → zh-TW-KI66MHQY.js} +6 -0
  245. package/chunks/{zoom-image-HPRBZHSS.js → zoom-image-E7D72GYV.js} +6 -4
  246. package/cli.js +13 -13
  247. package/locales/ca.js +10 -0
  248. package/locales/de.js +9 -0
  249. package/locales/en.js +10 -0
  250. package/locales/fr.js +9 -0
  251. package/locales/ja.js +9 -0
  252. package/locales/pt.js +9 -0
  253. package/locales/ru.js +9 -0
  254. package/locales/zh-TW.js +10 -0
  255. package/locales/zh.js +10 -0
  256. package/package.json +3 -3
  257. package/web-shell/assets/{arc-Ip-FFDJ0.js → arc-DybZaz32.js} +1 -1
  258. package/web-shell/assets/{architectureDiagram-3BPJPVTR-CChqgwIb.js → architectureDiagram-3BPJPVTR-jN3qBd19.js} +1 -1
  259. package/web-shell/assets/{blockDiagram-GPEHLZMM-BHN-Tfss.js → blockDiagram-GPEHLZMM-Ct5DZPrj.js} +1 -1
  260. package/web-shell/assets/{c4Diagram-AAUBKEIU-BhyjzDjN.js → c4Diagram-AAUBKEIU-CUAFMlUG.js} +1 -1
  261. package/web-shell/assets/channel-BMwLrwLW.js +1 -0
  262. package/web-shell/assets/{chunk-2J33WTMH-BB9eyHrx.js → chunk-2J33WTMH-CuV8n90B.js} +1 -1
  263. package/web-shell/assets/{chunk-4BX2VUAB-BeV7ce_J.js → chunk-4BX2VUAB-BUzl_kls.js} +1 -1
  264. package/web-shell/assets/{chunk-55IACEB6-DO7kXDiV.js → chunk-55IACEB6-BnDBLX6A.js} +1 -1
  265. package/web-shell/assets/{chunk-727SXJPM-B27MPznD.js → chunk-727SXJPM-B83uTOjm.js} +1 -1
  266. package/web-shell/assets/{chunk-AQP2D5EJ-DHIjqjD_.js → chunk-AQP2D5EJ-DM3HLgpT.js} +1 -1
  267. package/web-shell/assets/{chunk-FMBD7UC4-DabMqyN2.js → chunk-FMBD7UC4-CSQ5hgyb.js} +1 -1
  268. package/web-shell/assets/{chunk-ND2GUHAM-Dw7Nnnxc.js → chunk-ND2GUHAM-BWOF4SxX.js} +1 -1
  269. package/web-shell/assets/{chunk-QZHKN3VN-DdaZew1Q.js → chunk-QZHKN3VN-BsOH9LMi.js} +1 -1
  270. package/web-shell/assets/classDiagram-4FO5ZUOK-BGDv98jY.js +1 -0
  271. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BGDv98jY.js +1 -0
  272. package/web-shell/assets/{cose-bilkent-S5V4N54A-CgBpCYH5.js → cose-bilkent-S5V4N54A-IENqH2iJ.js} +1 -1
  273. package/web-shell/assets/{dagre-BM42HDAG-BB4IU8G0.js → dagre-BM42HDAG--dyzDTGo.js} +1 -1
  274. package/web-shell/assets/{diagram-2AECGRRQ-BcUTHU37.js → diagram-2AECGRRQ-BE7Dcqof.js} +1 -1
  275. package/web-shell/assets/{diagram-5GNKFQAL-B6Lyihyv.js → diagram-5GNKFQAL-Cr8-5OTj.js} +1 -1
  276. package/web-shell/assets/{diagram-KO2AKTUF-CRIJOjpG.js → diagram-KO2AKTUF-Bzey3uAY.js} +1 -1
  277. package/web-shell/assets/{diagram-LMA3HP47-DdNiwWWT.js → diagram-LMA3HP47-sErl28Xb.js} +1 -1
  278. package/web-shell/assets/{diagram-OG6HWLK6-Dz4b32Do.js → diagram-OG6HWLK6-Dq30ATIo.js} +1 -1
  279. package/web-shell/assets/{erDiagram-TEJ5UH35-D-8NGw77.js → erDiagram-TEJ5UH35-BkCoEfVW.js} +1 -1
  280. package/web-shell/assets/{flowDiagram-I6XJVG4X-Dun26LyM.js → flowDiagram-I6XJVG4X-DHwO0rrI.js} +1 -1
  281. package/web-shell/assets/{ganttDiagram-6RSMTGT7-F10Hu1Gc.js → ganttDiagram-6RSMTGT7-s7vAPxWq.js} +1 -1
  282. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Bf8Ez6-D.js → gitGraphDiagram-PVQCEYII-CQxhwPOU.js} +1 -1
  283. package/web-shell/assets/index-Bckpjr-I.css +5 -0
  284. package/web-shell/assets/{index-BXqw-nGq.js → index-CF4wApWp.js} +1 -1
  285. package/web-shell/assets/index-DwEr9HEW.js +1768 -0
  286. package/web-shell/assets/{infoDiagram-5YYISTIA-DVgTMLvj.js → infoDiagram-5YYISTIA-BnFrD0bq.js} +1 -1
  287. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-uT-KepvK.js → ishikawaDiagram-YF4QCWOH-Bf9zK5NK.js} +1 -1
  288. package/web-shell/assets/{journeyDiagram-JHISSGLW-Vg_XadQf.js → journeyDiagram-JHISSGLW-CyGAhsxi.js} +1 -1
  289. package/web-shell/assets/{kanban-definition-UN3LZRKU-Dyv1ESBE.js → kanban-definition-UN3LZRKU-CbsK5akB.js} +1 -1
  290. package/web-shell/assets/{linear-BMIepYX3.js → linear-cQsF4P8D.js} +1 -1
  291. package/web-shell/assets/{mermaid.core-zA8pJ9ag.js → mermaid.core-Z4HVqrKY.js} +5 -5
  292. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BCW_BZ_5.js → mindmap-definition-RKZ34NQL-CYnrBo_f.js} +1 -1
  293. package/web-shell/assets/{pieDiagram-4H26LBE5-DseNEGp2.js → pieDiagram-4H26LBE5-CBzOfhrs.js} +1 -1
  294. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-6Z7wr1Fi.js → quadrantDiagram-W4KKPZXB-D4LK1Ebn.js} +1 -1
  295. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CVOlCRPf.js → requirementDiagram-4Y6WPE33-Bzti2Lcj.js} +1 -1
  296. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-CGhgrUJZ.js → sankeyDiagram-5OEKKPKP-yTBw5Z2s.js} +1 -1
  297. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-dlqmpLuQ.js → sequenceDiagram-3UESZ5HK-D07UVRiZ.js} +1 -1
  298. package/web-shell/assets/{stateDiagram-AJRCARHV-B9EW10Xb.js → stateDiagram-AJRCARHV-UE_lHsTn.js} +1 -1
  299. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DC6xgXjX.js +1 -0
  300. package/web-shell/assets/{timeline-definition-PNZ67QCA-BBRh0mgZ.js → timeline-definition-PNZ67QCA-DRvYdiTs.js} +1 -1
  301. package/web-shell/assets/{vennDiagram-CIIHVFJN-B8Gs-REP.js → vennDiagram-CIIHVFJN-CQLIXs0u.js} +1 -1
  302. package/web-shell/assets/{wardley-L42UT6IY-D_y80Ur7.js → wardley-L42UT6IY-JZz_Xqse.js} +1 -1
  303. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-D-CNfHJ-.js → wardleyDiagram-YWT4CUSO--i7BiJwB.js} +1 -1
  304. package/web-shell/assets/{xychartDiagram-2RQKCTM6-DQ5CvELo.js → xychartDiagram-2RQKCTM6-Bkc-bW0S.js} +1 -1
  305. package/web-shell/index.html +2 -2
  306. package/chunks/chunk-6PEXNQTX.js +0 -68
  307. package/chunks/chunk-IUFV6FYU.js +0 -81
  308. package/web-shell/assets/channel-Cu8qd6OB.js +0 -1
  309. package/web-shell/assets/classDiagram-4FO5ZUOK-BI3KrXhq.js +0 -1
  310. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BI3KrXhq.js +0 -1
  311. package/web-shell/assets/index-QQlUCJGg.css +0 -5
  312. package/web-shell/assets/index-hcgjV7vS.js +0 -1768
  313. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CJTZJJ5X.js +0 -1
  314. package/chunks/{anthropicContentGenerator-DTMVEL5M.js → anthropicContentGenerator-SSFE2753.js} +9 -9
@@ -5,29 +5,30 @@ import {
5
5
  FileDiscoveryService,
6
6
  GitWorktreeService,
7
7
  generateAgentWorktreeSlug,
8
+ isTerminalWorkflowStatus,
8
9
  rebuildToolRegistryOnOverride,
9
10
  resolveSavedWorkflowScript,
10
11
  stripAnsiAndControl,
11
12
  toModelVisibleSubagentResult,
12
13
  writeWorkflowSnapshot,
13
14
  writeWorktreeSessionMarker
14
- } from "./chunk-Y7E5LNLO.js";
15
+ } from "./chunk-GXSNGY5M.js";
15
16
  import "./chunk-GOFAQQZA.js";
16
17
  import "./chunk-5M6IDOMF.js";
17
18
  import "./chunk-TWPJO254.js";
18
19
  import "./chunk-H6XPXXMH.js";
19
- import "./chunk-CNIID3TV.js";
20
+ import "./chunk-2UUMVNYT.js";
20
21
  import "./chunk-MVUQRLOH.js";
21
22
  import "./chunk-XCWO3SMQ.js";
22
23
  import "./chunk-7MH4J33A.js";
23
24
  import {
24
25
  parsePositiveIntegerEnv
25
26
  } from "./chunk-6PVPNMXU.js";
26
- import "./chunk-RMH5OWLD.js";
27
+ import "./chunk-VXZ5HAOV.js";
27
28
  import "./chunk-IRH27ZC2.js";
28
29
  import "./chunk-QHWCP53L.js";
29
30
  import "./chunk-GNPNYXJB.js";
30
- import "./chunk-Y4NGLFGJ.js";
31
+ import "./chunk-HUWENAHO.js";
31
32
  import "./chunk-O6GEWCJA.js";
32
33
  import "./chunk-T26EAKDL.js";
33
34
  import "./chunk-ZPJWUGCS.js";
@@ -36,57 +37,62 @@ import "./chunk-J6SZID63.js";
36
37
  import "./chunk-KRXPRVGL.js";
37
38
  import "./chunk-GM463R2B.js";
38
39
  import "./chunk-SEZ556DZ.js";
39
- import "./chunk-CJXIIILK.js";
40
- import "./chunk-3K7FH2KQ.js";
40
+ import "./chunk-2FRY5CRX.js";
41
+ import "./chunk-67N6HB5H.js";
42
+ import {
43
+ SUBAGENT_PLAN_LIFECYCLE_TOOLS
44
+ } from "./chunk-WAUGQKUU.js";
45
+ import "./chunk-PLFATELK.js";
46
+ import "./chunk-L4N6TIP7.js";
47
+ import "./chunk-SAH4BD2J.js";
41
48
  import {
42
- SUBAGENT_PLAN_LIFECYCLE_TOOLS,
43
49
  runWithAgentContext
44
- } from "./chunk-BVWVWGLE.js";
50
+ } from "./chunk-CPG6P4GG.js";
45
51
  import "./chunk-S6LOFUVP.js";
46
- import "./chunk-LZC3B5N2.js";
52
+ import "./chunk-2J3OJGTL.js";
53
+ import "./chunk-IA7TGCN2.js";
47
54
  import "./chunk-K623ENWT.js";
48
55
  import "./chunk-AQ37AY7B.js";
49
56
  import {
50
57
  WorkspaceContext
51
58
  } from "./chunk-EQL65XGA.js";
52
- import "./chunk-IIJEYBNH.js";
53
- import "./chunk-22NBYCPD.js";
59
+ import "./chunk-3P2LV43B.js";
54
60
  import "./chunk-NAVJD2PQ.js";
55
- import "./chunk-3ULCB3NE.js";
56
- import "./chunk-BGG4MBYD.js";
61
+ import "./chunk-HV76SFIA.js";
62
+ import "./chunk-4PYCZH2V.js";
63
+ import "./chunk-P3QQPMQA.js";
64
+ import "./chunk-SR7RZ4MS.js";
65
+ import "./chunk-M6HMMKVG.js";
57
66
  import "./chunk-DGEIYUC3.js";
58
67
  import "./chunk-MPHPFVKK.js";
59
68
  import "./chunk-AXMWHKXA.js";
69
+ import "./chunk-GLCZKT5V.js";
60
70
  import {
61
71
  createAbortController,
62
72
  createChildAbortController
63
73
  } from "./chunk-DJ2GSRLV.js";
64
- import "./chunk-33ACCIIY.js";
65
- import "./chunk-L4N6TIP7.js";
66
- import "./chunk-2J3OJGTL.js";
67
- import "./chunk-P3QQPMQA.js";
68
- import "./chunk-M6HMMKVG.js";
69
- import "./chunk-GLCZKT5V.js";
70
74
  import "./chunk-EI3HZX6C.js";
71
75
  import {
72
76
  WorkflowRunEvent,
73
77
  logWorkflowRun,
74
78
  read,
75
79
  writeLine
76
- } from "./chunk-2U3WZGZG.js";
80
+ } from "./chunk-3PY4LPJF.js";
77
81
  import "./chunk-WOJZWRAZ.js";
78
82
  import "./chunk-VGC4I5JJ.js";
79
83
  import "./chunk-FVKHVJZQ.js";
84
+ import "./chunk-COBO5EBO.js";
80
85
  import {
81
86
  SyntheticOutputTool
82
- } from "./chunk-NG2R4N5O.js";
87
+ } from "./chunk-6ZRFAKXK.js";
83
88
  import {
84
89
  BaseDeclarativeTool,
85
90
  BaseToolInvocation,
86
91
  ToolDisplayNames,
87
92
  ToolNames
88
- } from "./chunk-IC4Z6LX6.js";
89
- import "./chunk-6EOI4HOK.js";
93
+ } from "./chunk-PYQADEFD.js";
94
+ import "./chunk-M3STHEMM.js";
95
+ import "./chunk-F6WFNA7U.js";
90
96
  import "./chunk-46UV252V.js";
91
97
  import "./chunk-ZBVS26BY.js";
92
98
  import "./chunk-KKBPOU75.js";
@@ -402,6 +408,50 @@ function resolveMaxWallClockMs(opts) {
402
408
  return DEFAULT_MAX_WALL_CLOCK_MS;
403
409
  }
404
410
  __name(resolveMaxWallClockMs, "resolveMaxWallClockMs");
411
+ var WallClockWatchdog = class {
412
+ constructor(budgetMs, onFire) {
413
+ this.onFire = onFire;
414
+ this.remainingMs = budgetMs;
415
+ this.arm();
416
+ }
417
+ static {
418
+ __name(this, "WallClockWatchdog");
419
+ }
420
+ timer;
421
+ remainingMs;
422
+ armedAt = 0;
423
+ paused = false;
424
+ stopped = false;
425
+ pause() {
426
+ if (this.stopped || this.paused || this.timer === void 0) return;
427
+ this.paused = true;
428
+ clearTimeout(this.timer);
429
+ this.timer = void 0;
430
+ this.remainingMs = Math.max(
431
+ 0,
432
+ this.remainingMs - (performance.now() - this.armedAt)
433
+ );
434
+ }
435
+ resume() {
436
+ if (this.stopped || !this.paused) return;
437
+ this.paused = false;
438
+ this.arm();
439
+ }
440
+ stop() {
441
+ this.stopped = true;
442
+ if (this.timer !== void 0) clearTimeout(this.timer);
443
+ this.timer = void 0;
444
+ }
445
+ arm() {
446
+ this.armedAt = performance.now();
447
+ this.timer = setTimeout(() => {
448
+ this.stopped = true;
449
+ this.timer = void 0;
450
+ this.onFire();
451
+ }, this.remainingMs);
452
+ this.timer.unref?.();
453
+ }
454
+ };
405
455
  function validateArgs(val, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
406
456
  if (depth > ARGS_MAX_DEPTH) {
407
457
  throw new Error(
@@ -471,6 +521,17 @@ function createWorkflowSandbox(opts) {
471
521
  }, "safePhase");
472
522
  if (opts.args !== void 0) validateArgs(opts.args);
473
523
  const argsJson = opts.args === void 0 ? null : JSON.stringify(opts.args);
524
+ const unconsumedRoots = /* @__PURE__ */ new Map();
525
+ const unconsumedRejections = /* @__PURE__ */ new Map();
526
+ let nextUnconsumedId = 1;
527
+ let unconsumedSettled = false;
528
+ let mirroredEscapeKeys = /* @__PURE__ */ new Set();
529
+ const unconsumedRejectionLine = /* @__PURE__ */ __name((rec) => {
530
+ if (rec.dispatchFailed) {
531
+ return rec.isRoot ? "dispatch failed (result not consumed): " + rec.msg : "dispatch failed (rejection not handled): " + rec.msg;
532
+ }
533
+ return "script handler failed (rejection not handled): " + rec.msg;
534
+ }, "unconsumedRejectionLine");
474
535
  const bridge = {
475
536
  argsJson,
476
537
  pushPhase: safePhase,
@@ -488,6 +549,52 @@ function createWorkflowSandbox(opts) {
488
549
  `Workflow result revival failed at index ${idx}: ${reason}; slot set to null (non-JSON-serializable thunk return).`
489
550
  );
490
551
  }, "logRevivalFailure"),
552
+ // --- Unconsumed-rejection mirror bookkeeping ---
553
+ wfRegisterRoot: /* @__PURE__ */ __name(() => {
554
+ const id = nextUnconsumedId++;
555
+ unconsumedRoots.set(id, { rejectionHandled: false, adoptedOut: false });
556
+ return id;
557
+ }, "wfRegisterRoot"),
558
+ wfMarkRejectionHandled: /* @__PURE__ */ __name((rootId) => {
559
+ const root = unconsumedRoots.get(rootId);
560
+ if (root) root.rejectionHandled = true;
561
+ }, "wfMarkRejectionHandled"),
562
+ wfIsRootHandled: /* @__PURE__ */ __name((rootId) => unconsumedRoots.get(rootId)?.rejectionHandled === true, "wfIsRootHandled"),
563
+ wfMarkAdopted: /* @__PURE__ */ __name((rootId) => {
564
+ const root = unconsumedRoots.get(rootId);
565
+ if (root) root.adoptedOut = true;
566
+ }, "wfMarkAdopted"),
567
+ runId: opts.runId ?? "",
568
+ wfReportUnconsumed: /* @__PURE__ */ __name((rootId, isRoot, dispatchFailed, msg) => {
569
+ if (unconsumedSettled) {
570
+ const rec = {
571
+ rootId,
572
+ isRoot,
573
+ dispatchFailed,
574
+ msg
575
+ };
576
+ const rootState = unconsumedRoots.get(rootId);
577
+ if (!rootState?.rejectionHandled && !(dispatchFailed && rootState?.adoptedOut)) {
578
+ safeLog(unconsumedRejectionLine(rec));
579
+ }
580
+ return 0;
581
+ }
582
+ const id = nextUnconsumedId++;
583
+ unconsumedRejections.set(id, { rootId, isRoot, dispatchFailed, msg });
584
+ return id;
585
+ }, "wfReportUnconsumed"),
586
+ wfClearUnconsumed: /* @__PURE__ */ __name((id) => {
587
+ unconsumedRejections.delete(id);
588
+ }, "wfClearUnconsumed"),
589
+ // R10-1: teardown discrimination cannot key on the error name alone.
590
+ // The dominant in-flight cancellation path (controller.abort() →
591
+ // subagent returns terminateMode=CANCELLED → runSingleDispatch throws
592
+ // a PLAIN Error) never produces an 'AbortError', so the mirror would
593
+ // log a spurious dispatch failure for a correctly-cancelled run. Once
594
+ // the run's abort signal has fired, the run is already settling as
595
+ // cancelled / timed-out — every rejection still crossing the boundary
596
+ // is teardown noise regardless of its shape.
597
+ isRunAborted: /* @__PURE__ */ __name(() => opts.abortOnTimeout?.signal.aborted === true, "isRunAborted"),
491
598
  // The truthy flags distinguish "injected" from "default stub" inside the
492
599
  // init script without leaking the host function itself when not used.
493
600
  hasParallel: !!opts.parallel,
@@ -555,27 +662,318 @@ function createWorkflowSandbox(opts) {
555
662
  // those wrappers will produce vm-realm results); reject with a
556
663
  // freshly-constructed vm-realm Error so e.constructor.constructor
557
664
  // stays in the vm realm.
665
+ // Dispatch promises are ObservedPromise instances (a vm-realm
666
+ // Promise subclass). Its then override marks the result consumed
667
+ // and re-attaches the teardown observer to the derived promise, so
668
+ // script-derived chains (agent(...).then(...), await, and the
669
+ // ELEMENTS of static-combinator aggregates \u2014 everything that
670
+ // funnels through then) stay observed at every depth. The
671
+ // AGGREGATES of Promise.all/race/any are built by the native
672
+ // statics and never pass through the observed then, so those
673
+ // statics are wrapped explicitly below (observeAggregate).
674
+ // Without this, a correctly-cancelled run holding a pending derived
675
+ // chain fired a process-level unhandledRejection even though the
676
+ // bare dispatch promise was observed.
677
+ //
678
+ // Unconsumed rejections of an observed node are recorded through
679
+ // the bridge and mirrored into the run log at run settlement (a
680
+ // later consumption clears the record first) \u2014 a dispatch refused
681
+ // at the entry gate (budget / agent cap) or failing mid-run reaches
682
+ // no other surface, so without the mirror the failure leaves no
683
+ // log, alarm, or telemetry.
684
+ function mapDispatchError(hostErr) {
685
+ var msg;
686
+ try {
687
+ msg = (hostErr && hostErr.message != null)
688
+ ? String(hostErr.message)
689
+ : String(hostErr);
690
+ } catch (e) {
691
+ msg = '[unserializable rejection value]';
692
+ }
693
+ const vmErr = new Error(msg);
694
+ // Teardown discrimination at the host boundary \u2014 before the error
695
+ // is flattened into a vm-realm Error. Two shapes count as
696
+ // teardown: an error NAMED 'AbortError' (the scheduler's
697
+ // abortError() DOMException), and ANY rejection that crosses
698
+ // after the run's abort signal has fired \u2014 the dominant
699
+ // cancellation path rejects with a plain Error ('did not complete
700
+ // (terminate mode: CANCELLED).'), which a name-only match would
701
+ // mirror as a spurious dispatch failure on a correctly-cancelled
702
+ // run. Matching the name here (rather than the message text)
703
+ // still suppresses teardown noise without swallowing genuine
704
+ // failures whose message merely contains 'aborted' (e.g. a
705
+ // network-layer 'connection aborted by peer').
706
+ var isAbort = false;
707
+ try {
708
+ isAbort = !!(hostErr && hostErr.name === 'AbortError');
709
+ } catch (e) {
710
+ isAbort = false;
711
+ }
712
+ if (isAbort || __b.isRunAborted()) vmErr.__wfAbort = true;
713
+ vmErr.__wfDispatchFailed = true;
714
+ return vmErr;
715
+ }
716
+ function readFlag(value, name) {
717
+ try {
718
+ return !!(value && value[name]);
719
+ } catch (e) {
720
+ return false;
721
+ }
722
+ }
723
+ function observeDispatch(promise) {
724
+ // Direct native-then call: routing through ObservedPromise.then
725
+ // would mark the promise consumed and recurse the observer. The
726
+ // observer body must be exception-safe on ANY rejection value:
727
+ // a script handler can throw an exotic value (a message getter
728
+ // that throws, a Proxy with throwing traps), and an observer
729
+ // killed mid-body would turn the very rejection it watches into
730
+ // a process-level unhandledRejection \u2014 the exact failure class
731
+ // the observer exists to remove.
732
+ Promise.prototype.then.call(promise, undefined, function (err) {
733
+ if (promise.__wfConsumed) return;
734
+ // R11-30: also suppress on the run-level abort state, not just
735
+ // the rejection's own marker \u2014 a wrapped Promise.any aggregate
736
+ // rejects with a natively built AggregateError that carries
737
+ // neither marker, so teardown rejections of a correctly-
738
+ // cancelled run would still be mirrored when it is unconsumed.
739
+ if (readFlag(err, '__wfAbort') || __b.isRunAborted()) return;
740
+ var dispatchFailed = readFlag(err, '__wfDispatchFailed');
741
+ var errors = null;
742
+ try {
743
+ if (err && Array.isArray(err.errors)) errors = err.errors;
744
+ } catch (e) {
745
+ errors = null;
746
+ }
747
+ if (!dispatchFailed && errors) {
748
+ // R11-4: Promise.any rejects with a fresh vm-realm
749
+ // AggregateError carrying no flags; the element errors are
750
+ // reachable on .errors with their markers preserved. Derive
751
+ // the attribution from the causes instead of blaming the
752
+ // script for a dispatch failure.
753
+ for (var i = 0; i < errors.length; i++) {
754
+ if (readFlag(errors[i], '__wfDispatchFailed')) {
755
+ dispatchFailed = true;
756
+ break;
757
+ }
758
+ }
759
+ }
760
+ // R11-15: cross-root suppression \u2014 aggregate roots track
761
+ // rejectionHandled independently of their elements' roots, so
762
+ // a forwarded dispatch failure whose originating element root
763
+ // the script already handled must not mirror from the
764
+ // aggregate. The element rootId is stamped in vmAsync;
765
+ // Promise.all/race forward the element's own reason,
766
+ // Promise.any surfaces them on .errors.
767
+ try {
768
+ var sourceIds = [];
769
+ if (err && err.__wfRootId) {
770
+ sourceIds.push(err.__wfRootId);
771
+ } else if (errors) {
772
+ for (var j = 0; j < errors.length; j++) {
773
+ if (errors[j] && errors[j].__wfRootId) {
774
+ sourceIds.push(errors[j].__wfRootId);
775
+ }
776
+ }
777
+ }
778
+ for (var k = 0; k < sourceIds.length; k++) {
779
+ if (
780
+ sourceIds[k] !== promise.__wfRootId &&
781
+ __b.wfIsRootHandled(sourceIds[k])
782
+ ) {
783
+ return;
784
+ }
785
+ }
786
+ } catch (e) {
787
+ // A throwing exotic value must not kill the observer; fall
788
+ // through and mirror conservatively.
789
+ }
790
+ var msg;
791
+ try {
792
+ msg = String(err && err.message != null ? err.message : err);
793
+ } catch (e) {
794
+ msg = '[unserializable rejection value]';
795
+ }
796
+ promise.__wfUnconsumedId = __b.wfReportUnconsumed(
797
+ promise.__wfRootId,
798
+ promise.__wfIsRoot === true,
799
+ dispatchFailed,
800
+ msg,
801
+ );
802
+ });
803
+ }
804
+ // R11-3: await / Promise.resolve / returning a thenable from a
805
+ // handler adopts an ObservedPromise through this then with the
806
+ // adopting promise's capability (resolve, reject) pair \u2014 native
807
+ // functions, indistinguishable from real handlers by arity. They
808
+ // are detected by the native toString signature. Adoption
809
+ // CONSUMES the result (a delayed adoption clears a recorded
810
+ // verdict exactly like a delayed await) but is NOT a rejection
811
+ // handler: the rejection transfers into the adopting promise \u2014
812
+ // typically an async wrapper's implicit promise, which is a plain
813
+ // vm-realm Promise the mirror cannot observe. Marking adoption as
814
+ // handling would silently disarm the mirror for the forgotten-
815
+ // await failure class; the run-level escape hook in the host
816
+ // surfaces those escapes instead. Bound script functions also
817
+ // stringify as native code; misreading one as adoption only
818
+ // forgoes the rejectionHandled marking, never native semantics.
819
+ function isAdoptionAttach(handler) {
820
+ try {
821
+ return (
822
+ typeof handler === 'function' &&
823
+ Function.prototype.toString
824
+ .call(handler)
825
+ .indexOf('[native code]') !== -1
826
+ );
827
+ } catch (e) {
828
+ return false;
829
+ }
830
+ }
831
+ class ObservedPromise extends Promise {
832
+ then(onFulfilled, onRejected) {
833
+ // R11-26: introspect the handler BEFORE any state mutation.
834
+ // The read is guarded because a script-supplied handler can
835
+ // be exotic (a revoked Proxy wrapping a function, a throwing
836
+ // accessor) \u2014 an unguarded read made .then() throw
837
+ // synchronously, something native then never does, leaving
838
+ // the promise marked consumed with no handler attached.
839
+ var rethrows = false;
840
+ try {
841
+ rethrows = !!(onRejected && onRejected.__wfRethrows);
842
+ } catch (e) {
843
+ rethrows = false;
844
+ }
845
+ this.__wfConsumed = true;
846
+ // An attached rejection handler means the script can surface the
847
+ // root rejection itself; the mirror stays silent for it. The
848
+ // finally override below routes through this then with marked
849
+ // rethrow combinators \u2014 those re-raise the rejection instead of
850
+ // handling it, so they must NOT set the flag (marking them
851
+ // handled would silently drop a fire-and-forget
852
+ // agent(...).finally(...) failure). Adoption attaches count
853
+ // as consumption only, never handling (see isAdoptionAttach):
854
+ // they mark adoptedOut so forwarded sibling entries defer to
855
+ // the adopting chain / escape hook instead of mirroring.
856
+ if (isAdoptionAttach(onRejected)) {
857
+ __b.wfMarkAdopted(this.__wfRootId);
858
+ } else if (typeof onRejected === 'function' && !rethrows) {
859
+ __b.wfMarkRejectionHandled(this.__wfRootId);
860
+ }
861
+ // A delayed consumption clears a verdict recorded at
862
+ // rejection-settlement time, so a late-but-real await is not
863
+ // misreported as unconsumed.
864
+ if (this.__wfUnconsumedId !== undefined) {
865
+ __b.wfClearUnconsumed(this.__wfUnconsumedId);
866
+ this.__wfUnconsumedId = undefined;
867
+ }
868
+ const derived = super.then(onFulfilled, onRejected);
869
+ derived.__wfRootId = this.__wfRootId;
870
+ observeDispatch(derived);
871
+ return derived;
872
+ }
873
+ finally(onFinally) {
874
+ // Native Promise.prototype.finally calls the observed then with
875
+ // two function combinators, indistinguishable there from a real
876
+ // then(f, g) \u2014 which would mark the root rejection handled even
877
+ // though finally rethrows it. Implement finally through the
878
+ // observed then with an explicitly-marked rethrow combinator so
879
+ // the mirror stays armed for finally-only chains.
880
+ if (typeof onFinally !== 'function') {
881
+ return this.then(undefined, undefined);
882
+ }
883
+ const onRethrow = function (err) {
884
+ return Promise.resolve(onFinally()).then(function () {
885
+ throw err;
886
+ });
887
+ };
888
+ onRethrow.__wfRethrows = true;
889
+ return this.then(
890
+ function (value) {
891
+ return Promise.resolve(onFinally()).then(function () {
892
+ return value;
893
+ });
894
+ },
895
+ onRethrow,
896
+ );
897
+ }
898
+ }
899
+ // --- Static combinators: observe the aggregate promise ---
900
+ // Promise.all/race/any build their aggregate via the native static;
901
+ // it never passes through the observed then, so a fire-and-forget
902
+ // aggregate holding a failed dispatch would escape the run-log
903
+ // mirror. While the run is live the host's adoption-escape hook
904
+ // (R11-3) still catches and mirrors the process-level
905
+ // unhandledRejection \u2014 a round-14 A/B confirmed that hook, not
906
+ // this wrap, is the live-run backstop \u2014 but only with the coarse
907
+ // '(rejection not handled)' wording, and once the run's hook is
908
+ // detached nothing in the sandbox catches the escape. R14-A:
909
+ // wrapping the statics gives each aggregate its own observer, so
910
+ // consumption tracking works through the aggregate's own observed
911
+ // then (await / .catch / .then marks it handled) and the mirror
912
+ // itself classifies the rejection; the elements still funnel
913
+ // through the then override via the native static's internal
914
+ // attach, so they stay marked consumed.
915
+ function observeAggregate(nativeAggregate) {
916
+ const rootId = __b.wfRegisterRoot();
917
+ const observed = new ObservedPromise(function (resolve, reject) {
918
+ Promise.prototype.then.call(nativeAggregate, resolve, reject);
919
+ });
920
+ observed.__wfRootId = rootId;
921
+ observed.__wfIsRoot = true;
922
+ observeDispatch(observed);
923
+ return observed;
924
+ }
925
+ const nativePromiseAll = Promise.all;
926
+ const nativePromiseRace = Promise.race;
927
+ const nativePromiseAny = Promise.any;
928
+ // R11-16: a static called on a script-defined Promise subclass
929
+ // must honor the species contract and return a subclass instance,
930
+ // so non-default receivers bypass observation (their elements
931
+ // still funnel through the observed then, and a fire-and-forget
932
+ // dispatch failure escaping such an aggregate is still caught by
933
+ // the host's adoption-escape hook via its stamped markers).
934
+ Promise.all = function (items) {
935
+ if (this !== Promise) return nativePromiseAll.call(this, items);
936
+ return observeAggregate(nativePromiseAll.call(this, items));
937
+ };
938
+ Promise.race = function (items) {
939
+ if (this !== Promise) return nativePromiseRace.call(this, items);
940
+ return observeAggregate(nativePromiseRace.call(this, items));
941
+ };
942
+ Promise.any = function (items) {
943
+ if (this !== Promise) return nativePromiseAny.call(this, items);
944
+ return observeAggregate(nativePromiseAny.call(this, items));
945
+ };
558
946
  function vmAsync(hostFn) {
559
947
  return function (...vmArgs) {
560
- return new Promise(function (resolve, reject) {
948
+ const rootId = __b.wfRegisterRoot();
949
+ const p = new ObservedPromise(function (resolve, reject) {
950
+ function rejectMapped(hostErr) {
951
+ const vmErr = mapDispatchError(hostErr);
952
+ // Stamp the originating root and run BEFORE the error can
953
+ // be forwarded into aggregate promises: the observer's
954
+ // cross-root suppression (R11-15) reads __wfRootId and
955
+ // the host's adoption-escape hook (R11-3) attributes by
956
+ // __wfRunId.
957
+ try {
958
+ vmErr.__wfRootId = rootId;
959
+ vmErr.__wfRunId = __b.runId;
960
+ } catch (e) {}
961
+ reject(vmErr);
962
+ }
561
963
  try {
562
964
  const hostPromise = hostFn.apply(null, vmArgs);
563
965
  hostPromise.then(
564
966
  function (value) { resolve(value); },
565
- function (hostErr) {
566
- const msg = (hostErr && hostErr.message != null)
567
- ? String(hostErr.message)
568
- : String(hostErr);
569
- reject(new Error(msg));
570
- }
967
+ rejectMapped
571
968
  );
572
969
  } catch (hostErr) {
573
- const msg = (hostErr && hostErr.message != null)
574
- ? String(hostErr.message)
575
- : String(hostErr);
576
- reject(new Error(msg));
970
+ rejectMapped(hostErr);
577
971
  }
578
972
  });
973
+ p.__wfRootId = rootId;
974
+ p.__wfIsRoot = true;
975
+ observeDispatch(p);
976
+ return p;
579
977
  };
580
978
  }
581
979
 
@@ -873,41 +1271,118 @@ function createWorkflowSandbox(opts) {
873
1271
  { filename: "workflow-sandbox-init.js" }
874
1272
  );
875
1273
  const maxWallClockMs = resolveMaxWallClockMs(opts);
1274
+ const flushUnconsumedRejections = /* @__PURE__ */ __name(async () => {
1275
+ unconsumedSettled = true;
1276
+ if (nextUnconsumedId === 1) return;
1277
+ await new Promise((resolve) => {
1278
+ setImmediate(resolve);
1279
+ });
1280
+ for (const rec of unconsumedRejections.values()) {
1281
+ const rootState = unconsumedRoots.get(rec.rootId);
1282
+ if (rootState?.rejectionHandled) {
1283
+ continue;
1284
+ }
1285
+ if (rec.dispatchFailed && rootState?.adoptedOut) {
1286
+ continue;
1287
+ }
1288
+ const key = rec.rootId + "\0" + rec.msg;
1289
+ if (mirroredEscapeKeys.has(key)) continue;
1290
+ mirroredEscapeKeys.add(key);
1291
+ safeLog(unconsumedRejectionLine(rec));
1292
+ }
1293
+ unconsumedRejections.clear();
1294
+ }, "flushUnconsumedRejections");
1295
+ const hookRunId = opts.runId ?? "";
1296
+ const adoptionEscapeHook = /* @__PURE__ */ __name((reason, _promise) => {
1297
+ try {
1298
+ if (!reason || typeof reason !== "object") return;
1299
+ const marked = reason;
1300
+ if (marked.__wfDispatchFailed !== true) return;
1301
+ if (String(marked.__wfRunId ?? "") !== hookRunId) return;
1302
+ const rootId = typeof marked.__wfRootId === "number" ? marked.__wfRootId : void 0;
1303
+ if (rootId !== void 0 && unconsumedRoots.get(rootId)?.rejectionHandled) {
1304
+ return;
1305
+ }
1306
+ let msg;
1307
+ try {
1308
+ msg = marked.message != null ? String(marked.message) : String(reason);
1309
+ } catch {
1310
+ msg = "[unserializable rejection value]";
1311
+ }
1312
+ const key = String(rootId ?? "") + "\0" + msg;
1313
+ if (mirroredEscapeKeys.has(key)) return;
1314
+ mirroredEscapeKeys.add(key);
1315
+ safeLog("dispatch failed (rejection not handled): " + msg);
1316
+ } catch (e) {
1317
+ debugLogger2.warn("adoptionEscapeHook failed:", e);
1318
+ }
1319
+ }, "adoptionEscapeHook");
876
1320
  let extractedMeta = null;
877
1321
  return {
878
1322
  async run(scriptSource) {
879
- const { stripped, meta } = extractAndStripMeta(scriptSource);
880
- extractedMeta = meta;
881
- const wrapped = `(async () => {
1323
+ unconsumedSettled = false;
1324
+ unconsumedRoots.clear();
1325
+ unconsumedRejections.clear();
1326
+ nextUnconsumedId = 1;
1327
+ mirroredEscapeKeys = /* @__PURE__ */ new Set();
1328
+ let watchdog;
1329
+ let stopWatchingState;
1330
+ let rearmWatchdogOnAbort;
1331
+ process.on("unhandledRejection", adoptionEscapeHook);
1332
+ try {
1333
+ const { stripped, meta } = extractAndStripMeta(scriptSource);
1334
+ extractedMeta = meta;
1335
+ const wrapped = `(async () => {
882
1336
  ${stripped}
883
1337
  })()`;
884
- const script = new vm.Script(wrapped, {
885
- filename: "workflow.js"
886
- });
887
- const runOpts = {
888
- timeout: 3e4
889
- };
890
- const result = script.runInContext(ctx, runOpts);
891
- let timer;
892
- const timeoutPromise = new Promise((_, reject) => {
893
- timer = setTimeout(() => {
894
- opts.abortOnTimeout?.abort();
895
- reject(
896
- new Error(
897
- `Workflow execution timed out after ${maxWallClockMs} ms wall clock. Override via SandboxOptions.maxWallClockMs or QWEN_CODE_MAX_WORKFLOW_SECONDS env var.`
898
- )
899
- );
900
- }, maxWallClockMs);
901
- timer.unref?.();
902
- });
903
- try {
1338
+ const script = new vm.Script(wrapped, {
1339
+ filename: "workflow.js"
1340
+ });
1341
+ const runOpts = {
1342
+ timeout: 3e4
1343
+ };
1344
+ const result = script.runInContext(ctx, runOpts);
1345
+ const timeoutPromise = new Promise((_, reject) => {
1346
+ watchdog = new WallClockWatchdog(maxWallClockMs, () => {
1347
+ opts.abortOnTimeout?.abort();
1348
+ reject(
1349
+ new Error(
1350
+ `Workflow execution exceeded ${maxWallClockMs} ms of active time (paused time is not counted). Override via SandboxOptions.maxWallClockMs or QWEN_CODE_MAX_WORKFLOW_SECONDS env var.`
1351
+ )
1352
+ );
1353
+ });
1354
+ });
1355
+ const aborted = /* @__PURE__ */ __name(() => opts.abortOnTimeout?.signal.aborted === true, "aborted");
1356
+ stopWatchingState = opts.scheduler?.onStateChange(({ state }) => {
1357
+ if (state === "paused" && !aborted()) watchdog?.pause();
1358
+ else watchdog?.resume();
1359
+ });
1360
+ if (opts.scheduler?.snapshot().state === "paused" && !aborted()) {
1361
+ watchdog?.pause();
1362
+ }
1363
+ rearmWatchdogOnAbort = /* @__PURE__ */ __name(() => watchdog?.resume(), "rearmWatchdogOnAbort");
1364
+ opts.abortOnTimeout?.signal.addEventListener(
1365
+ "abort",
1366
+ rearmWatchdogOnAbort,
1367
+ { once: true }
1368
+ );
904
1369
  return await Promise.race([result, timeoutPromise]);
905
1370
  } finally {
906
- if (timer !== void 0) clearTimeout(timer);
1371
+ if (rearmWatchdogOnAbort) {
1372
+ opts.abortOnTimeout?.signal.removeEventListener(
1373
+ "abort",
1374
+ rearmWatchdogOnAbort
1375
+ );
1376
+ }
1377
+ stopWatchingState?.();
1378
+ watchdog?.stop();
1379
+ await flushUnconsumedRejections();
1380
+ process.off("unhandledRejection", adoptionEscapeHook);
907
1381
  }
908
1382
  },
909
1383
  getPhases: /* @__PURE__ */ __name(() => [...phases], "getPhases"),
910
1384
  getLogs: /* @__PURE__ */ __name(() => [...logs], "getLogs"),
1385
+ appendLog: /* @__PURE__ */ __name((line) => safeLog(line), "appendLog"),
911
1386
  getMeta: /* @__PURE__ */ __name(() => extractedMeta, "getMeta")
912
1387
  };
913
1388
  }
@@ -1144,58 +1619,122 @@ init_esbuild_shims();
1144
1619
  var WORKFLOW_SUBAGENT_SYSTEM_PROMPT = 'You are a subagent spawned by a workflow orchestration script. Use the tools available to complete the task.\nCRITICAL: Your final text response is returned **verbatim** as a string to the calling script \u2014 it is your return value, not a message to a human.\n- Output the literal result (data, JSON, text). Do NOT output confirmations like "Done." or "Sent."\n- If asked for JSON, return ONLY the raw JSON \u2014 no code fences, no prose, no markdown.\n- Do NOT use SendUserMessage to deliver your answer. Put your answer in your final text response.\n- Be concise. The script will parse your output.';
1145
1620
  var WORKFLOW_SUBAGENT_SYSTEM_PROMPT_WITH_SCHEMA = "You are a subagent spawned by a workflow orchestration script. Use the tools available to complete the task.\nCRITICAL: You MUST deliver your final answer by calling the `structured_output` tool with arguments that conform to its parameter schema. Plain-text final answers are DISCARDED \u2014 only a valid `structured_output` call returns a result to the calling script.\n- Use other tools (Read, Grep, etc.) to gather information first.\n- When ready, call `structured_output` ONCE with the conforming JSON object.\n- If validation fails, the error tells you what to fix. Try again with corrected fields.\n- After two failed attempts, the run terminates \u2014 get the arguments right.\n- Do NOT use SendUserMessage to deliver your answer.\n- Be concise; the script reads only the structured payload, not your prose.";
1146
1621
 
1147
- // packages/core/src/utils/concurrencyLimiter.ts
1622
+ // packages/core/src/agents/runtime/workflow-dispatch-scheduler.ts
1148
1623
  init_esbuild_shims();
1149
1624
  function abortError() {
1150
- return new DOMException("Concurrency limiter aborted.", "AbortError");
1625
+ return new DOMException("Workflow dispatch scheduler aborted.", "AbortError");
1151
1626
  }
1152
1627
  __name(abortError, "abortError");
1153
- function createConcurrencyLimiter(limit, signal) {
1154
- if (!Number.isInteger(limit) || limit < 1) {
1155
- throw new Error(
1156
- `Concurrency limit must be a positive integer, got ${String(limit)}.`
1157
- );
1628
+ var WorkflowDispatchScheduler = class {
1629
+ constructor(limit, signal, onStateChange) {
1630
+ this.limit = limit;
1631
+ this.signal = signal;
1632
+ if (!Number.isInteger(limit) || limit < 1) {
1633
+ throw new Error(
1634
+ `Workflow dispatch limit must be a positive integer, got ${String(limit)}.`
1635
+ );
1636
+ }
1637
+ if (onStateChange) this.stateListeners.add(onStateChange);
1638
+ if (signal && !signal.aborted) {
1639
+ signal.addEventListener("abort", () => this.abortPending(), {
1640
+ once: true
1641
+ });
1642
+ }
1158
1643
  }
1159
- let active = 0;
1160
- const queue = [];
1161
- const pump = /* @__PURE__ */ __name(() => {
1162
- while (active < limit && queue.length > 0) {
1163
- const job = queue.shift();
1164
- if (signal?.aborted) {
1644
+ static {
1645
+ __name(this, "WorkflowDispatchScheduler");
1646
+ }
1647
+ state = "running";
1648
+ inFlight = 0;
1649
+ queue = [];
1650
+ gateWaiters = [];
1651
+ stateListeners = /* @__PURE__ */ new Set();
1652
+ /**
1653
+ * Subscribe to state transitions. Returns an unsubscribe function.
1654
+ * The constructor callback (when given) is registered as the first
1655
+ * listener; this method lets additional observers — e.g. the sandbox's
1656
+ * pause-aware wall-clock watchdog — hook the same transitions.
1657
+ */
1658
+ onStateChange(listener) {
1659
+ this.stateListeners.add(listener);
1660
+ return () => {
1661
+ this.stateListeners.delete(listener);
1662
+ };
1663
+ }
1664
+ run(thunk) {
1665
+ return new Promise((resolve, reject) => {
1666
+ if (this.signal?.aborted) {
1667
+ reject(abortError());
1668
+ return;
1669
+ }
1670
+ this.queue.push({
1671
+ thunk,
1672
+ resolve,
1673
+ reject
1674
+ });
1675
+ this.pump();
1676
+ });
1677
+ }
1678
+ pause() {
1679
+ if (this.state !== "running" || this.signal?.aborted) return false;
1680
+ this.setState("pausing");
1681
+ if (this.inFlight === 0) this.setState("paused");
1682
+ return true;
1683
+ }
1684
+ resume() {
1685
+ if (this.state !== "paused" || this.signal?.aborted) return false;
1686
+ this.setState("running");
1687
+ while (this.gateWaiters.length > 0) {
1688
+ this.gateWaiters.shift().resolve();
1689
+ }
1690
+ this.pump();
1691
+ return true;
1692
+ }
1693
+ waitUntilRunning() {
1694
+ if (this.signal?.aborted) return Promise.reject(abortError());
1695
+ if (this.state === "running") return Promise.resolve();
1696
+ return new Promise((resolve, reject) => {
1697
+ this.gateWaiters.push({ resolve, reject });
1698
+ });
1699
+ }
1700
+ snapshot() {
1701
+ return {
1702
+ state: this.state,
1703
+ queued: this.queue.length,
1704
+ inFlight: this.inFlight
1705
+ };
1706
+ }
1707
+ pump() {
1708
+ while (this.state === "running" && this.inFlight < this.limit && this.queue.length > 0) {
1709
+ const job = this.queue.shift();
1710
+ if (this.signal?.aborted) {
1165
1711
  job.reject(abortError());
1166
1712
  continue;
1167
1713
  }
1168
- active++;
1714
+ this.inFlight++;
1169
1715
  Promise.resolve().then(job.thunk).then(job.resolve, job.reject).finally(() => {
1170
- active--;
1171
- pump();
1716
+ this.inFlight--;
1717
+ if (this.state === "pausing" && this.inFlight === 0) {
1718
+ this.setState("paused");
1719
+ }
1720
+ this.pump();
1172
1721
  });
1173
1722
  }
1174
- }, "pump");
1175
- const run = /* @__PURE__ */ __name((thunk) => new Promise((resolve, reject) => {
1176
- if (signal?.aborted) {
1177
- reject(abortError());
1178
- return;
1723
+ }
1724
+ setState(state) {
1725
+ if (this.state === state) return;
1726
+ this.state = state;
1727
+ const snapshot = this.snapshot();
1728
+ for (const listener of [...this.stateListeners]) listener(snapshot);
1729
+ }
1730
+ abortPending() {
1731
+ const error = abortError();
1732
+ while (this.queue.length > 0) this.queue.shift().reject(error);
1733
+ while (this.gateWaiters.length > 0) {
1734
+ this.gateWaiters.shift().reject(error);
1179
1735
  }
1180
- queue.push({
1181
- thunk,
1182
- resolve,
1183
- reject
1184
- });
1185
- pump();
1186
- }), "run");
1187
- if (signal && !signal.aborted) {
1188
- signal.addEventListener(
1189
- "abort",
1190
- () => {
1191
- while (queue.length > 0) queue.shift().reject(abortError());
1192
- },
1193
- { once: true }
1194
- );
1195
1736
  }
1196
- return { run };
1197
- }
1198
- __name(createConcurrencyLimiter, "createConcurrencyLimiter");
1737
+ };
1199
1738
 
1200
1739
  // packages/core/src/agents/runtime/workflow-orchestrator.ts
1201
1740
  var DEFAULT_MAX_AGENTS_PER_RUN = 1e3;
@@ -1310,7 +1849,7 @@ function createProductionDispatch(config, signal, onTokens, bridgeApprovalEvents
1310
1849
  }
1311
1850
  __name(createProductionDispatch, "createProductionDispatch");
1312
1851
  async function runSingleDispatch(config, prompt, opts, attemptSignal, emitter, onTokens) {
1313
- const { AgentHeadless, ContextState } = await import("./agent-headless-PR7YCB7S.js");
1852
+ const { AgentHeadless, ContextState } = await import("./agent-headless-2EE5J2KX.js");
1314
1853
  const ctx = new ContextState();
1315
1854
  ctx.set("task_prompt", prompt);
1316
1855
  const workflowAgentId = `workflow-agent-${randomBytes(8).toString("hex")}`;
@@ -1748,7 +2287,15 @@ var WorkflowOrchestrator = class {
1748
2287
  const runId = req.runId ?? generateRunId();
1749
2288
  const maxAgents = resolveMaxAgentsPerRun();
1750
2289
  const signal = req.abortOnTimeout?.signal;
1751
- const limiter = createConcurrencyLimiter(resolveConcurrencyLimit(), signal);
2290
+ const scheduler = req.scheduler ?? new WorkflowDispatchScheduler(resolveConcurrencyLimit(), signal);
2291
+ const rejectThroughPauseGate = /* @__PURE__ */ __name((error) => scheduler.waitUntilRunning().then(
2292
+ () => {
2293
+ throw error;
2294
+ },
2295
+ () => {
2296
+ throw error;
2297
+ }
2298
+ ), "rejectThroughPauseGate");
1752
2299
  let agentCount = 0;
1753
2300
  const emitter = req.emitter;
1754
2301
  const budget = req.budget;
@@ -1783,7 +2330,10 @@ var WorkflowOrchestrator = class {
1783
2330
  } catch (e) {
1784
2331
  debugLogger2.warn("emitter.agentCompleted threw:", e);
1785
2332
  }
1786
- return Promise.resolve(cached.result);
2333
+ return scheduler.waitUntilRunning().then(
2334
+ () => cached.result,
2335
+ () => cached.result
2336
+ );
1787
2337
  }
1788
2338
  }
1789
2339
  hadMiss = true;
@@ -1796,13 +2346,13 @@ var WorkflowOrchestrator = class {
1796
2346
  debugLogger2.warn(
1797
2347
  `[Workflow] budget gate refused dispatch at entry: runId=${runId} spent=${budget.spent()} total=${budget.total}`
1798
2348
  );
1799
- return Promise.reject(
2349
+ return rejectThroughPauseGate(
1800
2350
  new WorkflowBudgetExceededError(runId, budget.total, budget.spent())
1801
2351
  );
1802
2352
  }
1803
2353
  agentCount += 1;
1804
2354
  if (agentCount > maxAgents) {
1805
- return Promise.reject(
2355
+ return rejectThroughPauseGate(
1806
2356
  new Error(
1807
2357
  `Workflow exceeded the maximum of ${maxAgents} agent() calls per run.`
1808
2358
  )
@@ -1814,25 +2364,31 @@ var WorkflowOrchestrator = class {
1814
2364
  } catch (e) {
1815
2365
  debugLogger2.warn("emitter.agentDispatched threw:", e);
1816
2366
  }
1817
- return limiter.run(() => {
1818
- if (budget && budget.total !== null && budget.remaining() <= 0) {
1819
- debugLogger2.warn(
1820
- `[Workflow] budget gate refused dispatch at slot-acquire: runId=${runId} spent=${budget.spent()} total=${budget.total}`
1821
- );
1822
- throw new WorkflowBudgetExceededError(
1823
- runId,
1824
- budget.total,
1825
- budget.spent()
1826
- );
2367
+ let completionEmitted = false;
2368
+ const emitCompletion = /* @__PURE__ */ __name((error) => {
2369
+ if (completionEmitted) return;
2370
+ completionEmitted = true;
2371
+ const message = error === void 0 ? void 0 : error instanceof Error ? error.message : String(error);
2372
+ try {
2373
+ emitter?.agentCompleted?.(label, message);
2374
+ } catch (e) {
2375
+ debugLogger2.warn("emitter.agentCompleted threw:", e);
1827
2376
  }
1828
- return this.dispatch(prompt, opts);
1829
- }).then(
1830
- (result) => {
1831
- try {
1832
- emitter?.agentCompleted?.(label);
1833
- } catch (e) {
1834
- debugLogger2.warn("emitter.agentCompleted threw:", e);
2377
+ }, "emitCompletion");
2378
+ return scheduler.run(async () => {
2379
+ try {
2380
+ if (budget && budget.total !== null && budget.remaining() <= 0) {
2381
+ debugLogger2.warn(
2382
+ `[Workflow] budget gate refused dispatch at slot-acquire: runId=${runId} spent=${budget.spent()} total=${budget.total}`
2383
+ );
2384
+ throw new WorkflowBudgetExceededError(
2385
+ runId,
2386
+ budget.total,
2387
+ budget.spent()
2388
+ );
1835
2389
  }
2390
+ const result = await this.dispatch(prompt, opts);
2391
+ emitCompletion();
1836
2392
  if (journal && journalKey !== void 0) {
1837
2393
  journal.append({
1838
2394
  type: "result",
@@ -1851,14 +2407,8 @@ var WorkflowOrchestrator = class {
1851
2407
  }
1852
2408
  }
1853
2409
  return result;
1854
- },
1855
- (err) => {
1856
- const msg = err instanceof Error ? err.message : String(err);
1857
- try {
1858
- emitter?.agentCompleted?.(label, msg);
1859
- } catch (e) {
1860
- debugLogger2.warn("emitter.agentCompleted threw:", e);
1861
- }
2410
+ } catch (err) {
2411
+ emitCompletion(err);
1862
2412
  if (budget) {
1863
2413
  try {
1864
2414
  emitter?.budgetUpdated?.(budget.spent(), budget.total);
@@ -1868,35 +2418,70 @@ var WorkflowOrchestrator = class {
1868
2418
  }
1869
2419
  throw err;
1870
2420
  }
2421
+ }).then(
2422
+ // Resolve even if the gate aborts: a successful dispatch must not
2423
+ // turn into a teardown rejection — for a fire-and-forget call the
2424
+ // script never attached a handler, so the rejection would surface
2425
+ // as a spurious process-level unhandledRejection alarm on a
2426
+ // correctly-cancelled run.
2427
+ (result) => scheduler.waitUntilRunning().then(
2428
+ () => result,
2429
+ () => result
2430
+ ),
2431
+ (error) => {
2432
+ emitCompletion(error);
2433
+ return scheduler.waitUntilRunning().then(
2434
+ () => {
2435
+ throw error;
2436
+ },
2437
+ () => {
2438
+ throw error;
2439
+ }
2440
+ );
2441
+ }
1871
2442
  );
1872
2443
  }, "countedDispatch");
1873
2444
  const parallelImpl = makeParallelImpl(signal);
1874
2445
  const pipelineImpl = makePipelineImpl(signal);
1875
2446
  const resolveSavedWorkflow = req.resolveSavedWorkflow;
2447
+ const parentSandboxRef = {
2448
+ current: void 0
2449
+ };
1876
2450
  const workflowImpl = resolveSavedWorkflow ? async (nameOrRef, nestedArgs) => {
1877
2451
  const resolved = await resolveSavedWorkflow(nameOrRef);
1878
2452
  const nestedSandbox = createWorkflowSandbox({
1879
2453
  args: nestedArgs,
2454
+ runId,
1880
2455
  dispatch: countedDispatch,
1881
2456
  parallel: parallelImpl,
1882
2457
  pipeline: pipelineImpl,
1883
2458
  abortOnTimeout: req.abortOnTimeout,
1884
2459
  emitter,
1885
- budget
2460
+ budget,
2461
+ scheduler
1886
2462
  // No `workflow` — single-level nesting limit.
1887
2463
  });
1888
- return nestedSandbox.run(resolved.script);
2464
+ try {
2465
+ return await nestedSandbox.run(resolved.script);
2466
+ } finally {
2467
+ for (const line of nestedSandbox.getLogs()) {
2468
+ parentSandboxRef.current?.appendLog(line);
2469
+ }
2470
+ }
1889
2471
  } : void 0;
1890
2472
  const sandbox = createWorkflowSandbox({
1891
2473
  args: req.args,
2474
+ runId,
1892
2475
  dispatch: countedDispatch,
1893
2476
  parallel: parallelImpl,
1894
2477
  pipeline: pipelineImpl,
1895
2478
  workflow: workflowImpl,
1896
2479
  abortOnTimeout: req.abortOnTimeout,
1897
2480
  emitter,
1898
- budget
2481
+ budget,
2482
+ scheduler
1899
2483
  });
2484
+ parentSandboxRef.current = sandbox;
1900
2485
  try {
1901
2486
  const result = await sandbox.run(req.script);
1902
2487
  return {
@@ -2011,11 +2596,12 @@ __name(extractErrorMessage, "extractErrorMessage");
2011
2596
 
2012
2597
  // packages/core/src/agents/runtime/workflow-runner.ts
2013
2598
  var WorkflowRunHandle = class {
2014
- constructor(runId, budget, registry, controller, start) {
2599
+ constructor(runId, budget, registry, controller, scheduler, start) {
2015
2600
  this.runId = runId;
2016
2601
  this.budget = budget;
2017
2602
  this.registry = registry;
2018
2603
  this.controller = controller;
2604
+ this.scheduler = scheduler;
2019
2605
  this.completion = Promise.resolve().then(start);
2020
2606
  }
2021
2607
  static {
@@ -2025,6 +2611,12 @@ var WorkflowRunHandle = class {
2025
2611
  abort() {
2026
2612
  this.controller.abort();
2027
2613
  }
2614
+ pause() {
2615
+ return this.scheduler.pause();
2616
+ }
2617
+ resume() {
2618
+ return this.scheduler.resume();
2619
+ }
2028
2620
  };
2029
2621
  var WorkflowRunner = class {
2030
2622
  static {
@@ -2103,11 +2695,17 @@ var WorkflowRunner = class {
2103
2695
  emitUpdate();
2104
2696
  }, "budgetUpdated")
2105
2697
  };
2698
+ const scheduler = new WorkflowDispatchScheduler(
2699
+ resolveConcurrencyLimit(),
2700
+ controller.signal,
2701
+ ({ state }) => registry?.onDispatchStateChange(runId, state)
2702
+ );
2106
2703
  const handle = new WorkflowRunHandle(
2107
2704
  runId,
2108
2705
  budget,
2109
2706
  registry,
2110
2707
  controller,
2708
+ scheduler,
2111
2709
  async () => {
2112
2710
  try {
2113
2711
  const outcome = await orchestrator.run({
@@ -2119,7 +2717,8 @@ var WorkflowRunner = class {
2119
2717
  budget,
2120
2718
  resolveSavedWorkflow: /* @__PURE__ */ __name((ref) => resolveSavedWorkflowScript(ref, config), "resolveSavedWorkflow"),
2121
2719
  journal,
2122
- resumeReplay
2720
+ resumeReplay,
2721
+ scheduler
2123
2722
  });
2124
2723
  if (entry) {
2125
2724
  entry.meta = outcome.meta;
@@ -2128,6 +2727,12 @@ var WorkflowRunner = class {
2128
2727
  }
2129
2728
  }
2130
2729
  registry?.setRecentLogs(runId, outcome.logs);
2730
+ if (entry && isTerminalWorkflowStatus(entry.status)) {
2731
+ return {
2732
+ ok: false,
2733
+ message: entry.status === "cancelled" ? "Workflow run cancelled." : entry.error ?? "Workflow run failed."
2734
+ };
2735
+ }
2131
2736
  registry?.complete(runId, outcome.result, Date.now());
2132
2737
  return { ok: true, outcome };
2133
2738
  } catch (error) {
@@ -2143,20 +2748,18 @@ var WorkflowRunner = class {
2143
2748
  return { ok: false, message, details };
2144
2749
  } finally {
2145
2750
  controller.abort();
2146
- if (entry && entry.status !== "running") {
2751
+ if (entry && isTerminalWorkflowStatus(entry.status)) {
2752
+ const telemetryEvent = new WorkflowRunEvent({
2753
+ status: entry.status,
2754
+ agents_dispatched: entry.agentsDispatched,
2755
+ agents_completed: entry.agentsCompleted,
2756
+ phase_count: entry.phases.length,
2757
+ tokens_spent: entry.tokensSpent,
2758
+ duration_ms: (entry.endTime ?? entry.startTime) - entry.startTime
2759
+ });
2147
2760
  await writeWorkflowSnapshot(config, entry);
2148
2761
  try {
2149
- logWorkflowRun(
2150
- config,
2151
- new WorkflowRunEvent({
2152
- status: entry.status,
2153
- agents_dispatched: entry.agentsDispatched,
2154
- agents_completed: entry.agentsCompleted,
2155
- phase_count: entry.phases.length,
2156
- tokens_spent: entry.tokensSpent,
2157
- duration_ms: (entry.endTime ?? entry.startTime) - entry.startTime
2158
- })
2159
- );
2762
+ logWorkflowRun(config, telemetryEvent);
2160
2763
  } catch {
2161
2764
  }
2162
2765
  }
@@ -2201,7 +2804,7 @@ var WORKFLOW_PARAM_SCHEMA = {
2201
2804
  run_in_background: {
2202
2805
  type: "boolean",
2203
2806
  default: false,
2204
- description: "Optional. When true, start the workflow under the interactive session and return a run handle immediately. The Background Tasks view can observe or stop it, and completion is delivered to the conversation when the run settles. Interactive TUI only. Defaults to false."
2807
+ description: "Optional. When true, start the workflow under the interactive session and return a run handle immediately. The Background Tasks view can observe, cooperatively pause/resume, or stop it, and completion is delivered to the conversation when the run settles. Interactive TUI only. Defaults to false."
2205
2808
  }
2206
2809
  }
2207
2810
  // `script` is required UNLESS `scriptPath` is supplied; this XOR can't be
@@ -2269,7 +2872,7 @@ Run ID: ${handle.runId}
2269
2872
  Status: ${status}`
2270
2873
  }
2271
2874
  ],
2272
- returnDisplay: usageBanner + `Workflow ${handle.runId} started in the background (status: ${status}). Use Background Tasks to observe or stop it.`
2875
+ returnDisplay: usageBanner + `Workflow ${handle.runId} started in the background (status: ${status}). Use Background Tasks to observe, cooperatively pause/resume, or stop it.`
2273
2876
  };
2274
2877
  }
2275
2878
  const settlement = await handle.completion;
@@ -2419,7 +3022,7 @@ var WorkflowTool = class extends BaseDeclarativeTool {
2419
3022
  super(
2420
3023
  ToolNames.WORKFLOW,
2421
3024
  ToolDisplayNames.WORKFLOW,
2422
- "Execute a workflow script that orchestrates subagents. Supports `phase`, `log`, sequential `agent`, concurrent fan-out via `parallel(thunks)` / `pipeline(items, ...stages)` (default `max(1, min(16, cpus-2))` agents in flight per run, up to 1000 agents total; both env-overridable), per-call `agent({ schema, agentType, model, isolation: 'worktree' })` for structured-output contracts, declarative-agent selection, model override, and git-worktree-isolated subagents. Pass `resumeFromRunId` to resume a prior run \u2014 agent() calls whose rolling prefix-hash matches the journal are served from cache for the longest unchanged prefix. Runs are tracked in the background-tasks view and the `/workflows` dialog (live phase tree, token usage, cancel). Set `run_in_background: true` to return a run handle immediately in the interactive TUI and receive completion through the conversation. Scripts run in a node:vm sandbox without access to the filesystem or shell; all I/O happens through the spawned agents.",
3025
+ "Execute a workflow script that orchestrates subagents. Supports `phase`, `log`, sequential `agent`, concurrent fan-out via `parallel(thunks)` / `pipeline(items, ...stages)` (default `max(1, min(16, cpus-2))` agents in flight per run, up to 1000 agents total; both env-overridable), per-call `agent({ schema, agentType, model, isolation: 'worktree' })` for structured-output contracts, declarative-agent selection, model override, and git-worktree-isolated subagents. Pass `resumeFromRunId` to resume a prior run \u2014 agent() calls whose rolling prefix-hash matches the journal are served from cache for the longest unchanged prefix. Runs are tracked in the background-tasks view and the `/workflows` dialog (live phase tree, token usage, cooperative pause/resume, cancel). Set `run_in_background: true` to return a run handle immediately in the interactive TUI and receive completion through the conversation. Scripts run in a node:vm sandbox without access to the filesystem or shell; all I/O happens through the spawned agents.",
2423
3026
  "other" /* Other */,
2424
3027
  WORKFLOW_PARAM_SCHEMA,
2425
3028
  /* isOutputMarkdown */