@readmagic/workmate 0.0.23 → 0.0.25

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 (402) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-Y5S_lMjD.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DVbU-BaD.js +1 -0
  4. package/dist/chunks/App-B8q8PV77.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +2 -0
  6. package/dist/chunks/BypassPermissionsModeDialog-DjqGAL4C.js +1 -0
  7. package/dist/chunks/CustomSelect-BvTftqEH.js +1 -0
  8. package/dist/chunks/DiffDialog-v5r8cBKW.js +6 -0
  9. package/dist/chunks/Doctor-DKpBnbuI.js +1 -0
  10. package/dist/chunks/Doctor-uvO6NM5m.js +3 -0
  11. package/dist/chunks/ExitFlow-Dh9QdaYK.js +2 -0
  12. package/dist/chunks/InvalidConfigDialog-C9boykQn.js +1 -0
  13. package/dist/chunks/{InvalidSettingsDialog-Dtmpzeps.js → InvalidSettingsDialog-UN5mleCK.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +1 -0
  16. package/dist/chunks/MCPToolListView-De1W4jpj.js +1 -0
  17. package/dist/chunks/McpParsingWarnings-zkM_lGd0.js +1 -0
  18. package/dist/chunks/MessageSelector-DW_itlX-.js +3 -0
  19. package/dist/chunks/Messages-BFsCpACq.js +10 -0
  20. package/dist/chunks/Onboarding-BT90cFkn.js +1 -0
  21. package/dist/chunks/PromptInputFooterSuggestions-CCTZYbWI.js +1 -0
  22. package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +1 -0
  23. package/dist/chunks/{ProviderSetup-XcBHjUnd.js → ProviderSetup-yIj8YOKF.js} +1 -1
  24. package/dist/chunks/QueryEngine-egz5mbaW.js +1 -0
  25. package/dist/chunks/REPL-D27CE4WN.js +124 -0
  26. package/dist/chunks/REPL-e8wAT1wN.js +1 -0
  27. package/dist/chunks/ResumeConversation-CWA27Lke.js +1 -0
  28. package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +1 -0
  29. package/dist/chunks/{SelectMulti-Bc6l11_K.js → SelectMulti-BW7Ffk1G.js} +1 -1
  30. package/dist/chunks/Settings-axHLvYIy.js +3 -0
  31. package/dist/chunks/Spinner-VjwI7m_g.js +1 -0
  32. package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CqrOK3Mx.js} +1 -1
  33. package/dist/chunks/TextInput-Cev5Awdd.js +22 -0
  34. package/dist/chunks/ThemePicker-CtQYHmOr.js +1 -0
  35. package/dist/chunks/TrustDialog-8Sjmuu0e.js +1 -0
  36. package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-INwwoerV.js} +1 -1
  37. package/dist/chunks/_baseEach-DrPH_FGo.js +1 -0
  38. package/dist/chunks/add-dir-D3RMaYxy.js +1 -0
  39. package/dist/chunks/{agentDisplay-BReJUBWg.js → agentDisplay-B3npXoCS.js} +1 -1
  40. package/dist/chunks/{agents-B3x8yJ_r.js → agents-2mPGmeq6.js} +1 -1
  41. package/dist/chunks/agents-DEnmg8Xo.js +101 -0
  42. package/dist/chunks/allErrors-C9kx6lnk.js +1 -0
  43. package/dist/chunks/analytics-COpjZpvd.js +1 -0
  44. package/dist/chunks/{appleTerminalBackup-BArZWB21.js → appleTerminalBackup-CT7g8yOs.js} +1 -1
  45. package/dist/chunks/backgroundHousekeeping-BkFxfjOf.js +1 -0
  46. package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +1 -0
  47. package/dist/chunks/banner-DHpTmEO7.js +2 -0
  48. package/dist/chunks/branch-Be_yDFU8.js +2 -0
  49. package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-UUt6Dkf2.js} +2 -2
  50. package/dist/chunks/btw-DUml5L1w.js +1 -0
  51. package/dist/chunks/caches-DWjwe-DN.js +1 -0
  52. package/dist/chunks/caches-VLs1tQkZ.js +1 -0
  53. package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-mBGFDbI6.js} +1 -1
  54. package/dist/chunks/{clear-Bdhb6b39.js → clear-CrGjNe6E.js} +1 -1
  55. package/dist/chunks/{client-CpTCeWba.js → client-BDuhbzLD.js} +1 -1
  56. package/dist/chunks/{client-4iqhC8xq.js → client-BYFVVMcf.js} +1 -1
  57. package/dist/chunks/client-CO_6v4yl.js +1 -0
  58. package/dist/chunks/client-DO-O441l.js +1 -0
  59. package/dist/chunks/commands-Cn1P7Tms.js +1 -0
  60. package/dist/chunks/compact-DGUhdXcc.js +2 -0
  61. package/dist/chunks/config-C7GTF4iI.js +1 -0
  62. package/dist/chunks/config-CWPHVTic.js +3 -0
  63. package/dist/chunks/config-Cox0TM2Z.js +1 -0
  64. package/dist/chunks/context-mV5zjqmc.js +1 -0
  65. package/dist/chunks/context-noninteractive--OuiZUzL.js +1 -0
  66. package/dist/chunks/{context-noninteractive-Dd4xIoP1.js → context-noninteractive-DvfVvmSE.js} +2 -2
  67. package/dist/chunks/conversation--y8PD2Lk.js +1 -0
  68. package/dist/chunks/conversation-BIPJEOwO.js +1 -0
  69. package/dist/chunks/conversationRecovery-BBJzrA0g.js +1 -0
  70. package/dist/chunks/crossProjectResume-CwZb3cEU.js +40 -0
  71. package/dist/chunks/cwd-BZMp3CZ8.js +1 -0
  72. package/dist/chunks/cwd-BvNt_018.js +1 -0
  73. package/dist/chunks/debug-CRnGsZOV.js +39 -0
  74. package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-CsJLbVEe.js} +1 -1
  75. package/dist/chunks/{diff-BOAElpfQ.js → diff-DUEoNCnJ.js} +1 -1
  76. package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-Bgi8DBT5.js} +1 -1
  77. package/dist/chunks/doctor-4NiE46ZG.js +1 -0
  78. package/dist/chunks/entry-D1iD76SW.js +13 -0
  79. package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
  80. package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
  81. package/dist/chunks/{execFileNoThrow-BTachNBI.js → execFileNoThrow-BgRsj_SW.js} +3 -3
  82. package/dist/chunks/exit-CrsQsjbx.js +1 -0
  83. package/dist/chunks/extraUsage-BtHE-SBX.js +1 -0
  84. package/dist/chunks/extractMemories-kogJzpit.js +1 -0
  85. package/dist/chunks/fast-CuNVwVTr.js +1 -0
  86. package/dist/chunks/fast-RlFnwGRV.js +1 -0
  87. package/dist/chunks/fetchModelList-Cjow_QGy.js +1 -0
  88. package/dist/chunks/fetchModelList-uiCPVqbJ.js +1 -0
  89. package/dist/chunks/fileSuggestions-C96V9-Ne.js +3 -0
  90. package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
  91. package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
  92. package/dist/chunks/{gemini-D_ORb_L6.js → gemini-4YGElN3H.js} +2 -2
  93. package/dist/chunks/generateSessionName-BHIKyXpz.js +1 -0
  94. package/dist/chunks/{genericProcessUtils-DwQFuna9.js → genericProcessUtils-BNlr-QxM.js} +1 -1
  95. package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
  96. package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
  97. package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
  98. package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
  99. package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
  100. package/dist/chunks/goal-ePK_jLo3.js +3 -0
  101. package/dist/chunks/grok-DnmklTrm.js +1 -0
  102. package/dist/chunks/help-B7xRle-V.js +1 -0
  103. package/dist/chunks/history-kOw3CcLT.js +1 -0
  104. package/dist/chunks/hooks-BDY1jMbS.js +1 -0
  105. package/dist/chunks/{hooks-DIvN6gdv.js → hooks-BN5f58HY.js} +2 -2
  106. package/dist/chunks/install-DrMiHa2Q.js +1 -0
  107. package/dist/chunks/instrumentation-Oj5xagJG.js +21 -0
  108. package/dist/chunks/{job-R6c4-3c8.js → job-D9ypO0cd.js} +1 -1
  109. package/dist/chunks/keybindings-BRRN_eap.js +1 -0
  110. package/dist/chunks/launchLocalMemory-DliLezJw.js +3 -0
  111. package/dist/chunks/launchOnboarding-A-kk-7ID.js +8 -0
  112. package/dist/chunks/loadAgentsDir-CJAK4kif.js +1 -0
  113. package/dist/chunks/{loadAgentsDir-DlPbtIsS.js → loadAgentsDir-DGozQu_6.js} +550 -550
  114. package/dist/chunks/{loadPluginHooks-C_msxVIc.js → loadPluginHooks-BiHPKDaY.js} +1 -1
  115. package/dist/chunks/{loader-CICGtLp2.js → loader-CtoR-vO-.js} +1 -1
  116. package/dist/chunks/{localSearch-CK-sFzPm.js → localSearch-BU02Qsv9.js} +1 -1
  117. package/dist/chunks/localSearch-DyaB2Rm-.js +1 -0
  118. package/dist/chunks/{log-D2TIwHBV.js → log-DoSpAwRP.js} +1 -1
  119. package/dist/chunks/logoUtils-DLd6JKqW.js +1 -0
  120. package/dist/chunks/{magicDocs-BEF8D3if.js → magicDocs-Bj8LYrN2.js} +2 -2
  121. package/dist/chunks/main-B_09WbaG.js +345 -0
  122. package/dist/chunks/managedEnv-BJGfe3m7.js +1 -0
  123. package/dist/chunks/{managedEnv-OPlzUPbJ.js → managedEnv-CIWJsuty.js} +1 -1
  124. package/dist/chunks/mcp-1nBvcNxw.js +1 -0
  125. package/dist/chunks/mcp-7DXpXMdT.js +2 -0
  126. package/dist/chunks/mcp-kw99WVi2.js +6 -0
  127. package/dist/chunks/memory-CjWvzR_9.js +1 -0
  128. package/dist/chunks/mode-CBKawxnD.js +2 -0
  129. package/dist/chunks/model-DpZaKZMb.js +1 -0
  130. package/dist/chunks/model-DwbqvCY2.js +1 -0
  131. package/dist/chunks/modelOptions-CXBfKFXA.js +1 -0
  132. package/dist/chunks/nativeInstaller-SmPeEisk.js +1 -0
  133. package/dist/chunks/{notifications-4wP1Tx9Y.js → notifications-ql0eSo0Y.js} +1 -1
  134. package/dist/chunks/onChangeAppState-D85b33R5.js +1 -0
  135. package/dist/chunks/open-Cyrr4E5x.js +1 -0
  136. package/dist/chunks/openai-D_j7-KW6.js +2 -0
  137. package/dist/chunks/overlayContext-CLjlCFBl.js +1 -0
  138. package/dist/chunks/{panel-CVS4SK_E.js → panel-DMZkOEiU.js} +1 -1
  139. package/dist/chunks/parser-2usBI4G-.js +1 -0
  140. package/dist/chunks/{parser-Cg6hSCmn.js → parser-UqADrvxF.js} +1 -1
  141. package/dist/chunks/partition-CwxTlmMd.js +1 -0
  142. package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-ovtxMVR5.js} +1 -1
  143. package/dist/chunks/permissions-CgsvWOk_.js +3 -0
  144. package/dist/chunks/pidLock-B-SW3Nhx.js +3 -0
  145. package/dist/chunks/plan-BJrWtXEh.js +1 -0
  146. package/dist/chunks/platform-DsMIk3eq.js +2 -0
  147. package/dist/chunks/plugin-D97VJAxW.js +17 -0
  148. package/dist/chunks/{pluginAutoupdate-8qugAFhb.js → pluginAutoupdate-DQqYDPVg.js} +1 -1
  149. package/dist/chunks/{pluginBlocklist-q01ackCf.js → pluginBlocklist-BAr9WTup.js} +1 -1
  150. package/dist/chunks/pluginCliCommands-CUGPc853.js +1 -0
  151. package/dist/chunks/{pluginFlagging-BG2MHCQJ.js → pluginFlagging-BO_3qjfs.js} +1 -1
  152. package/dist/chunks/pluginOperations-rTrzu6Vg.js +2 -0
  153. package/dist/chunks/pluginStartupCheck-BRHnXlym.js +1 -0
  154. package/dist/chunks/{pluginStartupCheck-DTMa6TgL.js → pluginStartupCheck-BX6cv-vs.js} +1 -1
  155. package/dist/chunks/plugins-9crasx2V.js +4 -0
  156. package/dist/chunks/poorMode-BaS0DBUO.js +1 -0
  157. package/dist/chunks/{poorMode-B0QGV6Ci.js → poorMode-DmvzFAz_.js} +1 -1
  158. package/dist/chunks/print-Bi3xVdB3.js +13 -0
  159. package/dist/chunks/processBashCommand-BBtnCx-7.js +1 -0
  160. package/dist/chunks/processSlashCommand-jzF0GmLO.js +5 -0
  161. package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState--L3BKjOE.js} +1 -1
  162. package/dist/chunks/prompt-CmijKW7G.js +1 -0
  163. package/dist/chunks/prompt-DYBx_D0H.js +1 -0
  164. package/dist/chunks/{prompt-mM79EGnT.js → prompt-DzO1um1h.js} +4 -4
  165. package/dist/chunks/{promptEditor-DLGN_eLu.js → promptEditor-B6S_Rzcu.js} +2 -2
  166. package/dist/chunks/protocolHandler-BWgH1jaF.js +13 -0
  167. package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BjkGlmBu.js} +1 -1
  168. package/dist/chunks/reconciler-CVMmAaCy.js +1 -0
  169. package/dist/chunks/refresh-CAGv8BJY.js +1 -0
  170. package/dist/chunks/reject-CEUkoI2G.js +1 -0
  171. package/dist/chunks/{reload-plugins-C42xSB5l.js → reload-plugins-DeyJTx4s.js} +1 -1
  172. package/dist/chunks/rename-DPFis9g_.js +1 -0
  173. package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DRS2EslG.js} +1 -1
  174. package/dist/chunks/resume-N4O5YI-S.js +2 -0
  175. package/dist/chunks/ripgrep-3omwGI-l.js +1 -0
  176. package/dist/chunks/ripgrep-CgQrN3XX.js +5 -0
  177. package/dist/chunks/{runtimeObserver-1wQO8HSZ.js → runtimeObserver-C0CJvA3q.js} +1 -1
  178. package/dist/chunks/{runtimeObserver-XQrOux41.js → runtimeObserver-DMSzdFWt.js} +4 -4
  179. package/dist/chunks/sandbox-adapter-D15jjHJR.js +1 -0
  180. package/dist/chunks/sandbox-toggle-Tbbaw18C.js +1 -0
  181. package/dist/chunks/searchExtraTools-BoFc__Eg.js +1 -0
  182. package/dist/chunks/select-Fq6g2Ejk.js +1 -0
  183. package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +1 -0
  184. package/dist/chunks/{sessionObserver-DS4G6mb9.js → sessionObserver-CRie77tp.js} +2 -2
  185. package/dist/chunks/sessionObserver-PcaVCVkX.js +1 -0
  186. package/dist/chunks/sessionStorage-Dkf7FRgA.js +1 -0
  187. package/dist/chunks/sessionTracing-D7rekMdW.js +11 -0
  188. package/dist/chunks/settings-8fwIkMDV.js +1 -0
  189. package/dist/chunks/settings-CodSADx8.js +24 -0
  190. package/dist/chunks/setup-DBiIrXrh.js +3 -0
  191. package/dist/chunks/{shadowedRuleDetection-BRxZjobz.js → shadowedRuleDetection-CTnYVrmP.js} +1 -1
  192. package/dist/chunks/{sideQuestion-DLJxyrlp.js → sideQuestion-Cl8m2qYx.js} +3 -3
  193. package/dist/chunks/sinks-CiupmfTg.js +1 -0
  194. package/dist/chunks/sinks-DH83d_kd.js +1 -0
  195. package/dist/chunks/skillChangeDetector-BrrZaFkT.js +1 -0
  196. package/dist/chunks/{skillGapStore-CKN_d3pO.js → skillGapStore-es3K-aYe.js} +2 -2
  197. package/dist/chunks/{skillLifecycle-BMY2JGGG.js → skillLifecycle-BcgoOQBk.js} +2 -2
  198. package/dist/chunks/{skillSearchPanel-D9trHULQ.js → skillSearchPanel-CuDDb1L-.js} +4 -4
  199. package/dist/chunks/skills-BRtgqnLz.js +1 -0
  200. package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
  201. package/dist/chunks/src-Db7K3F_i.js +3 -0
  202. package/dist/chunks/startupProfiler-D1NRu2nj.js +1 -0
  203. package/dist/chunks/startupProfiler-DF0AjiDf.js +3 -0
  204. package/dist/chunks/{state-B4jiUise.js → state-BQ4BEGin.js} +1 -1
  205. package/dist/chunks/state-D3gvDiu8.js +1 -0
  206. package/dist/chunks/status-WXA16wIM.js +1 -0
  207. package/dist/chunks/statusNoticeHelpers-BfmIub5L.js +1 -0
  208. package/dist/chunks/{stringUtils-C718f5ey.js → stringUtils-Bu_lJH5c.js} +1 -1
  209. package/dist/chunks/switcher-5gilU5_R.js +1 -0
  210. package/dist/chunks/{switcher-CAajZeNL.js → switcher-DMfuKuw_.js} +1 -1
  211. package/dist/chunks/{tasks-BWNQr2d3.js → tasks-B6gYXxOx.js} +1 -1
  212. package/dist/chunks/{templateJobs-gUET39Ho.js → templateJobs-BW6TaqEC.js} +1 -1
  213. package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-BgIXFBpd.js} +4 -4
  214. package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-C-g9Xvj3.js} +1 -1
  215. package/dist/chunks/{theme-B7fKI6E5.js → theme-9AZceq_m.js} +1 -1
  216. package/dist/chunks/tipRegistry-DtO1H_Wo.js +2 -0
  217. package/dist/chunks/{toolEventObserver-BL06sDI4.js → toolEventObserver-DTuJcREC.js} +1 -1
  218. package/dist/chunks/toolPool-DHS8jWaL.js +1 -0
  219. package/dist/chunks/{types-Dx7P7JLQ.js → types-97nL3naE.js} +16 -16
  220. package/dist/chunks/{udsClient-cQz6nJ_T.js → udsClient-CmYHFiBD.js} +1 -1
  221. package/dist/chunks/{use-select-navigation-BiUJdWai.js → use-select-navigation-BStVRvcX.js} +1 -1
  222. package/dist/chunks/useExitOnCtrlCDWithKeybindings-DWRFdFoU.js +1 -0
  223. package/dist/chunks/useMainLoopModel-DSN5HjV1.js +1 -0
  224. package/dist/chunks/useManagePlugins-ntnOf5OU.js +1 -0
  225. package/dist/chunks/useMergedTools-C5Yns9Ij.js +1 -0
  226. package/dist/chunks/useSearchInput-B_mY9wBq.js +1 -0
  227. package/dist/chunks/useSettingsErrors-CM7tThcp.js +1 -0
  228. package/dist/chunks/util-Bb2S6g9N.js +1 -0
  229. package/dist/chunks/{validatePlugin-D6tFo87L.js → validatePlugin-D8WQ5z4W.js} +1 -1
  230. package/dist/chunks/vim-Dpnhgoz_.js +1 -0
  231. package/dist/chunks/worktree-a5oOPSYl.js +1 -0
  232. package/dist/cli.js +1 -1
  233. package/package.json +1 -12
  234. package/dist/chunks/AddWorkspaceDirectory-OgcBcK5A.js +0 -1
  235. package/dist/chunks/AgentsMdExternalIncludesDialog-CDNd5-7E.js +0 -1
  236. package/dist/chunks/AgentsMdExternalIncludesDialog-CNEifEyV.js +0 -1
  237. package/dist/chunks/App-B-3tPQ3k.js +0 -1
  238. package/dist/chunks/BackgroundTasksDialog-COuhHcey.js +0 -2
  239. package/dist/chunks/BypassPermissionsModeDialog-bJek4siJ.js +0 -1
  240. package/dist/chunks/CustomSelect-DoeEXOIP.js +0 -1
  241. package/dist/chunks/DiffDialog-B3X9FMpO.js +0 -6
  242. package/dist/chunks/Doctor-6PXyjIi6.js +0 -3
  243. package/dist/chunks/Doctor-DNgkgYhB.js +0 -1
  244. package/dist/chunks/ExitFlow-DgAZp_8U.js +0 -2
  245. package/dist/chunks/Grove-CHatOzcE.js +0 -11
  246. package/dist/chunks/InvalidConfigDialog-DXL92MN9.js +0 -1
  247. package/dist/chunks/KeybindingProviderSetup-DA37QUFs.js +0 -1
  248. package/dist/chunks/MCPConnectionManager-thZd-xA_.js +0 -1
  249. package/dist/chunks/MCPToolListView-CpY-YJg4.js +0 -1
  250. package/dist/chunks/McpParsingWarnings-JvChf3xr.js +0 -1
  251. package/dist/chunks/MessageSelector-C0_iw7SI.js +0 -3
  252. package/dist/chunks/Messages-K4DDsDP9.js +0 -10
  253. package/dist/chunks/Onboarding-C1UdzM-1.js +0 -1
  254. package/dist/chunks/PromptInputFooterSuggestions-AyLog8p7.js +0 -1
  255. package/dist/chunks/PromptInputHelpMenu-oyic20ip.js +0 -1
  256. package/dist/chunks/QueryEngine-DYxBjJ4i.js +0 -1
  257. package/dist/chunks/REPL-CQBJRrT0.js +0 -124
  258. package/dist/chunks/REPL-CrVuMQY2.js +0 -1
  259. package/dist/chunks/ResumeConversation-Dl8H9Gfy.js +0 -1
  260. package/dist/chunks/SearchExtraToolsTool-lv7VE50N.js +0 -1
  261. package/dist/chunks/Settings-TGp3fPrS.js +0 -3
  262. package/dist/chunks/Spinner-zYPFVFHN.js +0 -1
  263. package/dist/chunks/TextInput-CD9iau2k.js +0 -22
  264. package/dist/chunks/ThemePicker-0F0hZYPX.js +0 -1
  265. package/dist/chunks/TrustDialog-C76YiMKz.js +0 -1
  266. package/dist/chunks/_baseEach-4ff-vRlp.js +0 -1
  267. package/dist/chunks/add-dir-JMsRLGfx.js +0 -1
  268. package/dist/chunks/agents-9qQ8I6zW.js +0 -101
  269. package/dist/chunks/allErrors-DfWylHSw.js +0 -1
  270. package/dist/chunks/analytics-DJobLaWP.js +0 -1
  271. package/dist/chunks/backgroundHousekeeping-BGxHB_OX.js +0 -1
  272. package/dist/chunks/backgroundHousekeeping-CVNIhQg8.js +0 -17
  273. package/dist/chunks/banner-Cu2-XUek.js +0 -2
  274. package/dist/chunks/branch-C4TsMEkx.js +0 -2
  275. package/dist/chunks/btw-Dn1eYFAz.js +0 -1
  276. package/dist/chunks/caches-BGzKwpnc.js +0 -1
  277. package/dist/chunks/caches-DArHxBgL.js +0 -1
  278. package/dist/chunks/client-BiqbIkwr.js +0 -1
  279. package/dist/chunks/client-CZ8nyVh5.js +0 -1
  280. package/dist/chunks/commands-QepeBbFn.js +0 -1
  281. package/dist/chunks/compact-Bu9BUpxV.js +0 -2
  282. package/dist/chunks/config-C-Y2qtB2.js +0 -3
  283. package/dist/chunks/config-D58C3_Lu.js +0 -1
  284. package/dist/chunks/config-DD8fCYXn.js +0 -1
  285. package/dist/chunks/context-CY_yfdYa.js +0 -1
  286. package/dist/chunks/context-noninteractive-BDDi3NLF.js +0 -1
  287. package/dist/chunks/conversation-B0wxBwzv.js +0 -1
  288. package/dist/chunks/conversation-DUu9qBnq.js +0 -1
  289. package/dist/chunks/conversationRecovery-2ft8sCPE.js +0 -1
  290. package/dist/chunks/crossProjectResume-6boHMUBx.js +0 -40
  291. package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
  292. package/dist/chunks/cwd-Pa83R95t.js +0 -1
  293. package/dist/chunks/datadog-BPuGcxxC.js +0 -1
  294. package/dist/chunks/debug-Bglx1aTu.js +0 -39
  295. package/dist/chunks/doctor-CkLzqAMd.js +0 -1
  296. package/dist/chunks/entry-TNOoyy7_.js +0 -13
  297. package/dist/chunks/esm-eTAUP-La.js +0 -1
  298. package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
  299. package/dist/chunks/exit-DXApFJIP.js +0 -1
  300. package/dist/chunks/extraUsage-CmQaLPV1.js +0 -1
  301. package/dist/chunks/extractMemories-xP63mv6R.js +0 -1
  302. package/dist/chunks/fast-C5nQH8rm.js +0 -1
  303. package/dist/chunks/fast-eGx2IxD7.js +0 -1
  304. package/dist/chunks/fetchModelList-CxLsVNsu.js +0 -1
  305. package/dist/chunks/fetchModelList-D24lRIgR.js +0 -1
  306. package/dist/chunks/fileSuggestions-DHxdwq28.js +0 -3
  307. package/dist/chunks/firstPartyEventLogger-BVAogAX8.js +0 -1
  308. package/dist/chunks/firstPartyEventLogger-M6UMli2c.js +0 -3
  309. package/dist/chunks/generateSessionName-BQoDduyA.js +0 -1
  310. package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
  311. package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
  312. package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
  313. package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
  314. package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
  315. package/dist/chunks/goal-D7c2mSds.js +0 -3
  316. package/dist/chunks/grok-B2-ZbUiR.js +0 -1
  317. package/dist/chunks/grove-O6qp7ITR.js +0 -1
  318. package/dist/chunks/help-CZJdRviD.js +0 -1
  319. package/dist/chunks/history-CQiUERTL.js +0 -1
  320. package/dist/chunks/hooks-BNuUlMzL.js +0 -1
  321. package/dist/chunks/install-T_CV1Slu.js +0 -1
  322. package/dist/chunks/instrumentation-BjqUZ383.js +0 -21
  323. package/dist/chunks/keybindings-CLRaiL_Z.js +0 -1
  324. package/dist/chunks/launchLocalMemory-DrbKrwXc.js +0 -3
  325. package/dist/chunks/launchOnboarding-tqsMD8ni.js +0 -8
  326. package/dist/chunks/loadAgentsDir-CcmY8zCj.js +0 -1
  327. package/dist/chunks/localSearch-DrUj0B-d.js +0 -1
  328. package/dist/chunks/logoUtils-x2pHV-Nl.js +0 -1
  329. package/dist/chunks/main-kOVUGxOS.js +0 -345
  330. package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
  331. package/dist/chunks/mcp-BNd29r6p.js +0 -6
  332. package/dist/chunks/mcp-D0wAJrRT.js +0 -1
  333. package/dist/chunks/mcp-mgOlm1cY.js +0 -2
  334. package/dist/chunks/memory-DDLk9_LJ.js +0 -1
  335. package/dist/chunks/mode-CcNsWgK3.js +0 -2
  336. package/dist/chunks/model-BwBG0V1u.js +0 -1
  337. package/dist/chunks/model-DzCP4K-9.js +0 -1
  338. package/dist/chunks/modelOptions-DRaG3bo0.js +0 -1
  339. package/dist/chunks/nativeInstaller-C3pVPqrZ.js +0 -1
  340. package/dist/chunks/onChangeAppState-BlaoFbYF.js +0 -1
  341. package/dist/chunks/open-BtQHzzL9.js +0 -1
  342. package/dist/chunks/openai-CDN71NdX.js +0 -2
  343. package/dist/chunks/overlayContext-BT2Lq8ei.js +0 -1
  344. package/dist/chunks/parser-CG5RuOCK.js +0 -1
  345. package/dist/chunks/partition-CIl_ORUT.js +0 -1
  346. package/dist/chunks/permissions-zSNOZSwr.js +0 -3
  347. package/dist/chunks/pidLock-BTqO-h7Y.js +0 -3
  348. package/dist/chunks/plan-Bs6em6lk.js +0 -1
  349. package/dist/chunks/platform-BacQ6ACS.js +0 -2
  350. package/dist/chunks/plugin-DDDxjBa0.js +0 -17
  351. package/dist/chunks/pluginCliCommands-DXZfCZsv.js +0 -1
  352. package/dist/chunks/pluginOperations-hXYLrzM2.js +0 -2
  353. package/dist/chunks/pluginStartupCheck-HS1ZceZa.js +0 -1
  354. package/dist/chunks/plugins-COoGBYk6.js +0 -4
  355. package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
  356. package/dist/chunks/print-BASybEtO.js +0 -13
  357. package/dist/chunks/processBashCommand-DDi_Pymt.js +0 -1
  358. package/dist/chunks/processSlashCommand-Cq9kaoSF.js +0 -5
  359. package/dist/chunks/prompt-CHobfCB1.js +0 -1
  360. package/dist/chunks/prompt-CMm6RHHc.js +0 -1
  361. package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
  362. package/dist/chunks/reconciler-CeXqh95g.js +0 -1
  363. package/dist/chunks/refresh-Ce2yk28a.js +0 -1
  364. package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
  365. package/dist/chunks/reject-Bld5E-bn.js +0 -1
  366. package/dist/chunks/rename-CtBghpxZ.js +0 -1
  367. package/dist/chunks/resume-BWkaTDqd.js +0 -2
  368. package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
  369. package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
  370. package/dist/chunks/sandbox-adapter-8GO6eJxw.js +0 -1
  371. package/dist/chunks/sandbox-toggle-Dir9Polo.js +0 -1
  372. package/dist/chunks/searchExtraTools-BhDq8DTJ.js +0 -1
  373. package/dist/chunks/select-Bxf5-5sI.js +0 -1
  374. package/dist/chunks/sessionFileAccessHooks-CozocHQE.js +0 -1
  375. package/dist/chunks/sessionObserver-DGEQM4cO.js +0 -1
  376. package/dist/chunks/sessionStorage-BcAscOGE.js +0 -1
  377. package/dist/chunks/sessionTracing-BoDDYLxW.js +0 -11
  378. package/dist/chunks/settings-B2jvL8Dp.js +0 -24
  379. package/dist/chunks/settings-CisDe8DB.js +0 -1
  380. package/dist/chunks/setup-BRypY6iT.js +0 -3
  381. package/dist/chunks/sinks-CGdKmq_8.js +0 -1
  382. package/dist/chunks/sinks-Cz2HfgMU.js +0 -1
  383. package/dist/chunks/skillChangeDetector-xviGstqm.js +0 -1
  384. package/dist/chunks/skills-CX_AvwLG.js +0 -1
  385. package/dist/chunks/src-CHw1lvBc.js +0 -3
  386. package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
  387. package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
  388. package/dist/chunks/state-BhOKSFi5.js +0 -1
  389. package/dist/chunks/status-Daaak6Bo.js +0 -1
  390. package/dist/chunks/statusNoticeHelpers-vFVgIYuw.js +0 -1
  391. package/dist/chunks/switcher-BpgmH4AI.js +0 -1
  392. package/dist/chunks/tipRegistry-DamZr34w.js +0 -2
  393. package/dist/chunks/toolPool-CX5wDBi1.js +0 -1
  394. package/dist/chunks/useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js +0 -1
  395. package/dist/chunks/useMainLoopModel-DwjSVzzO.js +0 -1
  396. package/dist/chunks/useManagePlugins-BqfIVa6E.js +0 -1
  397. package/dist/chunks/useMergedTools-Bw8FchX8.js +0 -1
  398. package/dist/chunks/useSearchInput-B25K1RnK.js +0 -1
  399. package/dist/chunks/useSettingsErrors-DYQ44kX4.js +0 -1
  400. package/dist/chunks/util-CtlC2dsN.js +0 -1
  401. package/dist/chunks/vim-CoRp9lY1.js +0 -1
  402. package/dist/chunks/worktree-B8apCnVe.js +0 -1
@@ -0,0 +1,13 @@
1
+ import{c as e,l as t,o as n,s as r}from"./envUtils-DfkgIdYf.js";import{n as i,t as a}from"./defineProperty-C-QyHrDq.js";import{A as o,B as s,I as c,J as l,M as u,N as d,P as f,Q as p,U as m,W as h,X as g,Z as _,b as v,d as y,k as b,l as x,o as S,s as C,x as w,z as T}from"./types-97nL3naE.js";import{A as ee,Ft as te,Hn as ne,Ht as re,Mn as ie,O as ae,Pt as oe,W as E,at as D,nn as se,on as O,vn as ce,yn as le}from"./state-BQ4BEGin.js";import{$C as ue,$p as de,$r as fe,A as k,Aa as A,Ag as pe,Am as me,As as he,Av as ge,B as _e,Bd as j,Bl as ve,Bo as M,Bt as ye,C as N,Cc as be,Cg as xe,Ci as Se,Cm as Ce,Cs as we,Cv as Te,DC as P,Da as F,Dc as I,Di as Ee,Dm as L,EC as De,Fl as Oe,Fo as ke,Gn as Ae,Gu as je,HS as Me,Hg as Ne,Ho as Pe,Ia as Fe,Ig as Ie,Il as Le,Io as Re,Ji as ze,Ll as Be,Lo as Ve,Lr as He,MC as Ue,Mi as We,Ml as Ge,Mm as Ke,Ms as qe,My as Je,NC as Ye,Ng as Xe,Ni as Ze,Oa as Qe,Og as $e,Om as et,PC as tt,Pa as nt,Pm as rt,Ps as it,Pv as at,Py as ot,Q_ as st,Qp as ct,Qr as lt,Ro as ut,Rs as dt,Sc as ft,Sg as pt,Sn as mt,TC as ht,Ti as gt,Ug as _t,Uo as vt,Up as yt,Us as bt,V as xt,Vd as St,Vl as Ct,Vo as wt,Vt as Tt,Wg as Et,Wo as Dt,Wp as Ot,Ws as kt,Xr as At,Y_ as jt,Yn as Mt,Yr as Nt,Yy as Pt,Z_ as Ft,_c as It,_g as Lt,_i as Rt,_n as zt,_u as Bt,af as Vt,am as Ht,ao as Ut,aw as Wt,b as Gt,bc as Kt,bg as qt,bn as Jt,bv as Yt,cf as Xt,cs as Zt,cv as Qt,cy as $t,ef as R,em as en,f as tn,fo as nn,fp as rn,gg as an,gi as on,gr as sn,gu as cn,gw as ln,hC as un,hS as dn,hc as fn,hi as z,ho as pn,if as mn,ih as hn,im as gn,iv as _n,iy as vn,jC as yn,jl as bn,js as xn,jv as Sn,kC as Cn,kg as wn,kv as Tn,lf as En,ls as Dn,lv as On,ly as kn,mc as An,mi as jn,mn as Mn,mw as Nn,nf as Pn,nh as Fn,nw as In,o as Ln,of as Rn,oo as zn,ov as Bn,ow as Vn,oy as Hn,pf as Un,pp as Wn,pw as Gn,qu as Kn,rf as qn,rh as Jn,rw as Yn,s as Xn,sf as Zn,ss as Qn,sv as $n,sy as er,tT as tr,tf as nr,th as rr,tv as ir,uf as ar,uo as or,us as sr,uv as cr,v as lr,vc as ur,vg as dr,vn as fr,vw as pr,w as mr,wc as hr,wg as gr,wm as _r,xc as vr,xn as yr,xs as br,y as xr,yn as Sr,yw as Cr,zo as wr,zs as Tr,zv as Er}from"./loadAgentsDir-DGozQu_6.js";import{n as Dr,t as Or}from"./cwd-BvNt_018.js";import{$ as kr,C as B,E as Ar,I as jr,M as V,S as Mr,V as Nr,c as H,et as Pr,f as Fr,i as U,u as Ir,x as Lr}from"./debug-CRnGsZOV.js";import{Hn as Rr,Jr as zr,W as Br,Wn as Vr,Xr as Hr,Yr as Ur,_t as Wr,d as Gr,er as Kr,h as qr,nr as Jr,rt as Yr,tt as Xr,u as Zr,ut as Qr}from"./settings-CodSADx8.js";import{E as $r,k as ei}from"./config-CWPHVTic.js";import{i as ti,n as ni,o as W}from"./process-gEbdy6uY.js";import{H as ri,c as ii,i as ai,o as oi,q as si,s as G}from"./log-DoSpAwRP.js";import{n as ci}from"./analytics-COpjZpvd.js";import{At as li,D as ui,Mt as di,Pt as fi,f as pi,g as mi,jt as hi,k as gi,r as _i,s as vi,v as yi}from"./model-DpZaKZMb.js";import{_t as bi,at as xi,bn as Si,it as Ci,tn as wi,vn as Ti,vt as Ei,yt as Di}from"./prompt-DzO1um1h.js";import{i as Oi,n as K,r as ki,t as Ai}from"./reject-CEUkoI2G.js";import{t as ji}from"./pluginBlocklist-BAr9WTup.js";import{n as Mi,t as Ni}from"./toolPool-DHS8jWaL.js";import{n as Pi}from"./conversationRecovery-BBJzrA0g.js";import{a as Fi,i as Ii,n as Li,r as Ri}from"./QueryEngine-egz5mbaW.js";import{n as zi,r as Bi}from"./sessionTitle-k4wpUS5l.js";import{n as Vi,r as Hi}from"./sideQuestion-Cl8m2qYx.js";import{n as Ui,r as Wi}from"./context-noninteractive-DvfVvmSE.js";import{n as Gi,r as Ki}from"./modelOptions-CXBfKFXA.js";import{a as qi,o as Ji,t as Yi}from"./skillChangeDetector-BrrZaFkT.js";import{n as Xi}from"./reconciler-CVMmAaCy.js";import{n as Zi,t as Qi}from"./refresh-CAGv8BJY.js";import{dirname as $i,join as ea}from"path";import{randomUUID as q}from"crypto";import{readFile as ta,stat as na}from"fs/promises";import{cwd as J}from"process";v(),S();var ra=C(()=>h({inputTokens:m(),outputTokens:m(),cacheReadInputTokens:m(),cacheCreationInputTokens:m(),webSearchRequests:m(),costUSD:m(),contextWindow:m(),maxOutputTokens:m()})),ia=C(()=>s(`json_schema`));C(()=>h({type:ia()}));var aa=C(()=>h({type:s(`json_schema`),schema:l(g(),p())}));C(()=>aa());var oa=C(()=>b([`user`,`project`,`org`,`temporary`,`oauth`]));C(()=>b([`local`,`user`,`project`]).describe(`Config scope for settings.`)),C(()=>s(`context-1m-2025-08-07`));var sa=C(()=>h({type:s(`adaptive`)}).describe(`Work Mate decides when and how much to think (Opus 4.6+).`)),ca=C(()=>h({type:s(`enabled`),budgetTokens:m().optional()}).describe(`Fixed thinking token budget (older models)`)),la=C(()=>h({type:s(`disabled`)}).describe(`No extended thinking`));C(()=>_([sa(),ca(),la()]).describe(`Controls Work Mate's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var ua=C(()=>h({type:s(`stdio`).optional(),command:g(),args:d(g()).optional(),env:l(g(),g()).optional()})),da=C(()=>h({type:s(`sse`),url:g(),headers:l(g(),g()).optional()})),fa=C(()=>h({type:s(`http`),url:g(),headers:l(g(),g()).optional()})),pa=C(()=>h({type:s(`sdk`),name:g()})),ma=C(()=>_([ua(),da(),fa(),pa()])),ha=C(()=>h({type:s(`claudeai-proxy`),url:g(),id:g()})),ga=C(()=>_([ma(),ha()])),_a=C(()=>h({name:g().describe(`Server name as configured`),status:b([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:h({name:g(),version:g()}).optional().describe(`Server information (available when connected)`),error:g().optional().describe(`Error message (available when status is 'failed')`),config:ga().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:g().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:d(h({name:g(),description:g().optional(),annotations:h({readOnly:f().optional(),destructive:f().optional(),openWorld:f().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:h({experimental:l(g(),p()).optional()}).optional().describe(`@internal Server capabilities (available when connected). experimental['claude/channel'] is only present if the server's plugin is on the approved channels allowlist — use its presence to decide whether to show an Enable-channel prompt.`)}).describe(`Status information for an MCP server connection.`));C(()=>h({added:d(g()).describe(`Names of servers that were added`),removed:d(g()).describe(`Names of servers that were removed`),errors:l(g(),g()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var Y=C(()=>b([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),va=C(()=>b([`allow`,`deny`,`ask`])),ya=C(()=>h({toolName:g(),ruleContent:g().optional()})),ba=C(()=>c(`type`,[h({type:s(`addRules`),rules:d(ya()),behavior:va(),destination:Y()}),h({type:s(`replaceRules`),rules:d(ya()),behavior:va(),destination:Y()}),h({type:s(`removeRules`),rules:d(ya()),behavior:va(),destination:Y()}),h({type:s(`setMode`),mode:T(()=>Sa()),destination:Y()}),h({type:s(`addDirectories`),directories:d(g()),destination:Y()}),h({type:s(`removeDirectories`),directories:d(g()),destination:Y()})])),xa=C(()=>b([`user_temporary`,`user_permanent`,`user_reject`]).describe(`Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs).`));C(()=>_([h({behavior:s(`allow`),updatedInput:l(g(),p()).optional(),updatedPermissions:d(ba()).optional(),toolUseID:g().optional(),decisionClassification:xa().optional()}),h({behavior:s(`deny`),message:g(),interrupt:f().optional(),toolUseID:g().optional(),decisionClassification:xa().optional()})]));var Sa=C(()=>b([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).describe(`Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved. 'auto' - Automatic mode (transcript classifier).`)),Ca=`PreToolUse.PostToolUse.PostToolUseFailure.Notification.UserPromptSubmit.SessionStart.SessionEnd.Stop.StopFailure.SubagentStart.SubagentStop.PreCompact.PostCompact.PermissionRequest.PermissionDenied.Setup.TeammateIdle.TaskCreated.TaskCompleted.Elicitation.ElicitationResult.ConfigChange.WorktreeCreate.WorktreeRemove.InstructionsLoaded.CwdChanged.FileChanged`.split(`.`),wa=C(()=>b(Ca)),X=C(()=>h({session_id:g(),transcript_path:g(),cwd:g(),permission_mode:g().optional(),agent_id:g().optional().describe(`Subagent identifier. Present only when the hook fires from within a subagent (e.g., a tool called by an AgentTool worker). Absent for the main thread, even in --agent sessions. Use this field (not agent_type) to distinguish subagent calls from main-thread calls.`),agent_type:g().optional().describe(`Agent type name (e.g., "general-purpose", "code-reviewer"). Present when the hook fires from within a subagent (alongside agent_id), or on the main thread of a session started with --agent (without agent_id).`)})),Ta=C(()=>X().and(h({hook_event_name:s(`PreToolUse`),tool_name:g(),tool_input:p(),tool_use_id:g()}))),Ea=C(()=>X().and(h({hook_event_name:s(`PermissionRequest`),tool_name:g(),tool_input:p(),permission_suggestions:d(ba()).optional()}))),Da=C(()=>X().and(h({hook_event_name:s(`PostToolUse`),tool_name:g(),tool_input:p(),tool_response:p(),tool_use_id:g()}))),Oa=C(()=>X().and(h({hook_event_name:s(`PostToolUseFailure`),tool_name:g(),tool_input:p(),tool_use_id:g(),error:g(),is_interrupt:f().optional()}))),ka=C(()=>X().and(h({hook_event_name:s(`PermissionDenied`),tool_name:g(),tool_input:p(),tool_use_id:g(),reason:g()}))),Aa=C(()=>X().and(h({hook_event_name:s(`Notification`),message:g(),title:g().optional(),notification_type:g()}))),ja=C(()=>X().and(h({hook_event_name:s(`UserPromptSubmit`),prompt:g()}))),Ma=C(()=>X().and(h({hook_event_name:s(`SessionStart`),source:b([`startup`,`resume`,`clear`,`compact`]),agent_type:g().optional(),model:g().optional()}))),Na=C(()=>X().and(h({hook_event_name:s(`Setup`),trigger:b([`init`,`maintenance`])}))),Pa=C(()=>X().and(h({hook_event_name:s(`Stop`),stop_hook_active:f(),last_assistant_message:g().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Fa=C(()=>X().and(h({hook_event_name:s(`StopFailure`),error:No(),error_details:g().optional(),last_assistant_message:g().optional()}))),Ia=C(()=>X().and(h({hook_event_name:s(`SubagentStart`),agent_id:g(),agent_type:g()}))),La=C(()=>X().and(h({hook_event_name:s(`SubagentStop`),stop_hook_active:f(),agent_id:g(),agent_transcript_path:g(),agent_type:g(),last_assistant_message:g().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Ra=C(()=>X().and(h({hook_event_name:s(`PreCompact`),trigger:b([`manual`,`auto`]),custom_instructions:g().nullable()}))),za=C(()=>X().and(h({hook_event_name:s(`PostCompact`),trigger:b([`manual`,`auto`]),compact_summary:g().describe(`The conversation summary produced by compaction`)}))),Ba=C(()=>X().and(h({hook_event_name:s(`TeammateIdle`),teammate_name:g(),team_name:g()}))),Va=C(()=>X().and(h({hook_event_name:s(`TaskCreated`),task_id:g(),task_subject:g(),task_description:g().optional(),teammate_name:g().optional(),team_name:g().optional()}))),Ha=C(()=>X().and(h({hook_event_name:s(`TaskCompleted`),task_id:g(),task_subject:g(),task_description:g().optional(),teammate_name:g().optional(),team_name:g().optional()}))),Ua=C(()=>X().and(h({hook_event_name:s(`Elicitation`),mcp_server_name:g(),message:g(),mode:b([`form`,`url`]).optional(),url:g().optional(),elicitation_id:g().optional(),requested_schema:l(g(),p()).optional()})).describe(`Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog.`)),Wa=C(()=>X().and(h({hook_event_name:s(`ElicitationResult`),mcp_server_name:g(),elicitation_id:g().optional(),mode:b([`form`,`url`]).optional(),action:b([`accept`,`decline`,`cancel`]),content:l(g(),p()).optional()})).describe(`Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server.`)),Ga=[`user_settings`,`project_settings`,`local_settings`,`policy_settings`,`skills`],Ka=C(()=>X().and(h({hook_event_name:s(`ConfigChange`),source:b(Ga),file_path:g().optional()}))),qa=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Ja=[`User`,`Project`,`Local`,`Managed`],Ya=C(()=>X().and(h({hook_event_name:s(`InstructionsLoaded`),file_path:g(),memory_type:b(Ja),load_reason:b(qa),globs:d(g()).optional(),trigger_file_path:g().optional(),parent_file_path:g().optional()}))),Xa=C(()=>X().and(h({hook_event_name:s(`WorktreeCreate`),name:g()}))),Za=C(()=>X().and(h({hook_event_name:s(`WorktreeRemove`),worktree_path:g()}))),Qa=C(()=>X().and(h({hook_event_name:s(`CwdChanged`),old_cwd:g(),new_cwd:g()}))),$a=C(()=>X().and(h({hook_event_name:s(`FileChanged`),file_path:g(),event:b([`change`,`add`,`unlink`])}))),eo=[`clear`,`resume`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],to=C(()=>b(eo)),no=C(()=>X().and(h({hook_event_name:s(`SessionEnd`),reason:to()}))),ro=C(()=>_([Ta(),Da(),Oa(),ka(),Aa(),ja(),Ma(),no(),Pa(),Fa(),Ia(),La(),Ra(),za(),Ea(),Na(),Ba(),Va(),Ha(),Ua(),Wa(),Ka(),Ya(),Xa(),Za(),Qa(),$a()])),io=C(()=>h({async:s(!0),asyncTimeout:m().optional()})),ao=C(()=>h({hookEventName:s(`PreToolUse`),permissionDecision:va().optional(),permissionDecisionReason:g().optional(),updatedInput:l(g(),p()).optional(),additionalContext:g().optional()})),oo=C(()=>h({hookEventName:s(`UserPromptSubmit`),additionalContext:g().optional()})),so=C(()=>h({hookEventName:s(`SessionStart`),additionalContext:g().optional(),initialUserMessage:g().optional(),watchPaths:d(g()).optional()})),co=C(()=>h({hookEventName:s(`Setup`),additionalContext:g().optional()})),lo=C(()=>h({hookEventName:s(`SubagentStart`),additionalContext:g().optional()})),uo=C(()=>h({hookEventName:s(`PostToolUse`),additionalContext:g().optional(),updatedMCPToolOutput:p().optional()})),fo=C(()=>h({hookEventName:s(`PostToolUseFailure`),additionalContext:g().optional()})),po=C(()=>h({hookEventName:s(`PermissionDenied`),retry:f().optional()})),mo=C(()=>h({hookEventName:s(`Notification`),additionalContext:g().optional()})),ho=C(()=>h({hookEventName:s(`PermissionRequest`),decision:_([h({behavior:s(`allow`),updatedInput:l(g(),p()).optional(),updatedPermissions:d(ba()).optional()}),h({behavior:s(`deny`),message:g().optional(),interrupt:f().optional()})])})),go=C(()=>h({hookEventName:s(`CwdChanged`),watchPaths:d(g()).optional()})),_o=C(()=>h({hookEventName:s(`FileChanged`),watchPaths:d(g()).optional()})),vo=C(()=>h({continue:f().optional(),suppressOutput:f().optional(),stopReason:g().optional(),decision:b([`approve`,`block`]).optional(),systemMessage:g().optional(),reason:g().optional(),hookSpecificOutput:_([ao(),oo(),so(),co(),lo(),uo(),fo(),po(),mo(),ho(),yo(),bo(),go(),_o(),xo()]).optional()})),yo=C(()=>h({hookEventName:s(`Elicitation`),action:b([`accept`,`decline`,`cancel`]).optional(),content:l(g(),p()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),bo=C(()=>h({hookEventName:s(`ElicitationResult`),action:b([`accept`,`decline`,`cancel`]).optional(),content:l(g(),p()).optional()}).describe(`Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server.`)),xo=C(()=>h({hookEventName:s(`WorktreeCreate`),worktreePath:g()}).describe(`Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead.`));C(()=>_([io(),vo()]));var So=C(()=>h({key:g().describe(`Unique key for this option, returned in the response`),label:g().describe(`Display text for this option`),description:g().optional().describe(`Optional description shown below the label`)}));C(()=>h({prompt:g().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:g().describe(`The prompt message to display to the user`),options:d(So()).describe(`Available options for the user to choose from`)})),C(()=>h({prompt_response:g().describe(`The request ID from the corresponding prompt request`),selected:g().describe(`The key of the selected option`)}));var Co=C(()=>h({name:g().describe(`Skill name (without the leading slash)`),description:g().describe(`Description of what the skill does`),argumentHint:g().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),wo=C(()=>h({name:g().describe(`Agent type identifier (e.g., "Explore")`),description:g().describe(`Description of when to use this agent`),model:g().optional().describe(`Model alias this agent uses. If omitted, inherits the parent's model`)}).describe(`Information about an available subagent that can be invoked via the Task tool.`)),To=C(()=>h({value:g().describe(`Model identifier to use in API calls`),displayName:g().describe(`Human-readable display name`),description:g().describe(`Description of the model's capabilities`),supportsAdaptiveThinking:f().optional().describe(`Whether this model supports adaptive thinking (Work Mate decides when and how much to think)`),supportsFastMode:f().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:f().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),Eo=C(()=>h({email:g().optional(),organization:g().optional(),subscriptionType:g().optional(),tokenSource:g().optional(),apiKeySource:g().optional(),apiProvider:b([`firstParty`,`bedrock`,`vertex`,`foundry`]).optional().describe(`Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).`)}).describe(`Information about the logged in user's account.`)),Do=C(()=>_([g(),l(g(),ma())])),Oo=C(()=>h({description:g().describe(`Natural language description of when to use this agent`),tools:d(g()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:d(g()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:g().describe(`The agent's system prompt`),model:g().optional().describe(`Model alias (e.g. 'sonnet', 'opus', 'haiku') or full model ID (e.g. 'claude-opus-4-5'). If omitted or 'inherit', uses the main model`),mcpServers:d(Do()).optional(),criticalSystemReminder_EXPERIMENTAL:g().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:d(g()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:g().optional().describe(`Auto-submitted as the first user turn when this agent is the main thread agent. Slash commands are processed. Prepended to any user-provided prompt.`),maxTurns:m().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:f().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:b([`user`,`project`,`local`]).optional().describe(`Scope for auto-loading agent memory files. 'user' - ~/.workmate/agent-memory/<agentType>/, 'project' - .workmate/agent-memory/<agentType>/, 'local' - .workmate/agent-memory-local/<agentType>/`),permissionMode:Sa().optional().describe(`Permission mode controlling how tool executions are handled`)}).describe(`Definition for a custom subagent that can be invoked via the Agent tool.`));C(()=>b([`user`,`project`,`local`]).describe(`Source for loading filesystem-based settings. 'user' - Global user settings (~/.workmate/settings.json). 'project' - Project settings (.workmate/settings.json). 'local' - Local settings (.workmate/settings.local.json).`)),C(()=>h({type:s(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:g().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),C(()=>h({canRewind:f(),error:g().optional(),filesChanged:d(g()).optional(),insertions:m().optional(),deletions:m().optional()}).describe(`Result of a rewindFiles operation.`));var ko=C(()=>p()),Ao=C(()=>p()),jo=C(()=>p()),Z=C(()=>g()),Mo=C(()=>p()),No=C(()=>b([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),Po=C(()=>_([s(`compacting`),o()])),Fo=C(()=>h({type:s(`user`),message:ko(),parent_tool_use_id:g().nullable(),isSynthetic:f().optional(),tool_use_result:p().optional(),priority:b([`now`,`next`,`later`]).optional(),timestamp:g().optional().describe(`ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.`)})),Io=C(()=>Fo().extend({uuid:Z().optional(),session_id:g().optional()})),Lo=C(()=>Fo().extend({uuid:Z(),session_id:g(),isReplay:s(!0)})),Ro=C(()=>h({status:b([`allowed`,`allowed_warning`,`rejected`]),resetsAt:m().optional(),rateLimitType:b([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:m().optional(),overageStatus:b([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:m().optional(),overageDisabledReason:b([`overage_not_provisioned`,`org_level_disabled`,`org_level_disabled_until`,`out_of_credits`,`seat_tier_level_disabled`,`member_level_disabled`,`seat_tier_zero_credit_limit`,`group_zero_credit_limit`,`member_zero_credit_limit`,`org_service_level_disabled`,`org_service_zero_credit_limit`,`no_limits_configured`,`unknown`]).optional(),isUsingOverage:f().optional(),surpassedThreshold:m().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),zo=C(()=>h({type:s(`assistant`),message:Ao(),parent_tool_use_id:g().nullable(),error:No().optional(),uuid:Z(),session_id:g()})),Bo=C(()=>h({type:s(`rate_limit_event`),rate_limit_info:Ro(),uuid:Z(),session_id:g()}).describe(`Rate limit event emitted when rate limit info changes.`)),Vo=C(()=>h({type:s(`streamlined_text`),text:g().describe(`Text content preserved from the assistant message`),session_id:g(),uuid:Z()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),Ho=C(()=>h({type:s(`streamlined_tool_use_summary`),tool_summary:g().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:g(),uuid:Z()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),Uo=C(()=>h({tool_name:g(),tool_use_id:g(),tool_input:l(g(),p())})),Wo=C(()=>h({type:s(`result`),subtype:s(`success`),duration_ms:m(),duration_api_ms:m(),is_error:f(),num_turns:m(),result:g(),stop_reason:g().nullable(),total_cost_usd:m(),usage:Mo(),modelUsage:l(g(),ra()),permission_denials:d(Uo()),structured_output:p().optional(),fast_mode_state:ms().optional(),uuid:Z(),session_id:g()})),Go=C(()=>h({type:s(`result`),subtype:b([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:m(),duration_api_ms:m(),is_error:f(),num_turns:m(),stop_reason:g().nullable(),total_cost_usd:m(),usage:Mo(),modelUsage:l(g(),ra()),permission_denials:d(Uo()),errors:d(g()),fast_mode_state:ms().optional(),uuid:Z(),session_id:g()})),Ko=C(()=>_([Wo(),Go()])),qo=C(()=>h({type:s(`system`),subtype:s(`init`),agents:d(g()).optional(),apiKeySource:oa(),betas:d(g()).optional(),claude_code_version:g(),cwd:g(),tools:d(g()),mcp_servers:d(h({name:g(),status:g()})),model:g(),permissionMode:Sa(),slash_commands:d(g()),output_style:g(),skills:d(g()),plugins:d(h({name:g(),path:g(),source:g().optional().describe(`@internal Plugin source identifier in "name\\@marketplace" format. Sentinels: "name\\@inline" for --plugin-dir, "name\\@builtin" for built-in plugins.`)})),fast_mode_state:ms().optional(),uuid:Z(),session_id:g()})),Jo=C(()=>h({type:s(`stream_event`),event:jo(),parent_tool_use_id:g().nullable(),uuid:Z(),session_id:g()})),Yo=C(()=>h({type:s(`system`),subtype:s(`compact_boundary`),compact_metadata:h({trigger:b([`manual`,`auto`]),pre_tokens:m(),preserved_segment:h({head_uuid:Z(),anchor_uuid:Z(),tail_uuid:Z()}).optional().describe(`Relink info for messagesToKeep. Loaders splice the preserved segment at anchor_uuid (summary for suffix-preserving, boundary for prefix-preserving partial compact) so resume includes preserved content. Unset when compaction summarizes everything (no messagesToKeep).`)}),uuid:Z(),session_id:g()})),Xo=C(()=>h({type:s(`system`),subtype:s(`status`),status:Po(),permissionMode:Sa().optional(),uuid:Z(),session_id:g()})),Zo=C(()=>h({type:s(`system`),subtype:s(`post_turn_summary`),summarizes_uuid:g(),status_category:b([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:g(),is_noteworthy:f(),title:g(),description:g(),recent_action:g(),needs_action:g(),artifact_urls:d(g()),uuid:Z(),session_id:g()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),Qo=C(()=>h({type:s(`system`),subtype:s(`api_retry`),attempt:m(),max_retries:m(),retry_delay_ms:m(),error_status:m().nullable(),error:No(),uuid:Z(),session_id:g()}).describe(`Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response.`)),$o=C(()=>h({type:s(`system`),subtype:s(`local_command_output`),content:g(),uuid:Z(),session_id:g()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),es=C(()=>h({type:s(`system`),subtype:s(`hook_started`),hook_id:g(),hook_name:g(),hook_event:g(),uuid:Z(),session_id:g()})),ts=C(()=>h({type:s(`system`),subtype:s(`hook_progress`),hook_id:g(),hook_name:g(),hook_event:g(),stdout:g(),stderr:g(),output:g(),uuid:Z(),session_id:g()})),ns=C(()=>h({type:s(`system`),subtype:s(`hook_response`),hook_id:g(),hook_name:g(),hook_event:g(),output:g(),stdout:g(),stderr:g(),exit_code:m().optional(),outcome:b([`success`,`error`,`cancelled`]),uuid:Z(),session_id:g()})),rs=C(()=>h({type:s(`tool_progress`),tool_use_id:g(),tool_name:g(),parent_tool_use_id:g().nullable(),elapsed_time_seconds:m(),task_id:g().optional(),uuid:Z(),session_id:g()})),is=C(()=>h({type:s(`auth_status`),isAuthenticating:f(),output:d(g()),error:g().optional(),uuid:Z(),session_id:g()})),as=C(()=>h({type:s(`system`),subtype:s(`files_persisted`),files:d(h({filename:g(),file_id:g()})),failed:d(h({filename:g(),error:g()})),processed_at:g(),uuid:Z(),session_id:g()})),os=C(()=>h({type:s(`system`),subtype:s(`task_notification`),task_id:g(),tool_use_id:g().optional(),status:b([`completed`,`failed`,`stopped`]),output_file:g(),summary:g(),usage:h({total_tokens:m(),tool_uses:m(),duration_ms:m()}).optional(),uuid:Z(),session_id:g()})),ss=C(()=>h({type:s(`system`),subtype:s(`task_started`),task_id:g(),tool_use_id:g().optional(),description:g(),task_type:g().optional(),workflow_name:g().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:g().optional(),uuid:Z(),session_id:g()})),cs=C(()=>h({type:s(`system`),subtype:s(`session_state_changed`),state:b([`idle`,`running`,`requires_action`]),uuid:Z(),session_id:g()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),ls=C(()=>h({type:s(`system`),subtype:s(`task_progress`),task_id:g(),tool_use_id:g().optional(),description:g(),usage:h({total_tokens:m(),tool_uses:m(),duration_ms:m()}),last_tool_name:g().optional(),summary:g().optional(),uuid:Z(),session_id:g()})),us=C(()=>h({type:s(`tool_use_summary`),summary:g(),preceding_tool_use_ids:d(g()),uuid:Z(),session_id:g()})),ds=C(()=>h({type:s(`system`),subtype:s(`elicitation_complete`),mcp_server_name:g(),elicitation_id:g(),uuid:Z(),session_id:g()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),fs=C(()=>h({type:s(`prompt_suggestion`),suggestion:g(),uuid:Z(),session_id:g()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));C(()=>h({sessionId:g().describe(`Unique session identifier (UUID).`),summary:g().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:m().describe(`Last modified time in milliseconds since epoch.`),fileSize:m().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:g().optional().describe(`User-set session title via /rename.`),firstPrompt:g().optional().describe(`First meaningful user prompt in the session.`),gitBranch:g().optional().describe(`Git branch at the end of the session.`),cwd:g().optional().describe(`Working directory for the session.`),tag:g().optional().describe(`User-set session tag.`),createdAt:m().optional().describe(`Creation time in milliseconds since epoch, extracted from the first entry's timestamp.`)}).describe(`Session metadata returned by listSessions and getSessionInfo.`));var ps=C(()=>_([zo(),Io(),Lo(),Ko(),qo(),Jo(),Yo(),Xo(),Qo(),$o(),es(),ts(),ns(),rs(),is(),os(),ss(),ls(),cs(),as(),us(),Bo(),ds(),fs()])),ms=C(()=>b([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));v(),S();var hs=C(()=>p()),gs=C(()=>h({matcher:g().optional(),hookCallbackIds:d(g()),timeout:m().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),_s=C(()=>h({subtype:s(`initialize`),hooks:l(wa(),d(gs())).optional(),sdkMcpServers:d(g()).optional(),jsonSchema:l(g(),p()).optional(),systemPrompt:g().optional(),appendSystemPrompt:g().optional(),agents:l(g(),Oo()).optional(),promptSuggestions:f().optional(),agentProgressSummaries:f().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));C(()=>h({commands:d(Co()),agents:d(wo()),output_style:g(),available_output_styles:d(g()),models:d(To()),account:Eo(),pid:m().optional().describe(`@internal CLI process PID for tmux socket isolation`),fast_mode_state:ms().optional()}).describe(`Response from session initialization with available commands, models, and account info.`));var vs=C(()=>h({subtype:s(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),ys=C(()=>h({subtype:s(`can_use_tool`),tool_name:g(),input:l(g(),p()),permission_suggestions:d(ba()).optional(),blocked_path:g().optional(),decision_reason:g().optional(),title:g().optional(),display_name:g().optional(),tool_use_id:g(),agent_id:g().optional(),description:g().optional()}).describe(`Requests permission to use a tool with the given input.`)),bs=C(()=>h({subtype:s(`set_permission_mode`),mode:Sa()}).describe(`Sets the permission mode for tool execution handling.`)),xs=C(()=>h({subtype:s(`set_model`),model:g().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),Ss=C(()=>h({subtype:s(`set_max_thinking_tokens`),max_thinking_tokens:m().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Cs=C(()=>h({subtype:s(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));C(()=>h({mcpServers:d(_a())}).describe(`Response containing the current status of all MCP server connections.`));var ws=C(()=>h({subtype:s(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),Ts=C(()=>h({name:g(),tokens:m(),color:g(),isDeferred:f().optional()})),Es=C(()=>h({color:g(),isFilled:f(),categoryName:g(),tokens:m(),percentage:m(),squareFullness:m()}));C(()=>h({categories:d(Ts()),totalTokens:m(),maxTokens:m(),rawMaxTokens:m(),percentage:m(),gridRows:d(d(Es())),model:g(),memoryFiles:d(h({path:g(),type:g(),tokens:m()})),mcpTools:d(h({name:g(),serverName:g(),tokens:m(),isLoaded:f().optional()})),deferredBuiltinTools:d(h({name:g(),tokens:m(),isLoaded:f()})).optional(),systemTools:d(h({name:g(),tokens:m()})).optional(),systemPromptSections:d(h({name:g(),tokens:m()})).optional(),agents:d(h({agentType:g(),source:g(),tokens:m()})),slashCommands:h({totalCommands:m(),includedCommands:m(),tokens:m()}).optional(),skills:h({totalSkills:m(),includedSkills:m(),tokens:m(),skillFrontmatter:d(h({name:g(),source:g(),tokens:m()}))}).optional(),autoCompactThreshold:m().optional(),isAutoCompactEnabled:f(),messageBreakdown:h({toolCallTokens:m(),toolResultTokens:m(),attachmentTokens:m(),assistantMessageTokens:m(),userMessageTokens:m(),toolCallsByType:d(h({name:g(),callTokens:m(),resultTokens:m()})),attachmentsByType:d(h({name:g(),tokens:m()}))}).optional(),apiUsage:h({input_tokens:m(),output_tokens:m(),cache_creation_input_tokens:m(),cache_read_input_tokens:m()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var Ds=C(()=>h({subtype:s(`rewind_files`),user_message_id:g(),dry_run:f().optional()}).describe(`Rewinds file changes made since a specific user message.`));C(()=>h({canRewind:f(),error:g().optional(),filesChanged:d(g()).optional(),insertions:m().optional(),deletions:m().optional()}).describe(`Result of a rewindFiles operation.`));var Os=C(()=>h({subtype:s(`cancel_async_message`),message_uuid:g()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));C(()=>h({cancelled:f()}).describe(`Result of a cancel_async_message operation. cancelled=false means the message was not in the queue (already dequeued or never enqueued).`));var ks=C(()=>h({subtype:s(`seed_read_state`),path:g(),mtime:m()}).describe(`Seeds the readFileState cache with a path+mtime entry. Use when a prior Read was removed from context (e.g. by snip) so Edit validation would fail despite the client having observed the Read. The mtime lets the CLI detect if the file changed since the seeded Read — same staleness check as the normal path.`)),As=C(()=>h({subtype:s(`hook_callback`),callback_id:g(),input:ro(),tool_use_id:g().optional()}).describe(`Delivers a hook callback with its input data.`)),js=C(()=>h({subtype:s(`mcp_message`),server_name:g(),message:hs()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),Ms=C(()=>h({subtype:s(`mcp_set_servers`),servers:l(g(),ma())}).describe(`Replaces the set of dynamically managed MCP servers.`));C(()=>h({added:d(g()),removed:d(g()),errors:l(g(),g())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var Ns=C(()=>h({subtype:s(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));C(()=>h({commands:d(Co()),agents:d(wo()),plugins:d(h({name:g(),path:g(),source:g().optional()})),mcpServers:d(_a()),error_count:m()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var Ps=C(()=>h({subtype:s(`mcp_reconnect`),serverName:g()}).describe(`Reconnects a disconnected or failed MCP server.`)),Fs=C(()=>h({subtype:s(`mcp_toggle`),serverName:g(),enabled:f()}).describe(`Enables or disables an MCP server.`)),Is=C(()=>h({subtype:s(`stop_task`),task_id:g()}).describe(`Stops a running task.`)),Ls=C(()=>h({subtype:s(`apply_flag_settings`),settings:l(g(),p())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),Rs=C(()=>h({subtype:s(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));C(()=>h({effective:l(g(),p()),sources:d(h({source:b([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:l(g(),p())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:h({model:g()}).optional().describe("Runtime-resolved values after env overrides, session state, and model-specific defaults are applied. Unlike `effective` (disk merge), these reflect what will actually be sent to the API.")}).describe(`Effective merged settings plus raw per-source settings in merge order.`));var zs=C(()=>h({subtype:s(`elicitation`),mcp_server_name:g(),message:g(),mode:b([`form`,`url`]).optional(),url:g().optional(),elicitation_id:g().optional(),requested_schema:l(g(),p()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),Bs=C(()=>h({action:b([`accept`,`decline`,`cancel`]),content:l(g(),p()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),Vs=C(()=>_([vs(),ys(),_s(),bs(),xs(),Ss(),Cs(),ws(),As(),js(),Ds(),Os(),ks(),Ms(),Ns(),Ps(),Fs(),Is(),Ls(),Rs(),zs()])),Hs=C(()=>h({type:s(`control_request`),request_id:g(),request:Vs()})),Us=C(()=>h({subtype:s(`success`),request_id:g(),response:l(g(),p()).optional()})),Ws=C(()=>h({subtype:s(`error`),request_id:g(),error:g(),pending_permission_requests:d(T(()=>Hs())).optional()})),Gs=C(()=>h({type:s(`control_response`),response:_([Us(),Ws()])})),Ks=C(()=>h({type:s(`control_cancel_request`),request_id:g()}).describe(`Cancels a currently open control request.`)),qs=C(()=>h({type:s(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),Js=C(()=>h({type:s(`update_environment_variables`),variables:l(g(),g())}).describe(`Updates environment variables at runtime.`));C(()=>_([ps(),Vo(),Ho(),Zo(),Gs(),Hs(),Ks(),qs()])),C(()=>_([Io(),Hs(),Gs(),qs(),Js()])),n(),i(),oe(),kr(),jr(),Lr(),Fr(),ni(),zr(),Jt(),v(),U(),S(),Ke(),yr(),C(()=>w.object({tool_name:w.string().describe(`The name of the tool requesting permission`),input:w.record(w.string(),w.unknown()).describe(`The input for the tool`),tool_use_id:w.string().optional().describe(`The unique tool use request ID`)}));var Ys=C(()=>w.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),Xs=C(()=>w.object({behavior:w.literal(`allow`),updatedInput:w.record(w.string(),w.unknown()),updatedPermissions:w.array(mt()).optional().catch(e=>{H(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:w.string().optional(),decisionClassification:Ys()})),Zs=C(()=>w.object({behavior:w.literal(`deny`),message:w.string(),interrupt:w.boolean().optional(),toolUseID:w.string().optional(),decisionClassification:Ys()})),Qs=C(()=>w.union([Xs(),Zs()]));function $s(e,t,n,r){let i={type:`permissionPromptTool`,permissionPromptToolName:t.name,toolResult:e};if(e.behavior===`allow`){let t=e.updatedPermissions;t&&(r.setAppState(e=>({...e,toolPermissionContext:me(e.toolPermissionContext,t)})),rt(t));let a=Object.keys(e.updatedInput).length>0?e.updatedInput:n;return{...e,updatedInput:a,decisionReason:i}}else e.behavior===`deny`&&e.interrupt&&(H(`SDK permission prompt deny+interrupt: tool=${t.name} message=${e.message}`),r.abortController.abort());return{...e,decisionReason:i}}Dr(),si(),oi(),Jr(),x(),Wr(),Yr(),qr(),Ti(),wi(),ln(),yn(),Cn(),kn(),pe(),qt(),_r(),mn(),j(),Ge(),ft(),fn(),Dn(),Zt(),ze(),We(),on(),sn(),fr(),Mn(),xt();var ec=/\u2028|\u2029/g;function tc(e){return e.replace(ec,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function nc(e){return tc(B(e))}U(),Lr(),v(),Ke();var rc=`SandboxNetworkAccess`;function ic(e){if(e){if(e.type===`classifier`)return e.reason;switch(e.type){case`rule`:case`mode`:case`subcommandResults`:case`permissionPromptTool`:return;case`hook`:case`asyncAgent`:case`sandboxOverride`:case`workingDir`:case`safetyCheck`:case`other`:return e.reason}}}function ac(e,t,n,r){let i;try{i=e.getActivityDescription?.(t)??e.getToolUseSummary?.(t)??e.userFacingName(t)}catch{i=e.name}return{tool_name:e.name,action_description:i,tool_use_id:n,request_id:r,input:t}}var oc=1e3,sc=class{constructor(e,t){a(this,`input`,void 0),a(this,`replayUserMessages`,void 0),a(this,`structuredInput`,void 0),a(this,`pendingRequests`,new Map),a(this,`restoredWorkerState`,Promise.resolve(null)),a(this,`inputClosed`,!1),a(this,`unexpectedResponseCallback`,void 0),a(this,`resolvedToolUseIds`,new Set),a(this,`prependedLines`,[]),a(this,`onControlRequestSent`,void 0),a(this,`onControlRequestResolved`,void 0),a(this,`outbound`,new vr),this.input=e,this.replayUserMessages=t,this.input=e,this.structuredInput=this.read()}trackResolvedToolUseId(e){let t=e.request;if(t.subtype===`can_use_tool`&&(this.resolvedToolUseIds.add(t.tool_use_id),this.resolvedToolUseIds.size>oc)){let e=this.resolvedToolUseIds.values().next().value;e!==void 0&&this.resolvedToolUseIds.delete(e)}}flushInternalEvents(){return Promise.resolve()}get internalEventsPending(){return 0}prependUserMessage(e){this.prependedLines.push(`${B({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})}\n`)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
2
+ `);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&(Ur(`info`,`cli_stdin_message_parsed`,{type:r.type}),yield r)}}.bind(this);yield*t();for await(let n of this.input)e+=n,yield*t();if(e){let t=await this.processLine(e);t&&(yield t)}this.inputClosed=!0;for(let e of this.pendingRequests.values())e.reject(Error(`Tool permission stream closed before response received`))}getPendingPermissionRequests(){return Array.from(this.pendingRequests.values()).map(e=>e.request).filter(e=>e.request.subtype===`can_use_tool`)}setUnexpectedResponseCallback(e){this.unexpectedResponseCallback=e}injectControlResponse(e){let t=e.response,n=t?.request_id;if(!n)return;let r=this.pendingRequests.get(n);if(r)if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n),this.write({type:`control_cancel_request`,request_id:n}),t.subtype===`error`)r.reject(Error(t.error));else{let e=t.response;if(r.schema)try{r.resolve(r.schema.parse(e))}catch(e){r.reject(e)}else r.resolve({})}}setOnControlRequestSent(e){this.onControlRequestSent=e}setOnControlRequestResolved(e){this.onControlRequestResolved=e}async processLine(e){if(e)try{let t=Mr(e);if(t.type===`keep_alive`)return;if(t.type===`update_environment_variables`){let e=t.variables??{},n=Object.keys(e);for(let[t,n]of Object.entries(e))process.env[t]=n;H(`[structuredIO] applied update_environment_variables: ${n.join(`, `)}`);return}if(t.type===`control_response`){let e=`uuid`in t&&typeof t.uuid==`string`?t.uuid:void 0;e&&Vt(e,`completed`);let n=t.response,r=this.pendingRequests.get(n.request_id);if(!r){let e=(n.subtype===`success`?n.response:void 0)?.toolUseID;if(typeof e==`string`&&this.resolvedToolUseIds.has(e)){H(`Ignoring duplicate control_response for already-resolved toolUseID=${e} request_id=${n.request_id}`);return}this.unexpectedResponseCallback&&await this.unexpectedResponseCallback(t);return}if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n.request_id),r.request.request.subtype===`can_use_tool`&&this.onControlRequestResolved&&this.onControlRequestResolved(n.request_id),n.subtype===`error`){r.reject(Error(n.error??`Unknown error`));return}let i=n.response;if(r.schema)try{r.resolve(r.schema.parse(i))}catch(e){r.reject(e)}else r.resolve({});return this.replayUserMessages?t:void 0}if(t.type!==`user`&&t.type!==`control_request`&&t.type!==`assistant`&&t.type!==`system`){H(`Ignoring unknown message type: ${t.type}`,{level:`warn`});return}return t.type===`control_request`?(t.request||cc(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&cc(`Error: Expected message role 'user', got '${t.message?.role}'`),t)}catch(t){console.error(`Error parsing streaming input line: ${e}: ${t}`),process.exit(1)}}async write(e){W(`${nc(e)}\n`)}async sendRequest(e,t,n,r=q()){let i={type:`control_request`,request_id:r,request:e};if(this.inputClosed)throw Error(`Stream closed`);if(n?.aborted)throw Error(`Request aborted`);this.outbound.enqueue(i),e.subtype===`can_use_tool`&&this.onControlRequestSent&&this.onControlRequestSent(i);let a=()=>{this.outbound.enqueue({type:`control_cancel_request`,request_id:r});let e=this.pendingRequests.get(r);e&&(this.trackResolvedToolUseId(e.request),e.reject(new Ar))};n&&n.addEventListener(`abort`,a,{once:!0});try{return await new Promise((n,i)=>{this.pendingRequests.set(r,{request:{type:`control_request`,request_id:r,request:e},resolve:e=>{n(e)},reject:i,schema:t})})}finally{n&&n.removeEventListener(`abort`,a),this.pendingRequests.delete(r)}}createCanUseTool(e){return async(t,n,r,i,a,o)=>{let s=o??await _e(t,n,r,i,a);if(s.behavior===`allow`||s.behavior===`deny`)return s;let c=new AbortController,l=r.abortController.signal,u=()=>c.abort();l.addEventListener(`abort`,u,{once:!0});try{let i=lc(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=q();e?.(ac(t,n,a,o));let l=this.sendRequest({subtype:`can_use_tool`,tool_name:t.name,input:n,permission_suggestions:s.suggestions,blocked_path:s.blockedPath,decision_reason:ic(s.decisionReason),tool_use_id:a,agent_id:r.agentId},Qs(),c.signal,o).then(e=>({source:`sdk`,result:e})),u=await Promise.race([i,l]);return u.source===`hook`?u.decision?(l.catch(()=>{}),c.abort(),u.decision):$s((await l).result,t,n,r):$s(u.result,t,n,r)}catch(e){return $s({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&Le(`running`),l.removeEventListener(`abort`,u)}}}createHookCallback(e,t){return{type:`callback`,timeout:t,callback:async(t,n,r)=>{try{return await this.sendRequest({subtype:`hook_callback`,callback_id:e,input:t,tool_use_id:n||void 0},Sr(),r)}catch(t){return console.error(`Error in hook callback ${e}:`,t),{}}}}}async handleElicitation(e,t,n,r,i,a,o){try{return await this.sendRequest({subtype:`elicitation`,mcp_server_name:e,message:t,mode:i,url:a,elicitation_id:o,requested_schema:n},Bs(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:rc,input:{host:e.host},tool_use_id:q(),description:`Allow network connection to ${e.host}?`},Qs())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},h({mcp_response:u()}))).mcp_response}};function cc(e){console.error(e),process.exit(1)}async function lc(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=Tt(e,t,n,r,a,i,r.abortController.signal);for await(let e of o)if(e.permissionRequestResult&&(e.permissionRequestResult.behavior===`allow`||e.permissionRequestResult.behavior===`deny`)){let t=e.permissionRequestResult;if(t.behavior===`allow`){let e=t.updatedInput||n,i=t.updatedPermissions??[];if(i.length>0){rt(i);let e=me(r.getAppState().toolPermissionContext,i);r.setAppState(t=>t.toolPermissionContext===e?t:{...t,toolPermissionContext:e})}return{behavior:`allow`,updatedInput:e,userModified:!1,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}else return{behavior:`deny`,message:t.message||`Permission denied by PermissionRequest hook`,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}}bi(),Br(),Di(),[...Ei],U();var uc=`[stdout-guard]`,dc=!1,Q=``,$=null;function fc(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function pc(){dc||(dc=!0,$=process.stdout.write.bind(process.stdout),process.stdout.write=((e,t,n)=>{let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);Q+=r;let i,a=!0;for(;(i=Q.indexOf(`
3
+ `))!==-1;){let e=Q.slice(0,i);Q=Q.slice(i+1),fc(e)?a=$(`${e}\n`):(process.stderr.write(`${uc} ${e}\n`),H(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a}),Pr(async()=>{Q.length>0&&($&&fc(Q)?$(`${Q}\n`):process.stderr.write(`${uc} ${Q}\n`),Q=``),$&&(process.stdout.write=$,$=null),dc=!1}))}$r(),Ye(),Me(),at(),Te(),xi(),_t(),I(),we(),Pe(),or(),nt(),Ln(),Ni(),U(),jr(),Dr(),jr(),oi(),tr(),U();function mc(e){let t=process.env.CLAUDE_CODE_EXIT_AFTER_STOP_DELAY,n=t?parseInt(t,10):null,r=n&&!isNaN(n)&&n>0,i=null,a=0;return{start(){i&&(clearTimeout(i),i=null),r&&(a=Date.now(),i=setTimeout(()=>{let t=Date.now()-a;e()&&t>=n&&(H(`Exiting after ${n}ms of idle time`),z())},n))},stop(){i&&(clearTimeout(i),i=null)}}}fi(),gi(),pi(),In(),ki(),Ai(),ht(),rr(),Ot(),kt(),dt(),he(),Qe(),Gt(),Bi(),Vi();function hc(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:q(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(St(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:q(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}li(),Pt(),vn(),_n(),L(),Ht(),Wn(),Un(),En(),Pn(),je(),It(),Wi(),Ki(),U(),Lr();async function gc(){try{let e=await ta(wr(),`utf-8`),t=Qr().safeParse(Mr(e));return t.success?t.data:(H(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function _c(e){await ke(wr(),B(e,null,2))}async function vc(e,t){let n=ut();if(!n)return;let r=await yc(t);r!==null&&await ke(ea(n,Ve(e)),r)}async function yc(e){let t=[ea(e,`.claude-plugin`,`marketplace.json`),ea(e,`marketplace.json`),e];for(let e of t)try{return await ta(e,`utf-8`)}catch{}return null}async function bc(){let e=await nn();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await vc(t,n.installLocation)}catch(e){H(`Failed to save marketplace JSON for ${t}: ${e}`)}await _c({...await gc(),...e})}ci(),kr(),U(),zr(),oi(),or(),Pe();async function xc(){let e=Dt();H(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await pn();t&&(Ut(),A(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Ir().mkdir(M()),await Ir().mkdir(wt()));let n=Object.keys(zn()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)H(`installPluginsForHeadless: no marketplaces declared`);else{let t=await Hr(`headless_marketplace_reconcile`,()=>Xi({skip:e?(e,t)=>!vt(t):void 0,onProgress:e=>{e.type===`installed`?H(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&H(`installPluginsForHeadless: failed to install marketplace ${e.name}: ${e.error}`)}}),e=>({installed_count:e.installed.length,updated_count:e.updated.length,failed_count:e.failed.length,skipped_count:e.skipped.length}));t.skipped.length>0&&H(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(Ut(),A(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await bc();let t=await ji();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&A(`headlessPluginInstall: plugins changed`),e&&Pr(Re),i}catch(e){return G(e),!1}}Rr(),ci(),U(),zr(),mn(),Ge(),oi(),ni(),j(),on(),kr(),Dr(),xt(),Mn(),ze(),Lr(),Qi(),nt(),Lt(),cn(),ve(),jr(),Qt();var Sc=1e4,Cc=new Set,wc=[];function Tc(e){if(Cc.has(e))return!1;if(Cc.add(e),wc.push(e),wc.length>Sc){let e=wc.splice(0,wc.length-Sc);for(let t of e)Cc.delete(t)}return!0}function Ec(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Dc(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
4
+ `):e.flatMap(Ec)}function Oc(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function kc(e,n,r,i,a,o,s,c){if(Ue.subscribe(e=>{yt(e,r),Wt()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),!pr()&&t(process.env.CLAUDE_CODE_PROACTIVE)&&Gn(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),nr(),R(`runHeadless_entry`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
5
+ `),z(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
6
+ `),z(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
7
+ `),z(1);return}let l=zc(e,c);c.outputFormat===`stream-json`&&pc();let u=P.getSandboxUnavailableReason();if(u){if(P.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),z(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${u}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(P.isSandboxingEnabled())try{await P.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${V(e)}\n`),z(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&sr(e=>{let t=(()=>{switch(e.type){case`started`:return{type:`system`,subtype:`hook_started`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,uuid:q(),session_id:D()};case`progress`:return{type:`system`,subtype:`hook_progress`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,stdout:e.stdout,stderr:e.stderr,output:e.output,uuid:q(),session_id:D()};case`response`:return{type:`system`,subtype:`hook_response`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,output:e.output,stdout:e.stdout,stderr:e.stderr,exit_code:e.exitCode,outcome:e.outcome,uuid:q(),session_id:D()}}})();l.write(t)}),c.setupTrigger&&await Jn(c.setupTrigger),R(`before_loadInitialMessages`);let d=n(),{messages:f,turnInterruptionState:p,agentSetting:m}=await Rc(r,{continue:c.continue,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),h=hn();if(h&&l.prependUserMessage(h),!c.agent&&!E()&&m){let{agentDefinition:e}=qi(m,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!Xn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}lt(e.agentType)}}if(f.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){if(f.find(e=>e.uuid===c.rewindFiles)?.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),z(1);return}let e=n(),t=await Pc(c.rewindFiles,e,r,!1);if(!t.canRewind){process.stderr.write(`Error: ${t.error||`Unexpected error`}\n`),z(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),z(0);return}let g=typeof c.resume==`string`&&(!!St(c.resume)||c.resume.endsWith(`.jsonl`)),_=!!c.sdkUrl;if(!e&&!g&&!_){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
8
+ `),z(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
9
+ `),z(1);return}let v=hr(d.mcp.tools,d.toolPermissionContext),y=[...a,...v],b=Mc(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>n().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),Le(`requires_action`,e)});c.permissionPromptToolName&&(y=y.filter(e=>!Si(e,c.permissionPromptToolName))),ti(),R(`after_loadInitialMessages`),await ui(),R(`after_modelStrings`);let x=c.outputFormat===`json`&&c.verbose,S=[],C;R(`before_runHeadlessStreaming`);for await(let e of Ac(l,d.mcp.clients,[...i,...d.mcp.commands],y,f,b,o,n,r,s,c,p))c.outputFormat===`stream-json`&&c.verbose&&await l.write(e),e.type!==`control_response`&&e.type!==`control_request`&&e.type!==`control_cancel_request`&&!(e.type===`system`&&(e.subtype===`session_state_changed`||e.subtype===`task_notification`||e.subtype===`task_started`||e.subtype===`task_progress`||e.subtype===`post_turn_summary`))&&e.type!==`stream_event`&&e.type!==`keep_alive`&&e.type!==`streamlined_text`&&e.type!==`streamlined_tool_use_summary`&&e.type!==`prompt_suggestion`&&(x&&S.push(e),C=e);switch(c.outputFormat){case`json`:if(C?.type!==`result`)throw Error(`No messages returned`);if(c.verbose){W(`${B(S)}\n`);break}W(`${B(C)}\n`);break;case`stream-json`:break;default:if(C?.type!==`result`)throw Error(`No messages returned`);switch(C.subtype){case`success`:W(C.result.endsWith(`
10
+ `)?C.result:`${C.result}\n`);break;case`error_during_execution`:W(`Execution error`);break;case`error_max_turns`:W(`Error: Reached max turns (${c.maxTurns}).\nTip: Increase the limit with --max-turns or continue in a new session.`);break;case`error_max_budget_usd`:W(`Error: Exceeded USD budget ($${c.maxBudgetUsd}).\nTip: Increase the limit with --max-budget-usd or start a new session to continue.`);break;case`error_max_structured_output_retries`:W(`Error: Failed to provide valid structured output after maximum retries.
11
+ Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(qn(),ei())try{let{drainPendingExtraction:e}=await import(`./extractMemories-kogJzpit.js`);await e()}catch{}z(C?.type===`result`&&C?.is_error?1:0)}function Ac(n,i,a,o,s,c,l,u,d,f,p,m){let h=!1,g,_=!1,v=null,y,b=n.outbound;process.on(`SIGINT`,()=>{Ur(`info`,`shutdown_signal`,{signal:`SIGINT`}),y&&!y.signal.aborted&&y.abort(),jn(0)}),Pr(async()=>{let e={};for(let t of an(u()))Bt(t)&&(e[t.type]=(e[t.type]??0)+1);Ur(`info`,`run_state_at_shutdown`,{run_active:h,run_phase:g,worker_status:bn(),internal_events_pending:n.internalEventsPending,bg_tasks:e})}),Be(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&b.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:q(),session_id:D()})});let x={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},S=e=>{let t=Ii(e);t&&b.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:q(),session_id:D()})};Tr.add(S);let C=s,w=br(s,J(),100),T=Ne(100),te=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;m&&m.kind!==`none`&&te&&(H(`[print.ts] Auto-resuming interrupted turn (kind: ${m.kind})`),Lc(C,m.message),gr({mode:`prompt`,value:m.message.message.content,uuid:q()}));let ne=Gi().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?_i():yi(t),r=Kn(n),i=Vn(e.value),a=De(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),re=p.userSpecifiedModel;function oe(e,t){let n=dn(e,mi(t));C.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&b.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:D(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let E=[],O=[],le=new Set;function ue(e){for(let t of e){if(t.type!==`connected`||le.has(t.name)||t.config.type===`sdk`)continue;let e=t.name;try{t.client.setRequestHandler(Je,async(t,r)=>{ii(e,`Elicitation request received in print mode: ${B(t)}`);let i=t.params.mode===`url`?`url`:`form`,a=await Hn(e,t.params,r.signal);if(a)return ii(e,`Elicitation resolved by hook: ${B(a)}`),a.action,a;let o=`url`in t.params?t.params.url:void 0,s=`requestedSchema`in t.params?t.params.requestedSchema:void 0,c=`elicitationId`in t.params?t.params.elicitationId:void 0,l=await n.handleElicitation(e,t.params.message,s,r.signal,i,o,c),u=await er(e,l,r.signal,i,c);return u.action,u}),t.client.setNotificationHandler(ot,t=>{let{elicitationId:n}=t.params;ii(e,`Elicitation completion notification: ${n}`),ye({message:`MCP server "${e}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),b.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:e,elicitation_id:n,uuid:q(),session_id:D()})}),le.add(e)}catch{}}}async function de(){let e=new Set(Object.keys(l)),t=new Set(E.map(e=>e.name)),r=Array.from(e).some(e=>!t.has(e)),i=Array.from(t).some(t=>!e.has(t)),a=E.some(e=>e.type===`pending`),o=E.some(e=>e.type===`failed`);if(r||i||a||o){for(let t of E)e.has(t.name)||t.type===`connected`&&await t.cleanup();let r=await $n(l,(e,t)=>n.sendMcpMessage(e,t));E=r.clients,O=r.tools;let i=Vr([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(Xr(t)))),...O]}})),et(E)}}de();let k={clients:[],tools:[],configs:{}},A=e=>{let t=be(e.toolPermissionContext,e.mcp.tools),n=tt(Mi([...o,...O,...k.tools],t,e.toolPermissionContext.mode),`name`);p.permissionPromptToolName&&(n=n.filter(e=>!Si(e,p.permissionPromptToolName)));let r=ee();if(r&&!p.jsonSchema){let e=Ci(r);`tool`in e&&(n=[...n,e.tool])}return n},pe=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function me(e){let t=async()=>{let t=new Set(E.map(e=>e.name)),n=await Hc(e,{configs:l,clients:E,tools:O},k,d);for(let e of Object.keys(l))delete l[e];if(Object.assign(l,n.newSdkState.configs),E=n.newSdkState.clients,O=n.newSdkState.tools,k=n.newDynamicState,n.sdkServersChanged){let e=new Set(E.map(e=>e.name)),n=Vr([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(Xr(t)))),...O]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return pe=pe.then(t,t),pe}function he(){let e=u(),t=e.mcp.clients,n=tt([...e.mcp.tools,...k.tools],`name`),r=new Set([...t.map(e=>e.name),...E.map(e=>e.name)]);return[...t,...E,...k.clients.filter(e=>!r.has(e.name))].map(e=>{let t;if(e.config.type===`sse`||e.config.type===`http`)t={type:e.config.type,url:e.config.url,headers:e.config.headers};else if(e.config.type===`claudeai-proxy`)t={type:`claudeai-proxy`,url:e.config.url,id:e.config.id};else if(e.config.type===`stdio`||e.config.type===void 0){let n=e.config;t={type:`stdio`,command:n.command,args:n.args}}let r=e.type===`connected`?Yt(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0;return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r}})}async function _e(){try{await xc()&&await we()}catch(e){G(e)}}let j=null;r()||(t(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?j=_e():_e());let ve=mc(()=>!h),M=a,N=f;async function Ce(){let{agentDefinitions:e}=await Zi(d);M=await Ee(J());let t=N.filter(e=>e.source===`flagSettings`);N=[...e.allAgents,...t]}async function we(){let{servers:e}=await ge(),t={};for(let[n,r]of Object.entries(e)){let e=r.type;(e===void 0||e===`stdio`||e===`sse`||e===`http`||e===`sdk`)&&(t[n]=r)}for(let[e,n]of Object.entries(l))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await me(t);r&&de(),H(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Te=Yi.subscribe(()=>{Se(),Ee(J()).then(e=>{M=e})}),P=()=>{setTimeout(()=>{!pr()||Cr()||_||(async()=>{let e=await ar({basePrompt:`<${ri}>${new Date().toLocaleTimeString()}</${ri}>`,currentDir:J(),shouldCreate:()=>!_});if(_){await Rn({commands:e});return}for(let t of e)gr({...t,uuid:q()});F()})().catch(e=>{G(e),H(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Ie(()=>{y&&$e(`now`).length>0&&y.abort(`interrupt`)});let F=async()=>{if(h)return;if(h=!0,g=void 0,Le(`running`),ve.stop(),R(`run_entry`),await de(),R(`after_updateSdkMcp`),j){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=On(e).then(()=>`timeout`);await Promise.race([j,t])===`timeout`&&G(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`))}else await j;j=null,await Ce();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-BiHPKDaY.js`);t()}let t=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=pt(t);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;Oc(r,Xe(t));)i.push(pt(t));let a=await Zn(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Dc(i.map(e=>e.value)),uuid:i.findLast(e=>e.uuid)?.uuid??r.uuid});let o=i.map(e=>e.uuid).filter(e=>e!==void 0);if(p.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&b.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:D(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...E,...k.clients];ue(l);let f=A(s);for(let e of o)Vt(e,`started`);if(r.mode===`task-notification`){let e=typeof r.value==`string`?r.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),n=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&b.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:n?.[1],status:l,output_file:i?.[1]??``,summary:o?.[1]??``,usage:d&&f?{total_tokens:parseInt(d[1],10),tool_uses:parseInt(f[1],10),duration_ms:p?parseInt(p[1],10):0}:void 0,session_id:D(),uuid:q()})}let m=r.value,h=a.claimedCommands;if(x.abortController?.abort(),x.abortController=null,x.pendingSuggestion=null,x.pendingLastEmittedEntry=null,x.lastEmitted&&r.mode===`prompt`){let e=typeof m==`string`?m:m.find(e=>e.type===`text`)?.text;typeof e==`string`&&xn(x.lastEmitted.text,e,x.lastEmitted.emittedAt,x.lastEmitted.promptId,x.lastEmitted.generationRequestId),x.lastEmitted=null}y=$t(),R(`before_ask`),Kt();let g=r,_=!1;try{if(await hi(g.workload??p.workload,async()=>{for await(let e of Li({commands:tt([...M,...s.mcp.commands],`name`),prompt:m,promptUuid:g.uuid,isMeta:g.isMeta,cwd:J(),tools:f,verbose:p.verbose,mcpClients:l,thinkingConfig:p.thinkingConfig,maxTurns:p.maxTurns,maxBudgetUsd:p.maxBudgetUsd,taskBudget:p.taskBudget,canUseTool:c,userSpecifiedModel:re,fallbackModel:p.fallbackModel,jsonSchema:ee()??p.jsonSchema,mutableMessages:C,getReadFileCache:()=>T.size===0?w:Et(w,T),setReadFileCache:e=>{w=e;for(let[e,t]of T.entries()){let n=w.get(e);(!n||t.timestamp>n.timestamp)&&w.set(e,t)}T.clear()},customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,getAppState:u,setAppState:d,abortController:y,replayUserMessages:p.replayUserMessages,includePartialMessages:p.includePartialMessages,handleElicitation:(e,t,r)=>n.handleElicitation(e,t.message,void 0,r,t.mode,t.url,`elicitationId`in t?t.elicitationId:void 0),agents:N,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{b.enqueue({type:`system`,subtype:`status`,status:e,session_id:D(),uuid:q()})}}))if(e.type===`result`){_=!!e.is_error;for(let e of dr())b.enqueue(e);an(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Bt(e))?v=e:(v=null,b.enqueue(e))}else{for(let e of dr())b.enqueue(e);b.enqueue(e)}}),_)await Xt({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:J(),priority:`later`,workload:g.workload??p.workload});else{let e=await Xt({commands:h,outcome:{type:`completed`},currentDir:J(),priority:`later`,workload:g.workload??p.workload});for(let t of e)gr({...t,uuid:q()})}}catch(e){throw await Xt({commands:h,outcome:{type:`failed`,error:e},currentDir:J(),priority:`later`,workload:g.workload??p.workload}),e}for(let e of o)Vt(e,`completed`);if(p.promptSuggestions&&!e(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){x.abortController?.abort();let e=new AbortController;x.abortController=e;let t=bt();if(!t)qe(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await it(e,C,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:q(),session_id:D()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};v?(x.pendingSuggestion=r,x.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(x.lastEmitted=i,b.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){qe(`aborted`,void 0,void 0,`sdk`);return}G(Nr(e))}finally{x.inflightPromise===n.promise&&(x.inflightPromise=null)}})(),x.inflightPromise=n.promise}}qn(),ur(),nr()}};do{for(let e of dr())b.enqueue(e);g=`draining_commands`,await a(),i=!1;{let e=an(u()).some(e=>Bt(e)),n=Xe(t)!==void 0;(e||n)&&(i=!0,n||(g=`waiting_for_agents`,await On(100)))}}while(i);v&&(b.enqueue(v),v=null,x.pendingSuggestion&&(b.enqueue(x.pendingSuggestion),x.pendingLastEmittedEntry&&(x.lastEmitted={...x.pendingLastEmittedEntry,emittedAt:Date.now()},x.pendingLastEmittedEntry=null),x.pendingSuggestion=null))}catch(e){try{await n.write({type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:D(),total_cost_usd:0,usage:un,modelUsage:{},permission_denials:[],uuid:q(),errors:[V(e),...ai().map(e=>e.error)]})}catch{}x.abortController?.abort(),z(1);return}finally{if(g=`finally_flush`,await n.flushInternalEvents(),g=`finally_post_flush`,!Rt()){Le(`idle`);for(let e of dr())b.enqueue(e)}h=!1,ve.start()}if(pr()&&!Cr()&&Xe(t)===void 0&&!_){P();return}if(Xe(t)!==void 0){F();return}_&&(x.inflightPromise&&await Promise.race([x.inflightPromise,On(5e3)]),x.abortController?.abort(),x.abortController=null,await Qn(),Te(),Tr.delete(S),b.done())},I=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},L=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},ke=new Set;return n.setUnexpectedResponseCallback(async e=>{await Bc({message:e,setAppState:d,handledToolUseIds:ke,onEnqueued:()=>{F()}})}),(async()=>{let e=!1;Ur(`info`,`cli_message_loop_started`);for await(let t of n.structuredInput){let r=`uuid`in t?t.uuid:void 0;if(r&&t.type!==`user`&&t.type!==`control_response`&&Vt(r,`completed`),t.type===`control_request`){let r=t,o=r.request;if(r.request.subtype===`interrupt`)d(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,I(r);else if(o.subtype===`end_session`){H(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,I(r);break}else if(r.request.subtype===`initialize`){if(r.request.sdkMcpServers&&r.request.sdkMcpServers.length>0)for(let e of r.request.sdkMcpServers)l[e]={type:`sdk`,name:e};await Nc(r.request,r.request_id,e,b,a,ne,n,p,f,u),r.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),r.request.agentProgressSummaries&&ie(!0),e=!0,wn()&&F()}else if(r.request.subtype===`set_permission_mode`){let e=r.request;d(t=>({...t,toolPermissionContext:Fc(e,r.request_id,t.toolPermissionContext,b)}))}else if(r.request.subtype===`set_model`){let e=r.request.model??`default`,t=e==="default"?_i():e;re=t,ce(t),Oe({model:t}),oe(e,t),I(r)}else if(r.request.subtype===`set_max_thinking_tokens`)r.request.max_thinking_tokens===null?p.thinkingConfig=void 0:r.request.max_thinking_tokens===0?p.thinkingConfig={type:`disabled`}:p.thinkingConfig={type:`enabled`,budgetTokens:r.request.max_thinking_tokens},I(r);else if(r.request.subtype===`mcp_status`)I(r,{mcpServers:he()});else if(r.request.subtype===`get_context_usage`)try{let e=u(),t=await Ui({messages:C,getAppState:u,options:{mainLoopModel:vi(),tools:A(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt}});I(r,{...t})}catch(e){L(r,V(e))}else if(r.request.subtype===`mcp_message`){let e=r.request,t=E.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),I(r)}else if(r.request.subtype===`rewind_files`){let e=u(),t=await Pc(r.request.user_message_id,e,d,r.request.dry_run??!1);t.canRewind||r.request.dry_run?I(r,t):L(r,t.error??`Unexpected error`)}else if(r.request.subtype===`cancel_async_message`){let e=r.request.message_uuid,t=xe(t=>t.uuid===e);I(r,{cancelled:t.length>0})}else if(r.request.subtype===`seed_read_state`){try{let e=Kr(r.request.path),t=Math.floor((await na(e)).mtimeMs);if(t<=r.request.mtime){let n=await ta(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
12
+ `,`
13
+ `);T.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}I(r)}else if(r.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await me(r.request.servers);I(r,e),t&&de()}else if(r.request.subtype===`reload_plugins`)try{let e=await Zi(d),t=N.filter(e=>e.source===`flagSettings`);N=[...e.agentDefinitions.allAgents,...t];let n=[],[i,a,o]=await Promise.allSettled([Ee(J()),we(),Fe()]);i.status===`fulfilled`?M=i.value:G(i.reason),a.status===`rejected`&&G(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):G(o.reason),I(r,{commands:M.filter(e=>e.userInvocable!==!1).map(e=>({name:Ze(e),description:gt(e),argumentHint:e.argumentHint||``})),agents:N.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:he(),error_count:e.error_count})}catch(e){L(r,V(e))}else if(r.request.subtype===`mcp_reconnect`){let e=u(),{serverName:t}=r.request;le.delete(t);let n=Sn(t)??i.find(e=>e.name===t)?.config??E.find(e=>e.name===t)?.config??k.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)L(r,`Server not found: ${t}`);else{let e=await Bn(t,n),i=Xr(t);if(d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...K(n.mcp.tools,e=>e.name?.startsWith(i)),...e.tools],commands:[...K(n.mcp.commands,e=>cr(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:Oi(n.mcp.resources,t)}})),k={...k,clients:[...k.clients.filter(e=>e.name!==t),e.client],tools:[...k.tools.filter(e=>!e.name?.startsWith(i)),...e.tools]},e.client.type===`connected`)ue([e.client]),I(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;L(r,t)}}}else if(r.request.subtype===`mcp_toggle`){let e=u(),{serverName:t,enabled:n}=r.request;le.delete(t);let a=Sn(t)??i.find(e=>e.name===t)?.config??E.find(e=>e.name===t)?.config??k.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)L(r,`Server not found: ${t}`);else if(n){Er(t,!0);let e=await Bn(t,a),n=Xr(t);if(d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...K(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...K(r.mcp.commands,e=>cr(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:Oi(r.mcp.resources,t)}})),e.client.type===`connected`)ue([e.client]),I(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;L(r,t)}}else{Er(t,!1);let n=[...i,...E,...k.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Ft(t,a);let o=Xr(t);d(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:K(e.mcp.tools,e=>e.name?.startsWith(o)),commands:K(e.mcp.commands,e=>cr(e,t)),resources:Oi(e.mcp.resources,t)}})),I(r)}}else if(r.request.subtype===`apply_flag_settings`){let e=vi(),t=ae()??{},n=r.request.settings,i={...t,...n};for(let e of Object.keys(i))i[e]===null&&delete i[e];se(i),Ue.notifyChange(`flagSettings`),`model`in n&&(n.model==null?ce(void 0):ce(String(n.model)));let a=vi();if(a!==e){re=a;let e=n.model?String(n.model):`default`;Oe({model:a}),oe(e,a)}I(r)}else if(r.request.subtype===`get_settings`){let e=vi();I(r,{...Zr(),applied:{model:e}})}else if(r.request.subtype===`stop_task`){let{task_id:e}=r.request;try{await Ct(e,{getAppState:u,setAppState:d}),I(r,{})}catch(e){L(r,V(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(y&&!y.signal.aborted?y:$t()).signal;(async()=>{try{let i=await zi(e,n);if(i&&t)try{fe(D(),i)}catch(e){G(e)}I(r,{title:i})}catch(e){L(r,V(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=bt(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:$t()}}:await Fi({tools:A(u()),commands:M,mcpClients:[...u().mcp.clients,...E,...k.clients],messages:C,readFileState:w,getAppState:u,setAppState:d,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,thinkingConfig:p.thinkingConfig,agents:N}),i=await Hi({question:e,cacheSafeParams:n});I(r,{response:i.response})}catch(e){L(r,V(e))}})()}else r.request.subtype===`set_proactive`?(r.request.enabled?pr()||(Gn(`command`),P()):Nn(),I(r)):L(r,`Unsupported control request subtype: ${r.request.subtype}`);continue}else if(t.type===`control_response`){p.replayUserMessages&&b.enqueue(t);continue}else if(t.type===`keep_alive`)continue;else if(t.type===`update_environment_variables`)continue;else if(t.type===`assistant`||t.type===`system`){let e=Ri([t]);C.push(...e),t.type===`assistant`&&p.replayUserMessages&&b.enqueue(t);continue}if(t.type!==`user`)continue;let o=t;if(e=!0,o.uuid){let e=D(),t=await Ae(e,o.uuid);if(t||Cc.has(o.uuid)){H(`Skipping duplicate user message: ${o.uuid}`),p.replayUserMessages&&(H(`Sending acknowledgment for duplicate user message: ${o.uuid}`),b.enqueue({type:`user`,content:o.message?.content??``,message:o.message,session_id:e,parent_tool_use_id:null,uuid:o.uuid,timestamp:o.timestamp,isReplay:!0})),t&&Vt(o.uuid,`completed`);continue}Tc(o.uuid)}gr({mode:`prompt`,value:o.message.content,uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:rn(e.attribution,e=>{He(e).catch(e=>{H(`Attribution: Failed to save snapshot: ${e}`)})})})),F()}_=!0,h||(x.inflightPromise&&await Promise.race([x.inflightPromise,On(5e3)]),x.abortController?.abort(),x.abortController=null,await Qn(),Te(),Tr.delete(S),b.done())})(),b}function jc(e){let t=async(n,r,i,a,o,s)=>{let c=s??await _e(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=zt(i.abortController.signal);if(l.aborted)return u(),{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let d=new Promise(e=>{l.addEventListener(`abort`,()=>e(`aborted`),{once:!0})}),f=e.call({tool_name:n.name,input:r,tool_use_id:o},i,t,a),p=await Promise.race([f,d]);if(u(),p===`aborted`||l.aborted)return{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let m=p,h=e.mapToolResultToToolResultBlockParam(m.data,`1`);if(!h.content||!Array.isArray(h.content)||!h.content[0]||h.content[0].type!==`text`||typeof h.content[0].text!=`string`)throw Error(`Permission prompt tool returned an invalid result. Expected a single text block param with type="text" and a string text value.`);return $s(Qs().parse(y(h.content[0].text)),e,r,i)};return t}function Mc(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await _e(e,t,n,r,i);let i=null;return async(t,r,a,o,s,c)=>{if(!i){let t=n(),r=t.find(t=>Si(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),z(1),Error(n)}if(!r.inputJSONSchema){let t=`Error: tool ${e} (passed via --permission-prompt-tool) must be an MCP tool`;throw process.stderr.write(`${t}\n`),z(1),Error(t)}i=jc(r)}return i(t,r,a,o,s,c)}}async function Nc(e,t,n,r,i,a,o,s,c,l){if(n){r.enqueue({type:`control_response`,response:{subtype:`error`,error:`Already initialized`,request_id:t,pending_permission_requests:o.getPendingPermissionRequests()}});return}if(e.systemPrompt!==void 0&&(s.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(s.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(s.promptSuggestions=e.promptSuggestions),e.agents){let t=tn(e.agents,`flagSettings`);c.push(...t)}if(s.agent){let e=E()===s.agent,t=c.find(e=>e.agentType===s.agent);if(t&&!e){if(le(t.agentType),!s.systemPrompt&&!Xn(t)){let e=t.getSystemPrompt();e&&(s.systemPrompt=e)}!s.userSpecifiedModel&&t.model&&t.model!==`inherit`&&ce(yi(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let u=Gr()?.outputStyle||`default`,d=await F(Or());if(e.hooks){let t={};for(let[n,r]of Object.entries(e.hooks))t[n]=r.map(e=>{let t=e.hookCallbackIds.map(t=>o.createHookCallback(t,e.timeout));return{matcher:e.matcher,hooks:t}});re(t)}e.jsonSchema&&O(e.jsonSchema);let f={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:Ze(e),description:gt(e),argumentHint:e.argumentHint||``})),agents:c.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:u,available_output_styles:Object.keys(d),models:a,account:{apiProvider:di()},pid:process.pid};if(Wt()&&Yn()){let e=l();f.fast_mode_state=ue(s.userSpecifiedModel??null,e.fastMode)}r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:f}})}async function Pc(e,t,n,r){if(!de())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!ct(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await en(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await gn(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${V(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Fc(e,t,n,r){if(e.mode===`bypassPermissions`){if(mr())return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`}}),n;if(!n.isBypassPermissionsModeAvailable)return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}),n}if(e.mode===`auto`&&!N()){let e=xr();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${lr(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...k(n.mode,e.mode,n),mode:e.mode}}function Ic(e,t){if(t===`stream-json`){let t={type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:D(),total_cost_usd:0,usage:un,modelUsage:{},permission_denials:[],uuid:q(),errors:[e]};process.stdout.write(`${B(t)}\n`)}else process.stderr.write(`${e}\n`)}function Lc(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function Rc(e,t){let n=!te();if(t.continue)try{let r=await Pi(void 0,void 0);if(r)return t.forkSession||r.sessionId&&(ne(Ce(r.sessionId),r.fullPath?$i(r.fullPath):null),n&&await Nt()),Ji(r,e),At(t.forkSession?{...r,worktreeSession:void 0}:r),{messages:r.messages,turnInterruptionState:r.turnInterruptionState,agentSetting:r.agentSetting}}catch(e){return G(e),z(1),{messages:[]}}if(t.resume)try{let r=hc(typeof t.resume==`string`?t.resume:``);if(!r){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),Ic(e,t.outputFormat),z(1),{messages:[]}}let i=await Pi(r.sessionId,r.jsonlFile||void 0);if(!i||i.messages.length===0)return Ic(`No conversation found with session ID: ${r.sessionId}`,t.outputFormat),z(1),{messages:[]};if(t.resumeSessionAt){let e=i.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return Ic(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),z(1),{messages:[]};i.messages=e>=0?i.messages.slice(0,e+1):[]}return!t.forkSession&&i.sessionId&&(ne(Ce(i.sessionId),i.fullPath?$i(i.fullPath):null),n&&await Nt()),Ji(i,e),At(t.forkSession?{...i,worktreeSession:void 0}:i),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}catch(e){return G(e),Ic(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),z(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??Fn(`startup`))}}function zc(e,t){let n;return n=typeof e==`string`?e.trim()===``?An([]):An([B({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,new sc(n,t.replayUserMessages)}async function Bc({message:e,setAppState:t,onEnqueued:n,handledToolUseIds:r}){let i=e.response;if(i?.subtype===`success`&&i.response?.toolUseID&&typeof i.response.toolUseID==`string`){let e=i.response,t=e.toolUseID;if(!t)return!1;if(H(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return H(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await Mt(t);return a?(r.add(t),H(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),gr({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(H(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function Vc(e){return{...e,scope:`dynamic`}}async function Hc(e,t,n,r){let{allowed:i,blocked:a}=Tn(e),o={};for(let e of a)o[e]=`Blocked by enterprise policy (allowedMcpServers/deniedMcpServers)`;let s={},c={};for(let[e,t]of Object.entries(i))t.type===`sdk`?s[e]=t:c[e]=t;let l=new Set(Object.keys(t.configs)),u=new Set(Object.keys(s)),d=[],f=[],p={...t.configs},m=[...t.clients],h=[...t.tools];for(let e of l)if(!u.has(e)){let t=m.find(t=>t.name===e);t&&t.type===`connected`&&await t.cleanup(),m=m.filter(t=>t.name!==e);let n=`mcp__${e}__`;h=h.filter(e=>!e.name.startsWith(n)),delete p[e],f.push(e)}for(let[e,t]of Object.entries(s))if(!l.has(e)){p[e]=t;let n={type:`pending`,name:e,config:{...t,scope:`dynamic`}};m=[...m,n],d.push(e)}let g=await Uc(c,n,r);return{response:{added:[...d,...g.response.added],removed:[...f,...g.response.removed],errors:{...o,...g.response.errors}},newSdkState:{configs:p,clients:m,tools:h},newDynamicState:g.newState,sdkServersChanged:d.length>0||f.length>0}}async function Uc(e,t,n){let r=new Set(Object.keys(t.configs)),i=new Set(Object.keys(e)),a=[...r].filter(e=>!i.has(e)),o=[...i].filter(e=>!r.has(e)),s=[...r].filter(e=>i.has(e)).filter(n=>{let r=t.configs[n],i=e[n];return!r||!i||!jt(r,Vc(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){G(e)}await Ft(e,r)}let i=`mcp__${e}__`;f=f.filter(e=>!e.name.startsWith(i)),d=d.filter(t=>t.name!==e),a.includes(e)&&c.push(e)}for(let t of[...o,...s]){let n=e[t];if(!n)continue;let r=Vc(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await st(t,r);if(d.push(e),e.type===`connected`){let t=await ir(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Nr(e);u[t]=n.message,G(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=Vc(n))}let m={clients:d,tools:f,configs:p};return n(e=>{let n=new Set([...Object.keys(t.configs),...Object.keys(p)]),r=e.mcp.tools.filter(e=>{for(let t of n)if(e.name.startsWith(`mcp__${t}__`))return!1;return!0}),i=e.mcp.clients.filter(e=>!n.has(e.name));return{...e,mcp:{...e.mcp,tools:[...r,...f],clients:[...i,...d]}}}),{response:{added:l,removed:c,errors:u},newState:m}}export{kc as runHeadless};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,t as n}from"./src-DL3w8VPk.js";import{t as r}from"./jsx-runtime-Bb4Xn-E0.js";import{Ac as i,Em as a,Fb as o,Ib as s,Ji as c,Mf as l,Nf as u,Pf as d,Qu as f,Tm as p,Zu as m,_S as h,bS as g,jf as _,kc as v,wS as y,xS as b}from"./loadAgentsDir-DGozQu_6.js";import{A as x,I as S,M as C}from"./debug-CRnGsZOV.js";import{h as w,t as T}from"./settings-CodSADx8.js";import{n as E}from"./analytics-COpjZpvd.js";import{bt as D,yt as O}from"./prompt-DzO1um1h.js";import{randomUUID as k}from"crypto";n(),l(),f(),d();var A=r();function j({input:e,progress:n,verbose:r}){return(0,A.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,A.jsx)(m,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,A.jsx)(u,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):_.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}S(),E(),o(),c(),w();function M(){return T().defaultShell??`bash`}l(),O(),a();async function N(t,n,r,a,o){let c=D()&&M()===`powershell`,l=b({content:y({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;o({jsx:(0,A.jsx)(j,{input:t,progress:null,verbose:a.options.verbose}),shouldHidePromptInput:!1});try{let n={...a,setToolJSX:e=>{u=e?.jsx}},d=e=>{o({jsx:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(j,{input:t,progress:e.data,verbose:a.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},f=null;c&&(f=(i(),e(v)).PowerShellTool);let m=f??_,g=(f?await f.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d):await _.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d)).data;if(!g)throw Error(`No result received from shell command`);let y=g.stderr,x=await s(m,{...g,stderr:``},k()),S=typeof x.content==`string`?x.content:p(g.stdout);return{messages:[h(),l,...r,b({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${p(y)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof x?e.interrupted?{messages:[h(),l,g({toolUse:!1}),...r],shouldQuery:!1}:{messages:[h(),l,...r,b({content:`<bash-stdout>${p(e.stdout)}</bash-stdout><bash-stderr>${p(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[h(),l,...r,b({content:`<bash-stderr>Command failed: ${p(C(e))}</bash-stderr>`})],shouldQuery:!1}}finally{o(null)}}export{N as processBashCommand};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{An as t,Pt as n,at as r,t as i}from"./state-BQ4BEGin.js";import{$o as a,Ag as o,B as s,Bd as c,Bh as l,Ca as u,E as d,ES as f,Ei as p,Gs as m,Gx as h,Hh as g,Hs as _,Ji as v,Kx as y,Mi as b,Mp as x,Ni as S,Qo as C,SS as w,TS as T,Tg as E,V as D,Ws as O,Ym as ee,Zm as te,_S as k,_d as A,au as ne,b as re,bS as ie,bd as ae,bm as oe,cg as se,cu as ce,cv as le,cy as ue,df as de,dg as fe,eu as pe,ff as me,gc as he,gd as ge,hc as _e,ji as ve,jp as j,lS as M,la as N,lu as P,lv as F,ly as ye,mS as I,nu as L,nx as be,pf as xe,qx as R,rx as Se,ts as Ce,tu as we,tx as Te,vS as Ee,vd as De,wS as z,wg as Oe,wi as ke,xS as B,xi as Ae,xm as je,yd as Me,zd as Ne}from"./loadAgentsDir-DGozQu_6.js";import{E as V,I as Pe,c as H,f as Fe,i as U,k as W,u as Ie}from"./debug-CRnGsZOV.js";import{Dt as Le,Et as Re}from"./settings-CodSADx8.js";import{D as G,O as K,o as ze,q as Be,s as q}from"./log-DoSpAwRP.js";import{n as Ve}from"./analytics-COpjZpvd.js";import{At as He,kt as Ue}from"./model-DpZaKZMb.js";import{E as We,T as Ge,w as Ke}from"./sessionTracing-D7rekMdW.js";import{randomUUID as J}from"crypto";function qe(e,t,n,r,i){let a=0;for(let o of Le){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{H(`Removing one-shot hook for event ${o} in skill '${r}'`),ae(e,t,o,s)}:void 0;De(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var Je=e((()=>{Re(),U(),Me()}));function Ye(e){let t=e.trim();if(!t.startsWith(`/`))return null;let n=t.slice(1).split(` `);if(!n[0])return null;let r=n[0],i=!1,a=1;n.length>1&&n[1]===`(MCP)`&&(r=`${r} (MCP)`,i=!0,a=2);let o=n.slice(a).join(` `);return{commandName:r,args:o,isMcp:i}}var Xe=e((()=>{}));function Ze(){return!1}function Qe(){if(!Ze())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function $e(e,t,n,r,i,a,o){let s=Ne(),c=e.pluginInfo?R(e.pluginInfo.repository).marketplace:void 0;e.name,{...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...c&&{_PROTO_marketplace_name:c},...L(e.pluginInfo)}};let{skillContent:l,modifiedGetAppState:u,baseAgent:d,promptMessages:f}=await m(e,t,n);H(`Executing forked slash command /${e.name} with agent ${d.agentType}`);let p=n.options.allowBackgroundForkedSlashCommands===!0;if(p&&Qe(),p){let t=ue(),r=S(e),i=Ue(),c=e=>E({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),l=async()=>{if(!o?.runId)return;let e=await de({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)Oe(t)},p=async e=>{o?.runId&&await me({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await F(Q);let o=n.options.refreshTools?.()??n.options.tools,p=[];for await(let r of A({agentDefinition:d,promptMessages:f,toolUseContext:{...n,getAppState:u,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:s}}))p.push(r);let m=_(p,`Command completed`);H(`Background forked command /${r} completed (agent ${s})`),c(`<scheduled-task-result command="/${r}">\n${m}\n</scheduled-task-result>`);try{await l()}catch(e){q(e)}})().catch(async e=>{q(e),c(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await p(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let h=[],g=[],v=`forked-command-${e.name}`,y=0,b=e=>(y++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:l,agentId:s},parentToolUseID:v,toolUseID:`${v}-${y}`,timestamp:new Date().toISOString(),uuid:J()}),x=()=>{i({jsx:P(g,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};x();try{for await(let t of A({agentDefinition:d,promptMessages:f,toolUseContext:{...n,getAppState:u},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){h.push(t);let e=N([t]);if(t.type===`assistant`){let r=se(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(g.push(b(t)),x())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(g.push(b(t)),x())}}}finally{i(null)}let C=_(h,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),{messages:[B({content:z({inputString:`/${S(e)} ${t}`.trim(),precedingInputBlocks:r})}),B({content:`<local-command-stdout>\n${C}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:C}}function et(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function tt(e,n,r,i,a,o,s,c,l,d){let f=Ye(e);if(!f){let e="Commands are in the form `/command [args]`";return{messages:[k(),...i,B({content:z({inputString:e,precedingInputBlocks:n})})],shouldQuery:!1,resultText:e}}let{commandName:p,args:m,isMcp:h}=f,g=h?`mcp`:Ae().has(p)?p:`custom`;if(!ve(p,a.options.commands)){let r=!1;try{await Ie().stat(`/${p}`),r=!0}catch{}if(et(p)&&!r){let e=`Unknown skill: ${p}`;return{messages:[k(),...i,B({content:z({inputString:e,precedingInputBlocks:n})}),...m?[Ee(`Args from unknown skill: ${m}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let a=J();return t(a),Ge(`user_prompt`,{prompt_length:String(e.length),prompt:We(e),"prompt.id":a}),{messages:[B({content:z({inputString:e,precedingInputBlocks:n}),uuid:s}),...i],shouldQuery:!0}}let{messages:_,shouldQuery:v,allowedTools:b,model:x,command:S,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}=await nt(p,m,o,a,n,r,c,l,s,d);if(_.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=R(n),i=y(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,L(S.pluginInfo))}return{...e},{messages:[],shouldQuery:!1,model:x,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}if(_.length===2&&_[1].type===`user`&&typeof _[1].message.content==`string`&&_[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`),{messages:[k(),..._],shouldQuery:v,allowedTools:b,model:x};let D={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=R(t),r=y(n);D._PROTO_plugin_name=e.name,n&&(D._PROTO_marketplace_name=n),D.plugin_repository=r?t:`third-party`,D.plugin_name=r?e.name:`third-party`,r&&e.version&&(D.plugin_version=e.version),Object.assign(D,L(S.pluginInfo))}({...D});let O=_.length>0&&_[0]&&M(_[0]);return{messages:v||_.every(u)||O?_:[k(),..._],shouldQuery:v,allowedTools:b,model:x,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}async function nt(e,t,n,r,i,a,o,c,l,u){let d=p(e,r.options.commands);if(d.type===`prompt`&&d.userInvocable!==!1&&we(e),d.userInvocable===!1)return{messages:[B({content:z({inputString:`/${e}`,precedingInputBlocks:i})}),B({content:`This skill can only be invoked by Work Mate, not directly by users. Ask Work Mate to use the "${e}" skill for you.`})],shouldQuery:!1,command:d};try{switch(d.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:d,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>B({content:e,isMeta:!0})),s=x()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[I(Y(d,c)),I(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[B({content:z({inputString:Y(d,c),precedingInputBlocks:i})}),B(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${T}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:d,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};d.load().then(e=>e.call(o,{...r,canUseTool:c},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:d});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:d.immediate===!0})}}).catch(t=>{q(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:d}))})});case`local`:{let e=B({content:z({inputString:Y(d,d.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=k(),i=await(await d.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:d};if(i.type===`compact`){let t=[n,e,...i.displayText?[B({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return g(),{messages:ee(r),shouldQuery:!1,command:d}}return{messages:[e,I(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:d,resultText:i.value}}catch(t){return q(t),{messages:[e,I(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:d}}}case`prompt`:try{return d.context===`fork`?await $e(d,t,r,i,n,c??s,u):await Z(d,t,r,i,a,l)}catch(e){return e instanceof V?{messages:[B({content:z({inputString:Y(d,t),precedingInputBlocks:i})}),ie({toolUse:!1})],shouldQuery:!1,command:d}:{messages:[B({content:z({inputString:Y(d,t),precedingInputBlocks:i})}),B({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:d}}}}catch(e){if(e instanceof W)return{messages:[B({content:z({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:d};throw e}}function Y(e,t){return w(S(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${K}>${e}</${K}>`,`<skill-format>true</skill-format>`].join(`
2
+ `)}function rt(e,t){return[`<${G}>${e}</${G}>`,`<${K}>/${e}</${K}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
3
+ `)}function it(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):rt(e.name,t)}async function at(e,t,n,r,i=[]){let a=ke(e,n);if(!a)throw new W(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return Z(a,t,r,[],i)}async function Z(e,t,n,o=[],s=[],c){let l=await e.getPromptForCommand(t,n),u=!be(`hooks`)||Se(e.source);if(e.hooks&&u){let t=r();qe(n.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let f=e.source?`${e.source}:${e.name}`:e.name,p=l.filter(e=>e.type===`text`).map(e=>e.text).join(`
4
+
5
+ `);i(e.name,f,p,oe()?.agentId??null);let m=it(e,t),h=d(e.allowedTools??[]),g=s.length>0||o.length>0?[...s,...o,...l]:l,_=await he(a(l.filter(e=>e.type===`text`).map(e=>e.text).join(` `),n,null,[],n.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[B({content:m,uuid:c}),B({content:g,isMeta:!0}),..._,C({type:`command_permissions`,allowedTools:h,model:e.model})],shouldQuery:!0,allowedTools:h,model:e.model,command:e}}var Q,$;e((()=>{n(),b(),f(),Be(),Ve(),te(),l(),ge(),ce(),ye(),je(),Ce(),U(),Pe(),O(),Fe(),j(),_e(),Je(),ze(),o(),v(),re(),D(),h(),Te(),Xe(),le(),pe(),Ke(),ne(),fe(),c(),xe(),He(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,at as processPromptSlashCommand,tt as processSlashCommand};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./cwd-Pa83R95t.js";import{f as a,u as o}from"./debug-Bglx1aTu.js";import{En as s,wn as c}from"./settings-B2jvL8Dp.js";import{g as l,o as u,p as d}from"./config-C-Y2qtB2.js";import{join as f}from"path";function p(){let e=o().existsSync(f(i(),`AGENTS.md`)),t=s(i());return[{key:`workspace`,text:`Ask Work Mate to create a new app or clone a repository`,isComplete:!1,isCompletable:!0,isEnabled:t},{key:`agentsmd`,text:`Run /init to create a AGENTS.md file with instructions for Work Mate`,isComplete:e,isCompletable:!0,isEnabled:!t}]}function m(){return p().filter(({isCompletable:e,isEnabled:t})=>e&&t).every(({isComplete:e})=>e)}function h(){u().hasCompletedProjectOnboarding||m()&&l(e=>({...e,hasCompletedProjectOnboarding:!0}))}function g(){l(e=>({...e,projectOnboardingSeenCount:e.projectOnboardingSeenCount+1}))}var _,v=e((()=>{n(),d(),r(),c(),a(),_=t(()=>{let e=u();return e.hasCompletedProjectOnboarding||e.projectOnboardingSeenCount>=4||process.env.IS_DEMO?!1:!m()})}));export{_ as a,h as i,g as n,v as r,p as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./cwd-BvNt_018.js";import{f as a,u as o}from"./debug-CRnGsZOV.js";import{En as s,wn as c}from"./settings-CodSADx8.js";import{a as l,d as u,m as d}from"./config-CWPHVTic.js";import{join as f}from"path";function p(){let e=o().existsSync(f(i(),`AGENTS.md`)),t=s(i());return[{key:`workspace`,text:`Ask Work Mate to create a new app or clone a repository`,isComplete:!1,isCompletable:!0,isEnabled:t},{key:`agentsmd`,text:`Run /init to create a AGENTS.md file with instructions for Work Mate`,isComplete:e,isCompletable:!0,isEnabled:!t}]}function m(){return p().filter(({isCompletable:e,isEnabled:t})=>e&&t).every(({isComplete:e})=>e)}function h(){l().hasCompletedProjectOnboarding||m()&&d(e=>({...e,hasCompletedProjectOnboarding:!0}))}function g(){d(e=>({...e,projectOnboardingSeenCount:e.projectOnboardingSeenCount+1}))}var _,v=e((()=>{n(),u(),r(),c(),a(),_=t(()=>{let e=l();return e.hasCompletedProjectOnboarding||e.projectOnboardingSeenCount>=4||process.env.IS_DEMO?!1:!m()})}));export{_ as a,h as i,g as n,v as r,p as t};
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./prompt-DzO1um1h.js";t();export{e as isDeferredTool};
@@ -0,0 +1 @@
1
+ import{Ex as e,bx as t}from"./loadAgentsDir-DGozQu_6.js";e();export{t as clearPromptCache};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{l as a,o}from"./envUtils-DfkgIdYf.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{$ as l,G as u,W as d,Z as f,o as p,s as m,x as h}from"./types-Dx7P7JLQ.js";import{C as g,I as _,j as v,x as y}from"./debug-Bglx1aTu.js";import{G as b,K as x,U as S,W as C,Z as w,q as T}from"./settings-B2jvL8Dp.js";import{H as E,q as D}from"./log-D2TIwHBV.js";import{i as O,o as k}from"./platform-BacQ6ACS.js";import{d as A,o as j}from"./model-BwBG0V1u.js";import{join as M,parse as N,resolve as P,sep as ee}from"node:path";import{createHash as F}from"node:crypto";import{appendFile as I,mkdir as te,readFile as L,readdir as ne,rm as re,writeFile as ie}from"node:fs/promises";function ae(e,t){return{tool_use_id:e,type:`tool_result`,content:t}}function oe(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function se(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ce(e,t){return e.find(e=>se(e,t))}function le(e){return{...de,userFacingName:()=>e.name,...e}}var ue,de,fe=t((()=>{ue=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),de={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),pe,me,he,ge,_e=t((()=>{pe=`Edit`,me=`/.workmate/**`,he=`~/.workmate/**`,ge=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function ve(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function ye(){return!j().toLowerCase().includes(`claude-3-haiku`)}function be(e){let t=e.startsWith(`.`)?e.slice(1):e;return xe.has(t.toLowerCase())}var xe,Se=t((()=>{A(),xe=new Set([`pdf`])})),R,Ce=t((()=>{R=`Bash`}));function we(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
1
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{l as a,o}from"./envUtils-DfkgIdYf.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Q as l,U as u,W as d,X as f,b as p,o as m,s as h}from"./types-97nL3naE.js";import{C as g,I as _,j as v,x as y}from"./debug-CRnGsZOV.js";import{G as b,K as x,U as S,W as C,Z as w,q as T}from"./settings-CodSADx8.js";import{H as E,q as D}from"./log-DoSpAwRP.js";import{i as O,n as k}from"./platform-DsMIk3eq.js";import{f as A,s as j}from"./model-DpZaKZMb.js";import{join as M,parse as N,resolve as P,sep as ee}from"node:path";import{createHash as F}from"node:crypto";import{appendFile as I,mkdir as te,readFile as L,readdir as ne,rm as re,writeFile as ie}from"node:fs/promises";function ae(e,t){return{tool_use_id:e,type:`tool_result`,content:t}}function oe(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function se(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ce(e,t){return e.find(e=>se(e,t))}function le(e){return{...de,userFacingName:()=>e.name,...e}}var ue,de,fe=t((()=>{ue=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),de={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),pe,me,he,ge,_e=t((()=>{pe=`Edit`,me=`/.workmate/**`,he=`~/.workmate/**`,ge=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function ve(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function ye(){return!j().toLowerCase().includes(`claude-3-haiku`)}function be(e){let t=e.startsWith(`.`)?e.slice(1):e;return xe.has(t.toLowerCase())}var xe,Se=t((()=>{A(),xe=new Set([`pdf`])})),R,Ce=t((()=>{R=`Bash`}));function we(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
2
2
  Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
3
3
 
4
4
  Usage:
@@ -61,13 +61,13 @@ Plan mode note: In plan mode, use this tool to clarify requirements or choose be
61
61
  - Supports glob patterns like "**/*.js" or "src/**/*.ts"
62
62
  - Returns matching file paths sorted by modification time
63
63
  - Use this tool when you need to find files by name patterns
64
- - When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead`})),Tn,En=t((()=>{Tn=`PowerShell`}));function Dn(){return O()===`windows`&&a(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL)}var On,kn=t((()=>{Ce(),En(),o(),k(),On=[R,Tn]}));function An(){return`\n- If this is an existing file, you MUST use the ${z} tool first to read the file's contents. This tool will fail if you did not read the file first.`}function jn(){return`Writes a file to the local filesystem.
64
+ - When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead`})),Tn,En=t((()=>{Tn=`PowerShell`}));function Dn(){return k()===`windows`&&a(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL)}var On,kn=t((()=>{Ce(),En(),o(),O(),On=[R,Tn]}));function An(){return`\n- If this is an existing file, you MUST use the ${z} tool first to read the file's contents. This tool will fail if you did not read the file first.`}function jn(){return`Writes a file to the local filesystem.
65
65
 
66
66
  Usage:
67
67
  - This tool will overwrite the existing file if there is one at the provided path.${An()}
68
68
  - Prefer the Edit tool for modifying existing files \u2014 it only sends the diff. Only use this tool to create new files or for complete rewrites.
69
69
  - NEVER create documentation files (*.md) or README files unless explicitly requested by the User.
70
- - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var Mn,Nn=t((()=>{je(),Mn=`Write`})),Pn,Fn=t((()=>{Pn=`NotebookEdit`})),In,Ln=t((()=>{In=`TaskGet`})),Rn,zn=t((()=>{Rn=`TaskList`})),Bn,Vn=t((()=>{Bn=`SearchExtraTools`}));function Hn(e){return e.isNonInteractiveSession}function Un(e){let t=Yn.get(e);if(t)return t;let n=Wn(e);return Yn.set(e,n),n}function Wn(e){try{let t=new Gn.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...Jn,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new v(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Gn,Kn,qn,K,Jn,Yn,Xn=t((()=>{Gn=n(fn(),1),h(),fe(),_(),p(),y(),Kn=m(()=>u({}).passthrough()),qn=m(()=>f().describe(`Structured output tool result`)),K=`StructuredOutput`,Jn=le({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:K,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Kn()},get outputSchema(){return qn()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${g(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),Yn=new WeakMap})),Zn,Qn,$n,er=t((()=>{D(),Zn=`Sleep`,Qn=`Wait for a specified duration`,$n=`Wait for a specified duration. The user can interrupt the sleep at any time.
70
+ - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var Mn,Nn=t((()=>{je(),Mn=`Write`})),Pn,Fn=t((()=>{Pn=`NotebookEdit`})),In,Ln=t((()=>{In=`TaskGet`})),Rn,zn=t((()=>{Rn=`TaskList`})),Bn,Vn=t((()=>{Bn=`SearchExtraTools`}));function Hn(e){return e.isNonInteractiveSession}function Un(e){let t=Yn.get(e);if(t)return t;let n=Wn(e);return Yn.set(e,n),n}function Wn(e){try{let t=new Gn.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...Jn,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new v(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Gn,Kn,qn,K,Jn,Yn,Xn=t((()=>{Gn=n(fn(),1),p(),fe(),_(),m(),y(),Kn=h(()=>d({}).passthrough()),qn=h(()=>f().describe(`Structured output tool result`)),K=`StructuredOutput`,Jn=le({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:K,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Kn()},get outputSchema(){return qn()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${g(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),Yn=new WeakMap})),Zn,Qn,$n,er=t((()=>{D(),Zn=`Sleep`,Qn=`Wait for a specified duration`,$n=`Wait for a specified duration. The user can interrupt the sleep at any time.
71
71
 
72
72
  Use this when the user tells you to sleep or rest, when you have nothing to do, or when you're waiting for something.
73
73
 
@@ -97,7 +97,7 @@ All operations require:
97
97
 
98
98
  Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),rr,ir=t((()=>{rr=`VerifyPlanExecution`})),ar,or=t((()=>{ar=`ExecuteExtraTool`})),sr,cr=t((()=>{sr=`EnterWorktree`})),lr,ur=t((()=>{lr=`ExitWorktree`})),dr=t((()=>{})),q,J,fr,pr,mr,hr,Y=t((()=>{q=`Workflow`,J=`.workmate/workflows`,fr=`.workmate/workflow-runs`,pr=[`.ts`,`.js`,`.mjs`],mr=1e3,hr=4096}));function gr(e){return{[vr]:e}}function _r(e){return e[vr]}var vr,yr=t((()=>{vr=Symbol(`workflow.hostHandle`)}));function br(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var xr,Sr,Cr=t((()=>{s(),xr=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},Sr=class{constructor(){c(this,`adapters`,new Map),c(this,`rules`,[]),c(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if(br(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new xr(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function wr(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var Tr,Er=t((()=>{Y(),s(),Tr=class{constructor(e){c(this,`available`,void 0),c(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function Dr(e){let t=Nr.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new X("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new X(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new X(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:Or(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
99
99
  `)}}function Or(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new X(`meta must be an object`);let t=e;if(typeof t.name!=`string`||typeof t.description!=`string`)throw new X(`meta must include string name and description`);return t}function kr(){function e(...e){if(e.length===0)throw new Z(`Date.now()/new Date()`);return new Date(...e)}let t=e;return t.now=()=>{throw new Z(`Date.now()`)},t.parse=Date.parse,t.UTC=Date.UTC,t}function Ar(){return new Proxy(Math,{get(e,t,n){return t===`random`?()=>{throw new Z(`Math.random()`)}:Reflect.get(e,t,n)}})}function jr(e){if(/^\s*import\b/m.test(e))throw new X(`workflow scripts are the body of new AsyncFunction (not ESM modules); import is not supported. agent / parallel / pipeline / phase / log / workflow / args / budget are injected as parameters — use them directly.`);if(/\bimport\s*\(/m.test(e))throw new X(`dynamic import(...) is forbidden in workflow scripts: it bypasses the Date/Math sandbox and breaks resume determinism. The sandbox does not guarantee security (same trust level as the LLM), but explicit escapes are prohibited. Inject external dependencies via args.`);if(/^\s*export\b/m.test(e))throw new X(`workflow scripts allow only one export const meta = {...} (already extracted by the engine). Remove other export / export default statements; use top-level return for the result.`)}function Mr(e){let{meta:t,body:n}=Dr(e);jr(n);let r;try{r=new Pr(`agent`,`parallel`,`pipeline`,`phase`,`log`,`workflow`,`args`,`budget`,`Date`,`Math`,n)}catch(e){throw new X(`Script syntax error: ${e.message}`)}let i=kr(),a=Ar();return{meta:t,async execute(e,t,n){return r(e.agent,e.parallel,e.pipeline,e.phase,e.log,e.workflow,t,n,i,a)}}}var X,Nr,Z,Pr,Fr=t((()=>{X=class extends Error{constructor(e){super(e),this.name=`ScriptError`}},Nr=/export\s+const\s+meta\s*=\s*/,Z=class extends Error{constructor(e){super(`${e} is not available in workflow scripts (would break resume determinism). Pass timestamps/random seeds via args.`),this.name=`NonDeterministicError`}},Pr=Object.getPrototypeOf(async()=>{}).constructor}));function Ir(e){let{label:t,phase:n,...r}=e,i=Object.keys(r).sort(),a={};for(let e of i)a[e]=r[e];return JSON.stringify(a)}function Lr(e,t){return F(`sha256`).update(`${e}\n${Ir(t)}`).digest(`hex`)}function Rr(e){let t=t=>M(e,t,`journal.jsonl`);return{async read(e){try{return(await L(t(e),`utf-8`)).split(`
100
- `).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await te(M(e,n),{recursive:!0}),await I(t(n),`${JSON.stringify(r)}\n`,`utf-8`)},async truncate(t){await re(M(e,t),{recursive:!0,force:!0})}}}var zr=t((()=>{})),Br,Vr,Hr=t((()=>{s(),Br=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},Vr=class{constructor(e){c(this,`total`,void 0),c(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new Br}}})),Ur=t((()=>{}));function Wr(e,t){let n=P(e),r=P(n,t);return r===n||r.startsWith(n+ee)}function Gr(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var Kr=t((()=>{}));function qr(e){return pr.includes(e.toLowerCase())}async function Jr(e,t){for(let n of pr){let r=P(e,t+n);if(!Wr(e,r))return null;try{return{path:r,content:await L(r,`utf-8`)}}catch{}}return null}async function Yr(e){let t;try{t=await ne(e)}catch{return[]}return t.filter(e=>qr(N(e).ext)).map(e=>N(e).name).sort()}var Xr=t((()=>{Y(),Kr()})),Q,$,Zr=t((()=>{Q=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},$=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function Qr(e,t){return{semaphore:new Tr(wr(t)),budget:new Vr(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function $r(e){let t=Qr(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var ei=t((()=>{Hr(),Er()}));function ti(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Q(`workflow exceeds total agent cap (${mr})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=Lr(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),ni(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new $}try{if(e.signal.aborted)throw new $;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof $)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof $)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let p={key:s,seq:a,result:f};return e.journal.push(p),e.journalIndex++,await e.ports.journalStore.append(e.runId,p),ni(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Q(`parallel exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Q(`pipeline exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Q(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function ni(e){return e.kind===`ok`?e.output:null}var ri=t((()=>{Y(),Zr(),zr()}));async function ii(e){let{ports:t}=e,n;try{n=Mr(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=$r({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await ai(t,e.cwd),r;try{r=Mr(n)}catch(e){throw new Q(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=ti(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=ti(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof $?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function ai(e,t){if(e.script)return e.script;if(e.scriptPath)return await L(e.scriptPath,`utf-8`);if(e.name){let n=await Jr(M(t,J),e.name);if(!n)throw new Q(`Sub-workflow "${e.name}" not found`);return n.content}throw new Q(`workflow() requires name or scriptPath`)}var oi=t((()=>{Y(),ei(),Zr(),ri(),Xr(),Fr()})),si=t((()=>{})),ci,li=t((()=>{h(),ci=u({script:f().optional().describe(`Self-contained workflow script source (inline)`),name:f().optional().describe(`Named workflow, resolved to .workmate/workflows/<name>.ts|js|mjs`),scriptPath:f().optional().describe(`Absolute path to an existing script file`),args:l().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:f().optional().describe(`Resume the specified run, replaying the journal`),description:f().optional().describe(`A short description of this invocation (3-5 words)`),title:f().optional().describe(`Progress viewer title`),maxConcurrency:d().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function ui(e,t,n){let r=M(n,fr,t);await te(r,{recursive:!0});let i=M(r,`script.js`);return await ie(i,e,`utf-8`),i}var di=t((()=>{Y()}));function fi(e){return{name:q,inputSchema:ci,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return _i},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await gi(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{Mr(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await ui(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}ii({script:o,...t.args===void 0?{}:{args:hi(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>pi(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
100
+ `).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await te(M(e,n),{recursive:!0}),await I(t(n),`${JSON.stringify(r)}\n`,`utf-8`)},async truncate(t){await re(M(e,t),{recursive:!0,force:!0})}}}var zr=t((()=>{})),Br,Vr,Hr=t((()=>{s(),Br=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},Vr=class{constructor(e){c(this,`total`,void 0),c(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new Br}}})),Ur=t((()=>{}));function Wr(e,t){let n=P(e),r=P(n,t);return r===n||r.startsWith(n+ee)}function Gr(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var Kr=t((()=>{}));function qr(e){return pr.includes(e.toLowerCase())}async function Jr(e,t){for(let n of pr){let r=P(e,t+n);if(!Wr(e,r))return null;try{return{path:r,content:await L(r,`utf-8`)}}catch{}}return null}async function Yr(e){let t;try{t=await ne(e)}catch{return[]}return t.filter(e=>qr(N(e).ext)).map(e=>N(e).name).sort()}var Xr=t((()=>{Y(),Kr()})),Q,$,Zr=t((()=>{Q=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},$=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function Qr(e,t){return{semaphore:new Tr(wr(t)),budget:new Vr(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function $r(e){let t=Qr(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var ei=t((()=>{Hr(),Er()}));function ti(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Q(`workflow exceeds total agent cap (${mr})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=Lr(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),ni(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new $}try{if(e.signal.aborted)throw new $;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof $)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof $)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let p={key:s,seq:a,result:f};return e.journal.push(p),e.journalIndex++,await e.ports.journalStore.append(e.runId,p),ni(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Q(`parallel exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Q(`pipeline exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Q(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function ni(e){return e.kind===`ok`?e.output:null}var ri=t((()=>{Y(),Zr(),zr()}));async function ii(e){let{ports:t}=e,n;try{n=Mr(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=$r({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await ai(t,e.cwd),r;try{r=Mr(n)}catch(e){throw new Q(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=ti(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=ti(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof $?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function ai(e,t){if(e.script)return e.script;if(e.scriptPath)return await L(e.scriptPath,`utf-8`);if(e.name){let n=await Jr(M(t,J),e.name);if(!n)throw new Q(`Sub-workflow "${e.name}" not found`);return n.content}throw new Q(`workflow() requires name or scriptPath`)}var oi=t((()=>{Y(),ei(),Zr(),ri(),Xr(),Fr()})),si=t((()=>{})),ci,li=t((()=>{p(),ci=d({script:f().optional().describe(`Self-contained workflow script source (inline)`),name:f().optional().describe(`Named workflow, resolved to .workmate/workflows/<name>.ts|js|mjs`),scriptPath:f().optional().describe(`Absolute path to an existing script file`),args:l().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:f().optional().describe(`Resume the specified run, replaying the journal`),description:f().optional().describe(`A short description of this invocation (3-5 words)`),title:f().optional().describe(`Progress viewer title`),maxConcurrency:u().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function ui(e,t,n){let r=M(n,fr,t);await te(r,{recursive:!0});let i=M(r,`script.js`);return await ie(i,e,`utf-8`),i}var di=t((()=>{Y()}));function fi(e){return{name:q,inputSchema:ci,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return _i},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await gi(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{Mr(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await ui(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}ii({script:o,...t.args===void 0?{}:{args:hi(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>pi(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
101
101
  `)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function pi(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:mi(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function mi(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function hi(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function gi(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=P(t,e.scriptPath);if(!Wr(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await L(n,`utf-8`),workflowFile:n}}if(e.name){if(Gr(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await Jr(M(t,J),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${J}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var _i,vi=t((()=>{Y(),Xr(),oi(),Fr(),Kr(),li(),di(),_i='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .workmate/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),yi=t((()=>{dr(),Y(),yr(),Cr(),Er(),Fr(),zr(),Hr(),Ur(),Xr(),Zr(),ei(),ri(),oi(),si(),vi(),li(),di()})),bi,xi,Si,Ci,wi,Ti,Ei=t((()=>{bi=`LocalMemoryRecall`,xi=100*1024,Si=2*1024,Ci=50*1024,wi=4*1024,Ti=8*1024})),Di,Oi,ki,Ai,ji=t((()=>{x(),Me(),mn(),w(),yn(),C(),je(),Pe(),xn(),wn(),kn(),_e(),Nn(),Fn(),Be(),Ie(),Ln(),zn(),Re(),Vn(),Xn(),er(),nr(),ir(),or(),cr(),ur(),yi(),Ei(),Di=new Set([b,B,pn,T,hn,S,q,bi]),Oi=new Set([...Di]),ki=new Set([z,Ne,G,Sn,...On,pe,Mn,Pn,ze,K,Bn,ar,sr,lr]),Ai=new Set([...On,z,pe,Mn,Sn,G,Pn,T,hn,b,S,Fe,In,Rn,Le,Ne,pn,B,rr,`LSP`,ze,q,Zn,Bn,ar,K])}));function Mi(){return`Deferred tools appear by name in <available-deferred-tools> messages.`}function Ni(e){return!(e.alwaysLoad===!0||Ai.has(e.name))}function Pi(e){return e.name}function Fi(){return Ii+Mi()+Li}var Ii,Li,Ri=t((()=>{ji(),Vn(),Ii=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
102
102
 
103
103
  `,Li=` Returns matching tool names.
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{P_ as r,z_ as i}from"./loadAgentsDir-DlPbtIsS.js";import{Rn as a,t as o}from"./src-DL3w8VPk.js";import{T as s,c,f as l,i as u,u as d,x as f}from"./debug-Bglx1aTu.js";import{_ as p,b as m,x as h,y as g}from"./stringUtils-C718f5ey.js";import{i as _,n as v,o as y,s as b}from"./history-CQiUERTL.js";import{n as x,t as S}from"./tempfile-CHO5wXsV.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!g(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let r=n.split(` `),i=r[0]??n,o=r.slice(1),s=D(n);if(s){let r=O(s,e,t),a={detached:!0,stdio:`ignore`},l;return l=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...a,shell:!0}):w(i,[...o,...r],a),l.on(`error`,e=>c(`editor spawn failed: ${e}`,{level:`error`})),l.unref(),!0}let l=a.get(process.stdout);if(!l)return!1;let u=t&&j.test(C(i));l.enterAlternateScreen();try{let r={stdio:`inherit`},a;return a=process.platform===`win32`?T(`${n} ${u?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(i,[...o,...u?[`+${t}`,e]:[e]],r),a.error?(c(`editor spawn failed: ${a.error}`,{level:`error`}),!1):!0}finally{l.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),o(),u(),p(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=d(),n=a.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let r=N();if(!r)return{content:null};try{t.statSync(e)}catch{return{content:null}}let o=!F(r);o?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return m(`${z[r]??r} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${i(r)} exited with code ${t}`}}return{content:null}}finally{o?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=_(n,y(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function R(e,t){let n=d(),r=S();try{s(r,t?v(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Rn as r,t as i}from"./src-DL3w8VPk.js";import{W_ as a,z_ as o}from"./loadAgentsDir-DGozQu_6.js";import{T as s,c,f as l,i as u,u as d,x as f}from"./debug-CRnGsZOV.js";import{_ as p,b as m,x as h,y as g}from"./stringUtils-Bu_lJH5c.js";import{i as _,n as v,o as y,s as b}from"./history-kOw3CcLT.js";import{n as x,t as S}from"./tempfile-CHO5wXsV.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!g(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let i=n.split(` `),a=i[0]??n,o=i.slice(1),s=D(n);if(s){let r=O(s,e,t),i={detached:!0,stdio:`ignore`},l;return l=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...i,shell:!0}):w(a,[...o,...r],i),l.on(`error`,e=>c(`editor spawn failed: ${e}`,{level:`error`})),l.unref(),!0}let l=r.get(process.stdout);if(!l)return!1;let u=t&&j.test(C(a));l.enterAlternateScreen();try{let r={stdio:`inherit`},i;return i=process.platform===`win32`?T(`${n} ${u?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(a,[...o,...u?[`+${t}`,e]:[e]],r),i.error?(c(`editor spawn failed: ${i.error}`,{level:`error`}),!1):!0}finally{l.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),i(),u(),p(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=d(),n=r.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=N();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let o=!F(i);o?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return m(`${z[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${a(i)} exited with code ${t}`}}return{content:null}}finally{o?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=_(n,y(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function R(e,t){let n=d(),r=S();try{s(r,t?v(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
2
2
  `)&&!i.endsWith(`
3
3
 
4
- `)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{b(),o(),P(),h(),l(),r(),f(),x(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};
4
+ `)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{b(),i(),P(),h(),l(),o(),f(),x(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};
@@ -0,0 +1,13 @@
1
+ import{C as e,c as t,i as n,x as r}from"./debug-CRnGsZOV.js";import{d as i,o as a}from"./config-CWPHVTic.js";import{i as o,t as s}from"./execFileNoThrow-BgRsj_SW.js";import{_ as c,v as l}from"./stringUtils-Bu_lJH5c.js";import{n as u,t as d}from"./sanitization-DV-94a9Z.js";import{i as f,n as p,r as m}from"./banner-DHpTmEO7.js";import{homedir as h}from"os";import{basename as g}from"path";import{spawn as _}from"child_process";d();var v=`claude-cli`;function y(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31||n===127)return!0}return!1}var b=/^[\w.-]+\/[\w.-]+$/,x=5e3,S=4096;function C(e){let t=e.startsWith(`claude-cli://`)?e:e.startsWith(`claude-cli:`)?e.replace(`${v}:`,`${v}://`):null;if(!t)throw Error(`Invalid deep link: expected ${v}:// scheme, got "${e}"`);let n;try{n=new URL(t)}catch{throw Error(`Invalid deep link URL: "${e}"`)}if(n.hostname!==`open`)throw Error(`Unknown deep link action: "${n.hostname}"`);let r=n.searchParams.get(`cwd`)??void 0,i=n.searchParams.get(`repo`)??void 0,a=n.searchParams.get(`q`);if(r&&!r.startsWith(`/`)&&!/^[a-zA-Z]:[/\\]/.test(r))throw Error(`Invalid cwd in deep link: must be an absolute path, got "${r}"`);if(r&&y(r))throw Error(`Deep link cwd contains disallowed control characters`);if(r&&r.length>S)throw Error(`Deep link cwd exceeds ${S} characters (got ${r.length})`);if(i&&!b.test(i))throw Error(`Invalid repo in deep link: expected "owner/repo", got "${i}"`);let o;if(a&&a.trim().length>0){if(o=u(a.trim()),y(o))throw Error(`Deep link query contains disallowed control characters`);if(o.length>x)throw Error(`Deep link query exceeds ${x} characters (got ${o.length})`)}return{query:o,cwd:r,repo:i}}r(),n(),i(),o(),c();var w=[{name:`iTerm2`,bundleId:`com.googlecode.iterm2`,app:`iTerm`},{name:`Ghostty`,bundleId:`com.mitchellh.ghostty`,app:`Ghostty`},{name:`Kitty`,bundleId:`net.kovidgoyal.kitty`,app:`kitty`},{name:`Alacritty`,bundleId:`org.alacritty`,app:`Alacritty`},{name:`WezTerm`,bundleId:`com.github.wez.wezterm`,app:`WezTerm`},{name:`Terminal.app`,bundleId:`com.apple.Terminal`,app:`Terminal`}],T=[`ghostty`,`kitty`,`alacritty`,`wezterm`,`gnome-terminal`,`konsole`,`xfce4-terminal`,`mate-terminal`,`tilix`,`xterm`];async function E(){let e=a().deepLinkTerminal;if(e){let t=w.find(t=>t.app===e);if(t)return{name:t.name,command:t.app}}let t=process.env.TERM_PROGRAM;if(t){let e=t.replace(/\.app$/i,``).toLowerCase(),n=w.find(t=>t.app.toLowerCase()===e||t.name.toLowerCase()===e);if(n)return{name:n.name,command:n.app}}for(let e of w){let{code:t,stdout:n}=await s(`mdfind`,[`kMDItemCFBundleIdentifier == "${e.bundleId}"`],{timeout:5e3,useCwd:!1});if(t===0&&n.trim().length>0)return{name:e.name,command:e.app}}for(let e of w){let{code:t}=await s(`ls`,[`/Applications/${e.app}.app`],{timeout:1e3,useCwd:!1});if(t===0)return{name:e.name,command:e.app}}return{name:`Terminal.app`,command:`Terminal`}}async function D(){let e=process.env.TERMINAL;if(e){let t=await l(e);if(t)return{name:g(e),command:t}}let t=await l(`x-terminal-emulator`);if(t)return{name:`x-terminal-emulator`,command:t};for(let e of T){let t=await l(e);if(t)return{name:e,command:t}}return null}async function O(){let e=await l(`wt.exe`);if(e)return{name:`Windows Terminal`,command:e};let t=await l(`pwsh.exe`);if(t)return{name:`PowerShell`,command:t};let n=await l(`powershell.exe`);return n?{name:`PowerShell`,command:n}:{name:`Command Prompt`,command:`cmd.exe`}}async function k(){switch(process.platform){case`darwin`:return E();case`linux`:return D();case`win32`:return O();default:return null}}async function A(e,n){let r=await k();if(!r)return t(`No terminal emulator detected`,{level:`error`}),!1;t(`Launching in terminal: ${r.name} (${r.command})`);let i=[`--deep-link-origin`];switch(n.repo&&(i.push(`--deep-link-repo`,n.repo),n.lastFetchMs!==void 0&&i.push(`--deep-link-last-fetch`,String(n.lastFetchMs))),n.query&&i.push(`--prefill`,n.query),process.platform){case`darwin`:return j(r,e,i,n.cwd);case`linux`:return M(r,e,i,n.cwd);case`win32`:return N(r,e,i,n.cwd);default:return!1}}async function j(e,n,r,i){switch(e.command){case`iTerm`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "iTerm"
2
+ if running then
3
+ create window with default profile
4
+ else
5
+ activate
6
+ end if
7
+ tell current session of current window
8
+ write text ${L(F(n,r,i))}
9
+ end tell
10
+ end tell`],{useCwd:!1});if(e===0)return!0;break}case`Terminal`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "Terminal"
11
+ do script ${L(F(n,r,i))}
12
+ activate
13
+ end tell`],{useCwd:!1});return e===0}case`Ghostty`:{let t=[`-na`,e.command,`--args`,`--window-save-state=never`];i&&t.push(`--working-directory=${i}`),t.push(`-e`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`Alacritty`:{let t=[`-na`,e.command,`--args`];i&&t.push(`--working-directory`,i),t.push(`-e`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`kitty`:{let t=[`-na`,e.command,`--args`];i&&t.push(`--directory`,i),t.push(n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`WezTerm`:{let t=[`-na`,e.command,`--args`,`start`];i&&t.push(`--cwd`,i),t.push(`--`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}}return t(`Failed to launch ${e.name}, falling back to Terminal.app`),j({name:`Terminal.app`,command:`Terminal`},n,r,i)}async function M(e,t,n,r){let i,a;switch(e.name){case`gnome-terminal`:i=r?[`--working-directory=${r}`,`--`]:[`--`],i.push(t,...n);break;case`konsole`:i=r?[`--workdir`,r,`-e`]:[`-e`],i.push(t,...n);break;case`kitty`:i=r?[`--directory`,r]:[],i.push(t,...n);break;case`wezterm`:i=r?[`start`,`--cwd`,r,`--`]:[`start`,`--`],i.push(t,...n);break;case`alacritty`:i=r?[`--working-directory`,r,`-e`]:[`-e`],i.push(t,...n);break;case`ghostty`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;case`xfce4-terminal`:case`mate-terminal`:i=r?[`--working-directory=${r}`,`-x`]:[`-x`],i.push(t,...n);break;case`tilix`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;default:i=[`-e`,t,...n],a=r;break}return P(e.command,i,{cwd:a})}async function N(e,t,n,r){let i=[];switch(e.name){case`Windows Terminal`:r&&i.push(`-d`,r),i.push(`--`,t,...n);break;case`PowerShell`:{let e=r?`Set-Location ${R(r)}; `:``;i.push(`-NoExit`,`-Command`,`${e}& ${R(t)} ${n.map(R).join(` `)}`);break}default:{let e=r?`cd /d ${z(r)} && `:``;i.push(`/k`,`${e}${z(t)} ${n.map(e=>z(e)).join(` `)}`);break}}return P(e.command,i,{windowsVerbatimArguments:e.name===`Command Prompt`})}function P(e,n,r={}){return new Promise(i=>{let a=_(e,n,{detached:!0,stdio:`ignore`,cwd:r.cwd,windowsVerbatimArguments:r.windowsVerbatimArguments});a.once(`error`,n=>{t(`Failed to spawn ${e}: ${n.message}`,{level:`error`}),i(!1)}),a.once(`spawn`,()=>{a.unref(),i(!0)})})}function F(e,t,n){return`${n?`cd ${I(n)} && `:``}${[e,...t].map(I).join(` `)}`}function I(e){return`'${e.replace(/'/g,`'\\''`)}'`}function L(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function R(e){return`'${e.replace(/'/g,`''`)}'`}function z(e){return`"${e.replace(/"/g,``).replace(/%/g,`%%`).replace(/(\\+)$/,`$1$1`)}"`}n();async function B(n){t(`Handling deep link URI: ${n}`);let r;try{r=C(n)}catch(e){let t=e instanceof Error?e.message:String(e);return console.error(`Deep link error: ${t}`),1}t(`Parsed deep link action: ${e(r)}`);let{cwd:i,resolvedRepo:a}=await H(r),o=a?await p(i):void 0;return await A(process.execPath,{query:r.query,cwd:i,repo:a,lastFetchMs:o?.getTime()})?0:(console.error(`Failed to open a terminal. Make sure a supported terminal emulator is installed.`),1)}async function V(){if(process.env.__CFBundleIdentifier!==`com.anthropic.claude-code-url-handler`)return null;try{let{waitForUrlEvent:e}=await import(`./urlHandler-DLz3FZm1.js`),t=await e(5e3);return t?await B(t):null}catch{return null}}async function H(e){if(e.cwd)return{cwd:e.cwd};if(e.repo){let n=await m(f(e.repo));if(n[0])return t(`Resolved repo ${e.repo} → ${n[0]}`),{cwd:n[0],resolvedRepo:e.repo};t(`No local clone found for repo ${e.repo}, falling back to home`)}return{cwd:h()}}export{B as handleDeepLinkUri,V as handleUrlSchemeLaunch};
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,o as n,t as r}from"./rolldown-runtime-DaDcL9Zw.js";import{n as i,t as a}from"./memoize-BK3gG5ob.js";import{a as o,l as s,o as c}from"./envUtils-DfkgIdYf.js";import{i as l,n as u,r as d,t as f}from"./defineProperty-C-QyHrDq.js";import{a as p,c as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./classPrivateFieldSet2-D4U5K-I3.js";import{n as x,t as S}from"./classPrivateMethodInitSpec-BXQD0Vh4.js";import{t as C}from"./src-DCUgdrYl.js";import{n as w,t as T}from"./axios-DaWTGg7G.js";import{c as E,f as D,i as O,u as k}from"./debug-Bglx1aTu.js";import A from"assert";import{Agent as j}from"https";import*as M from"http";import{URL as N}from"url";import*as P from"net";import*as F from"tls";var I=t((()=>{})),L,R,z=t((()=>{I(),L=Symbol(`AgentBaseInternalState`),R=class extends M.Agent{constructor(e){super(e),this[L]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==`boolean`)return e.secureEndpoint;if(typeof e.protocol==`string`)return e.protocol===`https:`}let{stack:t}=Error();return typeof t==`string`&&t.split(`
1
+ import{i as e,n as t,o as n,t as r}from"./rolldown-runtime-DaDcL9Zw.js";import{n as i,t as a}from"./memoize-BK3gG5ob.js";import{a as o,l as s,o as c}from"./envUtils-DfkgIdYf.js";import{i as l,n as u,r as d,t as f}from"./defineProperty-C-QyHrDq.js";import{a as p,c as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./classPrivateFieldSet2-D4U5K-I3.js";import{n as x,t as S}from"./classPrivateMethodInitSpec-BXQD0Vh4.js";import{t as C}from"./src-DCUgdrYl.js";import{n as w,t as T}from"./axios-DaWTGg7G.js";import{c as E,f as D,i as O,u as k}from"./debug-CRnGsZOV.js";import A from"assert";import{Agent as j}from"https";import*as M from"http";import{URL as N}from"url";import*as P from"net";import*as F from"tls";var I=t((()=>{})),L,R,z=t((()=>{I(),L=Symbol(`AgentBaseInternalState`),R=class extends M.Agent{constructor(e){super(e),this[L]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==`boolean`)return e.secureEndpoint;if(typeof e.protocol==`string`)return e.protocol===`https:`}let{stack:t}=Error();return typeof t==`string`&&t.split(`
2
2
  `).some(e=>e.indexOf(`(https.js:`)!==-1||e.indexOf(`node:https:`)!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[e]||(this.sockets[e]=[]);let t=new P.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||t===null)return;let n=this.sockets[e],r=n.indexOf(t);r!==-1&&(n.splice(r,1),this.totalSocketCount--,n.length===0&&delete this.sockets[e])}getName(e){return this.isSecureEndpoint(e)?j.prototype.getName.call(this,e):super.getName(e)}createSocket(e,t,n){let r={...t,secureEndpoint:this.isSecureEndpoint(t)},i=this.getName(r),a=this.incrementSockets(i);Promise.resolve().then(()=>this.connect(e,r)).then(o=>{if(this.decrementSockets(i,a),o instanceof M.Agent)try{return o.addRequest(e,r)}catch(e){return n(e)}this[L].currentSocket=o,super.createSocket(e,t,n)},e=>{this.decrementSockets(i,a),n(e)})}createConnection(){let e=this[L].currentSocket;if(this[L].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[L].defaultPort??(this.protocol===`https:`?443:80)}set defaultPort(e){this[L]&&(this[L].defaultPort=e)}get protocol(){return this[L].protocol??(this.isSecureEndpoint()?`https:`:`http:`)}set protocol(e){this[L]&&(this[L].protocol=e)}}}));function B(e){return new Promise((t,n)=>{let r=0,i=[];function a(){let t=e.read();t?l(t):e.once(`readable`,a)}function o(){e.removeListener(`end`,s),e.removeListener(`error`,c),e.removeListener(`readable`,a)}function s(){o(),H(`onend`),n(Error(`Proxy connection ended before receiving CONNECT response`))}function c(e){o(),H(`onerror %o`,e),n(e)}function l(s){i.push(s),r+=s.length;let c=Buffer.concat(i,r),l=c.indexOf(`\r
3
3
  \r
4
4
  `);if(l===-1){H(`have not received end of HTTP headers yet...`),a();return}let u=c.slice(0,l).toString(`ascii`).split(`\r
@@ -0,0 +1 @@
1
+ import{Pt as e,q as t}from"./state-BQ4BEGin.js";import{do as n,io as r,oo as i,uo as a}from"./loadAgentsDir-DGozQu_6.js";import{I as o,M as s,c,i as l}from"./debug-CRnGsZOV.js";import{Dr as u,Ir as d,_t as f,kn as p,vt as m,wn as h}from"./settings-CodSADx8.js";import{o as g,s as _}from"./log-DoSpAwRP.js";import{ht as v,mt as y}from"./model-DpZaKZMb.js";import{isAbsolute as b,resolve as x}from"path";y(),e(),l(),o(),h(),d(),g(),a(),f();function S(e,t,n){let r=[],i=[],a=[];for(let[o,s]of Object.entries(e)){let e=t[o],c=w(s.source,n?.projectRoot);e?s.sourceIsFallback||v(c,e.source)?a.push(o):i.push({name:o,declaredSource:c,materializedSource:e.source}):r.push(o)}return{missing:r,sourceChanged:i,upToDate:a}}async function C(e){let a=i();if(Object.keys(a).length===0)return{installed:[],updated:[],failed:[],upToDate:[],skipped:[]};let o;try{o=await n()}catch(e){_(e),o={}}let l=S(a,o,{projectRoot:t()}),u=[...l.missing.map(e=>({name:e,source:w(a[e].source),action:`install`})),...l.sourceChanged.map(({name:e,declaredSource:t})=>({name:e,source:t,action:`update`}))],d=[],f=[];for(let t of u){if(e?.skip?.(t.name,t.source)){d.push(t.name);continue}if(t.action===`update`&&m(t.source)&&!await p(t.source.path)){c(`[reconcile] '${t.name}' declared path does not exist; keeping materialized entry`),d.push(t.name);continue}f.push(t)}if(f.length===0)return{installed:[],updated:[],failed:[],upToDate:l.upToDate,skipped:d};c(`[reconcile] ${f.length} marketplace(s): ${f.map(e=>`${e.name}(${e.action})`).join(`, `)}`);let h=[],g=[],v=[];for(let t=0;t<f.length;t++){let{name:n,source:i,action:a}=f[t];e?.onProgress?.({type:`installing`,name:n,action:a,index:t+1,total:f.length});try{let t=await r(i);a===`install`?h.push(n):g.push(n),e?.onProgress?.({type:`installed`,name:n,alreadyMaterialized:t.alreadyMaterialized})}catch(t){let r=s(t);v.push({name:n,error:r}),e?.onProgress?.({type:`failed`,name:n,error:r}),_(t)}}return{installed:h,updated:g,failed:v,upToDate:l.upToDate,skipped:d}}function w(e,n){if((e.source===`directory`||e.source===`file`)&&!b(e.path)){let r=n??t(),i=u(r);return{...e,path:x(i??r,e.path)}}return e}export{C as n,S as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,q as n}from"./state-BQ4BEGin.js";import{Fa as r,Go as i,Hv as a,Ko as o,Mo as s,No as c,Pa as l,Qf as u,Vv as d,Xf as f,ap as p,ch as m,cp as h,i as g,o as _,rp as v,sh as y,sp as b}from"./loadAgentsDir-DGozQu_6.js";import{I as x,M as S,c as C,i as w}from"./debug-CRnGsZOV.js";import{o as T,s as E}from"./log-DoSpAwRP.js";async function D(e){C(`refreshActivePlugins: clearing all plugin caches`),s(),f();let t=await r(),[o,c]=await Promise.all([i(),g(n())]),{enabled:l,disabled:u,errors:d}=t,[_,v]=await Promise.all([Promise.all(l.map(async e=>{if(e.mcpServers)return Object.keys(e.mcpServers).length;let t=await a(e,d);return t&&(e.mcpServers=t),t?Object.keys(t).length:0})),Promise.all(l.map(async e=>{if(e.lspServers)return Object.keys(e.lspServers).length;let t=await h(e,d);return t&&(e.lspServers=t),t?Object.keys(t).length:0}))]),y=_.reduce((e,t)=>e+t,0),b=v.reduce((e,t)=>e+t,0);e(e=>({...e,plugins:{...e.plugins,enabled:l,disabled:u,commands:o,errors:O(e.plugins.errors,d),needsRefresh:!1},agentDefinitions:c,mcp:{...e.mcp,pluginReconnectKey:e.mcp.pluginReconnectKey+1}})),p();let x=!1;try{await m()}catch(e){x=!0,E(e),C(`refreshActivePlugins: loadPluginHooks failed: ${S(e)}`)}let w=l.reduce((e,t)=>t.hooksConfig?e+Object.values(t.hooksConfig).reduce((e,t)=>e+(t?.reduce((e,t)=>e+t.hooks.length,0)??0),0):e,0);return C(`refreshActivePlugins: ${l.length} enabled, ${o.length} commands, ${c.allAgents.length} agents, ${w} hooks, ${y} MCP, ${b} LSP`),{enabled_count:l.length,disabled_count:u.length,command_count:o.length,agent_count:c.allAgents.length,hook_count:w,mcp_count:y,lsp_count:b,error_count:d.length+ +!!x,agentDefinitions:c,pluginCommands:o}}function O(e,t){let n=e.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),r=new Set(t.map(k));return[...n.filter(e=>!r.has(k(e))),...t]}function k(e){return e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`}var A=e((()=>{t(),v(),_(),w(),x(),T(),c(),o(),y(),b(),d(),u(),l()}));export{D as n,A as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{$r as r,Kr as i,Qr as a,_r as o,ai as s,ar as ee,cr as c,dr as l,fr as u,gr as te,ii as d,ir as ne,lr as f,ni as p,pr as m,qr as re,ri as h,ur as ie}from"./state-BQ4BEGin.js";import{BC as ae,GC as g,KC as _,mT as v,pT as y,zC as b}from"./loadAgentsDir-DGozQu_6.js";import{Gn as x,Jn as S,Kn as C,Xn as w,Yn as T,di as E,fi as D,qn as O}from"./settings-CodSADx8.js";import{A as k,j as A}from"./config-CWPHVTic.js";import{n as j,t as M}from"./_baseEach-DrPH_FGo.js";function N(e){return h(e)||re(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),i(),p(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):d(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{s(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return C(S(e,void 0,R),e+``)}var V=e((()=>{z(),O(),x()}));function H(e,t){var n=[];return M(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}var U=e((()=>{j()}));function W(e,t){return t.length<2?e:c(e,g(t,0,-1))}var G=e((()=>{f(),_()}));function K(e){if(typeof e!=`function`)throw TypeError(q);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var q,J=e((()=>{q=`Expected a function`}));function oe(e,t){t=u(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=l(t[n]);if(i===`__proto__`&&!Y.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=W(e,t);return a==null||delete a[l(ae(t))]}var Y,se=e((()=>{m(),b(),G(),ie(),Y=Object.prototype.hasOwnProperty}));function ce(e){return w(e)?void 0:e}var le=e((()=>{T()})),X,Z,Q,$,ue=e((()=>{o(),v(),se(),m(),D(),le(),V(),A(),X=1,Z=2,Q=4,$=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=te(t,function(t){return t=u(t,e),r||(r=t.length>1),t}),E(e,k(e),n),r&&(n=y(n,X|Z|Q,ce));for(var i=t.length;i--;)oe(n,t[i]);return n})}));function de(e,t){return(h(e)?a:H)(e,K(ne(t,3)))}var fe=e((()=>{r(),U(),ee(),p(),J()}));export{$ as i,de as n,ue as r,fe as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-C718f5ey.js";import{n as r,t as i}from"./refresh-Ce2yk28a.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-Bu_lJH5c.js";import{n as r,t as i}from"./refresh-CAGv8BJY.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,at as n}from"./state-BQ4BEGin.js";import{Ji as r,Zr as i,ei as a,fr as o,gr as s,oS as c}from"./loadAgentsDir-DGozQu_6.js";import{n as l,t as u}from"./generateSessionName-BHIKyXpz.js";async function d(e,t,r){let s;if(!r||r.trim()===``){let n=await u(c(t.messages),t.abortController.signal);if(!n)return e(`Could not generate a name: no conversation context yet. Usage: /rename <name>`,{display:`system`}),null;s=n}else s=r.trim();let l=n(),d=o();return await a(l,s,d),await i(l,s,d),t.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:s}})),e(`Session renamed to: ${s}`,{display:`system`}),null}e((()=>{t(),r(),s(),l()}))();export{d as call};
@@ -1 +1 @@
1
- import{l as e,o as t}from"./envUtils-DfkgIdYf.js";import{o as n,s as r}from"./log-D2TIwHBV.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
1
+ import{l as e,o as t}from"./envUtils-DfkgIdYf.js";import{o as n,s as r}from"./log-DoSpAwRP.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{I as i,P as a,ai as o,di as s,dr as c,fi as l,ot as u,t as d}from"./src-DL3w8VPk.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as p,at as m,q as h}from"./state-BQ4BEGin.js";import{Ar as g,Bd as _,Or as v,Tr as y,Vd as b,bi as x,br as S,db as C,fb as w,gr as T,kb as E,lr as D,nr as O,oi as k,vr as A,yi as j}from"./loadAgentsDir-DGozQu_6.js";import{o as M,s as N}from"./log-DoSpAwRP.js";import{r as P,t as F}from"./Spinner-VjwI7m_g.js";import{n as I,r as L}from"./modalContext-DDZdU1J8.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./crossProjectResume-CwZb3cEU.js";function W(e){switch(e.resultType){case`sessionNotFound`:return`Session ${s.bold(e.arg)} was not found. Run ${s.bold(`/resume`)} without arguments to browse all sessions.`;case`multipleMatches`:return`Found ${e.count} sessions matching ${s.bold(e.arg)}. Run ${s.bold(`/resume`)} to pick one from the list.`}}function G({message:e,args:t,onDone:n}){return J.useEffect(()=>{let e=setTimeout(n,0);return()=>clearTimeout(e)},[n]),(0,Y.jsxs)(i,{flexDirection:`column`,children:[(0,Y.jsxs)(a,{dimColor:!0,children:[r.pointer,` /resume `,t]}),(0,Y.jsx)(C,{children:(0,Y.jsx)(a,{children:e})})]})}function K({onDone:e,onResume:t}){let[n,r]=J.useState([]),[o,s]=J.useState([]),[l,d]=J.useState(!0),[f,p]=J.useState(!1),[_,x]=J.useState(!1),{rows:C}=u(),w=L(),T=J.useCallback(async(t,n)=>{d(!0);try{let i=q(t?await y():await g(n),m());if(i.length===0){e(`No conversations found to resume`);return}r(i)}catch{e(`Failed to load conversations`)}finally{d(!1)}},[e]);J.useEffect(()=>{async function e(){let e=await j(h());s(e),T(!1,e)}e()},[T]);let E=J.useCallback(()=>{let e=!_;x(e),T(e,o)},[_,T,o]);async function O(n){let r=b(D(n));if(!r){e(`Failed to resume conversation`);return}let i=S(n)?await v(n):n,a=U(i,_);if(a.isCrossProject){if(a.isSameRepoWorktree){p(!0),t(r,i,`slash_command_picker`);return}let n=await c(a.command);n&&process.stdout.write(n),e([``,`This conversation is from a different directory.`,``,`To resume, run:`,` ${a.command}`,``,`(Command copied to clipboard)`,``].join(`
2
+ `),{display:`user`});return}p(!0),t(r,i,`slash_command_picker`)}function k(){e(`Resume cancelled`,{display:`system`})}return l?(0,Y.jsxs)(i,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(a,{children:` Loading conversations…`})]}):f?(0,Y.jsxs)(i,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(a,{children:` Resuming conversation…`})]}):(0,Y.jsx)(R,{logs:n,maxHeight:w?Math.floor(C/2):C-2,onCancel:k,onSelect:O,onLogsChanged:()=>T(_,o),showAllProjects:_,onToggleAllProjects:E,onAgenticSearch:H})}function q(e,t){return e.filter(e=>!e.isSidechain&&D(e)!==t)}var J,Y,X;e((()=>{l(),n(),J=t(o(),1),p(),V(),w(),P(),I(),E(),d(),z(),B(),x(),M(),T(),_(),Y=f(),X=async(e,t,n)=>{let r=async(n,r,i)=>{try{await t.resume?.(n,r,i),e(void 0,{display:`skip`})}catch(t){N(t),e(`Failed to resume: ${t.message}`)}},i=n?.trim();if(!i)return(0,Y.jsx)(K,{onDone:e,onResume:r},Date.now());let a=await g(await j(h()));if(a.length===0){let t=`No conversations found to resume.`;return(0,Y.jsx)(G,{message:t,args:i,onDone:()=>e(t)})}let o=b(i);if(o){let e=a.filter(e=>D(e)===o).sort((e,t)=>t.modified.getTime()-e.modified.getTime());if(e.length>0){let t=e[0];return r(o,S(t)?await v(t):t,`slash_command_session_id`),null}let t=await O(o);if(t)return r(o,t,`slash_command_session_id`),null}if(A()){let t=await k(i,{exact:!0});if(t.length===1){let e=t[0],n=D(e);if(n)return r(n,S(e)?await v(e):e,`slash_command_title`),null}if(t.length>1){let n=W({resultType:`multipleMatches`,arg:i,count:t.length});return(0,Y.jsx)(G,{message:n,args:i,onDone:()=>e(n)})}}let s=W({resultType:`sessionNotFound`,arg:i});return(0,Y.jsx)(G,{message:s,args:i,onDone:()=>e(s)})}}))();export{X as call,q as filterResumableSessions};
@@ -0,0 +1 @@
1
+ import{a as e,i as t}from"./ripgrep-CgQrN3XX.js";e();export{t as getRipgrepStatus};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,o as i}from"./envUtils-DfkgIdYf.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{c as s,i as c}from"./debug-CRnGsZOV.js";import{i as l,t as u}from"./execFileNoThrow-BgRsj_SW.js";import{o as d,s as f}from"./log-DoSpAwRP.js";import{f as p,h as m,m as h,o as g,p as _,r as v}from"./stringUtils-Bu_lJH5c.js";import{i as y,n as b}from"./platform-DsMIk3eq.js";import{n as x}from"./analytics-COpjZpvd.js";import{homedir as S}from"os";import*as C from"path";import{existsSync as w}from"fs";import{execFile as T,spawn as E}from"child_process";import{fileURLToPath as D}from"url";var O,k,A,j=e((()=>{O=D(import.meta.url),k=C.dirname(O),A=(()=>{let e=k.split(C.sep),t=e.lastIndexOf(`dist`);if(t!==-1)return e.slice(0,t+1).join(C.sep);let n=e.lastIndexOf(`src`);return n===-1?k:e.slice(0,n).join(C.sep)})()}));function M(e,t,n){let r=n??process.platform;return w(e)?{mode:`builtin`,command:e,args:[]}:(t===void 0?p(`rg`,[]).cmd:t??`rg`)===`rg`?{mode:`builtin`,command:e,args:[],note:`no ripgrep available on ${r}; install ripgrep via apt/pkg/brew`}:{mode:`system`,command:`rg`,args:[]}}function N(){let e=V();return{rgPath:e.command,rgArgs:e.args,argv0:e.argv0}}function P(e){return e.includes(`os error 11`)||e.includes(`Resource temporarily unavailable`)}function F(e,t,n,r,i=!1){let{rgPath:a,rgArgs:o,argv0:s}=N(),c=i?[`-j`,`1`]:[],l=[...o,...c,...e,t],u=b()===`wsl`?6e4:2e4,d=parseInt(process.env.CLAUDE_CODE_GLOB_TIMEOUT_SECONDS||``,10)||0,f=d>0?d*1e3:u;if(s){let e=E(a,l,{argv0:s,signal:n,windowsHide:!0}),t=``,i=``,o=!1,c=!1;e.stdout?.on(`data`,e=>{o||(t+=e.toString(),t.length>H&&(t=t.slice(0,H),o=!0))}),e.stderr?.on(`data`,e=>{c||(i+=e.toString(),i.length>H&&(i=i.slice(0,H),c=!0))});let u,d=setTimeout(()=>{process.platform===`win32`?e.kill():(e.kill(`SIGTERM`),u=setTimeout(e=>e.kill(`SIGKILL`),5e3,e))},f),p=!1;return e.on(`close`,(e,n)=>{if(!p)if(p=!0,clearTimeout(d),clearTimeout(u),e===0||e===1)r(null,t,i);else{let a=Error(`ripgrep exited with code ${e}`);a.code=e??void 0,a.signal=n??void 0,r(a,t,i)}}),e.on(`error`,e=>{p||(p=!0,clearTimeout(d),clearTimeout(u),r(e,t,i))}),e}return T(a,l,{maxBuffer:H,signal:n,timeout:f,killSignal:process.platform===`win32`?void 0:`SIGKILL`},r)}async function I(e,t,n){await z();let{rgPath:r,rgArgs:i,argv0:a}=N();return new Promise((o,s)=>{let c=E(r,[...i,...e,t],{argv0:a,signal:n,windowsHide:!0,stdio:[`ignore`,`pipe`,`ignore`]}),l=0;c.stdout?.on(`data`,e=>{l+=v(e,`
2
+ `)});let u=!1;c.on(`close`,e=>{u||(u=!0,e===0||e===1?o(l):s(Error(`rg --files exited ${e}`)))}),c.on(`error`,e=>{u||(u=!0,s(e))})})}async function L(e,t,n){return await z(),K().catch(e=>{f(e)}),new Promise((r,i)=>{let a=(o,c,l,u)=>{if(!o){r(c.trim().split(`
3
+ `).map(e=>e.replace(/\r$/,``)).filter(Boolean));return}if(o.code===1){r([]);return}if([`ENOENT`,`EACCES`,`EPERM`].includes(o.code)){i(o);return}if(!u&&P(l)){s(`rg EAGAIN error detected, retrying with single-threaded mode (-j 1)`),F(e,t,n,(e,t,n)=>{a(e,t,n,!0)},!0);return}let d=c&&c.trim().length>0,p=o.signal===`SIGTERM`||o.signal===`SIGKILL`||o.code===`ABORT_ERR`,m=o.code===`ERR_CHILD_PROCESS_STDIO_MAXBUFFER`,h=[];if(d&&(h=c.trim().split(`
4
+ `).map(e=>e.replace(/\r$/,``)).filter(Boolean),h.length>0&&(p||m)&&(h=h.slice(0,-1))),s(`rg error (signal=${o.signal}, code=${o.code}, stderr: ${l}), ${h.length} results`),o.code!==2&&o.code!==`ABORT_ERR`&&f(o),p&&h.length===0){i(new U(`Ripgrep search timed out after ${b()===`wsl`?60:20} seconds. The search may have matched files but did not complete in time. Try searching a more specific path or pattern.`,h));return}r(h)};F(e,t,n,(e,t,n)=>{a(e,t,n,!1)})})}function R(){let e=V();return{mode:e.mode,path:e.command,working:G?.working??null,note:G?.note??e.note}}async function z(){if(process.platform!==`darwin`||q)return;q=!0;let e=V();if(e.mode!==`builtin`)return;let t=e.command;if((await u(`codesign`,[`-vv`,`-d`,t],{preserveOutputOnError:!1})).stdout.split(`
5
+ `).find(e=>e.includes(`linker-signed`)))try{let e=await u(`codesign`,[`--sign`,`-`,`--force`,`--preserve-metadata=entitlements,requirements,flags,runtime`,t]);e.code!==0&&f(Error(`Failed to sign ripgrep: ${e.stdout} ${e.stderr}`));let n=await u(`xattr`,[`-d`,`com.apple.quarantine`,t]);n.code!==0&&f(Error(`Failed to remove quarantine: ${n.stdout} ${n.stderr}`))}catch(e){f(e)}}var B,V,H,U,W,G,K,q,J=e((()=>{n(),x(),h(),c(),j(),i(),l(),_(),d(),y(),g(),a(),B=A,V=t(()=>{if(r(process.env.USE_BUILTIN_RIPGREP)){let{cmd:e}=p(`rg`,[]);if(e!==`rg`)return{mode:`system`,command:`rg`,args:[]}}if(m())return{mode:`embedded`,command:process.execPath,args:[`--no-config`],argv0:`rg`};let e=C.resolve(B,`vendor`,`ripgrep`);return M(process.platform===`win32`?C.resolve(e,`${process.arch}-win32`,`rg.exe`):C.resolve(e,`${process.arch}-${process.platform}`,`rg`))}),H=2e7,U=class extends Error{constructor(e,t){super(e),o(this,`partialResults`,void 0),this.partialResults=t,this.name=`RipgrepTimeoutError`}},W=t(async(e,t,n=[])=>{if(C.resolve(e)!==C.resolve(S()))try{let r=[`--files`,`--hidden`];n.forEach(e=>{r.push(`--glob`,`!${e}`)});let i=await I(r,e,t);if(i===0)return 0;let a=10**Math.floor(Math.log10(i));return Math.round(i/a)*a}catch(e){e?.name!==`AbortError`&&f(e)}},(e,t,n=[])=>`${e}|${n.join(`,`)}`),G=null,K=t(async()=>{if(G!==null)return;let e=V();try{let t;if(e.argv0){let n=Bun.spawn([e.command,`--version`],{argv0:e.argv0,stderr:`ignore`,stdout:`pipe`}),[r,i]=await Promise.all([n.stdout.text(),n.exited]);t={code:i,stdout:r}}else t=await u(e.command,[...e.args,`--version`],{timeout:5e3});let n=t.code===0&&!!t.stdout&&t.stdout.startsWith(`ripgrep `);G={working:n,lastTested:Date.now(),config:e,note:e.note},s(`Ripgrep first use test: ${n?`PASSED`:`FAILED`} (mode=${e.mode}, path=${e.command})`),+(e.mode===`system`)}catch(t){G={working:!1,lastTested:Date.now(),config:e,note:e.note},f(t)}}),q=!1}));export{J as a,N as c,R as i,W as n,M as o,V as r,L as s,U as t};
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-XQrOux41.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-DMSzdFWt.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};