@qwen-code/qwen-code 0.26.2-preview.0 → 0.26.2-preview.1

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 (300) hide show
  1. package/chunks/{MaxSizedBox-K6YUM3DX.js → MaxSizedBox-EGHZ2BPF.js} +1 -1
  2. package/chunks/{StandaloneSessionPicker-75IC33SN.js → StandaloneSessionPicker-UVCW6YW3.js} +1 -1
  3. package/chunks/{acp-subagent-executor-3NHBJRPL.js → acp-subagent-executor-AQ7AWSD4.js} +1 -1
  4. package/chunks/{acpAgent-JT6KQPTH.js → acpAgent-IV7JAGD7.js} +3 -3
  5. package/chunks/{advisor-TI2UVEZK.js → advisor-UZ4TF65D.js} +1 -1
  6. package/chunks/{agent-SWIZZZMY.js → agent-CNLVAWDD.js} +1 -1
  7. package/chunks/{agent-headless-USWEJ4GW.js → agent-headless-ZJUJLUJS.js} +1 -1
  8. package/chunks/{agent-host-client-ZFIMQX33.js → agent-host-client-SN5V2KBH.js} +1 -1
  9. package/chunks/{agent-host-connections-LOFD7O7Q.js → agent-host-connections-VKMAJIIU.js} +1 -1
  10. package/chunks/{anthropicContentGenerator-HMLEI4FI.js → anthropicContentGenerator-QTJVPAMI.js} +1 -1
  11. package/chunks/{autofix-pr-NKR2VSLB.js → autofix-pr-U7GNSH27.js} +1 -1
  12. package/chunks/{batch-JQZ3TOHA.js → batch-MBEWETXN.js} +1 -1
  13. package/chunks/{bridge-EIWWT4P6.js → bridge-TEJLNYV3.js} +1 -1
  14. package/chunks/{channel-settings-store-FLRLUA67.js → channel-settings-store-QNCKWWBL.js} +1 -1
  15. package/chunks/{chunk-244YTFYD.js → chunk-23KDY7UW.js} +1 -1
  16. package/chunks/{chunk-7TDMQJTD.js → chunk-2DWWSMTV.js} +1 -1
  17. package/chunks/{chunk-UU2LTNSF.js → chunk-3IZMVLVZ.js} +1 -1
  18. package/chunks/{chunk-B6T4ESBM.js → chunk-3JI7IKJL.js} +1 -1
  19. package/chunks/{chunk-Y5TT2G3N.js → chunk-427MARCP.js} +1 -1
  20. package/chunks/{chunk-KX7JS2P7.js → chunk-4NNNGSQY.js} +3 -3
  21. package/chunks/{chunk-6TQS2WQO.js → chunk-4RM7KY3Z.js} +2 -2
  22. package/chunks/{chunk-YL3N2UGG.js → chunk-5X7S4AE6.js} +5 -5
  23. package/chunks/{chunk-K2HAY5PY.js → chunk-5XAECBED.js} +1 -1
  24. package/chunks/{chunk-VCHFBETO.js → chunk-66KKSLUO.js} +1 -1
  25. package/chunks/{chunk-BSJR2KEF.js → chunk-6CIIDUZW.js} +1 -1
  26. package/chunks/{chunk-22CLK7PK.js → chunk-7EBRMQYW.js} +1 -1
  27. package/chunks/{chunk-J4TFGZ4A.js → chunk-7FSC2NKA.js} +1 -1
  28. package/chunks/{chunk-6JFC5M6B.js → chunk-A5TAAMML.js} +1 -1
  29. package/chunks/{chunk-DHHACQVN.js → chunk-AOYSX44A.js} +1 -1
  30. package/chunks/{chunk-VFVZ2DY7.js → chunk-AZCMQ3DD.js} +2 -2
  31. package/chunks/{chunk-BQJXWIMR.js → chunk-B6F7CVBP.js} +1 -1
  32. package/chunks/{chunk-OVPEAKOQ.js → chunk-BDQOLT37.js} +1 -1
  33. package/chunks/{chunk-5SYUBQNO.js → chunk-BIWEUAKG.js} +1 -1
  34. package/chunks/{chunk-BZM66PQO.js → chunk-BJ5R7LOM.js} +1 -1
  35. package/chunks/{chunk-4R2OHBH3.js → chunk-BKUFRNME.js} +1 -1
  36. package/chunks/{chunk-NIYWNFVF.js → chunk-BNZSPX2I.js} +1 -1
  37. package/chunks/{chunk-FJV2ECNY.js → chunk-D2URRVOK.js} +1 -1
  38. package/chunks/{chunk-GT6CHVAI.js → chunk-DANP7CMW.js} +1 -1
  39. package/chunks/{chunk-FHFLD4DR.js → chunk-DBHLRZGI.js} +1 -1
  40. package/chunks/{chunk-Y2UXZJLM.js → chunk-DL7TKH2E.js} +2 -2
  41. package/chunks/{chunk-MCQE2U7N.js → chunk-DOWKH5OZ.js} +6 -6
  42. package/chunks/{chunk-UHRLBY3C.js → chunk-DPHQJPCU.js} +1 -1
  43. package/chunks/{chunk-PV2VT25U.js → chunk-DPNGBOI7.js} +1 -1
  44. package/chunks/{chunk-NCDNF7UJ.js → chunk-DXRXF4QD.js} +1 -1
  45. package/chunks/{chunk-OCVRMNEQ.js → chunk-DZ3GV34J.js} +1 -1
  46. package/chunks/{chunk-3QIAXWWW.js → chunk-EU2MKUK4.js} +1 -1
  47. package/chunks/{chunk-KMAVI6FB.js → chunk-EVBUXPGM.js} +1 -1
  48. package/chunks/{chunk-BVSTV4JM.js → chunk-F3ZRU2SA.js} +1 -1
  49. package/chunks/{chunk-TBZY477Y.js → chunk-FCZYH27X.js} +1 -1
  50. package/chunks/{chunk-JCOK67LT.js → chunk-FNDMWG43.js} +1 -1
  51. package/chunks/{chunk-5SF32OGU.js → chunk-GDXLJJSW.js} +1 -1
  52. package/chunks/{chunk-SO6FCPRI.js → chunk-GZYIXB7Y.js} +1 -1
  53. package/chunks/{chunk-WZPTWC7X.js → chunk-HHNAH4IH.js} +1 -1
  54. package/chunks/{chunk-7KCAOXNL.js → chunk-HOKROBQZ.js} +1 -1
  55. package/chunks/{chunk-34ZBUQJV.js → chunk-IGPAATQW.js} +1 -1
  56. package/chunks/{chunk-2ZTRKK2O.js → chunk-INFBJDWM.js} +1 -1
  57. package/chunks/{chunk-IEJ2CGRN.js → chunk-J3R7ZNSA.js} +1 -1
  58. package/chunks/{chunk-KT5MPRYB.js → chunk-JCRS367I.js} +1 -1
  59. package/chunks/{chunk-7JWJTRP6.js → chunk-JFVXZFMV.js} +1 -1
  60. package/chunks/{chunk-47LP4MBD.js → chunk-JKMGS2VD.js} +1 -1
  61. package/chunks/{chunk-WRJ3PMDZ.js → chunk-JUQ7T2MV.js} +1 -1
  62. package/chunks/{chunk-NZX3UWNF.js → chunk-KQ4TDFNE.js} +1 -1
  63. package/chunks/{chunk-X7D4VKMX.js → chunk-L6BKKN42.js} +1 -1
  64. package/chunks/{chunk-YG5HVFMY.js → chunk-L7Y6MOHS.js} +1 -1
  65. package/chunks/{chunk-UFTIUKD4.js → chunk-LGYXZJI3.js} +1 -1
  66. package/chunks/{chunk-JQGGILML.js → chunk-LPOEVTKD.js} +1 -1
  67. package/chunks/{chunk-5KI55A6S.js → chunk-LRXS7ZI2.js} +1 -1
  68. package/chunks/{chunk-CKVHEYXW.js → chunk-LYYVSCNL.js} +1 -1
  69. package/chunks/{chunk-LIIMQ4DI.js → chunk-LZNBHBAJ.js} +6 -6
  70. package/chunks/{chunk-H4GDEXMF.js → chunk-M3C6RDGC.js} +1 -1
  71. package/chunks/{chunk-KKKUB3RQ.js → chunk-MNVMHVQJ.js} +1 -1
  72. package/chunks/{chunk-2B3W7IQY.js → chunk-MVGQFFIK.js} +1 -1
  73. package/chunks/{chunk-Q35A2RGO.js → chunk-NC7BCZPQ.js} +1 -1
  74. package/chunks/{chunk-2ZOTG3NW.js → chunk-NE627MUW.js} +1 -1
  75. package/chunks/{chunk-W4P2EN3V.js → chunk-NZNRCPGE.js} +1 -1
  76. package/chunks/{chunk-YPDQJQ3S.js → chunk-P3M4WWRA.js} +1 -1
  77. package/chunks/{chunk-DVB36ASH.js → chunk-P534ONQN.js} +1 -1
  78. package/chunks/{chunk-EL5J4ESB.js → chunk-QF44NNSC.js} +1 -1
  79. package/chunks/{chunk-IQPJOBPI.js → chunk-QHGCDHNW.js} +1 -1
  80. package/chunks/{chunk-EVZC4KEQ.js → chunk-QWJX7NIP.js} +1 -1
  81. package/chunks/{chunk-J2TJL2F4.js → chunk-S53G54DW.js} +2 -2
  82. package/chunks/{chunk-3A6LFJJV.js → chunk-SMNFL3AD.js} +1 -1
  83. package/chunks/{chunk-WDO3K3P2.js → chunk-TOBNWST4.js} +1 -1
  84. package/chunks/{chunk-AVGJ4HE3.js → chunk-TQSBUHAM.js} +1 -1
  85. package/chunks/{chunk-ABUS7DNN.js → chunk-TW5QEP2J.js} +1 -1
  86. package/chunks/{chunk-WYM4Z4D5.js → chunk-UEB2F43V.js} +1 -1
  87. package/chunks/{chunk-FUUPMVD2.js → chunk-UPPE4I6H.js} +1 -1
  88. package/chunks/{chunk-UHBJVFZA.js → chunk-US42COBM.js} +1 -1
  89. package/chunks/{chunk-RMQNBSMK.js → chunk-UUY6XSQI.js} +1 -1
  90. package/chunks/{chunk-UVQUQNCA.js → chunk-UZI3IA27.js} +1 -1
  91. package/chunks/{chunk-SXJ2E33J.js → chunk-V6VMUJ47.js} +1 -1
  92. package/chunks/{chunk-5UFCNJGN.js → chunk-VG2ZINTO.js} +1 -1
  93. package/chunks/{chunk-JPPPJ2GN.js → chunk-VJI6MHWX.js} +1 -1
  94. package/chunks/{chunk-AUI7WVSU.js → chunk-VOBNHBCJ.js} +1 -1
  95. package/chunks/{chunk-3BNJDZHU.js → chunk-VUEZWMI4.js} +1 -1
  96. package/chunks/{chunk-LMNKCL55.js → chunk-W7ZX6WB3.js} +2 -2
  97. package/chunks/{chunk-HVS6V2UZ.js → chunk-WA2LKUVP.js} +1 -1
  98. package/chunks/{chunk-7APLU2XE.js → chunk-WFFCJ5PF.js} +1 -1
  99. package/chunks/{chunk-3TD4WAG5.js → chunk-WQY5GE65.js} +1 -1
  100. package/chunks/{chunk-3YWRMF6C.js → chunk-WSESLSKK.js} +1 -1
  101. package/chunks/{chunk-NILCQMZ7.js → chunk-XFJV5NYT.js} +1 -1
  102. package/chunks/{chunk-LGBGUITT.js → chunk-XIYLRIW4.js} +1 -1
  103. package/chunks/{chunk-KS74L67R.js → chunk-XQ2NYKJH.js} +1 -1
  104. package/chunks/{chunk-JB2NOB6W.js → chunk-Y3VRWG52.js} +1 -1
  105. package/chunks/{chunk-GVZ6D2NL.js → chunk-YBISME5B.js} +1 -1
  106. package/chunks/{chunk-2C2253QI.js → chunk-YJNWPSB3.js} +1 -1
  107. package/chunks/{chunk-O2T3GQ6F.js → chunk-YWVV5STA.js} +1 -1
  108. package/chunks/{chunk-MAQZSOHI.js → chunk-ZH4J3FL6.js} +1 -1
  109. package/chunks/{chunk-THNEKTPK.js → chunk-ZSKCF6DI.js} +1 -1
  110. package/chunks/{chunk-Z7BAHKO5.js → chunk-ZW6456SD.js} +1 -1
  111. package/chunks/{chunk-DMSZ2TB3.js → chunk-ZWM3LLT7.js} +1 -1
  112. package/chunks/{codex-subagent-executor-DQ5LQQWO.js → codex-subagent-executor-DWWT7246.js} +1 -1
  113. package/chunks/{config-utils-CY6HLKZ5.js → config-utils-NGZB522W.js} +1 -1
  114. package/chunks/{contextCommand-SGBWI7O6.js → contextCommand-7QCW2YNX.js} +1 -1
  115. package/chunks/{core-runtime-4DP27LCC.js → core-runtime-PSVNDJPD.js} +1 -1
  116. package/chunks/{create-sub-session-ECPDZMBX.js → create-sub-session-JTSEMEJE.js} +1 -1
  117. package/chunks/{cron-create-OO4OG3EI.js → cron-create-VGIDTUMX.js} +1 -1
  118. package/chunks/{daemon-git-worktree-guard-OYDNHT7P.js → daemon-git-worktree-guard-IQRGS7IH.js} +1 -1
  119. package/chunks/{daemon-status-provider-JGDLXPC6.js → daemon-status-provider-R4MYCYPG.js} +1 -1
  120. package/chunks/{daemon-trust-policy-5HRARS54.js → daemon-trust-policy-VAUKFZ2N.js} +1 -1
  121. package/chunks/{daemon-trust-policy-monitor-RM7FVIIC.js → daemon-trust-policy-monitor-E5HIO6RP.js} +1 -1
  122. package/chunks/{deferred-core-runtime-3CXBZIOG.js → deferred-core-runtime-FLOFQJPU.js} +1 -1
  123. package/chunks/{edit-DJPESAAY.js → edit-OOVQUGKV.js} +1 -1
  124. package/chunks/{enterPlanMode-IHBLRIF3.js → enterPlanMode-AUWVTQLT.js} +1 -1
  125. package/chunks/{environment-JN5SD347.js → environment-RM5OXYP4.js} +1 -1
  126. package/chunks/{errors-NUJCME3Y.js → errors-CLDJGHVD.js} +1 -1
  127. package/chunks/{execution-tool-I3SWG6I3.js → execution-tool-JFBVOKPW.js} +1 -1
  128. package/chunks/{execution-worker-62UZMAMJ.js → execution-worker-MNJZD72W.js} +1 -1
  129. package/chunks/{exitPlanMode-JIC4V3FE.js → exitPlanMode-PC6XG4TW.js} +1 -1
  130. package/chunks/{fast-path-NIOIL5YI.js → fast-path-V4DN3CRZ.js} +1 -1
  131. package/chunks/{glob-EQ4QNAHF.js → glob-DTZROBDS.js} +1 -1
  132. package/chunks/{goal-tools-DYTTSBQG.js → goal-tools-FUVGTY33.js} +1 -1
  133. package/chunks/{handleAutoUpdate-44BTG5L5.js → handleAutoUpdate-U4LVTHGU.js} +1 -1
  134. package/chunks/{i18n-FTHZAHCT.js → i18n-XOKNDFYP.js} +1 -1
  135. package/chunks/{initializer-MSGKXC75.js → initializer-XBR5J4CY.js} +1 -1
  136. package/chunks/{installationInfo-4XJMJJYU.js → installationInfo-4AOEOUI6.js} +1 -1
  137. package/chunks/{interactive-mod-session-DFLRYO2Q.js → interactive-mod-session-YGZK2JK2.js} +1 -1
  138. package/chunks/{list-ODZ7Z6VI.js → list-TCGKVPH4.js} +1 -1
  139. package/chunks/{llm-O64DHKP7.js → llm-SKFTN5UN.js} +4 -4
  140. package/chunks/{llm-content-generator-SK24I6QS.js → llm-content-generator-GWHXT3WS.js} +1 -1
  141. package/chunks/{loadedSettingsAdapter-6PEBUZT5.js → loadedSettingsAdapter-ZALZGZE7.js} +1 -1
  142. package/chunks/{local-ED3UEKWP.js → local-RWTWYS5Z.js} +1 -1
  143. package/chunks/{local-execution-environment-PUKES5LO.js → local-execution-environment-R6JWLD65.js} +1 -1
  144. package/chunks/{loggingContentGenerator-UHOJVSRR.js → loggingContentGenerator-UJV6QFOY.js} +1 -1
  145. package/chunks/{loop-wakeup-NSJQETPZ.js → loop-wakeup-BU2RRYHA.js} +1 -1
  146. package/chunks/{manage-memory-5RRB6FLH.js → manage-memory-XI57JN4T.js} +1 -1
  147. package/chunks/{managed-execution-engine-MZAP7SK6.js → managed-execution-engine-BA5PABMP.js} +1 -1
  148. package/chunks/{managed-local-serve-XMES3HXL.js → managed-local-serve-MFKN22K6.js} +1 -1
  149. package/chunks/{managed-npm-update-R5KGY7G2.js → managed-npm-update-ZGN43NUA.js} +1 -1
  150. package/chunks/{managed-runtime-attestation-worker-O2KNHHV6.js → managed-runtime-attestation-worker-YN2VBGYN.js} +1 -1
  151. package/chunks/{managed-runtime-bootstrap-HOTLM6DE.js → managed-runtime-bootstrap-SGQVMUJE.js} +1 -1
  152. package/chunks/{managed-runtime-session-worker-QZX44ZTD.js → managed-runtime-session-worker-4UMF3VBY.js} +1 -1
  153. package/chunks/{managed-runtime-ssh-worker-U425WQ65.js → managed-runtime-ssh-worker-7XA6KRBN.js} +1 -1
  154. package/chunks/{managed-session-authority-THHDHCBP.js → managed-session-authority-IJGYAOEL.js} +1 -1
  155. package/chunks/{mcp-AR7EK4WY.js → mcp-V3L7B5YK.js} +1 -1
  156. package/chunks/{memory-C2TSF6BK.js → memory-3T6FPNAK.js} +1 -1
  157. package/chunks/{model-call-collection-25WR55OH.js → model-call-collection-WTTITWWM.js} +1 -1
  158. package/chunks/{model-configuration-KC7DQGKV.js → model-configuration-T6SSGI4J.js} +1 -1
  159. package/chunks/{modelConfigUtils-QEHMVLSQ.js → modelConfigUtils-TQA25QJC.js} +1 -1
  160. package/chunks/{monitor-PDQUZD23.js → monitor-5ZAOJSEE.js} +1 -1
  161. package/chunks/{nonInteractiveCli-WY2YFONU.js → nonInteractiveCli-YFINLVA7.js} +1 -1
  162. package/chunks/{nonInteractiveToolExecutor-7RJZYPHJ.js → nonInteractiveToolExecutor-DE3WACL5.js} +1 -1
  163. package/chunks/{notebook-edit-P4ITXF5H.js → notebook-edit-UK6HBRO3.js} +1 -1
  164. package/chunks/{omni-AYUPB2QM.js → omni-65LF5QK4.js} +1 -1
  165. package/chunks/{openaiContentGenerator-V5IK4ITO.js → openaiContentGenerator-HX7NCSV5.js} +1 -1
  166. package/chunks/{openaiResponsesContentGenerator-DYDH6KWT.js → openaiResponsesContentGenerator-CFA6U6Y5.js} +1 -1
  167. package/chunks/{pidfile-INPBL2DK.js → pidfile-ZVKJUNTZ.js} +1 -1
  168. package/chunks/{processUtils-J4UDEDS4.js → processUtils-VS6CJT7E.js} +1 -1
  169. package/chunks/{prompt-terminal-ledger-QLOQWHYE.js → prompt-terminal-ledger-UF5RDB57.js} +1 -1
  170. package/chunks/{qwenContentGenerator-RU43XKKB.js → qwenContentGenerator-GM3ZSI7E.js} +1 -1
  171. package/chunks/{reactive-degrade-2Q3Z3KAR.js → reactive-degrade-TSAQWZ5F.js} +1 -1
  172. package/chunks/{read-file-472BQ25I.js → read-file-J267NT45.js} +1 -1
  173. package/chunks/{resumeHistoryUtils-7SUFKZDC.js → resumeHistoryUtils-IM46VFDV.js} +1 -1
  174. package/chunks/{review-WX52IWJR.js → review-4B64XTCL.js} +1 -1
  175. package/chunks/{ripGrep-4GPGLKAM.js → ripGrep-YLOSXO7P.js} +1 -1
  176. package/chunks/{run-qwen-serve-MXK4RBKL.js → run-qwen-serve-SAHEC44O.js} +1 -1
  177. package/chunks/{runtime-WHU3AGFT.js → runtime-SJDZHV6J.js} +1 -1
  178. package/chunks/{sandboxConfig-7DBXEQJH.js → sandboxConfig-47EXXMUA.js} +1 -1
  179. package/chunks/{scheduled-tasks-O5RV6G6U.js → scheduled-tasks-E6RCTUUS.js} +1 -1
  180. package/chunks/{scheduler-HLMS5LR5.js → scheduler-SE3IWIWA.js} +1 -1
  181. package/chunks/{search-memory-PYND7ZX3.js → search-memory-2W7VJC4Q.js} +1 -1
  182. package/chunks/{send-message-TMLYTQOI.js → send-message-63YGQP6G.js} +1 -1
  183. package/chunks/{serve-EBNBRAME.js → serve-F4ML2WNL.js} +1 -1
  184. package/chunks/{server-63BRDBL5.js → server-S56IB4TT.js} +3 -3
  185. package/chunks/{session-XB6J4CZD.js → session-2CUVLZ4H.js} +1 -1
  186. package/chunks/{session-attachments-root-PFK475N2.js → session-attachments-root-FINBX7K5.js} +1 -1
  187. package/chunks/{session-execution-engine-selector-P6TJTCKR.js → session-execution-engine-selector-UGC7DGUN.js} +1 -1
  188. package/chunks/{session-pr-refresh-PM7VAQTV.js → session-pr-refresh-KQLQ4MZY.js} +1 -1
  189. package/chunks/{sessionService-PO3LLZIZ.js → sessionService-Q6N7LF7Z.js} +1 -1
  190. package/chunks/{settings-JDQSRXP3.js → settings-23I6H76E.js} +1 -1
  191. package/chunks/{shell-JCEX3HKM.js → shell-IUECEVVY.js} +1 -1
  192. package/chunks/{skill-JSZBONIZ.js → skill-YKUETMPC.js} +1 -1
  193. package/chunks/{skill-settings-YGFG6GPN.js → skill-settings-ODYXOPCA.js} +1 -1
  194. package/chunks/{spawnChannel-VIIWSWTL.js → spawnChannel-7XU2SRWZ.js} +1 -1
  195. package/chunks/{standalone-update-2UU6FQZL.js → standalone-update-SWI2RL3L.js} +1 -1
  196. package/chunks/{start-opentui-ui-OSZZNSLY.js → start-opentui-ui-T53QJGCH.js} +1 -1
  197. package/chunks/{startInteractiveUI-FFH66MYH.js → startInteractiveUI-USTZGQOE.js} +1 -1
  198. package/chunks/{team-create-TKGDJ3NU.js → team-create-4A2XUE3D.js} +1 -1
  199. package/chunks/{team-plan-approval-3VJF4G6Z.js → team-plan-approval-4TS5CYN6.js} +1 -1
  200. package/chunks/{terminal-image-renderer-T3VJRZGP.js → terminal-image-renderer-C7553YV6.js} +1 -1
  201. package/chunks/{theme-manager-ZGUFLFUI.js → theme-manager-GTW75GOO.js} +1 -1
  202. package/chunks/{tool-call-3EQS5KSE.js → tool-call-YTUMWL3A.js} +1 -1
  203. package/chunks/{tool-result-media-7LFNVQ6E.js → tool-result-media-JYOYBX4J.js} +1 -1
  204. package/chunks/{tool-search-UDZ4S7T5.js → tool-search-Y4XTT2WF.js} +1 -1
  205. package/chunks/{total-session-admission-U4MII4RA.js → total-session-admission-EMJ5NRGL.js} +1 -1
  206. package/chunks/{trustedFolders-2NQJCIN3.js → trustedFolders-YG6WAVRE.js} +1 -1
  207. package/chunks/{update-relaunch-YKLWSCLC.js → update-relaunch-4QYQRCP4.js} +1 -1
  208. package/chunks/{updateCheck-YDLTQQRU.js → updateCheck-VRFPSX4G.js} +1 -1
  209. package/chunks/{upload-config-5QQKWF4O.js → upload-config-UCKGUYYQ.js} +1 -1
  210. package/chunks/{useAutoAcceptIndicator-AJS4WTU2.js → useAutoAcceptIndicator-2VGLKD7B.js} +1 -1
  211. package/chunks/{validateNonInterActiveAuth-AETOT7ZW.js → validateNonInterActiveAuth-GGMQXKKU.js} +1 -1
  212. package/chunks/{version-IB6DLRAG.js → version-Y46PG7II.js} +1 -1
  213. package/chunks/{web-fetch-LS3QARNR.js → web-fetch-7MPU555L.js} +1 -1
  214. package/chunks/{web-search-FGHRIVEB.js → web-search-HU2CL2X2.js} +1 -1
  215. package/chunks/{workflow-FX6XNETQ.js → workflow-U3D34QQX.js} +1 -1
  216. package/chunks/{workflow-ancestor-trust-5XXBGN6F.js → workflow-ancestor-trust-OWC4YTMR.js} +1 -1
  217. package/chunks/{workspace-agents-UJKLYPUK.js → workspace-agents-KHLAWSAR.js} +1 -1
  218. package/chunks/{workspace-providers-status-4JOHMTAW.js → workspace-providers-status-T57SE3YX.js} +1 -1
  219. package/chunks/{workspace-recovery-worker-XFEYQ4TP.js → workspace-recovery-worker-VYQ723ZE.js} +1 -1
  220. package/chunks/{workspace-registration-store-LWAPVNYC.js → workspace-registration-store-I7PR3A2Y.js} +1 -1
  221. package/chunks/{workspace-registry-M7OC376O.js → workspace-registry-YYUBXCLH.js} +1 -1
  222. package/chunks/{workspace-runtime-coordinator-CYHIL47L.js → workspace-runtime-coordinator-5ICAQO7W.js} +1 -1
  223. package/chunks/{workspace-service-43VZZ56B.js → workspace-service-YROWXOLQ.js} +1 -1
  224. package/chunks/{workspace-skills-status-V2TT6UJQ.js → workspace-skills-status-DKKQDTZJ.js} +1 -1
  225. package/chunks/{workspace-trust-reconciler-YZ4AG5ZW.js → workspace-trust-reconciler-3FPMUZDO.js} +1 -1
  226. package/chunks/{write-file-TGEH5MEZ.js → write-file-7QQVYFDT.js} +1 -1
  227. package/chunks/{zoom-image-TT6R7H2H.js → zoom-image-WL5EB6Q7.js} +1 -1
  228. package/cli.js +2 -2
  229. package/execution-worker.js +1 -1
  230. package/export-transcript-document.js +1 -1
  231. package/package.json +3 -3
  232. package/web-shell/assets/{PierreFilePreview-OsApm5-S.js → PierreFilePreview-BZ17f56_.js} +1 -1
  233. package/web-shell/assets/{SpreadsheetPreview-I1v1EzV7.js → SpreadsheetPreview-Bvkvr_5u.js} +1 -1
  234. package/web-shell/assets/{WorkspaceFileBrowser-BO6aug7i.js → WorkspaceFileBrowser-BJ_I4Uoz.js} +1 -1
  235. package/web-shell/assets/{abnfDiagram-VCTEODGH-DxuLMyN0.js → abnfDiagram-VCTEODGH-iuaBM15V.js} +1 -1
  236. package/web-shell/assets/{agents-route-CSJf6QPO.js → agents-route-CycwfNSC.js} +1 -1
  237. package/web-shell/assets/{arc-3--LekYQ.js → arc-C0lt8n55.js} +1 -1
  238. package/web-shell/assets/{architectureDiagram-5GKGNRK7-Dihq4uto.js → architectureDiagram-5GKGNRK7-Bw326d-A.js} +1 -1
  239. package/web-shell/assets/{blockDiagram-NRAW4CY4-BnaRPM2o.js → blockDiagram-NRAW4CY4-CHtFgBjV.js} +1 -1
  240. package/web-shell/assets/{c4Diagram-UCG6FXSJ-BtC94eMa.js → c4Diagram-UCG6FXSJ-Bx66oJT9.js} +1 -1
  241. package/web-shell/assets/channel-CRJuO00u.js +1 -0
  242. package/web-shell/assets/{chunk-2Q5K7J3B-2ZTXWP6M.js → chunk-2Q5K7J3B-BIshvfa_.js} +1 -1
  243. package/web-shell/assets/{chunk-5VM5RSS4-DBh7DP1F.js → chunk-5VM5RSS4-BZeRS6uD.js} +1 -1
  244. package/web-shell/assets/{chunk-F27PBJKO-xzqbWXBw.js → chunk-F27PBJKO-El-CGY2R.js} +1 -1
  245. package/web-shell/assets/{chunk-G27WJ6UU-DxnCrpxK.js → chunk-G27WJ6UU-DO8ZfQL_.js} +1 -1
  246. package/web-shell/assets/{chunk-JWPE2WC7-BPjRsozm.js → chunk-JWPE2WC7-yYFrrKAj.js} +1 -1
  247. package/web-shell/assets/{chunk-LCL6LL3I-Q2HgB3lf.js → chunk-LCL6LL3I-BFGuOKN0.js} +1 -1
  248. package/web-shell/assets/{chunk-POPQ4Y6H-9tlPaKu-.js → chunk-POPQ4Y6H-GRHK6sdV.js} +1 -1
  249. package/web-shell/assets/{chunk-SVP7TREG-DkNdOHCU.js → chunk-SVP7TREG-DwDu6GqZ.js} +1 -1
  250. package/web-shell/assets/{chunk-XXDRQBXY-D0G-Dhfi.js → chunk-XXDRQBXY-RoNDjkIy.js} +1 -1
  251. package/web-shell/assets/classDiagram-DTDB5LWJ-pPPByLA7.js +1 -0
  252. package/web-shell/assets/classDiagram-v2-JRS7N3AN-pPPByLA7.js +1 -0
  253. package/web-shell/assets/{cose-bilkent-JH36ORCC-Ck0tHxul.js → cose-bilkent-JH36ORCC-CYNiiONE.js} +1 -1
  254. package/web-shell/assets/{cynefin-OW5HDTMX-a4-NTMHi.js → cynefin-OW5HDTMX-DC1_lDIG.js} +1 -1
  255. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-Pg41Zbf2.js → cynefinDiagram-5FMLGOSQ-D2VxKm2n.js} +1 -1
  256. package/web-shell/assets/{dagre-3AP2YEHR-DT_ZmqkF.js → dagre-3AP2YEHR-C4_BHzpM.js} +1 -1
  257. package/web-shell/assets/{diagram-S7CK7UJ4-hapdMOl1.js → diagram-S7CK7UJ4-BpAO4-Gv.js} +1 -1
  258. package/web-shell/assets/{diagram-UQ7AKVKN-YZ0nbk56.js → diagram-UQ7AKVKN-DqUsFdsX.js} +1 -1
  259. package/web-shell/assets/{diagram-VSXAHHWV-DA_yNbWy.js → diagram-VSXAHHWV-DcMXIYMy.js} +1 -1
  260. package/web-shell/assets/{diagram-VX7I27RA-DoULuCLT.js → diagram-VX7I27RA-I3nr09ex.js} +1 -1
  261. package/web-shell/assets/{diagram-Z3DM3KII-B5c9o9zL.js → diagram-Z3DM3KII-CN-gvsTo.js} +1 -1
  262. package/web-shell/assets/{docx-preview-BulxdBjs.js → docx-preview-31J6RsS0.js} +1 -1
  263. package/web-shell/assets/{ebnfDiagram-PWID7BFC-B5hgIg3m.js → ebnfDiagram-PWID7BFC-DOQvLWlM.js} +1 -1
  264. package/web-shell/assets/{erDiagram-SSCWMZ5O-BEfEPozi.js → erDiagram-SSCWMZ5O-Cb5ijFZh.js} +1 -1
  265. package/web-shell/assets/{flowDiagram-A5DVABFB-CQHNk92v.js → flowDiagram-A5DVABFB-BecqqjnZ.js} +1 -1
  266. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-BabdVgIM.js → ganttDiagram-EL5Y4UJY-DWY5vzQl.js} +1 -1
  267. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-ujRZBFUo.js → gitGraphDiagram-WWUBYQGX-DqBnsZmZ.js} +1 -1
  268. package/web-shell/assets/{index-B9uXebIR.js → index-DDmiUW3b.js} +6 -6
  269. package/web-shell/assets/{index-DSZXdZnu.js → index-DabH7kHA.js} +1 -1
  270. package/web-shell/assets/{infoDiagram-RXCK75RN-CUHj9jJC.js → infoDiagram-RXCK75RN-MlotyOdT.js} +1 -1
  271. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-CulW_q81.js → ishikawaDiagram-5VMMS53U-Daq_85C7.js} +1 -1
  272. package/web-shell/assets/{journeyDiagram-EYS64GPL-BR46CvRQ.js → journeyDiagram-EYS64GPL-OipivCxL.js} +1 -1
  273. package/web-shell/assets/{kanban-definition-3QL26DDD-HAoUqzFy.js → kanban-definition-3QL26DDD-zqaz7dLu.js} +1 -1
  274. package/web-shell/assets/{layout-DYLl7fyA.js → layout-Bi3msQMQ.js} +1 -1
  275. package/web-shell/assets/{linear-DPXABjDZ.js → linear-D4gPORvD.js} +1 -1
  276. package/web-shell/assets/{mermaid.core-Bi30Gi0n.js → mermaid.core-BUnytF7a.js} +6 -6
  277. package/web-shell/assets/{mindmap-definition-FBJOCRG2-B1_lUq4o.js → mindmap-definition-FBJOCRG2-B_X4iChu.js} +1 -1
  278. package/web-shell/assets/{pegDiagram-XKGWAZYB-Cy8tjJJC.js → pegDiagram-XKGWAZYB-z4wYBoBW.js} +1 -1
  279. package/web-shell/assets/{pieDiagram-E7YTZNPT-D6waLVVi.js → pieDiagram-E7YTZNPT-Dvyg6FYo.js} +1 -1
  280. package/web-shell/assets/{quadrantDiagram-AXDQQJYC--6ehi_FI.js → quadrantDiagram-AXDQQJYC-CJBWU2Dk.js} +1 -1
  281. package/web-shell/assets/{railroadDiagram-O6MQD6OU-BhLy40X4.js → railroadDiagram-O6MQD6OU-Dl_An1O0.js} +1 -1
  282. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BVNXTgNP.js → requirementDiagram-EFPCY7ZU-Tw8FwaYU.js} +1 -1
  283. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-BHgTytxV.js → sankeyDiagram-P5KCCOFB-BCPCkbR0.js} +1 -1
  284. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-CgOsTvhu.js → sequenceDiagram-WJ2MYXX4-DDj7uFTG.js} +1 -1
  285. package/web-shell/assets/{sizeCapture-X5ZJPWSS-vCQBQ5FI.js → sizeCapture-X5ZJPWSS-B9eVSpKb.js} +1 -1
  286. package/web-shell/assets/{stateDiagram-HBIQ2CUA-DytMYRWJ.js → stateDiagram-HBIQ2CUA-Bf4BZP_V.js} +1 -1
  287. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BPJi6Gre.js +1 -0
  288. package/web-shell/assets/{swimlanes-XN3QIQJK-CTGnifOP.js → swimlanes-XN3QIQJK-dyTWsZFj.js} +1 -1
  289. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Bw4NRtJQ.js +8 -0
  290. package/web-shell/assets/{timeline-definition-24CTP7MA-DEJ1cbn2.js → timeline-definition-24CTP7MA-DVl1A4uL.js} +1 -1
  291. package/web-shell/assets/{vennDiagram-4TSXK5OY-K1e4SjS0.js → vennDiagram-4TSXK5OY-Boosxy9D.js} +1 -1
  292. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-DEX-GkRp.js → wardleyDiagram-VM6X3IG4-C6wlY8jy.js} +1 -1
  293. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-B6wYXreH.js → xychartDiagram-S5SC5T6Z-CkzZe3ro.js} +1 -1
  294. package/web-shell/index.html +1 -1
  295. package/web-shell/sw.js +1 -1
  296. package/web-shell/assets/channel-CLVrtVFX.js +0 -1
  297. package/web-shell/assets/classDiagram-DTDB5LWJ-Df2T70oB.js +0 -1
  298. package/web-shell/assets/classDiagram-v2-JRS7N3AN-Df2T70oB.js +0 -1
  299. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CcjUJGng.js +0 -1
  300. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Dt8NvQfX.js +0 -8
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import"./chunk-6JFC5M6B.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-7JWJTRP6.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-GVZ6D2NL.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-H4GDEXMF.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-34ZBUQJV.js";import"./chunk-XZACON5H.js";import"./chunk-22CLK7PK.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-SXJ2E33J.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LIIMQ4DI.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import{readCronTasks}from"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import{DEFAULT_OTLP_ENDPOINT,DEFAULT_TELEMETRY_TARGET,initializeDaemonMetrics,recordDaemonCancel,recordDaemonChannelLifecycle,recordDaemonPipeMessage,recordDaemonPromptDuration,recordDaemonPromptQueueWait,recordDaemonSessionLifecycle,registerDaemonEventLoopLagGauge,registerDaemonGaugeCallbacks,resolveTelemetrySettings,startEventLoopLagMonitor}from"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-EL5J4ESB.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-PV2VT25U.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-JCOK67LT.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import{applyProviderInstallPlan,buildInstallPlan,findProviderById,getDefaultModelIds,getModelsForProviderProtocol,resolveBaseUrl}from"./chunk-OVPEAKOQ.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import{createDaemonBridgeTelemetry,emitDaemonLog,hashDaemonWorkspace}from"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-OCVRMNEQ.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import{forceFlushMetrics,initializeTelemetry,shutdownTelemetry}from"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import{Storage}from"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import{FatalConfigError}from"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import"./chunk-KBWJGX7I.js";init_esbuild_shims();export{DEFAULT_OTLP_ENDPOINT,DEFAULT_TELEMETRY_TARGET,FatalConfigError,Storage,applyProviderInstallPlan,buildInstallPlan,createDaemonBridgeTelemetry,emitDaemonLog,findProviderById,forceFlushMetrics,getDefaultModelIds,getModelsForProviderProtocol,hashDaemonWorkspace,initializeDaemonMetrics,initializeTelemetry,readCronTasks,recordDaemonCancel,recordDaemonChannelLifecycle,recordDaemonPipeMessage,recordDaemonPromptDuration,recordDaemonPromptQueueWait,recordDaemonSessionLifecycle,registerDaemonEventLoopLagGauge,registerDaemonGaugeCallbacks,resolveBaseUrl,resolveTelemetrySettings,shutdownTelemetry,startEventLoopLagMonitor};
3
+ import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import{readCronTasks}from"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import{DEFAULT_OTLP_ENDPOINT,DEFAULT_TELEMETRY_TARGET,initializeDaemonMetrics,recordDaemonCancel,recordDaemonChannelLifecycle,recordDaemonPipeMessage,recordDaemonPromptDuration,recordDaemonPromptQueueWait,recordDaemonSessionLifecycle,registerDaemonEventLoopLagGauge,registerDaemonGaugeCallbacks,resolveTelemetrySettings,startEventLoopLagMonitor}from"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import{applyProviderInstallPlan,buildInstallPlan,findProviderById,getDefaultModelIds,getModelsForProviderProtocol,resolveBaseUrl}from"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import{createDaemonBridgeTelemetry,emitDaemonLog,hashDaemonWorkspace}from"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import{forceFlushMetrics,initializeTelemetry,shutdownTelemetry}from"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import{Storage}from"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import{FatalConfigError}from"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import"./chunk-KBWJGX7I.js";init_esbuild_shims();export{DEFAULT_OTLP_ENDPOINT,DEFAULT_TELEMETRY_TARGET,FatalConfigError,Storage,applyProviderInstallPlan,buildInstallPlan,createDaemonBridgeTelemetry,emitDaemonLog,findProviderById,forceFlushMetrics,getDefaultModelIds,getModelsForProviderProtocol,hashDaemonWorkspace,initializeDaemonMetrics,initializeTelemetry,readCronTasks,recordDaemonCancel,recordDaemonChannelLifecycle,recordDaemonPipeMessage,recordDaemonPromptDuration,recordDaemonPromptQueueWait,recordDaemonSessionLifecycle,registerDaemonEventLoopLagGauge,registerDaemonGaugeCallbacks,resolveBaseUrl,resolveTelemetrySettings,shutdownTelemetry,startEventLoopLagMonitor};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2026 Qwen Team
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{isReservedStandaloneSessionSourceType,isScheduledTaskRunSource}from"./chunk-3XCRIK5A.js";import{createSessionOrganizationService}from"./chunk-IQPJOBPI.js";import{ACTIVE_WORK_CLOSE_TIMEOUT_MS}from"./chunk-WBDNGVHU.js";import{SessionNotFoundError}from"./chunk-VTZZXEWA.js";import"./chunk-L5UULTGF.js";import"./chunk-WSOEJTOC.js";import"./chunk-6JFC5M6B.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-7JWJTRP6.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-GVZ6D2NL.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-H4GDEXMF.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-34ZBUQJV.js";import"./chunk-XZACON5H.js";import"./chunk-22CLK7PK.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-SXJ2E33J.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import{SessionService}from"./chunk-LIIMQ4DI.js";import{stripTerminalControlSequences}from"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-EL5J4ESB.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-PV2VT25U.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-JCOK67LT.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-OVPEAKOQ.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-OCVRMNEQ.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import{writeStderrLine}from"./chunk-SLPJ4OII.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import{escapeXml,escapeXmlWithinBudget}from"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import{Storage}from"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{randomUUID}from"node:crypto";var log=createDebugLogger("SUB_SESSION");var MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER=16;var MAX_CONCURRENT_SUB_SESSIONS_TOTAL=24;var FIRST_TURN_TIMEOUT_MS=5*6e4;var SENT_MODE_DRAIN_TIMEOUT_MS=30*6e4;var RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS=30*6e4;var SENT_COMPLETION_DELIVERY_RETRY_MS=100;var SENT_COMPLETION_DELIVERY_MAX_RETRY_MS=3e4;var ROLLBACK_CLOSE_WATCHDOG_SLACK_MS=5e3;var MAX_RESULT_CHARS=32e3;var MAX_SENT_COMPLETION_MODEL_TEXT_CHARS=32768;var SENT_COMPLETION_RESULT_TRUNCATION_MARKER="\n[\u2026result truncated]";var MAX_NAME_LENGTH=60;var MAX_TRACKED_SPAWNED_SESSIONS=1024;var BIDI_CONTROL_MARKS=new RegExp("[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069]","g");function subSessionName(label,includeThreadGlyph=true){const cleaned=stripTerminalControlSequences(label).replace(BIDI_CONTROL_MARKS,"").trim().replace(/\s+/g," ");let short=cleaned;if(cleaned.length>MAX_NAME_LENGTH){let cut=MAX_NAME_LENGTH-1;const boundary=cleaned.charCodeAt(cut-1);if(boundary>=55296&&boundary<=56319)cut-=1;short=`${cleaned.slice(0,cut)}\u2026`}return includeThreadGlyph?`\u{1F9F5} ${short}`:short}__name(subSessionName,"subSessionName");function sentCompletionStatus(stopReason){if(stopReason==="end_turn")return"completed";if(stopReason==="cancelled"||stopReason==="shutdown"){return"cancelled"}return"failed"}__name(sentCompletionStatus,"sentCompletionStatus");function truncateCodePoints(value,max){const codePoints=Array.from(value);if(codePoints.length<=max)return value;return`${codePoints.slice(0,Math.max(0,max-1)).join("")}\u2026`}__name(truncateCodePoints,"truncateCodePoints");function buildSentCompletionNotification(sessionId,label,result,stopReason){const status=sentCompletionStatus(stopReason);const boundedStopReason=truncateCodePoints(stopReason,128);const statusText=status==="completed"?"completed":status==="cancelled"?"was cancelled":`failed (${boundedStopReason})`;const sessionLink=`[\u{1F9F5} ${sessionId.slice(0,8)}](qwen-session://${sessionId})`;const safeResult=result.trim()||`No text output (stopReason: ${stopReason}).`;const modelSessionId=truncateCodePoints(sessionId,256);const modelLabel=truncateCodePoints(label,256);const modelTextPrefix=["<task-notification>",`<task-id>${escapeXml(modelSessionId)}</task-id>`,`<status>${status}</status>`,`<summary>Sub-session &quot;${escapeXml(modelLabel)}&quot; ${escapeXml(statusText)}.</summary>`,`<session-link>qwen-session://${escapeXml(modelSessionId)}</session-link>`,"<result>"].join("");const modelTextSuffix="</result></task-notification>";const resultBudget=Math.max(0,MAX_SENT_COMPLETION_MODEL_TEXT_CHARS-modelTextPrefix.length-modelTextSuffix.length);let preview=escapeXmlWithinBudget(safeResult,resultBudget);const marker=SENT_COMPLETION_RESULT_TRUNCATION_MARKER;if(preview.truncated&&marker.length<=resultBudget){preview=escapeXmlWithinBudget(safeResult,resultBudget-marker.length);preview.text+=marker}const modelText=`${modelTextPrefix}${preview.text}${modelTextSuffix}`;return{displayText:`Sub-session ${sessionLink} ${statusText}.`,modelText,taskId:sessionId,status,kind:"agent",...modelLabel.trim()?{label:modelLabel}:{}}}__name(buildSentCompletionNotification,"buildSentCompletionNotification");function isBackgroundNotificationForTask(event,taskId){if(event.type!=="session_update")return false;const update=event.data?.update;return update?._meta?.source==="background_notification"&&update._meta.backgroundTask?.taskId===taskId}__name(isBackgroundNotificationForTask,"isBackgroundNotificationForTask");async function awaitRecoveredParentNotification(bridge,sessionId,notification,lastEventId,eventEpoch,stopSignal){const timeoutAc=new AbortController;const timer=setTimeout(()=>timeoutAc.abort(),RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS);if(typeof timer.unref==="function")timer.unref();const signal=AbortSignal.any([stopSignal,timeoutAc.signal]);let observedOwnNotification=false;try{for await(const event of bridge.subscribeEvents(sessionId,{lastEventId,epoch:eventEpoch,signal})){if(isBackgroundNotificationForTask(event,notification.taskId)){observedOwnNotification=true}else if(observedOwnNotification&&event.type==="background_notification_turn_complete"){return true}}}finally{clearTimeout(timer);timeoutAc.abort()}return false}__name(awaitRecoveredParentNotification,"awaitRecoveredParentNotification");async function waitForSentCompletionRetry(signal,attempt){if(signal.aborted)throw signal.reason;const delay=Math.min(SENT_COMPLETION_DELIVERY_RETRY_MS*2**attempt,SENT_COMPLETION_DELIVERY_MAX_RETRY_MS);await new Promise((resolve,reject)=>{const onAbort=__name(()=>{clearTimeout(timer);reject(signal.reason)},"onAbort");const timer=setTimeout(()=>{signal.removeEventListener("abort",onAbort);resolve()},delay);if(typeof timer.unref==="function")timer.unref();signal.addEventListener("abort",onAbort,{once:true})})}__name(waitForSentCompletionRetry,"waitForSentCompletionRetry");async function awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline){let lastError;let attempt=0;while(!stopSignal.aborted){try{const acknowledgement=await bridge.enqueueBackgroundNotification(parentSessionId,notification);if(acknowledgement.accepted)return"accepted"}catch(error){if(error instanceof SessionNotFoundError)return"missing";lastError=error}if(Date.now()>=deadline){throw new Error(`Parent ${parentSessionId} did not durably accept completion for sub-session ${notification.taskId}.`,lastError===void 0?void 0:{cause:lastError})}await waitForSentCompletionRetry(stopSignal,attempt);attempt+=1}throw stopSignal.reason}__name(awaitSentCompletionAcceptance,"awaitSentCompletionAcceptance");async function deliverSentCompletion(bridge,boundWorkspace,parentSessionId,notification,stopSignal,isolatedWorkspace,standaloneService){const deadline=Date.now()+RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS;const initialDelivery=await awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline);if(initialDelivery==="accepted")return;if(standaloneService){await standaloneService.resume(parentSessionId);let ownerBridge;let ownerSessionId="";let lastEventId=0;let eventEpoch="";const recoveredDelivery=await standaloneService.continueSession(parentSessionId,async(runtime,canonicalSessionId)=>{ownerBridge=runtime.bridge;ownerSessionId=canonicalSessionId;lastEventId=runtime.bridge.getSessionLastEventId(canonicalSessionId);eventEpoch=runtime.bridge.getSessionEventEpoch(canonicalSessionId);return awaitSentCompletionAcceptance(runtime.bridge,canonicalSessionId,notification,stopSignal,deadline)});if(recoveredDelivery==="missing"||!ownerBridge||!ownerSessionId){throw new SessionNotFoundError(parentSessionId)}void awaitRecoveredParentNotification(ownerBridge,ownerSessionId,notification,lastEventId,eventEpoch,stopSignal).then(continuationCompleted=>{if(!continuationCompleted&&!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation did not reach an end-turn boundary; leaving recovery attachment for the idle reaper`)}},error=>{if(!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation could not be observed: ${error instanceof Error?error.message:String(error)}`)}});return}let restoredParent;const isolatedCwd=isolatedWorkspace?await isolatedWorkspace.materializeDirectory(parentSessionId):void 0;let materializedDirectoryUnused=isolatedCwd!==void 0;try{restoredParent=await bridge.resumeSession({sessionId:parentSessionId,workspaceCwd:boundWorkspace});if(isolatedCwd!==void 0){if(restoredParent.hasActivePrompt===true&&restoredParent.currentCwd!==isolatedCwd){throw new Error("Active restored parent is outside its isolated conversation directory.")}if(restoredParent.hasActivePrompt===true){materializedDirectoryUnused=false}if(restoredParent.hasActivePrompt!==true){materializedDirectoryUnused=false;const changed=await bridge.changeSessionCwd(parentSessionId,{path:isolatedCwd,allowedRoots:[boundWorkspace],managedRelocation:"live-conversation"});if(changed.newCwd!==isolatedCwd){materializedDirectoryUnused=true;throw new Error("Restored parent workspace directory relocation was rejected.")}restoredParent.currentCwd=changed.newCwd}}const lastEventId=bridge.getSessionLastEventId(parentSessionId);const eventEpoch=bridge.getSessionEventEpoch(parentSessionId);const recoveredDelivery=await awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline);if(recoveredDelivery==="missing"){throw new SessionNotFoundError(parentSessionId)}void awaitRecoveredParentNotification(bridge,parentSessionId,notification,lastEventId,eventEpoch,stopSignal).then(continuationCompleted=>{if(!continuationCompleted&&!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation did not reach an end-turn boundary; leaving recovery attachment for the idle reaper`)}},error=>{if(!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation could not be observed: ${error instanceof Error?error.message:String(error)}`)}})}catch(error){let recoveredParentClosed=false;if(restoredParent!==void 0){try{if(restoredParent.hasActivePrompt===true){if(restoredParent.clientId){await bridge.detachClient(restoredParent.sessionId,restoredParent.clientId)}}else if(restoredParent.attached){if(restoredParent.clientId){await bridge.detachClient(restoredParent.sessionId,restoredParent.clientId)}}else{recoveredParentClosed=await bridge.killSession(restoredParent.sessionId,{requireZeroAttaches:true})}}catch{recoveredParentClosed=false}}if(isolatedWorkspace&&isolatedCwd!==void 0&&(recoveredParentClosed||materializedDirectoryUnused)){await isolatedWorkspace.discardEmptyDirectory(parentSessionId).catch(()=>{})}throw error}}__name(deliverSentCompletion,"deliverSentCompletion");async function awaitFirstTurn(bridge,sessionId,promptId,lastEventId,timeoutMs,stopSignal){const ac=new AbortController;let timedOut=false;const timer=setTimeout(()=>{timedOut=true;ac.abort()},timeoutMs);if(typeof timer.unref==="function")timer.unref();const composed=stopSignal?AbortSignal.any([ac.signal,stopSignal]):ac.signal;let acc="";let truncated=false;let stopReason;const appendChunk=__name(text=>{if(truncated)return;if(acc.length+text.length>MAX_RESULT_CHARS){let cut=Math.max(0,MAX_RESULT_CHARS-acc.length);if(cut>0){const code=text.charCodeAt(cut-1);if(code>=55296&&code<=56319)cut-=1}acc+=text.slice(0,cut);truncated=true}else{acc+=text}},"appendChunk");try{for await(const e of bridge.subscribeEvents(sessionId,{lastEventId,signal:composed})){if(e.type==="session_update"){const d=e.data;if(d?.update?.sessionUpdate==="agent_message_chunk"&&typeof d.update.content?.text==="string"&&(e.promptId===void 0||e.promptId===promptId)&&d.update._meta?.source!=="background_task_completed"&&d.update._meta?.source!=="background_notification"&&d.update._meta?.source!=="background_notification_turn_started"){appendChunk(d.update.content.text)}}else if(e.type==="turn_complete"){const d=e.data;if(d?.promptId===promptId){stopReason=d.stopReason??"end_turn";break}}else if(e.type==="turn_error"){const d=e.data;if(d?.promptId===promptId){stopReason="error";if(d.message&&!truncated){const suffix=`${acc?"\n":""}[turn error] ${d.message}`;if(acc.length+suffix.length<=MAX_RESULT_CHARS){acc+=suffix}else{truncated=true}}break}}}}finally{clearTimeout(timer);ac.abort()}if(stopReason===void 0){stopReason=stopSignal?.aborted?"shutdown":timedOut?"timeout":"incomplete"}if(truncated)acc+="\n[\u2026output truncated]";return{result:acc,stopReason}}__name(awaitFirstTurn,"awaitFirstTurn");function createSubSessionLauncher(opts){const{getBridge,getStandaloneSessionService,boundWorkspace,runtimeBaseDir,notifySentCompletion=false,isolatedWorkspace}=opts;const firstTurnTimeoutMs=opts.firstTurnTimeoutMs??FIRST_TURN_TIMEOUT_MS;const sentModeDrainTimeoutMs=opts.sentModeDrainTimeoutMs??SENT_MODE_DRAIN_TIMEOUT_MS;const maxConcurrentPerCaller=opts.maxConcurrentPerCaller??MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER;const maxConcurrentTotal=Math.min(opts.maxConcurrentTotal??MAX_CONCURRENT_SUB_SESSIONS_TOTAL,MAX_TRACKED_SPAWNED_SESSIONS);const inflight=new Map;const spawnedSessionIds=new Set;const stopAc=new AbortController;let inflightTotal=0;const release=__name(key=>{const n=(inflight.get(key)??1)-1;if(n<=0)inflight.delete(key);else inflight.set(key,n);inflightTotal=Math.max(0,inflightTotal-1)},"release");const rememberSpawned=__name(sessionId=>{spawnedSessionIds.add(sessionId);while(spawnedSessionIds.size>MAX_TRACKED_SPAWNED_SESSIONS){const oldest=spawnedSessionIds.values().next().value;if(oldest===void 0)break;spawnedSessionIds.delete(oldest)}},"rememberSpawned");const launch=__name(async info=>{if(stopAc.signal.aborted){throw new Error("The daemon is shutting down; cannot create a sub-session.")}const bridge=getBridge();if(!bridge){throw new Error("Session bridge is not available.")}const caller=bridge.getSessionSummary(info.callerSessionId);const standalone=isReservedStandaloneSessionSourceType(caller.sourceType);const standaloneService=standalone?getStandaloneSessionService?.():void 0;if(standalone&&!standaloneService){throw new Error("Standalone session service is unavailable.")}if(spawnedSessionIds.has(info.callerSessionId)||caller.parentSessionId!==void 0){throw new Error("A sub-session cannot create further sub-sessions (nesting is capped at one level).")}const key=info.callerSessionId;const current=inflight.get(key)??0;if(current>=maxConcurrentPerCaller){throw new Error(`Too many concurrent sub-sessions for this session (cap ${maxConcurrentPerCaller}); wait for one to finish.`)}if(inflightTotal>=maxConcurrentTotal){throw new Error(`Too many concurrent sub-sessions in this workspace (cap ${maxConcurrentTotal}); wait for one to finish.`)}inflight.set(key,current+1);inflightTotal+=1;let released=false;const releaseOnce=__name(()=>{if(released)return;released=true;release(key)},"releaseOnce");let spawnedSession;let promptAdmitted=false;try{const promptId=randomUUID();let lastEventId;let turn;let promptAdmission;let sub;if(standalone){const created=await standaloneService.createChildWithInitialPrompt({sessionId:randomUUID(),parentSessionId:info.callerSessionId,promptId,...info.sourceType?{sourceType:info.sourceType}:{},...info.sourceId?{sourceId:info.sourceId}:{},...info.model?{modelServiceId:info.model}:{}},info.prompt);sub=created.session;lastEventId=created.initialPrompt.lastEventId;turn=created.initialPrompt.turn}else{sub=await bridge.spawnOrAttach({workspaceCwd:boundWorkspace,sessionScope:"thread",parentSessionId:info.callerSessionId,...info.sourceType?{sourceType:info.sourceType}:{},...info.sourceId?{sourceId:info.sourceId}:{},...info.model?{modelServiceId:info.model}:{}})}spawnedSession=sub;const sessionId=sub.sessionId;if(!standalone&&isScheduledTaskRunSource(info)&&info.model&&sub.modelApplied===false){throw new Error(`sub-session model selection failed: ${info.model}`)}if(isolatedWorkspace&&!standalone){const isolatedCwd=await isolatedWorkspace.materializeDirectory(sessionId);const changed=await bridge.changeSessionCwd(sessionId,{path:isolatedCwd,allowedRoots:[boundWorkspace],managedRelocation:"live-conversation"});if(changed.newCwd!==isolatedCwd){throw new Error("Sub-session workspace directory relocation was rejected.")}}rememberSpawned(sessionId);try{bridge.updateSessionMetadata(sessionId,{displayName:subSessionName(info.name??info.prompt,!isScheduledTaskRunSource(info)),titleSource:"auto"})}catch(err){log.debug("sub-session: updateSessionMetadata failed",sessionId,err)}if(!standalone){lastEventId=bridge.getSessionLastEventId(sessionId);let markPromptAdmitted;promptAdmission=new Promise(resolve=>{markPromptAdmitted=resolve});const onPromptAdmitted=__name(()=>{promptAdmitted=true;markPromptAdmitted()},"onPromptAdmitted");turn=bridge.sendPrompt(sessionId,{sessionId,prompt:[{type:"text",text:info.prompt}]},void 0,{promptId,onPromptAdmitted})}void turn.catch(err=>{log.debug("sub-session: sendPrompt rejected",sessionId,String(err))});if(isScheduledTaskRunSource(info)&&promptAdmission){await Promise.race([promptAdmission,turn.then(()=>void 0,err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)))])}if(info.groupId){try{const assign=__name(()=>createSessionOrganizationService(boundWorkspace).updateSessionOrganization(sessionId,{groupId:info.groupId,color:null}),"assign");if(runtimeBaseDir){await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,assign)}else{await assign()}bridge.markSessionCatalogChanged()}catch(error){writeStderrLine(`qwen serve: scheduled-task session ${sessionId} could not be assigned to group ${info.groupId}: ${error instanceof Error?error.message:String(error)}`)}}if(info.completion==="sent"){const drainAc=new AbortController;const drainSignal=AbortSignal.any([stopAc.signal,drainAc.signal]);void(async()=>{try{let notification;try{const turnError=turn.then(()=>new Promise(()=>{}),err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)));const completion=await Promise.race([awaitFirstTurn(bridge,sessionId,promptId,lastEventId,sentModeDrainTimeoutMs,drainSignal),turnError]);if(stopAc.signal.aborted)return;if(completion.stopReason==="timeout"){writeStderrLine(`qwen serve: sub-session ${sessionId} drain timed out after ${Math.round(sentModeDrainTimeoutMs/6e4)}min; releasing its concurrency slot (the sub-session may still be running)`)}if(notifySentCompletion){notification=buildSentCompletionNotification(sessionId,subSessionName(info.name??info.prompt,false),completion.result,completion.stopReason)}}catch(err){if(stopAc.signal.aborted)return;if(!notifySentCompletion)return;const message=err instanceof Error?err.message:String(err);notification=buildSentCompletionNotification(sessionId,subSessionName(info.name??info.prompt,false),message,"error")}if(!notification)return;try{await deliverSentCompletion(bridge,boundWorkspace,info.callerSessionId,notification,stopAc.signal,isolatedWorkspace,standaloneService)}catch(notificationError){if(!stopAc.signal.aborted){writeStderrLine(`qwen serve: sub-session ${sessionId} completion could not be returned to parent ${info.callerSessionId}: ${notificationError instanceof Error?notificationError.message:String(notificationError)}`)}}}finally{drainAc.abort();releaseOnce()}})();return{sessionId,...sub.parentSessionPersisted!==void 0?{parentSessionPersisted:sub.parentSessionPersisted}:{}}}try{const turnError=turn.then(()=>new Promise(()=>{}),err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)));const firstTurn=awaitFirstTurn(bridge,sessionId,promptId,lastEventId,firstTurnTimeoutMs,stopAc.signal);const{result,stopReason}=await Promise.race([firstTurn,turnError]);return{sessionId,result,stopReason,...sub.parentSessionPersisted!==void 0?{parentSessionPersisted:sub.parentSessionPersisted}:{}}}finally{releaseOnce()}}catch(err){releaseOnce();if(spawnedSession!==void 0&&isolatedWorkspace&&!standalone){const sessionId=spawnedSession.sessionId;let sessionClosed=false;try{if(spawnedSession.attached){if(spawnedSession.clientId){await bridge.detachClient(sessionId,spawnedSession.clientId)}}else{sessionClosed=await bridge.killSession(sessionId,{requireZeroAttaches:true})}}catch(cleanupError){log.debug("sub-session: isolated session rollback failed",sessionId,cleanupError)}if(sessionClosed){if(!promptAdmitted){try{const removeTranscript=__name(()=>new SessionService(boundWorkspace).removeSession(sessionId),"removeTranscript");const transcriptRemoved=runtimeBaseDir?await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,removeTranscript):await removeTranscript();if(transcriptRemoved)bridge.markSessionCatalogChanged()}catch(cleanupError){log.debug("sub-session: isolated transcript cleanup failed",sessionId,cleanupError)}}try{await isolatedWorkspace.discardEmptyDirectory(sessionId)}catch(cleanupError){log.debug("sub-session: isolated workspace cleanup failed",sessionId,cleanupError)}}}else if(spawnedSession!==void 0&&!standalone){const sessionId=spawnedSession.sessionId;let sessionClosed=false;let closeTimer;try{await Promise.race([bridge.closeSession(sessionId,void 0,{reason:"sub_session_rollback",agentCloseTimeoutMs:ACTIVE_WORK_CLOSE_TIMEOUT_MS}),new Promise((_,reject)=>{closeTimer=setTimeout(()=>reject(new Error(`Timed out closing rolled-back sub-session ${sessionId}`)),ACTIVE_WORK_CLOSE_TIMEOUT_MS+ROLLBACK_CLOSE_WATCHDOG_SLACK_MS);if(typeof closeTimer.unref==="function")closeTimer.unref()})]);sessionClosed=true}catch(closeErr){log.debug("sub-session: closeSession threw",sessionId,closeErr)}finally{if(closeTimer!==void 0)clearTimeout(closeTimer)}if(!sessionClosed){try{sessionClosed=await bridge.killSession(sessionId,{requireZeroAttaches:true})}catch(killErr){log.debug("sub-session: killSession threw",sessionId,killErr)}}if(sessionClosed&&!promptAdmitted){try{const removeTranscript=__name(()=>new SessionService(boundWorkspace).removeSession(sessionId),"removeTranscript");const transcriptRemoved=runtimeBaseDir?await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,removeTranscript):await removeTranscript();if(transcriptRemoved)bridge.markSessionCatalogChanged()}catch(cleanupError){log.debug("sub-session: transcript cleanup failed",sessionId,cleanupError)}}}writeStderrLine(`qwen serve: create_sub_session failed: ${err instanceof Error?err.message:String(err)}`);throw err instanceof Error?err:new Error(String(err))}},"launch");return{launch,stop:__name(()=>{stopAc.abort()},"stop")}}__name(createSubSessionLauncher,"createSubSessionLauncher");export{MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER,MAX_CONCURRENT_SUB_SESSIONS_TOTAL,MAX_TRACKED_SPAWNED_SESSIONS,createSubSessionLauncher};
3
+ import{isReservedStandaloneSessionSourceType,isScheduledTaskRunSource}from"./chunk-3XCRIK5A.js";import{createSessionOrganizationService}from"./chunk-QHGCDHNW.js";import{ACTIVE_WORK_CLOSE_TIMEOUT_MS}from"./chunk-WBDNGVHU.js";import{SessionNotFoundError}from"./chunk-VTZZXEWA.js";import"./chunk-L5UULTGF.js";import"./chunk-WSOEJTOC.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import{SessionService}from"./chunk-LZNBHBAJ.js";import{stripTerminalControlSequences}from"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import{writeStderrLine}from"./chunk-SLPJ4OII.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import{escapeXml,escapeXmlWithinBudget}from"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import{Storage}from"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{randomUUID}from"node:crypto";var log=createDebugLogger("SUB_SESSION");var MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER=16;var MAX_CONCURRENT_SUB_SESSIONS_TOTAL=24;var FIRST_TURN_TIMEOUT_MS=5*6e4;var SENT_MODE_DRAIN_TIMEOUT_MS=30*6e4;var RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS=30*6e4;var SENT_COMPLETION_DELIVERY_RETRY_MS=100;var SENT_COMPLETION_DELIVERY_MAX_RETRY_MS=3e4;var ROLLBACK_CLOSE_WATCHDOG_SLACK_MS=5e3;var MAX_RESULT_CHARS=32e3;var MAX_SENT_COMPLETION_MODEL_TEXT_CHARS=32768;var SENT_COMPLETION_RESULT_TRUNCATION_MARKER="\n[\u2026result truncated]";var MAX_NAME_LENGTH=60;var MAX_TRACKED_SPAWNED_SESSIONS=1024;var BIDI_CONTROL_MARKS=new RegExp("[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069]","g");function subSessionName(label,includeThreadGlyph=true){const cleaned=stripTerminalControlSequences(label).replace(BIDI_CONTROL_MARKS,"").trim().replace(/\s+/g," ");let short=cleaned;if(cleaned.length>MAX_NAME_LENGTH){let cut=MAX_NAME_LENGTH-1;const boundary=cleaned.charCodeAt(cut-1);if(boundary>=55296&&boundary<=56319)cut-=1;short=`${cleaned.slice(0,cut)}\u2026`}return includeThreadGlyph?`\u{1F9F5} ${short}`:short}__name(subSessionName,"subSessionName");function sentCompletionStatus(stopReason){if(stopReason==="end_turn")return"completed";if(stopReason==="cancelled"||stopReason==="shutdown"){return"cancelled"}return"failed"}__name(sentCompletionStatus,"sentCompletionStatus");function truncateCodePoints(value,max){const codePoints=Array.from(value);if(codePoints.length<=max)return value;return`${codePoints.slice(0,Math.max(0,max-1)).join("")}\u2026`}__name(truncateCodePoints,"truncateCodePoints");function buildSentCompletionNotification(sessionId,label,result,stopReason){const status=sentCompletionStatus(stopReason);const boundedStopReason=truncateCodePoints(stopReason,128);const statusText=status==="completed"?"completed":status==="cancelled"?"was cancelled":`failed (${boundedStopReason})`;const sessionLink=`[\u{1F9F5} ${sessionId.slice(0,8)}](qwen-session://${sessionId})`;const safeResult=result.trim()||`No text output (stopReason: ${stopReason}).`;const modelSessionId=truncateCodePoints(sessionId,256);const modelLabel=truncateCodePoints(label,256);const modelTextPrefix=["<task-notification>",`<task-id>${escapeXml(modelSessionId)}</task-id>`,`<status>${status}</status>`,`<summary>Sub-session &quot;${escapeXml(modelLabel)}&quot; ${escapeXml(statusText)}.</summary>`,`<session-link>qwen-session://${escapeXml(modelSessionId)}</session-link>`,"<result>"].join("");const modelTextSuffix="</result></task-notification>";const resultBudget=Math.max(0,MAX_SENT_COMPLETION_MODEL_TEXT_CHARS-modelTextPrefix.length-modelTextSuffix.length);let preview=escapeXmlWithinBudget(safeResult,resultBudget);const marker=SENT_COMPLETION_RESULT_TRUNCATION_MARKER;if(preview.truncated&&marker.length<=resultBudget){preview=escapeXmlWithinBudget(safeResult,resultBudget-marker.length);preview.text+=marker}const modelText=`${modelTextPrefix}${preview.text}${modelTextSuffix}`;return{displayText:`Sub-session ${sessionLink} ${statusText}.`,modelText,taskId:sessionId,status,kind:"agent",...modelLabel.trim()?{label:modelLabel}:{}}}__name(buildSentCompletionNotification,"buildSentCompletionNotification");function isBackgroundNotificationForTask(event,taskId){if(event.type!=="session_update")return false;const update=event.data?.update;return update?._meta?.source==="background_notification"&&update._meta.backgroundTask?.taskId===taskId}__name(isBackgroundNotificationForTask,"isBackgroundNotificationForTask");async function awaitRecoveredParentNotification(bridge,sessionId,notification,lastEventId,eventEpoch,stopSignal){const timeoutAc=new AbortController;const timer=setTimeout(()=>timeoutAc.abort(),RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS);if(typeof timer.unref==="function")timer.unref();const signal=AbortSignal.any([stopSignal,timeoutAc.signal]);let observedOwnNotification=false;try{for await(const event of bridge.subscribeEvents(sessionId,{lastEventId,epoch:eventEpoch,signal})){if(isBackgroundNotificationForTask(event,notification.taskId)){observedOwnNotification=true}else if(observedOwnNotification&&event.type==="background_notification_turn_complete"){return true}}}finally{clearTimeout(timer);timeoutAc.abort()}return false}__name(awaitRecoveredParentNotification,"awaitRecoveredParentNotification");async function waitForSentCompletionRetry(signal,attempt){if(signal.aborted)throw signal.reason;const delay=Math.min(SENT_COMPLETION_DELIVERY_RETRY_MS*2**attempt,SENT_COMPLETION_DELIVERY_MAX_RETRY_MS);await new Promise((resolve,reject)=>{const onAbort=__name(()=>{clearTimeout(timer);reject(signal.reason)},"onAbort");const timer=setTimeout(()=>{signal.removeEventListener("abort",onAbort);resolve()},delay);if(typeof timer.unref==="function")timer.unref();signal.addEventListener("abort",onAbort,{once:true})})}__name(waitForSentCompletionRetry,"waitForSentCompletionRetry");async function awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline){let lastError;let attempt=0;while(!stopSignal.aborted){try{const acknowledgement=await bridge.enqueueBackgroundNotification(parentSessionId,notification);if(acknowledgement.accepted)return"accepted"}catch(error){if(error instanceof SessionNotFoundError)return"missing";lastError=error}if(Date.now()>=deadline){throw new Error(`Parent ${parentSessionId} did not durably accept completion for sub-session ${notification.taskId}.`,lastError===void 0?void 0:{cause:lastError})}await waitForSentCompletionRetry(stopSignal,attempt);attempt+=1}throw stopSignal.reason}__name(awaitSentCompletionAcceptance,"awaitSentCompletionAcceptance");async function deliverSentCompletion(bridge,boundWorkspace,parentSessionId,notification,stopSignal,isolatedWorkspace,standaloneService){const deadline=Date.now()+RECOVERED_PARENT_NOTIFICATION_TIMEOUT_MS;const initialDelivery=await awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline);if(initialDelivery==="accepted")return;if(standaloneService){await standaloneService.resume(parentSessionId);let ownerBridge;let ownerSessionId="";let lastEventId=0;let eventEpoch="";const recoveredDelivery=await standaloneService.continueSession(parentSessionId,async(runtime,canonicalSessionId)=>{ownerBridge=runtime.bridge;ownerSessionId=canonicalSessionId;lastEventId=runtime.bridge.getSessionLastEventId(canonicalSessionId);eventEpoch=runtime.bridge.getSessionEventEpoch(canonicalSessionId);return awaitSentCompletionAcceptance(runtime.bridge,canonicalSessionId,notification,stopSignal,deadline)});if(recoveredDelivery==="missing"||!ownerBridge||!ownerSessionId){throw new SessionNotFoundError(parentSessionId)}void awaitRecoveredParentNotification(ownerBridge,ownerSessionId,notification,lastEventId,eventEpoch,stopSignal).then(continuationCompleted=>{if(!continuationCompleted&&!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation did not reach an end-turn boundary; leaving recovery attachment for the idle reaper`)}},error=>{if(!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation could not be observed: ${error instanceof Error?error.message:String(error)}`)}});return}let restoredParent;const isolatedCwd=isolatedWorkspace?await isolatedWorkspace.materializeDirectory(parentSessionId):void 0;let materializedDirectoryUnused=isolatedCwd!==void 0;try{restoredParent=await bridge.resumeSession({sessionId:parentSessionId,workspaceCwd:boundWorkspace});if(isolatedCwd!==void 0){if(restoredParent.hasActivePrompt===true&&restoredParent.currentCwd!==isolatedCwd){throw new Error("Active restored parent is outside its isolated conversation directory.")}if(restoredParent.hasActivePrompt===true){materializedDirectoryUnused=false}if(restoredParent.hasActivePrompt!==true){materializedDirectoryUnused=false;const changed=await bridge.changeSessionCwd(parentSessionId,{path:isolatedCwd,allowedRoots:[boundWorkspace],managedRelocation:"live-conversation"});if(changed.newCwd!==isolatedCwd){materializedDirectoryUnused=true;throw new Error("Restored parent workspace directory relocation was rejected.")}restoredParent.currentCwd=changed.newCwd}}const lastEventId=bridge.getSessionLastEventId(parentSessionId);const eventEpoch=bridge.getSessionEventEpoch(parentSessionId);const recoveredDelivery=await awaitSentCompletionAcceptance(bridge,parentSessionId,notification,stopSignal,deadline);if(recoveredDelivery==="missing"){throw new SessionNotFoundError(parentSessionId)}void awaitRecoveredParentNotification(bridge,parentSessionId,notification,lastEventId,eventEpoch,stopSignal).then(continuationCompleted=>{if(!continuationCompleted&&!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation did not reach an end-turn boundary; leaving recovery attachment for the idle reaper`)}},error=>{if(!stopSignal.aborted){writeStderrLine(`qwen serve: restored parent ${parentSessionId} accepted completion for sub-session ${notification.taskId}, but its automatic continuation could not be observed: ${error instanceof Error?error.message:String(error)}`)}})}catch(error){let recoveredParentClosed=false;if(restoredParent!==void 0){try{if(restoredParent.hasActivePrompt===true){if(restoredParent.clientId){await bridge.detachClient(restoredParent.sessionId,restoredParent.clientId)}}else if(restoredParent.attached){if(restoredParent.clientId){await bridge.detachClient(restoredParent.sessionId,restoredParent.clientId)}}else{recoveredParentClosed=await bridge.killSession(restoredParent.sessionId,{requireZeroAttaches:true})}}catch{recoveredParentClosed=false}}if(isolatedWorkspace&&isolatedCwd!==void 0&&(recoveredParentClosed||materializedDirectoryUnused)){await isolatedWorkspace.discardEmptyDirectory(parentSessionId).catch(()=>{})}throw error}}__name(deliverSentCompletion,"deliverSentCompletion");async function awaitFirstTurn(bridge,sessionId,promptId,lastEventId,timeoutMs,stopSignal){const ac=new AbortController;let timedOut=false;const timer=setTimeout(()=>{timedOut=true;ac.abort()},timeoutMs);if(typeof timer.unref==="function")timer.unref();const composed=stopSignal?AbortSignal.any([ac.signal,stopSignal]):ac.signal;let acc="";let truncated=false;let stopReason;const appendChunk=__name(text=>{if(truncated)return;if(acc.length+text.length>MAX_RESULT_CHARS){let cut=Math.max(0,MAX_RESULT_CHARS-acc.length);if(cut>0){const code=text.charCodeAt(cut-1);if(code>=55296&&code<=56319)cut-=1}acc+=text.slice(0,cut);truncated=true}else{acc+=text}},"appendChunk");try{for await(const e of bridge.subscribeEvents(sessionId,{lastEventId,signal:composed})){if(e.type==="session_update"){const d=e.data;if(d?.update?.sessionUpdate==="agent_message_chunk"&&typeof d.update.content?.text==="string"&&(e.promptId===void 0||e.promptId===promptId)&&d.update._meta?.source!=="background_task_completed"&&d.update._meta?.source!=="background_notification"&&d.update._meta?.source!=="background_notification_turn_started"){appendChunk(d.update.content.text)}}else if(e.type==="turn_complete"){const d=e.data;if(d?.promptId===promptId){stopReason=d.stopReason??"end_turn";break}}else if(e.type==="turn_error"){const d=e.data;if(d?.promptId===promptId){stopReason="error";if(d.message&&!truncated){const suffix=`${acc?"\n":""}[turn error] ${d.message}`;if(acc.length+suffix.length<=MAX_RESULT_CHARS){acc+=suffix}else{truncated=true}}break}}}}finally{clearTimeout(timer);ac.abort()}if(stopReason===void 0){stopReason=stopSignal?.aborted?"shutdown":timedOut?"timeout":"incomplete"}if(truncated)acc+="\n[\u2026output truncated]";return{result:acc,stopReason}}__name(awaitFirstTurn,"awaitFirstTurn");function createSubSessionLauncher(opts){const{getBridge,getStandaloneSessionService,boundWorkspace,runtimeBaseDir,notifySentCompletion=false,isolatedWorkspace}=opts;const firstTurnTimeoutMs=opts.firstTurnTimeoutMs??FIRST_TURN_TIMEOUT_MS;const sentModeDrainTimeoutMs=opts.sentModeDrainTimeoutMs??SENT_MODE_DRAIN_TIMEOUT_MS;const maxConcurrentPerCaller=opts.maxConcurrentPerCaller??MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER;const maxConcurrentTotal=Math.min(opts.maxConcurrentTotal??MAX_CONCURRENT_SUB_SESSIONS_TOTAL,MAX_TRACKED_SPAWNED_SESSIONS);const inflight=new Map;const spawnedSessionIds=new Set;const stopAc=new AbortController;let inflightTotal=0;const release=__name(key=>{const n=(inflight.get(key)??1)-1;if(n<=0)inflight.delete(key);else inflight.set(key,n);inflightTotal=Math.max(0,inflightTotal-1)},"release");const rememberSpawned=__name(sessionId=>{spawnedSessionIds.add(sessionId);while(spawnedSessionIds.size>MAX_TRACKED_SPAWNED_SESSIONS){const oldest=spawnedSessionIds.values().next().value;if(oldest===void 0)break;spawnedSessionIds.delete(oldest)}},"rememberSpawned");const launch=__name(async info=>{if(stopAc.signal.aborted){throw new Error("The daemon is shutting down; cannot create a sub-session.")}const bridge=getBridge();if(!bridge){throw new Error("Session bridge is not available.")}const caller=bridge.getSessionSummary(info.callerSessionId);const standalone=isReservedStandaloneSessionSourceType(caller.sourceType);const standaloneService=standalone?getStandaloneSessionService?.():void 0;if(standalone&&!standaloneService){throw new Error("Standalone session service is unavailable.")}if(spawnedSessionIds.has(info.callerSessionId)||caller.parentSessionId!==void 0){throw new Error("A sub-session cannot create further sub-sessions (nesting is capped at one level).")}const key=info.callerSessionId;const current=inflight.get(key)??0;if(current>=maxConcurrentPerCaller){throw new Error(`Too many concurrent sub-sessions for this session (cap ${maxConcurrentPerCaller}); wait for one to finish.`)}if(inflightTotal>=maxConcurrentTotal){throw new Error(`Too many concurrent sub-sessions in this workspace (cap ${maxConcurrentTotal}); wait for one to finish.`)}inflight.set(key,current+1);inflightTotal+=1;let released=false;const releaseOnce=__name(()=>{if(released)return;released=true;release(key)},"releaseOnce");let spawnedSession;let promptAdmitted=false;try{const promptId=randomUUID();let lastEventId;let turn;let promptAdmission;let sub;if(standalone){const created=await standaloneService.createChildWithInitialPrompt({sessionId:randomUUID(),parentSessionId:info.callerSessionId,promptId,...info.sourceType?{sourceType:info.sourceType}:{},...info.sourceId?{sourceId:info.sourceId}:{},...info.model?{modelServiceId:info.model}:{}},info.prompt);sub=created.session;lastEventId=created.initialPrompt.lastEventId;turn=created.initialPrompt.turn}else{sub=await bridge.spawnOrAttach({workspaceCwd:boundWorkspace,sessionScope:"thread",parentSessionId:info.callerSessionId,...info.sourceType?{sourceType:info.sourceType}:{},...info.sourceId?{sourceId:info.sourceId}:{},...info.model?{modelServiceId:info.model}:{}})}spawnedSession=sub;const sessionId=sub.sessionId;if(!standalone&&isScheduledTaskRunSource(info)&&info.model&&sub.modelApplied===false){throw new Error(`sub-session model selection failed: ${info.model}`)}if(isolatedWorkspace&&!standalone){const isolatedCwd=await isolatedWorkspace.materializeDirectory(sessionId);const changed=await bridge.changeSessionCwd(sessionId,{path:isolatedCwd,allowedRoots:[boundWorkspace],managedRelocation:"live-conversation"});if(changed.newCwd!==isolatedCwd){throw new Error("Sub-session workspace directory relocation was rejected.")}}rememberSpawned(sessionId);try{bridge.updateSessionMetadata(sessionId,{displayName:subSessionName(info.name??info.prompt,!isScheduledTaskRunSource(info)),titleSource:"auto"})}catch(err){log.debug("sub-session: updateSessionMetadata failed",sessionId,err)}if(!standalone){lastEventId=bridge.getSessionLastEventId(sessionId);let markPromptAdmitted;promptAdmission=new Promise(resolve=>{markPromptAdmitted=resolve});const onPromptAdmitted=__name(()=>{promptAdmitted=true;markPromptAdmitted()},"onPromptAdmitted");turn=bridge.sendPrompt(sessionId,{sessionId,prompt:[{type:"text",text:info.prompt}]},void 0,{promptId,onPromptAdmitted})}void turn.catch(err=>{log.debug("sub-session: sendPrompt rejected",sessionId,String(err))});if(isScheduledTaskRunSource(info)&&promptAdmission){await Promise.race([promptAdmission,turn.then(()=>void 0,err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)))])}if(info.groupId){try{const assign=__name(()=>createSessionOrganizationService(boundWorkspace).updateSessionOrganization(sessionId,{groupId:info.groupId,color:null}),"assign");if(runtimeBaseDir){await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,assign)}else{await assign()}bridge.markSessionCatalogChanged()}catch(error){writeStderrLine(`qwen serve: scheduled-task session ${sessionId} could not be assigned to group ${info.groupId}: ${error instanceof Error?error.message:String(error)}`)}}if(info.completion==="sent"){const drainAc=new AbortController;const drainSignal=AbortSignal.any([stopAc.signal,drainAc.signal]);void(async()=>{try{let notification;try{const turnError=turn.then(()=>new Promise(()=>{}),err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)));const completion=await Promise.race([awaitFirstTurn(bridge,sessionId,promptId,lastEventId,sentModeDrainTimeoutMs,drainSignal),turnError]);if(stopAc.signal.aborted)return;if(completion.stopReason==="timeout"){writeStderrLine(`qwen serve: sub-session ${sessionId} drain timed out after ${Math.round(sentModeDrainTimeoutMs/6e4)}min; releasing its concurrency slot (the sub-session may still be running)`)}if(notifySentCompletion){notification=buildSentCompletionNotification(sessionId,subSessionName(info.name??info.prompt,false),completion.result,completion.stopReason)}}catch(err){if(stopAc.signal.aborted)return;if(!notifySentCompletion)return;const message=err instanceof Error?err.message:String(err);notification=buildSentCompletionNotification(sessionId,subSessionName(info.name??info.prompt,false),message,"error")}if(!notification)return;try{await deliverSentCompletion(bridge,boundWorkspace,info.callerSessionId,notification,stopAc.signal,isolatedWorkspace,standaloneService)}catch(notificationError){if(!stopAc.signal.aborted){writeStderrLine(`qwen serve: sub-session ${sessionId} completion could not be returned to parent ${info.callerSessionId}: ${notificationError instanceof Error?notificationError.message:String(notificationError)}`)}}}finally{drainAc.abort();releaseOnce()}})();return{sessionId,...sub.parentSessionPersisted!==void 0?{parentSessionPersisted:sub.parentSessionPersisted}:{}}}try{const turnError=turn.then(()=>new Promise(()=>{}),err=>Promise.reject(new Error(`sub-session dispatch failed: ${err instanceof Error?err.message:String(err)}`)));const firstTurn=awaitFirstTurn(bridge,sessionId,promptId,lastEventId,firstTurnTimeoutMs,stopAc.signal);const{result,stopReason}=await Promise.race([firstTurn,turnError]);return{sessionId,result,stopReason,...sub.parentSessionPersisted!==void 0?{parentSessionPersisted:sub.parentSessionPersisted}:{}}}finally{releaseOnce()}}catch(err){releaseOnce();if(spawnedSession!==void 0&&isolatedWorkspace&&!standalone){const sessionId=spawnedSession.sessionId;let sessionClosed=false;try{if(spawnedSession.attached){if(spawnedSession.clientId){await bridge.detachClient(sessionId,spawnedSession.clientId)}}else{sessionClosed=await bridge.killSession(sessionId,{requireZeroAttaches:true})}}catch(cleanupError){log.debug("sub-session: isolated session rollback failed",sessionId,cleanupError)}if(sessionClosed){if(!promptAdmitted){try{const removeTranscript=__name(()=>new SessionService(boundWorkspace).removeSession(sessionId),"removeTranscript");const transcriptRemoved=runtimeBaseDir?await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,removeTranscript):await removeTranscript();if(transcriptRemoved)bridge.markSessionCatalogChanged()}catch(cleanupError){log.debug("sub-session: isolated transcript cleanup failed",sessionId,cleanupError)}}try{await isolatedWorkspace.discardEmptyDirectory(sessionId)}catch(cleanupError){log.debug("sub-session: isolated workspace cleanup failed",sessionId,cleanupError)}}}else if(spawnedSession!==void 0&&!standalone){const sessionId=spawnedSession.sessionId;let sessionClosed=false;let closeTimer;try{await Promise.race([bridge.closeSession(sessionId,void 0,{reason:"sub_session_rollback",agentCloseTimeoutMs:ACTIVE_WORK_CLOSE_TIMEOUT_MS}),new Promise((_,reject)=>{closeTimer=setTimeout(()=>reject(new Error(`Timed out closing rolled-back sub-session ${sessionId}`)),ACTIVE_WORK_CLOSE_TIMEOUT_MS+ROLLBACK_CLOSE_WATCHDOG_SLACK_MS);if(typeof closeTimer.unref==="function")closeTimer.unref()})]);sessionClosed=true}catch(closeErr){log.debug("sub-session: closeSession threw",sessionId,closeErr)}finally{if(closeTimer!==void 0)clearTimeout(closeTimer)}if(!sessionClosed){try{sessionClosed=await bridge.killSession(sessionId,{requireZeroAttaches:true})}catch(killErr){log.debug("sub-session: killSession threw",sessionId,killErr)}}if(sessionClosed&&!promptAdmitted){try{const removeTranscript=__name(()=>new SessionService(boundWorkspace).removeSession(sessionId),"removeTranscript");const transcriptRemoved=runtimeBaseDir?await Storage.runWithResolvedRuntimeBaseDir(runtimeBaseDir,removeTranscript):await removeTranscript();if(transcriptRemoved)bridge.markSessionCatalogChanged()}catch(cleanupError){log.debug("sub-session: transcript cleanup failed",sessionId,cleanupError)}}}writeStderrLine(`qwen serve: create_sub_session failed: ${err instanceof Error?err.message:String(err)}`);throw err instanceof Error?err:new Error(String(err))}},"launch");return{launch,stop:__name(()=>{stopAc.abort()},"stop")}}__name(createSubSessionLauncher,"createSubSessionLauncher");export{MAX_CONCURRENT_SUB_SESSIONS_PER_CALLER,MAX_CONCURRENT_SUB_SESSIONS_TOTAL,MAX_TRACKED_SPAWNED_SESSIONS,createSubSessionLauncher};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2025 Qwen Team
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{CRON_GATE_TIMEOUT_MS,extractCommandRules,gateCommandError,nextFireTime,parseCron}from"./chunk-LIIMQ4DI.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import{buildPermissionCheckContext}from"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import{humanReadableCron}from"./chunk-QVPT37XZ.js";import{CRON_TASKS_DISPLAY_PATH}from"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-EL5J4ESB.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-PV2VT25U.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import{promptIdContext}from"./chunk-MWGB5RCF.js";import{buildShellExecWarnings,getCommandRoot,normalizeMonitorCommand}from"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-JCOK67LT.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-OVPEAKOQ.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-OCVRMNEQ.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import{BaseDeclarativeTool,BaseToolInvocation}from"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import{ToolDisplayNames,ToolNames}from"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import{getErrorMessage}from"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();function formatDays(days){return days===1?"1 day":`${days} days`}__name(formatDays,"formatDays");function recurringExpiryBlurb(maxAgeDays){if(!Number.isFinite(maxAgeDays)){return"Recurring tasks never auto-expire in this configuration \u2014 they keep firing until deleted with CronDelete. Tell the user the job runs until cancelled when scheduling recurring jobs."}const span=formatDays(maxAgeDays);return`Recurring tasks auto-expire after ${span} \u2014 they fire one final time, then are deleted. This bounds how long a forgotten schedule keeps firing. Tell the user about the ${span} limit when scheduling recurring jobs.`}__name(recurringExpiryBlurb,"recurringExpiryBlurb");var CronCreateInvocation=class extends BaseToolInvocation{constructor(config,params){super(params);this.config=config}static{__name(this,"CronCreateInvocation")}gateConfirmed=false;getDescription(){const gate=this.params.gate?` [gate: ${this.params.gate}]`:"";return`${this.params.cron}: ${this.params.prompt}${gate}`}async getConfirmationDetails(abortSignal){const gate=this.params.gate?.trim();if(!gate)return super.getConfirmationDetails(abortSignal);const normalized=normalizeMonitorCommand(gate);let permissionRules=[];try{permissionRules=[...new Set(await extractCommandRules(normalized.safetyCommand))].map(rule=>`Monitor(${rule})`)}catch{}if(permissionRules.length===0){permissionRules=[`Monitor(${normalized.safetyCommand})`]}const details={type:"exec",title:"Schedule a gated task",command:gate,rootCommand:getCommandRoot(normalized.safetyCommand)??gate,permissionRules,warnings:[`Runs unattended on this schedule (${humanReadableCron(this.params.cron)}) without further approval; the task prompt runs only when the command prints output.`,...buildShellExecWarnings(normalized.safetyCommand,gate)??[]],onConfirm:__name(async(outcome,_payload)=>{if(String(outcome).startsWith("proceed_"))this.gateConfirmed=true},"onConfirm")};return details}async assertGateApproved(gate){const pm=this.config.getPermissionManager?.();const cwd=this.config.getTargetDir();const decision=await pm?.evaluate({toolName:ToolNames.MONITOR,command:gate,cwd});if(decision==="deny"){throw new Error("The gate command is denied by a permission rule, so the task would be blocked at every fire. Remove that deny rule or choose another command.")}if(this.gateConfirmed)return;const mode=this.config.getApprovalMode();if(mode==="yolo")return;if(mode==="auto"){const toolDecision=await pm?.evaluate(buildPermissionCheckContext(ToolNames.CRON_CREATE,this.params,cwd));if(toolDecision!=="allow")return}if(decision==="allow")return;throw new Error(`The gate command was not confirmed: a saved ${ToolNames.CRON_CREATE} rule does not cover a shell command that runs unattended. Add a Monitor(...) rule for it, or remove that rule so the command can be confirmed.`)}async getDefaultPermission(){return"ask"}async execute(){const recurring=this.params.recurring!==false;const durable=this.params.durable===true;const useCurrentSession=this.params.sessionMode==="current";const prompt=this.params.prompt.trim();const gate=this.params.gate?.trim()||void 0;if(durable&&this.config.getSessionSourceType?.()==="standalone"){const message="Durable cron jobs are not supported in standalone sessions.";return{llmContent:message,returnDisplay:message,error:{message}}}const scheduler=this.config.getCronScheduler();try{parseCron(this.params.cron);nextFireTime(this.params.cron,new Date);if(useCurrentSession&&!durable){throw new Error("Current-session scheduling requires durable: true because session-only jobs cannot survive a daemon session switch.")}if(gate&&!recurring){throw new Error("A gate needs a recurring task: a one-shot whose gate prints nothing would be consumed with nothing delivered. Schedule it recurring (it still auto-expires) and delete it when done.")}if(gate)await this.assertGateApproved(gate);let job;if(useCurrentSession){const creator=this.config.getCurrentSessionScheduledTaskCreator();const promptId=promptIdContext.getStore();if(!creator||!promptId){throw new Error("current_session_scheduling_unavailable: Current-session scheduling requires an active daemon prompt.")}const created=await creator({cron:this.params.cron,prompt,recurring,promptId,...gate?{gate}:{}});if(gate&&created.gate!==gate){try{await scheduler.removeDurable(created.id)}catch(error){throw new Error(`current_session_gate_unsupported: The daemon stored task ${created.id} without its gate, and removing it failed (${getErrorMessage(error)}): it runs the prompt at every slot until deleted with cron_delete.`)}throw new Error('current_session_gate_unsupported: The daemon stored the task without its gate, so it was removed. Restart `qwen serve` on the current version, or schedule the gated task without sessionMode "current".')}if(gate)scheduler.approveGate(created.id,gate);job={id:created.id,cronExpr:created.cron}}else{const created=durable?await scheduler.createDurable(this.params.cron,prompt,recurring,gate):scheduler.create(this.params.cron,prompt,recurring,gate);if(gate)created.gateApproved=true;job=created}const display=humanReadableCron(job.cronExpr);const returnDisplay=`Scheduled ${job.id} (${display})${durable?" [durable]":""}${useCurrentSession?" [current conversation]":""}${gate?" [gated]":""}`;const where=durable?`Persisted to ${CRON_TASKS_DISPLAY_PATH}${useCurrentSession?" and bound to the current conversation":""}`:"Session-only (not written to disk, dies when Qwen Code exits)";const maxAgeDays=this.config.getCronRecurringMaxAgeDays();const expiry=Number.isFinite(maxAgeDays)?`Auto-expires after ${formatDays(maxAgeDays)}. Use CronDelete to cancel sooner.`:"Never auto-expires. Use CronDelete to cancel.";const gateNote=gate?` Gate: \`${gate}\` runs at each fire; the prompt is delivered only when it prints output, a silent run costs no turn, and a failing run is reported once, not at every fire.`:"";const llmContent=(recurring?`Scheduled recurring job ${job.id} (${job.cronExpr}). ${where}. `+expiry:`Scheduled one-shot task ${job.id} (${job.cronExpr}). ${where}. It will fire once then auto-delete.`)+gateNote;return{llmContent,returnDisplay}}catch(error){const message=getErrorMessage(error);return{llmContent:`Error creating cron job: ${message}`,returnDisplay:message,error:{message}}}}};var CronCreateTool=class _CronCreateTool extends BaseDeclarativeTool{constructor(config){const maxAgeDays=config.getCronRecurringMaxAgeDays();super(_CronCreateTool.Name,ToolDisplayNames.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
3
+ import{CRON_GATE_TIMEOUT_MS,extractCommandRules,gateCommandError,nextFireTime,parseCron}from"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import{buildPermissionCheckContext}from"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import{humanReadableCron}from"./chunk-QVPT37XZ.js";import{CRON_TASKS_DISPLAY_PATH}from"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import{promptIdContext}from"./chunk-MWGB5RCF.js";import{buildShellExecWarnings,getCommandRoot,normalizeMonitorCommand}from"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import{BaseDeclarativeTool,BaseToolInvocation}from"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import{ToolDisplayNames,ToolNames}from"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import{getErrorMessage}from"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();function formatDays(days){return days===1?"1 day":`${days} days`}__name(formatDays,"formatDays");function recurringExpiryBlurb(maxAgeDays){if(!Number.isFinite(maxAgeDays)){return"Recurring tasks never auto-expire in this configuration \u2014 they keep firing until deleted with CronDelete. Tell the user the job runs until cancelled when scheduling recurring jobs."}const span=formatDays(maxAgeDays);return`Recurring tasks auto-expire after ${span} \u2014 they fire one final time, then are deleted. This bounds how long a forgotten schedule keeps firing. Tell the user about the ${span} limit when scheduling recurring jobs.`}__name(recurringExpiryBlurb,"recurringExpiryBlurb");var CronCreateInvocation=class extends BaseToolInvocation{constructor(config,params){super(params);this.config=config}static{__name(this,"CronCreateInvocation")}gateConfirmed=false;getDescription(){const gate=this.params.gate?` [gate: ${this.params.gate}]`:"";return`${this.params.cron}: ${this.params.prompt}${gate}`}async getConfirmationDetails(abortSignal){const gate=this.params.gate?.trim();if(!gate)return super.getConfirmationDetails(abortSignal);const normalized=normalizeMonitorCommand(gate);let permissionRules=[];try{permissionRules=[...new Set(await extractCommandRules(normalized.safetyCommand))].map(rule=>`Monitor(${rule})`)}catch{}if(permissionRules.length===0){permissionRules=[`Monitor(${normalized.safetyCommand})`]}const details={type:"exec",title:"Schedule a gated task",command:gate,rootCommand:getCommandRoot(normalized.safetyCommand)??gate,permissionRules,warnings:[`Runs unattended on this schedule (${humanReadableCron(this.params.cron)}) without further approval; the task prompt runs only when the command prints output.`,...buildShellExecWarnings(normalized.safetyCommand,gate)??[]],onConfirm:__name(async(outcome,_payload)=>{if(String(outcome).startsWith("proceed_"))this.gateConfirmed=true},"onConfirm")};return details}async assertGateApproved(gate){const pm=this.config.getPermissionManager?.();const cwd=this.config.getTargetDir();const decision=await pm?.evaluate({toolName:ToolNames.MONITOR,command:gate,cwd});if(decision==="deny"){throw new Error("The gate command is denied by a permission rule, so the task would be blocked at every fire. Remove that deny rule or choose another command.")}if(this.gateConfirmed)return;const mode=this.config.getApprovalMode();if(mode==="yolo")return;if(mode==="auto"){const toolDecision=await pm?.evaluate(buildPermissionCheckContext(ToolNames.CRON_CREATE,this.params,cwd));if(toolDecision!=="allow")return}if(decision==="allow")return;throw new Error(`The gate command was not confirmed: a saved ${ToolNames.CRON_CREATE} rule does not cover a shell command that runs unattended. Add a Monitor(...) rule for it, or remove that rule so the command can be confirmed.`)}async getDefaultPermission(){return"ask"}async execute(){const recurring=this.params.recurring!==false;const durable=this.params.durable===true;const useCurrentSession=this.params.sessionMode==="current";const prompt=this.params.prompt.trim();const gate=this.params.gate?.trim()||void 0;if(durable&&this.config.getSessionSourceType?.()==="standalone"){const message="Durable cron jobs are not supported in standalone sessions.";return{llmContent:message,returnDisplay:message,error:{message}}}const scheduler=this.config.getCronScheduler();try{parseCron(this.params.cron);nextFireTime(this.params.cron,new Date);if(useCurrentSession&&!durable){throw new Error("Current-session scheduling requires durable: true because session-only jobs cannot survive a daemon session switch.")}if(gate&&!recurring){throw new Error("A gate needs a recurring task: a one-shot whose gate prints nothing would be consumed with nothing delivered. Schedule it recurring (it still auto-expires) and delete it when done.")}if(gate)await this.assertGateApproved(gate);let job;if(useCurrentSession){const creator=this.config.getCurrentSessionScheduledTaskCreator();const promptId=promptIdContext.getStore();if(!creator||!promptId){throw new Error("current_session_scheduling_unavailable: Current-session scheduling requires an active daemon prompt.")}const created=await creator({cron:this.params.cron,prompt,recurring,promptId,...gate?{gate}:{}});if(gate&&created.gate!==gate){try{await scheduler.removeDurable(created.id)}catch(error){throw new Error(`current_session_gate_unsupported: The daemon stored task ${created.id} without its gate, and removing it failed (${getErrorMessage(error)}): it runs the prompt at every slot until deleted with cron_delete.`)}throw new Error('current_session_gate_unsupported: The daemon stored the task without its gate, so it was removed. Restart `qwen serve` on the current version, or schedule the gated task without sessionMode "current".')}if(gate)scheduler.approveGate(created.id,gate);job={id:created.id,cronExpr:created.cron}}else{const created=durable?await scheduler.createDurable(this.params.cron,prompt,recurring,gate):scheduler.create(this.params.cron,prompt,recurring,gate);if(gate)created.gateApproved=true;job=created}const display=humanReadableCron(job.cronExpr);const returnDisplay=`Scheduled ${job.id} (${display})${durable?" [durable]":""}${useCurrentSession?" [current conversation]":""}${gate?" [gated]":""}`;const where=durable?`Persisted to ${CRON_TASKS_DISPLAY_PATH}${useCurrentSession?" and bound to the current conversation":""}`:"Session-only (not written to disk, dies when Qwen Code exits)";const maxAgeDays=this.config.getCronRecurringMaxAgeDays();const expiry=Number.isFinite(maxAgeDays)?`Auto-expires after ${formatDays(maxAgeDays)}. Use CronDelete to cancel sooner.`:"Never auto-expires. Use CronDelete to cancel.";const gateNote=gate?` Gate: \`${gate}\` runs at each fire; the prompt is delivered only when it prints output, a silent run costs no turn, and a failing run is reported once, not at every fire.`:"";const llmContent=(recurring?`Scheduled recurring job ${job.id} (${job.cronExpr}). ${where}. `+expiry:`Scheduled one-shot task ${job.id} (${job.cronExpr}). ${where}. It will fire once then auto-delete.`)+gateNote;return{llmContent,returnDisplay}}catch(error){const message=getErrorMessage(error);return{llmContent:`Error creating cron job: ${message}`,returnDisplay:message,error:{message}}}}};var CronCreateTool=class _CronCreateTool extends BaseDeclarativeTool{constructor(config){const maxAgeDays=config.getCronRecurringMaxAgeDays();super(_CronCreateTool.Name,ToolDisplayNames.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
4
4
 
5
5
  Uses standard 5-field cron in the user's local timezone: minute hour day-of-month month day-of-week. "0 9 * * *" means 9am local \u2014 no timezone conversion needed.
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{readSshWorkspace}from"./chunk-R7TNFTT4.js";import{EXTERNAL_TOOL_GUARD_MAX_DENIAL_REASON_CHARS,SHELL_EXECUTING_TOOL_NAMES}from"./chunk-NIEO2TBE.js";import"./chunk-6JFC5M6B.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PTHIQ7ZN.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-7JWJTRP6.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-GVZ6D2NL.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-H4GDEXMF.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-34ZBUQJV.js";import"./chunk-XZACON5H.js";import"./chunk-22CLK7PK.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-SXJ2E33J.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LIIMQ4DI.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import{GitWorktreeService}from"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-EL5J4ESB.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-PV2VT25U.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import{getShellConfiguration,splitCommands}from"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import{require_shell_quote}from"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-JCOK67LT.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-OVPEAKOQ.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import{isWithinRoot}from"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-OCVRMNEQ.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import{realpathNearestExistingAsync}from"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_shell_quote=__toESM(require_shell_quote(),1);import{realpath,readFile,stat}from"node:fs/promises";import path from"node:path";var RELOCATED_READ_ONLY_GIT_SUBCOMMANDS=new Set(["cat-file","rev-parse"]);var RELOCATED_READ_ONLY_DISQUALIFYING_FLAGS=new Set(["--filters","--output","--textconv"]);var GIT_GLOBAL_OPTIONS_WITH_VALUES=new Set(["--attr-source","--namespace","--shallow-file","--super-prefix"]);var GIT_COMMAND_CONFIG_KEY_PATTERNS=[/^alias\./,/^core\.(askpass|editor|fsmonitor|pager|sshcommand)$/,/^credential\.helper$/,/^diff\..+\.(command|textconv)$/,/^difftool\./,/^filter\./,/^core\.hookspath$/,/^gpg\.(.+\.)?program$/,/^merge\..+\.driver$/,/^mergetool\./,/^pager\./,/^sequence\.editor$/,/^uploadpack\.packobjectshook$/,/^browser\..+\.cmd$/,/^core\.gitproxy$/,/^credential\..+\.helper$/,/^diff\.external$/,/^gc\.recentobjectshook$/,/^help\.browser$/,/^interactive\.difffilter$/,/^remote\..+\.(proxy|receivepack|uploadpack)$/,/^ssh\.variant$/,/^tar\..+\.command$/,/^trailer\..+\.command$/,/^man\..+\.cmd$/,/^sendemail\.(sendmailcmd|tocmd|cccmd)$/,/^web\.browser$/,/^include\.path$/,/^includeif\..+\.path$/,/^imap\.tunnel$/,/^instaweb\.httpd$/];var GIT_DIR_ENV_KEYS=new Set(["GIT_COMMON_DIR","GIT_DIR"]);var GIT_WORK_TREE_ENV_KEYS=new Set(["GIT_INDEX_FILE","GIT_WORK_TREE"]);var GIT_UNRESOLVABLE_ENV_KEYS=new Set(["GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_ASKPASS","GIT_CONFIG","GIT_CONFIG_COUNT","GIT_CONFIG_GLOBAL","GIT_CONFIG_PARAMETERS","GIT_CONFIG_SYSTEM","GIT_EDITOR","GIT_DIFFTOOL_EXTCMD","GIT_EXTERNAL_DIFF","GIT_OBJECT_DIRECTORY","GIT_PAGER","GIT_SEQUENCE_EDITOR","GIT_SSH","GIT_SSH_COMMAND"]);var GIT_NUMBERED_CONFIG_ENV_PATTERN=/^GIT_CONFIG_(KEY|VALUE)_\d+$/;var SHELL_WRAPPER_PROGRAMS=new Set(["bash","dash","ksh","sh","zsh"]);var SHELL_WRAPPER_VALUE_FLAGS=new Set(["-o","-O"]);var WINDOWS_SHELL_PROGRAMS=new Set(["cmd","powershell","pwsh"]);var POWERSHELL_LOCATION_PROGRAMS=new Set(["set-location","sl","push-location","pop-location"]);var POWERSHELL_ENV_MUTATION_PATTERNS=[/^\$\{?env:[A-Za-z_][A-Za-z0-9_]*\}?\s*\+?=(?!=)/i,/^\[Environment\]::SetEnvironmentVariable\s*\(/i];function shellBundleRequestsCommand(flag){if(!flag.startsWith("-")||flag.startsWith("--"))return false;return flag.slice(1).includes("c")}__name(shellBundleRequestsCommand,"shellBundleRequestsCommand");function shellBundleValueFlagsBeforeCommand(flag){let consumed=0;for(const character of flag.slice(1)){if(character==="c")return consumed;if(character==="o"||character==="O")consumed++}return consumed}__name(shellBundleValueFlagsBeforeCommand,"shellBundleValueFlagsBeforeCommand");var ENV_CHDIR_FLAGS=new Set(["-C","--chdir"]);var ENV_VALUE_FLAGS=new Set(["-S","--split-string","-u","--unset"]);var ENV_KNOWN_FLAG_ONLY=new Set(["-","-0","-i","-v","--null","--ignore-environment","--debug"]);var ENV_CLEARS_ENVIRONMENT=new Set(["-","-i","--ignore-environment"]);var SUDO_VALUE_FLAGS=new Set(["-C","-D","-T","-g","-h","-p","-r","-t","-u","--chdir","--close-from","--command-timeout","--group","--host","--prompt","--role","--type","--user"]);var SUDO_CHDIR_FLAGS=new Set(["-D","--chdir"]);var SUDO_CHROOT_FLAGS=new Set(["-R","--chroot"]);var TIMEOUT_VALUE_FLAGS=new Set(["-k","-s","--kill-after","--signal"]);var PATH_RELINKING_PROGRAMS=new Set(["cp","ln","mv"]);var WIN32_PATH_RELINKING_PROGRAMS=new Set([...PATH_RELINKING_PROGRAMS,"copy","mklink","move","robocopy","xcopy"]);var PATH_EXTRACTING_PROGRAMS=new Set(["cpio","rsync","tar","unzip"]);var PROGRAMS_WITH_OWN_C_FLAG=new Set(["cmake","curl","cpio","diff","grep","install","make","patch","rsync","tar","unzip"]);var EXTERNAL_GUARD_UNSUPPORTED_TOOLS=new Set(["agent","workflow","create_sub_session","send_message"]);var DYNAMIC_RELOCATION_DENIAL="Daemon shell guard denied a mutating Git command with a dynamic repository location.";var UNPARSEABLE_COMMAND_DENIAL="Daemon shell guard denied a shell command that could not be parsed before execution.";var CMD_REWRITE_SYNTAX_DENIAL="Daemon shell guard denied a shell command containing cmd.exe rewrite syntax it cannot evaluate before execution.";var WINDOWS_UNMODELLED_SYNTAX_DENIAL="Daemon shell guard denied a shell command containing Windows shell syntax it cannot evaluate before execution.";var UNRESOLVED_TARGET_DENIAL_PREFIX="Daemon shell guard denied a mutating Git command with an unresolvable repository location: ";var OUTSIDE_TARGET_DENIAL_PREFIX="Daemon shell guard denied a mutating Git command outside the session working directory: ";var UNDECIDABLE_PAYLOAD_DENIAL="Daemon shell guard denied a shell command whose payload could not be resolved before execution.";var UNRECOGNIZED_PROGRAM_DENIAL="Daemon shell guard denied a shell command that may run a relocated Git command through an unrecognized program.";var SHADOW_REMOVAL_DENIAL="Daemon shell guard denied a shell command that removes a tracked shell definition in a way it cannot model.";var PROMPTLESS_PROVIDER_DENIAL="Managed external tool guard cannot consult an external provider without an active prompt binding.";var MAX_PAYLOAD_RECURSION_DEPTH=3;var UNVERIFIABLE_SCOPE_DENIAL_PREFIX="Daemon shell guard could not establish the execution directory of this call: ";var UNVERIFIABLE_SCOPE_DENIAL_HINT=" (a command runs only inside the session working directory or a worktree that session owns)";function envUnsetRemovesFunction(name,state){const keys=state.unsetEnvKeys;return keys!==void 0&&(keys.has(`BASH_FUNC_${name}%%`)||keys.has(`BASH_FUNC_${name}()`))}__name(envUnsetRemovesFunction,"envUnsetRemovesFunction");function sanitizeDenialPath(value,prefix,suffix=""){const stripped=[...value].filter(character=>{const code=character.charCodeAt(0);return code>=32&&!(code>=127&&code<=159)&&code!==8232&&code!==8233}).join("");const budget=EXTERNAL_TOOL_GUARD_MAX_DENIAL_REASON_CHARS-prefix.length-suffix.length;if(stripped.length<=budget)return stripped;return`${stripped.slice(0,Math.max(1,budget-1))}\u2026`}__name(sanitizeDenialPath,"sanitizeDenialPath");function denyDynamicRelocation(){return{allowed:false,reason:DYNAMIC_RELOCATION_DENIAL}}__name(denyDynamicRelocation,"denyDynamicRelocation");function denyTarget(prefix,target,suffix=""){return{allowed:false,reason:`${prefix}${sanitizeDenialPath(target,prefix,suffix)}${suffix}`}}__name(denyTarget,"denyTarget");var BRACE_EXPANSION_PATTERN=/\{[^{}]*,[^{}]*\}/;function isDynamicPathValue(token){return token===void 0||token.dynamic||token.text.includes("`")||token.text.startsWith("~")||BRACE_EXPANSION_PATTERN.test(token.text)}__name(isDynamicPathValue,"isDynamicPathValue");function leadingEnvAssignmentKey(token){const match=/^([A-Za-z_][A-Za-z0-9_]*)\+?=/.exec(token);return match?match[1]:null}__name(leadingEnvAssignmentKey,"leadingEnvAssignmentKey");function isAppendAssignment(token){return/^[A-Za-z_][A-Za-z0-9_]*\+=/.test(token)}__name(isAppendAssignment,"isAppendAssignment");function executableBaseName(token){const base=token.text.split(/[\\/]/).pop()??token.text;return base.toLowerCase().replace(/\.exe$/i,"")}__name(executableBaseName,"executableBaseName");var SUBSHELL_OPENING_OPERATORS=new Set(["(","<(",">("]);var REDIRECT_OPERATORS=new Set(["<",">",">>","<<","<<<","<>",">&","<&",">|","&>","&>>"]);var WINDOWS_CMD_BOUNDARY_CHARS=new Set([" "," ",";","|","&","<",">","(",")"]);function preserveWindowsPathSeparators(segment,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell==="bash")return segment;let single=false;let double=false;let out="";for(let index=0;index<segment.length;index++){const character=segment[index];if(single){if(character==="'")single=false;out+=character;continue}if(double){if(character==='"'){double=false}else if(character==="\\"){out+="\\\\";continue}out+=character;continue}if(character==="'"){single=true;out+=character;continue}if(character==='"'){double=true;out+=character;continue}if(character==="\\"){const next=segment[index+1];out+=next!==void 0&&WINDOWS_CMD_BOUNDARY_CHARS.has(next)?'"\\\\"':"\\\\";continue}out+=character}return out}__name(preserveWindowsPathSeparators,"preserveWindowsPathSeparators");function containsCmdRewriteSyntax(segment,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell!=="cmd")return false;let doubleQuoted=false;let percents=0;let bangs=0;for(const character of segment){if(character==='"'){doubleQuoted=!doubleQuoted;continue}if(character==="^"&&!doubleQuoted)return true;if(character==="%")percents++;else if(character==="!")bangs++}return percents>=2||bangs>=2}__name(containsCmdRewriteSyntax,"containsCmdRewriteSyntax");function containsUnmodelledWindowsSyntax(command,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell==="bash")return false;const trimmed=command.trim();if(shell==="cmd"&&trimmed.length>1&&trimmed.startsWith('"')&&trimmed.endsWith('"')&&trimmed.slice(1,-1).includes('"')){return true}let single=false;let double=false;for(let index=0;index<command.length;index++){const character=command[index];if(single){if(character==="'"){if(shell==="powershell"&&command[index+1]==="'")return true;single=false}continue}if(double){if(character==='"')double=false;continue}if(character==="'"){if(shell==="cmd")return true;single=true;continue}if(character==='"'){double=true;continue}if(character==="("||character===")")return true;if(character==="&"){if(command[index+1]==="&"){index++;continue}if(command[index+1]===">"){index+=command[index+2]===">"?2:1;continue}const previous=command[index-1];if(previous===">"||previous==="<")continue;return true}if(shell==="cmd"&&(character==="#"||character===";")){return true}if(shell==="powershell"&&command.startsWith("--%",index)){return true}if(shell==="powershell"&&POWERSHELL_ENV_MUTATION_PATTERNS.some(pattern=>pattern.test(command.slice(index)))){return true}}return false}__name(containsUnmodelledWindowsSyntax,"containsUnmodelledWindowsSyntax");function tokenizeSegment(segment,startDepth){let parsed;try{parsed=(0,import_shell_quote.parse)(segment,key=>`$${key}`)}catch{return null}let depth=startDepth;const runs=[{tokens:[],depth}];let redirectOperand=false;for(let index=0;index<parsed.length;index++){const token=parsed[index];if(typeof token==="string"){const isRedirectOperand=redirectOperand;redirectOperand=false;if(token.endsWith("$")){const next=parsed[index+1];if(next!==null&&typeof next==="object"&&"op"in next&&next.op==="("){let depth2=0;index++;for(;index<parsed.length;index++){const inner=parsed[index];if(inner!==null&&typeof inner==="object"&&"op"in inner){if(inner.op==="(")depth2++;else if(inner.op===")"){depth2--;if(depth2===0)break}}}runs.at(-1).tokens.push({text:token,dynamic:true,...isRedirectOperand?{redirect:true}:{}});continue}}runs.at(-1).tokens.push({text:token,dynamic:token.includes("$")||token.includes("`"),...isRedirectOperand?{redirect:true}:{}});continue}if(token===null||typeof token!=="object")return null;if("comment"in token)break;if(!("op"in token))return null;const op=token.op;if(op==="glob"){const pattern="pattern"in token&&typeof token.pattern==="string"?token.pattern:"";runs.at(-1).tokens.push({text:pattern,dynamic:true});continue}if(SUBSHELL_OPENING_OPERATORS.has(op)){depth++;runs.push({tokens:[],depth});continue}if(op===")"){depth=Math.max(0,depth-1);runs.push({tokens:[],depth});continue}if(REDIRECT_OPERATORS.has(op)){const tokens=runs.at(-1).tokens;const previous=tokens.at(-1);if(previous&&!previous.redirect&&/^\d+$/.test(previous.text)){tokens[tokens.length-1]={...previous,ambiguousFd:true}}redirectOperand=true;continue}runs.push({tokens:[],depth})}return{runs:runs.filter(run=>run.tokens.length>0),endDepth:depth}}__name(tokenizeSegment,"tokenizeSegment");function expandShellLocals(token,shellLocals){if(!token.dynamic||shellLocals.size===0)return token;let resolved=true;const text=token.text.replace(/\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?/g,(match,name)=>{const local=shellLocals.get(name);if(local===void 0||local.dynamic){resolved=false;return match}return local.text.slice(local.text.indexOf("=")+1)});if(text===token.text)return token;return{text,dynamic:!resolved}}__name(expandShellLocals,"expandShellLocals");function quoteForRejoin(text){if(text.length===0)return"''";if(!/[\s"'`$\\|&;<>()*?[\]{}!#~]/.test(text))return text;return`'${text.replaceAll("'",`'\\''`)}'`}__name(quoteForRejoin,"quoteForRejoin");function joinTokenTexts(tokens){return tokens.filter(token=>!token.redirect).map(token=>token.text).join(" ")}__name(joinTokenTexts,"joinTokenTexts");function joinArgvTexts(tokens){return tokens.filter(token=>!token.redirect).map(token=>quoteForRejoin(token.text)).join(" ")}__name(joinArgvTexts,"joinArgvTexts");function hasGitRelocationMarker(tokens){return tokens.some(token=>{if(token.text==="-C"||token.text.startsWith("-C"))return true;if(/^--(?:git-dir|work-tree)(?:=|$)/.test(token.text))return true;const key=leadingEnvAssignmentKey(token.text);return key!==null&&(GIT_DIR_ENV_KEYS.has(key)||GIT_WORK_TREE_ENV_KEYS.has(key)||GIT_PROGRAM_ENV_KEYS.has(key))})}__name(hasGitRelocationMarker,"hasGitRelocationMarker");var GIT_WORD_PATTERN=/\bgit\b/i;var TEXT_RELOCATION_MARKER_WITHOUT_C_PATTERN=/(^|\s)(--git-dir=?|--work-tree=?|-execdir)|(^|[\s;&|(){}])(cd|chdir|pushd)([\s;&|]|$)|(^|[\s;&|(){}])(GIT_DIR|GIT_WORK_TREE|GIT_COMMON_DIR|GIT_INDEX_FILE|GIT_EXEC_PATH|PATH)\+?=/;var TEXT_RELOCATION_MARKER_PATTERN=/(^|\s)(-C|--git-dir=?|--work-tree=?|-execdir)|(^|[\s;&|(){}])(cd|chdir|pushd)([\s;&|]|$)|(^|[\s;&|(){}])(GIT_DIR|GIT_WORK_TREE|GIT_COMMON_DIR|GIT_INDEX_FILE|GIT_EXEC_PATH|PATH)\+?=/;var GIT_PROGRAM_ENV_KEYS=new Set(["GIT_EXEC_PATH","PATH"]);function recordEnvAssignment(token,state){const rawKey=leadingEnvAssignmentKey(token.text);if(rawKey===null)return;const key=process.platform==="win32"&&getShellConfiguration().shell!=="bash"?rawKey.toUpperCase():rawKey;if(GIT_PROGRAM_ENV_KEYS.has(key)||GIT_UNRESOLVABLE_ENV_KEYS.has(key)||GIT_NUMBERED_CONFIG_ENV_PATTERN.test(key)){state.unresolved=true;return}if(!GIT_DIR_ENV_KEYS.has(key)&&!GIT_WORK_TREE_ENV_KEYS.has(key))return;const value=token.text.slice(token.text.indexOf("=")+1);if(token.dynamic||isAppendAssignment(token.text)||isDynamicPathValue({text:value,dynamic:false})){state.unresolved=true;return}state.relocations.push({target:value,kind:GIT_WORK_TREE_ENV_KEYS.has(key)?"work-tree":"git-dir"})}__name(recordEnvAssignment,"recordEnvAssignment");function attachedChdirValue(flag,set){for(const candidate of set){if(candidate.startsWith("--")&&flag.startsWith(`${candidate}=`)){return flag.slice(candidate.length+1)}if(candidate.length===2&&flag.startsWith(candidate)&&flag.length>candidate.length){return flag.slice(candidate.length)}}return void 0}__name(attachedChdirValue,"attachedChdirValue");function recordChdirValue(value,state){if(isDynamicPathValue(value)){state.unresolved=true;return}state.relocations.push({target:value.text,kind:"cwd"})}__name(recordChdirValue,"recordChdirValue");function consumeEnvWrapper(run,start,state){let index=start+1;while(index<run.length){const token=run[index];if(token.dynamic){state.unresolved=true;index++;continue}if(token.text==="--"){index++;break}if(ENV_KNOWN_FLAG_ONLY.has(token.text)){if(ENV_CLEARS_ENVIRONMENT.has(token.text)){state.clearsEnvironment=true}index++;continue}if(ENV_CHDIR_FLAGS.has(token.text)){recordChdirValue(run[index+1],state);index+=2;continue}const attached=attachedChdirValue(token.text,ENV_CHDIR_FLAGS);if(attached!==void 0){recordChdirValue({text:attached,dynamic:false},state);index++;continue}if(token.text==="-S"||token.text==="--split-string"){const payloadToken=run[index+1];if(payloadToken===void 0)return{next:run.length};if(payloadToken.dynamic)return{next:run.length,undecidable:true};const rest=joinArgvTexts(run.slice(index+2));return{next:run.length,payload:rest?`${payloadToken.text} ${rest}`:payloadToken.text}}if(/^-[A-Za-z]*S/.test(token.text)&&!token.text.startsWith("--")){const fused=token.text.slice(token.text.indexOf("S")+1);if(fused.length>0){const rest2=joinArgvTexts(run.slice(index+1));return{next:run.length,payload:rest2?`${fused} ${rest2}`:fused}}const payloadToken=run[index+1];if(payloadToken===void 0)return{next:run.length};if(payloadToken.dynamic)return{next:run.length,undecidable:true};const rest=joinArgvTexts(run.slice(index+2));return{next:run.length,payload:rest?`${payloadToken.text} ${rest}`:payloadToken.text}}if(ENV_VALUE_FLAGS.has(token.text)){const removed=run[index+1];if(removed!==void 0&&!removed.dynamic){(state.unsetEnvKeys??=new Set).add(removed.text)}index+=2;continue}if(/^-u./.test(token.text)||token.text.startsWith("--unset=")||token.text.startsWith("--split-string=")){if(token.text.startsWith("--split-string=")){const fused=token.text.slice("--split-string=".length);const rest=joinArgvTexts(run.slice(index+1));return{next:run.length,payload:rest?`${fused} ${rest}`:fused}}const removedName=token.text.startsWith("--unset=")?token.text.slice("--unset=".length):token.text.slice(2);(state.unsetEnvKeys??=new Set).add(removedName);index++;continue}if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);index++;continue}if(token.text.startsWith("-")){state.unresolved=true;index++;continue}break}return{next:index}}__name(consumeEnvWrapper,"consumeEnvWrapper");function consumeSudoWrapper(run,start,state){let index=start+1;while(index<run.length){const token=run[index];if(token.dynamic){state.unresolved=true;index++;continue}if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);index++;continue}if(!token.text.startsWith("-"))break;if(SUDO_CHDIR_FLAGS.has(token.text)){recordChdirValue(run[index+1],state);index+=2;continue}if(SUDO_CHROOT_FLAGS.has(token.text)||token.text.startsWith("--chroot=")||/^-R./.test(token.text)){state.unresolved=true;index+=SUDO_CHROOT_FLAGS.has(token.text)?2:1;continue}const attached=attachedChdirValue(token.text,SUDO_CHDIR_FLAGS);if(attached!==void 0){recordChdirValue({text:attached,dynamic:false},state);index++;continue}if(SUDO_VALUE_FLAGS.has(token.text)){index+=2;continue}index++}return{next:index}}__name(consumeSudoWrapper,"consumeSudoWrapper");function consumeTimeoutWrapper(run,start){let index=start+1;while(index<run.length){const token=run[index];if(!token.text.startsWith("-"))break;if(TIMEOUT_VALUE_FLAGS.has(token.text)&&!token.text.includes("=")){index+=2;continue}index++}if(index<run.length)index++;return index}__name(consumeTimeoutWrapper,"consumeTimeoutWrapper");function nextArgvIndex(run,from){let index=from;while(index<run.length&&(run[index].redirect||run[index].ambiguousFd)){index++}return index}__name(nextArgvIndex,"nextArgvIndex");function consumeShellWrapper(run,start){let index=start+1;while(index<run.length){const token=run[index];if(token.text==="-c"){const payloadToken=run[nextArgvIndex(run,index+1)];if(payloadToken===void 0){return{kind:"static",payload:""}}if(payloadToken.dynamic)return{kind:"dynamic"};return{kind:"static",payload:payloadToken.text}}if(token.dynamic){return{kind:"dynamic"}}if(shellBundleRequestsCommand(token.text)){const remainder=token.text.slice(token.text.indexOf("c")+1);if(remainder.length>0&&!/^[A-Za-z]+$/.test(remainder)){return{kind:"static",payload:remainder}}let payloadIndex=nextArgvIndex(run,index+1);let toSkip=shellBundleValueFlagsBeforeCommand(token.text)+(remainder.match(/[oO]/g)?.length??0);while(toSkip-- >0){payloadIndex=nextArgvIndex(run,payloadIndex+1)}const payloadToken=run[payloadIndex];if(payloadToken===void 0){return{kind:"static",payload:""}}if(payloadToken.dynamic)return{kind:"dynamic"};return{kind:"static",payload:payloadToken.text}}if(token.text.startsWith("+")){index++;continue}if(!token.text.startsWith("-"))return{kind:"none"};if(token.text==="--")return{kind:"none"};index+=SHELL_WRAPPER_VALUE_FLAGS.has(token.text)?2:1}return{kind:"none"}}__name(consumeShellWrapper,"consumeShellWrapper");var LEADING_SHELL_KEYWORDS=new Set(["{","}","!","if","then","else","elif","fi","for","do","done","while","until","in","case","esac","time","coproc"]);var EXPORT_BUILTINS=new Set(["declare","export","local","readonly","typeset"]);var CHDIR_OPTION_PATTERN=/^-[LPe@qs]+$/;var FUSED_CHDIR_PATTERN=/^(cd|chdir|pushd|popd)([./\\].*)$/i;function splitFusedWindowsChdirs(run){for(let index=0;index<run.length;index++){const token=run[index];if(token.redirect||token.ambiguousFd)continue;if(leadingEnvAssignmentKey(token.text)!==null)continue;if(LEADING_SHELL_KEYWORDS.has(token.text))continue;const match=token.dynamic?null:FUSED_CHDIR_PATTERN.exec(token.text);if(match===null)return run;const replacement=run.slice();replacement.splice(index,1,{text:match[1],dynamic:false},{text:match[2],dynamic:false});return replacement}return run}__name(splitFusedWindowsChdirs,"splitFusedWindowsChdirs");function findChdirTarget(run,start,variant,windows=false){let index=start;while(index<run.length){const token=run[index];if(token.text==="--")return run[index+1];if(windows&&/^\/[dD]$/.test(token.text)){index++;continue}if(variant==="cd"&&CHDIR_OPTION_PATTERN.test(token.text)){index++;continue}if(/^[-+]/.test(token.text))return void 0;return token}return void 0}__name(findChdirTarget,"findChdirTarget");function requestsAllExport(run,start){for(let index=start;index<run.length;index++){const token=run[index];const text=token.text;if(token.dynamic)return true;if(text==="-o"||text==="--"){if(run[index+1]?.text==="allexport")return true;continue}if(text==="allexport"||text==="--allexport")return true;if(/^-[a-zA-Z]*a/.test(text))return true}return false}__name(requestsAllExport,"requestsAllExport");function disablesAllExport(run,start){for(let index=start;index<run.length;index++){const text=run[index].text;if(text==="+o"&&run[index+1]?.text==="allexport")return true;if(/^\+[a-zA-Z]*a/.test(text))return true}return false}__name(disablesAllExport,"disablesAllExport");function readProgramWord(run){for(const token of run){if(token.redirect||token.ambiguousFd)continue;if(leadingEnvAssignmentKey(token.text)!==null)continue;if(LEADING_SHELL_KEYWORDS.has(token.text))continue;return token.text}return void 0}__name(readProgramWord,"readProgramWord");function runFromProgramWord(run){let index=0;while(index<run.length){const token=run[index];if(token.redirect||token.ambiguousFd||leadingEnvAssignmentKey(token.text)!==null||LEADING_SHELL_KEYWORDS.has(token.text)){index++;continue}break}return run.slice(index)}__name(runFromProgramWord,"runFromProgramWord");function readFunctionName(run){const body=runFromProgramWord(run);if(body.length===0)return void 0;const first=body[0].text;if(first.endsWith("()")&&first.length>2)return first.slice(0,-2);if(body[1]?.text==="()")return first;return void 0}__name(readFunctionName,"readFunctionName");function readAliasDefinitions(run){const body=runFromProgramWord(run);if(body.length===0||executableBaseName(body[0])!=="alias")return[];const definitions=[];for(const token of body.slice(1)){const separator=token.text.indexOf("=");if(separator<=0)continue;definitions.push({name:token.text.slice(0,separator),body:token.text.slice(separator+1)})}return definitions}__name(readAliasDefinitions,"readAliasDefinitions");function readDefinition(run){const body=runFromProgramWord(run);if(body.length===0)return void 0;const first=body[0].text;const name=first.endsWith("()")?first.slice(0,-2):body[1]?.text==="()"?first:void 0;if(!name)return void 0;const bodyTokens=body.slice(first.endsWith("()")?1:2).filter(token=>token.text!=="{"&&token.text!=="}");if(bodyTokens.length===0)return void 0;return{name,body:joinArgvTexts(bodyTokens)}}__name(readDefinition,"readDefinition");function analyzeRun(run,platform=process.platform){if(platform==="win32"&&getShellConfiguration().shell!=="bash"){run=splitFusedWindowsChdirs(run)}const state={relocations:[],unresolved:false};let index=0;let assignments=0;while(index<run.length&&LEADING_SHELL_KEYWORDS.has(run[index].text)){index++}while(index<run.length){const token=run[index];if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);assignments++;index++;continue}if(token.dynamic){return{kind:"dynamic-program",rest:run.slice(index),state}}const program=executableBaseName(token);if(program==="command"||program==="builtin"){index++;while(index<run.length&&run[index].text.startsWith("-"))index++;continue}if(EXPORT_BUILTINS.has(program)){const operands=run.slice(index+1);for(const operand of operands)recordEnvAssignment(operand,state);return{kind:"export",state,operands}}if(platform==="win32"&&getShellConfiguration().shell!=="bash"&&(program==="path"||program==="doskey")){state.unresolved=true;return{kind:"export",state,operands:[]}}if(platform==="win32"&&getShellConfiguration().shell!=="bash"&&(program==="set"||program==="setx")){const operands=run.slice(index+1);if(program==="setx"||getShellConfiguration().shell==="powershell"){state.unresolved=true;return{kind:"export",state,operands:[]}}for(const operand of operands){if(operand.dynamic||leadingEnvAssignmentKey(operand.text)===null){state.unresolved=true;return{kind:"export",state,operands:[]}}recordEnvAssignment(operand,state)}return{kind:"export",state,operands}}if(program==="set"){if(requestsAllExport(run,index+1)){return{kind:"all-export",state}}if(disablesAllExport(run,index+1)){return{kind:"all-export-off",state}}}if(program==="env"){const scan=consumeEnvWrapper(run,index,state);if(scan.undecidable)return{kind:"undecidable"};if(scan.payload!==void 0){return{kind:"payload",payload:scan.payload,state,propagatesCwd:false}}index=scan.next;continue}if(program==="sudo"){index=consumeSudoWrapper(run,index,state).next;continue}if(program==="timeout"){index=consumeTimeoutWrapper(run,index);continue}if(program==="eval"){const payloadTokens=run.slice(index+1);if(payloadTokens.some(payloadToken=>payloadToken.dynamic||payloadToken.ambiguousFd)){return{kind:"undecidable"}}return{kind:"payload",payload:joinTokenTexts(payloadTokens),state,propagatesCwd:true}}if(platform==="win32"&&WINDOWS_SHELL_PROGRAMS.has(program)){return{kind:"undecidable"}}if(SHELL_WRAPPER_PROGRAMS.has(program)){const scan=consumeShellWrapper(run,index);if(scan.kind==="none"){return{kind:"other",state,assignmentsOnly:false}}if(scan.kind==="dynamic")return{kind:"undecidable"};return{kind:"payload",payload:scan.payload,state,propagatesCwd:false,importsExportedFunctions:program==="bash"&&!state.clearsEnvironment}}if(program==="nohup"||program==="exec"){index++;continue}if(program==="git"){return{kind:"git",tokens:run.slice(index),state}}if(program==="cd"||program==="pushd"||program==="popd"||platform==="win32"&&program==="chdir"||platform==="win32"&&getShellConfiguration().shell==="powershell"&&POWERSHELL_LOCATION_PROGRAMS.has(program)){const variant=program==="chdir"||program==="set-location"||program==="sl"?"cd":program==="push-location"||program==="pushd"?"pushd":program==="pop-location"||program==="popd"?"popd":"cd";const rest=run.slice(index+1);const namedIndex=rest.findIndex(token2=>token2.text==="-Path"||token2.text==="-LiteralPath");return{kind:"cd",variant,target:namedIndex>=0?rest[namedIndex+1]:findChdirTarget(rest,0,variant,platform==="win32"),physical:rest.some(token2=>/^-[A-Za-z]*P/.test(token2.text))}}return{kind:"other",state,assignmentsOnly:false}}return{kind:"other",state,assignmentsOnly:assignments>0}}__name(analyzeRun,"analyzeRun");function readGitInvocation(tokens){const cwdTargets=[];const gitDirTargets=[];const workTreeTargets=[];let subcommand;let unresolved=false;let dangerousConfig=false;const recordConfigAssignment=__name(value=>{const separator=value.indexOf("=");const key=(separator>=0?value.slice(0,separator):value).toLowerCase();const assignment=separator>=0?value.slice(separator+1):"";if(GIT_COMMAND_CONFIG_KEY_PATTERNS.some(pattern=>pattern.test(key))||assignment.trimStart().startsWith("!")){dangerousConfig=true}},"recordConfigAssignment");const pushRelocation=__name((kind,value,emptyIsNoop)=>{if(value===void 0){unresolved=true;return false}if(value.text===""&&!value.dynamic){if(emptyIsNoop)return true;unresolved=true;return false}if(isDynamicPathValue(value)){unresolved=true;return true}if(kind==="cwd")cwdTargets.push(value);else if(kind==="git-dir")gitDirTargets.push(value);else workTreeTargets.push(value);return true},"pushRelocation");let index=1;while(index<tokens.length){const token=tokens[index];if(token.redirect||token.ambiguousFd){index++;continue}if(token.dynamic||BRACE_EXPANSION_PATTERN.test(token.text)){unresolved=true;index++;continue}if(token.text==="-C"){if(!pushRelocation("cwd",tokens[index+1],true))break;index+=2;continue}if(token.text==="--git-dir"||token.text==="--work-tree"){const kind=token.text==="--git-dir"?"git-dir":"work-tree";if(!pushRelocation(kind,tokens[index+1],false))break;index+=2;continue}if(token.text.length>2&&token.text.startsWith("-C")){if(!pushRelocation("cwd",{text:token.text.slice(2),dynamic:false},false)){break}index++;continue}if(token.text.startsWith("--git-dir=")||token.text.startsWith("--work-tree=")){const kind=token.text.startsWith("--git-dir=")?"git-dir":"work-tree";const value=token.text.slice(token.text.indexOf("=")+1);if(!pushRelocation(kind,{text:value,dynamic:false},false)){break}index++;continue}if(token.text==="-c"||token.text==="--config-env"){const value=tokens[index+1];if(value===void 0)break;if(value.dynamic)dangerousConfig=true;else recordConfigAssignment(value.text);index+=2;continue}if(token.text.startsWith("--config-env=")){recordConfigAssignment(token.text.slice("--config-env=".length));index++;continue}if(token.text.length>2&&token.text.startsWith("-c")&&!token.text.startsWith("--")){recordConfigAssignment(token.text.slice(2));index++;continue}if(GIT_GLOBAL_OPTIONS_WITH_VALUES.has(token.text)){if(tokens[index+1]===void 0)break;index+=2;continue}if(token.text.startsWith("-")){index++;continue}subcommand=token.text;break}const hasDisqualifyingFlag=tokens.some(token=>{const separator=token.text.indexOf("=");const flag=separator>=0?token.text.slice(0,separator):token.text;return RELOCATED_READ_ONLY_DISQUALIFYING_FLAGS.has(flag)});return{cwdTargets,gitDirTargets,workTreeTargets,subcommand,unresolved,dangerousConfig,hasDisqualifyingFlag}}__name(readGitInvocation,"readGitInvocation");async function resolveGitDirRepository(canonicalGitDir){let current=canonicalGitDir;for(let depth=0;depth<3;depth++){const stats=await stat(current);if(stats.isFile()){const[firstLine]=(await readFile(current,"utf8")).split(/\r?\n/);const match=/^gitdir:\s*(.+)$/.exec(firstLine??"");if(!match)throw new Error("unrecognized gitfile");current=path.resolve(path.dirname(current),match[1].trim());continue}if(path.basename(current)===".git"){return path.dirname(current)}if(/[/\\]\.git[/\\]worktrees[/\\][^/\\]+$/.test(current)){const worktreeGitPointer=(await readFile(path.join(current,"gitdir"),"utf8")).trim();if(!worktreeGitPointer)throw new Error("empty worktree gitdir file");return path.dirname(path.resolve(current,worktreeGitPointer))}return current}throw new Error("gitdir indirection too deep")}__name(resolveGitDirRepository,"resolveGitDirRepository");async function resolvePhysicalPath(base,target){const parsed=path.parse(target);const absolute=path.isAbsolute(target);let current=absolute?parsed.root:base;const walkable=absolute?target.slice(parsed.root.length):target;const separators=path.sep==="\\"?/[\\/]+/:/\/+/;for(const segment of walkable.split(separators)){if(segment===""||segment===".")continue;if(segment===".."){current=path.dirname(await realpathNearestExistingAsync(current));continue}current=await realpathNearestExistingAsync(path.join(current,segment))}return current}__name(resolvePhysicalPath,"resolvePhysicalPath");async function resolveDiscoveredRepository(startDirectory,boundary){let current=startDirectory;for(let depth=0;depth<64;depth++){const candidate=path.join(current,".git");let exists=true;try{await stat(candidate)}catch{exists=false}if(exists){return resolveGitDirRepository(await realpathNearestExistingAsync(candidate))}if(current===boundary)return void 0;const parent=path.dirname(current);if(parent===current)return void 0;current=parent}return void 0}__name(resolveDiscoveredRepository,"resolveDiscoveredRepository");async function evaluateGitInvocation(invocation,state,basisCwd,entryCwd,context){if(invocation.unresolved||invocation.dangerousConfig||state.unresolved||context.ambientUnresolved){return denyDynamicRelocation()}if(RELOCATED_READ_ONLY_GIT_SUBCOMMANDS.has(invocation.subcommand??"")&&!invocation.hasDisqualifyingFlag){return void 0}const cwdRelocations=[];const repositoryRelocations=[];for(const relocation of[...context.ambientRelocations,...state.relocations]){if(relocation.kind==="cwd")cwdRelocations.push(relocation);else repositoryRelocations.push(relocation)}for(const target of invocation.cwdTargets){cwdRelocations.push({target:target.text,kind:"cwd"})}for(const target of invocation.gitDirTargets){repositoryRelocations.push({target:target.text,kind:"git-dir"})}for(const target of invocation.workTreeTargets){repositoryRelocations.push({target:target.text,kind:"work-tree"})}const relocated=basisCwd===void 0||basisCwd!==entryCwd||cwdRelocations.length>0||repositoryRelocations.length>0;if(!relocated){return basisCwd===void 0?void 0:denyOutsideDiscoveredRepository(basisCwd,context)}let gitCwd=basisCwd;for(const relocation of cwdRelocations){if(gitCwd===void 0&&!path.isAbsolute(relocation.target))break;gitCwd=await resolvePhysicalPath(gitCwd??"",relocation.target)}if(gitCwd===void 0){return denyDynamicRelocation()}const checkedTargets=[];for(const relocation of repositoryRelocations){checkedTargets.push({target:path.isAbsolute(relocation.target)?relocation.target:path.resolve(gitCwd,relocation.target),kind:relocation.kind})}if(basisCwd===void 0||basisCwd!==entryCwd||cwdRelocations.length>0){checkedTargets.push({target:gitCwd,kind:"cwd"})}for(const{target,kind}of checkedTargets){const canonicalTarget=await realpathNearestExistingAsync(target);let repositoryTarget;if(kind==="git-dir"){try{repositoryTarget=await resolveGitDirRepository(canonicalTarget)}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalTarget)}}else{try{await realpath(canonicalTarget);repositoryTarget=canonicalTarget}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalTarget)}}repositoryTarget=await realpathNearestExistingAsync(repositoryTarget);if(!isWithinRoot(repositoryTarget,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,repositoryTarget)}}if(repositoryRelocations.every(relocation=>relocation.kind!=="git-dir")){const denial=await denyOutsideDiscoveredRepository(gitCwd,context);if(denial)return denial}return void 0}__name(evaluateGitInvocation,"evaluateGitInvocation");async function denyOutsideDiscoveredRepository(startDirectory,context){const canonicalStart=await realpathNearestExistingAsync(startDirectory);let discovered;try{discovered=await resolveDiscoveredRepository(canonicalStart,context.canonicalEffectiveCwd)}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalStart)}if(discovered===void 0)return void 0;const canonicalDiscovered=await realpathNearestExistingAsync(discovered);if(!isWithinRoot(canonicalDiscovered,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,canonicalDiscovered)}return void 0}__name(denyOutsideDiscoveredRepository,"denyOutsideDiscoveredRepository");function skipAnsiCQuote(segment,start){let index=start+2;while(index<segment.length&&segment[index]!=="'"){if(segment[index]==="\\")index++;index++}return index+1}__name(skipAnsiCQuote,"skipAnsiCQuote");function extractCommandSubstitutions(segment){const bodies=[];let single=false;let double=false;let index=0;while(index<segment.length){const character=segment[index];if(!single&&character==="\\"&&index+1<segment.length){index+=2;continue}if(!single&&!double&&character==="$"&&segment[index+1]==="'"){index=skipAnsiCQuote(segment,index);continue}if(!single&&character==="$"&&segment[index+1]==="("){if(segment[index+2]==="("){index+=3;continue}const end=findSubstitutionEnd(segment,index+2);if(end===-1)return null;bodies.push(segment.slice(index+2,end));index=end+1;continue}if(!single&&character==="`"){let end=index+1;while(end<segment.length&&segment[end]!=="`"){if(segment[end]==="\\")end++;end++}if(end>=segment.length)return null;bodies.push(segment.slice(index+1,end));index=end+1;continue}if(character==="'"&&!double)single=!single;else if(character==='"'&&!single)double=!double;index++}return bodies}__name(extractCommandSubstitutions,"extractCommandSubstitutions");function findSubstitutionEnd(segment,start){let single=false;let double=false;let depth=0;for(let index=start;index<segment.length;index++){const character=segment[index];if(!single&&character==="\\"){index++;continue}if(!single&&!double&&character==="$"&&segment[index+1]==="'"){index=skipAnsiCQuote(segment,index)-1;continue}if(character==="'"&&!double){single=!single;continue}if(character==='"'&&!single){double=!double;continue}if(single||double)continue;if(character==="(")depth++;else if(character===")"){if(depth===0)return index;depth--}}return-1}__name(findSubstitutionEnd,"findSubstitutionEnd");async function evaluateUnrecognizedRun(run,state,basisCwd,context,relink){if(!run.some(token=>GIT_WORD_PATTERN.test(token.text)))return void 0;if(relink?.gitDir){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const gitIndex=run.findIndex(token=>executableBaseName(token)==="git");if(gitIndex>=0&&readGitInvocation(run.slice(gitIndex)).dangerousConfig){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const ownsCFlag=run.length>0&&PROGRAMS_WITH_OWN_C_FLAG.has(executableBaseName(run[0]));if(!ownsCFlag&&hasGitRelocationMarker(run)||run.some(token=>(ownsCFlag?TEXT_RELOCATION_MARKER_WITHOUT_C_PATTERN:TEXT_RELOCATION_MARKER_PATTERN).test(token.text))||state.relocations.length>0||state.unresolved||context.ambientRelocations.length>0||context.ambientUnresolved){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}if(basisCwd===void 0){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const canonicalBasis=await realpathNearestExistingAsync(basisCwd);if(!isWithinRoot(canonicalBasis,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,canonicalBasis)}return denyOutsideDiscoveredRepository(canonicalBasis,context)}__name(evaluateUnrecognizedRun,"evaluateUnrecognizedRun");function stripHeredocBodies(command){const lines=command.split("\n");const out=[];for(let index=0;index<lines.length;index++){const line=lines[index];out.push(line);const match=/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/.exec(line);if(!match)continue;const delimiter=match[2];const stripTabs=line.includes("<<-");while(index+1<lines.length){index++;const body=lines[index];const trimmed=stripTabs?body.replace(/^\t+/,""):body;if(trimmed===delimiter)break}}return out.join("\n")}__name(stripHeredocBodies,"stripHeredocBodies");function readTopLevelSeparators(command){const separators=[];let single=false;let double=false;let backtick=false;let substitution=0;const quoteStack=[];for(let index=0;index<command.length;index++){const character=command[index];const next=command[index+1];if(!single&&character==="\\"&&index+1<command.length){index++;continue}if(!single&&character==="`"){backtick=!backtick;continue}if(!single&&!backtick&&character==="$"&&next==="("){quoteStack.push([single,double]);single=false;double=false;substitution++;index++;continue}if(!backtick&&substitution>0&&character===")"&&!single&&!double){const enclosing=quoteStack.pop();single=enclosing?.[0]??false;double=enclosing?.[1]??false;substitution--;continue}if(!backtick&&character==="'"&&!double){single=!single;continue}if(!backtick&&character==='"'&&!single){double=!double;continue}if(single||double||backtick||substitution>0)continue;if(character==="&"&&next==="&"){separators.push("&&");index++}else if(character==="&"&&next===">"){index+=command[index+2]===">"?2:1}else if(character==="&"&&(command[index-1]===">"||command[index-1]==="<")){}else if(character==="&"){separators.push("&")}else if(character==="|"&&next==="|"){separators.push("||");index++}else if(character==="|"){separators.push(command[index-1]===">"?">|":"|")}else if(character===";"){separators.push(";")}else if(character==="\n"){separators.push("\n")}}return separators}__name(readTopLevelSeparators,"readTopLevelSeparators");async function evaluateCommandWithCwd(command,startCwd,entryCwd,context,depth,scope={relink:{targets:[],gitDir:false}}){let trackedCwd=startCwd;const exported={relocations:[],unresolved:false};let allExport=scope.allExport??false;const shellLocals=scope.locals??new Map;const definedBodies=scope.definedBodies??new Map;const exportedNames=scope.exportedNames??new Set;const gitShapedNames=scope.gitShapedNames??new Set;const exportedFunctions=scope.exportedFunctions??new Set;let insideDefinition;let definitionBody="";const relinkedTargets=scope.relink.targets;const activeContext=__name(()=>exported.relocations.length>0||exported.unresolved?{canonicalEffectiveCwd:context.canonicalEffectiveCwd,ambientRelocations:[...context.ambientRelocations,...exported.relocations],ambientUnresolved:context.ambientUnresolved||exported.unresolved}:context,"activeContext");let subshellDepth=0;const snapshotShellState=__name(()=>({cwd:trackedCwd,relocations:[...exported.relocations],unresolved:exported.unresolved,allExport,locals:[...shellLocals]}),"snapshotShellState");const restoreShellState=__name(snapshot=>{if(snapshot===void 0)return;trackedCwd=snapshot.cwd;exported.relocations.length=0;exported.relocations.push(...snapshot.relocations);exported.unresolved=snapshot.unresolved;allExport=snapshot.allExport;shellLocals.clear();for(const[key,token]of snapshot.locals)shellLocals.set(key,token)},"restoreShellState");const subshellCwds=[];const invokeDefinedBody=__name(async(programToken,run)=>{const defined=definedBodies.get(programToken);if(depth>=MAX_PAYLOAD_RECURSION_DEPTH)return denyDynamicRelocation();let replay=defined.body;const programIndex=run.findIndex(token=>!token.redirect&&!token.ambiguousFd&&token.text===programToken);if(defined.alias){const args=joinArgvTexts(run.slice(programIndex+1));if(args.length>0)replay=`${replay} ${args}`}const prefix={relocations:[],unresolved:false};for(const token of run.slice(0,programIndex)){if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,prefix)}}const base=activeContext();const bodyContext=prefix.relocations.length>0||prefix.unresolved?{canonicalEffectiveCwd:base.canonicalEffectiveCwd,ambientRelocations:[...base.ambientRelocations,...prefix.relocations],ambientUnresolved:base.ambientUnresolved||prefix.unresolved}:base;const nested=await evaluateCommandWithCwd(replay,trackedCwd,entryCwd,bodyContext,depth+1,{relink:scope.relink,locals:shellLocals,exportedNames,allExport,definedBodies,gitShapedNames,exportedFunctions});if(nested.denial)return nested.denial;trackedCwd=nested.cwdAfter;if(nested.exportedAfter){exported.relocations.push(...nested.exportedAfter.relocations);if(nested.exportedAfter.unresolved)exported.unresolved=true}if(nested.allExportAfter!==void 0)allExport=nested.allExportAfter;for(const[key,token]of nested.shellLocalsAfter??[]){shellLocals.set(key,token)}return void 0},"invokeDefinedBody");const platformNow=process.platform;const shellNow=getShellConfiguration().shell;const windowsNative=platformNow==="win32"&&shellNow!=="bash";const strippedCommand=windowsNative?command:stripHeredocBodies(command);if(containsCmdRewriteSyntax(strippedCommand,platformNow,shellNow)){return{denial:{allowed:false,reason:CMD_REWRITE_SYNTAX_DENIAL},cwdAfter:trackedCwd}}if(containsUnmodelledWindowsSyntax(strippedCommand,platformNow,shellNow)){return{denial:{allowed:false,reason:WINDOWS_UNMODELLED_SYNTAX_DENIAL},cwdAfter:trackedCwd}}const normalizedCommand=preserveWindowsPathSeparators(strippedCommand,platformNow,shellNow);const segments=splitCommands(normalizedCommand);const separators=readTopLevelSeparators(normalizedCommand);const separatorsMatch=separators.length===segments.length-1;const isPipeComponent=__name(index=>windowsNative&&shellNow==="powershell"?false:separatorsMatch?separators[index-1]==="|"||separators[index]==="|"||separators[index]==="&":separators.some(separator=>separator==="|"||separator==="&"),"isPipeComponent");for(const[segmentIndex,segment]of segments.entries()){const pipeComponent=isPipeComponent(segmentIndex);const cwdBeforeSegment=trackedCwd;const definedBodiesBefore=pipeComponent?new Map(definedBodies):void 0;const gitShapedNamesBefore=pipeComponent?new Set(gitShapedNames):void 0;const exportedNamesBefore=pipeComponent?new Set(exportedNames):void 0;const exportedFunctionsBefore=pipeComponent?new Set(exportedFunctions):void 0;const shellLocalsBefore=pipeComponent?new Map(shellLocals):void 0;const exportedBefore=pipeComponent?{relocations:[...exported.relocations],unresolved:exported.unresolved}:void 0;const allExportBefore=allExport;const substitutions=extractCommandSubstitutions(segment);const tokenized=substitutions===null?null:tokenizeSegment(segment,subshellDepth);const runs=tokenized?.runs??null;if(runs===null){return{denial:{allowed:false,reason:UNPARSEABLE_COMMAND_DENIAL},cwdAfter:trackedCwd}}const functionHeader=windowsNative?null:/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*\)/.exec(segment)??/^\s*function\s+([A-Za-z_][A-Za-z0-9_]*)\b/.exec(segment);if(functionHeader){insideDefinition=functionHeader[1];const braceAt=segment.indexOf("{");definitionBody=braceAt>=0?segment.slice(braceAt+1):""}else if(insideDefinition!==void 0){definitionBody+=`
3
+ import{readSshWorkspace}from"./chunk-R7TNFTT4.js";import{EXTERNAL_TOOL_GUARD_MAX_DENIAL_REASON_CHARS,SHELL_EXECUTING_TOOL_NAMES}from"./chunk-NIEO2TBE.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PTHIQ7ZN.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import{GitWorktreeService}from"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import{getShellConfiguration,splitCommands}from"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import{require_shell_quote}from"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import{isWithinRoot}from"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import{realpathNearestExistingAsync}from"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_shell_quote=__toESM(require_shell_quote(),1);import{realpath,readFile,stat}from"node:fs/promises";import path from"node:path";var RELOCATED_READ_ONLY_GIT_SUBCOMMANDS=new Set(["cat-file","rev-parse"]);var RELOCATED_READ_ONLY_DISQUALIFYING_FLAGS=new Set(["--filters","--output","--textconv"]);var GIT_GLOBAL_OPTIONS_WITH_VALUES=new Set(["--attr-source","--namespace","--shallow-file","--super-prefix"]);var GIT_COMMAND_CONFIG_KEY_PATTERNS=[/^alias\./,/^core\.(askpass|editor|fsmonitor|pager|sshcommand)$/,/^credential\.helper$/,/^diff\..+\.(command|textconv)$/,/^difftool\./,/^filter\./,/^core\.hookspath$/,/^gpg\.(.+\.)?program$/,/^merge\..+\.driver$/,/^mergetool\./,/^pager\./,/^sequence\.editor$/,/^uploadpack\.packobjectshook$/,/^browser\..+\.cmd$/,/^core\.gitproxy$/,/^credential\..+\.helper$/,/^diff\.external$/,/^gc\.recentobjectshook$/,/^help\.browser$/,/^interactive\.difffilter$/,/^remote\..+\.(proxy|receivepack|uploadpack)$/,/^ssh\.variant$/,/^tar\..+\.command$/,/^trailer\..+\.command$/,/^man\..+\.cmd$/,/^sendemail\.(sendmailcmd|tocmd|cccmd)$/,/^web\.browser$/,/^include\.path$/,/^includeif\..+\.path$/,/^imap\.tunnel$/,/^instaweb\.httpd$/];var GIT_DIR_ENV_KEYS=new Set(["GIT_COMMON_DIR","GIT_DIR"]);var GIT_WORK_TREE_ENV_KEYS=new Set(["GIT_INDEX_FILE","GIT_WORK_TREE"]);var GIT_UNRESOLVABLE_ENV_KEYS=new Set(["GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_ASKPASS","GIT_CONFIG","GIT_CONFIG_COUNT","GIT_CONFIG_GLOBAL","GIT_CONFIG_PARAMETERS","GIT_CONFIG_SYSTEM","GIT_EDITOR","GIT_DIFFTOOL_EXTCMD","GIT_EXTERNAL_DIFF","GIT_OBJECT_DIRECTORY","GIT_PAGER","GIT_SEQUENCE_EDITOR","GIT_SSH","GIT_SSH_COMMAND"]);var GIT_NUMBERED_CONFIG_ENV_PATTERN=/^GIT_CONFIG_(KEY|VALUE)_\d+$/;var SHELL_WRAPPER_PROGRAMS=new Set(["bash","dash","ksh","sh","zsh"]);var SHELL_WRAPPER_VALUE_FLAGS=new Set(["-o","-O"]);var WINDOWS_SHELL_PROGRAMS=new Set(["cmd","powershell","pwsh"]);var POWERSHELL_LOCATION_PROGRAMS=new Set(["set-location","sl","push-location","pop-location"]);var POWERSHELL_ENV_MUTATION_PATTERNS=[/^\$\{?env:[A-Za-z_][A-Za-z0-9_]*\}?\s*\+?=(?!=)/i,/^\[Environment\]::SetEnvironmentVariable\s*\(/i];function shellBundleRequestsCommand(flag){if(!flag.startsWith("-")||flag.startsWith("--"))return false;return flag.slice(1).includes("c")}__name(shellBundleRequestsCommand,"shellBundleRequestsCommand");function shellBundleValueFlagsBeforeCommand(flag){let consumed=0;for(const character of flag.slice(1)){if(character==="c")return consumed;if(character==="o"||character==="O")consumed++}return consumed}__name(shellBundleValueFlagsBeforeCommand,"shellBundleValueFlagsBeforeCommand");var ENV_CHDIR_FLAGS=new Set(["-C","--chdir"]);var ENV_VALUE_FLAGS=new Set(["-S","--split-string","-u","--unset"]);var ENV_KNOWN_FLAG_ONLY=new Set(["-","-0","-i","-v","--null","--ignore-environment","--debug"]);var ENV_CLEARS_ENVIRONMENT=new Set(["-","-i","--ignore-environment"]);var SUDO_VALUE_FLAGS=new Set(["-C","-D","-T","-g","-h","-p","-r","-t","-u","--chdir","--close-from","--command-timeout","--group","--host","--prompt","--role","--type","--user"]);var SUDO_CHDIR_FLAGS=new Set(["-D","--chdir"]);var SUDO_CHROOT_FLAGS=new Set(["-R","--chroot"]);var TIMEOUT_VALUE_FLAGS=new Set(["-k","-s","--kill-after","--signal"]);var PATH_RELINKING_PROGRAMS=new Set(["cp","ln","mv"]);var WIN32_PATH_RELINKING_PROGRAMS=new Set([...PATH_RELINKING_PROGRAMS,"copy","mklink","move","robocopy","xcopy"]);var PATH_EXTRACTING_PROGRAMS=new Set(["cpio","rsync","tar","unzip"]);var PROGRAMS_WITH_OWN_C_FLAG=new Set(["cmake","curl","cpio","diff","grep","install","make","patch","rsync","tar","unzip"]);var EXTERNAL_GUARD_UNSUPPORTED_TOOLS=new Set(["agent","workflow","create_sub_session","send_message"]);var DYNAMIC_RELOCATION_DENIAL="Daemon shell guard denied a mutating Git command with a dynamic repository location.";var UNPARSEABLE_COMMAND_DENIAL="Daemon shell guard denied a shell command that could not be parsed before execution.";var CMD_REWRITE_SYNTAX_DENIAL="Daemon shell guard denied a shell command containing cmd.exe rewrite syntax it cannot evaluate before execution.";var WINDOWS_UNMODELLED_SYNTAX_DENIAL="Daemon shell guard denied a shell command containing Windows shell syntax it cannot evaluate before execution.";var UNRESOLVED_TARGET_DENIAL_PREFIX="Daemon shell guard denied a mutating Git command with an unresolvable repository location: ";var OUTSIDE_TARGET_DENIAL_PREFIX="Daemon shell guard denied a mutating Git command outside the session working directory: ";var UNDECIDABLE_PAYLOAD_DENIAL="Daemon shell guard denied a shell command whose payload could not be resolved before execution.";var UNRECOGNIZED_PROGRAM_DENIAL="Daemon shell guard denied a shell command that may run a relocated Git command through an unrecognized program.";var SHADOW_REMOVAL_DENIAL="Daemon shell guard denied a shell command that removes a tracked shell definition in a way it cannot model.";var PROMPTLESS_PROVIDER_DENIAL="Managed external tool guard cannot consult an external provider without an active prompt binding.";var MAX_PAYLOAD_RECURSION_DEPTH=3;var UNVERIFIABLE_SCOPE_DENIAL_PREFIX="Daemon shell guard could not establish the execution directory of this call: ";var UNVERIFIABLE_SCOPE_DENIAL_HINT=" (a command runs only inside the session working directory or a worktree that session owns)";function envUnsetRemovesFunction(name,state){const keys=state.unsetEnvKeys;return keys!==void 0&&(keys.has(`BASH_FUNC_${name}%%`)||keys.has(`BASH_FUNC_${name}()`))}__name(envUnsetRemovesFunction,"envUnsetRemovesFunction");function sanitizeDenialPath(value,prefix,suffix=""){const stripped=[...value].filter(character=>{const code=character.charCodeAt(0);return code>=32&&!(code>=127&&code<=159)&&code!==8232&&code!==8233}).join("");const budget=EXTERNAL_TOOL_GUARD_MAX_DENIAL_REASON_CHARS-prefix.length-suffix.length;if(stripped.length<=budget)return stripped;return`${stripped.slice(0,Math.max(1,budget-1))}\u2026`}__name(sanitizeDenialPath,"sanitizeDenialPath");function denyDynamicRelocation(){return{allowed:false,reason:DYNAMIC_RELOCATION_DENIAL}}__name(denyDynamicRelocation,"denyDynamicRelocation");function denyTarget(prefix,target,suffix=""){return{allowed:false,reason:`${prefix}${sanitizeDenialPath(target,prefix,suffix)}${suffix}`}}__name(denyTarget,"denyTarget");var BRACE_EXPANSION_PATTERN=/\{[^{}]*,[^{}]*\}/;function isDynamicPathValue(token){return token===void 0||token.dynamic||token.text.includes("`")||token.text.startsWith("~")||BRACE_EXPANSION_PATTERN.test(token.text)}__name(isDynamicPathValue,"isDynamicPathValue");function leadingEnvAssignmentKey(token){const match=/^([A-Za-z_][A-Za-z0-9_]*)\+?=/.exec(token);return match?match[1]:null}__name(leadingEnvAssignmentKey,"leadingEnvAssignmentKey");function isAppendAssignment(token){return/^[A-Za-z_][A-Za-z0-9_]*\+=/.test(token)}__name(isAppendAssignment,"isAppendAssignment");function executableBaseName(token){const base=token.text.split(/[\\/]/).pop()??token.text;return base.toLowerCase().replace(/\.exe$/i,"")}__name(executableBaseName,"executableBaseName");var SUBSHELL_OPENING_OPERATORS=new Set(["(","<(",">("]);var REDIRECT_OPERATORS=new Set(["<",">",">>","<<","<<<","<>",">&","<&",">|","&>","&>>"]);var WINDOWS_CMD_BOUNDARY_CHARS=new Set([" "," ",";","|","&","<",">","(",")"]);function preserveWindowsPathSeparators(segment,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell==="bash")return segment;let single=false;let double=false;let out="";for(let index=0;index<segment.length;index++){const character=segment[index];if(single){if(character==="'")single=false;out+=character;continue}if(double){if(character==='"'){double=false}else if(character==="\\"){out+="\\\\";continue}out+=character;continue}if(character==="'"){single=true;out+=character;continue}if(character==='"'){double=true;out+=character;continue}if(character==="\\"){const next=segment[index+1];out+=next!==void 0&&WINDOWS_CMD_BOUNDARY_CHARS.has(next)?'"\\\\"':"\\\\";continue}out+=character}return out}__name(preserveWindowsPathSeparators,"preserveWindowsPathSeparators");function containsCmdRewriteSyntax(segment,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell!=="cmd")return false;let doubleQuoted=false;let percents=0;let bangs=0;for(const character of segment){if(character==='"'){doubleQuoted=!doubleQuoted;continue}if(character==="^"&&!doubleQuoted)return true;if(character==="%")percents++;else if(character==="!")bangs++}return percents>=2||bangs>=2}__name(containsCmdRewriteSyntax,"containsCmdRewriteSyntax");function containsUnmodelledWindowsSyntax(command,platform=process.platform,shell=getShellConfiguration().shell){if(platform!=="win32"||shell==="bash")return false;const trimmed=command.trim();if(shell==="cmd"&&trimmed.length>1&&trimmed.startsWith('"')&&trimmed.endsWith('"')&&trimmed.slice(1,-1).includes('"')){return true}let single=false;let double=false;for(let index=0;index<command.length;index++){const character=command[index];if(single){if(character==="'"){if(shell==="powershell"&&command[index+1]==="'")return true;single=false}continue}if(double){if(character==='"')double=false;continue}if(character==="'"){if(shell==="cmd")return true;single=true;continue}if(character==='"'){double=true;continue}if(character==="("||character===")")return true;if(character==="&"){if(command[index+1]==="&"){index++;continue}if(command[index+1]===">"){index+=command[index+2]===">"?2:1;continue}const previous=command[index-1];if(previous===">"||previous==="<")continue;return true}if(shell==="cmd"&&(character==="#"||character===";")){return true}if(shell==="powershell"&&command.startsWith("--%",index)){return true}if(shell==="powershell"&&POWERSHELL_ENV_MUTATION_PATTERNS.some(pattern=>pattern.test(command.slice(index)))){return true}}return false}__name(containsUnmodelledWindowsSyntax,"containsUnmodelledWindowsSyntax");function tokenizeSegment(segment,startDepth){let parsed;try{parsed=(0,import_shell_quote.parse)(segment,key=>`$${key}`)}catch{return null}let depth=startDepth;const runs=[{tokens:[],depth}];let redirectOperand=false;for(let index=0;index<parsed.length;index++){const token=parsed[index];if(typeof token==="string"){const isRedirectOperand=redirectOperand;redirectOperand=false;if(token.endsWith("$")){const next=parsed[index+1];if(next!==null&&typeof next==="object"&&"op"in next&&next.op==="("){let depth2=0;index++;for(;index<parsed.length;index++){const inner=parsed[index];if(inner!==null&&typeof inner==="object"&&"op"in inner){if(inner.op==="(")depth2++;else if(inner.op===")"){depth2--;if(depth2===0)break}}}runs.at(-1).tokens.push({text:token,dynamic:true,...isRedirectOperand?{redirect:true}:{}});continue}}runs.at(-1).tokens.push({text:token,dynamic:token.includes("$")||token.includes("`"),...isRedirectOperand?{redirect:true}:{}});continue}if(token===null||typeof token!=="object")return null;if("comment"in token)break;if(!("op"in token))return null;const op=token.op;if(op==="glob"){const pattern="pattern"in token&&typeof token.pattern==="string"?token.pattern:"";runs.at(-1).tokens.push({text:pattern,dynamic:true});continue}if(SUBSHELL_OPENING_OPERATORS.has(op)){depth++;runs.push({tokens:[],depth});continue}if(op===")"){depth=Math.max(0,depth-1);runs.push({tokens:[],depth});continue}if(REDIRECT_OPERATORS.has(op)){const tokens=runs.at(-1).tokens;const previous=tokens.at(-1);if(previous&&!previous.redirect&&/^\d+$/.test(previous.text)){tokens[tokens.length-1]={...previous,ambiguousFd:true}}redirectOperand=true;continue}runs.push({tokens:[],depth})}return{runs:runs.filter(run=>run.tokens.length>0),endDepth:depth}}__name(tokenizeSegment,"tokenizeSegment");function expandShellLocals(token,shellLocals){if(!token.dynamic||shellLocals.size===0)return token;let resolved=true;const text=token.text.replace(/\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?/g,(match,name)=>{const local=shellLocals.get(name);if(local===void 0||local.dynamic){resolved=false;return match}return local.text.slice(local.text.indexOf("=")+1)});if(text===token.text)return token;return{text,dynamic:!resolved}}__name(expandShellLocals,"expandShellLocals");function quoteForRejoin(text){if(text.length===0)return"''";if(!/[\s"'`$\\|&;<>()*?[\]{}!#~]/.test(text))return text;return`'${text.replaceAll("'",`'\\''`)}'`}__name(quoteForRejoin,"quoteForRejoin");function joinTokenTexts(tokens){return tokens.filter(token=>!token.redirect).map(token=>token.text).join(" ")}__name(joinTokenTexts,"joinTokenTexts");function joinArgvTexts(tokens){return tokens.filter(token=>!token.redirect).map(token=>quoteForRejoin(token.text)).join(" ")}__name(joinArgvTexts,"joinArgvTexts");function hasGitRelocationMarker(tokens){return tokens.some(token=>{if(token.text==="-C"||token.text.startsWith("-C"))return true;if(/^--(?:git-dir|work-tree)(?:=|$)/.test(token.text))return true;const key=leadingEnvAssignmentKey(token.text);return key!==null&&(GIT_DIR_ENV_KEYS.has(key)||GIT_WORK_TREE_ENV_KEYS.has(key)||GIT_PROGRAM_ENV_KEYS.has(key))})}__name(hasGitRelocationMarker,"hasGitRelocationMarker");var GIT_WORD_PATTERN=/\bgit\b/i;var TEXT_RELOCATION_MARKER_WITHOUT_C_PATTERN=/(^|\s)(--git-dir=?|--work-tree=?|-execdir)|(^|[\s;&|(){}])(cd|chdir|pushd)([\s;&|]|$)|(^|[\s;&|(){}])(GIT_DIR|GIT_WORK_TREE|GIT_COMMON_DIR|GIT_INDEX_FILE|GIT_EXEC_PATH|PATH)\+?=/;var TEXT_RELOCATION_MARKER_PATTERN=/(^|\s)(-C|--git-dir=?|--work-tree=?|-execdir)|(^|[\s;&|(){}])(cd|chdir|pushd)([\s;&|]|$)|(^|[\s;&|(){}])(GIT_DIR|GIT_WORK_TREE|GIT_COMMON_DIR|GIT_INDEX_FILE|GIT_EXEC_PATH|PATH)\+?=/;var GIT_PROGRAM_ENV_KEYS=new Set(["GIT_EXEC_PATH","PATH"]);function recordEnvAssignment(token,state){const rawKey=leadingEnvAssignmentKey(token.text);if(rawKey===null)return;const key=process.platform==="win32"&&getShellConfiguration().shell!=="bash"?rawKey.toUpperCase():rawKey;if(GIT_PROGRAM_ENV_KEYS.has(key)||GIT_UNRESOLVABLE_ENV_KEYS.has(key)||GIT_NUMBERED_CONFIG_ENV_PATTERN.test(key)){state.unresolved=true;return}if(!GIT_DIR_ENV_KEYS.has(key)&&!GIT_WORK_TREE_ENV_KEYS.has(key))return;const value=token.text.slice(token.text.indexOf("=")+1);if(token.dynamic||isAppendAssignment(token.text)||isDynamicPathValue({text:value,dynamic:false})){state.unresolved=true;return}state.relocations.push({target:value,kind:GIT_WORK_TREE_ENV_KEYS.has(key)?"work-tree":"git-dir"})}__name(recordEnvAssignment,"recordEnvAssignment");function attachedChdirValue(flag,set){for(const candidate of set){if(candidate.startsWith("--")&&flag.startsWith(`${candidate}=`)){return flag.slice(candidate.length+1)}if(candidate.length===2&&flag.startsWith(candidate)&&flag.length>candidate.length){return flag.slice(candidate.length)}}return void 0}__name(attachedChdirValue,"attachedChdirValue");function recordChdirValue(value,state){if(isDynamicPathValue(value)){state.unresolved=true;return}state.relocations.push({target:value.text,kind:"cwd"})}__name(recordChdirValue,"recordChdirValue");function consumeEnvWrapper(run,start,state){let index=start+1;while(index<run.length){const token=run[index];if(token.dynamic){state.unresolved=true;index++;continue}if(token.text==="--"){index++;break}if(ENV_KNOWN_FLAG_ONLY.has(token.text)){if(ENV_CLEARS_ENVIRONMENT.has(token.text)){state.clearsEnvironment=true}index++;continue}if(ENV_CHDIR_FLAGS.has(token.text)){recordChdirValue(run[index+1],state);index+=2;continue}const attached=attachedChdirValue(token.text,ENV_CHDIR_FLAGS);if(attached!==void 0){recordChdirValue({text:attached,dynamic:false},state);index++;continue}if(token.text==="-S"||token.text==="--split-string"){const payloadToken=run[index+1];if(payloadToken===void 0)return{next:run.length};if(payloadToken.dynamic)return{next:run.length,undecidable:true};const rest=joinArgvTexts(run.slice(index+2));return{next:run.length,payload:rest?`${payloadToken.text} ${rest}`:payloadToken.text}}if(/^-[A-Za-z]*S/.test(token.text)&&!token.text.startsWith("--")){const fused=token.text.slice(token.text.indexOf("S")+1);if(fused.length>0){const rest2=joinArgvTexts(run.slice(index+1));return{next:run.length,payload:rest2?`${fused} ${rest2}`:fused}}const payloadToken=run[index+1];if(payloadToken===void 0)return{next:run.length};if(payloadToken.dynamic)return{next:run.length,undecidable:true};const rest=joinArgvTexts(run.slice(index+2));return{next:run.length,payload:rest?`${payloadToken.text} ${rest}`:payloadToken.text}}if(ENV_VALUE_FLAGS.has(token.text)){const removed=run[index+1];if(removed!==void 0&&!removed.dynamic){(state.unsetEnvKeys??=new Set).add(removed.text)}index+=2;continue}if(/^-u./.test(token.text)||token.text.startsWith("--unset=")||token.text.startsWith("--split-string=")){if(token.text.startsWith("--split-string=")){const fused=token.text.slice("--split-string=".length);const rest=joinArgvTexts(run.slice(index+1));return{next:run.length,payload:rest?`${fused} ${rest}`:fused}}const removedName=token.text.startsWith("--unset=")?token.text.slice("--unset=".length):token.text.slice(2);(state.unsetEnvKeys??=new Set).add(removedName);index++;continue}if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);index++;continue}if(token.text.startsWith("-")){state.unresolved=true;index++;continue}break}return{next:index}}__name(consumeEnvWrapper,"consumeEnvWrapper");function consumeSudoWrapper(run,start,state){let index=start+1;while(index<run.length){const token=run[index];if(token.dynamic){state.unresolved=true;index++;continue}if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);index++;continue}if(!token.text.startsWith("-"))break;if(SUDO_CHDIR_FLAGS.has(token.text)){recordChdirValue(run[index+1],state);index+=2;continue}if(SUDO_CHROOT_FLAGS.has(token.text)||token.text.startsWith("--chroot=")||/^-R./.test(token.text)){state.unresolved=true;index+=SUDO_CHROOT_FLAGS.has(token.text)?2:1;continue}const attached=attachedChdirValue(token.text,SUDO_CHDIR_FLAGS);if(attached!==void 0){recordChdirValue({text:attached,dynamic:false},state);index++;continue}if(SUDO_VALUE_FLAGS.has(token.text)){index+=2;continue}index++}return{next:index}}__name(consumeSudoWrapper,"consumeSudoWrapper");function consumeTimeoutWrapper(run,start){let index=start+1;while(index<run.length){const token=run[index];if(!token.text.startsWith("-"))break;if(TIMEOUT_VALUE_FLAGS.has(token.text)&&!token.text.includes("=")){index+=2;continue}index++}if(index<run.length)index++;return index}__name(consumeTimeoutWrapper,"consumeTimeoutWrapper");function nextArgvIndex(run,from){let index=from;while(index<run.length&&(run[index].redirect||run[index].ambiguousFd)){index++}return index}__name(nextArgvIndex,"nextArgvIndex");function consumeShellWrapper(run,start){let index=start+1;while(index<run.length){const token=run[index];if(token.text==="-c"){const payloadToken=run[nextArgvIndex(run,index+1)];if(payloadToken===void 0){return{kind:"static",payload:""}}if(payloadToken.dynamic)return{kind:"dynamic"};return{kind:"static",payload:payloadToken.text}}if(token.dynamic){return{kind:"dynamic"}}if(shellBundleRequestsCommand(token.text)){const remainder=token.text.slice(token.text.indexOf("c")+1);if(remainder.length>0&&!/^[A-Za-z]+$/.test(remainder)){return{kind:"static",payload:remainder}}let payloadIndex=nextArgvIndex(run,index+1);let toSkip=shellBundleValueFlagsBeforeCommand(token.text)+(remainder.match(/[oO]/g)?.length??0);while(toSkip-- >0){payloadIndex=nextArgvIndex(run,payloadIndex+1)}const payloadToken=run[payloadIndex];if(payloadToken===void 0){return{kind:"static",payload:""}}if(payloadToken.dynamic)return{kind:"dynamic"};return{kind:"static",payload:payloadToken.text}}if(token.text.startsWith("+")){index++;continue}if(!token.text.startsWith("-"))return{kind:"none"};if(token.text==="--")return{kind:"none"};index+=SHELL_WRAPPER_VALUE_FLAGS.has(token.text)?2:1}return{kind:"none"}}__name(consumeShellWrapper,"consumeShellWrapper");var LEADING_SHELL_KEYWORDS=new Set(["{","}","!","if","then","else","elif","fi","for","do","done","while","until","in","case","esac","time","coproc"]);var EXPORT_BUILTINS=new Set(["declare","export","local","readonly","typeset"]);var CHDIR_OPTION_PATTERN=/^-[LPe@qs]+$/;var FUSED_CHDIR_PATTERN=/^(cd|chdir|pushd|popd)([./\\].*)$/i;function splitFusedWindowsChdirs(run){for(let index=0;index<run.length;index++){const token=run[index];if(token.redirect||token.ambiguousFd)continue;if(leadingEnvAssignmentKey(token.text)!==null)continue;if(LEADING_SHELL_KEYWORDS.has(token.text))continue;const match=token.dynamic?null:FUSED_CHDIR_PATTERN.exec(token.text);if(match===null)return run;const replacement=run.slice();replacement.splice(index,1,{text:match[1],dynamic:false},{text:match[2],dynamic:false});return replacement}return run}__name(splitFusedWindowsChdirs,"splitFusedWindowsChdirs");function findChdirTarget(run,start,variant,windows=false){let index=start;while(index<run.length){const token=run[index];if(token.text==="--")return run[index+1];if(windows&&/^\/[dD]$/.test(token.text)){index++;continue}if(variant==="cd"&&CHDIR_OPTION_PATTERN.test(token.text)){index++;continue}if(/^[-+]/.test(token.text))return void 0;return token}return void 0}__name(findChdirTarget,"findChdirTarget");function requestsAllExport(run,start){for(let index=start;index<run.length;index++){const token=run[index];const text=token.text;if(token.dynamic)return true;if(text==="-o"||text==="--"){if(run[index+1]?.text==="allexport")return true;continue}if(text==="allexport"||text==="--allexport")return true;if(/^-[a-zA-Z]*a/.test(text))return true}return false}__name(requestsAllExport,"requestsAllExport");function disablesAllExport(run,start){for(let index=start;index<run.length;index++){const text=run[index].text;if(text==="+o"&&run[index+1]?.text==="allexport")return true;if(/^\+[a-zA-Z]*a/.test(text))return true}return false}__name(disablesAllExport,"disablesAllExport");function readProgramWord(run){for(const token of run){if(token.redirect||token.ambiguousFd)continue;if(leadingEnvAssignmentKey(token.text)!==null)continue;if(LEADING_SHELL_KEYWORDS.has(token.text))continue;return token.text}return void 0}__name(readProgramWord,"readProgramWord");function runFromProgramWord(run){let index=0;while(index<run.length){const token=run[index];if(token.redirect||token.ambiguousFd||leadingEnvAssignmentKey(token.text)!==null||LEADING_SHELL_KEYWORDS.has(token.text)){index++;continue}break}return run.slice(index)}__name(runFromProgramWord,"runFromProgramWord");function readFunctionName(run){const body=runFromProgramWord(run);if(body.length===0)return void 0;const first=body[0].text;if(first.endsWith("()")&&first.length>2)return first.slice(0,-2);if(body[1]?.text==="()")return first;return void 0}__name(readFunctionName,"readFunctionName");function readAliasDefinitions(run){const body=runFromProgramWord(run);if(body.length===0||executableBaseName(body[0])!=="alias")return[];const definitions=[];for(const token of body.slice(1)){const separator=token.text.indexOf("=");if(separator<=0)continue;definitions.push({name:token.text.slice(0,separator),body:token.text.slice(separator+1)})}return definitions}__name(readAliasDefinitions,"readAliasDefinitions");function readDefinition(run){const body=runFromProgramWord(run);if(body.length===0)return void 0;const first=body[0].text;const name=first.endsWith("()")?first.slice(0,-2):body[1]?.text==="()"?first:void 0;if(!name)return void 0;const bodyTokens=body.slice(first.endsWith("()")?1:2).filter(token=>token.text!=="{"&&token.text!=="}");if(bodyTokens.length===0)return void 0;return{name,body:joinArgvTexts(bodyTokens)}}__name(readDefinition,"readDefinition");function analyzeRun(run,platform=process.platform){if(platform==="win32"&&getShellConfiguration().shell!=="bash"){run=splitFusedWindowsChdirs(run)}const state={relocations:[],unresolved:false};let index=0;let assignments=0;while(index<run.length&&LEADING_SHELL_KEYWORDS.has(run[index].text)){index++}while(index<run.length){const token=run[index];if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,state);assignments++;index++;continue}if(token.dynamic){return{kind:"dynamic-program",rest:run.slice(index),state}}const program=executableBaseName(token);if(program==="command"||program==="builtin"){index++;while(index<run.length&&run[index].text.startsWith("-"))index++;continue}if(EXPORT_BUILTINS.has(program)){const operands=run.slice(index+1);for(const operand of operands)recordEnvAssignment(operand,state);return{kind:"export",state,operands}}if(platform==="win32"&&getShellConfiguration().shell!=="bash"&&(program==="path"||program==="doskey")){state.unresolved=true;return{kind:"export",state,operands:[]}}if(platform==="win32"&&getShellConfiguration().shell!=="bash"&&(program==="set"||program==="setx")){const operands=run.slice(index+1);if(program==="setx"||getShellConfiguration().shell==="powershell"){state.unresolved=true;return{kind:"export",state,operands:[]}}for(const operand of operands){if(operand.dynamic||leadingEnvAssignmentKey(operand.text)===null){state.unresolved=true;return{kind:"export",state,operands:[]}}recordEnvAssignment(operand,state)}return{kind:"export",state,operands}}if(program==="set"){if(requestsAllExport(run,index+1)){return{kind:"all-export",state}}if(disablesAllExport(run,index+1)){return{kind:"all-export-off",state}}}if(program==="env"){const scan=consumeEnvWrapper(run,index,state);if(scan.undecidable)return{kind:"undecidable"};if(scan.payload!==void 0){return{kind:"payload",payload:scan.payload,state,propagatesCwd:false}}index=scan.next;continue}if(program==="sudo"){index=consumeSudoWrapper(run,index,state).next;continue}if(program==="timeout"){index=consumeTimeoutWrapper(run,index);continue}if(program==="eval"){const payloadTokens=run.slice(index+1);if(payloadTokens.some(payloadToken=>payloadToken.dynamic||payloadToken.ambiguousFd)){return{kind:"undecidable"}}return{kind:"payload",payload:joinTokenTexts(payloadTokens),state,propagatesCwd:true}}if(platform==="win32"&&WINDOWS_SHELL_PROGRAMS.has(program)){return{kind:"undecidable"}}if(SHELL_WRAPPER_PROGRAMS.has(program)){const scan=consumeShellWrapper(run,index);if(scan.kind==="none"){return{kind:"other",state,assignmentsOnly:false}}if(scan.kind==="dynamic")return{kind:"undecidable"};return{kind:"payload",payload:scan.payload,state,propagatesCwd:false,importsExportedFunctions:program==="bash"&&!state.clearsEnvironment}}if(program==="nohup"||program==="exec"){index++;continue}if(program==="git"){return{kind:"git",tokens:run.slice(index),state}}if(program==="cd"||program==="pushd"||program==="popd"||platform==="win32"&&program==="chdir"||platform==="win32"&&getShellConfiguration().shell==="powershell"&&POWERSHELL_LOCATION_PROGRAMS.has(program)){const variant=program==="chdir"||program==="set-location"||program==="sl"?"cd":program==="push-location"||program==="pushd"?"pushd":program==="pop-location"||program==="popd"?"popd":"cd";const rest=run.slice(index+1);const namedIndex=rest.findIndex(token2=>token2.text==="-Path"||token2.text==="-LiteralPath");return{kind:"cd",variant,target:namedIndex>=0?rest[namedIndex+1]:findChdirTarget(rest,0,variant,platform==="win32"),physical:rest.some(token2=>/^-[A-Za-z]*P/.test(token2.text))}}return{kind:"other",state,assignmentsOnly:false}}return{kind:"other",state,assignmentsOnly:assignments>0}}__name(analyzeRun,"analyzeRun");function readGitInvocation(tokens){const cwdTargets=[];const gitDirTargets=[];const workTreeTargets=[];let subcommand;let unresolved=false;let dangerousConfig=false;const recordConfigAssignment=__name(value=>{const separator=value.indexOf("=");const key=(separator>=0?value.slice(0,separator):value).toLowerCase();const assignment=separator>=0?value.slice(separator+1):"";if(GIT_COMMAND_CONFIG_KEY_PATTERNS.some(pattern=>pattern.test(key))||assignment.trimStart().startsWith("!")){dangerousConfig=true}},"recordConfigAssignment");const pushRelocation=__name((kind,value,emptyIsNoop)=>{if(value===void 0){unresolved=true;return false}if(value.text===""&&!value.dynamic){if(emptyIsNoop)return true;unresolved=true;return false}if(isDynamicPathValue(value)){unresolved=true;return true}if(kind==="cwd")cwdTargets.push(value);else if(kind==="git-dir")gitDirTargets.push(value);else workTreeTargets.push(value);return true},"pushRelocation");let index=1;while(index<tokens.length){const token=tokens[index];if(token.redirect||token.ambiguousFd){index++;continue}if(token.dynamic||BRACE_EXPANSION_PATTERN.test(token.text)){unresolved=true;index++;continue}if(token.text==="-C"){if(!pushRelocation("cwd",tokens[index+1],true))break;index+=2;continue}if(token.text==="--git-dir"||token.text==="--work-tree"){const kind=token.text==="--git-dir"?"git-dir":"work-tree";if(!pushRelocation(kind,tokens[index+1],false))break;index+=2;continue}if(token.text.length>2&&token.text.startsWith("-C")){if(!pushRelocation("cwd",{text:token.text.slice(2),dynamic:false},false)){break}index++;continue}if(token.text.startsWith("--git-dir=")||token.text.startsWith("--work-tree=")){const kind=token.text.startsWith("--git-dir=")?"git-dir":"work-tree";const value=token.text.slice(token.text.indexOf("=")+1);if(!pushRelocation(kind,{text:value,dynamic:false},false)){break}index++;continue}if(token.text==="-c"||token.text==="--config-env"){const value=tokens[index+1];if(value===void 0)break;if(value.dynamic)dangerousConfig=true;else recordConfigAssignment(value.text);index+=2;continue}if(token.text.startsWith("--config-env=")){recordConfigAssignment(token.text.slice("--config-env=".length));index++;continue}if(token.text.length>2&&token.text.startsWith("-c")&&!token.text.startsWith("--")){recordConfigAssignment(token.text.slice(2));index++;continue}if(GIT_GLOBAL_OPTIONS_WITH_VALUES.has(token.text)){if(tokens[index+1]===void 0)break;index+=2;continue}if(token.text.startsWith("-")){index++;continue}subcommand=token.text;break}const hasDisqualifyingFlag=tokens.some(token=>{const separator=token.text.indexOf("=");const flag=separator>=0?token.text.slice(0,separator):token.text;return RELOCATED_READ_ONLY_DISQUALIFYING_FLAGS.has(flag)});return{cwdTargets,gitDirTargets,workTreeTargets,subcommand,unresolved,dangerousConfig,hasDisqualifyingFlag}}__name(readGitInvocation,"readGitInvocation");async function resolveGitDirRepository(canonicalGitDir){let current=canonicalGitDir;for(let depth=0;depth<3;depth++){const stats=await stat(current);if(stats.isFile()){const[firstLine]=(await readFile(current,"utf8")).split(/\r?\n/);const match=/^gitdir:\s*(.+)$/.exec(firstLine??"");if(!match)throw new Error("unrecognized gitfile");current=path.resolve(path.dirname(current),match[1].trim());continue}if(path.basename(current)===".git"){return path.dirname(current)}if(/[/\\]\.git[/\\]worktrees[/\\][^/\\]+$/.test(current)){const worktreeGitPointer=(await readFile(path.join(current,"gitdir"),"utf8")).trim();if(!worktreeGitPointer)throw new Error("empty worktree gitdir file");return path.dirname(path.resolve(current,worktreeGitPointer))}return current}throw new Error("gitdir indirection too deep")}__name(resolveGitDirRepository,"resolveGitDirRepository");async function resolvePhysicalPath(base,target){const parsed=path.parse(target);const absolute=path.isAbsolute(target);let current=absolute?parsed.root:base;const walkable=absolute?target.slice(parsed.root.length):target;const separators=path.sep==="\\"?/[\\/]+/:/\/+/;for(const segment of walkable.split(separators)){if(segment===""||segment===".")continue;if(segment===".."){current=path.dirname(await realpathNearestExistingAsync(current));continue}current=await realpathNearestExistingAsync(path.join(current,segment))}return current}__name(resolvePhysicalPath,"resolvePhysicalPath");async function resolveDiscoveredRepository(startDirectory,boundary){let current=startDirectory;for(let depth=0;depth<64;depth++){const candidate=path.join(current,".git");let exists=true;try{await stat(candidate)}catch{exists=false}if(exists){return resolveGitDirRepository(await realpathNearestExistingAsync(candidate))}if(current===boundary)return void 0;const parent=path.dirname(current);if(parent===current)return void 0;current=parent}return void 0}__name(resolveDiscoveredRepository,"resolveDiscoveredRepository");async function evaluateGitInvocation(invocation,state,basisCwd,entryCwd,context){if(invocation.unresolved||invocation.dangerousConfig||state.unresolved||context.ambientUnresolved){return denyDynamicRelocation()}if(RELOCATED_READ_ONLY_GIT_SUBCOMMANDS.has(invocation.subcommand??"")&&!invocation.hasDisqualifyingFlag){return void 0}const cwdRelocations=[];const repositoryRelocations=[];for(const relocation of[...context.ambientRelocations,...state.relocations]){if(relocation.kind==="cwd")cwdRelocations.push(relocation);else repositoryRelocations.push(relocation)}for(const target of invocation.cwdTargets){cwdRelocations.push({target:target.text,kind:"cwd"})}for(const target of invocation.gitDirTargets){repositoryRelocations.push({target:target.text,kind:"git-dir"})}for(const target of invocation.workTreeTargets){repositoryRelocations.push({target:target.text,kind:"work-tree"})}const relocated=basisCwd===void 0||basisCwd!==entryCwd||cwdRelocations.length>0||repositoryRelocations.length>0;if(!relocated){return basisCwd===void 0?void 0:denyOutsideDiscoveredRepository(basisCwd,context)}let gitCwd=basisCwd;for(const relocation of cwdRelocations){if(gitCwd===void 0&&!path.isAbsolute(relocation.target))break;gitCwd=await resolvePhysicalPath(gitCwd??"",relocation.target)}if(gitCwd===void 0){return denyDynamicRelocation()}const checkedTargets=[];for(const relocation of repositoryRelocations){checkedTargets.push({target:path.isAbsolute(relocation.target)?relocation.target:path.resolve(gitCwd,relocation.target),kind:relocation.kind})}if(basisCwd===void 0||basisCwd!==entryCwd||cwdRelocations.length>0){checkedTargets.push({target:gitCwd,kind:"cwd"})}for(const{target,kind}of checkedTargets){const canonicalTarget=await realpathNearestExistingAsync(target);let repositoryTarget;if(kind==="git-dir"){try{repositoryTarget=await resolveGitDirRepository(canonicalTarget)}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalTarget)}}else{try{await realpath(canonicalTarget);repositoryTarget=canonicalTarget}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalTarget)}}repositoryTarget=await realpathNearestExistingAsync(repositoryTarget);if(!isWithinRoot(repositoryTarget,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,repositoryTarget)}}if(repositoryRelocations.every(relocation=>relocation.kind!=="git-dir")){const denial=await denyOutsideDiscoveredRepository(gitCwd,context);if(denial)return denial}return void 0}__name(evaluateGitInvocation,"evaluateGitInvocation");async function denyOutsideDiscoveredRepository(startDirectory,context){const canonicalStart=await realpathNearestExistingAsync(startDirectory);let discovered;try{discovered=await resolveDiscoveredRepository(canonicalStart,context.canonicalEffectiveCwd)}catch{return denyTarget(UNRESOLVED_TARGET_DENIAL_PREFIX,canonicalStart)}if(discovered===void 0)return void 0;const canonicalDiscovered=await realpathNearestExistingAsync(discovered);if(!isWithinRoot(canonicalDiscovered,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,canonicalDiscovered)}return void 0}__name(denyOutsideDiscoveredRepository,"denyOutsideDiscoveredRepository");function skipAnsiCQuote(segment,start){let index=start+2;while(index<segment.length&&segment[index]!=="'"){if(segment[index]==="\\")index++;index++}return index+1}__name(skipAnsiCQuote,"skipAnsiCQuote");function extractCommandSubstitutions(segment){const bodies=[];let single=false;let double=false;let index=0;while(index<segment.length){const character=segment[index];if(!single&&character==="\\"&&index+1<segment.length){index+=2;continue}if(!single&&!double&&character==="$"&&segment[index+1]==="'"){index=skipAnsiCQuote(segment,index);continue}if(!single&&character==="$"&&segment[index+1]==="("){if(segment[index+2]==="("){index+=3;continue}const end=findSubstitutionEnd(segment,index+2);if(end===-1)return null;bodies.push(segment.slice(index+2,end));index=end+1;continue}if(!single&&character==="`"){let end=index+1;while(end<segment.length&&segment[end]!=="`"){if(segment[end]==="\\")end++;end++}if(end>=segment.length)return null;bodies.push(segment.slice(index+1,end));index=end+1;continue}if(character==="'"&&!double)single=!single;else if(character==='"'&&!single)double=!double;index++}return bodies}__name(extractCommandSubstitutions,"extractCommandSubstitutions");function findSubstitutionEnd(segment,start){let single=false;let double=false;let depth=0;for(let index=start;index<segment.length;index++){const character=segment[index];if(!single&&character==="\\"){index++;continue}if(!single&&!double&&character==="$"&&segment[index+1]==="'"){index=skipAnsiCQuote(segment,index)-1;continue}if(character==="'"&&!double){single=!single;continue}if(character==='"'&&!single){double=!double;continue}if(single||double)continue;if(character==="(")depth++;else if(character===")"){if(depth===0)return index;depth--}}return-1}__name(findSubstitutionEnd,"findSubstitutionEnd");async function evaluateUnrecognizedRun(run,state,basisCwd,context,relink){if(!run.some(token=>GIT_WORD_PATTERN.test(token.text)))return void 0;if(relink?.gitDir){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const gitIndex=run.findIndex(token=>executableBaseName(token)==="git");if(gitIndex>=0&&readGitInvocation(run.slice(gitIndex)).dangerousConfig){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const ownsCFlag=run.length>0&&PROGRAMS_WITH_OWN_C_FLAG.has(executableBaseName(run[0]));if(!ownsCFlag&&hasGitRelocationMarker(run)||run.some(token=>(ownsCFlag?TEXT_RELOCATION_MARKER_WITHOUT_C_PATTERN:TEXT_RELOCATION_MARKER_PATTERN).test(token.text))||state.relocations.length>0||state.unresolved||context.ambientRelocations.length>0||context.ambientUnresolved){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}if(basisCwd===void 0){return{allowed:false,reason:UNRECOGNIZED_PROGRAM_DENIAL}}const canonicalBasis=await realpathNearestExistingAsync(basisCwd);if(!isWithinRoot(canonicalBasis,context.canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,canonicalBasis)}return denyOutsideDiscoveredRepository(canonicalBasis,context)}__name(evaluateUnrecognizedRun,"evaluateUnrecognizedRun");function stripHeredocBodies(command){const lines=command.split("\n");const out=[];for(let index=0;index<lines.length;index++){const line=lines[index];out.push(line);const match=/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/.exec(line);if(!match)continue;const delimiter=match[2];const stripTabs=line.includes("<<-");while(index+1<lines.length){index++;const body=lines[index];const trimmed=stripTabs?body.replace(/^\t+/,""):body;if(trimmed===delimiter)break}}return out.join("\n")}__name(stripHeredocBodies,"stripHeredocBodies");function readTopLevelSeparators(command){const separators=[];let single=false;let double=false;let backtick=false;let substitution=0;const quoteStack=[];for(let index=0;index<command.length;index++){const character=command[index];const next=command[index+1];if(!single&&character==="\\"&&index+1<command.length){index++;continue}if(!single&&character==="`"){backtick=!backtick;continue}if(!single&&!backtick&&character==="$"&&next==="("){quoteStack.push([single,double]);single=false;double=false;substitution++;index++;continue}if(!backtick&&substitution>0&&character===")"&&!single&&!double){const enclosing=quoteStack.pop();single=enclosing?.[0]??false;double=enclosing?.[1]??false;substitution--;continue}if(!backtick&&character==="'"&&!double){single=!single;continue}if(!backtick&&character==='"'&&!single){double=!double;continue}if(single||double||backtick||substitution>0)continue;if(character==="&"&&next==="&"){separators.push("&&");index++}else if(character==="&"&&next===">"){index+=command[index+2]===">"?2:1}else if(character==="&"&&(command[index-1]===">"||command[index-1]==="<")){}else if(character==="&"){separators.push("&")}else if(character==="|"&&next==="|"){separators.push("||");index++}else if(character==="|"){separators.push(command[index-1]===">"?">|":"|")}else if(character===";"){separators.push(";")}else if(character==="\n"){separators.push("\n")}}return separators}__name(readTopLevelSeparators,"readTopLevelSeparators");async function evaluateCommandWithCwd(command,startCwd,entryCwd,context,depth,scope={relink:{targets:[],gitDir:false}}){let trackedCwd=startCwd;const exported={relocations:[],unresolved:false};let allExport=scope.allExport??false;const shellLocals=scope.locals??new Map;const definedBodies=scope.definedBodies??new Map;const exportedNames=scope.exportedNames??new Set;const gitShapedNames=scope.gitShapedNames??new Set;const exportedFunctions=scope.exportedFunctions??new Set;let insideDefinition;let definitionBody="";const relinkedTargets=scope.relink.targets;const activeContext=__name(()=>exported.relocations.length>0||exported.unresolved?{canonicalEffectiveCwd:context.canonicalEffectiveCwd,ambientRelocations:[...context.ambientRelocations,...exported.relocations],ambientUnresolved:context.ambientUnresolved||exported.unresolved}:context,"activeContext");let subshellDepth=0;const snapshotShellState=__name(()=>({cwd:trackedCwd,relocations:[...exported.relocations],unresolved:exported.unresolved,allExport,locals:[...shellLocals]}),"snapshotShellState");const restoreShellState=__name(snapshot=>{if(snapshot===void 0)return;trackedCwd=snapshot.cwd;exported.relocations.length=0;exported.relocations.push(...snapshot.relocations);exported.unresolved=snapshot.unresolved;allExport=snapshot.allExport;shellLocals.clear();for(const[key,token]of snapshot.locals)shellLocals.set(key,token)},"restoreShellState");const subshellCwds=[];const invokeDefinedBody=__name(async(programToken,run)=>{const defined=definedBodies.get(programToken);if(depth>=MAX_PAYLOAD_RECURSION_DEPTH)return denyDynamicRelocation();let replay=defined.body;const programIndex=run.findIndex(token=>!token.redirect&&!token.ambiguousFd&&token.text===programToken);if(defined.alias){const args=joinArgvTexts(run.slice(programIndex+1));if(args.length>0)replay=`${replay} ${args}`}const prefix={relocations:[],unresolved:false};for(const token of run.slice(0,programIndex)){if(leadingEnvAssignmentKey(token.text)!==null){recordEnvAssignment(token,prefix)}}const base=activeContext();const bodyContext=prefix.relocations.length>0||prefix.unresolved?{canonicalEffectiveCwd:base.canonicalEffectiveCwd,ambientRelocations:[...base.ambientRelocations,...prefix.relocations],ambientUnresolved:base.ambientUnresolved||prefix.unresolved}:base;const nested=await evaluateCommandWithCwd(replay,trackedCwd,entryCwd,bodyContext,depth+1,{relink:scope.relink,locals:shellLocals,exportedNames,allExport,definedBodies,gitShapedNames,exportedFunctions});if(nested.denial)return nested.denial;trackedCwd=nested.cwdAfter;if(nested.exportedAfter){exported.relocations.push(...nested.exportedAfter.relocations);if(nested.exportedAfter.unresolved)exported.unresolved=true}if(nested.allExportAfter!==void 0)allExport=nested.allExportAfter;for(const[key,token]of nested.shellLocalsAfter??[]){shellLocals.set(key,token)}return void 0},"invokeDefinedBody");const platformNow=process.platform;const shellNow=getShellConfiguration().shell;const windowsNative=platformNow==="win32"&&shellNow!=="bash";const strippedCommand=windowsNative?command:stripHeredocBodies(command);if(containsCmdRewriteSyntax(strippedCommand,platformNow,shellNow)){return{denial:{allowed:false,reason:CMD_REWRITE_SYNTAX_DENIAL},cwdAfter:trackedCwd}}if(containsUnmodelledWindowsSyntax(strippedCommand,platformNow,shellNow)){return{denial:{allowed:false,reason:WINDOWS_UNMODELLED_SYNTAX_DENIAL},cwdAfter:trackedCwd}}const normalizedCommand=preserveWindowsPathSeparators(strippedCommand,platformNow,shellNow);const segments=splitCommands(normalizedCommand);const separators=readTopLevelSeparators(normalizedCommand);const separatorsMatch=separators.length===segments.length-1;const isPipeComponent=__name(index=>windowsNative&&shellNow==="powershell"?false:separatorsMatch?separators[index-1]==="|"||separators[index]==="|"||separators[index]==="&":separators.some(separator=>separator==="|"||separator==="&"),"isPipeComponent");for(const[segmentIndex,segment]of segments.entries()){const pipeComponent=isPipeComponent(segmentIndex);const cwdBeforeSegment=trackedCwd;const definedBodiesBefore=pipeComponent?new Map(definedBodies):void 0;const gitShapedNamesBefore=pipeComponent?new Set(gitShapedNames):void 0;const exportedNamesBefore=pipeComponent?new Set(exportedNames):void 0;const exportedFunctionsBefore=pipeComponent?new Set(exportedFunctions):void 0;const shellLocalsBefore=pipeComponent?new Map(shellLocals):void 0;const exportedBefore=pipeComponent?{relocations:[...exported.relocations],unresolved:exported.unresolved}:void 0;const allExportBefore=allExport;const substitutions=extractCommandSubstitutions(segment);const tokenized=substitutions===null?null:tokenizeSegment(segment,subshellDepth);const runs=tokenized?.runs??null;if(runs===null){return{denial:{allowed:false,reason:UNPARSEABLE_COMMAND_DENIAL},cwdAfter:trackedCwd}}const functionHeader=windowsNative?null:/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*\)/.exec(segment)??/^\s*function\s+([A-Za-z_][A-Za-z0-9_]*)\b/.exec(segment);if(functionHeader){insideDefinition=functionHeader[1];const braceAt=segment.indexOf("{");definitionBody=braceAt>=0?segment.slice(braceAt+1):""}else if(insideDefinition!==void 0){definitionBody+=`
4
4
  ${segment}`}if(insideDefinition!==void 0){if(segment.includes("}")){const closeAt=definitionBody.lastIndexOf("}");const body=(closeAt>=0?definitionBody.slice(0,closeAt):definitionBody).trim();if(body.length>0&&!pipeComponent){definedBodies.set(insideDefinition,{body,alias:false})}insideDefinition=void 0}continue}for(const body of substitutions){if(depth>=MAX_PAYLOAD_RECURSION_DEPTH){return{denial:denyDynamicRelocation(),cwdAfter:trackedCwd}}const nested=await evaluateCommandWithCwd(body,trackedCwd,entryCwd,activeContext(),depth+1,{relink:scope.relink,locals:new Map(shellLocals),exportedNames:new Set(exportedNames),allExport,definedBodies:new Map(definedBodies),gitShapedNames:new Set(gitShapedNames),exportedFunctions:new Set(exportedFunctions)});if(nested.denial){return{denial:nested.denial,cwdAfter:trackedCwd}}}for(const{tokens:run,depth:runDepth}of runs){while(runDepth>subshellDepth){subshellCwds.push(snapshotShellState());subshellDepth++}while(runDepth<subshellDepth){restoreShellState(subshellCwds.pop());subshellDepth--}let removalStart=0;const skipRedirectOperands=__name(()=>{while(removalStart<run.length&&(run[removalStart].redirect||run[removalStart].ambiguousFd)){removalStart++}},"skipRedirectOperands");skipRedirectOperands();let hasCommandPrefix=false;while(removalStart<run.length&&(run[removalStart].text==="command"||run[removalStart].text==="builtin")){if(definedBodies.has(run[removalStart].text))break;hasCommandPrefix=true;removalStart++;while(removalStart<run.length&&(run[removalStart].text.startsWith("-")||run[removalStart].redirect||run[removalStart].ambiguousFd)){removalStart++}}const removalTokens=run.slice(removalStart);const removalProgram=readProgramWord(removalTokens);const shadowedBuiltin=!hasCommandPrefix&&removalProgram!==void 0&&definedBodies.has(removalProgram);const isRemoval=!shadowedBuiltin&&(removalProgram==="unset"||removalProgram==="unalias"||removalProgram==="export"&&removalTokens.some(token=>/^-[A-Za-z]*n/.test(token.text)));if(isRemoval){const clearsAll=removalTokens.some(token=>/^-[A-Za-z]*a/.test(token.text));const touchesShadow=__name(name=>definedBodies.has(name)||gitShapedNames.has(name)||exportedFunctions.has(name),"touchesShadow");const anyShadow=definedBodies.size>0||gitShapedNames.size>0||exportedFunctions.size>0;const retractsShadow=clearsAll&&anyShadow||removalTokens.slice(1).some(token=>!token.text.startsWith("-")&&(token.dynamic||touchesShadow(token.text)));if(retractsShadow){return{denial:{allowed:false,reason:SHADOW_REMOVAL_DENIAL},cwdAfter:trackedCwd}}if(removalProgram==="unset"&&!removalTokens.some(token=>token.text==="-f")){for(const token of removalTokens.slice(1)){if(!token.text.startsWith("-"))shellLocals.delete(token.text)}}continue}const invoked=readProgramWord(run);if(invoked!==void 0&&definedBodies.has(invoked)&&readFunctionName(run)===void 0&&readAliasDefinitions(run).length===0){const denial=await invokeDefinedBody(invoked,run);if(denial)return{denial,cwdAfter:trackedCwd};continue}const analysis=analyzeRun(run,platformNow);switch(analysis.kind){case"cd":{const target=analysis.target===void 0?void 0:expandShellLocals(analysis.target,shellLocals);if(analysis.variant==="popd"||target===void 0){trackedCwd=void 0;break}if(isDynamicPathValue(target)){trackedCwd=void 0;break}if(analysis.physical){trackedCwd=trackedCwd===void 0&&!path.isAbsolute(target.text)?void 0:await resolvePhysicalPath(trackedCwd??"",target.text);break}if(path.isAbsolute(target.text)){trackedCwd=target.text;break}trackedCwd=trackedCwd===void 0?void 0:path.resolve(trackedCwd,target.text);break}case"payload":{if(depth>=MAX_PAYLOAD_RECURSION_DEPTH){return{denial:denyDynamicRelocation(),cwdAfter:trackedCwd}}const inherited=activeContext();const ambient={canonicalEffectiveCwd:inherited.canonicalEffectiveCwd,ambientRelocations:[...inherited.ambientRelocations,...analysis.state.relocations],ambientUnresolved:inherited.ambientUnresolved||analysis.state.unresolved};const nested=await evaluateCommandWithCwd(analysis.payload,trackedCwd,entryCwd,ambient,depth+1,{relink:scope.relink,...analysis.propagatesCwd?{locals:shellLocals,exportedNames,allExport,definedBodies,gitShapedNames,exportedFunctions}:analysis.importsExportedFunctions?{definedBodies:new Map([...definedBodies].filter(([name])=>exportedFunctions.has(name)&&!envUnsetRemovesFunction(name,analysis.state))),exportedFunctions:new Set([...exportedFunctions].filter(name=>!envUnsetRemovesFunction(name,analysis.state)))}:{}});if(nested.denial){return{denial:nested.denial,cwdAfter:trackedCwd}}if(analysis.propagatesCwd){trackedCwd=nested.cwdAfter;if(nested.exportedAfter){exported.relocations.push(...nested.exportedAfter.relocations);if(nested.exportedAfter.unresolved)exported.unresolved=true}if(nested.allExportAfter!==void 0){allExport=nested.allExportAfter}for(const[key,token]of nested.shellLocalsAfter??[]){shellLocals.set(key,token)}}break}case"git":{const invocation=readGitInvocation(analysis.tokens);const resolvedRelocations=[...invocation.cwdTargets,...invocation.gitDirTargets,...invocation.workTreeTargets].map(target=>trackedCwd===void 0?target.text:path.resolve(trackedCwd,target.text));if(trackedCwd!==void 0&&trackedCwd!==entryCwd){resolvedRelocations.push(trackedCwd)}if(scope.relink.gitDir||resolvedRelocations.some(target=>relinkedTargets.some(relinked=>target===relinked||isWithinRoot(target,relinked)||isWithinRoot(relinked,target)))){return{denial:denyDynamicRelocation(),cwdAfter:trackedCwd}}const denial=await evaluateGitInvocation(invocation,analysis.state,trackedCwd,entryCwd,activeContext());if(denial)return{denial,cwdAfter:trackedCwd};break}case"dynamic-program":{const inherited=activeContext();const expanded=analysis.rest.map(token=>expandShellLocals(token,shellLocals));for(const operand of expanded){if(operand.text.startsWith("-")||operand.dynamic)continue;if(trackedCwd===void 0){scope.relink.gitDir=true;continue}const resolved=path.resolve(trackedCwd,operand.text);if(path.basename(resolved)===".git")scope.relink.gitDir=true;else relinkedTargets.push(resolved)}if(analysis.state.unresolved||analysis.state.relocations.length>0||inherited.ambientUnresolved||inherited.ambientRelocations.length>0||hasGitRelocationMarker(expanded)||expanded.some(token=>TEXT_RELOCATION_MARKER_PATTERN.test(token.text))){return{denial:denyDynamicRelocation(),cwdAfter:trackedCwd}}if(trackedCwd===void 0||!isWithinRoot(await realpathNearestExistingAsync(trackedCwd),inherited.canonicalEffectiveCwd)){return{denial:denyDynamicRelocation(),cwdAfter:trackedCwd}}const denial=await evaluateUnrecognizedRun(expanded,analysis.state,trackedCwd,inherited,scope.relink);if(denial)return{denial,cwdAfter:trackedCwd};break}case"undecidable":return{denial:{allowed:false,reason:UNDECIDABLE_PAYLOAD_DENIAL},cwdAfter:trackedCwd};case"export":{exported.relocations.push(...analysis.state.relocations);if(analysis.state.unresolved)exported.unresolved=true;if(analysis.operands.some(op=>op.text==="-f")){for(const op of analysis.operands){if(!op.text.startsWith("-")&&!op.dynamic){exportedFunctions.add(op.text)}}}for(const operand of analysis.operands){if(leadingEnvAssignmentKey(operand.text)!==null)continue;if(operand.dynamic){exported.unresolved=true;continue}const pending=shellLocals.get(operand.text);if(pending)recordEnvAssignment(pending,exported);if(GIT_DIR_ENV_KEYS.has(operand.text)||GIT_WORK_TREE_ENV_KEYS.has(operand.text)||GIT_UNRESOLVABLE_ENV_KEYS.has(operand.text)||GIT_PROGRAM_ENV_KEYS.has(operand.text)){exportedNames.add(operand.text)}}const denial=await evaluateUnrecognizedRun(run,analysis.state,trackedCwd,activeContext(),scope.relink);if(denial)return{denial,cwdAfter:trackedCwd};break}case"all-export":allExport=true;exported.relocations.push(...analysis.state.relocations);if(analysis.state.unresolved)exported.unresolved=true;break;case"all-export-off":allExport=false;break;case"other":{const aliasDefinitions=windowsNative?[]:readAliasDefinitions(run);if(aliasDefinitions.length>0){for(const definition2 of aliasDefinitions){definedBodies.set(definition2.name,{body:definition2.body,alias:true})}break}const definition=windowsNative?void 0:readDefinition(run);if(definition){definedBodies.set(definition.name,{body:definition.body,alias:false});break}const programToken=readProgramWord(run);const definitionName=windowsNative?void 0:readFunctionName(run);if(definitionName){if(run.some(token=>GIT_WORD_PATTERN.test(token.text))){gitShapedNames.add(definitionName)}break}if(programToken!==void 0&&gitShapedNames.has(programToken)){const denial2=await evaluateUnrecognizedRun([{text:programToken,dynamic:false},{text:"git",dynamic:false}],analysis.state,trackedCwd,activeContext(),scope.relink);if(denial2)return{denial:denial2,cwdAfter:trackedCwd};break}if(programToken!==void 0&&definedBodies.has(programToken)){const denial2=await invokeDefinedBody(programToken,run);if(denial2)return{denial:denial2,cwdAfter:trackedCwd};break}if(run.some(t=>PATH_EXTRACTING_PROGRAMS.has(executableBaseName(t)))){if(trackedCwd!==void 0)relinkedTargets.push(trackedCwd)}const relinkPrograms=platformNow==="win32"?WIN32_PATH_RELINKING_PROGRAMS:PATH_RELINKING_PROGRAMS;const relinkProgramIndex=run.findIndex(t=>!t.redirect&&!t.ambiguousFd&&relinkPrograms.has(executableBaseName(t)));if(relinkProgramIndex>=0){for(const[operandIndex,operand]of run.entries()){if(operandIndex===relinkProgramIndex)continue;if(operand.redirect||operand.ambiguousFd)continue;if(operand.text.startsWith("-"))continue;if(windowsNative&&operand.text.startsWith("/"))continue;if(operand.dynamic||trackedCwd===void 0){scope.relink.gitDir=true;continue}const resolved=path.resolve(trackedCwd,operand.text);relinkedTargets.push(resolved);if(path.basename(resolved)===".git")scope.relink.gitDir=true}}if(analysis.assignmentsOnly){if(allExport){exported.relocations.push(...analysis.state.relocations);if(analysis.state.unresolved)exported.unresolved=true}else{for(const token of run){const key=leadingEnvAssignmentKey(token.text);if(key===null)continue;if(exportedNames.has(key)){recordEnvAssignment(token,exported);continue}const previous=shellLocals.get(key);if(!isAppendAssignment(token.text)||previous===void 0){shellLocals.set(key,token);continue}shellLocals.set(key,{text:previous.text+token.text.slice(token.text.indexOf("=")+1),dynamic:previous.dynamic||token.dynamic})}}}const denial=await evaluateUnrecognizedRun(run,analysis.state,trackedCwd,activeContext(),scope.relink);if(denial)return{denial,cwdAfter:trackedCwd};break}default:{const exhaustive=analysis;void exhaustive;break}}}while(tokenized.endDepth<subshellDepth){restoreShellState(subshellCwds.pop());subshellDepth--}while(tokenized.endDepth>subshellDepth){subshellCwds.push(snapshotShellState());subshellDepth++}if(pipeComponent){trackedCwd=cwdBeforeSegment;allExport=allExportBefore;definedBodies.clear();for(const[k,v]of definedBodiesBefore)definedBodies.set(k,v);gitShapedNames.clear();for(const k of gitShapedNamesBefore)gitShapedNames.add(k);exportedNames.clear();for(const k of exportedNamesBefore)exportedNames.add(k);exportedFunctions.clear();for(const k of exportedFunctionsBefore)exportedFunctions.add(k);shellLocals.clear();for(const[k,v]of shellLocalsBefore)shellLocals.set(k,v);exported.relocations.length=0;exported.relocations.push(...exportedBefore.relocations);exported.unresolved=exportedBefore.unresolved}}return{cwdAfter:trackedCwd,exportedAfter:exported,allExportAfter:allExport,shellLocalsAfter:shellLocals}}__name(evaluateCommandWithCwd,"evaluateCommandWithCwd");async function evaluateBuiltInGuard(request){if(!SHELL_EXECUTING_TOOL_NAMES.has(request.toolName))return{allowed:true};const command=request.arguments["command"];if(typeof command!=="string")return{allowed:true};if(readSshWorkspace(request.effectiveCwd))return{allowed:true};const sessionCwd=await realpathNearestExistingAsync(request.effectiveCwd);let canonicalEffectiveCwd=sessionCwd;const reportedCwd=request.invocationCwd;if(typeof reportedCwd==="string"&&reportedCwd.length>0){const canonicalReported=await realpathNearestExistingAsync(reportedCwd);if(isWithinRoot(canonicalReported,sessionCwd)){if(canonicalReported!==sessionCwd){let discovered;try{discovered=await resolveDiscoveredRepository(canonicalReported,sessionCwd)}catch{return denyTarget(UNVERIFIABLE_SCOPE_DENIAL_PREFIX,canonicalReported,UNVERIFIABLE_SCOPE_DENIAL_HINT)}if(discovered!==void 0&&await realpathNearestExistingAsync(discovered)===canonicalReported){canonicalEffectiveCwd=canonicalReported}}}else{const ownedWorktrees=await realpathNearestExistingAsync(GitWorktreeService.getWorktreesDir(request.sessionId));if(!isWithinRoot(canonicalReported,ownedWorktrees)){return denyTarget(UNVERIFIABLE_SCOPE_DENIAL_PREFIX,canonicalReported,UNVERIFIABLE_SCOPE_DENIAL_HINT)}canonicalEffectiveCwd=canonicalReported}}if(request.permissionChecked===true&&canonicalEffectiveCwd===sessionCwd){return{allowed:true}}let startDirectory=canonicalEffectiveCwd;const startDirectoryValue=request.arguments["directory"];if(typeof startDirectoryValue==="string"){startDirectory=await realpathNearestExistingAsync(path.resolve(canonicalEffectiveCwd,startDirectoryValue));if(!isWithinRoot(startDirectory,canonicalEffectiveCwd)){return denyTarget(OUTSIDE_TARGET_DENIAL_PREFIX,startDirectory)}}const{denial}=await evaluateCommandWithCwd(command,startDirectory,startDirectory,{canonicalEffectiveCwd,ambientRelocations:[],ambientUnresolved:false},0);return denial??{allowed:true}}__name(evaluateBuiltInGuard,"evaluateBuiltInGuard");function createDaemonToolGuard(externalGuard){return async request=>{const trusted=request;if(typeof trusted.effectiveCwd!=="string"){throw new Error("Daemon tool guard requires trusted workspace context.")}const builtInDecision=await evaluateBuiltInGuard(trusted);if(!builtInDecision.allowed||!externalGuard)return builtInDecision;if(trusted.promptId===void 0){return{allowed:false,reason:PROMPTLESS_PROVIDER_DENIAL}}if(EXTERNAL_GUARD_UNSUPPORTED_TOOLS.has(request.toolName)){return{allowed:false,reason:"Managed external tool guard v1 does not support nested or delegated agent execution."}}return externalGuard(request)}}__name(createDaemonToolGuard,"createDaemonToolGuard");export{containsCmdRewriteSyntax,containsUnmodelledWindowsSyntax,createDaemonToolGuard,preserveWindowsPathSeparators};
5
5
  /**
6
6
  * @license