@qwen-code/qwen-code 0.20.0-nightly.20260722.b98306b7e → 0.20.0

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 (341) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +1 -1
  2. package/bundled/qc-helper/docs/features/auto-mode.md +16 -19
  3. package/bundled/qc-helper/docs/features/commands.md +0 -54
  4. package/bundled/qc-helper/docs/features/sub-agents.md +7 -16
  5. package/bundled/qc-helper/docs/integration-github-action.md +10 -10
  6. package/bundled/qc-helper/docs/qwen-serve.md +1 -2
  7. package/bundled/review/DESIGN.md +2 -2
  8. package/bundled/review/SKILL.md +4 -4
  9. package/chunks/{MaxSizedBox-YO432SD4.js → MaxSizedBox-B5YGZSYE.js} +34 -41
  10. package/chunks/{StandaloneSessionPicker-525JBPXC.js → StandaloneSessionPicker-CEGO2AZX.js} +50 -57
  11. package/chunks/{acpAgent-FORCZCBG.js → acpAgent-YUR43TLG.js} +496 -1487
  12. package/chunks/{agent-OZCWHX2J.js → agent-H4JIDL7S.js} +30 -37
  13. package/chunks/agent-headless-TTBEREQV.js +61 -0
  14. package/chunks/{anthropicContentGenerator-NMSS7IMV.js → anthropicContentGenerator-HVKLXOOU.js} +12 -13
  15. package/chunks/{artifact-tool-56T5IMBP.js → artifact-tool-WBCAMD3O.js} +3 -3
  16. package/chunks/{askUserQuestion-E25OBIC2.js → askUserQuestion-6DZC4UV5.js} +3 -3
  17. package/chunks/{bridge-HUUBAUDS.js → bridge-VL7ITBU5.js} +35 -42
  18. package/chunks/{build-GHIZ4MSZ.js → build-SSCNEHZZ.js} +1 -1
  19. package/chunks/{ca-N6VVUFVB.js → ca-2SL2BXTK.js} +201 -611
  20. package/chunks/{channel-worker-group-LFBT7K64.js → channel-worker-group-53CMOPFT.js} +5 -5
  21. package/chunks/{channel-worker-manager-3RUPERG2.js → channel-worker-manager-UTXILKC2.js} +5 -5
  22. package/chunks/{channel-worker-supervisor-A3KVATD3.js → channel-worker-supervisor-ZGO2W2MD.js} +4 -4
  23. package/chunks/{chunk-2LI23QA6.js → chunk-2HOVDT7W.js} +1 -1
  24. package/chunks/{chunk-QSZOJHCQ.js → chunk-2LL7TXB4.js} +2 -2
  25. package/chunks/{chunk-EGMNITTR.js → chunk-333CXMNJ.js} +5 -5
  26. package/chunks/{chunk-DGKZ6QL3.js → chunk-33XUAINQ.js} +21 -61
  27. package/chunks/{chunk-DKT6SIJC.js → chunk-4EP2PYYL.js} +5 -5
  28. package/chunks/{chunk-QW3QUYG5.js → chunk-4ILMYHEI.js} +3 -3
  29. package/chunks/{chunk-B5KE3KNO.js → chunk-4N3KMAIL.js} +32 -128
  30. package/chunks/{chunk-6ZBPS62S.js → chunk-4ODB7WIB.js} +1 -1
  31. package/chunks/{chunk-5XPUJM4N.js → chunk-4XNLIGVA.js} +298 -576
  32. package/chunks/{chunk-67SZUDUH.js → chunk-542SK7KV.js} +1608 -243
  33. package/chunks/{chunk-RZZNAWTE.js → chunk-5JBR5XIK.js} +2 -2
  34. package/chunks/{chunk-E4IMU4Y5.js → chunk-5SCI6E3E.js} +1 -1
  35. package/chunks/{chunk-ZKY7USAE.js → chunk-6AFUCL3D.js} +1 -1
  36. package/chunks/{chunk-5I5BM454.js → chunk-6EFTQYW7.js} +1 -1
  37. package/chunks/{chunk-BXCXDT2T.js → chunk-7PZ2ATFZ.js} +29 -54
  38. package/chunks/{chunk-FJZPCXZM.js → chunk-7RMOXZTC.js} +4 -4
  39. package/chunks/{chunk-XPWXDCW5.js → chunk-7SXZC7ID.js} +6 -7
  40. package/chunks/{chunk-O2WEV2LS.js → chunk-A5LYNIW7.js} +8 -8
  41. package/chunks/{chunk-SEHBVG2S.js → chunk-AJSJ5TTU.js} +1 -1
  42. package/chunks/{chunk-422RQSNN.js → chunk-AKX4WPPP.js} +86 -307
  43. package/chunks/{chunk-QVQCCBMW.js → chunk-ANPINBOF.js} +5 -5
  44. package/chunks/{chunk-JJEFX6U5.js → chunk-AQIEINAY.js} +1766 -28
  45. package/chunks/{chunk-7Z6JQEL6.js → chunk-AYCDXHZB.js} +1 -1
  46. package/chunks/{chunk-BKZEHVPV.js → chunk-B3KGZCQN.js} +169 -177
  47. package/chunks/{chunk-6X4GWOPW.js → chunk-BDBMYST4.js} +1 -1
  48. package/chunks/{chunk-25WFJZL5.js → chunk-BMWMT5Y2.js} +373 -3
  49. package/chunks/{chunk-EDANOBFR.js → chunk-BRRF37CO.js} +6 -6
  50. package/chunks/{chunk-QLJUC7TG.js → chunk-BVLROR2T.js} +1 -1
  51. package/chunks/{chunk-OQB4EXO4.js → chunk-C27BYUX6.js} +11 -14
  52. package/chunks/{chunk-GDBCCE2J.js → chunk-CB2HFGRV.js} +6 -31
  53. package/chunks/chunk-CPCVCKKF.js +358 -0
  54. package/chunks/{chunk-K6YXJ3J5.js → chunk-CV63PP6U.js} +1 -1
  55. package/chunks/{chunk-BWGIRN4Z.js → chunk-CZF3E5GF.js} +1 -1
  56. package/chunks/{chunk-6NAAGP57.js → chunk-D22SX43D.js} +1 -1
  57. package/chunks/{chunk-X6N25LXS.js → chunk-D2VIDMVM.js} +2 -2
  58. package/chunks/{chunk-E7O22QBU.js → chunk-DBE4QFZS.js} +23 -27
  59. package/chunks/{chunk-4ZAHUGSC.js → chunk-DP5GXXNZ.js} +1 -5
  60. package/chunks/{chunk-Q2YKNMLS.js → chunk-EAUYY7SS.js} +3 -3
  61. package/chunks/{chunk-KHOVYUHX.js → chunk-EIAK6Q2B.js} +2 -2
  62. package/chunks/{chunk-NPQDJGKU.js → chunk-EZVDJFZ7.js} +1 -1
  63. package/chunks/{chunk-FODK6UMO.js → chunk-FEOZBUMT.js} +27 -0
  64. package/chunks/{chunk-6NHK6HS7.js → chunk-FLSVD6BS.js} +3 -3
  65. package/chunks/{chunk-LLJNFFFT.js → chunk-FQD7GFSV.js} +3 -3
  66. package/chunks/{chunk-T2L47JJK.js → chunk-FSL5W5TI.js} +3 -3
  67. package/chunks/{chunk-JCW2R7WC.js → chunk-G45X5TRN.js} +72 -1
  68. package/chunks/{chunk-ZHERRXZJ.js → chunk-GKY2OJ7R.js} +1 -1
  69. package/chunks/{chunk-6IL7KRLE.js → chunk-GMGDLUC7.js} +1 -1
  70. package/chunks/{chunk-N2HDLRGT.js → chunk-HZPN55E5.js} +1 -1
  71. package/chunks/{chunk-NTC7J4X7.js → chunk-I2PYAYFM.js} +3 -3
  72. package/chunks/{chunk-RVWSD6GI.js → chunk-IR46U7RB.js} +3 -3
  73. package/chunks/{chunk-W6E7KTQL.js → chunk-IVPSS6EL.js} +4 -4
  74. package/chunks/{chunk-4K56OJFJ.js → chunk-JD3MKVKL.js} +1 -1
  75. package/chunks/{chunk-SP5WRGVG.js → chunk-JNWZQ27S.js} +3 -3
  76. package/chunks/{chunk-VAUDHMX6.js → chunk-KDC6GNQR.js} +4 -4
  77. package/chunks/{chunk-5TSCAYXT.js → chunk-KG3XV6FH.js} +2 -29
  78. package/chunks/{chunk-HCQ2Q3KF.js → chunk-KOR3XKCA.js} +4 -10
  79. package/chunks/{chunk-52Y2T4L3.js → chunk-KQNM4EO7.js} +5 -137
  80. package/chunks/{chunk-4K7VDKAD.js → chunk-KTUQMDEP.js} +1 -1
  81. package/chunks/{chunk-Z2FTZM4Z.js → chunk-KX6UK4VJ.js} +19929 -22391
  82. package/chunks/{chunk-JYS55H6Z.js → chunk-MAQQGNQ5.js} +7 -66
  83. package/chunks/{chunk-7FNV372W.js → chunk-MJ6S23WZ.js} +4 -4
  84. package/chunks/{chunk-D7WXIW7H.js → chunk-NBMIC7DR.js} +4 -4
  85. package/chunks/{chunk-HGGEN2SC.js → chunk-NDMQLV4Y.js} +4 -4
  86. package/chunks/{chunk-FFFM6NJV.js → chunk-NEEB7UEN.js} +2 -1
  87. package/chunks/{chunk-WKGGZF7Z.js → chunk-NGFEPAE6.js} +6 -8
  88. package/chunks/{chunk-RVLZCXEE.js → chunk-NIJEXGV6.js} +10 -79
  89. package/chunks/{chunk-LMY4HCMA.js → chunk-O3OCNYY5.js} +2 -2
  90. package/chunks/{chunk-RIEABAJC.js → chunk-O3Z73NBP.js} +7 -7
  91. package/chunks/{chunk-VBZBVAQ3.js → chunk-OEO2ERWK.js} +33 -54
  92. package/chunks/{chunk-KQQ757OQ.js → chunk-OLMETXLX.js} +2 -2
  93. package/chunks/{chunk-LIZRAKPB.js → chunk-OOCI5VVU.js} +1 -1
  94. package/chunks/{chunk-GPSKDNEE.js → chunk-OONJNQ42.js} +3 -3
  95. package/chunks/{chunk-YM3SZTH4.js → chunk-OP4MOGXF.js} +1 -8
  96. package/chunks/{chunk-FCPNARPD.js → chunk-OWCALFEG.js} +1 -1
  97. package/chunks/{chunk-MPZ34JE7.js → chunk-OYZWQNWG.js} +2 -2
  98. package/chunks/{chunk-QBUDF33N.js → chunk-PBATSWUQ.js} +1 -1
  99. package/chunks/{chunk-6MNDXSG6.js → chunk-PBWEWI4N.js} +69 -76
  100. package/chunks/{chunk-OCCDRJIS.js → chunk-PF4CHQOJ.js} +6 -6
  101. package/chunks/{chunk-BH32VITB.js → chunk-PGEPSDJI.js} +8 -13
  102. package/chunks/{chunk-4LVZNIDO.js → chunk-QKYTTBYW.js} +1 -1
  103. package/chunks/{chunk-VYPFXUCB.js → chunk-R3VWUU2E.js} +1 -1
  104. package/chunks/{chunk-RV4C2ZFG.js → chunk-RFIAR4YL.js} +1 -1
  105. package/chunks/{chunk-P4B4SXDS.js → chunk-S2PD3EZD.js} +1 -1
  106. package/chunks/{chunk-H6T65C7O.js → chunk-S2W2LVDU.js} +3 -3
  107. package/chunks/{chunk-VJ4P64ID.js → chunk-S2XVRHDN.js} +1 -1
  108. package/chunks/chunk-SEKHYHMS.js +45 -0
  109. package/chunks/{chunk-JNEA3NW7.js → chunk-SJMV7ZBK.js} +8 -8
  110. package/chunks/{chunk-THJNPLI4.js → chunk-TB6UDU4T.js} +16 -16
  111. package/chunks/{chunk-R3D7SK6L.js → chunk-TIH2ZTOC.js} +2 -2
  112. package/chunks/{chunk-3FML67YK.js → chunk-TKLLK6XQ.js} +11 -11
  113. package/chunks/{chunk-SMVDDPEJ.js → chunk-TMQ6XQCX.js} +53 -170
  114. package/chunks/{chunk-QNLNLENL.js → chunk-UEY4AYUL.js} +2 -2
  115. package/chunks/{chunk-BLTELXOK.js → chunk-VDWBQ5AW.js} +1 -1
  116. package/chunks/{chunk-WGBLCAVW.js → chunk-VEXFOTEO.js} +3 -3
  117. package/chunks/{chunk-4RAFVWW2.js → chunk-VZQUV7VK.js} +1 -1
  118. package/chunks/chunk-W7FJ3N32.js +49 -0
  119. package/chunks/{chunk-UGYMA4EI.js → chunk-W7H223ZZ.js} +1 -1
  120. package/chunks/{chunk-UH3WSE5L.js → chunk-X6YQWCIJ.js} +1 -13
  121. package/chunks/{chunk-H4AR2JQF.js → chunk-XVVH63JG.js} +3 -3
  122. package/chunks/{chunk-QKTHJXCS.js → chunk-Y2ENGUD6.js} +1 -1
  123. package/chunks/{chunk-QD6BRERJ.js → chunk-YWEW33JY.js} +7 -7
  124. package/chunks/{chunk-57FIIFJN.js → chunk-ZEOZL37W.js} +1 -1
  125. package/chunks/chunk-ZFKNWQGQ.js +74639 -0
  126. package/chunks/{computer-use-XPLRRVJM.js → computer-use-NIWQNUZF.js} +35 -42
  127. package/chunks/{config-utils-WYUQ7II4.js → config-utils-AHQ6YZ66.js} +3 -3
  128. package/chunks/contextCommand-L2COEUHS.js +66 -0
  129. package/chunks/{create-sub-session-5YJR5PAM.js → create-sub-session-MGNX52P3.js} +30 -37
  130. package/chunks/{create-sub-session-AZ77LBL3.js → create-sub-session-P26FE5GG.js} +3 -3
  131. package/chunks/{cron-create-KTWJM7QT.js → cron-create-JWFHBDRQ.js} +5 -5
  132. package/chunks/{cron-delete-2P3I5ULL.js → cron-delete-GDX4E26G.js} +5 -5
  133. package/chunks/{cron-list-PXDPGEDQ.js → cron-list-USMAIWPT.js} +5 -5
  134. package/chunks/{daemon-KLPTQIE4.js → daemon-RG2MAI6T.js} +81 -138
  135. package/chunks/daemon-status-provider-NL4IAG7B.js +74 -0
  136. package/chunks/{de-4IBXM7CN.js → de-I7ZIYXZC.js} +1 -5
  137. package/chunks/{dist-HMU6CYS4.js → dist-2BHAYBKP.js} +2 -2
  138. package/chunks/{dist-PJLG2XYX.js → dist-2MIU4UUH.js} +1 -1
  139. package/chunks/{dist-UIFWIFRO.js → dist-53PZYC5B.js} +2 -2
  140. package/chunks/{dist-OAV7LJGJ.js → dist-AU7NQQRP.js} +1 -1
  141. package/chunks/{dist-OMW6WDEO.js → dist-FUTEXY6A.js} +1 -1
  142. package/chunks/{dist-XRYV6TJP.js → dist-WGTQO7F2.js} +25 -65
  143. package/chunks/{earlyInputCapture-XMECIN6Y.js → earlyInputCapture-L6I2A22T.js} +31 -38
  144. package/chunks/{edit-MMPLBVZU.js → edit-3QV3JZJL.js} +37 -42
  145. package/chunks/{en-USMCCJAJ.js → en-XE34GKAA.js} +1 -5
  146. package/chunks/{enter-worktree-BD7MCCG7.js → enter-worktree-4GMMF7EG.js} +35 -42
  147. package/chunks/{enterPlanMode-BQNJC23R.js → enterPlanMode-L5UWBAUC.js} +36 -48
  148. package/chunks/{environment-F3KL5Z5S.js → environment-3OV7UQOT.js} +32 -39
  149. package/chunks/{errors-VJ544HIS.js → errors-LEOF5QG4.js} +32 -39
  150. package/chunks/{exit-worktree-RDIQXZMI.js → exit-worktree-DDP57JLV.js} +35 -42
  151. package/chunks/{exitPlanMode-UNCZQPTX.js → exitPlanMode-CJBLGPIP.js} +35 -42
  152. package/chunks/{fast-path-H7N32H7D.js → fast-path-M6RP2ING.js} +3 -4
  153. package/chunks/{fast-path-settings-XB3CPUJT.js → fast-path-settings-DAOVFADC.js} +2 -2
  154. package/chunks/{fr-WVHEBDDB.js → fr-X7KDVZIY.js} +1 -5
  155. package/chunks/{gemini-G4VKT5DQ.js → gemini-H4PHBJTL.js} +89 -97
  156. package/chunks/{geminiContentGenerator-MDAL2B4C.js → geminiContentGenerator-VURJYPWP.js} +5 -5
  157. package/chunks/{getMachineId-bsd-QFVLPUPT.js → getMachineId-bsd-EXV7SWPA.js} +1 -1
  158. package/chunks/{getMachineId-darwin-DGMQQE2E.js → getMachineId-darwin-IUOMFXU3.js} +1 -1
  159. package/chunks/{getMachineId-linux-R4Z6CSWC.js → getMachineId-linux-K7XJYFHL.js} +1 -1
  160. package/chunks/{getMachineId-unsupported-Z3SBVBUV.js → getMachineId-unsupported-EA5FDRJ6.js} +1 -1
  161. package/chunks/{getMachineId-win-SCK5UFDT.js → getMachineId-win-KBA6RAI5.js} +1 -1
  162. package/chunks/{glob-JBT6FGZL.js → glob-2KUSRAVQ.js} +35 -42
  163. package/chunks/{grep-5NUIQ63X.js → grep-B5RXVESV.js} +35 -42
  164. package/chunks/handleAutoUpdate-QQVIWXKT.js +67 -0
  165. package/chunks/{i18n-IPHO7BGL.js → i18n-N6OBDORT.js} +31 -38
  166. package/chunks/initializer-6WCFNDLL.js +72 -0
  167. package/chunks/installationInfo-6J3WPXNS.js +64 -0
  168. package/chunks/{ja-KY4ROZTE.js → ja-2ICT3KXF.js} +1 -5
  169. package/chunks/{keychain-token-storage-6ACJDYIB.js → keychain-token-storage-DWRJMNH3.js} +3 -3
  170. package/chunks/list-HOWQSWP6.js +75 -0
  171. package/chunks/loadedSettingsAdapter-AO4YBRXZ.js +69 -0
  172. package/chunks/{loop-wakeup-RNMRVA66.js → loop-wakeup-5GLTUBHA.js} +6 -6
  173. package/chunks/{ls-J2ZI5XYK.js → ls-FHBY3Y7I.js} +5 -5
  174. package/chunks/{lsp-UMS3NUB5.js → lsp-B6VMEW6Y.js} +3 -3
  175. package/chunks/mcp-QH7QNXOH.js +69 -0
  176. package/chunks/{monitor-SIX5LMEK.js → monitor-GLJZDNPS.js} +35 -42
  177. package/chunks/nonInteractiveCli-TI7EMPXD.js +126 -0
  178. package/chunks/{notebook-edit-CWVOTW3I.js → notebook-edit-AVCIWS4F.js} +38 -43
  179. package/chunks/{openaiContentGenerator-FELHHJAN.js → openaiContentGenerator-B7W24G3D.js} +17 -22
  180. package/chunks/{pidfile-2ZQGHGPJ.js → pidfile-UEHAT6DH.js} +31 -38
  181. package/chunks/{processUtils-M3RKQCI4.js → processUtils-XZPY2PBB.js} +2 -2
  182. package/chunks/{pt-OK455PLH.js → pt-JJ4XPIBP.js} +1 -5
  183. package/chunks/{qwenContentGenerator-RBFIZMBC.js → qwenContentGenerator-6GUTWJIC.js} +35 -44
  184. package/chunks/{qwenOAuth2-S2BUDQM3.js → qwenOAuth2-GASEEWGU.js} +15 -18
  185. package/chunks/{read-file-WQCCV6HY.js → read-file-SQJONF6A.js} +11 -13
  186. package/chunks/{read-mcp-resource-F6HYMDUY.js → read-mcp-resource-AKCL7I43.js} +3 -3
  187. package/chunks/{record-artifact-7GCFLDD7.js → record-artifact-PEUB7727.js} +3 -3
  188. package/chunks/{resumeHistoryUtils-NDYMU2WO.js → resumeHistoryUtils-PFQ2A23X.js} +36 -43
  189. package/chunks/ripGrep-QCK22GDU.js +59 -0
  190. package/chunks/{ru-7SPDGMGD.js → ru-STR4KTW7.js} +1 -5
  191. package/chunks/{run-qwen-serve-FY5MMHPN.js → run-qwen-serve-OZGR3FQA.js} +82 -104
  192. package/chunks/{runtime-LONMMWKO.js → runtime-SNVAP6EH.js} +40 -49
  193. package/chunks/{scheduler-KYNL2MHI.js → scheduler-Z7QLMUWA.js} +30 -37
  194. package/chunks/{send-message-PYIJ2PZL.js → send-message-3RHE7HSM.js} +4 -6
  195. package/chunks/{serve-VNORFL4H.js → serve-BT7KS6SC.js} +36 -43
  196. package/chunks/{server-X2KCJKA3.js → server-SO64U3X5.js} +284 -988
  197. package/chunks/{session-CSYW4ELX.js → session-2KL2WQAH.js} +173 -92
  198. package/chunks/{settings-QZJ4XWS3.js → settings-KITVOUSV.js} +39 -46
  199. package/chunks/{shell-ELMKOZKP.js → shell-BITUVH2R.js} +30 -37
  200. package/chunks/{skill-IBUGJX5S.js → skill-SOQHY455.js} +20 -24
  201. package/chunks/{spawnChannel-SWCGOB2N.js → spawnChannel-2BU3AULL.js} +32 -39
  202. package/chunks/{src-FOUKVFPZ.js → src-43LM7JLB.js} +209 -279
  203. package/chunks/{standalone-update-5U5IRIN5.js → standalone-update-YG5JUYCM.js} +32 -39
  204. package/chunks/{startInteractiveUI-B3KIQ363.js → startInteractiveUI-3RGTGEX5.js} +895 -1092
  205. package/chunks/{syntheticOutput-H7RTI5KL.js → syntheticOutput-FG5PQKIR.js} +4 -4
  206. package/chunks/{task-create-7474AJJD.js → task-create-HX32YXO7.js} +8 -10
  207. package/chunks/{task-list-633HGOIB.js → task-list-QWSY4ZIU.js} +6 -6
  208. package/chunks/{task-stop-MNUGHPIA.js → task-stop-GWC6UWAL.js} +3 -3
  209. package/chunks/{task-update-66GQB5LI.js → task-update-NCTAB73Q.js} +8 -10
  210. package/chunks/{team-create-AT3OPBS4.js → team-create-FXN3PEBP.js} +35 -42
  211. package/chunks/{team-delete-BB3CG3QF.js → team-delete-KK37HTOG.js} +6 -6
  212. package/chunks/{team-plan-approval-6AYAQ3KG.js → team-plan-approval-GEIZ356Q.js} +35 -42
  213. package/chunks/theme-manager-IAETOI25.js +63 -0
  214. package/chunks/{todoWrite-KRAUN54W.js → todoWrite-ERCAMLFS.js} +5 -5
  215. package/chunks/{tool-search-2ZFYIVVW.js → tool-search-XKK7DNOK.js} +17 -21
  216. package/chunks/total-session-admission-BJLDHKJN.js +69 -0
  217. package/chunks/{trustedFolders-VHGVDSZU.js → trustedFolders-5XCVNEUU.js} +31 -38
  218. package/chunks/{update-relaunch-RM5E3W4P.js → update-relaunch-FMVZK6XF.js} +17 -17
  219. package/chunks/updateCheck-YZZB7YBU.js +70 -0
  220. package/chunks/{useAutoAcceptIndicator-AAPKHC46.js → useAutoAcceptIndicator-ZSQX4I2H.js} +40 -47
  221. package/chunks/{validateNonInterActiveAuth-7WGVSFOZ.js → validateNonInterActiveAuth-PRVEB6GG.js} +72 -79
  222. package/chunks/{version-M7BDNXTT.js → version-AZMG6KWL.js} +1 -1
  223. package/chunks/{web-fetch-UZSKXY3L.js → web-fetch-EPGJ5OQQ.js} +41 -100
  224. package/chunks/{workflow-OCSRM2L2.js → workflow-UTNVPW22.js} +39 -47
  225. package/chunks/workspace-providers-status-EADV364W.js +72 -0
  226. package/chunks/{workspace-registration-store-QDOLWEMY.js → workspace-registration-store-F3ZX3YHT.js} +2 -8
  227. package/chunks/workspace-registry-W6VMFYZU.js +73 -0
  228. package/chunks/workspace-service-F3KIN2UN.js +84 -0
  229. package/chunks/workspace-skills-status-YVICUR5Y.js +71 -0
  230. package/chunks/write-file-CVGF2OKV.js +596 -0
  231. package/chunks/{zh-WY5DWYZD.js → zh-6ANG2HTL.js} +1 -5
  232. package/chunks/{zh-TW-BM47YBFH.js → zh-TW-4RR3YHNN.js} +1 -5
  233. package/cli-entry.js +12 -164
  234. package/cli.js +11 -18
  235. package/locales/ca.js +203 -772
  236. package/locales/de.js +2 -8
  237. package/locales/en.js +2 -8
  238. package/locales/fr.js +2 -8
  239. package/locales/ja.js +2 -8
  240. package/locales/pt.js +2 -8
  241. package/locales/ru.js +2 -8
  242. package/locales/zh-TW.js +2 -8
  243. package/locales/zh.js +2 -8
  244. package/package.json +3 -3
  245. package/web-shell/assets/{arc-ByltRugA.js → arc-Buk1besA.js} +1 -1
  246. package/web-shell/assets/{architectureDiagram-3BPJPVTR-CCRTto5d.js → architectureDiagram-3BPJPVTR-B1aUKYDC.js} +1 -1
  247. package/web-shell/assets/{blockDiagram-GPEHLZMM-Jfy36u1L.js → blockDiagram-GPEHLZMM-CRTdg3Zx.js} +1 -1
  248. package/web-shell/assets/{c4Diagram-AAUBKEIU-4d5FfEZ0.js → c4Diagram-AAUBKEIU-DFdRMp5g.js} +1 -1
  249. package/web-shell/assets/channel-04R0vLbG.js +1 -0
  250. package/web-shell/assets/{chunk-2J33WTMH-BPwxCEro.js → chunk-2J33WTMH-4rYQdkEI.js} +1 -1
  251. package/web-shell/assets/{chunk-4BX2VUAB-jY7ZmJWY.js → chunk-4BX2VUAB-Coi-pQJy.js} +1 -1
  252. package/web-shell/assets/{chunk-55IACEB6-C98HgCsS.js → chunk-55IACEB6-BtBjz02t.js} +1 -1
  253. package/web-shell/assets/{chunk-727SXJPM-cDu-ge-q.js → chunk-727SXJPM-CGYOWorl.js} +1 -1
  254. package/web-shell/assets/{chunk-AQP2D5EJ-BKdJwxXK.js → chunk-AQP2D5EJ-CH5AKhqx.js} +1 -1
  255. package/web-shell/assets/{chunk-FMBD7UC4-DnuxqwMu.js → chunk-FMBD7UC4-Cd50-w85.js} +1 -1
  256. package/web-shell/assets/{chunk-ND2GUHAM-C4fZNPv0.js → chunk-ND2GUHAM-C2wF3KCK.js} +1 -1
  257. package/web-shell/assets/{chunk-QZHKN3VN-Cf4XWOmz.js → chunk-QZHKN3VN-pCeRTaWi.js} +1 -1
  258. package/web-shell/assets/classDiagram-4FO5ZUOK-Bw9SOwAV.js +1 -0
  259. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Bw9SOwAV.js +1 -0
  260. package/web-shell/assets/{cose-bilkent-S5V4N54A-C82mFiqj.js → cose-bilkent-S5V4N54A-B-_fAB6D.js} +1 -1
  261. package/web-shell/assets/{dagre-BM42HDAG-Df8KACER.js → dagre-BM42HDAG-ChSPNHpL.js} +1 -1
  262. package/web-shell/assets/{diagram-2AECGRRQ-EzNs7s_2.js → diagram-2AECGRRQ-BX7cFOF3.js} +1 -1
  263. package/web-shell/assets/{diagram-5GNKFQAL-BRLNvreg.js → diagram-5GNKFQAL-BQUTW92n.js} +1 -1
  264. package/web-shell/assets/{diagram-KO2AKTUF-2HLYHRjC.js → diagram-KO2AKTUF-BkYPh3e4.js} +1 -1
  265. package/web-shell/assets/{diagram-LMA3HP47-DeH0NzSp.js → diagram-LMA3HP47-Cl6jsNyx.js} +1 -1
  266. package/web-shell/assets/{diagram-OG6HWLK6-k5Gn47-G.js → diagram-OG6HWLK6-DRWoHz8n.js} +1 -1
  267. package/web-shell/assets/{erDiagram-TEJ5UH35-gPHFo79f.js → erDiagram-TEJ5UH35-CGvFcZco.js} +1 -1
  268. package/web-shell/assets/{flowDiagram-I6XJVG4X-DYBOiTRW.js → flowDiagram-I6XJVG4X-vms6oVdv.js} +1 -1
  269. package/web-shell/assets/{ganttDiagram-6RSMTGT7-cxjAuic9.js → ganttDiagram-6RSMTGT7-ukT_sfmi.js} +1 -1
  270. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-3nPqpmCP.js → gitGraphDiagram-PVQCEYII-Bn2ZE2Ut.js} +1 -1
  271. package/web-shell/assets/index-DgkKrjw3.js +1187 -0
  272. package/web-shell/assets/index-Rv6mOAN9.css +5 -0
  273. package/web-shell/assets/{index-Cl8d-1bK.js → index-wFXp7W68.js} +1 -1
  274. package/web-shell/assets/{infoDiagram-5YYISTIA-Dph21pR5.js → infoDiagram-5YYISTIA-DHJdSi7x.js} +1 -1
  275. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-Cjg1hSaG.js → ishikawaDiagram-YF4QCWOH-DOvd2Wph.js} +1 -1
  276. package/web-shell/assets/{journeyDiagram-JHISSGLW-CR-IzvnU.js → journeyDiagram-JHISSGLW-CH_urMCT.js} +1 -1
  277. package/web-shell/assets/{kanban-definition-UN3LZRKU-BYmuybuC.js → kanban-definition-UN3LZRKU-FKiBdgbH.js} +1 -1
  278. package/web-shell/assets/{linear-CngEEoy8.js → linear-0ZVQFVKf.js} +1 -1
  279. package/web-shell/assets/{mermaid.core-G6fbZRPf.js → mermaid.core-DJ05ZZIK.js} +5 -5
  280. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BtnqnUwJ.js → mindmap-definition-RKZ34NQL-BPuUhkUm.js} +1 -1
  281. package/web-shell/assets/{pieDiagram-4H26LBE5-XTq6UHIA.js → pieDiagram-4H26LBE5-yLFKcXyG.js} +1 -1
  282. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-D1J5PrsS.js → quadrantDiagram-W4KKPZXB-irWqc1pE.js} +1 -1
  283. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CLcBUy3t.js → requirementDiagram-4Y6WPE33-B_4uMoIV.js} +1 -1
  284. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-iwKV02_6.js → sankeyDiagram-5OEKKPKP-ciA4GPwk.js} +1 -1
  285. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-7NFYQcEX.js → sequenceDiagram-3UESZ5HK-CRdZvy0U.js} +1 -1
  286. package/web-shell/assets/{stateDiagram-AJRCARHV-Bvm4Wih6.js → stateDiagram-AJRCARHV-DaYIkCCn.js} +1 -1
  287. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DWBoO4UY.js +1 -0
  288. package/web-shell/assets/{timeline-definition-PNZ67QCA-B4FZFE9O.js → timeline-definition-PNZ67QCA-oBUKv6iH.js} +1 -1
  289. package/web-shell/assets/{vennDiagram-CIIHVFJN-CvMBpmtL.js → vennDiagram-CIIHVFJN-CGW9Sdmb.js} +1 -1
  290. package/web-shell/assets/{wardley-L42UT6IY-E3ag2327.js → wardley-L42UT6IY-CvwKJOCm.js} +1 -1
  291. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BEXWlgxC.js → wardleyDiagram-YWT4CUSO-Ipc260sN.js} +1 -1
  292. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CICK05gI.js → xychartDiagram-2RQKCTM6-D6-CM7pK.js} +1 -1
  293. package/web-shell/index.html +2 -2
  294. package/chunks/agent-headless-QTKDKVED.js +0 -68
  295. package/chunks/chunk-2RFKHEXL.js +0 -74
  296. package/chunks/chunk-43T5WDQ7.js +0 -127
  297. package/chunks/chunk-6PVPNMXU.js +0 -29
  298. package/chunks/chunk-7362QS5B.js +0 -2256
  299. package/chunks/chunk-D7ZI5C7O.js +0 -20600
  300. package/chunks/chunk-GLNBDYUX.js +0 -38
  301. package/chunks/chunk-GMLTZG4O.js +0 -391
  302. package/chunks/chunk-HTR4WV6U.js +0 -327
  303. package/chunks/chunk-KWK7UE6L.js +0 -6194
  304. package/chunks/chunk-M7WBGLYP.js +0 -151
  305. package/chunks/chunk-MMT6IQCT.js +0 -121
  306. package/chunks/chunk-NABLFI57.js +0 -82
  307. package/chunks/chunk-OQ5SYCPE.js +0 -10017
  308. package/chunks/chunk-PI6ECBP3.js +0 -1780
  309. package/chunks/chunk-U7ZFW55U.js +0 -2098
  310. package/chunks/chunk-WHGVTP7Q.js +0 -1049
  311. package/chunks/chunk-XHATNRQA.js +0 -1500
  312. package/chunks/contextCommand-2W675HYY.js +0 -73
  313. package/chunks/daemon-status-provider-QZCVTG6N.js +0 -81
  314. package/chunks/handleAutoUpdate-EF3LY7MI.js +0 -74
  315. package/chunks/initializer-HCOCXGBI.js +0 -79
  316. package/chunks/installationInfo-UEBNCLFW.js +0 -73
  317. package/chunks/list-4SKXTNSD.js +0 -82
  318. package/chunks/loadedSettingsAdapter-EQWK5CG6.js +0 -76
  319. package/chunks/managed-npm-update-ZUZU4UFM.js +0 -333
  320. package/chunks/mcp-4Z3EC4SI.js +0 -76
  321. package/chunks/nonInteractiveCli-FTUKIU5R.js +0 -133
  322. package/chunks/ripGrep-K2E3F5ED.js +0 -66
  323. package/chunks/sdk-exporters-grpc-ETLH47EP.js +0 -23214
  324. package/chunks/sdk-exporters-http-T3POX73F.js +0 -563
  325. package/chunks/sdk-impl-NSLPDH6I.js +0 -9193
  326. package/chunks/theme-manager-733OBN7I.js +0 -70
  327. package/chunks/total-session-admission-TZ4NVA6B.js +0 -76
  328. package/chunks/updateCheck-DGY3LFKB.js +0 -89
  329. package/chunks/web-search-EG64C5VB.js +0 -731
  330. package/chunks/workspace-providers-status-HZLYOFRA.js +0 -79
  331. package/chunks/workspace-registry-EVSTTG3G.js +0 -80
  332. package/chunks/workspace-service-DNQMT6FN.js +0 -91
  333. package/chunks/workspace-skills-status-ICGPGD6F.js +0 -78
  334. package/chunks/write-file-K6R5F3IZ.js +0 -66
  335. package/web-shell/assets/channel-4N2UIFcG.js +0 -1
  336. package/web-shell/assets/classDiagram-4FO5ZUOK-Q4dYOtsh.js +0 -1
  337. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Q4dYOtsh.js +0 -1
  338. package/web-shell/assets/index-B7jzUZ_s.css +0 -5
  339. package/web-shell/assets/index-gE8OWwj_.js +0 -1197
  340. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-xXU_zO2Z.js +0 -1
  341. package/chunks/{chunk-QZJY47IE.js → chunk-PEJWA3QQ.js} +5 -5
@@ -1,8 +1,5 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import {
4
- recomputeMcpGating
5
- } from "./chunk-EGMNITTR.js";
6
3
  import {
7
4
  classifyApiError
8
5
  } from "./chunk-V7RNNPGC.js";
@@ -15,49 +12,41 @@ import {
15
12
  matchMcpServerByRef,
16
13
  parseExtensionRef,
17
14
  parseMcpServerRef
18
- } from "./chunk-W6E7KTQL.js";
15
+ } from "./chunk-IVPSS6EL.js";
19
16
  import {
20
17
  getAvailableCommands,
21
18
  handleSlashCommand,
22
19
  insertAfterFunctionResponses,
23
20
  isSlashCommand,
24
21
  normalizePartList
25
- } from "./chunk-6MNDXSG6.js";
22
+ } from "./chunk-PBWEWI4N.js";
23
+ import {
24
+ recomputeMcpGating
25
+ } from "./chunk-333CXMNJ.js";
26
26
  import {
27
27
  appEvents,
28
28
  buildDisabledSkillNamesProvider,
29
29
  loadCliConfig,
30
30
  normalizeDisabledToolList
31
- } from "./chunk-5XPUJM4N.js";
32
- import "./chunk-5DTTYNB7.js";
33
- import {
34
- collectContextData,
35
- formatContextUsageText
36
- } from "./chunk-O2WEV2LS.js";
31
+ } from "./chunk-4XNLIGVA.js";
37
32
  import {
38
33
  getCommandSubcommandNames
39
- } from "./chunk-N2HDLRGT.js";
34
+ } from "./chunk-HZPN55E5.js";
40
35
  import {
41
36
  getEffectiveSupportedModes
42
- } from "./chunk-QSZOJHCQ.js";
43
- import "./chunk-4LVZNIDO.js";
37
+ } from "./chunk-2LL7TXB4.js";
38
+ import "./chunk-5DTTYNB7.js";
39
+ import "./chunk-QKYTTBYW.js";
40
+ import {
41
+ collectContextData,
42
+ formatContextUsageText
43
+ } from "./chunk-A5LYNIW7.js";
44
44
  import "./chunk-4WGODMVR.js";
45
- import "./chunk-H6T65C7O.js";
45
+ import "./chunk-AYCDXHZB.js";
46
+ import "./chunk-KDC6GNQR.js";
47
+ import "./chunk-KG3XV6FH.js";
48
+ import "./chunk-S2W2LVDU.js";
46
49
  import "./chunk-YAF2MQZ6.js";
47
- import "./chunk-7Z6JQEL6.js";
48
- import {
49
- computeCpuPercent
50
- } from "./chunk-HGT6JR3U.js";
51
- import "./chunk-HCQ2Q3KF.js";
52
- import "./chunk-6H67XLET.js";
53
- import {
54
- beginAcpBootstrapConfigProfiling,
55
- buildAndFreezeAcpStartupProfile,
56
- endAcpBootstrapConfigProfiling,
57
- markAcpStartup
58
- } from "./chunk-TDKQP3M6.js";
59
- import "./chunk-VAUDHMX6.js";
60
- import "./chunk-WGBLCAVW.js";
61
50
  import {
62
51
  GENERATION_MAX_PROMPT_BYTES,
63
52
  GENERATION_TIMEOUT_MS,
@@ -76,7 +65,7 @@ import {
76
65
  shouldSuppressRememberErrorDetails,
77
66
  workspaceMemoryFailureCode,
78
67
  workspaceMemoryFailureDiagnostics
79
- } from "./chunk-RZZNAWTE.js";
68
+ } from "./chunk-5JBR5XIK.js";
80
69
  import {
81
70
  HistoryReplayer,
82
71
  MessageEmitter,
@@ -86,19 +75,31 @@ import {
86
75
  goalTerminalEventToHistoryItem,
87
76
  recordGoalStatusItem,
88
77
  restoreGoalFromHistory
89
- } from "./chunk-BH32VITB.js";
90
- import "./chunk-4K7VDKAD.js";
78
+ } from "./chunk-PGEPSDJI.js";
79
+ import "./chunk-KTUQMDEP.js";
80
+ import "./chunk-D22SX43D.js";
91
81
  import "./chunk-RS7MT2QG.js";
92
- import "./chunk-6NAAGP57.js";
93
82
  import "./chunk-H2XVO6NE.js";
94
83
  import "./chunk-QHTIBUWB.js";
95
84
  import {
96
85
  isTerminalGoalStatusKind
97
86
  } from "./chunk-QTERJVPZ.js";
98
87
  import "./chunk-L573Z2QZ.js";
88
+ import {
89
+ computeCpuPercent
90
+ } from "./chunk-HGT6JR3U.js";
99
91
  import "./chunk-RXFQM6FQ.js";
92
+ import "./chunk-KOR3XKCA.js";
93
+ import "./chunk-6H67XLET.js";
94
+ import {
95
+ beginAcpBootstrapConfigProfiling,
96
+ buildAndFreezeAcpStartupProfile,
97
+ endAcpBootstrapConfigProfiling,
98
+ markAcpStartup
99
+ } from "./chunk-TDKQP3M6.js";
100
+ import "./chunk-VEXFOTEO.js";
100
101
  import "./chunk-LXXMOYPL.js";
101
- import "./chunk-HGGEN2SC.js";
102
+ import "./chunk-NDMQLV4Y.js";
102
103
  import "./chunk-E5Z2AVNV.js";
103
104
  import {
104
105
  ACP_ROUTE_ID_PREFIX,
@@ -108,7 +109,7 @@ import {
108
109
  parseAcpModelOption,
109
110
  resolveAcpModelOption,
110
111
  sanitizeProviderBaseUrl
111
- } from "./chunk-WKGGZF7Z.js";
112
+ } from "./chunk-NGFEPAE6.js";
112
113
  import {
113
114
  mapSkillConfigToStatus
114
115
  } from "./chunk-2W3OOD4W.js";
@@ -118,28 +119,19 @@ import {
118
119
  buildPermissionSettings,
119
120
  normalizePermissionRules,
120
121
  readPermissionRuleSet
121
- } from "./chunk-VJ4P64ID.js";
122
+ } from "./chunk-S2XVRHDN.js";
122
123
  import {
123
124
  MAX_AUDIO_BYTES,
124
125
  sanitizeVoiceErrorMessage,
125
126
  transcribeVoiceAudio
126
- } from "./chunk-RVWSD6GI.js";
127
+ } from "./chunk-IR46U7RB.js";
127
128
  import {
128
129
  readVoiceModel
129
- } from "./chunk-P4B4SXDS.js";
130
- import "./chunk-QLJUC7TG.js";
131
- import "./chunk-GDBCCE2J.js";
132
- import "./chunk-7FNV372W.js";
133
- import "./chunk-57OAHC2Y.js";
134
- import "./chunk-QD6BRERJ.js";
135
- import "./chunk-6ZBPS62S.js";
136
- import "./chunk-V6WHFGST.js";
137
- import {
138
- createLoadedSettingsAdapter
139
- } from "./chunk-BWGIRN4Z.js";
130
+ } from "./chunk-S2PD3EZD.js";
131
+ import "./chunk-BVLROR2T.js";
140
132
  import {
141
133
  parseSessionSource
142
- } from "./chunk-422RQSNN.js";
134
+ } from "./chunk-AKX4WPPP.js";
143
135
  import "./chunk-6RLROE6G.js";
144
136
  import "./chunk-COH43MRJ.js";
145
137
  import {
@@ -154,12 +146,12 @@ import {
154
146
  MID_TURN_QUEUE_DRAIN_METHOD,
155
147
  TODO_STOP_GUARD_QUEUE_RELEASE_METHOD
156
148
  } from "./chunk-QR6U5QPP.js";
157
- import {
158
- NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE
159
- } from "./chunk-UH3WSE5L.js";
160
149
  import {
161
150
  ndJsonStream
162
- } from "./chunk-K6YXJ3J5.js";
151
+ } from "./chunk-CV63PP6U.js";
152
+ import {
153
+ NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE
154
+ } from "./chunk-X6YQWCIJ.js";
163
155
  import {
164
156
  ACP_PREFLIGHT_KINDS,
165
157
  IDLE_HOOK_EVENTS,
@@ -167,13 +159,23 @@ import {
167
159
  SERVE_STATUS_EXT_METHODS,
168
160
  STATUS_SCHEMA_VERSION,
169
161
  mapDomainErrorToErrorKind
170
- } from "./chunk-BLTELXOK.js";
171
- import "./chunk-QKTHJXCS.js";
162
+ } from "./chunk-VDWBQ5AW.js";
163
+ import "./chunk-CB2HFGRV.js";
164
+ import "./chunk-MJ6S23WZ.js";
165
+ import "./chunk-57OAHC2Y.js";
166
+ import "./chunk-YWEW33JY.js";
167
+ import "./chunk-4ODB7WIB.js";
168
+ import "./chunk-V6WHFGST.js";
169
+ import {
170
+ createLoadedSettingsAdapter
171
+ } from "./chunk-CZF3E5GF.js";
172
+ import "./chunk-W7FJ3N32.js";
173
+ import "./chunk-Y2ENGUD6.js";
172
174
  import "./chunk-TJTKSVIV.js";
173
175
  import "./chunk-M5GB774H.js";
174
- import "./chunk-RV4C2ZFG.js";
175
- import "./chunk-2LI23QA6.js";
176
- import "./chunk-RVLZCXEE.js";
176
+ import "./chunk-RFIAR4YL.js";
177
+ import "./chunk-2HOVDT7W.js";
178
+ import "./chunk-NIJEXGV6.js";
177
179
  import {
178
180
  AgentSideConnection,
179
181
  PROTOCOL_VERSION,
@@ -182,7 +184,7 @@ import {
182
184
  import {
183
185
  assembleMcpServers,
184
186
  loadMcpApprovals
185
- } from "./chunk-XPWXDCW5.js";
187
+ } from "./chunk-7SXZC7ID.js";
186
188
  import {
187
189
  getOutputLanguageFilePath,
188
190
  getPersistScopeForModelSelection,
@@ -191,40 +193,38 @@ import {
191
193
  resolveOutputLanguageOrPreserveAuto,
192
194
  updateOutputLanguageFile,
193
195
  writeOutputLanguageAndRegisterPath
194
- } from "./chunk-DGKZ6QL3.js";
196
+ } from "./chunk-33XUAINQ.js";
195
197
  import "./chunk-RKUWKYED.js";
198
+ import "./chunk-GOXKNSDZ.js";
199
+ import {
200
+ getSystemDefaultsPath,
201
+ getSystemSettingsPath
202
+ } from "./chunk-IDS7MSUP.js";
196
203
  import {
197
204
  SUPPORTED_LANGUAGES,
198
205
  getCurrentLanguage,
199
206
  setLanguageAsync
200
- } from "./chunk-3FML67YK.js";
207
+ } from "./chunk-TKLLK6XQ.js";
201
208
  import {
202
209
  findEnvFiles,
203
210
  preResolveHomeEnvOverrides,
204
211
  reloadEnvironment
205
- } from "./chunk-R3D7SK6L.js";
206
- import "./chunk-5TSCAYXT.js";
207
- import "./chunk-GOXKNSDZ.js";
212
+ } from "./chunk-TIH2ZTOC.js";
208
213
  import "./chunk-QRUIS3DN.js";
209
- import "./chunk-2RFKHEXL.js";
210
- import {
211
- getSystemDefaultsPath,
212
- getSystemSettingsPath
213
- } from "./chunk-IDS7MSUP.js";
214
- import "./chunk-XFSFZCM5.js";
215
- import "./chunk-FCPNARPD.js";
214
+ import "./chunk-OWCALFEG.js";
216
215
  import "./chunk-VJNBRRZG.js";
217
216
  import {
218
217
  isFolderTrustEnabled,
219
218
  isWorkspaceTrusted,
220
219
  loadTrustedFolders
221
- } from "./chunk-NTC7J4X7.js";
220
+ } from "./chunk-I2PYAYFM.js";
222
221
  import "./chunk-ALGGS7UH.js";
223
222
  import "./chunk-MR3PXB6E.js";
224
223
  import {
225
224
  writeStderrLine,
226
225
  writeStderrLineSafe
227
226
  } from "./chunk-OWAK7LMW.js";
227
+ import "./chunk-XFSFZCM5.js";
228
228
  import {
229
229
  ALL_PROVIDERS,
230
230
  APPROVAL_MODE_INFO,
@@ -243,20 +243,16 @@ import {
243
243
  McpServerSpawnFailedError,
244
244
  McpTransportPool,
245
245
  MessageDisplayDispatcher,
246
- PLAN_MODE_ENTRY_SIBLING_SKIP_MESSAGE,
247
246
  POOLED_TRANSPORTS_DEFAULT,
248
247
  SESSION_ARTIFACT_PERSISTENCE_VERSION,
249
248
  SESSION_TITLE_MAX_LENGTH,
250
249
  SESSION_TRANSCRIPT_MAX_LIMIT,
251
250
  SESSION_TRANSCRIPT_MAX_PAGE_BYTES,
252
- SESSION_WRITER_RPC_CODES,
253
251
  SessionService,
254
252
  SessionTranscriptPageTooLargeError,
255
253
  SessionTranscriptReader,
256
254
  SessionTranscriptSnapshotUnavailableError,
257
255
  SessionTranscriptTooLargeError,
258
- SessionWriterError,
259
- SessionWriterUnavailableError,
260
256
  TURN_INTERRUPTION_HISTORY_TAIL_COUNT,
261
257
  WorkspaceMcpBudget,
262
258
  abortGoalForStopHookCap,
@@ -276,18 +272,13 @@ import {
276
272
  convertToFunctionErrorResponse,
277
273
  convertToFunctionResponse,
278
274
  createDuplicateProviderToolCallResponse,
279
- decorateClassifierUnavailableConfirmation,
280
- decoratePlanModeShellConfirmation,
281
275
  dedupeToolCallsById,
282
276
  detectAutonomousSentinel,
283
277
  detectLoopSentinel,
284
278
  encodeSessionTranscriptCursor,
285
279
  evaluateAutoMode,
286
280
  evaluatePermissionFlow,
287
- evaluatePlanModeShellPolicy,
288
- finalizeToolResponses,
289
281
  findExistingProviderModels,
290
- findPlanModeEntryBatchBoundaryIndex,
291
282
  findProviderById,
292
283
  findRepeatedDuplicateProviderToolCall,
293
284
  fireNotificationHook,
@@ -310,19 +301,21 @@ import {
310
301
  getPlanModeSystemReminder,
311
302
  getProviderToolCallId,
312
303
  getScopedEnvContents,
313
- getStopHookContinuationReason,
304
+ getStartupContextLength,
314
305
  ideContextStore,
315
306
  injectPermissionRulesIfMissing,
316
307
  isApproveOutcome,
317
308
  isDenialFallbackReason,
318
309
  isGatedMcpScope,
319
310
  isPlanModeBlocked,
311
+ isSystemReminderContent,
320
312
  markDuplicateProviderToolCallResponseSent,
321
313
  matchesAnyServerPattern,
322
314
  mcpServerRequiresOAuth,
323
315
  needsConfirmation,
324
316
  normalizeEventPayload,
325
317
  normalizeSnapshotPayload,
318
+ parsePositiveIntegerEnv,
326
319
  persistPermissionOutcome,
327
320
  readManyFiles,
328
321
  recordAllow,
@@ -344,58 +337,43 @@ import {
344
337
  shouldRunAutoModeForCall,
345
338
  subagentGenerator,
346
339
  unregisterGoalHook,
347
- updateSetting,
348
- validatePlanModeShellApproval,
349
- validatePlanModeShellContext
350
- } from "./chunk-Z2FTZM4Z.js";
340
+ updateSetting
341
+ } from "./chunk-KX6UK4VJ.js";
342
+ import "./chunk-5M6IDOMF.js";
351
343
  import "./chunk-T4TZQJ7W.js";
352
344
  import {
353
345
  external_exports
354
346
  } from "./chunk-H6XPXXMH.js";
355
- import "./chunk-5M6IDOMF.js";
356
- import "./chunk-T2L47JJK.js";
357
- import "./chunk-GPSKDNEE.js";
358
- import "./chunk-X6N25LXS.js";
347
+ import "./chunk-EAUYY7SS.js";
348
+ import "./chunk-FSL5W5TI.js";
349
+ import "./chunk-OONJNQ42.js";
350
+ import "./chunk-D2VIDMVM.js";
359
351
  import "./chunk-E2UVIFI2.js";
360
- import "./chunk-Q2YKNMLS.js";
361
352
  import "./chunk-XU457J4V.js";
362
353
  import "./chunk-VDDGDZMA.js";
363
- import "./chunk-KHOVYUHX.js";
354
+ import "./chunk-EIAK6Q2B.js";
364
355
  import "./chunk-SZRN75WQ.js";
365
- import {
366
- parsePositiveIntegerEnv
367
- } from "./chunk-6PVPNMXU.js";
368
- import "./chunk-MMT6IQCT.js";
356
+ import "./chunk-HTO4JFDZ.js";
369
357
  import "./chunk-CPBF7KYF.js";
370
- import "./chunk-NABLFI57.js";
371
- import {
372
- HookEventName,
373
- createHookOutput
374
- } from "./chunk-QBUDF33N.js";
375
- import "./chunk-LIZRAKPB.js";
376
358
  import {
377
359
  APPROVAL_MODES,
378
360
  FORK_SUBAGENT_TYPE,
379
- getStartupContextLength,
380
- isSystemReminderContent,
381
361
  runWithRuntimeContentGenerator
382
- } from "./chunk-WHGVTP7Q.js";
362
+ } from "./chunk-CPCVCKKF.js";
383
363
  import "./chunk-6AM5D4ME.js";
384
- import "./chunk-JCW2R7WC.js";
385
- import "./chunk-57FIIFJN.js";
386
- import "./chunk-HTO4JFDZ.js";
387
- import "./chunk-XVNQMZ2I.js";
388
- import "./chunk-FODK6UMO.js";
389
- import "./chunk-GLNBDYUX.js";
364
+ import "./chunk-G45X5TRN.js";
365
+ import {
366
+ HookEventName,
367
+ createHookOutput
368
+ } from "./chunk-PBATSWUQ.js";
369
+ import "./chunk-ZEOZL37W.js";
370
+ import "./chunk-OOCI5VVU.js";
390
371
  import {
391
372
  clearCachedCredentialFile,
392
373
  qwenOAuth2Events
393
- } from "./chunk-EDANOBFR.js";
374
+ } from "./chunk-BRRF37CO.js";
375
+ import "./chunk-BMWMT5Y2.js";
394
376
  import "./chunk-JESCGQM3.js";
395
- import "./chunk-GMLTZG4O.js";
396
- import "./chunk-25WFJZL5.js";
397
- import "./chunk-DJ2GSRLV.js";
398
- import "./chunk-5I5BM454.js";
399
377
  import {
400
378
  AuthType,
401
379
  ConversationFinishedEvent,
@@ -403,6 +381,8 @@ import {
403
381
  LoopDetectedEvent,
404
382
  PromptSuggestionEvent,
405
383
  UserPromptEvent,
384
+ endToolExecutionSpan,
385
+ endToolSpan,
406
386
  extractDaemonTraceContext,
407
387
  formatFullTurnVisionNotice,
408
388
  formatVisionBridgeNotice,
@@ -418,63 +398,62 @@ import {
418
398
  logUserPrompt,
419
399
  normalizeParts,
420
400
  registerAcpEventLoopLagGauge,
401
+ runInToolSpanContext,
421
402
  runSideQuery,
422
403
  runVisionBridge,
423
404
  shouldRunVisionBridge,
424
405
  splitImageParts,
425
406
  startEventLoopLagMonitor,
407
+ startToolExecutionSpan,
408
+ startToolSpan,
426
409
  uiTelemetryService,
427
- withDaemonSpan
428
- } from "./chunk-D7ZI5C7O.js";
410
+ withDaemonSpan,
411
+ withInteractionSpan
412
+ } from "./chunk-ZFKNWQGQ.js";
413
+ import "./chunk-4WKAA4KS.js";
414
+ import "./chunk-CR3C7WXL.js";
429
415
  import "./chunk-VGC4I5JJ.js";
430
416
  import {
431
417
  getAutoMemoryRoot,
432
418
  getUserAutoMemoryRoot
433
- } from "./chunk-4K56OJFJ.js";
419
+ } from "./chunk-JD3MKVKL.js";
420
+ import "./chunk-UEY4AYUL.js";
421
+ import "./chunk-BDBMYST4.js";
422
+ import "./chunk-EZVDJFZ7.js";
423
+ import {
424
+ ToolConfirmationOutcome,
425
+ ToolNames,
426
+ isShellProgressData
427
+ } from "./chunk-OP4MOGXF.js";
428
+ import "./chunk-XVNQMZ2I.js";
429
+ import "./chunk-FEOZBUMT.js";
430
+ import "./chunk-DJ2GSRLV.js";
431
+ import "./chunk-6EFTQYW7.js";
434
432
  import {
435
433
  DEFAULT_TOKEN_LIMIT,
436
434
  getToolCallPreparations,
437
435
  tokenLimit
438
- } from "./chunk-JYS55H6Z.js";
436
+ } from "./chunk-MAQQGNQ5.js";
439
437
  import "./chunk-A4UCTEB5.js";
440
438
  import "./chunk-XWRJCPHC.js";
441
- import "./chunk-QNLNLENL.js";
442
- import "./chunk-6X4GWOPW.js";
443
439
  import "./chunk-TYQMGACW.js";
444
440
  import "./chunk-TYAMGABM.js";
445
441
  import "./chunk-FCMNKVXT.js";
446
- import {
447
- endToolExecutionSpan,
448
- endToolSpan,
449
- runInToolSpanContext,
450
- startToolExecutionSpan,
451
- startToolSpan,
452
- withInteractionSpan
453
- } from "./chunk-7362QS5B.js";
454
- import "./chunk-HTR4WV6U.js";
455
- import "./chunk-M7WBGLYP.js";
456
- import "./chunk-U7ZFW55U.js";
457
- import "./chunk-NPQDJGKU.js";
458
- import {
459
- ToolConfirmationOutcome,
460
- ToolNames,
461
- isShellProgressData
462
- } from "./chunk-YM3SZTH4.js";
463
442
  import {
464
443
  Storage,
465
444
  createDebugLogger,
466
445
  getErrorMessage,
467
446
  getErrorStatus,
468
447
  isSubpath
469
- } from "./chunk-OQB4EXO4.js";
470
- import "./chunk-4RAFVWW2.js";
448
+ } from "./chunk-C27BYUX6.js";
449
+ import "./chunk-VZQUV7VK.js";
471
450
  import {
472
451
  runExitCleanup
473
- } from "./chunk-4ZAHUGSC.js";
452
+ } from "./chunk-DP5GXXNZ.js";
474
453
  import "./chunk-75DOP5OR.js";
475
454
  import "./chunk-DMTGGOSA.js";
476
455
  import "./chunk-YQ3U5MUC.js";
477
- import "./chunk-THJNPLI4.js";
456
+ import "./chunk-TB6UDU4T.js";
478
457
  import {
479
458
  init_esbuild_shims
480
459
  } from "./chunk-5O2XNYP6.js";
@@ -484,7 +463,7 @@ import {
484
463
 
485
464
  // packages/cli/src/acp-integration/acpAgent.ts
486
465
  init_esbuild_shims();
487
- import { randomUUID as randomUUID2 } from "node:crypto";
466
+ import { randomUUID } from "node:crypto";
488
467
  import { performance } from "node:perf_hooks";
489
468
 
490
469
  // packages/cli/src/acp-integration/authMethods.ts
@@ -862,7 +841,6 @@ __name(isInactiveExtensionSkill, "isInactiveExtensionSkill");
862
841
  // packages/cli/src/acp-integration/session/Session.ts
863
842
  init_esbuild_shims();
864
843
  import { Buffer as Buffer2 } from "node:buffer";
865
- import { randomUUID } from "node:crypto";
866
844
  import { existsSync as existsSync2, statSync as statSync2 } from "node:fs";
867
845
  import * as os2 from "node:os";
868
846
  import * as path3 from "node:path";
@@ -987,23 +965,8 @@ function supportsHideAlwaysAllow(confirmation) {
987
965
  }
988
966
  __name(supportsHideAlwaysAllow, "supportsHideAlwaysAllow");
989
967
  function filterAlwaysAllowOptions(confirmation, options, forceHideAlwaysAllow = false) {
990
- const hideAlwaysAllow = forceHideAlwaysAllow || confirmation.autoModeFallback !== void 0 || supportsHideAlwaysAllow(confirmation) && confirmation.hideAlwaysAllow === true;
991
- const visibleOptions = hideAlwaysAllow ? options.filter((option) => option.kind !== "allow_always") : options;
992
- if (!confirmation.autoModeFallback) return visibleOptions;
993
- const switchOption = {
994
- optionId: "proceed_once_and_switch_to_default" /* ProceedOnceAndSwitchToDefault */,
995
- name: "Switch to Default Mode and allow once (recommended)",
996
- kind: "allow_once"
997
- };
998
- const rejectIndex = visibleOptions.findIndex(
999
- (option) => option.kind === "reject_once"
1000
- );
1001
- if (rejectIndex === -1) return [...visibleOptions, switchOption];
1002
- return [
1003
- ...visibleOptions.slice(0, rejectIndex),
1004
- switchOption,
1005
- ...visibleOptions.slice(rejectIndex)
1006
- ];
968
+ const hideAlwaysAllow = forceHideAlwaysAllow || supportsHideAlwaysAllow(confirmation) && confirmation.hideAlwaysAllow === true;
969
+ return hideAlwaysAllow ? options.filter((option) => option.kind !== "allow_always") : options;
1007
970
  }
1008
971
  __name(filterAlwaysAllowOptions, "filterAlwaysAllowOptions");
1009
972
  function formatExecPermissionScopeLabel(confirmation) {
@@ -1031,22 +994,6 @@ function interactionMetaFields(confirmation) {
1031
994
  __name(interactionMetaFields, "interactionMetaFields");
1032
995
  function buildPermissionRequestContent(confirmation) {
1033
996
  const content = [];
1034
- if (confirmation.autoModeFallback) {
1035
- content.push({
1036
- type: "content",
1037
- content: {
1038
- type: "text",
1039
- text: confirmation.autoModeFallback.message
1040
- }
1041
- });
1042
- }
1043
- const warnings = confirmation.type === "exec" || confirmation.type === "edit" ? confirmation.warnings ?? [] : [];
1044
- for (const warning of warnings) {
1045
- content.push({
1046
- type: "content",
1047
- content: { type: "text", text: warning }
1048
- });
1049
- }
1050
997
  if (confirmation.type === "edit") {
1051
998
  content.push({
1052
999
  type: "diff",
@@ -1067,56 +1014,6 @@ function buildPermissionRequestContent(confirmation) {
1067
1014
  return content;
1068
1015
  }
1069
1016
  __name(buildPermissionRequestContent, "buildPermissionRequestContent");
1070
- function permissionAbortError(signal) {
1071
- return signal.reason instanceof Error ? signal.reason : new Error("Permission request was aborted.");
1072
- }
1073
- __name(permissionAbortError, "permissionAbortError");
1074
- function requestPermissionWithAbort(client, params, signal) {
1075
- if (signal.aborted) {
1076
- return Promise.reject(permissionAbortError(signal));
1077
- }
1078
- return new Promise((resolve5, reject) => {
1079
- let settled = false;
1080
- const finish = /* @__PURE__ */ __name((callback) => {
1081
- if (settled) return;
1082
- settled = true;
1083
- signal.removeEventListener("abort", onAbort);
1084
- callback();
1085
- }, "finish");
1086
- const onAbort = /* @__PURE__ */ __name(() => finish(() => reject(permissionAbortError(signal))), "onAbort");
1087
- signal.addEventListener("abort", onAbort, { once: true });
1088
- let request;
1089
- try {
1090
- request = client.requestPermission(params);
1091
- } catch (error) {
1092
- finish(() => reject(error));
1093
- return;
1094
- }
1095
- request.then(
1096
- (response) => finish(() => resolve5(response)),
1097
- (error) => finish(() => reject(error))
1098
- );
1099
- });
1100
- }
1101
- __name(requestPermissionWithAbort, "requestPermissionWithAbort");
1102
- function resolvePermissionOutcome(response, offeredOptions) {
1103
- if (response.outcome.outcome === "cancelled") {
1104
- return "cancel" /* Cancel */;
1105
- }
1106
- const optionId = response.outcome.optionId;
1107
- if (!offeredOptions.some((option) => option.optionId === optionId)) {
1108
- throw new Error(
1109
- `Permission response selected unoffered option: ${optionId}`
1110
- );
1111
- }
1112
- if (!Object.values(ToolConfirmationOutcome).includes(
1113
- optionId
1114
- )) {
1115
- throw new Error(`Permission response selected invalid option: ${optionId}`);
1116
- }
1117
- return optionId;
1118
- }
1119
- __name(resolvePermissionOutcome, "resolvePermissionOutcome");
1120
1017
  function toPermissionOptions(confirmation, forceHideAlwaysAllow = false) {
1121
1018
  switch (confirmation.type) {
1122
1019
  case "edit":
@@ -1343,13 +1240,9 @@ var SubAgentTracker = class {
1343
1240
  }, "onConfirm")
1344
1241
  };
1345
1242
  const { title, locations, kind } = this.toolCallEmitter.resolveToolMetadata(event.name, state?.args);
1346
- const permissionOptions = toPermissionOptions(fullConfirmationDetails);
1347
- const offeredPermissionOptions = permissionOptions.map((option) => ({
1348
- ...option
1349
- }));
1350
1243
  const params = {
1351
1244
  sessionId: this.ctx.sessionId,
1352
- options: permissionOptions,
1245
+ options: toPermissionOptions(fullConfirmationDetails),
1353
1246
  toolCall: {
1354
1247
  toolCallId: event.callId,
1355
1248
  status: "pending",
@@ -1370,15 +1263,8 @@ var SubAgentTracker = class {
1370
1263
  }
1371
1264
  };
1372
1265
  try {
1373
- const output = await requestPermissionWithAbort(
1374
- this.client,
1375
- params,
1376
- abortSignal
1377
- );
1378
- const outcome = resolvePermissionOutcome(
1379
- output,
1380
- offeredPermissionOptions
1381
- );
1266
+ const output = await this.client.requestPermission(params);
1267
+ const outcome = output.outcome.outcome === "cancelled" ? "cancel" /* Cancel */ : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
1382
1268
  await event.respond(outcome, {
1383
1269
  answers: "answers" in output ? output.answers : void 0
1384
1270
  });
@@ -1970,10 +1856,6 @@ function maskApiKeyForDisplay(apiKey) {
1970
1856
  return `${trimmed.slice(0, 3)}...${trimmed.slice(-4)}`;
1971
1857
  }
1972
1858
  __name(maskApiKeyForDisplay, "maskApiKeyForDisplay");
1973
- function getAbortAwareEndTurnStopReason(signal) {
1974
- return signal.aborted ? "cancelled" : "end_turn";
1975
- }
1976
- __name(getAbortAwareEndTurnStopReason, "getAbortAwareEndTurnStopReason");
1977
1859
  var DAEMON_INVALID_TOOL_PARAMS_THRESHOLD = 3;
1978
1860
  var PERMISSION_CANCEL_SKIP_MESSAGE = "Skipped because a permission request was cancelled before the user answered; user input is required before continuing.";
1979
1861
  var LOOP_DETECTED_SKIP_MESSAGE = "Skipped because loop detection stopped the current turn before this tool call could run.";
@@ -2425,7 +2307,7 @@ var Session = class {
2425
2307
  this.client = client;
2426
2308
  this.settings = settings;
2427
2309
  this.sessionId = id;
2428
- this.runtimeBaseDir = config.storage.getRuntimeBaseDir();
2310
+ this.runtimeBaseDir = Storage.getRuntimeBaseDir();
2429
2311
  const todoStopGuardEnabled = this.settings.merged.experimental?.todoStopGuard === true && !this.config.getBareMode() && !this.config.isSafeMode();
2430
2312
  this.todoStopGuard = new DaemonTodoStopGuard(todoStopGuardEnabled);
2431
2313
  this.todoStopGuardBackgroundBaseline = todoStopGuardEnabled ? this.#captureTodoStopGuardBackgroundBaseline() : {
@@ -2456,7 +2338,6 @@ var Session = class {
2456
2338
  * process termination is slow.
2457
2339
  */
2458
2340
  pendingPromptCompletion = null;
2459
- automaticDrainRetry = null;
2460
2341
  /**
2461
2342
  * Per-turn AbortController for the fire-and-forget follow-up suggestion
2462
2343
  * generation. Aborted on the top of the next `prompt()` and on
@@ -2519,9 +2400,6 @@ var Session = class {
2519
2400
  // or session reload), which would otherwise execute orphaned cron prompts
2520
2401
  // on a session whose registries are already unregistered.
2521
2402
  disposed = false;
2522
- closing = false;
2523
- closeGateCompletion = null;
2524
- resolveCloseGate = null;
2525
2403
  unsubscribeChatRecordingFailure;
2526
2404
  // Modular components
2527
2405
  historyReplayer;
@@ -2756,7 +2634,7 @@ var Session = class {
2756
2634
  * mount.
2757
2635
  */
2758
2636
  startCronScheduler() {
2759
- this.#startCronSchedulerInRuntime().catch((error) => {
2637
+ this.#startCronSchedulerIfNeeded().catch((error) => {
2760
2638
  debugLogger6.warn(
2761
2639
  `Cron scheduler startup failed [session ${this.sessionId}]: ${error}`
2762
2640
  );
@@ -2765,95 +2643,8 @@ var Session = class {
2765
2643
  getConfig() {
2766
2644
  return this.config;
2767
2645
  }
2768
- async assertCanStartTurn() {
2769
- if (this.closing) {
2770
- throw RequestError.invalidParams(void 0, "Session is closing");
2771
- }
2772
- try {
2773
- await this.config.assertCanStartTurn();
2774
- } catch (error) {
2775
- if (error instanceof SessionWriterError) {
2776
- throw new RequestError(error.rpcCode, error.message, {
2777
- errorKind: error.errorKind
2778
- });
2779
- }
2780
- throw error;
2781
- }
2782
- if (this.closing) {
2783
- throw RequestError.invalidParams(void 0, "Session is closing");
2784
- }
2785
- }
2786
2646
  isIdle() {
2787
- return !this.closing && !this.#hasActiveTurn();
2788
- }
2789
- #hasActiveTurn() {
2790
- return Boolean(
2791
- this.pendingPrompt || this.pendingPromptCompletion || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
2792
- );
2793
- }
2794
- beginClose() {
2795
- if (this.closing) {
2796
- throw RequestError.invalidParams(
2797
- void 0,
2798
- "Session close is already in progress"
2799
- );
2800
- }
2801
- this.closing = true;
2802
- let resolveGate;
2803
- const completion = new Promise((resolve5) => {
2804
- resolveGate = resolve5;
2805
- });
2806
- this.closeGateCompletion = completion;
2807
- this.resolveCloseGate = resolveGate;
2808
- let released = false;
2809
- return () => {
2810
- if (released) return;
2811
- released = true;
2812
- if (this.closeGateCompletion === completion) {
2813
- this.closeGateCompletion = null;
2814
- this.resolveCloseGate = null;
2815
- }
2816
- resolveGate();
2817
- if (this.disposed) return;
2818
- this.closing = false;
2819
- void this.#drainCronQueue();
2820
- void this.#drainNotificationQueue();
2821
- };
2822
- }
2823
- beginCloseIfAvailable() {
2824
- if (this.disposed) {
2825
- throw RequestError.invalidParams(void 0, "Session has been disposed");
2826
- }
2827
- return this.closing ? null : this.beginClose();
2828
- }
2829
- waitForCloseGateToRelease() {
2830
- return this.closeGateCompletion ?? Promise.resolve();
2831
- }
2832
- async waitForActiveTurnsToSettle() {
2833
- const pending = [
2834
- this.pendingPromptCompletion,
2835
- this.cronCompletion,
2836
- this.notificationCompletion
2837
- ].filter((completion) => completion !== null);
2838
- await Promise.allSettled(pending);
2839
- }
2840
- #deferAutomaticQueueDrainUntilTurnsSettle() {
2841
- const completions = [
2842
- this.pendingPromptCompletion,
2843
- this.cronCompletion,
2844
- this.notificationCompletion
2845
- ].filter((completion) => completion !== null);
2846
- if (completions.length === 0) return false;
2847
- if (this.automaticDrainRetry) return true;
2848
- const retry = Promise.allSettled(completions).then(() => {
2849
- if (this.automaticDrainRetry !== retry) return;
2850
- this.automaticDrainRetry = null;
2851
- if (this.disposed) return;
2852
- void this.#drainCronQueue();
2853
- void this.#drainNotificationQueue();
2854
- });
2855
- this.automaticDrainRetry = retry;
2856
- return true;
2647
+ return !this.pendingPrompt && !this.pendingPromptCompletion && !this.cronProcessing && !this.cronAbortController && !this.notificationProcessing && !this.notificationAbortController;
2857
2648
  }
2858
2649
  getTurnCount() {
2859
2650
  return this.turn;
@@ -2863,10 +2654,6 @@ var Session = class {
2863
2654
  }
2864
2655
  dispose() {
2865
2656
  this.disposed = true;
2866
- this.closing = true;
2867
- this.resolveCloseGate?.();
2868
- this.resolveCloseGate = null;
2869
- this.closeGateCompletion = null;
2870
2657
  this.todoStopGuardQueuedPromptPriority = false;
2871
2658
  this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
2872
2659
  this.todoStopGuard.clearTrust();
@@ -2883,7 +2670,7 @@ var Session = class {
2883
2670
  this.cronProcessing = false;
2884
2671
  this.cronCompletion = null;
2885
2672
  if (this.config.isCronEnabled()) {
2886
- this.#stopCronSchedulerInRuntime();
2673
+ this.config.getCronScheduler().stop();
2887
2674
  }
2888
2675
  this.config.getBackgroundTaskRegistry().setNotificationCallback(void 0);
2889
2676
  this.config.getMonitorRegistry().setNotificationCallback(void 0);
@@ -2967,7 +2754,7 @@ var Session = class {
2967
2754
  "targetTurnIndex must be a non-negative integer"
2968
2755
  );
2969
2756
  }
2970
- if (this.closing || this.#hasActiveTurn()) {
2757
+ if (this.pendingPrompt || this.cronProcessing || this.cronAbortController || this.notificationProcessing || this.notificationAbortController) {
2971
2758
  throw RequestError.invalidParams(
2972
2759
  void 0,
2973
2760
  "Cannot rewind while a prompt is running"
@@ -3024,7 +2811,7 @@ var Session = class {
3024
2811
  return count;
3025
2812
  }
3026
2813
  restoreHistory(history) {
3027
- if (this.closing || this.#hasActiveTurn()) {
2814
+ if (this.pendingPrompt || this.cronProcessing || this.cronAbortController || this.notificationProcessing || this.notificationAbortController) {
3028
2815
  throw RequestError.invalidParams(
3029
2816
  void 0,
3030
2817
  "Cannot restore history while a prompt is running"
@@ -3098,17 +2885,13 @@ var Session = class {
3098
2885
  const scheduler = this.config.isCronEnabled() ? this.config.getCronScheduler() : null;
3099
2886
  if (scheduler) {
3100
2887
  const summary = scheduler.getExitSummary();
3101
- this.#stopCronSchedulerInRuntime();
2888
+ scheduler.stop();
3102
2889
  if (summary) {
3103
2890
  await this.messageEmitter.emitAgentMessage(summary);
3104
2891
  }
3105
2892
  }
3106
2893
  }
3107
2894
  async prompt(params) {
3108
- if (this.closing) {
3109
- throw RequestError.invalidParams(void 0, "Session is closing");
3110
- }
3111
- await this.assertCanStartTurn();
3112
2895
  const todoStopGuardPreparation = this.#prepareTodoStopGuardForPrompt(params);
3113
2896
  this.pendingPrompt?.abort();
3114
2897
  const pendingSend = new AbortController();
@@ -3168,13 +2951,6 @@ var Session = class {
3168
2951
  void this.#drainNotificationQueue();
3169
2952
  this.#maybeEmitFollowupSuggestion(result);
3170
2953
  return result;
3171
- } catch (error) {
3172
- if (error instanceof SessionWriterError) {
3173
- throw new RequestError(error.rpcCode, error.message, {
3174
- errorKind: error.errorKind
3175
- });
3176
- }
3177
- throw error;
3178
2954
  } finally {
3179
2955
  this.pendingPrompt = null;
3180
2956
  const shouldDrainAutomaticQueues = todoStopGuardPreparation.drainSupersededAutomaticQueues || this.todoStopGuardDrainAutomaticQueuesWhenIdle || this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority;
@@ -3183,7 +2959,7 @@ var Session = class {
3183
2959
  void this.#drainCronQueue();
3184
2960
  void this.#drainNotificationQueue();
3185
2961
  }
3186
- void this.#startCronSchedulerInRuntime();
2962
+ void this.#startCronSchedulerIfNeeded();
3187
2963
  resolveCompletion();
3188
2964
  this.pendingPromptCompletion = null;
3189
2965
  }
@@ -3317,10 +3093,6 @@ var Session = class {
3317
3093
  this.runtimeBaseDir,
3318
3094
  this.config.getWorkingDir(),
3319
3095
  async () => {
3320
- await this.assertCanStartTurn();
3321
- if (pendingSend.signal.aborted) {
3322
- return { stopReason: "cancelled" };
3323
- }
3324
3096
  this.turn += 1;
3325
3097
  const promptId = this.config.getSessionId() + "########" + this.turn;
3326
3098
  const parentContext = extractDaemonTraceContext(params);
@@ -3631,11 +3403,7 @@ ${this.pendingWorktreeNotice}
3631
3403
  toolRun,
3632
3404
  pendingSend.signal
3633
3405
  );
3634
- return {
3635
- stopReason: getAbortAwareEndTurnStopReason(
3636
- pendingSend.signal
3637
- )
3638
- };
3406
+ return { stopReason: "end_turn" };
3639
3407
  }
3640
3408
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
3641
3409
  toolRun,
@@ -3649,11 +3417,7 @@ ${this.pendingWorktreeNotice}
3649
3417
  toolRun,
3650
3418
  pendingSend.signal
3651
3419
  );
3652
- return {
3653
- stopReason: getAbortAwareEndTurnStopReason(
3654
- pendingSend.signal
3655
- )
3656
- };
3420
+ return { stopReason: "end_turn" };
3657
3421
  }
3658
3422
  }
3659
3423
  }
@@ -3698,7 +3462,7 @@ ${this.pendingWorktreeNotice}
3698
3462
  while (true) {
3699
3463
  if (pendingSend.signal.aborted) {
3700
3464
  this.todoStopGuard.suspend();
3701
- return { stopReason: "cancelled" };
3465
+ return { stopReason: "end_turn" };
3702
3466
  }
3703
3467
  if (this.config.getApprovalMode() === "plan" /* PLAN */) {
3704
3468
  this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
@@ -3801,7 +3565,7 @@ ${this.pendingWorktreeNotice}
3801
3565
  await this.messageEmitter.emitAgentMessage(stopOutput.systemMessage);
3802
3566
  }
3803
3567
  if (stopOutput?.isBlockingDecision() || stopOutput?.shouldStopExecution()) {
3804
- externalReason = getStopHookContinuationReason(stopOutput);
3568
+ externalReason = stopOutput.getEffectiveReason();
3805
3569
  stopHookIterationCount++;
3806
3570
  stopHookReasons = [...stopHookReasons, externalReason];
3807
3571
  stopHookCount = response.stopHookCount ?? 1;
@@ -4148,7 +3912,7 @@ ${this.pendingWorktreeNotice}
4148
3912
  await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
4149
3913
  return {
4150
3914
  kind: "terminal",
4151
- stopReason: getAbortAwareEndTurnStopReason(pendingSend.signal),
3915
+ stopReason: "end_turn",
4152
3916
  ...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
4153
3917
  };
4154
3918
  }
@@ -4397,18 +4161,13 @@ ${this.pendingWorktreeNotice}
4397
4161
  }
4398
4162
  }
4399
4163
  async #preserveStoppedToolRun(toolRun, abortSignal) {
4400
- const midTurnParts = abortSignal.aborted ? await this.#buildMidTurnParts(
4401
- this.#takeRecoveredMidTurnMessages(),
4402
- abortSignal,
4403
- { preserveFallbackOnAbort: true }
4404
- ) : await this.#drainMidTurnUserMessages(abortSignal);
4405
4164
  this.#preserveUnsentMessageHistory(
4406
4165
  {
4407
4166
  role: "user",
4408
4167
  parts: [
4409
4168
  ...toolRun.parts,
4410
4169
  ...toolRun.loopDetected ? [{ text: LOOP_DETECTED_CONTEXT_MESSAGE }] : [],
4411
- ...midTurnParts
4170
+ ...await this.#drainMidTurnUserMessages(abortSignal)
4412
4171
  ]
4413
4172
  },
4414
4173
  true
@@ -4523,7 +4282,11 @@ ${this.pendingWorktreeNotice}
4523
4282
  const recovered = this.#takeRecoveredMidTurnMessages();
4524
4283
  if (this.midTurnDrainUnavailable) {
4525
4284
  return {
4526
- parts: await this.#buildMidTurnParts(recovered, abortSignal, options),
4285
+ parts: await this.#buildMidTurnParts(
4286
+ recovered,
4287
+ abortSignal,
4288
+ options.onFullTurnModel
4289
+ ),
4527
4290
  hasQueuedPrompt: false
4528
4291
  };
4529
4292
  }
@@ -4551,7 +4314,7 @@ ${this.pendingWorktreeNotice}
4551
4314
  parts: await this.#buildMidTurnParts(
4552
4315
  [...recovered, ...parseMidTurnDrainResponse(response)],
4553
4316
  abortSignal,
4554
- options
4317
+ options.onFullTurnModel
4555
4318
  ),
4556
4319
  hasQueuedPrompt: isRecord2(response) && response["hasQueuedPrompt"] === true
4557
4320
  };
@@ -4571,7 +4334,11 @@ ${this.pendingWorktreeNotice}
4571
4334
  `Mid-turn queue drain ${isPermanentError ? "permanently " : ""}unavailable [session ${this.sessionId}]: ${errorMessage}`
4572
4335
  );
4573
4336
  return {
4574
- parts: await this.#buildMidTurnParts(recovered, abortSignal, options),
4337
+ parts: await this.#buildMidTurnParts(
4338
+ recovered,
4339
+ abortSignal,
4340
+ options.onFullTurnModel
4341
+ ),
4575
4342
  hasQueuedPrompt: false
4576
4343
  };
4577
4344
  }
@@ -4631,7 +4398,7 @@ ${this.pendingWorktreeNotice}
4631
4398
  * happens on injection (here), so a message recovered from an earlier
4632
4399
  * timed-out drain is still recorded exactly once.
4633
4400
  */
4634
- async #buildMidTurnParts(messages, abortSignal, options = {}) {
4401
+ async #buildMidTurnParts(messages, abortSignal, onFullTurnModel) {
4635
4402
  const parts = [];
4636
4403
  for (const message of messages) {
4637
4404
  const displayText = message.kind === "text" ? message.message : message.displayText;
@@ -4641,19 +4408,13 @@ ${this.pendingWorktreeNotice}
4641
4408
  abortSignal,
4642
4409
  MID_TURN_QUEUE_RESOLVE_TIMEOUT_MS,
4643
4410
  (signal) => this.#resolvePrompt(message.content, signal, {
4644
- onFullTurnModel: options.onFullTurnModel
4411
+ onFullTurnModel
4645
4412
  })
4646
4413
  );
4647
4414
  } catch (messageError) {
4648
- if (abortSignal.aborted && !options.preserveFallbackOnAbort) {
4649
- return parts;
4650
- }
4651
- if (!abortSignal.aborted) {
4652
- const errorMessage = this.#formatError(messageError);
4653
- debugLogger6.warn(
4654
- `Failed to resolve mid-turn message: ${errorMessage}`
4655
- );
4656
- }
4415
+ if (abortSignal.aborted) return parts;
4416
+ const errorMessage = this.#formatError(messageError);
4417
+ debugLogger6.warn(`Failed to resolve mid-turn message: ${errorMessage}`);
4657
4418
  rawParts = [{ text: displayText }];
4658
4419
  if (message.kind === "structured" && hasInlineMediaContentBlock(message.content)) {
4659
4420
  rawParts.push({ text: MID_TURN_ATTACHMENT_PROCESSING_FAILURE_TEXT });
@@ -4695,20 +4456,6 @@ ${this.pendingWorktreeNotice}
4695
4456
  void this.#drainCronQueue();
4696
4457
  });
4697
4458
  }
4698
- #startCronSchedulerInRuntime() {
4699
- return Storage.runWithRuntimeBaseDir(
4700
- this.runtimeBaseDir,
4701
- this.config.getWorkingDir(),
4702
- () => this.#startCronSchedulerIfNeeded()
4703
- );
4704
- }
4705
- #stopCronSchedulerInRuntime() {
4706
- Storage.runWithRuntimeBaseDir(
4707
- this.runtimeBaseDir,
4708
- this.config.getWorkingDir(),
4709
- () => this.config.getCronScheduler().stop()
4710
- );
4711
- }
4712
4459
  #enqueueCronPrompt(item) {
4713
4460
  if ((this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuardQueuedPromptPriority) && !this.#cronContinuesTodoStopGuardWorkChain(item)) {
4714
4461
  if (item.taskId) {
@@ -4739,24 +4486,10 @@ ${this.pendingWorktreeNotice}
4739
4486
  */
4740
4487
  async #drainCronQueue() {
4741
4488
  if (this.disposed) return;
4742
- if (this.closing) return;
4743
4489
  if (this.cronProcessing) return;
4744
4490
  if (this.pendingPrompt) return;
4745
4491
  if (this.notificationProcessing) return;
4746
- if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
4747
4492
  if (this.#nextCronQueueIndex() < 0) return;
4748
- try {
4749
- await this.assertCanStartTurn();
4750
- } catch (error) {
4751
- debugLogger6.warn(
4752
- `Cron turn rejected [session ${this.sessionId}]: ${error instanceof Error ? error.message : String(error)}`
4753
- );
4754
- return;
4755
- }
4756
- if (this.disposed || this.closing || this.cronProcessing || this.pendingPrompt || this.notificationProcessing || this.#nextCronQueueIndex() < 0) {
4757
- return;
4758
- }
4759
- if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
4760
4493
  this.cronProcessing = true;
4761
4494
  let resolveCompletion;
4762
4495
  this.cronCompletion = new Promise((resolve5) => {
@@ -4778,7 +4511,7 @@ ${this.pendingWorktreeNotice}
4778
4511
  if (this.config.isCronEnabled()) {
4779
4512
  const scheduler = this.config.getCronScheduler();
4780
4513
  if (!scheduler.hasPendingWork) {
4781
- this.#stopCronSchedulerInRuntime();
4514
+ scheduler.stop();
4782
4515
  }
4783
4516
  }
4784
4517
  }
@@ -4845,8 +4578,6 @@ ${this.pendingWorktreeNotice}
4845
4578
  async () => {
4846
4579
  let turnCount = 0;
4847
4580
  try {
4848
- await this.assertCanStartTurn();
4849
- if (ac.signal.aborted) return;
4850
4581
  const loopMode = detectLoopSentinel(prompt);
4851
4582
  const autonomousMode = loopMode ? null : detectAutonomousSentinel(prompt);
4852
4583
  let loopTick = null;
@@ -5176,26 +4907,12 @@ ${this.pendingWorktreeNotice}
5176
4907
  }
5177
4908
  async #drainNotificationQueue() {
5178
4909
  if (this.disposed) return;
5179
- if (this.closing) return;
5180
4910
  if (this.notificationProcessing) return;
5181
4911
  if (this.pendingPrompt || this.cronProcessing || this.cronAbortController) {
5182
4912
  return;
5183
4913
  }
5184
- if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
5185
4914
  if (this.notificationQueue.length === 0) return;
5186
4915
  if (this.#nextNotificationQueueIndex() < 0) return;
5187
- try {
5188
- await this.assertCanStartTurn();
5189
- } catch (error) {
5190
- debugLogger6.warn(
5191
- `Notification turn rejected [session ${this.sessionId}]: ${error instanceof Error ? error.message : String(error)}`
5192
- );
5193
- return;
5194
- }
5195
- if (this.disposed || this.closing || this.notificationProcessing || this.pendingPrompt || this.cronProcessing || this.cronAbortController || this.#nextNotificationQueueIndex() < 0) {
5196
- return;
5197
- }
5198
- if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
5199
4916
  this.notificationProcessing = true;
5200
4917
  let resolveCompletion;
5201
4918
  this.notificationCompletion = new Promise((resolve5) => {
@@ -5245,8 +4962,6 @@ ${this.pendingWorktreeNotice}
5245
4962
  );
5246
4963
  const promptId = this.config.getSessionId() + "########notification" + Date.now();
5247
4964
  try {
5248
- await this.assertCanStartTurn();
5249
- if (ac.signal.aborted) return;
5250
4965
  await this.#emitBackgroundNotificationDisplay(item);
5251
4966
  const notificationParts = [{ text: item.modelText }];
5252
4967
  this.config.getChatRecordingService()?.recordNotification(notificationParts, item.displayText);
@@ -5376,9 +5091,7 @@ ${this.pendingWorktreeNotice}
5376
5091
  if (toolRun.stopAfterPermissionCancel) {
5377
5092
  this.todoStopGuard.suspend();
5378
5093
  await this.#preserveStoppedToolRun(toolRun, ac.signal);
5379
- await this.#emitBackgroundNotificationEndTurn(
5380
- getAbortAwareEndTurnStopReason(ac.signal)
5381
- );
5094
+ await this.#emitBackgroundNotificationEndTurn("end_turn");
5382
5095
  return;
5383
5096
  }
5384
5097
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
@@ -5389,9 +5102,7 @@ ${this.pendingWorktreeNotice}
5389
5102
  if (toolRun.loopDetected) {
5390
5103
  this.todoStopGuard.suspend();
5391
5104
  await this.#preserveStoppedToolRun(toolRun, ac.signal);
5392
- await this.#emitBackgroundNotificationEndTurn(
5393
- getAbortAwareEndTurnStopReason(ac.signal)
5394
- );
5105
+ await this.#emitBackgroundNotificationEndTurn("end_turn");
5395
5106
  return;
5396
5107
  }
5397
5108
  }
@@ -5409,9 +5120,7 @@ ${this.pendingWorktreeNotice}
5409
5120
  false
5410
5121
  )).stopReason;
5411
5122
  }
5412
- await this.#emitBackgroundNotificationEndTurn(
5413
- ac.signal.aborted ? "cancelled" : stopReason
5414
- );
5123
+ await this.#emitBackgroundNotificationEndTurn(stopReason);
5415
5124
  } catch (error) {
5416
5125
  if (ac.signal.aborted) {
5417
5126
  this.todoStopGuard.suspend();
@@ -5704,46 +5413,8 @@ ${this.pendingWorktreeNotice}
5704
5413
  */
5705
5414
  async runToolCalls(abortSignal, promptId, functionCalls, toolLoopState) {
5706
5415
  const dedupedFunctionCalls = dedupeToolCallsById(functionCalls);
5707
- const generatedCallIdBase = randomUUID();
5708
- const executionCallIds = new Map(
5709
- dedupedFunctionCalls.map((functionCall, index) => [
5710
- functionCall,
5711
- functionCall.id ?? `${functionCall.name ?? "tool"}-${generatedCallIdBase}-${index}`
5712
- ])
5713
- );
5714
- const pendingToolResultRecords = [];
5715
- let toolResultRecordSequence = 0;
5716
- const queueToolResultRecord = /* @__PURE__ */ __name((fc, record) => {
5717
- pendingToolResultRecords.push({
5718
- ...record,
5719
- ordinal: dedupedFunctionCalls.indexOf(fc),
5720
- sequence: toolResultRecordSequence++
5721
- });
5722
- }, "queueToolResultRecord");
5723
- const finalizeRunToolResult = /* @__PURE__ */ __name(async (result) => {
5724
- if (pendingToolResultRecords.length === 0) return result;
5725
- const orderedRecords = [...pendingToolResultRecords].sort(
5726
- (left, right) => left.ordinal - right.ordinal || left.sequence - right.sequence
5727
- );
5728
- const finalized = await finalizeToolResponses(
5729
- this.config,
5730
- orderedRecords.map((record) => ({
5731
- callId: record.callId,
5732
- toolName: record.toolName,
5733
- responseParts: record.responseParts,
5734
- persistedOutputFiles: record.persistedOutputFiles
5735
- }))
5736
- );
5737
- orderedRecords.forEach((record, index) => {
5738
- this.config.getChatRecordingService()?.recordToolResult(finalized[index].responseParts, record.metadata);
5739
- });
5740
- return {
5741
- ...result,
5742
- parts: finalized.flatMap((entry) => entry.responseParts)
5743
- };
5744
- }, "finalizeRunToolResult");
5745
5416
  let skippedToolCallCounter = 0;
5746
- const recordSkippedToolCall = /* @__PURE__ */ __name(async (fc, message = PERMISSION_CANCEL_SKIP_MESSAGE, emitStart = true, errorType) => {
5417
+ const recordSkippedToolCall = /* @__PURE__ */ __name(async (fc, message = PERMISSION_CANCEL_SKIP_MESSAGE, emitStart = true) => {
5747
5418
  const toolName = fc.name ?? "unknown_tool";
5748
5419
  const callId = fc.id ?? `${toolName}-skip-${++skippedToolCallCounter}`;
5749
5420
  const part = {
@@ -5755,17 +5426,12 @@ ${this.pendingWorktreeNotice}
5755
5426
  };
5756
5427
  const error = new Error(message);
5757
5428
  try {
5758
- queueToolResultRecord(fc, {
5429
+ this.config.getChatRecordingService()?.recordToolResult([part], {
5759
5430
  callId,
5760
- toolName,
5761
- responseParts: [part],
5762
- metadata: {
5763
- callId,
5764
- status: "error",
5765
- resultDisplay: void 0,
5766
- error,
5767
- errorType
5768
- }
5431
+ status: "error",
5432
+ resultDisplay: void 0,
5433
+ error,
5434
+ errorType: void 0
5769
5435
  });
5770
5436
  if (emitStart) {
5771
5437
  await this.toolCallEmitter.emitStart({
@@ -5787,7 +5453,7 @@ ${this.pendingWorktreeNotice}
5787
5453
  toolLoopState,
5788
5454
  dedupedFunctionCalls.length
5789
5455
  )) {
5790
- return await finalizeRunToolResult({
5456
+ return {
5791
5457
  parts: await Promise.all(
5792
5458
  dedupedFunctionCalls.map(
5793
5459
  (fc) => recordSkippedToolCall(fc, LOOP_DETECTED_SKIP_MESSAGE, false)
@@ -5795,7 +5461,7 @@ ${this.pendingWorktreeNotice}
5795
5461
  ),
5796
5462
  stopAfterPermissionCancel: false,
5797
5463
  loopDetected: true
5798
- });
5464
+ };
5799
5465
  }
5800
5466
  const batches = [];
5801
5467
  const handledProviderToolCallIds = new Set(
@@ -5812,13 +5478,13 @@ ${this.pendingWorktreeNotice}
5812
5478
  debugLogger6.debug(
5813
5479
  `[Session.runToolCalls] Dropping batch after repeated duplicate provider tool-call id: ${providerCallId} (tool: ${repeatedDuplicateCall.name ?? "unknown_tool"})`
5814
5480
  );
5815
- return await finalizeRunToolResult({
5481
+ return {
5816
5482
  parts: [],
5817
5483
  stopAfterPermissionCancel: false,
5818
5484
  repeatedDuplicateProviderToolCall: true
5819
- });
5485
+ };
5820
5486
  }
5821
- const pushDuplicateBatch = /* @__PURE__ */ __name((fc, request) => {
5487
+ const pushDuplicateBatch = /* @__PURE__ */ __name((request) => {
5822
5488
  const providerCallId = request.providerCallId ?? request.callId;
5823
5489
  markDuplicateProviderToolCallResponseSent(
5824
5490
  providerCallId,
@@ -5828,7 +5494,7 @@ ${this.pendingWorktreeNotice}
5828
5494
  debugLogger6.debug(
5829
5495
  `[Session.runToolCalls] Suppressing duplicate provider tool-call id: ${providerCallId} (tool: ${request.name})`
5830
5496
  );
5831
- batches.push({ kind: "duplicate", fc, request, response });
5497
+ batches.push({ kind: "duplicate", request, response });
5832
5498
  }, "pushDuplicateBatch");
5833
5499
  const emitDuplicateBatch = /* @__PURE__ */ __name(async (batch) => {
5834
5500
  const { request, response } = batch;
@@ -5865,26 +5531,20 @@ ${this.pendingWorktreeNotice}
5865
5531
  success: false
5866
5532
  });
5867
5533
  }
5868
- queueToolResultRecord(batch.fc, {
5534
+ this.config.getChatRecordingService()?.recordToolResult(response.responseParts, {
5869
5535
  callId: response.callId,
5870
- toolName: request.name,
5871
- responseParts: response.responseParts,
5872
- persistedOutputFiles: response.persistedOutputFiles,
5873
- metadata: {
5874
- callId: response.callId,
5875
- status: "error",
5876
- resultDisplay: response.resultDisplay,
5877
- error: response.error,
5878
- errorType: response.errorType
5879
- }
5536
+ status: "error",
5537
+ resultDisplay: response.resultDisplay,
5538
+ error: response.error,
5539
+ errorType: response.errorType
5880
5540
  });
5881
5541
  }, "emitDuplicateBatch");
5882
5542
  for (const fc of dedupedFunctionCalls) {
5883
5543
  const providerCallId = getProviderToolCallId(fc) ?? fc.id;
5884
5544
  if (providerCallId) {
5885
5545
  if (handledProviderToolCallIds.has(providerCallId)) {
5886
- const callId = executionCallIds.get(fc);
5887
- pushDuplicateBatch(fc, {
5546
+ const callId = fc.id ?? `${fc.name}-${Date.now()}`;
5547
+ pushDuplicateBatch({
5888
5548
  callId,
5889
5549
  providerCallId,
5890
5550
  name: fc.name ?? "unknown_tool",
@@ -5904,13 +5564,6 @@ ${this.pendingWorktreeNotice}
5904
5564
  batches.push({ kind: "execute", concurrent: isAgent, calls: [fc] });
5905
5565
  }
5906
5566
  }
5907
- const executableCalls = batches.flatMap(
5908
- (batch) => batch.kind === "execute" ? batch.calls : []
5909
- );
5910
- const planModeEntryBoundaryIndex = findPlanModeEntryBatchBoundaryIndex(
5911
- executableCalls.map((call) => call.name)
5912
- );
5913
- const planModeEntryBoundary = planModeEntryBoundaryIndex === void 0 ? void 0 : executableCalls[planModeEntryBoundaryIndex];
5914
5567
  const appendSkippedAfter = /* @__PURE__ */ __name(async (parts2, fc, message = PERMISSION_CANCEL_SKIP_MESSAGE) => {
5915
5568
  const startIndex = dedupedFunctionCalls.indexOf(fc) + 1;
5916
5569
  for (const remainingCall of dedupedFunctionCalls.slice(startIndex)) {
@@ -5977,9 +5630,7 @@ ${this.pendingWorktreeNotice}
5977
5630
  calls[i],
5978
5631
  onStopAfterPermissionCancel,
5979
5632
  toolLoopState,
5980
- recordSkippedToolCall,
5981
- queueToolResultRecord,
5982
- executionCallIds.get(calls[i])
5633
+ recordSkippedToolCall
5983
5634
  );
5984
5635
  results[i] = r;
5985
5636
  if (r.loopDetected) {
@@ -6011,9 +5662,7 @@ ${this.pendingWorktreeNotice}
6011
5662
  calls[idx],
6012
5663
  onStopAfterPermissionCancel,
6013
5664
  toolLoopState,
6014
- recordSkippedToolCall,
6015
- queueToolResultRecord,
6016
- executionCallIds.get(calls[idx])
5665
+ recordSkippedToolCall
6017
5666
  ).then((r) => {
6018
5667
  results[idx] = r;
6019
5668
  }).finally(() => {
@@ -6052,19 +5701,6 @@ ${this.pendingWorktreeNotice}
6052
5701
  parts.push(...batch.response.responseParts);
6053
5702
  continue;
6054
5703
  }
6055
- if (planModeEntryBoundary && !batch.calls.includes(planModeEntryBoundary)) {
6056
- for (const fc of batch.calls) {
6057
- parts.push(
6058
- await recordSkippedToolCall(
6059
- fc,
6060
- PLAN_MODE_ENTRY_SIBLING_SKIP_MESSAGE,
6061
- true,
6062
- "execution_denied" /* EXECUTION_DENIED */
6063
- )
6064
- );
6065
- }
6066
- continue;
6067
- }
6068
5704
  if (batch.concurrent && batch.calls.length > 1) {
6069
5705
  const batchAbortController = new AbortController();
6070
5706
  let batchStopAfterPermissionCancel = false;
@@ -6108,24 +5744,24 @@ ${this.pendingWorktreeNotice}
6108
5744
  batch.calls[batch.calls.length - 1],
6109
5745
  LOOP_DETECTED_SKIP_MESSAGE
6110
5746
  );
6111
- return await finalizeRunToolResult({
5747
+ return {
6112
5748
  parts,
6113
5749
  stopAfterPermissionCancel: false,
6114
5750
  loopDetected: true,
6115
5751
  memoryWriteCandidates
6116
- });
5752
+ };
6117
5753
  }
6118
5754
  if (shouldStop) {
6119
5755
  await appendSkippedAfter(
6120
5756
  parts,
6121
5757
  batch.calls[batch.calls.length - 1]
6122
5758
  );
6123
- return await finalizeRunToolResult({
5759
+ return {
6124
5760
  parts,
6125
5761
  stopAfterPermissionCancel: true,
6126
5762
  repeatedDuplicateProviderToolCall: false,
6127
5763
  memoryWriteCandidates
6128
- });
5764
+ };
6129
5765
  }
6130
5766
  } else {
6131
5767
  for (const fc of batch.calls) {
@@ -6135,39 +5771,37 @@ ${this.pendingWorktreeNotice}
6135
5771
  fc,
6136
5772
  void 0,
6137
5773
  toolLoopState,
6138
- recordSkippedToolCall,
6139
- queueToolResultRecord,
6140
- executionCallIds.get(fc)
5774
+ recordSkippedToolCall
6141
5775
  );
6142
5776
  parts.push(...r.parts);
6143
5777
  collectMemoryWriteCandidates(r);
6144
5778
  if (r.loopDetected) {
6145
5779
  await appendSkippedAfter(parts, fc, LOOP_DETECTED_SKIP_MESSAGE);
6146
- return await finalizeRunToolResult({
5780
+ return {
6147
5781
  parts,
6148
5782
  stopAfterPermissionCancel: false,
6149
5783
  loopDetected: true,
6150
5784
  memoryWriteCandidates
6151
- });
5785
+ };
6152
5786
  }
6153
5787
  if (r.stopAfterPermissionCancel) {
6154
5788
  await appendSkippedAfter(parts, fc);
6155
- return await finalizeRunToolResult({
5789
+ return {
6156
5790
  parts,
6157
5791
  stopAfterPermissionCancel: true,
6158
5792
  repeatedDuplicateProviderToolCall: false,
6159
5793
  memoryWriteCandidates
6160
- });
5794
+ };
6161
5795
  }
6162
5796
  }
6163
5797
  }
6164
5798
  }
6165
- return await finalizeRunToolResult({
5799
+ return {
6166
5800
  parts,
6167
5801
  stopAfterPermissionCancel: false,
6168
5802
  repeatedDuplicateProviderToolCall: false,
6169
5803
  memoryWriteCandidates
6170
- });
5804
+ };
6171
5805
  } finally {
6172
5806
  await refreshMemoryIfNeeded();
6173
5807
  }
@@ -6202,8 +5836,8 @@ ${this.pendingWorktreeNotice}
6202
5836
  }
6203
5837
  return reminders;
6204
5838
  }
6205
- async runTool(abortSignal, promptId, fc, onStopAfterPermissionCancel, toolLoopState, recordSkippedToolCall, queueToolResultRecord, generatedCallId) {
6206
- const callId = fc.id ?? generatedCallId ?? `${fc.name}-${Date.now()}`;
5839
+ async runTool(abortSignal, promptId, fc, onStopAfterPermissionCancel, toolLoopState, recordSkippedToolCall) {
5840
+ const callId = fc.id ?? `${fc.name}-${Date.now()}`;
6207
5841
  let args = fc.args ?? {};
6208
5842
  if (toolLoopState?.loopDetected) {
6209
5843
  return {
@@ -6265,17 +5899,12 @@ ${this.pendingWorktreeNotice}
6265
5899
  await this.toolCallEmitter.emitError(callId, toolName2, error);
6266
5900
  }
6267
5901
  const errorParts = errorResponse(error);
6268
- queueToolResultRecord?.(fc, {
5902
+ this.config.getChatRecordingService()?.recordToolResult(errorParts, {
6269
5903
  callId,
6270
- toolName: toolName2,
6271
- responseParts: errorParts,
6272
- metadata: {
6273
- callId,
6274
- status: "error",
6275
- resultDisplay: void 0,
6276
- error,
6277
- errorType: void 0
6278
- }
5904
+ status: "error",
5905
+ resultDisplay: void 0,
5906
+ error,
5907
+ errorType: void 0
6279
5908
  });
6280
5909
  const loopDetected = opts?.recordInvalidToolParams === true && !activeToolAbortSignal.aborted && !opts?.stopAfterPermissionCancel && recordDaemonInvalidToolParams(
6281
5910
  this.config,
@@ -6305,21 +5934,19 @@ ${this.pendingWorktreeNotice}
6305
5934
  { recordInvalidToolParams: true }
6306
5935
  );
6307
5936
  }
6308
- const policyToolName = tool.name;
6309
- const originalPolicyRequestArgs = policyToolName === ToolNames.SHELL || policyToolName === ToolNames.MONITOR ? structuredClone(args) : args;
6310
- const toolSpan = startToolSpan(policyToolName, {
5937
+ const toolSpan = startToolSpan(toolName, {
6311
5938
  "tool.call_id": callId,
6312
5939
  // Dual-emit the legacy call_id/tool_name aliases like CoreToolScheduler
6313
5940
  // (coreToolScheduler.ts) so pre-Phase-2 dashboards keyed off call_id keep
6314
5941
  // matching daemon/ACP tool spans during the migration window.
6315
5942
  call_id: callId,
6316
- tool_name: policyToolName
5943
+ tool_name: toolName
6317
5944
  });
6318
5945
  let spanSuccess = false;
6319
5946
  try {
6320
5947
  return await runInToolSpanContext(toolSpan, async () => {
6321
5948
  const pm = this.config.getPermissionManager?.();
6322
- if (pm && !await pm.isToolEnabled(policyToolName)) {
5949
+ if (pm && !await pm.isToolEnabled(toolName)) {
6323
5950
  return earlyErrorResponse(
6324
5951
  new Error(`Tool "${toolName}" is disabled.`),
6325
5952
  toolName
@@ -6348,7 +5975,7 @@ ${this.pendingWorktreeNotice}
6348
5975
  }
6349
5976
  }
6350
5977
  const toolUseId = generateToolUseId();
6351
- let approvalMode = this.config.getApprovalMode();
5978
+ const approvalMode = this.config.getApprovalMode();
6352
5979
  let toolBuildSucceeded = false;
6353
5980
  try {
6354
5981
  const invocation = tool.build(args);
@@ -6373,12 +6000,12 @@ ${this.pendingWorktreeNotice}
6373
6000
  activeToolAbortSignal
6374
6001
  );
6375
6002
  }
6376
- const isAskUserQuestionTool = policyToolName === ToolNames.ASK_USER_QUESTION;
6377
- let toolParams = invocation.params;
6003
+ const isAskUserQuestionTool = toolName === ToolNames.ASK_USER_QUESTION;
6004
+ const toolParams = invocation.params;
6378
6005
  const flowResult = await evaluatePermissionFlow(
6379
6006
  this.config,
6380
6007
  invocation,
6381
- policyToolName,
6008
+ toolName,
6382
6009
  toolParams
6383
6010
  );
6384
6011
  const {
@@ -6388,75 +6015,31 @@ ${this.pendingWorktreeNotice}
6388
6015
  denyMessage,
6389
6016
  requiresUserInteraction
6390
6017
  } = flowResult;
6391
- approvalMode = this.config.getApprovalMode();
6392
6018
  const isPlanMode = approvalMode === "plan" /* PLAN */;
6393
- const isPlanShellCall = isPlanMode && (policyToolName === ToolNames.SHELL || policyToolName === ToolNames.MONITOR);
6394
6019
  if (finalPermission === "deny") {
6395
6020
  return earlyErrorResponse(
6396
6021
  new Error(denyMessage ?? `Tool "${toolName}" is denied.`),
6397
6022
  toolName
6398
6023
  );
6399
6024
  }
6400
- let planShellAmbientWorkingDirectory;
6401
- if (isPlanShellCall) {
6402
- const directory = toolParams["directory"];
6403
- planShellAmbientWorkingDirectory = typeof directory === "string" && directory.length > 0 ? void 0 : this.config.getTargetDir();
6404
- invocation.params = {
6405
- ...structuredClone(invocation.params),
6406
- directory: typeof directory === "string" && directory.length > 0 ? directory : planShellAmbientWorkingDirectory
6407
- };
6408
- toolParams = invocation.params;
6409
- }
6410
- const planShellDecision = isPlanShellCall ? await evaluatePlanModeShellPolicy({
6411
- config: this.config,
6412
- toolName: policyToolName,
6413
- requestArgs: originalPolicyRequestArgs,
6414
- invocationParams: toolParams,
6415
- permissionContext: pmCtx,
6416
- ambientWorkingDirectory: planShellAmbientWorkingDirectory,
6417
- signal: activeToolAbortSignal
6418
- }) : { classification: "not-applicable" };
6419
- if (planShellDecision.classification !== "not-applicable") {
6420
- const initialPlanShellError = await validatePlanModeShellContext({
6421
- config: this.config,
6422
- decision: planShellDecision,
6423
- requestArgs: args,
6424
- invocationParams: invocation.params,
6425
- signal: activeToolAbortSignal
6426
- });
6427
- if (initialPlanShellError) {
6428
- return earlyErrorResponse(
6429
- new Error(initialPlanShellError),
6430
- toolName
6431
- );
6432
- }
6433
- }
6434
- if (planShellDecision.classification === "write") {
6435
- return earlyErrorResponse(
6436
- new Error(planShellDecision.writeBlockMessage),
6437
- toolName
6438
- );
6439
- }
6440
- const planShellRequiresConfirmation = planShellDecision.classification === "unknown";
6441
- const forceAutoReviewForAllow = approvalMode === "auto" /* AUTO */ && (shouldForceAutoModeReviewForAllow(pmCtx, this.config.getCwd()) || shouldClassifyAllShellForAutoMode(policyToolName, this.config));
6025
+ const forceAutoReviewForAllow = approvalMode === "auto" /* AUTO */ && (shouldForceAutoModeReviewForAllow(pmCtx, this.config.getCwd()) || shouldClassifyAllShellForAutoMode(toolName, this.config));
6442
6026
  const confirmationPermission = getEffectivePermissionForConfirmation(
6443
6027
  finalPermission,
6444
6028
  forceAutoReviewForAllow
6445
6029
  );
6446
6030
  if (finalPermission === "allow" && forceAutoReviewForAllow) {
6447
6031
  debugLogger6.info(
6448
- `Auto mode: L4 allow overridden by protected-write guard for ${policyToolName}`
6032
+ `Auto mode: L4 allow overridden by protected-write guard for ${toolName}`
6449
6033
  );
6450
6034
  }
6451
- let autoModeAllowed = finalPermission === "allow" && !forceAutoReviewForAllow && !planShellRequiresConfirmation;
6035
+ let autoModeAllowed = finalPermission === "allow" && !forceAutoReviewForAllow;
6452
6036
  if (autoModeAllowed && approvalMode === "auto" /* AUTO */) {
6453
6037
  this.config.setAutoModeDenialState(
6454
6038
  recordAllow(this.config.getAutoModeDenialState())
6455
6039
  );
6456
6040
  }
6457
- let wasAutoModeManualFallback = false;
6458
- let autoModeFallbackMessage;
6459
- if (!autoModeAllowed && !requiresUserInteraction && shouldRunAutoModeForCall(approvalMode, policyToolName)) {
6041
+ let wasAutoModeDenialFallback = false;
6042
+ if (!autoModeAllowed && !requiresUserInteraction && shouldRunAutoModeForCall(approvalMode, toolName)) {
6460
6043
  const denialState = this.config.getAutoModeDenialState();
6461
6044
  const fallback = shouldFallback(denialState);
6462
6045
  const messages = this.config.getGeminiClient?.()?.getHistoryTail(MAX_TRANSCRIPT_MESSAGES, false) ?? [];
@@ -6478,7 +6061,7 @@ ${this.pendingWorktreeNotice}
6478
6061
  this.config,
6479
6062
  decision,
6480
6063
  outcome,
6481
- policyToolName,
6064
+ toolName,
6482
6065
  toolParams,
6483
6066
  callId,
6484
6067
  abortSignal
@@ -6489,16 +6072,17 @@ ${this.pendingWorktreeNotice}
6489
6072
  break;
6490
6073
  case "blocked":
6491
6074
  debugLogger6.warn(
6492
- `Auto mode blocked (${outcome.reason}): tool=${policyToolName}, ` + formatDenialStateLog(denialState)
6075
+ `Auto mode blocked (${outcome.reason}): tool=${toolName}, ` + formatDenialStateLog(denialState)
6493
6076
  );
6494
6077
  return earlyErrorResponse(
6495
6078
  new Error(outcome.errorMessage),
6496
6079
  toolName
6497
6080
  );
6498
6081
  case "fallback":
6499
- wasAutoModeManualFallback = isDenialFallbackReason(outcome.reason) || outcome.reason === "classifier_unavailable";
6500
- autoModeFallbackMessage = outcome.message;
6501
- if (wasAutoModeManualFallback) {
6082
+ wasAutoModeDenialFallback = isDenialFallbackReason(
6083
+ outcome.reason
6084
+ );
6085
+ if (wasAutoModeDenialFallback) {
6502
6086
  debugLogger6.warn(
6503
6087
  `Auto mode fallback to manual approval (${outcome.reason}): ` + formatDenialStateLog(denialState)
6504
6088
  );
@@ -6513,7 +6097,7 @@ ${this.pendingWorktreeNotice}
6513
6097
  let didRequestPermission = false;
6514
6098
  let confirmationDetails;
6515
6099
  const recordAutoModeFallbackResolution = /* @__PURE__ */ __name((outcome) => {
6516
- if (approvalMode === "auto" /* AUTO */ && wasAutoModeManualFallback && isApproveOutcome(outcome)) {
6100
+ if (approvalMode === "auto" /* AUTO */ && wasAutoModeDenialFallback && isApproveOutcome(outcome)) {
6517
6101
  const before = this.config.getAutoModeDenialState();
6518
6102
  const after = recordFallbackApprove(before);
6519
6103
  if (after === before) {
@@ -6529,51 +6113,14 @@ ${this.pendingWorktreeNotice}
6529
6113
  }
6530
6114
  }, "recordAutoModeFallbackResolution");
6531
6115
  if (!autoModeAllowed && needsConfirmation(
6532
- planShellRequiresConfirmation ? "ask" : confirmationPermission,
6116
+ confirmationPermission,
6533
6117
  approvalMode,
6534
- policyToolName,
6118
+ toolName,
6535
6119
  requiresUserInteraction
6536
6120
  )) {
6537
- confirmationDetails = await invocation.getConfirmationDetails(
6538
- activeToolAbortSignal
6539
- );
6540
- if (autoModeFallbackMessage) {
6541
- confirmationDetails = decorateClassifierUnavailableConfirmation(
6542
- confirmationDetails,
6543
- autoModeFallbackMessage
6544
- );
6545
- }
6546
- if (planShellDecision.classification !== "not-applicable") {
6547
- const preDisplayPlanShellError = await validatePlanModeShellContext({
6548
- config: this.config,
6549
- decision: planShellDecision,
6550
- requestArgs: args,
6551
- invocationParams: invocation.params,
6552
- signal: activeToolAbortSignal
6553
- });
6554
- if (preDisplayPlanShellError) {
6555
- return earlyErrorResponse(
6556
- new Error(preDisplayPlanShellError),
6557
- toolName
6558
- );
6559
- }
6560
- }
6561
- try {
6562
- confirmationDetails = decoratePlanModeShellConfirmation(
6563
- planShellDecision,
6564
- confirmationDetails
6565
- );
6566
- } catch {
6567
- if (planShellDecision.classification === "unknown") {
6568
- return earlyErrorResponse(
6569
- new Error(planShellDecision.noApprovalMessage),
6570
- toolName
6571
- );
6572
- }
6573
- throw new Error("Unable to prepare shell confirmation.");
6574
- }
6121
+ confirmationDetails = await invocation.getConfirmationDetails(abortSignal);
6575
6122
  injectPermissionRulesIfMissing(confirmationDetails, pmCtx);
6576
- if (planShellDecision.classification === "not-applicable" && isPlanModeBlocked(
6123
+ if (isPlanModeBlocked(
6577
6124
  isPlanMode,
6578
6125
  isExitPlanModeTool,
6579
6126
  isAskUserQuestionTool,
@@ -6593,50 +6140,23 @@ ${this.pendingWorktreeNotice}
6593
6140
  if (hooksEnabled && messageBus) {
6594
6141
  const hookResult = await firePermissionRequestHook(
6595
6142
  messageBus,
6596
- policyToolName,
6143
+ toolName,
6597
6144
  args,
6598
- String(approvalMode),
6599
- void 0,
6600
- activeToolAbortSignal
6145
+ String(approvalMode)
6601
6146
  );
6602
6147
  if (hookResult.hasDecision && (!hookResult.shouldAllow || !requiresUserInteraction)) {
6603
6148
  hookHandled = true;
6604
6149
  if (hookResult.shouldAllow) {
6605
- if (planShellDecision.classification !== "not-applicable") {
6606
- const approval = await validatePlanModeShellApproval({
6607
- config: this.config,
6608
- decision: planShellDecision,
6609
- requestArgs: args,
6610
- invocationParams: invocation.params,
6611
- signal: activeToolAbortSignal,
6612
- outcome: "proceed_once" /* ProceedOnce */,
6613
- payload: hookResult.updatedInput ? { updatedInput: hookResult.updatedInput } : void 0
6614
- });
6615
- await confirmationDetails.onConfirm(
6616
- approval.outcome,
6617
- approval.payload
6618
- );
6619
- if (approval.outcome === "cancel" /* Cancel */) {
6620
- return earlyErrorResponse(
6621
- new Error(
6622
- approval.payload?.cancelMessage ?? planShellDecision.noApprovalMessage
6623
- ),
6624
- toolName
6625
- );
6626
- }
6627
- recordAutoModeFallbackResolution(approval.outcome);
6628
- } else {
6629
- if (hookResult.updatedInput) {
6630
- args = hookResult.updatedInput;
6631
- invocation.params = hookResult.updatedInput;
6632
- }
6633
- await confirmationDetails.onConfirm(
6634
- "proceed_once" /* ProceedOnce */
6635
- );
6636
- recordAutoModeFallbackResolution(
6637
- "proceed_once" /* ProceedOnce */
6638
- );
6150
+ if (hookResult.updatedInput) {
6151
+ args = hookResult.updatedInput;
6152
+ invocation.params = hookResult.updatedInput;
6639
6153
  }
6154
+ await confirmationDetails.onConfirm(
6155
+ "proceed_once" /* ProceedOnce */
6156
+ );
6157
+ recordAutoModeFallbackResolution(
6158
+ "proceed_once" /* ProceedOnce */
6159
+ );
6640
6160
  } else {
6641
6161
  return earlyErrorResponse(
6642
6162
  new Error(
@@ -6649,26 +6169,11 @@ ${this.pendingWorktreeNotice}
6649
6169
  }
6650
6170
  if (!requiresUserInteraction && approvalMode === "auto-edit" /* AUTO_EDIT */ && (confirmationDetails.type === "edit" || confirmationDetails.type === "info")) {
6651
6171
  } else if (!hookHandled) {
6652
- if (planShellDecision.classification !== "not-applicable") {
6653
- const finalPreDisplayPlanShellError = await validatePlanModeShellContext({
6654
- config: this.config,
6655
- decision: planShellDecision,
6656
- requestArgs: args,
6657
- invocationParams: invocation.params,
6658
- signal: activeToolAbortSignal
6659
- });
6660
- if (finalPreDisplayPlanShellError) {
6661
- return earlyErrorResponse(
6662
- new Error(finalPreDisplayPlanShellError),
6663
- toolName
6664
- );
6665
- }
6666
- }
6667
6172
  didRequestPermission = true;
6668
6173
  const content = buildPermissionRequestContent(confirmationDetails);
6669
6174
  const mappedKind = this.toolCallEmitter.mapToolKind(
6670
6175
  tool.kind,
6671
- policyToolName
6176
+ toolName
6672
6177
  );
6673
6178
  if (hooksEnabled && messageBus) {
6674
6179
  this.fireNotificationHookWithTerminalSequence(
@@ -6678,16 +6183,9 @@ ${this.pendingWorktreeNotice}
6678
6183
  "Permission needed"
6679
6184
  );
6680
6185
  }
6681
- const permissionOptions = toPermissionOptions(
6682
- confirmationDetails,
6683
- pmForcedAsk
6684
- );
6685
- const offeredPermissionOptions = permissionOptions.map(
6686
- (option) => ({ ...option })
6687
- );
6688
6186
  const params = {
6689
6187
  sessionId: this.sessionId,
6690
- options: permissionOptions,
6188
+ options: toPermissionOptions(confirmationDetails, pmForcedAsk),
6691
6189
  toolCall: {
6692
6190
  toolCallId: callId,
6693
6191
  status: "pending",
@@ -6706,12 +6204,10 @@ ${this.pendingWorktreeNotice}
6706
6204
  }
6707
6205
  }
6708
6206
  };
6709
- const stopAfterPermissionCancel = /* @__PURE__ */ __name((message) => {
6207
+ const stopAfterPermissionCancel = /* @__PURE__ */ __name(() => {
6710
6208
  onStopAfterPermissionCancel?.();
6711
6209
  return earlyErrorResponse(
6712
- new Error(
6713
- message ?? `Tool "${toolName}" was canceled by the user.`
6714
- ),
6210
+ new Error(`Tool "${toolName}" was canceled by the user.`),
6715
6211
  toolName,
6716
6212
  { stopAfterPermissionCancel: true }
6717
6213
  );
@@ -6719,15 +6215,10 @@ ${this.pendingWorktreeNotice}
6719
6215
  let output;
6720
6216
  let outcome;
6721
6217
  try {
6722
- output = await requestPermissionWithAbort(
6723
- this.client,
6724
- params,
6725
- activeToolAbortSignal
6726
- );
6727
- outcome = resolvePermissionOutcome(
6728
- output,
6729
- offeredPermissionOptions
6218
+ output = await this.client.requestPermission(
6219
+ params
6730
6220
  );
6221
+ outcome = output.outcome.outcome === "cancelled" ? "cancel" /* Cancel */ : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
6731
6222
  } catch (error) {
6732
6223
  debugLogger6.error(
6733
6224
  `Permission request failed for tool ${toolName}:`,
@@ -6744,9 +6235,7 @@ ${this.pendingWorktreeNotice}
6744
6235
  );
6745
6236
  }
6746
6237
  onStopAfterPermissionCancel?.();
6747
- const permissionFailureMessage = isExitPlanModeTool ? "The host could not present plan-exit approval. Plan mode remains active; use the host mode selector or /plan exit to leave plan mode." : planShellDecision.classification === "unknown" ? `Plan mode could not complete approval for this shell command: ${this.#formatError(
6748
- error
6749
- )}. The command was not run; Plan mode remains active.` : `Permission request failed for "${toolName}": ${this.#formatError(
6238
+ const permissionFailureMessage = isExitPlanModeTool ? "The host could not present plan-exit approval. Plan mode remains active; use the host mode selector or /plan exit to leave plan mode." : `Permission request failed for "${toolName}": ${this.#formatError(
6750
6239
  error
6751
6240
  )}`;
6752
6241
  return earlyErrorResponse(
@@ -6755,32 +6244,11 @@ ${this.pendingWorktreeNotice}
6755
6244
  { stopAfterPermissionCancel: true }
6756
6245
  );
6757
6246
  }
6758
- let confirmationPayload = {
6759
- answers: output.answers
6760
- };
6761
- if (planShellDecision.classification !== "not-applicable") {
6762
- const approval = await validatePlanModeShellApproval({
6763
- config: this.config,
6764
- decision: planShellDecision,
6765
- requestArgs: args,
6766
- invocationParams: invocation.params,
6767
- signal: activeToolAbortSignal,
6768
- outcome,
6769
- payload: confirmationPayload
6770
- });
6771
- outcome = approval.outcome;
6772
- confirmationPayload = approval.payload;
6773
- }
6774
- const shouldSwitchToDefault = outcome === "proceed_once_and_switch_to_default" /* ProceedOnceAndSwitchToDefault */;
6775
- if (shouldSwitchToDefault) {
6776
- outcome = "proceed_once" /* ProceedOnce */;
6777
- }
6778
6247
  recordAutoModeFallbackResolution(outcome);
6779
6248
  try {
6780
- await confirmationDetails.onConfirm(
6781
- outcome,
6782
- confirmationPayload
6783
- );
6249
+ await confirmationDetails.onConfirm(outcome, {
6250
+ answers: output.answers
6251
+ });
6784
6252
  } catch (error) {
6785
6253
  if (outcome !== "cancel" /* Cancel */) {
6786
6254
  throw error;
@@ -6791,31 +6259,21 @@ ${this.pendingWorktreeNotice}
6791
6259
  );
6792
6260
  return stopAfterPermissionCancel();
6793
6261
  }
6794
- if (shouldSwitchToDefault) {
6795
- this.config.setApprovalMode("default" /* DEFAULT */);
6796
- await this.sendCurrentModeUpdateNotification();
6797
- }
6798
6262
  if (outcome === "proceed_always" /* ProceedAlways */ || outcome === "proceed_always_project" /* ProceedAlwaysProject */ || outcome === "proceed_always_user" /* ProceedAlwaysUser */) {
6799
6263
  await persistPermissionOutcome(
6800
6264
  outcome,
6801
6265
  confirmationDetails,
6802
6266
  this.config.getOnPersistPermissionRule?.(),
6803
6267
  this.config.getPermissionManager?.(),
6804
- confirmationPayload
6268
+ { answers: output.answers }
6805
6269
  );
6806
6270
  }
6807
6271
  if (confirmationDetails.type === "edit" && outcome === "proceed_always" /* ProceedAlways */) {
6808
6272
  await this.sendCurrentModeUpdateNotification();
6809
6273
  }
6810
6274
  switch (outcome) {
6811
- case "proceed_once_and_switch_to_default" /* ProceedOnceAndSwitchToDefault */:
6812
- throw new Error(
6813
- "Switch-to-Default outcome must be normalized before execution."
6814
- );
6815
6275
  case "cancel" /* Cancel */:
6816
- return stopAfterPermissionCancel(
6817
- confirmationPayload?.cancelMessage
6818
- );
6276
+ return stopAfterPermissionCancel();
6819
6277
  case "proceed_once" /* ProceedOnce */:
6820
6278
  case "proceed_always" /* ProceedAlways */:
6821
6279
  case "proceed_always_project" /* ProceedAlwaysProject */:
@@ -6847,7 +6305,7 @@ ${this.pendingWorktreeNotice}
6847
6305
  if (hooksEnabledForTool && messageBusForTool) {
6848
6306
  const preHookResult = await firePreToolUseHook(
6849
6307
  messageBusForTool,
6850
- policyToolName,
6308
+ toolName,
6851
6309
  args,
6852
6310
  toolUseId,
6853
6311
  permissionMode,
@@ -6964,7 +6422,7 @@ ${this.pendingWorktreeNotice}
6964
6422
  };
6965
6423
  const postHookResult = await firePostToolUseHook(
6966
6424
  messageBusForTool,
6967
- policyToolName,
6425
+ toolName,
6968
6426
  args,
6969
6427
  toolResponse,
6970
6428
  toolUseId,
@@ -6995,7 +6453,7 @@ ${this.pendingWorktreeNotice}
6995
6453
  const failureHookResult = await firePostToolUseFailureHook(
6996
6454
  messageBusForTool,
6997
6455
  toolUseId,
6998
- policyToolName,
6456
+ toolName,
6999
6457
  args,
7000
6458
  toolResult.error?.message ?? "Tool execution was cancelled",
7001
6459
  isInterrupt,
@@ -7049,18 +6507,12 @@ ${this.pendingWorktreeNotice}
7049
6507
  prompt_id: promptId,
7050
6508
  tool_type: typeof tool !== "undefined" && tool instanceof DiscoveredMCPTool ? "mcp" : "native"
7051
6509
  });
7052
- queueToolResultRecord?.(fc, {
6510
+ this.config.getChatRecordingService()?.recordToolResult(responseParts, {
7053
6511
  callId,
7054
- toolName,
7055
- responseParts,
7056
- persistedOutputFiles: toolResult.persistedOutputFiles,
7057
- metadata: {
7058
- callId,
7059
- status,
7060
- resultDisplay: toolResult.returnDisplay,
7061
- error: toolResult.error ? new Error(toolResult.error.message) : void 0,
7062
- errorType: toolResult.error?.type
7063
- }
6512
+ status,
6513
+ resultDisplay: toolResult.returnDisplay,
6514
+ error: toolResult.error ? new Error(toolResult.error.message) : void 0,
6515
+ errorType: toolResult.error?.type
7064
6516
  });
7065
6517
  spanSuccess = succeeded;
7066
6518
  if (toolResult.error) {
@@ -7090,7 +6542,7 @@ ${this.pendingWorktreeNotice}
7090
6542
  const failureHookResult = await firePostToolUseFailureHook(
7091
6543
  messageBusForError,
7092
6544
  toolUseId,
7093
- policyToolName,
6545
+ toolName,
7094
6546
  args,
7095
6547
  error.message,
7096
6548
  isInterrupt,
@@ -7111,6 +6563,24 @@ ${this.pendingWorktreeNotice}
7111
6563
  });
7112
6564
  }
7113
6565
  await this.toolCallEmitter.emitError(callId, toolName, error);
6566
+ const errorParts = [
6567
+ {
6568
+ functionResponse: {
6569
+ id: callId,
6570
+ name: toolName,
6571
+ response: { error: error.message }
6572
+ }
6573
+ }
6574
+ ];
6575
+ this.config.getChatRecordingService()?.recordToolResult(errorParts, {
6576
+ callId,
6577
+ // A throw caused by abort (e.g. AbortError) is a cancellation, not
6578
+ // a genuine tool error — keep it consistent with the success path.
6579
+ status: activeToolAbortSignal.aborted ? "cancelled" : "error",
6580
+ resultDisplay: void 0,
6581
+ error,
6582
+ errorType: void 0
6583
+ });
7114
6584
  const loopDetected = !activeToolAbortSignal.aborted && !toolBuildSucceeded && recordDaemonInvalidToolParams(
7115
6585
  this.config,
7116
6586
  promptId,
@@ -7119,18 +6589,6 @@ ${this.pendingWorktreeNotice}
7119
6589
  error
7120
6590
  );
7121
6591
  const responseParts = errorResponse(error);
7122
- queueToolResultRecord?.(fc, {
7123
- callId,
7124
- toolName,
7125
- responseParts,
7126
- metadata: {
7127
- callId,
7128
- status: activeToolAbortSignal.aborted ? "cancelled" : "error",
7129
- resultDisplay: void 0,
7130
- error,
7131
- errorType: void 0
7132
- }
7133
- });
7134
6592
  return {
7135
6593
  parts: responseParts,
7136
6594
  stopAfterPermissionCancel: nestedPermissionCancelled,
@@ -7767,7 +7225,6 @@ var QWEN_ACP_LOCAL_READ_ROOTS_ENV = "QWEN_ACP_LOCAL_READ_ROOTS";
7767
7225
  var POSIX_TMP_LOCAL_READ_ROOT = "/tmp";
7768
7226
  var BTW_CHILD_TIMEOUT_MS = 55e3;
7769
7227
  var MCP_OAUTH_START_TIMEOUT_MS = 3e4;
7770
- var SESSION_DRAIN_TIMEOUT_MS = 3e4;
7771
7228
  var WORKSPACE_MEMORY_REMEMBER_CHILD_TIMEOUT_MS = 295e3;
7772
7229
  function createAcpSessionStartProfiler(span) {
7773
7230
  let failedStage;
@@ -7826,77 +7283,6 @@ function workspaceMemoryErrorData(code, diagnostics) {
7826
7283
  };
7827
7284
  }
7828
7285
  __name(workspaceMemoryErrorData, "workspaceMemoryErrorData");
7829
- var SESSION_WRITER_MESSAGES = {
7830
- session_writer_conflict: "This session is already open in another Qwen process.",
7831
- session_writer_lost: "Write ownership for this session was lost.",
7832
- session_transcript_changed: "The session transcript changed outside its active writer.",
7833
- session_writer_unavailable: "Session write ownership could not be verified."
7834
- };
7835
- function getSessionWriterError(error) {
7836
- if (!error || typeof error !== "object") return void 0;
7837
- const candidate = error;
7838
- const errorKind = candidate["errorKind"];
7839
- if (typeof errorKind !== "string" || !(errorKind in SESSION_WRITER_RPC_CODES)) {
7840
- return void 0;
7841
- }
7842
- const typedKind = errorKind;
7843
- if (candidate["rpcCode"] !== SESSION_WRITER_RPC_CODES[typedKind]) {
7844
- return void 0;
7845
- }
7846
- return {
7847
- rpcCode: SESSION_WRITER_RPC_CODES[typedKind],
7848
- errorKind: typedKind,
7849
- message: SESSION_WRITER_MESSAGES[typedKind]
7850
- };
7851
- }
7852
- __name(getSessionWriterError, "getSessionWriterError");
7853
- function mapSessionWriterRequestError(error) {
7854
- const writerError = getSessionWriterError(error);
7855
- return writerError ? new RequestError(writerError.rpcCode, writerError.message, {
7856
- errorKind: writerError.errorKind
7857
- }) : error;
7858
- }
7859
- __name(mapSessionWriterRequestError, "mapSessionWriterRequestError");
7860
- async function shutdownSessionConfig(config) {
7861
- await config.shutdown({ shutdownTelemetry: false });
7862
- if (config.hasSessionWriteOwnership()) {
7863
- throw new SessionWriterUnavailableError();
7864
- }
7865
- }
7866
- __name(shutdownSessionConfig, "shutdownSessionConfig");
7867
- async function waitForSessionDrain(operation, timeoutMs, kind) {
7868
- let timer;
7869
- const timeout = new Promise((_, reject) => {
7870
- timer = setTimeout(
7871
- () => reject(new Error(`Session ${kind} timed out after ${timeoutMs}ms`)),
7872
- timeoutMs
7873
- );
7874
- timer.unref();
7875
- });
7876
- try {
7877
- await Promise.race([operation, timeout]);
7878
- } finally {
7879
- if (timer) clearTimeout(timer);
7880
- }
7881
- }
7882
- __name(waitForSessionDrain, "waitForSessionDrain");
7883
- async function beginSessionCloseAfterCurrentGate(session, timeoutMs) {
7884
- const deadline = Date.now() + timeoutMs;
7885
- while (true) {
7886
- const releaseGate = session.beginCloseIfAvailable();
7887
- if (releaseGate) return releaseGate;
7888
- const remainingMs = deadline - Date.now();
7889
- if (remainingMs <= 0) {
7890
- throw new Error(`Session close timed out after ${timeoutMs}ms`);
7891
- }
7892
- await waitForSessionDrain(
7893
- session.waitForCloseGateToRelease(),
7894
- remainingMs,
7895
- "close"
7896
- );
7897
- }
7898
- }
7899
- __name(beginSessionCloseAfterCurrentGate, "beginSessionCloseAfterCurrentGate");
7900
7286
  var logWorkspaceMemoryExtractionError = createWorkspaceMemoryExtractionErrorLogger(debugLogger7);
7901
7287
  function parseAcpLocalReadRootsEnv(raw = process.env[QWEN_ACP_LOCAL_READ_ROOTS_ENV]) {
7902
7288
  if (!raw) return [];
@@ -7914,7 +7300,7 @@ function buildAcpLocalReadRoots(config) {
7914
7300
  // local read fallback, not read_file's default permission.
7915
7301
  config.storage.getProjectTempDir(),
7916
7302
  path4.join(config.storage.getProjectDir(), "subagents"),
7917
- path4.join(config.getSessionRuntimeBaseDir(), "tmp"),
7303
+ Storage.getGlobalTempDir(),
7918
7304
  getAutoMemoryRoot(config.getTargetDir()),
7919
7305
  getUserAutoMemoryRoot(),
7920
7306
  ...config.storage.getUserSkillsDirs(),
@@ -9417,11 +8803,6 @@ async function runAcpAgent(config, settings, argv) {
9417
8803
  } finally {
9418
8804
  endAcpBootstrapConfigProfiling();
9419
8805
  }
9420
- const startupWarnings = typeof config.getWarnings === "function" ? config.getWarnings() : [];
9421
- for (const warning of startupWarnings) {
9422
- process.stderr.write(`${warning}
9423
- `);
9424
- }
9425
8806
  const eventLoopMonitor = startEventLoopLagMonitor({
9426
8807
  onNewMaxStall: /* @__PURE__ */ __name((maxMs) => {
9427
8808
  console.error(`[perf] acp agent event loop stall: max=${maxMs}ms`);
@@ -9492,7 +8873,7 @@ async function runAcpAgent(config, settings, argv) {
9492
8873
  debugLogger7.debug("[ACP] Shutdown signal received, closing streams");
9493
8874
  try {
9494
8875
  await fireSessionEndOnce("other" /* Other */);
9495
- await agentInstance?.disposeSessions();
8876
+ agentInstance?.disposeSessions();
9496
8877
  try {
9497
8878
  process.stdin.destroy();
9498
8879
  } catch {
@@ -9519,7 +8900,7 @@ async function runAcpAgent(config, settings, argv) {
9519
8900
  await connection.closed;
9520
8901
  await fireSessionEndOnce("prompt_input_exit" /* PromptInputExit */);
9521
8902
  await drainPoolBeforeExit("ide_close");
9522
- await agentInstance?.disposeSessions();
8903
+ agentInstance?.disposeSessions();
9523
8904
  } finally {
9524
8905
  process.off("SIGTERM", shutdownHandler);
9525
8906
  process.off("SIGINT", shutdownHandler);
@@ -9678,7 +9059,6 @@ var QwenAgent = class {
9678
9059
  mcpAuthenticationResults = /* @__PURE__ */ new Map();
9679
9060
  generationControllers = /* @__PURE__ */ new Map();
9680
9061
  transcriptReplayConfigCache = /* @__PURE__ */ new Map();
9681
- pendingConfigCleanup = /* @__PURE__ */ new Map();
9682
9062
  clientCapabilities;
9683
9063
  // CPU-usage delta baseline for the daemon's `workspaceResource` extMethod
9684
9064
  // (Daemon Status child-resource chart). The daemon polls this at a fixed
@@ -9781,26 +9161,21 @@ var QwenAgent = class {
9781
9161
  async createWorkspaceMcpDiscoveryConfig(settings) {
9782
9162
  if (this.workspaceMcpDiscoveryConfig) return;
9783
9163
  const cwd = this.config.getTargetDir();
9784
- const config = await this.runWithPinnedRuntimeBaseDir(
9785
- settings,
9164
+ const config = await loadCliConfig(
9165
+ settings.merged,
9166
+ {
9167
+ ...this.argv,
9168
+ sessionId: "workspace-mcp-discovery",
9169
+ resume: void 0,
9170
+ continue: false
9171
+ },
9786
9172
  cwd,
9787
- () => loadCliConfig(
9788
- settings.merged,
9789
- {
9790
- ...this.argv,
9791
- sessionId: "workspace-mcp-discovery",
9792
- resume: void 0,
9793
- continue: false,
9794
- chatRecording: false
9795
- },
9796
- cwd,
9797
- void 0,
9798
- {
9799
- userHooks: settings.getUserHooks(),
9800
- projectHooks: settings.getProjectHooks()
9801
- },
9802
- buildDisabledSkillNamesProvider(settings)
9803
- )
9173
+ void 0,
9174
+ {
9175
+ userHooks: settings.getUserHooks(),
9176
+ projectHooks: settings.getProjectHooks()
9177
+ },
9178
+ buildDisabledSkillNamesProvider(settings)
9804
9179
  );
9805
9180
  config.setMcpTransportPool(this.mcpPool);
9806
9181
  try {
@@ -9908,224 +9283,99 @@ var QwenAgent = class {
9908
9283
  );
9909
9284
  }
9910
9285
  }
9911
- async removeStoredSessionEntry(sessionId, session, cleanupErrors = [], options = {}) {
9912
- if (this.sessions.get(sessionId) !== session) return;
9913
- try {
9914
- session.dispose();
9915
- } catch (error) {
9916
- cleanupErrors.push(error);
9286
+ async closeStoredSession(sessionId, opts) {
9287
+ for (const [requestId, generation] of this.generationControllers) {
9288
+ if (generation.sessionId !== sessionId) continue;
9289
+ generation.controller.abort();
9290
+ this.generationControllers.delete(requestId);
9291
+ }
9292
+ const session = this.sessions.get(sessionId);
9293
+ if (!session) {
9294
+ this.mcpPool?.releaseSession(sessionId);
9295
+ return;
9917
9296
  }
9918
- if (options.shutdownConfig !== false) {
9297
+ const requireFlush = opts?.requireFlush === true;
9298
+ const flushRecording = /* @__PURE__ */ __name(async () => {
9919
9299
  try {
9920
- await session.getConfig().shutdown({ shutdownTelemetry: false });
9921
- } catch (error) {
9922
- cleanupErrors.push(error);
9300
+ await session.getConfig().getChatRecordingService()?.flush();
9301
+ return void 0;
9302
+ } catch (err) {
9303
+ debugLogger7.debug(
9304
+ `Session ${sessionId} chat recording flush during close failed: ${err instanceof Error ? err.message : String(err)}`
9305
+ );
9306
+ return err;
9307
+ }
9308
+ }, "flushRecording");
9309
+ if (requireFlush) {
9310
+ const preCancelFlushError = await flushRecording();
9311
+ if (preCancelFlushError !== void 0) {
9312
+ throw preCancelFlushError;
9923
9313
  }
9924
9314
  }
9925
9315
  try {
9926
- unregisterGoalHook(session.getConfig(), sessionId);
9927
- } catch (error) {
9928
- cleanupErrors.push(error);
9316
+ await session.cancelPendingPrompt();
9317
+ } catch (err) {
9318
+ debugLogger7.debug(
9319
+ `Session ${sessionId} cancel during close failed: ${err instanceof Error ? err.message : String(err)}`
9320
+ );
9929
9321
  }
9930
- try {
9931
- this.mcpPool?.releaseSession(sessionId);
9932
- } catch (error) {
9933
- cleanupErrors.push(error);
9322
+ const flushError = await flushRecording();
9323
+ if (flushError !== void 0 && requireFlush) {
9324
+ throw flushError;
9934
9325
  }
9935
9326
  try {
9936
- uiTelemetryService.removeSession(sessionId);
9937
- } catch (error) {
9938
- cleanupErrors.push(error);
9939
- }
9940
- this.sessions.delete(sessionId);
9941
- if (cleanupErrors.length > 0) {
9942
- debugLogger7.warn(
9943
- `Session ${sessionId} closed after ${cleanupErrors.length} cleanup failure(s): ${cleanupErrors.map(
9944
- (error) => error instanceof Error ? error.message : String(error)
9945
- ).join("; ")}`
9327
+ await session.getConfig().getToolRegistry()?.stop();
9328
+ } catch (err) {
9329
+ debugLogger7.debug(
9330
+ `Session ${sessionId} tool registry stop during close failed: ${err instanceof Error ? err.message : String(err)}`
9946
9331
  );
9947
9332
  }
9333
+ unregisterGoalHook(session.getConfig(), sessionId);
9334
+ this.mcpPool?.releaseSession(sessionId);
9335
+ uiTelemetryService.removeSession(sessionId);
9336
+ this.sessions.delete(sessionId);
9948
9337
  }
9949
- async withLiveSessionRestore(sessionId, session, operation) {
9950
- await session.assertCanStartTurn();
9951
- const config = session.getConfig();
9952
- const releaseGate = session.beginClose();
9953
- try {
9954
- await waitForSessionDrain(
9955
- session.waitForActiveTurnsToSettle(),
9956
- SESSION_DRAIN_TIMEOUT_MS,
9957
- "restore"
9958
- );
9959
- const recorder = config.getChatRecordingService();
9960
- const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
9961
- const data = recorder ? await recorder.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
9962
- if (!data) throw new SessionWriterUnavailableError();
9963
- return await operation(config, data);
9964
- } catch (error) {
9965
- throw mapSessionWriterRequestError(error);
9966
- } finally {
9967
- releaseGate();
9338
+ discardStoredSessionIfCurrent(sessionId, session) {
9339
+ if (this.sessions.get(sessionId) !== session) {
9340
+ return;
9968
9341
  }
9969
- }
9970
- async cleanupUnstoredConfig(config) {
9971
- const sessionId = config.getSessionId();
9972
- const cleanupKey = this.pendingConfigCleanupKey(
9973
- config.getSessionRuntimeBaseDir(),
9974
- sessionId
9975
- );
9342
+ const logCleanupFailure = /* @__PURE__ */ __name((action, err) => {
9343
+ debugLogger7.debug(
9344
+ `Session ${sessionId} ${action} during failed restore cleanup failed: ${err instanceof Error ? err.message : String(err)}`
9345
+ );
9346
+ }, "logCleanupFailure");
9976
9347
  try {
9977
- await shutdownSessionConfig(config);
9978
- } catch (error) {
9979
- const pending2 = this.pendingConfigCleanup.get(cleanupKey) ?? /* @__PURE__ */ new Set();
9980
- pending2.add(config);
9981
- this.pendingConfigCleanup.set(cleanupKey, pending2);
9982
- throw mapSessionWriterRequestError(error);
9983
- }
9984
- const pending = this.pendingConfigCleanup.get(cleanupKey);
9985
- pending?.delete(config);
9986
- if (pending?.size === 0) {
9987
- this.pendingConfigCleanup.delete(cleanupKey);
9348
+ session.dispose();
9349
+ } catch (err) {
9350
+ logCleanupFailure("dispose", err);
9988
9351
  }
9989
- }
9990
- async cleanupAfterRequestFailure(error, cleanup) {
9991
9352
  try {
9992
- await cleanup();
9993
- } catch (cleanupError) {
9994
- debugLogger7.warn(
9995
- `Session cleanup failed while preserving the original request error: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`
9996
- );
9997
- }
9998
- throw error;
9999
- }
10000
- pendingConfigCleanupKey(runtimeBaseDir, sessionId) {
10001
- return `${path4.resolve(runtimeBaseDir)}\0${sessionId}`;
10002
- }
10003
- async retryPendingConfigCleanup(runtimeBaseDir, requiredSessionId) {
10004
- const resolvedRuntimeBaseDir = path4.resolve(runtimeBaseDir);
10005
- const configs = /* @__PURE__ */ new Set();
10006
- for (const pending of this.pendingConfigCleanup.values()) {
10007
- for (const config of pending) {
10008
- if (path4.resolve(config.getSessionRuntimeBaseDir()) === resolvedRuntimeBaseDir) {
10009
- configs.add(config);
10010
- }
10011
- }
10012
- }
10013
- for (const config of configs) {
10014
- try {
10015
- await this.cleanupUnstoredConfig(config);
10016
- } catch (error) {
10017
- if (config.getSessionId() === requiredSessionId) throw error;
10018
- debugLogger7.warn(
10019
- `Deferred Config cleanup retry failed for session ${config.getSessionId()}: ${error instanceof Error ? error.message : String(error)}`
10020
- );
10021
- }
9353
+ unregisterGoalHook(session.getConfig(), sessionId);
9354
+ } catch (err) {
9355
+ logCleanupFailure("goal hook unregister", err);
10022
9356
  }
10023
- }
10024
- async closeStoredSession(sessionId, opts) {
10025
- const session = this.sessions.get(sessionId);
10026
- if (!session) {
9357
+ try {
10027
9358
  this.mcpPool?.releaseSession(sessionId);
10028
- return;
10029
- }
10030
- const recorder = session.getConfig().getChatRecordingService();
10031
- const requireFlush = opts?.requireFlush === true;
10032
- if (requireFlush) {
10033
- await recorder?.flush();
10034
- }
10035
- const drainTimeoutMs = opts?.drainTimeoutMs ?? SESSION_DRAIN_TIMEOUT_MS;
10036
- const cancelClose = opts?.waitForCloseGate ? await beginSessionCloseAfterCurrentGate(session, drainTimeoutMs) : session.beginClose();
10037
- for (const [requestId, generation] of this.generationControllers) {
10038
- if (generation.sessionId !== sessionId) continue;
10039
- generation.controller.abort();
10040
- this.generationControllers.delete(requestId);
9359
+ } catch (err) {
9360
+ logCleanupFailure("MCP pool release", err);
10041
9361
  }
10042
- let removedFromStore = false;
10043
9362
  try {
10044
- await waitForSessionDrain(
10045
- (async () => {
10046
- try {
10047
- await session.cancelPendingPrompt();
10048
- } catch (err) {
10049
- debugLogger7.debug(
10050
- `Session ${sessionId} cancel during close failed: ${err instanceof Error ? err.message : String(err)}`
10051
- );
10052
- }
10053
- await session.waitForActiveTurnsToSettle();
10054
- })(),
10055
- drainTimeoutMs,
10056
- "close"
10057
- );
10058
- recorder?.finalize();
10059
- let flushError;
10060
- try {
10061
- await recorder?.flush();
10062
- } catch (error) {
10063
- flushError = error;
10064
- }
10065
- if (flushError !== void 0 && requireFlush) {
10066
- throw flushError;
10067
- }
10068
- let closeError;
10069
- try {
10070
- await recorder?.close();
10071
- } catch (error) {
10072
- closeError = error;
10073
- }
10074
- if (recorder?.hasWriteOwnership()) {
10075
- throw closeError ?? new SessionWriterUnavailableError();
10076
- }
10077
- const cleanupErrors = [];
10078
- if (flushError !== void 0) cleanupErrors.push(flushError);
10079
- if (closeError !== void 0) cleanupErrors.push(closeError);
10080
- await this.removeStoredSessionEntry(sessionId, session, cleanupErrors, {
10081
- shutdownConfig: opts?.shutdownConfig
10082
- });
10083
- removedFromStore = true;
10084
- } finally {
10085
- if (!removedFromStore) cancelClose();
10086
- }
10087
- }
10088
- async discardStoredSessionIfCurrent(sessionId, session, opts) {
10089
- if (this.sessions.get(sessionId) !== session) {
10090
- return;
9363
+ uiTelemetryService.removeSession(sessionId);
9364
+ } catch (err) {
9365
+ logCleanupFailure("telemetry removal", err);
10091
9366
  }
10092
- await this.closeStoredSession(sessionId, opts);
9367
+ this.sessions.delete(sessionId);
10093
9368
  }
10094
- async disposeSessions() {
9369
+ disposeSessions() {
10095
9370
  for (const generation of this.generationControllers.values()) {
10096
9371
  generation.controller.abort();
10097
9372
  }
10098
9373
  this.generationControllers.clear();
10099
- await Promise.allSettled(
10100
- [...this.sessions.entries()].map(
10101
- ([sessionId, session]) => this.discardStoredSessionIfCurrent(sessionId, session, {
10102
- waitForCloseGate: true
10103
- })
10104
- )
10105
- );
10106
- await Promise.allSettled(
10107
- [...this.pendingConfigCleanup.values()].flatMap((configs) => [...configs]).map((config) => this.cleanupUnstoredConfig(config))
10108
- );
10109
- this.disposeTranscriptReplayConfigs();
10110
- }
10111
- runWithPinnedRuntimeBaseDir(settings, cwd, operation) {
10112
- return runWithAcpRuntimeOutputDir(settings, cwd, operation);
10113
- }
10114
- async assertLiveSessionScope(config, settings, cwd) {
10115
- if (path4.resolve(config.storage.getProjectRoot()) !== path4.resolve(cwd)) {
10116
- throw RequestError.invalidParams(
10117
- void 0,
10118
- "The live session belongs to another workspace."
10119
- );
10120
- }
10121
- const requestedRuntimeBaseDir = await this.runWithPinnedRuntimeBaseDir(
10122
- settings,
10123
- cwd,
10124
- () => Storage.getRuntimeBaseDir()
10125
- );
10126
- if (path4.resolve(config.getSessionRuntimeBaseDir()) !== path4.resolve(requestedRuntimeBaseDir)) {
10127
- throw mapSessionWriterRequestError(new SessionWriterUnavailableError());
9374
+ for (const session of this.sessions.values()) {
9375
+ session.dispose();
10128
9376
  }
9377
+ this.sessions.clear();
9378
+ this.disposeTranscriptReplayConfigs();
10129
9379
  }
10130
9380
  /** Expose the pool's workspace-scoped budget controller for snapshot builders. */
10131
9381
  getWorkspaceMcpBudget() {
@@ -10156,7 +9406,7 @@ var QwenAgent = class {
10156
9406
  markAcpStartup("initializeHandlerStart");
10157
9407
  this.clientCapabilities = args.clientCapabilities;
10158
9408
  const authMethods = buildAuthMethods();
10159
- const version = "0.20.0-nightly.20260722.b98306b7e";
9409
+ const version = "0.20.0";
10160
9410
  const response = {
10161
9411
  protocolVersion: PROTOCOL_VERSION,
10162
9412
  agentInfo: {
@@ -10245,24 +9495,15 @@ var QwenAgent = class {
10245
9495
  "config_setup",
10246
9496
  () => this.newSessionConfig(cwd, mcpServers, settings)
10247
9497
  );
10248
- let session;
10249
- try {
10250
- await profiler.time("auth", () => this.ensureAuthenticated(config));
10251
- profiler.timeSync(
10252
- "file_system_setup",
10253
- () => this.setupFileSystem(config)
10254
- );
10255
- session = await profiler.time(
10256
- "session_register",
10257
- () => this.createAndStoreSession(config, settings)
10258
- );
10259
- } catch (error) {
10260
- return this.cleanupAfterRequestFailure(error, async () => {
10261
- if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
10262
- await this.cleanupUnstoredConfig(config);
10263
- }
10264
- });
10265
- }
9498
+ await profiler.time("auth", () => this.ensureAuthenticated(config));
9499
+ profiler.timeSync(
9500
+ "file_system_setup",
9501
+ () => this.setupFileSystem(config)
9502
+ );
9503
+ const session = await profiler.time(
9504
+ "session_register",
9505
+ () => this.createAndStoreSession(config, settings)
9506
+ );
10266
9507
  profiler.setSessionId(session.getId());
10267
9508
  return profiler.timeSync("response_build", () => ({
10268
9509
  sessionId: session.getId(),
@@ -10276,56 +9517,7 @@ var QwenAgent = class {
10276
9517
  }
10277
9518
  async loadSession(params) {
10278
9519
  const settings = loadSettingsCached(params.cwd);
10279
- const liveSession = this.sessions.get(params.sessionId);
10280
- if (liveSession) {
10281
- const liveConfig = liveSession.getConfig();
10282
- await this.assertLiveSessionScope(liveConfig, settings, params.cwd);
10283
- return this.withLiveSessionRestore(
10284
- params.sessionId,
10285
- liveSession,
10286
- async (config2, sessionData2) => {
10287
- const response2 = {
10288
- modes: this.buildModesData(config2),
10289
- models: this.buildAvailableModels(config2),
10290
- configOptions: this.buildConfigOptions(config2),
10291
- ...sessionData2.artifactSnapshot ? { artifactSnapshot: sessionData2.artifactSnapshot } : {}
10292
- };
10293
- const records = sessionData2.conversation.messages;
10294
- if (records.length === 0) return response2;
10295
- const bulkReplay2 = isBulkLoadReplayRequest(params);
10296
- const replayPage = bulkReplay2 ? selectRecentHistoryRecords(records, getLoadReplayPageSize(params)) : { records, hasMore: false };
10297
- const replay = await collectHistoryReplayUpdates({
10298
- sessionId: params.sessionId,
10299
- config: config2,
10300
- records: replayPage.records,
10301
- gaps: sessionData2.historyGaps,
10302
- cumulativeUsage: createReplayCumulativeUsage(),
10303
- logger: debugLogger7
10304
- });
10305
- if (!bulkReplay2) {
10306
- for (const update of replay.updates) {
10307
- await liveSession.sendUpdate(update);
10308
- }
10309
- if (replay.replayError !== void 0) {
10310
- throw RequestError.internalError(void 0, replay.replayError);
10311
- }
10312
- return response2;
10313
- }
10314
- return {
10315
- ...response2,
10316
- _meta: {
10317
- [LOAD_REPLAY_META_KEY]: {
10318
- v: LOAD_REPLAY_VERSION,
10319
- updates: replay.updates,
10320
- ...replay.replayError !== void 0 ? { partial: true, replayError: replay.replayError } : {},
10321
- ...replayPage.hasMore ? { hasMore: true } : {}
10322
- }
10323
- }
10324
- };
10325
- }
10326
- );
10327
- }
10328
- const exists = await this.runWithPinnedRuntimeBaseDir(
9520
+ const exists = await runWithAcpRuntimeOutputDir(
10329
9521
  settings,
10330
9522
  params.cwd,
10331
9523
  async () => {
@@ -10348,26 +9540,17 @@ var QwenAgent = class {
10348
9540
  params.sessionId,
10349
9541
  true
10350
9542
  );
9543
+ await this.ensureAuthenticated(config);
9544
+ this.setupFileSystem(config);
10351
9545
  const sessionData = config.getResumedSessionData();
10352
9546
  const bulkReplay = isBulkLoadReplayRequest(params);
10353
9547
  const replayPageSize = bulkReplay ? getLoadReplayPageSize(params) : void 0;
10354
- let session;
10355
- try {
10356
- await this.ensureAuthenticated(config);
10357
- this.setupFileSystem(config);
10358
- session = await this.createAndStoreSession(
10359
- config,
10360
- settings,
10361
- sessionData,
10362
- bulkReplay ? { replayHistory: false, startPostReplayServices: false } : {}
10363
- );
10364
- } catch (error) {
10365
- return this.cleanupAfterRequestFailure(error, async () => {
10366
- if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
10367
- await this.cleanupUnstoredConfig(config);
10368
- }
10369
- });
10370
- }
9548
+ const session = await this.createAndStoreSession(
9549
+ config,
9550
+ settings,
9551
+ sessionData,
9552
+ bulkReplay ? { replayHistory: false, startPostReplayServices: false } : {}
9553
+ );
10371
9554
  let replayEnvelope;
10372
9555
  if (bulkReplay) {
10373
9556
  try {
@@ -10414,21 +9597,8 @@ var QwenAgent = class {
10414
9597
  session.installRewriter();
10415
9598
  session.startCronScheduler();
10416
9599
  } catch (err) {
10417
- return this.cleanupAfterRequestFailure(err, async () => {
10418
- try {
10419
- await this.discardStoredSessionIfCurrent(params.sessionId, session);
10420
- } catch (cleanupError) {
10421
- await this.removeStoredSessionEntry(
10422
- params.sessionId,
10423
- session,
10424
- [cleanupError],
10425
- {
10426
- shutdownConfig: false
10427
- }
10428
- );
10429
- await this.cleanupUnstoredConfig(config);
10430
- }
10431
- });
9600
+ this.discardStoredSessionIfCurrent(params.sessionId, session);
9601
+ throw err;
10432
9602
  }
10433
9603
  }
10434
9604
  await this.#restoreWorktreeOnResume(config, session);
@@ -10454,22 +9624,7 @@ var QwenAgent = class {
10454
9624
  }
10455
9625
  async unstable_resumeSession(params) {
10456
9626
  const settings = loadSettingsCached(params.cwd);
10457
- const liveSession = this.sessions.get(params.sessionId);
10458
- if (liveSession) {
10459
- const liveConfig = liveSession.getConfig();
10460
- await this.assertLiveSessionScope(liveConfig, settings, params.cwd);
10461
- return this.withLiveSessionRestore(
10462
- params.sessionId,
10463
- liveSession,
10464
- async (config2, sessionData2) => ({
10465
- modes: this.buildModesData(config2),
10466
- models: this.buildAvailableModels(config2),
10467
- configOptions: this.buildConfigOptions(config2),
10468
- ...sessionData2.artifactSnapshot ? { artifactSnapshot: sessionData2.artifactSnapshot } : {}
10469
- })
10470
- );
10471
- }
10472
- const exists = await this.runWithPinnedRuntimeBaseDir(
9627
+ const exists = await runWithAcpRuntimeOutputDir(
10473
9628
  settings,
10474
9629
  params.cwd,
10475
9630
  async () => {
@@ -10488,23 +9643,14 @@ var QwenAgent = class {
10488
9643
  params.sessionId,
10489
9644
  true
10490
9645
  );
10491
- let session;
10492
- try {
10493
- await this.ensureAuthenticated(config);
10494
- this.setupFileSystem(config);
10495
- session = await this.createAndStoreSession(
10496
- config,
10497
- settings,
10498
- config.getResumedSessionData(),
10499
- { replayHistory: false }
10500
- );
10501
- } catch (error) {
10502
- return this.cleanupAfterRequestFailure(error, async () => {
10503
- if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
10504
- await this.cleanupUnstoredConfig(config);
10505
- }
10506
- });
10507
- }
9646
+ await this.ensureAuthenticated(config);
9647
+ this.setupFileSystem(config);
9648
+ const session = await this.createAndStoreSession(
9649
+ config,
9650
+ settings,
9651
+ config.getResumedSessionData(),
9652
+ { replayHistory: false }
9653
+ );
10508
9654
  await this.#restoreWorktreeOnResume(config, session);
10509
9655
  this.#restoreGoalOnResume(config, session);
10510
9656
  const modesData = this.buildModesData(config);
@@ -12418,19 +11564,6 @@ var QwenAgent = class {
12418
11564
  };
12419
11565
  }
12420
11566
  async extMethod(method, params) {
12421
- try {
12422
- return await this.extMethodInternal(method, params);
12423
- } catch (error) {
12424
- const writerError = getSessionWriterError(error);
12425
- if (writerError) {
12426
- throw new RequestError(writerError.rpcCode, writerError.message, {
12427
- errorKind: writerError.errorKind
12428
- });
12429
- }
12430
- throw error;
12431
- }
12432
- }
12433
- async extMethodInternal(method, params) {
12434
11567
  const requestedCwd = typeof params["cwd"] === "string" ? params["cwd"] : void 0;
12435
11568
  const cwd = requestedCwd || process.cwd();
12436
11569
  const SESSION_ID_RE = /^[0-9a-fA-F-]{32,36}$/;
@@ -13571,34 +12704,6 @@ var QwenAgent = class {
13571
12704
  }
13572
12705
  return { sessionId, persisted: true, kind };
13573
12706
  }
13574
- case "qwen/session/recordTextElements": {
13575
- const sessionId = params["sessionId"];
13576
- const content = params["content"];
13577
- const textElements = params["textElements"];
13578
- if (typeof sessionId !== "string" || sessionId.length === 0) {
13579
- throw RequestError.invalidParams(
13580
- void 0,
13581
- "Invalid or missing sessionId"
13582
- );
13583
- }
13584
- if (typeof content !== "string" || !Array.isArray(textElements)) {
13585
- throw RequestError.invalidParams(
13586
- void 0,
13587
- "Invalid user text elements payload"
13588
- );
13589
- }
13590
- const session = this.sessionOrThrow(sessionId);
13591
- await session.assertCanStartTurn();
13592
- const recording = session.getConfig().getChatRecordingService();
13593
- if (!recording) {
13594
- throw RequestError.internalError(
13595
- void 0,
13596
- "Chat recording service unavailable"
13597
- );
13598
- }
13599
- await recording.recordUserTextElements({ content, textElements });
13600
- return { sessionId, persisted: true };
13601
- }
13602
12707
  case SERVE_CONTROL_EXT_METHODS.sessionTitle: {
13603
12708
  const sessionId = params["sessionId"];
13604
12709
  const displayName = params["displayName"];
@@ -13694,16 +12799,8 @@ var QwenAgent = class {
13694
12799
  "Invalid or missing sessionId"
13695
12800
  );
13696
12801
  }
13697
- const rawDrainTimeoutMs = params["drainTimeoutMs"];
13698
- if (rawDrainTimeoutMs !== void 0 && (typeof rawDrainTimeoutMs !== "number" || !Number.isSafeInteger(rawDrainTimeoutMs) || rawDrainTimeoutMs < 1 || rawDrainTimeoutMs > 2147483647)) {
13699
- throw RequestError.invalidParams(
13700
- void 0,
13701
- "Invalid session close drain timeout"
13702
- );
13703
- }
13704
12802
  await this.closeStoredSession(sessionId, {
13705
- requireFlush: params["requireFlush"] === true,
13706
- ...typeof rawDrainTimeoutMs === "number" ? { drainTimeoutMs: rawDrainTimeoutMs } : {}
12803
+ requireFlush: params["requireFlush"] === true
13707
12804
  });
13708
12805
  return { sessionId, closed: true };
13709
12806
  }
@@ -13745,21 +12842,6 @@ var QwenAgent = class {
13745
12842
  });
13746
12843
  }
13747
12844
  const canonicalPath = await fs2.realpath(targetPath);
13748
- const allowedRoots = params["allowedRoots"];
13749
- if (Array.isArray(allowedRoots) && allowedRoots.length > 0) {
13750
- const contained = allowedRoots.some((root) => {
13751
- if (typeof root !== "string") return false;
13752
- const rel = path4.relative(root, canonicalPath);
13753
- return !rel.startsWith("..") && !path4.isAbsolute(rel);
13754
- });
13755
- if (!contained) {
13756
- throw new RequestError(
13757
- -32004,
13758
- `Path outside allowed roots: ${canonicalPath}`,
13759
- { errorKind: "containment_violation", path: canonicalPath }
13760
- );
13761
- }
13762
- }
13763
12845
  const previousCwd = config.getTargetDir();
13764
12846
  if (canonicalPath === previousCwd) {
13765
12847
  return { previousCwd, newCwd: canonicalPath, warnings: [] };
@@ -14641,11 +13723,16 @@ ${outputText}
14641
13723
  let artifactSnapshot;
14642
13724
  let artifactSnapshotUnavailable;
14643
13725
  try {
14644
- const config = session.getConfig();
14645
- const recording = config.getChatRecordingService();
14646
- await recording?.flush();
14647
- const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
14648
- const sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
13726
+ await session.getConfig().getChatRecordingService()?.flush();
13727
+ const cwd2 = session.getConfig().getProjectRoot();
13728
+ const sessionData = await runWithAcpRuntimeOutputDir(
13729
+ this.settings,
13730
+ cwd2,
13731
+ async () => {
13732
+ const sessionService = new SessionService(cwd2);
13733
+ return sessionService.loadSession(sessionId);
13734
+ }
13735
+ );
14649
13736
  if (sessionData === void 0) {
14650
13737
  artifactSnapshotUnavailable = "session data unavailable after rewind";
14651
13738
  } else if (sessionData.artifactSnapshot) {
@@ -14686,37 +13773,20 @@ ${outputText}
14686
13773
  "Invalid or missing sessionId"
14687
13774
  );
14688
13775
  }
14689
- const liveSession = this.sessions.get(sessionId);
14690
- let replayConfig = this.config;
14691
- let sessionData;
14692
- if (liveSession) {
14693
- const config = liveSession.getConfig();
14694
- await this.assertLiveSessionScope(
14695
- config,
14696
- loadSettingsCached(cwd),
14697
- cwd
14698
- );
14699
- const recording = config.getChatRecordingService();
14700
- const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
14701
- sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
14702
- replayConfig = config;
14703
- } else {
14704
- const settings = loadSettingsCached(cwd);
14705
- sessionData = await this.runWithPinnedRuntimeBaseDir(
14706
- settings,
14707
- cwd,
14708
- async () => {
14709
- const sessionService = new SessionService(cwd);
14710
- return sessionService.loadSession(sessionId);
14711
- }
14712
- );
14713
- }
13776
+ const sessionData = await runWithAcpRuntimeOutputDir(
13777
+ this.settings,
13778
+ cwd,
13779
+ async () => {
13780
+ const sessionService = new SessionService(cwd);
13781
+ return sessionService.loadSession(sessionId);
13782
+ }
13783
+ );
14714
13784
  if (!sessionData?.conversation) {
14715
13785
  return { updates: [] };
14716
13786
  }
14717
13787
  const replay = await collectHistoryReplayUpdates({
14718
13788
  sessionId,
14719
- config: replayConfig,
13789
+ config: this.config,
14720
13790
  records: sessionData.conversation.messages,
14721
13791
  gaps: sessionData.historyGaps,
14722
13792
  cumulativeUsage: createReplayCumulativeUsage(),
@@ -14784,51 +13854,56 @@ ${outputText}
14784
13854
  sessionId
14785
13855
  });
14786
13856
  }
14787
- const sourceConfig = sourceSession.getConfig();
14788
- const recording = sourceConfig.getChatRecordingService();
13857
+ const recording = sourceSession.getConfig().getChatRecordingService();
14789
13858
  if (recording) {
14790
13859
  await recording.flush();
14791
13860
  }
14792
- const newSessionId = randomUUID2();
14793
- const sessionService = sourceConfig.getSessionService();
14794
- await sessionService.forkSession(sessionId, newSessionId);
14795
- let title;
14796
- try {
14797
- let baseName;
14798
- if (typeof name === "string" && name.trim().length > 0) {
14799
- baseName = name.trim();
14800
- } else {
14801
- const existingTitle = recording?.getCurrentCustomTitle();
14802
- const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
14803
- if (stripped && stripped.length > 0) {
14804
- baseName = stripped;
14805
- } else {
14806
- baseName = sessionId.slice(0, 8);
13861
+ const newSessionId = randomUUID();
13862
+ return await runWithAcpRuntimeOutputDir(
13863
+ this.settings,
13864
+ cwd,
13865
+ async () => {
13866
+ const sessionService = new SessionService(cwd);
13867
+ await sessionService.forkSession(sessionId, newSessionId);
13868
+ let title;
13869
+ try {
13870
+ let baseName;
13871
+ if (typeof name === "string" && name.trim().length > 0) {
13872
+ baseName = name.trim();
13873
+ } else {
13874
+ const existingTitle = recording?.getCurrentCustomTitle();
13875
+ const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
13876
+ if (stripped && stripped.length > 0) {
13877
+ baseName = stripped;
13878
+ } else {
13879
+ baseName = sessionId.slice(0, 8);
13880
+ }
13881
+ }
13882
+ title = await computeUniqueBranchTitle(baseName, sessionService);
13883
+ const renamed = await sessionService.renameSession(
13884
+ newSessionId,
13885
+ title,
13886
+ "manual"
13887
+ );
13888
+ if (!renamed) {
13889
+ throw new RequestError(
13890
+ -32603,
13891
+ `Failed to set title on forked session ${newSessionId}`,
13892
+ { errorKind: "internal", sessionId: newSessionId }
13893
+ );
13894
+ }
13895
+ } catch (err) {
13896
+ sessionService.removeSession(newSessionId).catch((rmErr) => {
13897
+ process.stderr.write(
13898
+ `qwen serve: failed to clean up orphan session ${newSessionId}: ${rmErr instanceof Error ? rmErr.message : rmErr}
13899
+ `
13900
+ );
13901
+ });
13902
+ throw err;
14807
13903
  }
13904
+ return { newSessionId, title, displayName: title };
14808
13905
  }
14809
- title = await computeUniqueBranchTitle(baseName, sessionService);
14810
- const renamed = await sessionService.renameSession(
14811
- newSessionId,
14812
- title,
14813
- "manual"
14814
- );
14815
- if (!renamed) {
14816
- throw new RequestError(
14817
- -32603,
14818
- `Failed to set title on forked session ${newSessionId}`,
14819
- { errorKind: "internal", sessionId: newSessionId }
14820
- );
14821
- }
14822
- } catch (err) {
14823
- sessionService.removeSession(newSessionId).catch((rmErr) => {
14824
- process.stderr.write(
14825
- `qwen serve: failed to clean up orphan session ${newSessionId}: ${rmErr instanceof Error ? rmErr.message : rmErr}
14826
- `
14827
- );
14828
- });
14829
- throw err;
14830
- }
14831
- return { newSessionId, title, displayName: title };
13906
+ );
14832
13907
  }
14833
13908
  case "qwen/settings/getCore": {
14834
13909
  const settings = loadSettings(cwd);
@@ -15217,25 +14292,17 @@ ${outputText}
15217
14292
  this.disposeTranscriptReplayConfig(cached.config);
15218
14293
  }
15219
14294
  const entry = { settings };
15220
- const pending = this.newSessionConfig(
15221
- cwd,
15222
- [],
15223
- settings,
15224
- void 0,
15225
- false,
15226
- {
15227
- skipMcpDiscovery: true,
15228
- skipHooks: true,
15229
- skipSkillManager: true,
15230
- skipFileCheckpointing: true,
15231
- // Read-only replay: tolerate tools that cannot construct without the
15232
- // subsystems skipped above (e.g. SkillTool needs the SkillManager). The
15233
- // registry is only consulted for optional tool_call metadata during
15234
- // replay, and ToolCallEmitter falls back to the recorded tool name.
15235
- lenientToolWarmup: true
15236
- },
15237
- false
15238
- );
14295
+ const pending = this.newSessionConfig(cwd, [], settings, void 0, false, {
14296
+ skipMcpDiscovery: true,
14297
+ skipHooks: true,
14298
+ skipSkillManager: true,
14299
+ skipFileCheckpointing: true,
14300
+ // Read-only replay: tolerate tools that cannot construct without the
14301
+ // subsystems skipped above (e.g. SkillTool needs the SkillManager). The
14302
+ // registry is only consulted for optional tool_call metadata during
14303
+ // replay, and ToolCallEmitter falls back to the recorded tool name.
14304
+ lenientToolWarmup: true
14305
+ });
15239
14306
  entry.pending = pending;
15240
14307
  this.transcriptReplayConfigCache.set(key, entry);
15241
14308
  try {
@@ -15263,34 +14330,7 @@ ${outputText}
15263
14330
  throw error;
15264
14331
  }
15265
14332
  }
15266
- async newSessionConfig(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
15267
- try {
15268
- return await this.runWithPinnedRuntimeBaseDir(settings, cwd, async () => {
15269
- await this.retryPendingConfigCleanup(
15270
- Storage.getRuntimeBaseDir(),
15271
- sessionId
15272
- );
15273
- return this.newSessionConfigInRuntimeContext(
15274
- cwd,
15275
- mcpServers,
15276
- settings,
15277
- sessionId,
15278
- resume,
15279
- initializeOptions,
15280
- chatRecording
15281
- );
15282
- });
15283
- } catch (error) {
15284
- const writerError = getSessionWriterError(error);
15285
- if (writerError) {
15286
- throw new RequestError(writerError.rpcCode, writerError.message, {
15287
- errorKind: writerError.errorKind
15288
- });
15289
- }
15290
- throw error;
15291
- }
15292
- }
15293
- async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
14333
+ async newSessionConfig(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}) {
15294
14334
  const sessionMcpServers = {};
15295
14335
  for (const server of mcpServers) {
15296
14336
  const stdioServer = toStdioServer(server);
@@ -15346,14 +14386,8 @@ ${outputText}
15346
14386
  const sessionArg = resume === true ? { resume: sessionId, sessionId: void 0 } : { sessionId, resume: void 0 };
15347
14387
  const argvForSession = {
15348
14388
  ...this.argv,
15349
- // Docker sandbox relaunch injects a fixed --sandbox-session-id into
15350
- // the ACP process argv. Without clearing it, every newSession()
15351
- // inherits the same ID and the second session collides with the
15352
- // first's writer lease (#7435).
15353
- sandboxSessionId: void 0,
15354
14389
  ...sessionArg,
15355
- continue: false,
15356
- ...chatRecording !== void 0 ? { chatRecording } : {}
14390
+ continue: false
15357
14391
  };
15358
14392
  const config = await loadCliConfig(
15359
14393
  mergedSettings,
@@ -15407,22 +14441,15 @@ ${outputText}
15407
14441
  });
15408
14442
  });
15409
14443
  }
15410
- try {
15411
- await config.initialize({
15412
- ...initializeOptions,
15413
- // Reverse tool channel (issue #5626, Phase 2): bind the session
15414
- // manager's SDK MCP callback to the `client_mcp/message` ext-method so a
15415
- // client-hosted (extension) MCP server added at runtime reaches the
15416
- // daemon WS. Servers that aren't client-hosted never use this callback
15417
- // (the daemon only adds SDK-type runtime servers for client MCP).
15418
- sendSdkMcpMessage: this.buildClientMcpSender(wiredSessionId)
15419
- });
15420
- } catch (error) {
15421
- return this.cleanupAfterRequestFailure(
15422
- error,
15423
- () => this.cleanupUnstoredConfig(config)
15424
- );
15425
- }
14444
+ await config.initialize({
14445
+ ...initializeOptions,
14446
+ // Reverse tool channel (issue #5626, Phase 2): bind the session
14447
+ // manager's SDK MCP callback to the `client_mcp/message` ext-method so a
14448
+ // client-hosted (extension) MCP server added at runtime reaches the
14449
+ // daemon WS. Servers that aren't client-hosted never use this callback
14450
+ // (the daemon only adds SDK-type runtime servers for client MCP).
14451
+ sendSdkMcpMessage: this.buildClientMcpSender(wiredSessionId)
14452
+ });
15426
14453
  void this.surfaceMcpFailuresWhenReady(config);
15427
14454
  return config;
15428
14455
  }
@@ -15483,47 +14510,29 @@ ${outputText}
15483
14510
  if (needsInitialize) {
15484
14511
  await geminiClient.initialize();
15485
14512
  }
15486
- if (this.sessions.has(sessionId)) {
15487
- throw new Error(`Session ${sessionId} is already active.`);
15488
- }
14513
+ this.sessions.get(sessionId)?.dispose();
15489
14514
  const session = new Session(sessionId, config, this.connection, settings);
15490
14515
  this.sessions.set(sessionId, session);
15491
- try {
15492
- if (sessionData?.fileHistorySnapshots?.length) {
15493
- config.getFileHistoryService().restoreFromSnapshots(sessionData.fileHistorySnapshots);
15494
- }
15495
- if (sessionData?.conversation.messages) {
15496
- config.getChatRecordingService()?.rebuildTurnBoundaries(sessionData.conversation.messages);
15497
- }
15498
- if (options.replayHistory !== false && sessionData?.conversation.messages) {
15499
- await session.replayHistory(
15500
- sessionData.conversation.messages,
15501
- sessionData.historyGaps
15502
- );
15503
- }
15504
- if (options.startPostReplayServices !== false) {
15505
- session.installRewriter();
15506
- session.startCronScheduler();
15507
- }
15508
- setTimeout(() => {
15509
- void session.sendAvailableCommandsUpdate();
15510
- }, 0);
15511
- return session;
15512
- } catch (error) {
15513
- try {
15514
- await this.discardStoredSessionIfCurrent(sessionId, session, {
15515
- shutdownConfig: false
15516
- });
15517
- } catch (cleanupError) {
15518
- await this.removeStoredSessionEntry(
15519
- sessionId,
15520
- session,
15521
- [cleanupError],
15522
- { shutdownConfig: false }
15523
- );
15524
- }
15525
- throw error;
14516
+ setTimeout(async () => {
14517
+ await session.sendAvailableCommandsUpdate();
14518
+ }, 0);
14519
+ if (sessionData?.fileHistorySnapshots?.length) {
14520
+ config.getFileHistoryService().restoreFromSnapshots(sessionData.fileHistorySnapshots);
14521
+ }
14522
+ if (sessionData?.conversation.messages) {
14523
+ config.getChatRecordingService()?.rebuildTurnBoundaries(sessionData.conversation.messages);
14524
+ }
14525
+ if (options.replayHistory !== false && sessionData?.conversation.messages) {
14526
+ await session.replayHistory(
14527
+ sessionData.conversation.messages,
14528
+ sessionData.historyGaps
14529
+ );
14530
+ }
14531
+ if (options.startPostReplayServices !== false) {
14532
+ session.installRewriter();
14533
+ session.startCronScheduler();
15526
14534
  }
14535
+ return session;
15527
14536
  }
15528
14537
  buildAvailableModels(config) {
15529
14538
  const rawCurrentModelId = (config.getModel() || this.config.getModel() || "").trim();