@readmagic/workmate 0.0.28 → 0.0.30

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 (305) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Bmgh8VS3.js → AddWorkspaceDirectory-B03NZZuQ.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-45Ize2zR.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-BJfHqScU.js → AgentsMdExternalIncludesDialog-CIyefOzT.js} +1 -1
  4. package/dist/chunks/App-WBysAL0_.js +1 -0
  5. package/dist/chunks/{BackgroundTasksDialog-WkoL4g5Q.js → BackgroundTasksDialog-CvvrjBoq.js} +2 -2
  6. package/dist/chunks/{BypassPermissionsModeDialog-BT9yl0Qt.js → BypassPermissionsModeDialog-DdVbMyla.js} +1 -1
  7. package/dist/chunks/{CustomSelect-t4wXuXWH.js → CustomSelect-iSG1rbWU.js} +1 -1
  8. package/dist/chunks/{DiffDialog-CXZxnb7Y.js → DiffDialog-DSb46fzB.js} +5 -5
  9. package/dist/chunks/Doctor--yF3SBsD.js +1 -0
  10. package/dist/chunks/Doctor-dR71Dg_D.js +3 -0
  11. package/dist/chunks/ExitFlow-BiBi5Sqk.js +2 -0
  12. package/dist/chunks/{InvalidConfigDialog-riLYEaUP.js → InvalidConfigDialog-7MkDSXXj.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-BGXl3V1A.js → InvalidSettingsDialog-D8Ves3Th.js} +1 -1
  14. package/dist/chunks/{KeybindingProviderSetup-syiDgtpB.js → KeybindingProviderSetup-DJSFdVYv.js} +1 -1
  15. package/dist/chunks/MCPConnectionManager-BZxRMdGO.js +1 -0
  16. package/dist/chunks/MCPToolListView-H_Kvvelz.js +1 -0
  17. package/dist/chunks/{McpParsingWarnings-Czze2JPd.js → McpParsingWarnings-D2xvaog9.js} +1 -1
  18. package/dist/chunks/MessageSelector-DQgIgPij.js +3 -0
  19. package/dist/chunks/Messages-DyQCr-od.js +10 -0
  20. package/dist/chunks/{Onboarding-CD_Uv5h9.js → Onboarding-DFufTPIY.js} +1 -1
  21. package/dist/chunks/{PromptInputFooterSuggestions-CHXJsTtQ.js → PromptInputFooterSuggestions-B9JRcHHE.js} +1 -1
  22. package/dist/chunks/{PromptInputHelpMenu-BZIVCV7V.js → PromptInputHelpMenu-DcGXK5lt.js} +1 -1
  23. package/dist/chunks/{ProviderSetup-CwMvjmjh.js → ProviderSetup-DJ_Z1BSe.js} +1 -1
  24. package/dist/chunks/QueryEngine-BQ5PSqKV.js +1 -0
  25. package/dist/chunks/{REPL-CtFtb35A.js → REPL-CjoJCy0g.js} +24 -24
  26. package/dist/chunks/REPL-DGieTVDl.js +1 -0
  27. package/dist/chunks/ResumeConversation-exTLviBY.js +1 -0
  28. package/dist/chunks/SearchExtraToolsTool-BBhWAuoA.js +1 -0
  29. package/dist/chunks/Settings-nM6-cXh0.js +2 -0
  30. package/dist/chunks/Spinner-ChT4lOOg.js +1 -0
  31. package/dist/chunks/{SpinnerGlyph-BR_SiV9L.js → SpinnerGlyph-4aVLQdJf.js} +1 -1
  32. package/dist/chunks/{TextInput-ou7ZhpVY.js → TextInput-CanSwT9J.js} +5 -5
  33. package/dist/chunks/{ThemePicker-CVFWqSc7.js → ThemePicker-CXzPiSy0.js} +1 -1
  34. package/dist/chunks/{TrustDialog-CGXv_LF4.js → TrustDialog-D0fJ-YIw.js} +1 -1
  35. package/dist/chunks/{ValidationErrorsList-CKeHoN2Z.js → ValidationErrorsList-29bQ0l-Q.js} +1 -1
  36. package/dist/chunks/{_baseEach-BYhqv77g.js → _baseEach-DPcnudh_.js} +1 -1
  37. package/dist/chunks/{add-dir-BSizpuef.js → add-dir-DbNz1SeY.js} +1 -1
  38. package/dist/chunks/{agentDisplay-JKfYFD1m.js → agentDisplay-Bif3eE1e.js} +1 -1
  39. package/dist/chunks/{agents-BDTCH6YB.js → agents-CbsNbPbp.js} +1 -1
  40. package/dist/chunks/{agents-MEaV8P2G.js → agents-yvC-VikU.js} +6 -6
  41. package/dist/chunks/allErrors-Bv1e8fra.js +1 -0
  42. package/dist/chunks/{appleTerminalBackup-CN8kS74J.js → appleTerminalBackup-Ct9hf1QQ.js} +1 -1
  43. package/dist/chunks/{backgroundHousekeeping-CsXlkIg3.js → backgroundHousekeeping-C75FgxW1.js} +1 -1
  44. package/dist/chunks/backgroundHousekeeping-d0qpqWHe.js +1 -0
  45. package/dist/chunks/banner-D5m9LUjl.js +2 -0
  46. package/dist/chunks/{branch-BllXcYwS.js → branch-DOQ3yNds.js} +2 -2
  47. package/dist/chunks/bridgeControl-DMUu37uO.js +2 -0
  48. package/dist/chunks/{btw-DzaRBa6o.js → btw-DUjuwyMH.js} +1 -1
  49. package/dist/chunks/{bundledMode-D9omqD3L.js → bundledMode-Dqe4pz0a.js} +1 -1
  50. package/dist/chunks/caches-BKAPMXp9.js +1 -0
  51. package/dist/chunks/caches-he4NeZSK.js +1 -0
  52. package/dist/chunks/channel-C8JmEI06.js +2 -0
  53. package/dist/chunks/{channel-Gw6skpUh.js → channel-TEYwDITo.js} +1 -1
  54. package/dist/chunks/{clear-CDQs9_5P.js → clear-BFlTcvMt.js} +1 -1
  55. package/dist/chunks/{client-pA7fKk0-.js → client-D3QmHVeI.js} +1 -1
  56. package/dist/chunks/client-dTKhXxBT.js +1 -0
  57. package/dist/chunks/{client-2w-g5kMx.js → client-q_uGYC2E.js} +1 -1
  58. package/dist/chunks/client-y_U1O4mI.js +1 -0
  59. package/dist/chunks/commands-BoGtXPAA.js +1 -0
  60. package/dist/chunks/compact-CyR7Sbo1.js +2 -0
  61. package/dist/chunks/config-B-hDBSL8.js +1 -0
  62. package/dist/chunks/config-Bjwat4P6.js +3 -0
  63. package/dist/chunks/config-DubkVeOw.js +1 -0
  64. package/dist/chunks/{context-TkdzCK3Y.js → context-Cm_gyngQ.js} +1 -1
  65. package/dist/chunks/{context-noninteractive-BcBo64vo.js → context-noninteractive-BDmFfPRt.js} +2 -2
  66. package/dist/chunks/context-noninteractive-CmOFpwwP.js +1 -0
  67. package/dist/chunks/conversation-B7YCvyCD.js +1 -0
  68. package/dist/chunks/conversation-CYZKYlWc.js +1 -0
  69. package/dist/chunks/{conversationRecovery-_hWC7JBO.js → conversationRecovery-BUqpxLl-.js} +1 -1
  70. package/dist/chunks/crossProjectResume-BCa2l0KZ.js +40 -0
  71. package/dist/chunks/{debug-2pVES-2G.js → debug-NBJH_NxR.js} +2 -2
  72. package/dist/chunks/{detectRepository--luIRv5H.js → detectRepository-Bu0he_XM.js} +1 -1
  73. package/dist/chunks/{diff-BzVUPO4Z.js → diff-BEvpLh_b.js} +1 -1
  74. package/dist/chunks/{directoryCompletion-BC0qRmrz.js → directoryCompletion-CwKPuwrS.js} +1 -1
  75. package/dist/chunks/doctor-DYKr9Reu.js +1 -0
  76. package/dist/chunks/{entry-333L52Lo.js → entry-JGyBs1p5.js} +3 -3
  77. package/dist/chunks/{execFileNoThrow-DXSEj8ZO.js → execFileNoThrow-7Ys9mO27.js} +1 -1
  78. package/dist/chunks/exit-DU2KGyDk.js +1 -0
  79. package/dist/chunks/{extraUsage-CmgRR-zH.js → extraUsage-cZx2XLx4.js} +1 -1
  80. package/dist/chunks/extractMemories-4wbv-mTc.js +1 -0
  81. package/dist/chunks/fast-BALHWqpd.js +1 -0
  82. package/dist/chunks/{fast-D7oNjaZ3.js → fast-DUJq6-QE.js} +1 -1
  83. package/dist/chunks/{fetchModelList-Cv1vWIpC.js → fetchModelList-Dn8OahtV.js} +1 -1
  84. package/dist/chunks/fetchModelList-OZ2sLDEx.js +1 -0
  85. package/dist/chunks/{fileSuggestions-DF3HTRKr.js → fileSuggestions-XLnnVLwx.js} +3 -3
  86. package/dist/chunks/{gemini-ou7_YyXc.js → gemini-qzPNGqOX.js} +2 -2
  87. package/dist/chunks/{generateSessionName-CeN9EZNY.js → generateSessionName-CA-cc58H.js} +1 -1
  88. package/dist/chunks/{genericProcessUtils-GqURdVAv.js → genericProcessUtils-XwqvFxyn.js} +1 -1
  89. package/dist/chunks/{goal-CCxo4Wyf.js → goal-x9Pkx5nv.js} +3 -3
  90. package/dist/chunks/{grok-BMmUcNbI.js → grok-36CpLjsq.js} +1 -1
  91. package/dist/chunks/{help-CYtogTZk.js → help-DwfAEV0X.js} +1 -1
  92. package/dist/chunks/{history-CUrqO9rV.js → history-PZLMYab7.js} +1 -1
  93. package/dist/chunks/hooks-BofA8GeO.js +1 -0
  94. package/dist/chunks/{hooks-ByVkvodY.js → hooks-DBmA-DWx.js} +2 -2
  95. package/dist/chunks/{install-DIxyfdXG.js → install-DF4ep6nb.js} +1 -1
  96. package/dist/chunks/{instrumentation-BmHivmxs.js → instrumentation-BAbhrE3f.js} +3 -3
  97. package/dist/chunks/{job-D534P26R.js → job-CFWKIjNl.js} +1 -1
  98. package/dist/chunks/{keybindings-CxgQqQJe.js → keybindings-CkiE_uBG.js} +1 -1
  99. package/dist/chunks/{launchLocalMemory-CWXLb3KF.js → launchLocalMemory-Cf8l-1fz.js} +2 -2
  100. package/dist/chunks/{launchOnboarding-CocPmwzz.js → launchOnboarding-8CDef-v1.js} +1 -1
  101. package/dist/chunks/loadAgentsDir-C-qRJlXH.js +1 -0
  102. package/dist/chunks/{loadAgentsDir-bmpKLPdG.js → loadAgentsDir-DnHL_5cU.js} +358 -358
  103. package/dist/chunks/loadPluginHooks-BuunKr9m.js +1 -0
  104. package/dist/chunks/{loader-BMAtuwRa.js → loader-DsEdsMHv.js} +1 -1
  105. package/dist/chunks/localSearch-BulDBrBk.js +1 -0
  106. package/dist/chunks/{localSearch-Da8cVYoI.js → localSearch-LFCzV7VE.js} +1 -1
  107. package/dist/chunks/{log-L1kqxa_P.js → log-D98mO6yJ.js} +1 -1
  108. package/dist/chunks/{logoUtils-qNuBc2nI.js → logoUtils-B8MIA7c5.js} +1 -1
  109. package/dist/chunks/{magicDocs-BsEiBLQl.js → magicDocs-BoxJusTI.js} +2 -2
  110. package/dist/chunks/{main-B31aPMPP.js → main-B9ciFYnO.js} +22 -22
  111. package/dist/chunks/{managedEnv-EZ2IirNa.js → managedEnv-B0mj-wgE.js} +1 -1
  112. package/dist/chunks/managedEnv-BFpXdDI8.js +1 -0
  113. package/dist/chunks/mcp-B3Ewo-_h.js +1 -0
  114. package/dist/chunks/mcp-CHlAZvpV.js +2 -0
  115. package/dist/chunks/{mcp-Dd8TBfQQ.js → mcp-DVKuOqvY.js} +3 -3
  116. package/dist/chunks/memory-Cr0d-s7U.js +1 -0
  117. package/dist/chunks/{mode-SM8doWgC.js → mode-DBNBDbVP.js} +2 -2
  118. package/dist/chunks/model-B2r1Ms0g.js +1 -0
  119. package/dist/chunks/model-C9ANf1-R.js +1 -0
  120. package/dist/chunks/{modelOptions-BQL4gbNk.js → modelOptions-B4BWYms0.js} +1 -1
  121. package/dist/chunks/{nativeInstaller-DMkZdsof.js → nativeInstaller-BDJxBAPV.js} +1 -1
  122. package/dist/chunks/{notifications-BwS1XsnZ.js → notifications-BV-VeXyJ.js} +1 -1
  123. package/dist/chunks/{onChangeAppState-C9cYQJPF.js → onChangeAppState-BGWWkhBg.js} +1 -1
  124. package/dist/chunks/openai-BL_IWBTr.js +2 -0
  125. package/dist/chunks/{overlayContext-C5WPACKC.js → overlayContext-DGUFuee9.js} +1 -1
  126. package/dist/chunks/{parser-CTnaXFVJ.js → parser-D2kggQDp.js} +1 -1
  127. package/dist/chunks/parser-DZUcp40d.js +1 -0
  128. package/dist/chunks/{partition-CKgWl7p4.js → partition-B2VCm4vu.js} +1 -1
  129. package/dist/chunks/{pasteStore-njJCBMKr.js → pasteStore-2RafnH7M.js} +1 -1
  130. package/dist/chunks/permissions-Bkj1UB1h.js +3 -0
  131. package/dist/chunks/{pidLock-CqkC3-nD.js → pidLock-CawSx6hb.js} +2 -2
  132. package/dist/chunks/{plan-Ce6wfjjI.js → plan-D7Ki5ADu.js} +1 -1
  133. package/dist/chunks/plugin-D7I6VZjh.js +17 -0
  134. package/dist/chunks/{pluginAutoupdate-ByokIVEs.js → pluginAutoupdate-Cr3jw-ky.js} +1 -1
  135. package/dist/chunks/pluginBlocklist-JG_kJSSK.js +1 -0
  136. package/dist/chunks/pluginCliCommands-BWIBBFJf.js +1 -0
  137. package/dist/chunks/{pluginFlagging-B2ZX5_oB.js → pluginFlagging-yFcXMVin.js} +1 -1
  138. package/dist/chunks/pluginOperations-6QXjdPOb.js +2 -0
  139. package/dist/chunks/pluginStartupCheck-B-nYb61N.js +1 -0
  140. package/dist/chunks/{pluginStartupCheck-QG0d95dE.js → pluginStartupCheck-CkjyJ4RS.js} +1 -1
  141. package/dist/chunks/plugins-CMDfjFp-.js +4 -0
  142. package/dist/chunks/{poorMode-CG2JNTD0.js → poorMode-BvypUTur.js} +1 -1
  143. package/dist/chunks/poorMode-CP6359Sz.js +1 -0
  144. package/dist/chunks/print-B6x_8O9w.js +13 -0
  145. package/dist/chunks/process-CewWh77C.js +1 -0
  146. package/dist/chunks/process-De2crvt4.js +1 -0
  147. package/dist/chunks/processBashCommand-D0BBcBHY.js +1 -0
  148. package/dist/chunks/processSlashCommand-BvjNuNyP.js +5 -0
  149. package/dist/chunks/{projectOnboardingState-D-_ijZnG.js → projectOnboardingState-ofkjp9FJ.js} +1 -1
  150. package/dist/chunks/prompt-Cpu4meqR.js +1 -0
  151. package/dist/chunks/{prompt-BnDapYGL.js → prompt-DDlkyIzV.js} +3 -3
  152. package/dist/chunks/prompt-HO8Docca.js +1 -0
  153. package/dist/chunks/{promptEditor-14TB3MYt.js → promptEditor-CyMqa_av.js} +1 -1
  154. package/dist/chunks/{protocolHandler-CJO3CRYW.js → protocolHandler-Bjmx7OmF.js} +1 -1
  155. package/dist/chunks/{proxy--_NfbJhm.js → proxy-MzIsnPd7.js} +1 -1
  156. package/dist/chunks/{reconciler-C_HKsocm.js → reconciler-CHbint0C.js} +1 -1
  157. package/dist/chunks/refresh-yut9uEfd.js +1 -0
  158. package/dist/chunks/{reject-Tug1RmkE.js → reject-CrNfit3M.js} +1 -1
  159. package/dist/chunks/{reload-plugins-CL9LWzpq.js → reload-plugins-labKy5Eh.js} +1 -1
  160. package/dist/chunks/rename-c8tElppw.js +1 -0
  161. package/dist/chunks/{renderOptions-B0RFpjRI.js → renderOptions-B3DyIbF6.js} +1 -1
  162. package/dist/chunks/{resume-BZ42SpS2.js → resume-C8xif2lo.js} +2 -2
  163. package/dist/chunks/ripgrep-CIIzTaSI.js +1 -0
  164. package/dist/chunks/{ripgrep-67m14ImZ.js → ripgrep-CnK9qx1e.js} +1 -1
  165. package/dist/chunks/{runtimeObserver-DT5P2_XL.js → runtimeObserver-DuJ8mRfr.js} +4 -4
  166. package/dist/chunks/{runtimeObserver-BLq2guVy.js → runtimeObserver-vmPplAGH.js} +1 -1
  167. package/dist/chunks/sandbox-adapter-BKnsdtVj.js +1 -0
  168. package/dist/chunks/{sandbox-toggle-DghmaJhK.js → sandbox-toggle-USHaZHD7.js} +1 -1
  169. package/dist/chunks/searchExtraTools-DV5iZPdw.js +1 -0
  170. package/dist/chunks/{select-CaxQ-BVq.js → select-BpiKdirZ.js} +1 -1
  171. package/dist/chunks/sessionFileAccessHooks-nq8C34WL.js +1 -0
  172. package/dist/chunks/sessionObserver-CKp3uqPg.js +1 -0
  173. package/dist/chunks/{sessionObserver-DBoZUvWL.js → sessionObserver-sO6PF7mV.js} +1 -1
  174. package/dist/chunks/sessionStorage-CuQf4d1y.js +1 -0
  175. package/dist/chunks/{sessionTracing-5a7HDF4e.js → sessionTracing-Bz89tYh5.js} +1 -1
  176. package/dist/chunks/settings-B3WqnPDo.js +1 -0
  177. package/dist/chunks/{settings-D4M13toi.js → settings-CA-5Px85.js} +2 -2
  178. package/dist/chunks/setup-B-FejaeH.js +3 -0
  179. package/dist/chunks/{shadowedRuleDetection-L3tnySui.js → shadowedRuleDetection-BI6Xz0pY.js} +1 -1
  180. package/dist/chunks/{sideQuestion-BJTVma-5.js → sideQuestion-BEpCuv_7.js} +3 -3
  181. package/dist/chunks/{sinks-CV0SWuZW.js → sinks-BvOPODnl.js} +1 -1
  182. package/dist/chunks/sinks-DLALCllz.js +1 -0
  183. package/dist/chunks/skillChangeDetector-D-fxaAMH.js +1 -0
  184. package/dist/chunks/{skillGapStore-Cposc03e.js → skillGapStore-A1FCr8Mf.js} +2 -2
  185. package/dist/chunks/{skillLifecycle-RXQp0JU7.js → skillLifecycle-CTVa34xO.js} +2 -2
  186. package/dist/chunks/{skillSearchPanel-B2pjskqk.js → skillSearchPanel-CjekGkrw.js} +4 -4
  187. package/dist/chunks/{skills-D2ZjMtv4.js → skills-110JHHbj.js} +1 -1
  188. package/dist/chunks/{sleep-xKMbXTJe.js → sleep-BGewNhNx.js} +1 -1
  189. package/dist/chunks/{startupProfiler-B9Qv2QGH.js → startupProfiler-C_xcIvEA.js} +1 -1
  190. package/dist/chunks/startupProfiler-uueg2S43.js +1 -0
  191. package/dist/chunks/status-D_b3UMke.js +1 -0
  192. package/dist/chunks/statusNoticeHelpers-C5BRU3lw.js +1 -0
  193. package/dist/chunks/{stringUtils-Cs6E5f-B.js → stringUtils-CtJhTszO.js} +1 -1
  194. package/dist/chunks/switcher-BFzvv7KT.js +1 -0
  195. package/dist/chunks/{switcher-rep86o4_.js → switcher-nLHGsxLw.js} +1 -1
  196. package/dist/chunks/{tasks-B4coTfrq.js → tasks-CjYr59Ak.js} +1 -1
  197. package/dist/chunks/{templateJobs-C5ukh6H3.js → templateJobs-ECX0rRRp.js} +1 -1
  198. package/dist/chunks/{terminalSetup-CaGbEVjB.js → terminalSetup-AptBNs_i.js} +1 -1
  199. package/dist/chunks/{terminalSetup-xe_P98fY.js → terminalSetup-CKO6eWhS.js} +1 -1
  200. package/dist/chunks/{theme-7RmvErYJ.js → theme-BCSx9irC.js} +1 -1
  201. package/dist/chunks/tipRegistry-CnQB3TaA.js +2 -0
  202. package/dist/chunks/{toolEventObserver-Dzwzi5Vi.js → toolEventObserver-Bqtypnkk.js} +1 -1
  203. package/dist/chunks/toolPool-B1sXN7SK.js +1 -0
  204. package/dist/chunks/{udsClient-CWeoNrm3.js → udsClient-COYqIvvr.js} +1 -1
  205. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-BT0nexZw.js → useExitOnCtrlCDWithKeybindings-DegJrysj.js} +1 -1
  206. package/dist/chunks/useMainLoopModel-CPnigpM1.js +1 -0
  207. package/dist/chunks/useManagePlugins-BW2Zj_jf.js +1 -0
  208. package/dist/chunks/useMergedTools-CTm1AU9b.js +1 -0
  209. package/dist/chunks/{useSearchInput-j12K4wEo.js → useSearchInput-DrY4BZKy.js} +1 -1
  210. package/dist/chunks/useSettingsErrors-2uIAF6H8.js +1 -0
  211. package/dist/chunks/{util-CCEK8oze.js → util-BUgUtaUV.js} +1 -1
  212. package/dist/chunks/validatePlugin-BGB8T9Mb.js +1 -0
  213. package/dist/chunks/{vim-BlO9V5_5.js → vim-DdxGarvY.js} +1 -1
  214. package/dist/chunks/worktree-DBZ7f9Lk.js +1 -0
  215. package/dist/cli.js +1 -1
  216. package/package.json +1 -1
  217. package/dist/chunks/AgentsMdExternalIncludesDialog-BjbUilCE.js +0 -1
  218. package/dist/chunks/App-COdpsR2w.js +0 -1
  219. package/dist/chunks/Doctor-B6isid5K.js +0 -1
  220. package/dist/chunks/Doctor-COj-tZBc.js +0 -3
  221. package/dist/chunks/ExitFlow-CcMYH5iI.js +0 -2
  222. package/dist/chunks/MCPConnectionManager-C7RmKzJh.js +0 -1
  223. package/dist/chunks/MCPToolListView-CewNLJus.js +0 -1
  224. package/dist/chunks/MessageSelector-Kc6JlnDX.js +0 -3
  225. package/dist/chunks/Messages-BvFYO4Zn.js +0 -10
  226. package/dist/chunks/QueryEngine-DAwfp_ht.js +0 -1
  227. package/dist/chunks/REPL-tFT1FGQF.js +0 -1
  228. package/dist/chunks/ResumeConversation-CERzSBvg.js +0 -1
  229. package/dist/chunks/SearchExtraToolsTool-ndh4aEwQ.js +0 -1
  230. package/dist/chunks/Settings-CPaqWNdP.js +0 -2
  231. package/dist/chunks/Spinner-C0qHjfIY.js +0 -1
  232. package/dist/chunks/allErrors-Dhnf6rqg.js +0 -1
  233. package/dist/chunks/backgroundHousekeeping-Bu-zRFCx.js +0 -1
  234. package/dist/chunks/banner-BKOzHotb.js +0 -2
  235. package/dist/chunks/bridgeControl-aDnUrYZR.js +0 -2
  236. package/dist/chunks/caches-CMF-MmR-.js +0 -1
  237. package/dist/chunks/caches-CW5YnYNS.js +0 -1
  238. package/dist/chunks/channel-DVx21qde.js +0 -1
  239. package/dist/chunks/client-B0ngS4Uu.js +0 -1
  240. package/dist/chunks/client-BP4DOH3K.js +0 -1
  241. package/dist/chunks/commands-CfYMwgP7.js +0 -1
  242. package/dist/chunks/compact-6F2tuItE.js +0 -2
  243. package/dist/chunks/config-BDkzWBnL.js +0 -1
  244. package/dist/chunks/config-Bio2EjUK.js +0 -3
  245. package/dist/chunks/config-C_AEhZrn.js +0 -1
  246. package/dist/chunks/context-noninteractive-oFcnY1Er.js +0 -1
  247. package/dist/chunks/conversation-CYZyg1U1.js +0 -1
  248. package/dist/chunks/conversation-DXzlRhNw.js +0 -1
  249. package/dist/chunks/crossProjectResume-CCo3iZrB.js +0 -40
  250. package/dist/chunks/doctor-B4jQbGQr.js +0 -1
  251. package/dist/chunks/exit-D5DYnRvR.js +0 -1
  252. package/dist/chunks/extractMemories-CVUrBFMj.js +0 -1
  253. package/dist/chunks/fast-CRhW9zha.js +0 -1
  254. package/dist/chunks/fetchModelList-DIa1HwAJ.js +0 -1
  255. package/dist/chunks/hooks-CBGUcyCs.js +0 -1
  256. package/dist/chunks/loadAgentsDir-Zw648oQO.js +0 -1
  257. package/dist/chunks/loadPluginHooks-BIfM53-_.js +0 -1
  258. package/dist/chunks/localSearch-Dbj8cXyO.js +0 -1
  259. package/dist/chunks/managedEnv-DCGLDTP_.js +0 -1
  260. package/dist/chunks/mcp-BMeWtYCx.js +0 -2
  261. package/dist/chunks/mcp-CYbesbfl.js +0 -1
  262. package/dist/chunks/memory-DtQQGyPS.js +0 -1
  263. package/dist/chunks/model-C2r-PaR4.js +0 -1
  264. package/dist/chunks/model-Dd3x121y.js +0 -1
  265. package/dist/chunks/openai-Bea4I2Od.js +0 -2
  266. package/dist/chunks/parser-Diihup2V.js +0 -1
  267. package/dist/chunks/permissions-Dv_PCfY0.js +0 -3
  268. package/dist/chunks/plugin-aK4tDrVg.js +0 -17
  269. package/dist/chunks/pluginBlocklist-ByRQaVPu.js +0 -1
  270. package/dist/chunks/pluginCliCommands-Dyk4HYHs.js +0 -1
  271. package/dist/chunks/pluginOperations-BCvJvfOC.js +0 -2
  272. package/dist/chunks/pluginStartupCheck-o_TC7wIt.js +0 -1
  273. package/dist/chunks/plugins-DzsTDNWJ.js +0 -4
  274. package/dist/chunks/poorMode-eMIFCAC_.js +0 -1
  275. package/dist/chunks/print-dUT7E1g9.js +0 -13
  276. package/dist/chunks/process-CNfq37LF.js +0 -1
  277. package/dist/chunks/process-gEbdy6uY.js +0 -1
  278. package/dist/chunks/processBashCommand-DtGCgTkF.js +0 -1
  279. package/dist/chunks/processSlashCommand-wXblpK2C.js +0 -5
  280. package/dist/chunks/prompt-BdH2zk0S.js +0 -1
  281. package/dist/chunks/prompt-D0TFER0A.js +0 -1
  282. package/dist/chunks/refresh-Cm4jZzLa.js +0 -1
  283. package/dist/chunks/rename-OfKJSazJ.js +0 -1
  284. package/dist/chunks/ripgrep-DB7KB8RZ.js +0 -1
  285. package/dist/chunks/sandbox-adapter-982rx2cm.js +0 -1
  286. package/dist/chunks/searchExtraTools-B4N1bpy0.js +0 -1
  287. package/dist/chunks/sessionFileAccessHooks-BqQ58T7e.js +0 -1
  288. package/dist/chunks/sessionObserver-qYpA90El.js +0 -1
  289. package/dist/chunks/sessionStorage-CC0v4zMs.js +0 -1
  290. package/dist/chunks/settings-Dfit5gGT.js +0 -1
  291. package/dist/chunks/setup-DVLnIlse.js +0 -3
  292. package/dist/chunks/sinks-C9NdbjLo.js +0 -1
  293. package/dist/chunks/skillChangeDetector-DlodgOyC.js +0 -1
  294. package/dist/chunks/startupProfiler-DWcM4QBl.js +0 -1
  295. package/dist/chunks/status-BcSkj9nE.js +0 -1
  296. package/dist/chunks/statusNoticeHelpers-DsrqBOQt.js +0 -1
  297. package/dist/chunks/switcher-BietN6il.js +0 -1
  298. package/dist/chunks/tipRegistry-BYpJZIjR.js +0 -2
  299. package/dist/chunks/toolPool-BGfiNj6h.js +0 -1
  300. package/dist/chunks/useMainLoopModel-QuE7VkgX.js +0 -1
  301. package/dist/chunks/useManagePlugins-pGaGzsEg.js +0 -1
  302. package/dist/chunks/useMergedTools-BLsIT3R_.js +0 -1
  303. package/dist/chunks/useSettingsErrors-C8VIzdws.js +0 -1
  304. package/dist/chunks/validatePlugin-CTVnWx9H.js +0 -1
  305. package/dist/chunks/worktree-BWL0vR4o.js +0 -1
@@ -1,17 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{D as o,Gr as s,Gt as c,H as l,I as u,P as d,T as f,Wt as p,Xn as m,ai as h,hn as g,j as _,k as v,n as y,ot as b,r as x,t as S,x as C,y as ee}from"./src-BX54x08P.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as T,Qn as te,d as ne,gt as E,m as D,s as O,y as k,yt as re}from"./settings-D4M13toi.js";import{$a as ie,$d as A,$m as j,Ao as ae,Ax as M,Ba as N,Bh as oe,Co as se,Cx as P,Do as ce,Eo as le,Fa as ue,Ga as F,Hh as I,Ka as de,Mo as fe,Mx as pe,No as me,Nx as he,Oo as ge,Pa as L,Qa as R,Qm as _e,So as ve,To as ye,Tx as be,Va as xe,Xd as Se,Xm as Ce,Ya as we,Ym as z,Zm as Te,_f as Ee,bu as De,do as B,eh as Oe,gf as ke,go as Ae,hd as je,io as Me,kx as Ne,lx as Pe,md as V,mo as Fe,nh as Ie,ox as Le,rh as Re,sb as ze,so as Be,tb as Ve,th as He,to as Ue,uo as We,ux as Ge,vo as Ke,wo as qe,yo as Je,yu as Ye,yx as Xe,zh as Ze}from"./loadAgentsDir-bmpKLPdG.js";import{I as Qe,M as $e,S as et,V as tt,c as nt,i as rt,x as it}from"./debug-2pVES-2G.js";import{d as at,g as ot}from"./config-Bio2EjUK.js";import{o as st,s as ct}from"./log-L1kqxa_P.js";import{n as lt}from"./analytics-COpjZpvd.js";import{S as ut,v as dt}from"./startupProfiler-B9Qv2QGH.js";import{l as H,o as ft}from"./stringUtils-Cs6E5f-B.js";import{n as pt,t as mt}from"./pluginStartupCheck-QG0d95dE.js";import{a as ht,d as gt,f as _t,i as vt,l as yt,o as bt,s as xt,u as St}from"./pluginOperations-BCvJvfOC.js";import{a as Ct,c as wt,i as Tt,n as Et,o as Dt,s as Ot,t as kt}from"./validatePlugin-CTVnWx9H.js";import{a as At,n as jt,o as Mt,r as Nt}from"./pluginFlagging-B2ZX5_oB.js";import{i as Pt,n as Ft}from"./MCPConnectionManager-C7RmKzJh.js";import{n as It,t as Lt}from"./useExitOnCtrlCDWithKeybindings-BT0nexZw.js";import{n as Rt,t as zt}from"./TextInput-ou7ZhpVY.js";import{r as Bt,t as Vt}from"./Spinner-C0qHjfIY.js";import{t as Ht}from"./SearchBox-zA5QwIpO.js";import{n as Ut,t as Wt}from"./useSearchInput-j12K4wEo.js";import{a as Gt,c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./MCPToolListView-CewNLJus.js";import{i as $t,n as en}from"./pluginAutoupdate-ByokIVEs.js";import*as tn from"path";import*as nn from"fs/promises";function rn({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:s,setResult:c,setViewState:l,onAddComplete:p,cliMode:m=!1}){let h=(0,an.useRef)(!1),[g,_]=(0,an.useState)(!1),[v,y]=(0,an.useState)(``),b=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ct(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{_(!0),y(``);let{name:e,resolvedSource:t}=await Me(n,e=>{y(e)});Ke(e,{source:t}),fe(),n.source,n.source===`github`&&n.repo,p&&await p(),y(``),_(!1),m?c(`Successfully added marketplace: ${e}`):l({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=tt(e);ct(t),a(t.message),y(``),_(!1),c(m?`Error: ${t.message}`:null)}};return(0,an.useEffect)(()=>{e&&!h.current&&!i&&!s&&(h.current=!0,b())},[]),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsxs)(u,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(u,{marginBottom:1,children:(0,U.jsx)(d,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsx)(d,{children:`Enter marketplace source:`}),(0,U.jsx)(d,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(d,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(d,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(d,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(d,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(zt,{value:e,onChange:t,onSubmit:b,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),g&&(0,U.jsxs)(u,{marginTop:1,children:[(0,U.jsx)(Vt,{}),(0,U.jsx)(d,{children:v||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{color:`error`,children:i})}),s&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{children:s})})]}),(0,U.jsx)(u,{marginLeft:3,children:(0,U.jsx)(d,{dimColor:!0,italic:!0,children:(0,U.jsxs)(f,{children:[(0,U.jsx)(o,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(V,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var an,U,on=e((()=>{an=t(h(),1),lt(),je(),S(),Bt(),Rt(),Qe(),st(),me(),We(),Tt(),U=w()}));function sn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function cn({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let l=Object.keys(n),f=(0,ln.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[m,h]=(0,ln.useState)(0),[_,v]=(0,ln.useState)({}),[y,b]=(0,ln.useState)(()=>l[0]?f(l[0]):``),x=l[m],S=x?n[x]:null;if(p(`confirm:no`,o,{context:`Settings`}),c({"confirm:nextField":(0,ln.useCallback)(()=>{if(m<l.length-1&&x){v(e=>({...e,[x]:y})),h(e=>e+1);let e=l[m+1];b(e?f(e):``)}},[m,l,x,y,f]),"confirm:yes":(0,ln.useCallback)(()=>{if(!x)return;let e={..._,[x]:y};if(m===l.length-1)i(sn(l,e,n,r));else{v(e),h(e=>e+1);let t=l[m+1];b(t?f(t):``)}},[x,_,y,m,l,n,i,f,r])},{context:`Confirmation`}),g((e,t)=>{if(t.backspace||t.delete){b(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&b(t=>t+e)}),!S||!x)return null;let C=S.sensitive===!0,w=S.required===!0,T=C?`*`.repeat(s(y)):y;return(0,un.jsxs)(ee,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{bold:!0,children:[S.title||x,w&&(0,un.jsx)(d,{color:`error`,children:` *`})]}),S.description&&(0,un.jsx)(d,{dimColor:!0,children:S.description}),(0,un.jsxs)(u,{marginTop:1,children:[(0,un.jsxs)(d,{children:[a.pointerSmall,` `]}),(0,un.jsx)(d,{children:T}),(0,un.jsx)(d,{children:`█`})]})]}),(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{dimColor:!0,children:[`Field `,m+1,` of `,l.length]}),m<l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),m===l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var ln,un,dn=e((()=>{i(),ln=t(h(),1),S(),Ve(),r(),un=w()}));async function fn(e){let{enabled:t,disabled:n}=await ue();return[...t,...n].find(t=>t.repository===e||t.source===e)}function pn({plugin:e,pluginId:t,onDone:n}){let[r]=mn.useState(()=>{let n=[],r=z(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>Te(t),save:n=>_e(t,n,e.manifest.userConfig)});let i=ke(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>He(t,r.server)??void 0,save:e=>Re(t,r.server,e,r.configSchema)});return n}),[i,a]=mn.useState(0),o=mn.useRef(n);if(o.current=n,mn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function c(e){try{s.save(e)}catch(e){n(`error`,$e(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,hn.jsx)(cn,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:c,onCancel:()=>n(`skipped`)},s.key)}var mn,hn,gn=e((()=>{mn=t(h(),1),Qe(),j(),Ee(),L(),Ce(),dn(),hn=w()}));function _n(){let e=ce();return(0,vn.jsxs)(u,{marginBottom:1,children:[(0,vn.jsxs)(d,{color:`claude`,children:[a.warning,` `]}),(0,vn.jsxs)(d,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var vn,yn=e((()=>{i(),S(),ge(),vn=w()}));function bn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function xn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Sn({hasSelection:e}){return(0,Cn.jsx)(u,{marginTop:1,children:(0,Cn.jsx)(d,{dimColor:!0,italic:!0,children:(0,Cn.jsxs)(f,{children:[e&&(0,Cn.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,Cn.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Cn.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Cn.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var Cn,wn=e((()=>{je(),S(),Cn=w()}));function Tn({totalItems:e,maxVisible:t=Dn,selectedIndex:n=0}){let r=e>t,i=(0,En.useRef)(0),a=(0,En.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,En.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,En.useCallback)(e=>o+e,[o]),u=(0,En.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,En.useCallback)(e=>{},[]),f=(0,En.useCallback)(()=>{},[]),p=(0,En.useCallback)(()=>{},[]),m=(0,En.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,En.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var En,Dn,On=e((()=>{En=t(h(),1),Dn=5}));function kn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:l}){let[m,h]=(0,W.useState)(`marketplace-list`),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)([]),[S,C]=(0,W.useState)([]),[ee,w]=(0,W.useState)(!0),[T,ne]=(0,W.useState)(null),[E,D]=(0,W.useState)(0),[O,k]=(0,W.useState)(new Set),[re,A]=(0,W.useState)(new Set),j=Tn({totalItems:S.length,selectedIndex:E}),[M,N]=(0,W.useState)(0),[oe,se]=(0,W.useState)(!1),[P,ce]=(0,W.useState)(null),[ue,F]=(0,W.useState)(null);p(`confirm:no`,An.useCallback(()=>{m===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):b.length===1?i({type:`menu`}):(h(`marketplace-list`),_(null),k(new Set)):m===`plugin-details`?(h(`plugin-list`),y(null)):i({type:`menu`})},[m,s,i,b.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=te(r.plugins,t=>ie(ve(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:le(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),x(i);let a=ye(r,te(n,e=>e.data!==null));if(a)if(a.type===`warning`)F(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!l){let e=i[0];e&&(_(e.name),h(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await Be(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=ve(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:R(e)},r=t;break}}}if(n&&r){let e=n.pluginId;R(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(_(r),y(n),h(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(_(s),h(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{w(!1)}}e()},[t,s,l]),(0,W.useEffect)(()=>{if(!g)return;let e=!1;async function n(n){w(!0);try{let t=await Be(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=ve(e.name,n);de(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:R(t)})}try{let t=await Ot();if(e)return;ne(t),t?r.sort((e,n)=>{let r=t.get(e.pluginId)??0,i=t.get(n.pluginId)??0;return r===i?e.entry.name.localeCompare(n.entry.name):i-r}):r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(t){if(e)return;nt(`Failed to fetch install counts: ${$e(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(r),D(0),k(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{w(!1)}}return n(g),()=>{e=!0}},[g,t]);let I=async()=>{if(O.size===0)return;let e=S.filter(e=>O.has(e.pluginId));A(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}A(new Set),k(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},pe=async(e,t=`user`)=>{se(!0),ce(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){se(!1),h({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else se(!1),ce(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),c({"select:previous":()=>{E>0&&D(E-1)},"select:next":()=>{E<b.length-1&&D(E+1)},"select:accept":()=>{let e=b[E];e&&(_(e.name),h(`plugin-list`))}},{context:`Select`,isActive:m===`marketplace-list`}),c({"select:previous":()=>{E>0&&j.handleSelectionChange(E-1,D)},"select:next":()=>{E<S.length-1&&j.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===S.length&&O.size>0)I();else if(E<S.length){let e=S[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(y(e),h(`plugin-details`),N(0),ce(null)))}}},{context:`Select`,isActive:m===`plugin-list`}),c({"plugin:toggle":()=>{if(E<S.length){let e=S[E];if(e&&!e.isInstalled){let t=new Set(O);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),k(t)}}},"plugin:install":()=>{O.size>0&&I()}},{context:`Plugin`,isActive:m===`plugin-list`});let me=An.useMemo(()=>{if(!v)return[];let e=v.entry.homepage;return xn(e,bn(v))},[v]);if(c({"select:previous":()=>{M>0&&N(M-1)},"select:next":()=>{M<me.length-1&&N(M+1)},"select:accept":()=>{if(!v)return;let e=me[M]?.action,t=v.entry.homepage,n=bn(v);e===`install-user`?pe(v,`user`):e===`install-project`?pe(v,`project`):e===`install-local`?pe(v,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(h(`plugin-list`),y(null))}},{context:`Select`,isActive:m===`plugin-details`&&!!v}),typeof m==`object`&&m.type===`plugin-options`){let{plugin:e,pluginId:t}=m;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,G.jsx)(d,{children:`Loading…`});if(e)return(0,G.jsx)(d,{color:`error`,children:e});if(m===`marketplace-list`)return b.length===0?(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(d,{children:`No marketplaces configured.`}),(0,G.jsxs)(d,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),ue&&(0,G.jsx)(u,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(d,{color:`warning`,children:[a.warning,` `,ue]})}),b.map((e,t)=>(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:+(t<b.length-1),children:[(0,G.jsx)(u,{children:(0,G.jsxs)(d,{color:E===t?`suggestion`:void 0,children:[E===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(u,{marginLeft:2,children:(0,G.jsxs)(d,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(m===`plugin-details`&&v){let e=v.entry.homepage,t=xn(e,bn(v));return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:v.entry.name}),v.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[`Version: `,v.entry.version]}),v.entry.description&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{children:v.entry.description})}),v.entry.author&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof v.entry.author==`string`?v.entry.author:v.entry.author.name]})})]}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:`Will install:`}),v.entry.commands&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(v.entry.commands)?v.entry.commands.join(`, `):Object.keys(v.entry.commands).join(`, `)]}),v.entry.agents&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(v.entry.agents)?v.entry.agents.join(`, `):Object.keys(v.entry.agents).join(`, `)]}),v.entry.hooks&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Hooks: `,Object.keys(v.entry.hooks).join(`, `)]}),v.entry.mcpServers&&(0,G.jsxs)(d,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(v.entry.mcpServers)?v.entry.mcpServers.join(`, `):typeof v.entry.mcpServers==`object`?Object.keys(v.entry.mcpServers).join(`, `):`configured`]}),!v.entry.commands&&!v.entry.agents&&!v.entry.hooks&&!v.entry.mcpServers&&(typeof v.entry.source==`object`&&`source`in v.entry.source&&(v.entry.source.source===`github`||v.entry.source.source===`url`||v.entry.source.source===`npm`||v.entry.source.source===`pip`)?(0,G.jsx)(d,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(d,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(_n,{}),P&&(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsxs)(d,{color:`error`,children:[`Error: `,P]})}),(0,G.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(u,{children:[M===t&&(0,G.jsx)(d,{children:`> `}),M!==t&&(0,G.jsx)(d,{children:` `}),(0,G.jsx)(d,{bold:M===t,children:oe&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(d,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(d,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(u,{marginLeft:3,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let he=j.getVisibleItems(S);return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install Plugins`})}),j.scrollPosition.canScrollUp&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),he.map((t,n)=>{let r=j.toActualIndex(n),i=E===r,o=O.has(t.pluginId),s=re.has(t.pluginId);return(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:n===he.length-1&&!e?0:1,children:[(0,G.jsxs)(u,{children:[(0,G.jsxs)(d,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(d,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(d,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(d,{dimColor:!0,children:` (installed)`}),T&&g===`claude-plugins-official`&&(0,G.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(u,{marginLeft:4,children:[(0,G.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),j.scrollPosition.canScrollDown&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Sn,{hasSelection:O.size>0})]})}var An,W,G,jn=e((()=>{i(),An=t(h(),1),W=t(h(),1),je(),S(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),G=w()}));function Mn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:l}){let[h,_]=(0,K.useState)(`plugin-list`),[y,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[ee,w]=(0,K.useState)(!0),[T,ne]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),O=(0,K.useCallback)(e=>{D(e),s?.(e)},[s]),{query:k,setQuery:re,cursorOffset:ie}=Ut({isActive:h===`plugin-list`&&E&&!ee,onExit:()=>{O(!1)}}),A=m(),{columns:j}=b(),M=(0,K.useMemo)(()=>{if(!k)return S;let e=k.toLowerCase();return S.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[S,k]),[N,oe]=(0,K.useState)(0),[P,ce]=(0,K.useState)(new Set),[le,ue]=(0,K.useState)(new Set),F=Tn({totalItems:M.length,selectedIndex:N});(0,K.useEffect)(()=>{oe(0)},[k]);let[I,pe]=(0,K.useState)(0),[me,he]=(0,K.useState)(!1),[ge,L]=(0,K.useState)(null),[_e,be]=(0,K.useState)(null),[Se,Ce]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=ve(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:R(t)})}let a=i.filter(e=>!e.isInstalled&&!de(e.pluginId));try{let e=await Ot();ne(e),e?a.sort((t,n)=>{let r=e.get(t.pluginId)??0,i=e.get(n.pluginId)??0;return r===i?t.entry.name.localeCompare(n.entry.name):i-r}):a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(e){nt(`Failed to fetch install counts: ${$e(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(a);let o=Object.keys(e).length;if(a.length===0){let e=await se({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});Ce(e)}let s=ye(r,te(n,e=>e.data!==null));if(s)if(s.type===`warning`)be(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(l){let e=i.find(e=>e.entry.name===l);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(x(e),_(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{w(!1)}}e()},[t,l]);let we=async()=>{if(P.size===0)return;let e=S.filter(e=>P.has(e.pluginId));ue(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ue(new Set),ce(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},z=async(e,t=`user`)=>{he(!0),L(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){he(!1),_({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else he(!1),L(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),p(`confirm:no`,()=>{_(`plugin-list`),x(null)},{context:`Confirmation`,isActive:h===`plugin-details`}),p(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:h===`plugin-list`&&!E}),g((e,t)=>{let n=!t.ctrl&&!t.meta;E||(e===`/`&&n?(O(!0),re(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(O(!0),re(e)))},{isActive:h===`plugin-list`&&!ee}),c({"select:previous":()=>{N===0?O(!0):F.handleSelectionChange(N-1,oe)},"select:next":()=>{N<M.length-1&&F.handleSelectionChange(N+1,oe)},"select:accept":()=>{if(N===M.length&&P.size>0)we();else if(N<M.length){let e=M[N];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(x(e),_(`plugin-details`),pe(0),L(null)))}}},{context:`Select`,isActive:h===`plugin-list`&&!E}),c({"plugin:toggle":()=>{if(N<M.length){let e=M[N];if(e&&!e.isInstalled){let t=new Set(P);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ce(t)}}},"plugin:install":()=>{P.size>0&&we()}},{context:`Plugin`,isActive:h===`plugin-list`&&!E});let Te=Fn.useMemo(()=>{if(!y)return[];let e=y.entry.homepage;return xn(e,bn(y))},[y]);if(c({"select:previous":()=>{I>0&&pe(I-1)},"select:next":()=>{I<Te.length-1&&pe(I+1)},"select:accept":()=>{if(!y)return;let e=Te[I]?.action,t=y.entry.homepage,n=bn(y);e===`install-user`?z(y,`user`):e===`install-project`?z(y,`project`):e===`install-local`?z(y,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(_(`plugin-list`),x(null))}},{context:`Select`,isActive:h===`plugin-details`&&!!y}),typeof h==`object`&&h.type===`plugin-options`){let{plugin:e,pluginId:t}=h;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,q.jsx)(d,{children:`Loading…`});if(e)return(0,q.jsx)(d,{color:`error`,children:e});if(h===`plugin-details`&&y){let e=y.entry.homepage,t=xn(e,bn(y));return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(d,{bold:!0,children:y.entry.name}),(0,q.jsxs)(d,{dimColor:!0,children:[`from `,y.marketplaceName]}),y.entry.version&&(0,q.jsxs)(d,{dimColor:!0,children:[`Version: `,y.entry.version]}),y.entry.description&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{children:y.entry.description})}),y.entry.author&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof y.entry.author==`string`?y.entry.author:y.entry.author.name]})})]}),(0,q.jsx)(_n,{}),ge&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`error`,children:[`Error: `,ge]})}),(0,q.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(u,{children:[I===t&&(0,q.jsx)(d,{children:`> `}),I!==t&&(0,q.jsx)(d,{children:` `}),(0,q.jsx)(d,{bold:I===t,children:me&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,children:(0,q.jsxs)(f,{children:[(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Pn,{reason:Se}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Ee=F.getVisibleItems(M);return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsxs)(u,{children:[(0,q.jsx)(d,{bold:!0,children:`Discover plugins`}),F.needsPagination&&(0,q.jsxs)(d,{dimColor:!0,children:[` `,`(`,F.scrollPosition.current,`/`,F.scrollPosition.total,`)`]})]}),(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(v,{query:k,isFocused:E,isTerminalFocused:A,width:j-4,cursorOffset:ie})}),_e&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`warning`,children:[a.warning,` `,_e]})}),M.length===0&&k&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`No plugins match "`,k,`"`]})}),F.scrollPosition.canScrollUp&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ee.map((t,n)=>{let r=F.toActualIndex(n),i=N===r,o=P.has(t.pluginId),s=le.has(t.pluginId);return(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:n===Ee.length-1&&!e?0:1,children:[(0,q.jsxs)(u,{children:[(0,q.jsxs)(d,{color:i&&!E?`suggestion`:void 0,children:[i&&!E?a.pointer:` `,` `]}),(0,q.jsxs)(d,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(d,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),T&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(u,{marginLeft:4,children:(0,q.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)})})]},`${F.startIndex}-${t.pluginId}`)}),F.scrollPosition.canScrollDown&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Nn,{hasSelection:P.size>0,canToggle:N<M.length&&!M[N]?.isInstalled})]})}function Nn({hasSelection:e,canToggle:t}){return(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:(0,q.jsxs)(f,{children:[e&&(0,q.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(d,{children:`type to search`}),t&&(0,q.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Pn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(d,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(d,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var Fn,K,q,In=e((()=>{i(),Fn=t(h(),1),K=t(h(),1),je(),Ht(),S(),Wt(),ze(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),q=w()}));function Ln({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:l}){let[m,h]=(0,zn.useState)([]),[_,v]=(0,zn.useState)(!0),[y,b]=(0,zn.useState)(0),[x,S]=(0,zn.useState)(!1),[C,ee]=(0,zn.useState)(null),[w,T]=(0,zn.useState)(null),[ne,E]=(0,zn.useState)(null),[D,ie]=(0,zn.useState)(`list`),[A,j]=(0,zn.useState)(null),[M,N]=(0,zn.useState)(0),oe=(0,zn.useRef)(!1);(0,zn.useEffect)(()=>{async function e(){try{let e=await B(),{enabled:r,disabled:i}=await ue(),a=[...r,...i],{marketplaces:o,failures:c}=await ae(e),u=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));u.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(u);let d=ye(c,te(o,e=>e.data!==null));if(d)if(d.type===`warning`)ee(d.message);else throw Error(d.message);if(s&&!oe.current&&!t){oe.current=!0;let e=u.findIndex(e=>e.name===s);if(e>=0){let t=u[e];if(l){b(e+1);let t=[...u];l===`update`?t[e].pendingUpdate=!0:l===`remove`&&(t[e].pendingRemove=!0),h(t),setTimeout(ce,100,t)}else t&&(b(e+1),j(t),ie(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),ee(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{v(!1)}}e()},[s,l,t]);let se=()=>m.some(e=>e.pendingUpdate||e.pendingRemove),P=()=>({updateCount:te(m,e=>e.pendingUpdate),removeCount:te(m,e=>e.pendingRemove)}),ce=async t=>{let i=t||m,s=D===`details`;S(!0),ee(null),T(null),E(null);try{let t=O(`userSettings`),n=0,c=0,l=new Set;for(let e of i){if(e.pendingRemove){if(e.installedPlugins&&e.installedPlugins.length>0){let n={...t?.enabledPlugins};for(let t of e.installedPlugins){let r=ve(t.name,e.name);n[r]=!1}k(`userSettings`,{enabledPlugins:n})}await Ae(e.name),c++,e.name,e.installedPlugins?.length;continue}e.pendingUpdate&&(await Fe(e.name,e=>{E(e)}),n++,l.add(e.name.toLowerCase()),e.name)}let u=0;l.size>0&&(u=(await $t(l)).length),fe(),o&&await o();let d=await B(),{enabled:f,disabled:p}=await ue(),m=[...f,...p],{marketplaces:g}=await ae(d),_=[];for(let{name:e,config:t,data:n}of g){let r=m.filter(t=>t.source.endsWith(`@${e}`));_.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}if(_.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(_),s&&A){let e=_.find(e=>e.name===A.name);e&&j(e)}let v=[];if(n>0){let e=u>0?` (${u} ${H(u,`plugin`)} bumped)`:``;v.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&v.push(`Removed ${c} ${H(c,`marketplace`)}`),v.length>0){let t=`${a.tick} ${v.join(`, `)}`;s?T(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=$e(e);ee(t),n&&n(t)}finally{S(!1),E(null)}},F=async()=>{if(!A)return;let e=m.map(e=>e.name===A.name?{...e,pendingRemove:!0}:e);h(e),await ce(e)},I=e=>{if(!e)return[];let t=[{label:`Browse plugins (${e.pluginCount??0})`,value:`browse`},{label:`Update marketplace`,secondaryLabel:e.lastUpdated?`(last updated ${new Date(e.lastUpdated).toLocaleDateString()})`:void 0,value:`update`}];return ot()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},de=async e=>{let t=!e.autoUpdate;try{await Je(e.name,t),h(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),j(e=>e&&{...e,autoUpdate:t})}catch(e){ee(e instanceof Error?e.message:`Failed to update setting`)}};if(p(`confirm:no`,()=>{ie(`list`),N(0)},{context:`Confirmation`,isActive:!x&&(D===`details`||D===`confirm-remove`)}),p(`confirm:no`,()=>{h(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),b(0)},{context:`Confirmation`,isActive:!x&&D===`list`&&se()}),p(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!x&&D===`list`&&!se()}),c({"select:previous":()=>b(e=>Math.max(0,e-1)),"select:next":()=>{let e=m.length+1;b(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=y-1;if(y===0)e({type:`add-marketplace`});else if(se())ce();else{let e=m[t];e&&(j(e),ie(`details`),N(0))}}},{context:`Select`,isActive:!x&&D===`list`}),g(e=>{let t=y-1;if((e===`u`||e===`U`)&&t>=0)h(e=>e.map((e,n)=>n===t?{...e,pendingUpdate:!e.pendingUpdate,pendingRemove:e.pendingUpdate?e.pendingRemove:!1}:e));else if((e===`r`||e===`R`)&&t>=0){let e=m[t];e&&(j(e),ie(`confirm-remove`))}},{isActive:!x&&D===`list`}),c({"select:previous":()=>N(e=>Math.max(0,e-1)),"select:next":()=>{let e=I(A);N(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!A)return;let t=I(A)[M];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:A.name});else if(t?.value===`update`){let e=m.map(e=>e.name===A.name?{...e,pendingUpdate:!0}:e);h(e),ce(e)}else t?.value===`toggle-auto-update`?de(A):t?.value===`remove`&&ie(`confirm-remove`)}},{context:`Select`,isActive:!x&&D===`details`}),g(e=>{e===`y`||e===`Y`?F():(e===`n`||e===`N`)&&(ie(`list`),j(null))},{isActive:!x&&D===`confirm-remove`}),_)return(0,J.jsx)(d,{children:`Loading marketplaces…`});if(m.length===0)return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(d,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(D===`confirm-remove`&&A){let e=A.installedPlugins?.length||0;return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsxs)(d,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(d,{italic:!0,children:A.name}),`?`]}),(0,J.jsxs)(u,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,marginLeft:2,children:A.installedPlugins.map(e=>(0,J.jsxs)(d,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[`Press `,(0,J.jsx)(d,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(d,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(D===`details`&&A){let e=A.pendingUpdate||x,t=I(A);return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{bold:!0,children:A.name}),(0,J.jsx)(d,{dimColor:!0,children:A.source}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[A.pluginCount||0,` available `,H(A.pluginCount||0,`plugin`)]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsxs)(u,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(d,{bold:!0,children:[`Installed plugins (`,A.installedPlugins.length,`):`]}),(0,J.jsx)(u,{flexDirection:`column`,marginLeft:1,children:A.installedPlugins.map(e=>(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(d,{children:a.bullet}),(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{children:e.name}),(0,J.jsx)(d,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(d,{color:`claude`,children:`Updating marketplace…`}),ne&&(0,J.jsx)(d,{dimColor:!0,children:ne})]}),!e&&w&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:w})}),!e&&C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),!e&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===M;return(0,J.jsxs)(u,{children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(d,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!ot()&&A.autoUpdate&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:pe,removeCount:me}=P();return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:y===0?`suggestion`:void 0,children:[y===0?a.pointer:` `,` +`]}),(0,J.jsx)(d,{bold:!0,color:y===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(u,{flexDirection:`column`,children:m.map((e,t)=>{let n=t+1===y,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(u,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(d,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(d,{dimColor:!0,children:e.source}),(0,J.jsxs)(d,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),se()&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(d,{children:[(0,J.jsx)(d,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(d,{dimColor:!0,children:`Enter to apply`})]}),pe>0&&(0,J.jsxs)(d,{children:[`• Update `,pe,` `,H(pe,`marketplace`)]}),me>0&&(0,J.jsxs)(d,{color:`warning`,children:[`• Remove `,me,` `,H(me,`marketplace`)]})]}),x&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:`Processing changes…`})}),C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),(0,J.jsx)(Rn,{exitState:i,hasPendingActions:se()})]})}function Rn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:(0,J.jsxs)(f,{children:[t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(o,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(o,{shortcut:`r`,action:`remove`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var zn,J,Bn=e((()=>{i(),zn=t(h(),1),lt(),je(),S(),Ve(),T(),at(),Qe(),me(),ge(),We(),en(),L(),E(),D(),ft(),J=w()}));function Vn(e){switch(e.type){case`path-not-found`:return`${e.component} path not found: ${e.path}`;case`git-auth-failed`:return`Git ${e.authType.toUpperCase()} authentication failed for ${e.gitUrl}`;case`git-timeout`:return`Git ${e.operation} timed out for ${e.gitUrl}`;case`network-error`:return`Network error accessing ${e.url}${e.details?`: ${e.details}`:``}`;case`manifest-parse-error`:return`Failed to parse manifest at ${e.manifestPath}: ${e.parseError}`;case`manifest-validation-error`:return`Invalid manifest at ${e.manifestPath}: ${e.validationErrors.join(`, `)}`;case`plugin-not-found`:return`Plugin "${e.pluginId}" not found in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return`Marketplace "${e.marketplace}" not found`;case`marketplace-load-failed`:return`Failed to load marketplace "${e.marketplace}": ${e.reason}`;case`mcp-config-invalid`:return`Invalid MCP server config for "${e.serverName}": ${e.validationError}`;case`mcp-server-suppressed-duplicate`:{let t=e.duplicateOf.startsWith(`plugin:`)?`server provided by plugin "${e.duplicateOf.split(`:`)[1]??`?`}"`:`already-configured "${e.duplicateOf}"`;return`MCP server "${e.serverName}" skipped — same command/URL as ${t}`}case`hook-load-failed`:return`Failed to load hooks from ${e.hookPath}: ${e.reason}`;case`component-load-failed`:return`Failed to load ${e.component} from ${e.path}: ${e.reason}`;case`mcpb-download-failed`:return`Failed to download MCPB from ${e.url}: ${e.reason}`;case`mcpb-extract-failed`:return`Failed to extract MCPB ${e.mcpbPath}: ${e.reason}`;case`mcpb-invalid-manifest`:return`MCPB manifest invalid at ${e.mcpbPath}: ${e.validationError}`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`Marketplace "${e.marketplace}" is blocked by enterprise policy`:`Marketplace "${e.marketplace}" is not in the allowed marketplace list`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Dependency "${e.dependency}" is disabled`:`Dependency "${e.dependency}" is not installed`;case`lsp-config-invalid`:return`Invalid LSP server config for "${e.serverName}": ${e.validationError}`;case`lsp-server-start-failed`:return`LSP server "${e.serverName}" failed to start: ${e.reason}`;case`lsp-server-crashed`:return e.signal?`LSP server "${e.serverName}" crashed with signal ${e.signal}`:`LSP server "${e.serverName}" crashed with exit code ${e.exitCode??`unknown`}`;case`lsp-request-timeout`:return`LSP server "${e.serverName}" timed out on ${e.method} after ${e.timeoutMs}ms`;case`lsp-request-failed`:return`LSP server "${e.serverName}" ${e.method} failed: ${e.error}`;case`plugin-cache-miss`:return`Plugin "${e.plugin}" not cached at ${e.installPath}`;case`generic-error`:return e.error}return pe(e)}function Hn(e){switch(e.type){case`path-not-found`:return`Check that the path in your manifest or marketplace config is correct`;case`git-auth-failed`:return e.authType===`ssh`?`Configure SSH keys or use HTTPS URL instead`:`Configure credentials or use SSH URL instead`;case`git-timeout`:case`network-error`:return`Check your internet connection and try again`;case`manifest-parse-error`:return`Check manifest file syntax in the plugin directory`;case`manifest-validation-error`:return`Check manifest file follows the required schema`;case`plugin-not-found`:return`Plugin may not exist in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return e.availableMarketplaces.length>0?`Available marketplaces: ${e.availableMarketplaces.join(`, `)}`:`Add the marketplace first using /plugin marketplace add`;case`mcp-config-invalid`:return`Check MCP server configuration in .mcp.json or manifest`;case`mcp-server-suppressed-duplicate`:return e.duplicateOf.startsWith(`plugin:`)?`Disable plugin "${e.duplicateOf.split(`:`)[1]??`the other plugin`}" if you want this plugin's version instead`:`Remove "${e.duplicateOf}" from your MCP config if you want the plugin's version instead`;case`hook-load-failed`:return`Check hooks.json file syntax and structure`;case`component-load-failed`:return`Check ${e.component} directory structure and file permissions`;case`mcpb-download-failed`:return`Check your internet connection and URL accessibility`;case`mcpb-extract-failed`:return`Verify the MCPB file is valid and not corrupted`;case`mcpb-invalid-manifest`:return`Contact the plugin author about the invalid manifest`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`This marketplace source is explicitly blocked by your administrator`:e.allowedSources.length>0?`Allowed sources: ${e.allowedSources.join(`, `)}`:`Contact your administrator to configure allowed marketplace sources`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Enable "${e.dependency}" or uninstall "${e.plugin}"`:`Install "${e.dependency}" or uninstall "${e.plugin}"`;case`lsp-config-invalid`:return`Check LSP server configuration in the plugin manifest`;case`lsp-server-start-failed`:case`lsp-server-crashed`:case`lsp-request-timeout`:case`lsp-request-failed`:return`Check LSP server logs with --debug for details`;case`plugin-cache-miss`:return`Run /plugins to refresh the plugin cache`;case`marketplace-load-failed`:case`generic-error`:return null}return null}var Un=e((()=>{he()}));function Wn({item:e,isSelected:t}){let[n]=l();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=_(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=_(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=_(`success`,n)(a.tick),i=`enabled`):(r=_(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=_(`warning`,n)(a.warning);return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=_(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=_(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=_(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=_(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=_(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=_(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{dimColor:!t,children:`└ `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]}):(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}var Y,Gn=e((()=>{i(),S(),ft(),Y=w()}));async function Kn(e){try{return(await nn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>tn.basename(e.name,`.md`))}catch(t){return nt(`Failed to read plugin components from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}async function qn(e){try{let t=await nn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=tn.join(e,r.name,`SKILL.md`);try{(await nn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return nt(`Failed to read skill directories from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}function Jn({plugin:e,marketplace:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{async function n(){try{if(t===`builtin`){let t=Ne(e.name);if(t){let e=t.skills?.map(e=>e.name)??[],n=t.hooks?Object.keys(t.hooks):[],i=t.mcpServers?Object.keys(t.mcpServers):[];r({commands:null,agents:null,skills:e.length>0?e:null,hooks:n.length>0?n:null,mcpServers:i.length>0?i:null})}else s(`Built-in plugin ${e.name} not found`);a(!1);return}let n=(await Be(t)).plugins.find(t=>t.name===e.name);if(n){let t=[];e.commandsPath&&t.push(e.commandsPath),e.commandsPaths&&t.push(...e.commandsPaths);let i=[];for(let e of t)if(typeof e==`string`){let t=await Kn(e);i.push(...t)}let a=[];e.agentsPath&&a.push(e.agentsPath),e.agentsPaths&&a.push(...e.agentsPaths);let o=[];for(let e of a)if(typeof e==`string`){let t=await Kn(e);o.push(...t)}let s=[];e.skillsPath&&s.push(e.skillsPath),e.skillsPaths&&s.push(...e.skillsPaths);let c=[];for(let e of s)if(typeof e==`string`){let t=await qn(e);c.push(...t)}let l=[];e.hooksConfig&&l.push(Object.keys(e.hooksConfig)),n.hooks&&l.push(n.hooks);let u=[];e.mcpServers&&u.push(Object.keys(e.mcpServers)),n.mcpServers&&u.push(n.mcpServers),r({commands:i.length>0?i:null,agents:o.length>0?o:null,skills:c.length>0?c:null,hooks:l.length>0?l:null,mcpServers:u.length>0?u:null})}else s(`Plugin ${e.name} not found in marketplace`)}catch(e){s(e instanceof Error?e.message:`Failed to load components`)}finally{a(!1)}}n()},[e.name,e.commandsPath,e.commandsPaths,e.agentsPath,e.agentsPaths,e.skillsPath,e.skillsPaths,e.hooksConfig,e.mcpServers,t]),i?null:o?(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Components:`}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(d,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Yn(e,t){let n=(await Be(t))?.plugins.find(t=>t.name===e);return n&&typeof n.source==`string`?`Local plugins cannot be updated remotely. To update, modify the source at: ${n.source}`:null}function Xn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!de(`${e.name}@${t}`)})}function Zn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=oe(e=>e.mcp.clients),h=oe(e=>e.mcp.tools),_=oe(e=>e.plugins.errors),y=jt(),[x,S]=(0,X.useState)(!1),C=(0,X.useCallback)(e=>{S(e),r?.(e)},[r]),ee=m(),{columns:w}=b(),[T,E]=(0,X.useState)(`plugin-list`),{query:D,setQuery:re,cursorOffset:ie}=Ut({isActive:T===`plugin-list`&&x,onExit:()=>{C(!1)}}),[A,j]=(0,X.useState)(null),[ae,M]=(0,X.useState)([]),[N,se]=(0,X.useState)([]),[P,ce]=(0,X.useState)(!0),[le,F]=(0,X.useState)(new Map),I=(0,X.useRef)(!1),de=(0,X.useRef)(void 0),pe=Pt();p(`confirm:no`,Qn.useCallback(()=>{if(T===`plugin-details`)E(`plugin-list`),j(null),B(null);else if(typeof T==`object`&&T.type===`failed-plugin-details`)E(`plugin-list`),B(null);else if(T===`configuring`)E(`plugin-details`),Ae(null);else if(typeof T==`object`&&(T.type===`plugin-options`||T.type===`configuring-options`))E(`plugin-list`),j(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof T==`object`&&T.type===`flagged-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-tools`)E({type:`mcp-detail`,client:T.client});else if(typeof T==`object`&&T.type===`mcp-tool-detail`)E({type:`mcp-tools`,client:T.client});else{if(le.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[T,e,le,t]),{context:`Confirmation`,isActive:(T!==`plugin-list`||!x)&&T!==`confirm-project-uninstall`&&!(typeof T==`object`&&T.type===`confirm-data-cleanup`)});let me=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,he=(0,X.useMemo)(()=>{let e=ne(),t=new Map;for(let e of l)if(e.name.startsWith(`plugin:`)){let n=e.name.split(`:`);if(n.length>=3){let r=n[1],i=n.slice(2).join(`:`),a=t.get(r)||[];a.push({displayName:i,client:e}),t.set(r,a)}}let n=[];for(let r of N){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=_.filter(e=>`plugin`in e&&e.plugin===r.plugin.name||e.source===i||e.source.startsWith(`${r.plugin.name}@`)),s=r.plugin.isBuiltin?`builtin`:r.scope||`user`;n.push({item:{type:`plugin`,id:i,name:r.plugin.name,description:r.plugin.manifest.description,marketplace:r.marketplace,scope:s,isEnabled:a,errorCount:o.length,errors:o,plugin:r.plugin,pendingEnable:r.pendingEnable,pendingUpdate:r.pendingUpdate,pendingToggle:le.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of _){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=mt(),s=[];for(let[e,t]of a){if(e in y)continue;let n=be(e),r=n.name||e,i=n.marketplace||`unknown`,a=o.get(e),c=a===`flag`||a===void 0?`user`:a;s.push({type:`failed-plugin`,id:e,name:r,marketplace:i,scope:c,errorCount:t.length,errors:t})}let c=[];for(let e of l)e.name!==`ide`&&(e.name.startsWith(`plugin:`)||c.push({type:`mcp`,id:`mcp:${e.name}`,name:e.name,description:void 0,scope:e.config.scope,status:me(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},d=[],f=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;f.has(n)||f.set(n,[]),f.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;f.has(r)||f.set(r,[]),f.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:me(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let e of s){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let[e,t]of Object.entries(y)){let n=be(e),r=n.name||e,i=n.marketplace||`unknown`;f.has(`flagged`)||f.set(`flagged`,[]),f.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let p=[...f.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of p){let t=f.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)d.push(...e);d.push(...r)}return d},[N,l,_,le,y]),ge=(0,X.useMemo)(()=>he.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[he]);(0,X.useEffect)(()=>{ge.length>0&&At(ge)},[ge]);let L=(0,X.useMemo)(()=>{if(!D)return he;let e=D.toLowerCase();return he.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[he,D]),[R,ve]=(0,X.useState)(0),ye=Tn({totalItems:L.length,selectedIndex:R,maxVisible:8}),[xe,Ce]=(0,X.useState)(0),[we,z]=(0,X.useState)(!1),[Ee,B]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)(!1),[Ne,Pe]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!A){Pe(!1);return}async function e(){let e=A.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))),!t)try{let e=tn.join(A.plugin.path,`..`),n=tn.join(e,`.claude-plugin`,`marketplace.json`),r=et(await nn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===A.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))}}catch(e){nt(`Failed to read raw marketplace.json: ${e}`)}Pe(t)}e()},[A]),(0,X.useEffect)(()=>{async function e(){ce(!0);try{let{enabled:e,disabled:t}=await ue(),n=ne(),r=Xn([...e,...t]),i={};for(let e of r){let t=e.source.split(`@`)[1]||`local`;i[t]||(i[t]=[]),i[t].push(e)}let a=[];for(let[e,t]of Object.entries(i)){let r=te(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),M(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:bt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}se(o),ve(0)}finally{ce(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!I.current&&i&&ae.length>0&&!P){let{name:e,marketplace:n}=be(i),r=o??n,a=r?ae.filter(e=>e.name===r):ae;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=bt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};j(r),E(`plugin-details`),de.current=s,I.current=!0;return}}let c=he.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(E({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),I.current=!0),!I.current&&s&&(I.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,ae,P,he,s,t]);let Fe=async r=>{if(!A)return;let i=A.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){B(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!yt(i)&&r!==`update`){B(`This plugin is managed by your organization. Contact your admin to disable it.`);return}z(!0),B(null);try{let o=`${A.plugin.name}@${A.marketplace}`,s;switch(r){case`enable`:{let e=await ht(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await vt(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!yt(i))break;if(St(o)){z(!1),E(`confirm-project-uninstall`);return}let e=Ue().plugins[o],t=!e||e.length<=1?await Le(o):null;if(t){z(!1),E({type:`confirm-data-cleanup`,size:t});return}let n=await gt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await _t(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${A.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}fe();let c=`${A.plugin.name}@${A.marketplace}`;if(ne()?.enabledPlugins?.[c]!==!1){z(!1),E({type:`plugin-options`});return}let l=r===`enable`?`Enabled`:r===`disable`?`Disabled`:r===`update`?`Updated`:`Uninstalled`,u=s&&s.length>0?` · required by ${s.join(`, `)}`:``;t(`✓ ${l} ${A.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){z(!1);let t=e instanceof Error?e.message:String(e);B(`Failed to ${r}: ${t}`),ct(tt(e))}},Re=(0,X.useRef)(Fe);Re.current=Fe,(0,X.useEffect)(()=>{if(T===`plugin-details`&&A&&de.current){let e=de.current;de.current=void 0,Re.current(e)}},[T,A]);let ze=Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=ne(),r=le.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||yt(a)){let e=new Map(le);r?(e.delete(t),(async()=>{try{r===`will-disable`?await ht(t):await vt(t),fe()}catch(e){ct(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await vt(t):await ht(t),fe()}catch(e){ct(e)}})()),F(e)}}else e?.type===`mcp`&&pe(e.client.name)},[R,L,le,N,pe]);c({"select:previous":()=>{R===0?C(!0):ye.handleSelectionChange(R-1,ve)},"select:next":()=>{R<L.length-1&&ye.handleSelectionChange(R+1,ve)},"select:accept":Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type===`plugin`){let t=N.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(j(t),E(`plugin-details`),Ce(0),B(null))}else e?.type===`flagged-plugin`?(E({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),B(null)):e?.type===`failed-plugin`?(E({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),Ce(0),B(null)):e?.type===`mcp`&&(E({type:`mcp-detail`,client:e.client}),B(null))},[R,L,N])},{context:`Select`,isActive:T===`plugin-list`&&!x}),c({"plugin:toggle":ze},{context:`Plugin`,isActive:T===`plugin-list`&&!x}),c({"select:accept":Qn.useCallback(()=>{typeof T!=`object`||T.type!==`flagged-detail`||(Mt(T.plugin.id),E(`plugin-list`))},[T])},{context:`Select`,isActive:typeof T==`object`&&T.type===`flagged-detail`});let Be=Qn.useMemo(()=>{if(T!==`plugin-details`||!A)return[];let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=A.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Fe(n?`disable`:`enable`)}),r||(i.push({label:A.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Yn(A.plugin.name,A.marketplace);if(e){B(e);return}let t=[...N],n=t.findIndex(e=>e.plugin.name===A.plugin.name&&e.marketplace===A.marketplace);n!==-1&&(t[n].pendingUpdate=!A.pendingUpdate,se(t),j({...A,pendingUpdate:!A.pendingUpdate}))}catch(e){B(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Ne&&i.push({label:`Configure`,action:async()=>{Me(!0);try{let e=A.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&Oe(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&Oe(n)){t=n;break}}if(!t){B(`No MCPB file found in plugin`),Me(!1);return}let n=`${A.plugin.name}@${A.marketplace}`,r=await Ie(t,A.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ae(r),E(`configuring`)):B(`Failed to load MCPB for configuration`)}catch(e){let t=$e(e);B(`Failed to load configuration: ${t}`)}finally{Me(!1)}}}),A.plugin.manifest.userConfig&&Object.keys(A.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{E({type:`configuring-options`,schema:A.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Fe(`update`)}),i.push({label:`Uninstall`,action:()=>void Fe(`uninstall`)})),A.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void De(A.plugin.manifest.homepage)}),A.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void De(A.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{E(`plugin-list`),j(null),B(null)}}),i},[T,A,Ne,N]);if(c({"select:previous":()=>{xe>0&&Ce(xe-1)},"select:next":()=>{xe<Be.length-1&&Ce(xe+1)},"select:accept":()=>{Be[xe]&&Be[xe].action()}},{context:`Select`,isActive:T===`plugin-details`&&!!A}),c({"select:accept":()=>{typeof T==`object`&&T.type===`failed-plugin-details`&&(async()=>{z(!0),B(null);let e=T.plugin.id,t=T.plugin.scope,r=yt(t)?await gt(e,t,!1):await gt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=O(t);n?.enabledPlugins?.[e]!==void 0&&(k(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}fe()}i?(n&&await n(),z(!1),E(`plugin-list`)):(z(!1),B(r.message))})()}},{context:`Select`,isActive:typeof T==`object`&&T.type===`failed-plugin-details`&&T.plugin.scope!==`managed`}),c({"confirm:yes":()=>{if(!A)return;z(!0),B(null);let r=`${A.plugin.name}@${A.marketplace}`,{error:i}=k(`localSettings`,{enabledPlugins:{...O(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){z(!1),B(`Failed to write settings: ${i.message}`);return}fe(),t(`✓ Disabled ${A.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{E(`plugin-details`),B(null)}},{context:`Confirmation`,isActive:T===`confirm-project-uninstall`&&!!A&&!we}),g((r,i)=>{if(!A)return;let o=`${A.plugin.name}@${A.marketplace}`,s=A.scope;if(!s||s===`builtin`||!yt(s))return;let c=async r=>{z(!0),B(null);try{let i=await gt(o,s,r);if(!i.success)throw Error(i.message);fe();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){z(!1),B(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(E(`plugin-details`),B(null))},{isActive:typeof T==`object`&&T.type===`confirm-data-cleanup`&&!!A&&!we}),Qn.useEffect(()=>{ve(0)},[D]),g((e,t)=>{let n=!t.ctrl&&!t.meta;x||(e===`/`&&n?(C(!0),re(``),ve(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(C(!0),re(e),ve(0)))},{isActive:T===`plugin-list`}),P)return(0,Z.jsx)(d,{children:`Loading installed plugins…`});if(he.length===0)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(d,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Esc to go back`})})]});if(typeof T==`object`&&T.type===`plugin-options`&&A){let r=`${A.plugin.name}@${A.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(pn,{plugin:A.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof T==`object`&&T.type===`configuring-options`&&A){let e=`${A.plugin.name}@${A.marketplace}`;return(0,Z.jsx)(cn,{title:`Configure ${A.plugin.name}`,subtitle:`Plugin options`,configSchema:T.schema,initialValues:Te(e),onSave:n=>{try{_e(e,n,T.schema),fe(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){B(`Failed to save configuration: ${$e(e)}`)}E(`plugin-details`)},onCancel:()=>E(`plugin-details`)})}if(T===`configuring`&&ke&&A){let e=`${A.plugin.name}@${A.marketplace}`;async function n(n){if(!(!ke||!A))try{let r=A.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&Oe(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&Oe(e)){i=e;break}}if(!i){B(`No MCPB file found`),E(`plugin-details`);return}await Ie(i,A.plugin.path,e,void 0,n),B(null),Ae(null),E(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=$e(e);B(`Failed to save configuration: ${t}`),E(`plugin-details`)}}function r(){Ae(null),E(`plugin-details`)}return(0,Z.jsx)(cn,{title:`Configure ${ke.manifest.name}`,subtitle:`Plugin: ${A.plugin.name}`,configSchema:ke.configSchema,initialValues:ke.existingConfig,onSave:n,onCancel:r})}if(typeof T==`object`&&T.type===`flagged-detail`){let e=T.plugin;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(u,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(d,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(d,{children:e.text}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(u,{children:[(0,Z.jsxs)(d,{children:[a.pointer,` `]}),(0,Z.jsx)(d,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(T===`confirm-project-uninstall`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,color:`warning`,children:[A.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(d,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof T==`object`&&T.type===`confirm-data-cleanup`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` has `,T.size.human,` of persistent data`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(d,{dimColor:!0,children:Ge(`${A.plugin.name}@${A.marketplace}`)})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(d,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(d,{bold:!0,children:`esc`}),` to cancel`]})})]});if(T===`plugin-details`&&A){let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=_.filter(e=>`plugin`in e&&e.plugin===A.plugin.name||e.source===t||e.source.startsWith(`${A.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(d,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Hn(e);return(0,Z.jsxs)(u,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(d,{color:`error`,children:Vn(e)}),n&&(0,Z.jsxs)(d,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` @ `,A.marketplace]})}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(d,{children:A.scope||`user`})]}),A.plugin.manifest.version&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.version})]}),A.plugin.manifest.description&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{children:A.plugin.manifest.description})}),A.plugin.manifest.author&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.author.name})]}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),A.pendingUpdate&&(0,Z.jsx)(d,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Jn,{plugin:A.plugin,marketplace:A.marketplace}),i,(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:Be.map((e,t)=>{let n=t===xe;return(0,Z.jsxs)(u,{children:[n&&(0,Z.jsxs)(d,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(d,{children:` `}),(0,Z.jsx)(d,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),we&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{children:`Processing…`})}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`failed-plugin-details`){let e=T.plugin,t=e.errors[0],n=t?Vn(t):`Failed to load`;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:e.name}),(0,Z.jsxs)(d,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(d,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(u,{marginTop:1,children:[(0,Z.jsxs)(d,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(d,{bold:!0,children:`Remove`})]}),we&&(0,Z.jsx)(d,{children:`Processing…`}),Ee&&(0,Z.jsx)(d,{color:`error`,children:Ee}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[e.scope!==`managed`&&(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`mcp-detail`){let e=T.client,n=Se(h,e.name).length,r=()=>{E({type:`mcp-tools`,client:e})},i=()=>{E(`plugin-list`)},a=e=>{e&&t(e),E(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Gt,{server:{name:e.name,client:e,scope:o,transport:`stdio`,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`sse`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`sse`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`http`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`http`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`claudeai-proxy`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):(E(`plugin-list`),null)}if(typeof T==`object`&&T.type===`mcp-tools`){let e=T.client,t=e.config.scope,n=e.config.type,r;return r=n===`stdio`?{name:e.name,client:e,scope:t,transport:`stdio`,config:e.config}:n===`sse`?{name:e.name,client:e,scope:t,transport:`sse`,isAuthenticated:void 0,config:e.config}:n===`http`?{name:e.name,client:e,scope:t,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:t,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Qt,{server:r,onSelectTool:t=>{E({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>E({type:`mcp-detail`,client:e})})}if(typeof T==`object`&&T.type===`mcp-tool-detail`){let{client:e,tool:t}=T,n=e.config.scope,r=e.config.type,i;return i=r===`stdio`?{name:e.name,client:e,scope:n,transport:`stdio`,config:e.config}:r===`sse`?{name:e.name,client:e,scope:n,transport:`sse`,isAuthenticated:void 0,config:e.config}:r===`http`?{name:e.name,client:e,scope:n,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:n,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Xt,{tool:t,server:i,onBack:()=>E({type:`mcp-tools`,client:e})})}let Ve=ye.getVisibleItems(L);return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(v,{query:D,isFocused:x,isTerminalFocused:ee,width:w-4,cursorOffset:ie})}),L.length===0&&D&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsxs)(d,{dimColor:!0,children:[`No items match "`,D,`"`]})}),ye.scrollPosition.canScrollUp&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ve.map((e,t)=>{let n=ye.toActualIndex(t)===R&&!x,r=t>0?Ve[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)(Qn.Fragment,{children:[i&&(0,Z.jsx)(u,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(d,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Wn,{item:e,isSelected:n})]},e.id)}),ye.scrollPosition.canScrollDown&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(u,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(d,{children:`type to search`}),(0,Z.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),le.size>0&&(0,Z.jsx)(u,{marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var Qn,X,Z,$n=e((()=>{i(),Qn=t(h(),1),X=t(h(),1),je(),S(),Kt(),Yt(),qt(),Jt(),Ht(),Wt(),ze(),Ve(),M(),Ft(),A(),xt(),Ze(),T(),Ye(),rt(),Qe(),st(),me(),we(),We(),j(),Pe(),Nt(),P(),L(),Ce(),F(),pt(),D(),it(),ft(),Un(),dn(),gn(),Gn(),On(),Z=w()}));function er(e){if(!e)return{type:`menu`};let t=e.trim().split(/\s+/);switch(t[0]?.toLowerCase()){case`help`:case`--help`:case`-h`:return{type:`help`};case`install`:case`i`:{let e=t[1];if(!e)return{type:`install`};if(e.includes(`@`)){let[t,n]=e.split(`@`);return{type:`install`,plugin:t,marketplace:n}}return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`file://`)||e.includes(`/`)||e.includes(`\\`)?{type:`install`,marketplace:e}:{type:`install`,plugin:e}}case`manage`:return{type:`manage`};case`uninstall`:return{type:`uninstall`,plugin:t[1]};case`enable`:return{type:`enable`,plugin:t[1]};case`disable`:return{type:`disable`,plugin:t[1]};case`validate`:return{type:`validate`,path:t.slice(1).join(` `).trim()||void 0};case`marketplace`:case`market`:{let e=t[1]?.toLowerCase(),n=t.slice(2).join(` `);switch(e){case`add`:return{type:`marketplace`,action:`add`,target:n};case`remove`:case`rm`:return{type:`marketplace`,action:`remove`,target:n};case`update`:return{type:`marketplace`,action:`update`,target:n};case`list`:return{type:`marketplace`,action:`list`};default:return{type:`marketplace`}}}default:return{type:`menu`}}}var tr=e((()=>{}));function nr({onComplete:e,path:t}){return(0,rr.useEffect)(()=>{async function n(){if(!t){e(`Usage: /plugin validate <path>
2
-
3
- Validate a plugin or marketplace manifest file or directory.
4
-
5
- Examples:
6
- /plugin validate .claude-plugin/plugin.json
7
- /plugin validate /path/to/plugin-directory
8
- /plugin validate .
9
-
10
- When given a directory, automatically validates .claude-plugin/marketplace.json
11
- or .claude-plugin/plugin.json (prefers marketplace if both exist).
12
-
13
- Or from the command line:
14
- claude plugin validate <path>`);return}try{let n=await Et(t),r=``;r+=`Validating ${n.fileType} manifest: ${n.filePath}\n\n`,n.errors.length>0&&(r+=`${a.cross} Found ${n.errors.length} ${H(n.errors.length,`error`)}:\n\n`,n.errors.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
15
- `),n.warnings.length>0&&(r+=`${a.warning} Found ${n.warnings.length} ${H(n.warnings.length,`warning`)}:\n\n`,n.warnings.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
16
- `),n.success?(n.warnings.length>0?r+=`${a.tick} Validation passed with warnings\n`:r+=`${a.tick} Validation passed\n`,process.exitCode=0):(r+=`${a.cross} Validation failed\n`,process.exitCode=1),e(r)}catch(t){process.exitCode=2,ct(t),e(`${a.cross} Unexpected error during validation: ${$e(t)}`)}}n()},[e,t]),(0,ir.jsx)(u,{flexDirection:`column`,children:(0,ir.jsx)(d,{children:`Running validation...`})})}var rr,ir,ar=e((()=>{i(),rr=t(h(),1),S(),Qe(),st(),kt(),ft(),ir=w()}));function or({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await B(),n=Object.keys(t);n.length===0?e(`No marketplaces configured`):e(`Configured marketplaces:\n${n.map(e=>` • ${e}`).join(`
17
- `)}`)}catch(t){e(`Error loading marketplaces: ${$e(t)}`)}}t()},[e]),(0,$.jsx)(d,{children:`Loading marketplaces...`})}function sr(e){let t=[];for(let{source:n,scope:r}of[{source:`userSettings`,scope:`user`},{source:`projectSettings`,scope:`project`},{source:`localSettings`,scope:`local`}])O(n)?.extraKnownMarketplaces?.[e]&&t.push({source:n,scope:r});return{editableSources:t,isInPolicy:!!O(`policySettings`)?.extraKnownMarketplaces?.[e]}}function cr(e){let{editableSources:t,isInPolicy:n}=sr(e);return t.length>0?{kind:`remove-extra-marketplace`,name:e,sources:t}:n?{kind:`managed-only`,name:e}:{kind:`navigate`,tab:`marketplaces`,viewState:{type:`manage-marketplaces`,targetMarketplace:e,action:`remove`}}}function lr(e){return{kind:`navigate`,tab:`installed`,viewState:{type:`manage-plugins`,targetPlugin:e,action:`uninstall`}}}function ur(e){return vr.has(e.type)}function dr(e){if(`pluginId`in e&&e.pluginId)return e.pluginId;if(`plugin`in e&&e.plugin)return e.plugin;if(e.source.includes(`@`))return e.source.split(`@`)[0]}function fr(e,t,n,r,i,a,o){let s=[];for(let e of a){let t=`pluginId`in e?e.pluginId:`plugin`in e?e.plugin:void 0;s.push({label:t??e.source,message:Vn(e),guidance:`Restart to retry loading plugins`,action:{kind:`none`}})}let c=new Set;for(let t of e){c.add(t.name);let e=cr(t.name),n=sr(t.name),r=n.isInPolicy?`managed`:n.editableSources[0]?.scope;s.push({label:t.name,message:t.error??`Installation failed`,guidance:e.kind===`managed-only`?`Managed by your organization — contact your admin`:void 0,action:e,scope:r})}for(let e of t){let t=`marketplace`in e?e.marketplace:e.source;if(c.has(t))continue;c.add(t);let n=cr(t),r=sr(t),i=r.isInPolicy?`managed`:r.editableSources[0]?.scope;s.push({label:t,message:Vn(e),guidance:n.kind===`managed-only`?`Managed by your organization — contact your admin`:Hn(e),action:n,scope:i})}for(let e of i)c.has(e.name)||(c.add(e.name),s.push({label:e.name,message:e.error,action:{kind:`remove-installed-marketplace`,name:e.name}}));let l=new Set;for(let e of n){let t=dr(e);if(t&&l.has(t))continue;t&&l.add(t);let n=`marketplace`in e?e.marketplace:void 0,r=t?o.get(e.source)??o.get(t):void 0;s.push({label:t?n?`${t} @ ${n}`:t:e.source,message:Vn(e),guidance:Hn(e),action:t?lr(t):{kind:`none`},scope:r})}for(let e of r)s.push({label:e.source,message:Vn(e),guidance:Hn(e),action:{kind:`none`}});return s}function pr(e,t){for(let{source:n}of t){let t=O(n);if(!t)continue;let r={};if(t.extraKnownMarketplaces?.[e]&&(r.extraKnownMarketplaces={...t.extraKnownMarketplaces,[e]:void 0}),t.enabledPlugins){let n=`@${e}`,i=!1,a={...t.enabledPlugins};for(let e in a)e.endsWith(n)&&(a[e]=void 0,i=!0);i&&(r.enabledPlugins=a)}Object.keys(r).length>0&&k(n,r)}}function mr({setViewState:e,setActiveTab:t,markPluginsChanged:n}){let r=oe(e=>e.plugins.errors),i=oe(e=>e.plugins.installationStatus),o=I(),[s,l]=(0,Q.useState)(0),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await ae(await B());_(e)}catch{}})()},[]);let v=i.marketplaces.filter(e=>e.status===`failed`),y=new Set(v.map(e=>e.name)),b=r.filter(ur),x=fr(v,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!y.has(e.marketplace)),r.filter(e=>ur(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:dr(e)!==void 0),r.filter(e=>ur(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:dr(e)===void 0),g,b,mt());p(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),c({"select:previous":()=>l(e=>Math.max(0,e-1)),"select:next":()=>l(e=>Math.min(x.length-1,e+1)),"select:accept":()=>{let r=x[s];if(!r)return;let{action:i}=r;switch(i.kind){case`navigate`:t(i.tab),e(i.viewState);break;case`remove-extra-marketplace`:{let e=i.sources.map(e=>e.scope).join(`, `);pr(i.name,i.sources),fe(),o(e=>({...e,plugins:{...e.plugins,errors:e.plugins.errors.filter(e=>!(`marketplace`in e&&e.marketplace===i.name)),installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.filter(e=>e.name!==i.name)}}})),h(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await Ae(i.name),fe(),_(e=>e.filter(e=>e.name!==i.name)),h(`${a.tick} Removed marketplace "${i.name}"`),n()}catch(e){h(`Failed to remove "${i.name}": ${e instanceof Error?e.message:String(e)}`)}})();break;case`managed-only`:break;case`none`:break}}},{context:`Select`,isActive:x.length>0});let S=Math.min(s,Math.max(0,x.length-1));S!==s&&l(S);let C=x[S]?.action,ee=C&&C.kind!==`none`&&C.kind!==`managed-only`;return x.length===0?(0,$.jsxs)(u,{flexDirection:`column`,children:[(0,$.jsx)(u,{marginLeft:1,children:(0,$.jsx)(d,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(u,{marginTop:1,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:(0,$.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(u,{flexDirection:`column`,children:[x.map((e,t)=>{let n=t===S;return(0,$.jsxs)(u,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(d,{children:[(0,$.jsxs)(d,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(d,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(u,{marginLeft:3,children:(0,$.jsx)(d,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(u,{marginLeft:3,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),m&&(0,$.jsx)(u,{marginTop:1,marginLeft:1,children:(0,$.jsx)(d,{color:`claude`,children:m})}),(0,$.jsx)(u,{marginTop:1,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:(0,$.jsxs)(f,{children:[(0,$.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),ee&&(0,$.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}function hr(e){switch(e.type){case`help`:return{type:`help`};case`validate`:return{type:`validate`,path:e.path};case`install`:return e.marketplace?{type:`browse-marketplace`,targetMarketplace:e.marketplace,targetPlugin:e.plugin}:e.plugin?{type:`discover-plugins`,targetPlugin:e.plugin}:{type:`discover-plugins`};case`manage`:return{type:`manage-plugins`};case`uninstall`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`uninstall`};case`enable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`enable`};case`disable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`disable`};case`marketplace`:return e.action===`list`?{type:`marketplace-list`}:e.action===`add`?{type:`add-marketplace`,initialValue:e.target}:e.action===`remove`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`remove`}:e.action===`update`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`update`}:{type:`marketplace-menu`};default:return{type:`discover-plugins`}}}function gr(e){return e.type===`manage-plugins`?`installed`:e.type===`manage-marketplaces`?`marketplaces`:`discover`}function _r({onComplete:e,args:t}){let n=er(t),r=hr(n),[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(gr(r)),[c,l]=(0,Q.useState)(i.type===`add-marketplace`&&i.initialValue||``),[f,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[b,S]=(0,Q.useState)(!1),ee=I(),w=oe(e=>{let t=e.plugins.errors.length;for(let n of e.plugins.installationStatus.marketplaces)n.status===`failed`&&t++;return t}),T=w>0?`Errors (${w})`:`Errors`,te=It(),ne=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,E=(0,Q.useCallback)(()=>{ee(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[ee]),D=(0,Q.useCallback)(e=>{let t=e;switch(s(t),g(null),t){case`discover`:a({type:`discover-plugins`});break;case`installed`:a({type:`manage-plugins`});break;case`marketplaces`:a({type:`manage-marketplaces`});break;case`errors`:break}},[]);return(0,Q.useEffect)(()=>{i.type===`menu`&&!_&&e()},[i.type,_,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&o!==`discover`&&s(`discover`)},[i.type,o]),p(`confirm:no`,(0,Q.useCallback)(()=>{s(`marketplaces`),a({type:`manage-marketplaces`}),l(``),g(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{_&&e(_)},[_,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(u,{flexDirection:`column`,children:[(0,$.jsx)(d,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(d,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(d,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(d,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(d,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Management:`}),(0,$.jsx)(d,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(d,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(d,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(d,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(d,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(d,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(d,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(d,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(d,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Other:`}),(0,$.jsx)(d,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(d,{children:` /plugin help - Show this help`}),(0,$.jsx)(d,{children:` /plugins - Alias for /plugin`})]}):i.type===`validate`?(0,$.jsx)(nr,{onComplete:e,path:i.path}):i.type===`marketplace-menu`?(a({type:`menu`}),null):i.type===`marketplace-list`?(0,$.jsx)(or,{onComplete:e}):i.type===`add-marketplace`?(0,$.jsx)(rn,{inputValue:c,setInputValue:l,cursorOffset:f,setCursorOffset:m,error:h,setError:g,result:_,setResult:v,setViewState:a,onAddComplete:E,cliMode:ne}):(0,$.jsx)(C,{color:`suggestion`,children:(0,$.jsxs)(x,{title:`Plugins`,selectedTab:o,onTabChange:D,color:`suggestion`,disableNavigation:b,children:[(0,$.jsx)(y,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(kn,{error:h,setError:g,result:_,setResult:v,setViewState:a,onInstallComplete:E,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Mn,{error:h,setError:g,result:_,setResult:v,setViewState:a,onInstallComplete:E,onSearchModeChange:S,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(y,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Zn,{setViewState:a,setResult:v,onManageComplete:E,onSearchModeChange:S,targetPlugin:i.type===`manage-plugins`?i.targetPlugin:void 0,targetMarketplace:i.type===`manage-plugins`?i.targetMarketplace:void 0,action:i.type===`manage-plugins`?i.action:void 0})}),(0,$.jsx)(y,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Ln,{setViewState:a,error:h,setError:g,setResult:v,exitState:te,onManageComplete:E,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(y,{id:`errors`,title:T,children:(0,$.jsx)(mr,{setViewState:a,setActiveTab:s,markPluginsChanged:E})})]})})}var Q,$,vr,yr=e((()=>{i(),Q=t(h(),1),je(),S(),Lt(),Ve(),Ze(),Qe(),me(),ge(),We(),pt(),D(),on(),jn(),In(),Bn(),$n(),Un(),tr(),ar(),$=w(),vr=new Set([`git-auth-failed`,`git-timeout`,`network-error`])}));async function br(e,t,n){return(0,xr.jsx)(_r,{onComplete:e,args:n})}var xr;e((()=>{yr(),xr=w()}))();export{br as call};
@@ -1 +0,0 @@
1
- import{Ya as e,fo as t,so as n,to as r,uo as i}from"./loadAgentsDir-bmpKLPdG.js";import{I as a,M as o,c as s,i as c}from"./debug-2pVES-2G.js";import{d as l,s as u}from"./pluginOperations-BCvJvfOC.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-B2ZX5_oB.js";u(),c(),a(),e(),i(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let e=r(),i=f(),a=await t(),c=[];for(let t of Object.keys(a))try{let r=await n(t);if(!r.forceRemoveDeletedPlugins)continue;let a=h(e,r,t);for(let t of a){if(t in i)continue;let n=e.plugins[t]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let e of n){let{scope:n}=e;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(t,n)}catch(e){s(`Failed to auto-uninstall delisted plugin ${t} from ${n}: ${o(e)}`,{level:`error`})}}await m(t),c.push(t)}}}catch(e){s(`Failed to check for delisted plugins in "${t}": ${o(e)}`,{level:`warn`})}return c}export{g as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{Cx as n,Ja as r,Tx as i,au as a,gi as o,iu as s,mi as c,qa as l,ru as u}from"./loadAgentsDir-bmpKLPdG.js";import{I as d,M as f}from"./debug-2pVES-2G.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-L1kqxa_P.js";import{n as _}from"./analytics-COpjZpvd.js";import{a as v,c as y,d as b,f as x,i as S,r as C,s as w}from"./pluginOperations-BCvJvfOC.js";e(),d(),o(),h(),r(),n(),p(),a(),_(),w();function T(e,n,r){g(e);let a=r?`${n} plugin "${r}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${a}: ${f(e)}`);let o=r?(()=>{let{name:e,marketplace:t}=i(r);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...u(e,t,l())}})():{};s(e),{...o},process.exit(1)}async function E(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`install`,e)}}async function D(e,n=`user`,r=!1){try{let a=await b(e,n,!r);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);({...s&&{_PROTO_marketplace_name:s}}),a.scope,{...u(o,s,l())},process.exit(0)}catch(t){T(t,`uninstall`,e)}}async function O(e,n){try{let r=await v(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`enable`,e)}}async function k(e,n){try{let r=await S(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`disable`,e)}}async function A(){try{let e=await C();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),process.exit(0)}catch(e){T(e,`disable-all`)}}async function j(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await x(e,n);if(!r.success)throw Error(r.message);if(m(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=i(r.pluginId||e);({...n&&{_PROTO_marketplace_name:n}}),r.oldVersion,r.newVersion,{...u(t,n,l())}}await c(0)}catch(t){T(t,`update`,e)}}export{D as a,E as i,k as n,j as o,O as r,A as t};
@@ -1,2 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{m as t,s as n,y as r}from"./settings-D4M13toi.js";import{Pt as i,q as a}from"./state-CXY-q5gr.js";import{Ax as o,Ba as s,Cx as c,Ex as l,Fa as u,Ga as d,Ha as f,Jm as p,Ka as m,La as h,Ma as g,Mo as _,Na as v,No as y,Pa as b,Po as x,Sx as S,Tx as C,Ua as w,Wa as T,Xm as E,Ya as ee,ax as te,bx as D,do as ne,eo as O,ja as k,jx as A,ka as j,lo as M,lx as re,no as ie,ro as ae,so as oe,to as N,uo as se,xx as P,za as ce}from"./loadAgentsDir-bmpKLPdG.js";import{I as F,R as I,V as L,f as R,u as z}from"./debug-2pVES-2G.js";import{o as B,s as V}from"./log-L1kqxa_P.js";import{l as H,o as U}from"./stringUtils-Cs6E5f-B.js";import{n as W,t as G}from"./pluginStartupCheck-QG0d95dE.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?a():void 0}function de(e){return n(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let r of[`local`,`project`,`user`]){let i=n(l(r))?.enabledPlugins;if(i){for(let n of Object.keys(i))if(t?n===e:n.startsWith(`${e}@`))return{pluginId:n,scope:r}}}return null}function pe(e,t){let{name:n,marketplace:r}=C(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=C(e),n=N();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=C(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=N().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=a(),r=t.find(e=>e.scope===`local`&&e.projectPath===n);if(r)return{scope:r.scope,projectPath:r.projectPath};let i=t.find(e=>e.scope===`project`&&e.projectPath===n);if(i)return{scope:i.scope,projectPath:i.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=C(e),i,a,o;if(r){let t=await M(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await ne();for(let[t,r]of Object.entries(e))try{let e=(await oe(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){V(L(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,c=`${s.name}@${a}`,l=await f({pluginId:c,entry:s,scope:t,marketplaceInstallLocation:o});if(!l.ok){let e=l;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:ce(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${c} (scope: ${t})${l.depNote}`,pluginId:c,pluginName:s.name,scope:t}}async function ge(e,t=`user`,i=!0){q(t);let{enabled:a,disabled:o}=await u(),s=[...a,...o],c=pe(e,s),d=l(t),f=n(d),m,h;if(c)m=Object.keys(f?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),h=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};m=t.pluginId,h=t.pluginName}let g=J(t),v=N().plugins[m],y=v?.find(e=>e.scope===t&&e.projectPath===g);if(!y){let{scope:n}=Y(m);return n!==t&&v&&v.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.workmate/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let b=y.installPath,S={...f?.enabledPlugins};S[m]=void 0,r(d,{enabledPlugins:S}),_(),ie(m,t,g);let C=N().plugins[m],w=!C||C.length===0;w&&b&&await x(b),w&&(p(m),i&&await te(m));let T=D(m,s),E=P(T);return{success:!0,message:`Successfully uninstalled plugin: ${h} (scope: ${t})${E}`,pluginId:m,pluginName:h,scope:t,reverseDependents:T.length>0?T:void 0}}async function X(e,t,i){let a=t?`enable`:`disable`;if(A(e)){let{error:i}=r(`userSettings`,{enabledPlugins:{...n(`userSettings`)?.enabledPlugins,[e]:t}});if(i)return{success:!1,message:`Failed to ${a} built-in plugin: ${i.message}`};_();let{name:o}=C(e);return{success:!0,message:`Successfully ${a}d built-in plugin: ${o}`,pluginId:e,pluginName:o,scope:`user`}}i&&q(i);let o,s,c=fe(e);if(i)if(s=i,c)o=c.pluginId;else if(e.includes(`@`))o=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)o=c.pluginId,s=c.scope;else if(e.includes(`@`))o=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&m(o))return{success:!1,message:`Plugin "${o}" is blocked by your organization's policy and cannot be enabled`};let d=l(s),f=n(d)?.enabledPlugins?.[o],p={user:0,project:1,local:2},h=i&&c&&p[i]>p[c.scope];if(i&&f===void 0&&c&&c.scope!==i&&!h)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${i}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(i&&!h?f===!0:G().has(o)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${i?` at ${i} scope`:``}`};let g;if(!t){let{enabled:e,disabled:t}=await u(),n=D(o,[...e,...t]);n.length>0&&(g=n)}let{error:v}=r(d,{enabledPlugins:{...n(d)?.enabledPlugins,[o]:t}});if(v)return{success:!1,message:`Failed to ${a} plugin: ${v.message}`};_();let{name:y}=C(o),b=P(g);return{success:!0,message:`Successfully ${a}d plugin: ${y} (scope: ${s})${b}`,pluginId:o,pluginName:y,scope:s,reverseDependents:g}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${H(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
2
- `)}`}:{success:!0,message:`Disabled ${t.length} ${H(t.length,`plugin`)}`}}async function ye(e,t){let{name:n,marketplace:r}=C(e),i=r?`${n}@${r}`:e,a=await M(e);if(!a)return{success:!1,message:`Plugin "${n}" not found`,pluginId:i,scope:t};let{entry:o,marketplaceInstallLocation:s}=a,c=O().plugins[i];if(!c||c.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:i,scope:t};let l=J(t),u=c.find(e=>e.scope===t&&e.projectPath===l);return u?be({pluginId:i,pluginName:n,entry:o,marketplaceInstallLocation:s,installation:u,scope:t,projectPath:l}):{success:!1,message:`Plugin "${n}" is not installed at scope ${l?`${t} (${l})`:t}`,pluginId:i,scope:t}}async function be({pluginId:e,pluginName:t,entry:n,marketplaceInstallLocation:r,installation:i,scope:a,projectPath:o}){let s=z(),c=i.version,l,u,d=!1,f;if(typeof n.source!=`string`){let t=await j(n.source,{manifest:{name:n.name}});l=t.path,d=!0,f=t.gitCommitSha,u=await w(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await s.stat(r)}catch(t){if(I(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:a};throw t}l=K(t.isDirectory()?r:le(r),n.source);try{await s.stat(l)}catch(t){if(I(t))return{success:!1,message:`Plugin source not found at ${l}`,pluginId:e,scope:a};throw t}let i,o=K(l,`.claude-plugin`,`plugin.json`);try{i=await h(o,n.name,n.source)}catch{}u=await w(e,n.source,i,l,n.version)}try{let r=g(e,u),s=v(e,u);if(i.version===u||i.installPath===r||i.installPath===s)return{success:!0,message:`${t} is already at the latest version (${u}).`,pluginId:e,newVersion:u,oldVersion:c,alreadyUpToDate:!0,scope:a};r=await k(l,e,u,n);let d=i.installPath;if(ae(e,a,o,r,u,f),d&&d!==r){let e=O();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===d))||await x(d)}let p=o?`${a} (${o})`:a;return{success:!0,message:`Plugin "${t}" updated from ${c||`unknown`} to ${u} for scope ${p}. Restart to apply changes.`,pluginId:e,newVersion:u,oldVersion:c,scope:a}}finally{d&&l!==g(e,u)&&await s.rm(l,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{i(),o(),F(),R(),B(),y(),S(),ee(),se(),re(),c(),s(),b(),E(),d(),W(),T(),t(),U(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./pluginStartupCheck-QG0d95dE.js";e();export{t as getPluginEditableScopes};
@@ -1,4 +0,0 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{Bn as n,Pt as r}from"./state-CXY-q5gr.js";import{$a as i,Ao as a,Cx as o,Ex as s,Fa as c,Mo as l,Mx as u,No as d,Nx as f,Oo as p,Pa as m,So as h,Tx as g,Ya as _,_f as v,do as y,go as ee,io as te,mo as b,po as x,to as S,uo as C,vf as w,vo as T}from"./loadAgentsDir-bmpKLPdG.js";import{C as E,I as ne,M as D,x as re}from"./debug-2pVES-2G.js";import{o as O,s as k}from"./log-L1kqxa_P.js";import{n as A}from"./analytics-COpjZpvd.js";import{l as j,o as M}from"./stringUtils-Cs6E5f-B.js";import{n as N,t as P}from"./exit-s9XGerrH.js";import{n as F,s as I,t as L}from"./pluginOperations-BCvJvfOC.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./pluginCliCommands-Dyk4HYHs.js";import{a as ie,c as W,i as G,n as K,r as q,s as J,t as Y}from"./validatePlugin-CTVnWx9H.js";import{basename as ae,dirname as X}from"path";e(),r(),A(),I(),f(),ne(),O(),d(),W(),_(),p(),C(),v(),G(),o(),m(),Y(),re(),M();function Z(e,n){k(e),P(`${t.cross} Failed to ${n}: ${D(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${j(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${j(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function oe(e,r){r.cowork&&n(!0);try{let n=await K(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(ae(e)===`.claude-plugin`){r=await q(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?N(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){k(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&n(!0);let r=S(),{getPluginEditableScopes:o}=await import(`./pluginStartupCheck-o_TC7wIt.js`),s=o(),l=Object.keys(r.plugins),{enabled:d,disabled:f,errors:p}=await c(),m=[...d,...f],_=m.filter(e=>e.source.endsWith(`@inline`)),v=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),n=[];for(let e of l.sort()){let i=r.plugins[e];if(!i||i.length===0)continue;let a=g(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(u);for(let r of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await w(i);e&&Object.keys(e).length>0&&(a=e)}n.push({id:e,version:r.version||`unknown`,scope:r.scope,enabled:s.has(e),installPath:r.installPath,installedAt:r.installedAt,lastUpdated:r.lastUpdated,projectPath:r.projectPath,mcpServers:a,errors:o.length>0?o:void 0})}}for(let e of _){let t=e.mcpServers||await w(e),r=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(u);n.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:r.length>0?r:void 0})}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[u(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([y(),J()]),{marketplaces:r}=await a(t);for(let{name:t,data:a}of r)if(a)for(let r of a.plugins){let a=h(r.name,t);i(a)||e.push({pluginId:a,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(a)})}}catch{}N(E({installed:n,available:e},null,2))}else N(E(n,null,2))}l.length===0&&_.length===0&&v.length===0&&N("No plugins installed. Use `wm plugin install` to install a plugin."),l.length>0&&console.log(`Installed plugins:
2
- `);for(let e of l.sort()){let n=r.plugins[e];if(!n||n.length===0)continue;let i=g(e).name,a=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let r of n){let n=s.has(e),i=a.length>0?`${t.cross} failed to load`:n?`${t.tick} enabled`:`${t.cross} disabled`,o=r.version||`unknown`,c=r.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${o}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${u(e)}`);console.log(``)}}if(_.length>0||v.length>0){console.log(`Session-only plugins (--plugin-dir):
3
- `);for(let e of _){let n=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${u(e)}`);console.log(``)}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${u(e)}\n`)}N()}async function ce(e,r){r.cowork&&n(!0);try{let n=await ie(e);n||P(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in n&&P(`${t.cross} ${n.error}`);let i=r.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&P(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=s(i),o=n;r.sparse&&r.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:r.sparse}:P(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:u,resolvedSource:d}=await te(o,e=>{console.log(e)});T(c,{source:d},a),l(),o.source,o.source===`github`&&o.repo,N(u?`${t.tick} Marketplace '${c}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${i} settings)`)}catch(e){Z(e,`add marketplace`)}}async function le(e){e.cowork&&n(!0);try{let n=await y(),r=Object.keys(n);e.json&&N(E(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&N(`No marketplaces configured`),console.log(`Configured marketplaces:
4
- `),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),N()}catch(e){Z(e,`list marketplaces`)}}async function $(e,r){r.cowork&&n(!0);try{await ee(e),l(),N(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Z(e,`remove marketplace`)}}async function ue(e,r){r.cowork&&n(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await b(e,e=>{console.log(e)}),l(),N(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await y(),n=Object.keys(e);n.length===0&&N(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await x(),l(),n.length,N(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Z(e,`update marketplace(s)`)}}async function de(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&P(`--cowork can only be used with user scope`),L.includes(r)||P(`Invalid scope: ${r}. Must be one of: ${L.join(`, `)}.`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await z(e,r)}async function fe(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&P(`--cowork can only be used with user scope`),L.includes(r)||P(`Invalid scope: ${r}. Must be one of: ${L.join(`, `)}.`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await R(e,r,t.keepData)}async function pe(e,t){t.cowork&&n(!0);let r;t.scope&&(L.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&P(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await H(e,r)}async function me(e,t){if(t.all&&e&&P(`Cannot use --all with a specific plugin`),!t.all&&!e&&P(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&n(!0),t.all){t.scope&&P(`Cannot use --scope with --all`),await U();return}let r;t.scope&&(L.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&P(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await B(e,r)}async function he(e,t){t.cowork&&n(!0);let{name:r,marketplace:i}=g(e);({...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(F.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${F.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&P(`--cowork can only be used with user scope`),await V(e,a)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,$ as marketplaceRemoveHandler,ue as marketplaceUpdateHandler,me as pluginDisableHandler,pe as pluginEnableHandler,de as pluginInstallHandler,se as pluginListHandler,fe as pluginUninstallHandler,he as pluginUpdateHandler,oe as pluginValidateHandler};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./poorMode-CG2JNTD0.js";t();export{e as isPoorModeActive};
@@ -1,13 +0,0 @@
1
- import{c as e,l as t,o as n,s as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./defineProperty-C-QyHrDq.js";import{$n as o,$t as s,Gi as c,Hi as l,Ni as u,Pi as d,U as f,Ui as p,Vi as m,Wi as h,Xi as g,Zi as _,bn as v,ca as y,d as b,di as ee,dr as te,ea as x,en as S,et as ne,fi as C,gt as w,ia as T,lt as re,m as ie,nt as ae,oa as E,pr as D,qi as O,sa as k,ta as A,tr as oe,u as se,ui as j,vn as M}from"./settings-D4M13toi.js";import{A as ce,Ft as le,Hn as ue,Ht as de,Mn as fe,O as pe,Pt as me,W as he,at as N,nn as ge,on as P,vn as _e,yn as ve}from"./state-CXY-q5gr.js";import{$d as F,$h as I,$r as ye,A as be,AC as xe,Aa as Se,Ad as Ce,Ag as L,As as R,Av as z,B as we,Bd as Te,Bl as Ee,Bo as De,Bp as Oe,Bt as ke,Bv as Ae,C as je,Cc as Me,Cg as Ne,Ci as Pe,Cs as Fe,Cv as Ie,DC as Le,Da as Re,Dc as ze,Dg as Be,Di as Ve,Ep as He,Fl as Ue,Fo as We,Gf as Ge,Gn as Ke,Gp as qe,Gu as Je,Gv as Ye,HC as Xe,Ho as Ze,Hp as Qe,Ia as $e,Id as et,Il as tt,Io as nt,Iv as rt,Ji as it,Jp as at,KC as ot,Kp as st,Kv as ct,Ll as lt,Lo as ut,Lr as dt,Mg as ft,Mi as pt,Ml as mt,Ms as ht,NC as gt,Nd as _t,Ni as vt,Nv as yt,Oa as bt,Od as xt,Og as St,Ov as Ct,PC as wt,Pa as Tt,Pg as Et,Ps as Dt,Qh as Ot,Qp as kt,Qr as At,Rd as jt,Ro as Mt,Rs as Nt,Sc as Pt,Sf as Ft,Sn as It,Sv as Lt,Ti as Rt,Tp as zt,Uh as Bt,Uo as Vt,Up as Ht,Us as Ut,V as Wt,VC as Gt,Vl as Kt,Vo as qt,Vp as Jt,Vt as Yt,WC as Xt,Wh as Zt,Wo as Qt,Wp as $t,Ws as en,Wv as tn,Xd as nn,Xr as rn,Yn as an,Yp as on,Yr as sn,_c as cn,_i as ln,_n as un,_u as dn,_v as fn,aC as pn,af as mn,ag as hn,ao as gn,b as _n,bS as vn,bc as yn,bn,bv as xn,cp as Sn,cs as Cn,dC as wn,eg as Tn,f as En,fC as Dn,fh as On,fo as kn,gi as An,gr as jn,gu as Mn,gv as Nn,hc as Pn,hf as Fn,hi as B,ho as In,iC as Ln,i_ as Rn,ig as zn,jC as Bn,jl as Vn,js as Hn,kd as Un,kv as Wn,lC as Gn,ls as Kn,mc as qn,mi as Jn,mn as Yn,n_ as Xn,o as Zn,of as Qn,oo as $n,ph as er,qC as tr,qS as nr,qf as rr,qp as ir,qu as ar,qx as or,rC as sr,r_ as cr,s as lr,sC as ur,sf as dr,ss as fr,t_ as pr,uC as mr,uf as hr,uo as gr,us as _r,uw as vr,v as yr,vc as br,vn as xr,vv as Sr,w as Cr,wc as wr,wg as Tr,wv as Er,xc as Dr,xf as Or,xn as kr,xs as Ar,y as jr,yf as Mr,yn as Nr,zd as Pr,zo as Fr,zp as V,zs as Ir,zv as Lr}from"./loadAgentsDir-bmpKLPdG.js";import{n as Rr,t as zr}from"./cwd-DrEEb4f5.js";import{$ as Br,C as H,E as Vr,I as Hr,M as U,S as Ur,V as Wr,c as W,et as Gr,f as Kr,i as G,u as qr,x as Jr}from"./debug-2pVES-2G.js";import{C as Yr,E as Xr}from"./config-Bio2EjUK.js";import{i as Zr,n as Qr,o as K}from"./process-gEbdy6uY.js";import{H as $r,c as ei,i as ti,o as ni,q as ri,s as q}from"./log-L1kqxa_P.js";import{n as ii}from"./analytics-COpjZpvd.js";import{At as ai,D as oi,Mt as si,Pt as ci,f as li,g as ui,jt as di,k as fi,r as pi,s as mi,v as hi}from"./model-Dd3x121y.js";import{at as gi,bn as _i,bt as vi,it as yi,tn as bi,vn as xi,xt as Si,yt as Ci}from"./prompt-BnDapYGL.js";import{n as wi,t as Ti}from"./sleep-xKMbXTJe.js";import{i as Ei,n as Di,r as Oi,t as ki}from"./reject-Tug1RmkE.js";import{t as Ai}from"./pluginBlocklist-ByRQaVPu.js";import{n as ji,t as Mi}from"./toolPool-BGfiNj6h.js";import{n as Ni}from"./conversationRecovery-_hWC7JBO.js";import{a as Pi,i as Fi,n as Ii,r as Li}from"./QueryEngine-DAwfp_ht.js";import{n as Ri,r as zi}from"./sessionTitle-k4wpUS5l.js";import{n as Bi,r as Vi}from"./sideQuestion-BJTVma-5.js";import{n as Hi,r as Ui}from"./context-noninteractive-BcBo64vo.js";import{n as Wi,r as Gi}from"./modelOptions-BQL4gbNk.js";import{a as Ki,o as qi,t as Ji}from"./skillChangeDetector-DlodgOyC.js";import{n as Yi}from"./reconciler-C_HKsocm.js";import{n as Xi,t as Zi}from"./refresh-Cm4jZzLa.js";import{dirname as Qi,join as $i}from"path";import{randomUUID as J}from"crypto";import{readFile as ea,stat as ta}from"fs/promises";import{cwd as Y}from"process";u(),s();var na=S(()=>A({inputTokens:x(),outputTokens:x(),cacheReadInputTokens:x(),cacheCreationInputTokens:x(),webSearchRequests:x(),costUSD:x(),contextWindow:x(),maxOutputTokens:x()})),ra=S(()=>_(`json_schema`));S(()=>A({type:ra()}));var ia=S(()=>A({type:_(`json_schema`),schema:T(E(),y())}));S(()=>ia());var aa=S(()=>m([`user`,`project`,`org`,`temporary`,`oauth`]));S(()=>m([`local`,`user`,`project`]).describe(`Config scope for settings.`)),S(()=>_(`context-1m-2025-08-07`));var oa=S(()=>A({type:_(`adaptive`)}).describe(`Work Mate decides when and how much to think (Opus 4.6+).`)),sa=S(()=>A({type:_(`enabled`),budgetTokens:x().optional()}).describe(`Fixed thinking token budget (older models)`)),ca=S(()=>A({type:_(`disabled`)}).describe(`No extended thinking`));S(()=>k([oa(),sa(),ca()]).describe(`Controls Work Mate's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var la=S(()=>A({type:_(`stdio`).optional(),command:E(),args:h(E()).optional(),env:T(E(),E()).optional()})),ua=S(()=>A({type:_(`sse`),url:E(),headers:T(E(),E()).optional()})),da=S(()=>A({type:_(`http`),url:E(),headers:T(E(),E()).optional()})),fa=S(()=>A({type:_(`sdk`),name:E()})),pa=S(()=>k([la(),ua(),da(),fa()])),ma=S(()=>A({type:_(`claudeai-proxy`),url:E(),id:E()})),ha=S(()=>k([pa(),ma()])),ga=S(()=>A({name:E().describe(`Server name as configured`),status:m([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:A({name:E(),version:E()}).optional().describe(`Server information (available when connected)`),error:E().optional().describe(`Error message (available when status is 'failed')`),config:ha().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:E().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:h(A({name:E(),description:E().optional(),annotations:A({readOnly:c().optional(),destructive:c().optional(),openWorld:c().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:A({experimental:T(E(),y()).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.`));S(()=>A({added:h(E()).describe(`Names of servers that were added`),removed:h(E()).describe(`Names of servers that were removed`),errors:T(E(),E()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var _a=S(()=>m([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),va=S(()=>m([`allow`,`deny`,`ask`])),ya=S(()=>A({toolName:E(),ruleContent:E().optional()})),ba=S(()=>O(`type`,[A({type:_(`addRules`),rules:h(ya()),behavior:va(),destination:_a()}),A({type:_(`replaceRules`),rules:h(ya()),behavior:va(),destination:_a()}),A({type:_(`removeRules`),rules:h(ya()),behavior:va(),destination:_a()}),A({type:_(`setMode`),mode:g(()=>Sa()),destination:_a()}),A({type:_(`addDirectories`),directories:h(E()),destination:_a()}),A({type:_(`removeDirectories`),directories:h(E()),destination:_a()})])),xa=S(()=>m([`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).`));S(()=>k([A({behavior:_(`allow`),updatedInput:T(E(),y()).optional(),updatedPermissions:h(ba()).optional(),toolUseID:E().optional(),decisionClassification:xa().optional()}),A({behavior:_(`deny`),message:E(),interrupt:c().optional(),toolUseID:E().optional(),decisionClassification:xa().optional()})]));var Sa=S(()=>m([`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=S(()=>m(Ca)),X=S(()=>A({session_id:E(),transcript_path:E(),cwd:E(),permission_mode:E().optional(),agent_id:E().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:E().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=S(()=>X().and(A({hook_event_name:_(`PreToolUse`),tool_name:E(),tool_input:y(),tool_use_id:E()}))),Ea=S(()=>X().and(A({hook_event_name:_(`PermissionRequest`),tool_name:E(),tool_input:y(),permission_suggestions:h(ba()).optional()}))),Da=S(()=>X().and(A({hook_event_name:_(`PostToolUse`),tool_name:E(),tool_input:y(),tool_response:y(),tool_use_id:E()}))),Oa=S(()=>X().and(A({hook_event_name:_(`PostToolUseFailure`),tool_name:E(),tool_input:y(),tool_use_id:E(),error:E(),is_interrupt:c().optional()}))),ka=S(()=>X().and(A({hook_event_name:_(`PermissionDenied`),tool_name:E(),tool_input:y(),tool_use_id:E(),reason:E()}))),Aa=S(()=>X().and(A({hook_event_name:_(`Notification`),message:E(),title:E().optional(),notification_type:E()}))),ja=S(()=>X().and(A({hook_event_name:_(`UserPromptSubmit`),prompt:E()}))),Ma=S(()=>X().and(A({hook_event_name:_(`SessionStart`),source:m([`startup`,`resume`,`clear`,`compact`]),agent_type:E().optional(),model:E().optional()}))),Na=S(()=>X().and(A({hook_event_name:_(`Setup`),trigger:m([`init`,`maintenance`])}))),Pa=S(()=>X().and(A({hook_event_name:_(`Stop`),stop_hook_active:c(),last_assistant_message:E().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Fa=S(()=>X().and(A({hook_event_name:_(`StopFailure`),error:No(),error_details:E().optional(),last_assistant_message:E().optional()}))),Ia=S(()=>X().and(A({hook_event_name:_(`SubagentStart`),agent_id:E(),agent_type:E()}))),La=S(()=>X().and(A({hook_event_name:_(`SubagentStop`),stop_hook_active:c(),agent_id:E(),agent_transcript_path:E(),agent_type:E(),last_assistant_message:E().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Ra=S(()=>X().and(A({hook_event_name:_(`PreCompact`),trigger:m([`manual`,`auto`]),custom_instructions:E().nullable()}))),za=S(()=>X().and(A({hook_event_name:_(`PostCompact`),trigger:m([`manual`,`auto`]),compact_summary:E().describe(`The conversation summary produced by compaction`)}))),Ba=S(()=>X().and(A({hook_event_name:_(`TeammateIdle`),teammate_name:E(),team_name:E()}))),Va=S(()=>X().and(A({hook_event_name:_(`TaskCreated`),task_id:E(),task_subject:E(),task_description:E().optional(),teammate_name:E().optional(),team_name:E().optional()}))),Ha=S(()=>X().and(A({hook_event_name:_(`TaskCompleted`),task_id:E(),task_subject:E(),task_description:E().optional(),teammate_name:E().optional(),team_name:E().optional()}))),Ua=S(()=>X().and(A({hook_event_name:_(`Elicitation`),mcp_server_name:E(),message:E(),mode:m([`form`,`url`]).optional(),url:E().optional(),elicitation_id:E().optional(),requested_schema:T(E(),y()).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=S(()=>X().and(A({hook_event_name:_(`ElicitationResult`),mcp_server_name:E(),elicitation_id:E().optional(),mode:m([`form`,`url`]).optional(),action:m([`accept`,`decline`,`cancel`]),content:T(E(),y()).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=S(()=>X().and(A({hook_event_name:_(`ConfigChange`),source:m(Ga),file_path:E().optional()}))),qa=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Ja=[`User`,`Project`,`Local`,`Managed`],Ya=S(()=>X().and(A({hook_event_name:_(`InstructionsLoaded`),file_path:E(),memory_type:m(Ja),load_reason:m(qa),globs:h(E()).optional(),trigger_file_path:E().optional(),parent_file_path:E().optional()}))),Xa=S(()=>X().and(A({hook_event_name:_(`WorktreeCreate`),name:E()}))),Za=S(()=>X().and(A({hook_event_name:_(`WorktreeRemove`),worktree_path:E()}))),Qa=S(()=>X().and(A({hook_event_name:_(`CwdChanged`),old_cwd:E(),new_cwd:E()}))),$a=S(()=>X().and(A({hook_event_name:_(`FileChanged`),file_path:E(),event:m([`change`,`add`,`unlink`])}))),eo=[`clear`,`resume`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],to=S(()=>m(eo)),no=S(()=>X().and(A({hook_event_name:_(`SessionEnd`),reason:to()}))),ro=S(()=>k([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=S(()=>A({async:_(!0),asyncTimeout:x().optional()})),ao=S(()=>A({hookEventName:_(`PreToolUse`),permissionDecision:va().optional(),permissionDecisionReason:E().optional(),updatedInput:T(E(),y()).optional(),additionalContext:E().optional()})),oo=S(()=>A({hookEventName:_(`UserPromptSubmit`),additionalContext:E().optional()})),so=S(()=>A({hookEventName:_(`SessionStart`),additionalContext:E().optional(),initialUserMessage:E().optional(),watchPaths:h(E()).optional()})),co=S(()=>A({hookEventName:_(`Setup`),additionalContext:E().optional()})),lo=S(()=>A({hookEventName:_(`SubagentStart`),additionalContext:E().optional()})),uo=S(()=>A({hookEventName:_(`PostToolUse`),additionalContext:E().optional(),updatedMCPToolOutput:y().optional()})),fo=S(()=>A({hookEventName:_(`PostToolUseFailure`),additionalContext:E().optional()})),po=S(()=>A({hookEventName:_(`PermissionDenied`),retry:c().optional()})),mo=S(()=>A({hookEventName:_(`Notification`),additionalContext:E().optional()})),ho=S(()=>A({hookEventName:_(`PermissionRequest`),decision:k([A({behavior:_(`allow`),updatedInput:T(E(),y()).optional(),updatedPermissions:h(ba()).optional()}),A({behavior:_(`deny`),message:E().optional(),interrupt:c().optional()})])})),go=S(()=>A({hookEventName:_(`CwdChanged`),watchPaths:h(E()).optional()})),_o=S(()=>A({hookEventName:_(`FileChanged`),watchPaths:h(E()).optional()})),vo=S(()=>A({continue:c().optional(),suppressOutput:c().optional(),stopReason:E().optional(),decision:m([`approve`,`block`]).optional(),systemMessage:E().optional(),reason:E().optional(),hookSpecificOutput:k([ao(),oo(),so(),co(),lo(),uo(),fo(),po(),mo(),ho(),yo(),bo(),go(),_o(),xo()]).optional()})),yo=S(()=>A({hookEventName:_(`Elicitation`),action:m([`accept`,`decline`,`cancel`]).optional(),content:T(E(),y()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),bo=S(()=>A({hookEventName:_(`ElicitationResult`),action:m([`accept`,`decline`,`cancel`]).optional(),content:T(E(),y()).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=S(()=>A({hookEventName:_(`WorktreeCreate`),worktreePath:E()}).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.`));S(()=>k([io(),vo()]));var So=S(()=>A({key:E().describe(`Unique key for this option, returned in the response`),label:E().describe(`Display text for this option`),description:E().optional().describe(`Optional description shown below the label`)}));S(()=>A({prompt:E().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:E().describe(`The prompt message to display to the user`),options:h(So()).describe(`Available options for the user to choose from`)})),S(()=>A({prompt_response:E().describe(`The request ID from the corresponding prompt request`),selected:E().describe(`The key of the selected option`)}));var Co=S(()=>A({name:E().describe(`Skill name (without the leading slash)`),description:E().describe(`Description of what the skill does`),argumentHint:E().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),wo=S(()=>A({name:E().describe(`Agent type identifier (e.g., "Explore")`),description:E().describe(`Description of when to use this agent`),model:E().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=S(()=>A({value:E().describe(`Model identifier to use in API calls`),displayName:E().describe(`Human-readable display name`),description:E().describe(`Description of the model's capabilities`),supportsAdaptiveThinking:c().optional().describe(`Whether this model supports adaptive thinking (Work Mate decides when and how much to think)`),supportsFastMode:c().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:c().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),Eo=S(()=>A({email:E().optional(),organization:E().optional(),subscriptionType:E().optional(),tokenSource:E().optional(),apiKeySource:E().optional(),apiProvider:m([`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=S(()=>k([E(),T(E(),pa())])),Oo=S(()=>A({description:E().describe(`Natural language description of when to use this agent`),tools:h(E()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:h(E()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:E().describe(`The agent's system prompt`),model:E().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:h(Do()).optional(),criticalSystemReminder_EXPERIMENTAL:E().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:h(E()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:E().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:x().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:c().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:m([`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.`));S(()=>m([`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).`)),S(()=>A({type:_(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:E().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),S(()=>A({canRewind:c(),error:E().optional(),filesChanged:h(E()).optional(),insertions:x().optional(),deletions:x().optional()}).describe(`Result of a rewindFiles operation.`));var ko=S(()=>y()),Ao=S(()=>y()),jo=S(()=>y()),Z=S(()=>E()),Mo=S(()=>y()),No=S(()=>m([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),Po=S(()=>k([_(`compacting`),l()])),Fo=S(()=>A({type:_(`user`),message:ko(),parent_tool_use_id:E().nullable(),isSynthetic:c().optional(),tool_use_result:y().optional(),priority:m([`now`,`next`,`later`]).optional(),timestamp:E().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=S(()=>Fo().extend({uuid:Z().optional(),session_id:E().optional()})),Lo=S(()=>Fo().extend({uuid:Z(),session_id:E(),isReplay:_(!0)})),Ro=S(()=>A({status:m([`allowed`,`allowed_warning`,`rejected`]),resetsAt:x().optional(),rateLimitType:m([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:x().optional(),overageStatus:m([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:x().optional(),overageDisabledReason:m([`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:c().optional(),surpassedThreshold:x().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),zo=S(()=>A({type:_(`assistant`),message:Ao(),parent_tool_use_id:E().nullable(),error:No().optional(),uuid:Z(),session_id:E()})),Bo=S(()=>A({type:_(`rate_limit_event`),rate_limit_info:Ro(),uuid:Z(),session_id:E()}).describe(`Rate limit event emitted when rate limit info changes.`)),Vo=S(()=>A({type:_(`streamlined_text`),text:E().describe(`Text content preserved from the assistant message`),session_id:E(),uuid:Z()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),Ho=S(()=>A({type:_(`streamlined_tool_use_summary`),tool_summary:E().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:E(),uuid:Z()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),Uo=S(()=>A({tool_name:E(),tool_use_id:E(),tool_input:T(E(),y())})),Wo=S(()=>A({type:_(`result`),subtype:_(`success`),duration_ms:x(),duration_api_ms:x(),is_error:c(),num_turns:x(),result:E(),stop_reason:E().nullable(),total_cost_usd:x(),usage:Mo(),modelUsage:T(E(),na()),permission_denials:h(Uo()),structured_output:y().optional(),fast_mode_state:ms().optional(),uuid:Z(),session_id:E()})),Go=S(()=>A({type:_(`result`),subtype:m([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:x(),duration_api_ms:x(),is_error:c(),num_turns:x(),stop_reason:E().nullable(),total_cost_usd:x(),usage:Mo(),modelUsage:T(E(),na()),permission_denials:h(Uo()),errors:h(E()),fast_mode_state:ms().optional(),uuid:Z(),session_id:E()})),Ko=S(()=>k([Wo(),Go()])),qo=S(()=>A({type:_(`system`),subtype:_(`init`),agents:h(E()).optional(),apiKeySource:aa(),betas:h(E()).optional(),claude_code_version:E(),cwd:E(),tools:h(E()),mcp_servers:h(A({name:E(),status:E()})),model:E(),permissionMode:Sa(),slash_commands:h(E()),output_style:E(),skills:h(E()),plugins:h(A({name:E(),path:E(),source:E().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:E()})),Jo=S(()=>A({type:_(`stream_event`),event:jo(),parent_tool_use_id:E().nullable(),uuid:Z(),session_id:E()})),Yo=S(()=>A({type:_(`system`),subtype:_(`compact_boundary`),compact_metadata:A({trigger:m([`manual`,`auto`]),pre_tokens:x(),preserved_segment:A({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:E()})),Xo=S(()=>A({type:_(`system`),subtype:_(`status`),status:Po(),permissionMode:Sa().optional(),uuid:Z(),session_id:E()})),Zo=S(()=>A({type:_(`system`),subtype:_(`post_turn_summary`),summarizes_uuid:E(),status_category:m([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:E(),is_noteworthy:c(),title:E(),description:E(),recent_action:E(),needs_action:E(),artifact_urls:h(E()),uuid:Z(),session_id:E()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),Qo=S(()=>A({type:_(`system`),subtype:_(`api_retry`),attempt:x(),max_retries:x(),retry_delay_ms:x(),error_status:x().nullable(),error:No(),uuid:Z(),session_id:E()}).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=S(()=>A({type:_(`system`),subtype:_(`local_command_output`),content:E(),uuid:Z(),session_id:E()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),es=S(()=>A({type:_(`system`),subtype:_(`hook_started`),hook_id:E(),hook_name:E(),hook_event:E(),uuid:Z(),session_id:E()})),ts=S(()=>A({type:_(`system`),subtype:_(`hook_progress`),hook_id:E(),hook_name:E(),hook_event:E(),stdout:E(),stderr:E(),output:E(),uuid:Z(),session_id:E()})),ns=S(()=>A({type:_(`system`),subtype:_(`hook_response`),hook_id:E(),hook_name:E(),hook_event:E(),output:E(),stdout:E(),stderr:E(),exit_code:x().optional(),outcome:m([`success`,`error`,`cancelled`]),uuid:Z(),session_id:E()})),rs=S(()=>A({type:_(`tool_progress`),tool_use_id:E(),tool_name:E(),parent_tool_use_id:E().nullable(),elapsed_time_seconds:x(),task_id:E().optional(),uuid:Z(),session_id:E()})),is=S(()=>A({type:_(`auth_status`),isAuthenticating:c(),output:h(E()),error:E().optional(),uuid:Z(),session_id:E()})),as=S(()=>A({type:_(`system`),subtype:_(`files_persisted`),files:h(A({filename:E(),file_id:E()})),failed:h(A({filename:E(),error:E()})),processed_at:E(),uuid:Z(),session_id:E()})),os=S(()=>A({type:_(`system`),subtype:_(`task_notification`),task_id:E(),tool_use_id:E().optional(),status:m([`completed`,`failed`,`stopped`]),output_file:E(),summary:E(),usage:A({total_tokens:x(),tool_uses:x(),duration_ms:x()}).optional(),uuid:Z(),session_id:E()})),ss=S(()=>A({type:_(`system`),subtype:_(`task_started`),task_id:E(),tool_use_id:E().optional(),description:E(),task_type:E().optional(),workflow_name:E().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:E().optional(),uuid:Z(),session_id:E()})),cs=S(()=>A({type:_(`system`),subtype:_(`session_state_changed`),state:m([`idle`,`running`,`requires_action`]),uuid:Z(),session_id:E()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),ls=S(()=>A({type:_(`system`),subtype:_(`task_progress`),task_id:E(),tool_use_id:E().optional(),description:E(),usage:A({total_tokens:x(),tool_uses:x(),duration_ms:x()}),last_tool_name:E().optional(),summary:E().optional(),uuid:Z(),session_id:E()})),us=S(()=>A({type:_(`tool_use_summary`),summary:E(),preceding_tool_use_ids:h(E()),uuid:Z(),session_id:E()})),ds=S(()=>A({type:_(`system`),subtype:_(`elicitation_complete`),mcp_server_name:E(),elicitation_id:E(),uuid:Z(),session_id:E()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),fs=S(()=>A({type:_(`prompt_suggestion`),suggestion:E(),uuid:Z(),session_id:E()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));S(()=>A({sessionId:E().describe(`Unique session identifier (UUID).`),summary:E().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:x().describe(`Last modified time in milliseconds since epoch.`),fileSize:x().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:E().optional().describe(`User-set session title via /rename.`),firstPrompt:E().optional().describe(`First meaningful user prompt in the session.`),gitBranch:E().optional().describe(`Git branch at the end of the session.`),cwd:E().optional().describe(`Working directory for the session.`),tag:E().optional().describe(`User-set session tag.`),createdAt:x().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=S(()=>k([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=S(()=>m([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));u(),s();var hs=S(()=>y()),gs=S(()=>A({matcher:E().optional(),hookCallbackIds:h(E()),timeout:x().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),_s=S(()=>A({subtype:_(`initialize`),hooks:T(wa(),h(gs())).optional(),sdkMcpServers:h(E()).optional(),jsonSchema:T(E(),y()).optional(),systemPrompt:E().optional(),appendSystemPrompt:E().optional(),agents:T(E(),Oo()).optional(),promptSuggestions:c().optional(),agentProgressSummaries:c().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));S(()=>A({commands:h(Co()),agents:h(wo()),output_style:E(),available_output_styles:h(E()),models:h(To()),account:Eo(),pid:x().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=S(()=>A({subtype:_(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),ys=S(()=>A({subtype:_(`can_use_tool`),tool_name:E(),input:T(E(),y()),permission_suggestions:h(ba()).optional(),blocked_path:E().optional(),decision_reason:E().optional(),title:E().optional(),display_name:E().optional(),tool_use_id:E(),agent_id:E().optional(),description:E().optional()}).describe(`Requests permission to use a tool with the given input.`)),bs=S(()=>A({subtype:_(`set_permission_mode`),mode:Sa()}).describe(`Sets the permission mode for tool execution handling.`)),xs=S(()=>A({subtype:_(`set_model`),model:E().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),Ss=S(()=>A({subtype:_(`set_max_thinking_tokens`),max_thinking_tokens:x().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Cs=S(()=>A({subtype:_(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));S(()=>A({mcpServers:h(ga())}).describe(`Response containing the current status of all MCP server connections.`));var ws=S(()=>A({subtype:_(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),Ts=S(()=>A({name:E(),tokens:x(),color:E(),isDeferred:c().optional()})),Es=S(()=>A({color:E(),isFilled:c(),categoryName:E(),tokens:x(),percentage:x(),squareFullness:x()}));S(()=>A({categories:h(Ts()),totalTokens:x(),maxTokens:x(),rawMaxTokens:x(),percentage:x(),gridRows:h(h(Es())),model:E(),memoryFiles:h(A({path:E(),type:E(),tokens:x()})),mcpTools:h(A({name:E(),serverName:E(),tokens:x(),isLoaded:c().optional()})),deferredBuiltinTools:h(A({name:E(),tokens:x(),isLoaded:c()})).optional(),systemTools:h(A({name:E(),tokens:x()})).optional(),systemPromptSections:h(A({name:E(),tokens:x()})).optional(),agents:h(A({agentType:E(),source:E(),tokens:x()})),slashCommands:A({totalCommands:x(),includedCommands:x(),tokens:x()}).optional(),skills:A({totalSkills:x(),includedSkills:x(),tokens:x(),skillFrontmatter:h(A({name:E(),source:E(),tokens:x()}))}).optional(),autoCompactThreshold:x().optional(),isAutoCompactEnabled:c(),messageBreakdown:A({toolCallTokens:x(),toolResultTokens:x(),attachmentTokens:x(),assistantMessageTokens:x(),userMessageTokens:x(),toolCallsByType:h(A({name:E(),callTokens:x(),resultTokens:x()})),attachmentsByType:h(A({name:E(),tokens:x()}))}).optional(),apiUsage:A({input_tokens:x(),output_tokens:x(),cache_creation_input_tokens:x(),cache_read_input_tokens:x()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var Ds=S(()=>A({subtype:_(`rewind_files`),user_message_id:E(),dry_run:c().optional()}).describe(`Rewinds file changes made since a specific user message.`));S(()=>A({canRewind:c(),error:E().optional(),filesChanged:h(E()).optional(),insertions:x().optional(),deletions:x().optional()}).describe(`Result of a rewindFiles operation.`));var Os=S(()=>A({subtype:_(`cancel_async_message`),message_uuid:E()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));S(()=>A({cancelled:c()}).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=S(()=>A({subtype:_(`seed_read_state`),path:E(),mtime:x()}).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=S(()=>A({subtype:_(`hook_callback`),callback_id:E(),input:ro(),tool_use_id:E().optional()}).describe(`Delivers a hook callback with its input data.`)),js=S(()=>A({subtype:_(`mcp_message`),server_name:E(),message:hs()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),Ms=S(()=>A({subtype:_(`mcp_set_servers`),servers:T(E(),pa())}).describe(`Replaces the set of dynamically managed MCP servers.`));S(()=>A({added:h(E()),removed:h(E()),errors:T(E(),E())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var Ns=S(()=>A({subtype:_(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));S(()=>A({commands:h(Co()),agents:h(wo()),plugins:h(A({name:E(),path:E(),source:E().optional()})),mcpServers:h(ga()),error_count:x()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var Ps=S(()=>A({subtype:_(`mcp_reconnect`),serverName:E()}).describe(`Reconnects a disconnected or failed MCP server.`)),Fs=S(()=>A({subtype:_(`mcp_toggle`),serverName:E(),enabled:c()}).describe(`Enables or disables an MCP server.`)),Is=S(()=>A({subtype:_(`stop_task`),task_id:E()}).describe(`Stops a running task.`)),Ls=S(()=>A({subtype:_(`apply_flag_settings`),settings:T(E(),y())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),Rs=S(()=>A({subtype:_(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));S(()=>A({effective:T(E(),y()),sources:h(A({source:m([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:T(E(),y())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:A({model:E()}).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=S(()=>A({subtype:_(`elicitation`),mcp_server_name:E(),message:E(),mode:m([`form`,`url`]).optional(),url:E().optional(),elicitation_id:E().optional(),requested_schema:T(E(),y()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),Bs=S(()=>A({action:m([`accept`,`decline`,`cancel`]),content:T(E(),y()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),Vs=S(()=>k([vs(),ys(),_s(),bs(),xs(),Ss(),Cs(),ws(),As(),js(),Ds(),Os(),ks(),Ms(),Ns(),Ps(),Fs(),Is(),Ls(),Rs(),zs()])),Hs=S(()=>A({type:_(`control_request`),request_id:E(),request:Vs()})),Us=S(()=>A({subtype:_(`success`),request_id:E(),response:T(E(),y()).optional()})),Ws=S(()=>A({subtype:_(`error`),request_id:E(),error:E(),pending_permission_requests:h(g(()=>Hs())).optional()})),Gs=S(()=>A({type:_(`control_response`),response:k([Us(),Ws()])})),Ks=S(()=>A({type:_(`control_cancel_request`),request_id:E()}).describe(`Cancels a currently open control request.`)),qs=S(()=>A({type:_(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),Js=S(()=>A({type:_(`update_environment_variables`),variables:T(E(),E())}).describe(`Updates environment variables at runtime.`));S(()=>k([ps(),Vo(),Ho(),Zo(),Gs(),Hs(),Ks(),qs()])),S(()=>k([Io(),Hs(),Gs(),qs(),Js()])),n(),i(),me(),Br(),Hr(),Jr(),Kr(),Qr(),j(),bn(),u(),G(),s(),ft(),kr(),S(()=>d.object({tool_name:d.string().describe(`The name of the tool requesting permission`),input:d.record(d.string(),d.unknown()).describe(`The input for the tool`),tool_use_id:d.string().optional().describe(`The unique tool use request ID`)}));var Ys=S(()=>d.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),Xs=S(()=>d.object({behavior:d.literal(`allow`),updatedInput:d.record(d.string(),d.unknown()),updatedPermissions:d.array(It()).optional().catch(e=>{W(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:d.string().optional(),decisionClassification:Ys()})),Zs=S(()=>d.object({behavior:d.literal(`deny`),message:d.string(),interrupt:d.boolean().optional(),toolUseID:d.string().optional(),decisionClassification:Ys()})),Qs=S(()=>d.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:L(e.toolPermissionContext,t)})),Et(t));let a=Object.keys(e.updatedInput).length>0?e.updatedInput:n;return{...e,updatedInput:a,decisionReason:i}}else e.behavior===`deny`&&e.interrupt&&(W(`SDK permission prompt deny+interrupt: tool=${t.name} message=${e.message}`),r.abortController.abort());return{...e,decisionReason:i}}Rr(),ri(),ni(),D(),M(),w(),ae(),ie(),xi(),bi(),Xt(),Gn(),ur(),Ae(),z(),xn(),Tr(),Ht(),zt(),mt(),Pt(),Pn(),Kn(),Cn(),it(),pt(),An(),jn(),xr(),Yn(),Wt();var ec=/\u2028|\u2029/g;function tc(e){return e.replace(ec,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function nc(e){return tc(H(e))}G(),Jr(),u(),ft();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 Dr),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(`${H({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&&(ee(`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=Ur(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;W(`[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&&$t(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)){W(`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`){W(`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){K(`${nc(e)}\n`)}async sendRequest(e,t,n,r=J()){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 Vr))};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 we(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=J();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&&tt(`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},Nr(),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:J(),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},A({mcp_response:p()}))).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=Yt(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){Et(i);let e=L(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`}}}}Ci(),f(),Si(),[...vi],G();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`),W(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a}),Gr(async()=>{Q.length>0&&($&&fc(Q)?$(`${Q}\n`):process.stderr.write(`${uc} ${Q}\n`),Q=``),$&&(process.stdout.write=$,$=null),dc=!1}))}Yr(),wn(),vn(),gi(),Ye(),hr(),F(),ze(),Fe(),Ze(),gr(),Tt(),Zn(),Mi(),G(),Hr(),Rr(),Hr(),ni(),vr(),G();function mc(e){let t=process.env.WORKMATE_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&&(W(`Exiting after ${n}ms of idle time`),B())},n))},stop(){i&&(clearTimeout(i),i=null)}}}ci(),fi(),li(),xe(),Oi(),ki(),sr(),pr(),Zt(),en(),Nt(),R(),bt(),_n(),zi(),Bi();function hc(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:J(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(He(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:J(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}ai(),Be(),hn(),er(),kt(),at(),Jt(),Sn(),Mr(),et(),Je(),cn(),Ui(),Gi(),G(),Jr();async function gc(){try{let e=await ea(Fr(),`utf-8`),t=re().safeParse(Ur(e));return t.success?t.data:(W(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function _c(e){await We(Fr(),H(e,null,2))}async function vc(e,t){let n=Mt();if(!n)return;let r=await yc(t);r!==null&&await We($i(n,ut(e)),r)}async function yc(e){let t=[$i(e,`.claude-plugin`,`marketplace.json`),$i(e,`marketplace.json`),e];for(let e of t)try{return await ea(e,`utf-8`)}catch{}return null}async function bc(){let e=await kn();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await vc(t,n.installLocation)}catch(e){W(`Failed to save marketplace JSON for ${t}: ${e}`)}await _c({...await gc(),...e})}ii(),Br(),G(),j(),ni(),gr(),Ze();async function xc(){let e=Qt();W(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await In();t&&(gn(),Se(`headlessPluginInstall: seed marketplaces registered`)),e&&(await qr().mkdir(De()),await qr().mkdir(qt()));let n=Object.keys($n()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)W(`installPluginsForHeadless: no marketplaces declared`);else{let t=await C(`headless_marketplace_reconcile`,()=>Yi({skip:e?(e,t)=>!Vt(t):void 0,onProgress:e=>{e.type===`installed`?W(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&W(`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&&W(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(gn(),Se(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await bc();let t=await Ai();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&Se(`headlessPluginInstall: plugins changed`),e&&Gr(nt),i}catch(e){return q(e),!1}}o(),ii(),G(),j(),Ht(),mt(),ni(),Qr(),zt(),An(),Br(),Rr(),Wt(),Yn(),it(),Jr(),Zi(),Tt(),fn(),Mn(),Ee(),Hr(),Ti();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(mr.subscribe(e=>{Bt(e,r),gt()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),!ot()&&t(process.env.WORKMATE_PROACTIVE)&&Gt(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),Oe(),V(`runHeadless_entry`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
5
- `),B(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
6
- `),B(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
7
- `),B(1);return}let l=zc(e,c);c.outputFormat===`stream-json`&&pc();let u=pn.getSandboxUnavailableReason();if(u){if(pn.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),B(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(pn.isSandboxingEnabled())try{await pn.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${U(e)}\n`),B(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&_r(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:J(),session_id:N()};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:J(),session_id:N()};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:J(),session_id:N()}}})();l.write(t)}),c.setupTrigger&&await cr(c.setupTrigger),V(`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=Rn();if(h&&l.prependUserMessage(h),!c.agent&&!he()&&m){let{agentDefinition:e}=Ki(m,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!lr(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}At(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`),B(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`),B(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),B(0);return}let g=typeof c.resume==`string`&&(!!He(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
- `),B(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
9
- `),B(1);return}let v=wr(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}})),tt(`requires_action`,e)});c.permissionPromptToolName&&(y=y.filter(e=>!_i(e,c.permissionPromptToolName))),Zr(),V(`after_loadInitialMessages`),await oi(),V(`after_modelStrings`);let ee=c.outputFormat===`json`&&c.verbose,te=[],x;V(`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`&&(ee&&te.push(e),x=e);switch(c.outputFormat){case`json`:if(x?.type!==`result`)throw Error(`No messages returned`);if(c.verbose){K(`${H(te)}\n`);break}K(`${H(x)}\n`);break;case`stream-json`:break;default:if(x?.type!==`result`)throw Error(`No messages returned`);switch(x.subtype){case`success`:K(x.result.endsWith(`
10
- `)?x.result:`${x.result}\n`);break;case`error_during_execution`:K(`Execution error`);break;case`error_max_turns`:K(`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`:K(`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`:K(`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(Qe(),Xr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-CVUrBFMj.js`);await e()}catch{}B(x?.type===`result`&&x?.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`,()=>{ee(`info`,`shutdown_signal`,{signal:`SIGINT`}),y&&!y.signal.aborted&&y.abort(),Jn(0)}),Gr(async()=>{let e={};for(let t of Nn(u()))dn(t)&&(e[t.type]=(e[t.type]??0)+1);ee(`info`,`run_state_at_shutdown`,{run_active:h,run_phase:g,worker_status:Vn(),internal_events_pending:n.internalEventsPending,bg_tasks:e})}),lt(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&b.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:J(),session_id:N()})});let x={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},S=e=>{let t=Fi(e);t&&b.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:J(),session_id:N()})};Ir.add(S);let C=s,w=Ar(s,Y(),100),T=tn(100),re=process.env.WORKMATE_RESUME_INTERRUPTED_TURN;m&&m.kind!==`none`&&re&&(W(`[print.ts] Auto-resuming interrupted turn (kind: ${m.kind})`),Lc(C,m.message),Er({mode:`prompt`,value:m.message.message.content,uuid:J()}));let ie=Wi().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?pi():hi(t),r=ar(n),i=wt(e.value),a=Ln(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),ae=p.userSpecifiedModel;function E(e,t){let n=or(e,ui(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:N(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let D=[],O=[],k=new Set;function A(e){for(let t of e){if(t.type!==`connected`||k.has(t.name)||t.config.type===`sdk`)continue;let e=t.name;try{t.client.setRequestHandler(Ge,async(t,r)=>{ei(e,`Elicitation request received in print mode: ${H(t)}`);let i=t.params.mode===`url`?`url`:`form`,a=await Or(e,t.params,r.signal);if(a)return ei(e,`Elicitation resolved by hook: ${H(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 Ft(e,l,r.signal,i,c);return u.action,u}),t.client.setNotificationHandler(rr,t=>{let{elicitationId:n}=t.params;ei(e,`Elicitation completion notification: ${n}`),ke({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:J(),session_id:N()})}),k.add(e)}catch{}}}async function j(){let e=new Set(Object.keys(l)),t=new Set(D.map(e=>e.name)),r=Array.from(e).some(e=>!t.has(e)),i=Array.from(t).some(t=>!e.has(t)),a=D.some(e=>e.type===`pending`),o=D.some(e=>e.type===`failed`);if(r||i||a||o){for(let t of D)e.has(t.name)||t.type===`connected`&&await t.cleanup();let r=await Pr(l,(e,t)=>n.sendMcpMessage(e,t));D=r.clients,O=r.tools;let i=oe([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(ne(t)))),...O]}})),St(D)}}j();let M={clients:[],tools:[],configs:{}},le=e=>{let t=Me(e.toolPermissionContext,e.mcp.tools),n=Dn(ji([...o,...O,...M.tools],t,e.toolPermissionContext.mode),`name`);p.permissionPromptToolName&&(n=n.filter(e=>!_i(e,p.permissionPromptToolName)));let r=ce();if(r&&!p.jsonSchema){let e=yi(r);`tool`in e&&(n=[...n,e.tool])}return n},ue=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function de(e){let t=async()=>{let t=new Set(D.map(e=>e.name)),n=await Hc(e,{configs:l,clients:D,tools:O},M,d);for(let e of Object.keys(l))delete l[e];if(Object.assign(l,n.newSdkState.configs),D=n.newSdkState.clients,O=n.newSdkState.tools,M=n.newDynamicState,n.sdkServersChanged){let e=new Set(D.map(e=>e.name)),n=oe([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(ne(t)))),...O]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return ue=ue.then(t,t),ue}function me(){let e=u(),t=e.mcp.clients,n=Dn([...e.mcp.tools,...M.tools],`name`),r=new Set([...t.map(e=>e.name),...D.map(e=>e.name)]);return[...t,...D,...M.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`?nn(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 he(){try{await xc()&&await xe()}catch(e){q(e)}}let P=null;r()||(t(process.env.WORKMATE_SYNC_PLUGIN_INSTALL)?P=he():he());let ve=mc(()=>!h),F=a,I=f;async function be(){let{agentDefinitions:e}=await Xi(d);F=await Ve(Y());let t=I.filter(e=>e.source===`flagSettings`);I=[...e.allAgents,...t]}async function xe(){let{servers:e}=await Qn(),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 de(t);r&&j(),W(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Se=Ji.subscribe(()=>{Pe(),Ve(Y()).then(e=>{F=e})}),Ce=()=>{setTimeout(()=>{!ot()||tr()||_||(async()=>{let e=await on({basePrompt:`<${$r}>${new Date().toLocaleTimeString()}</${$r}>`,currentDir:Y(),shouldCreate:()=>!_});if(_){await qe({commands:e});return}for(let t of e)Er({...t,uuid:J()});L()})().catch(e=>{q(e),W(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};rt(()=>{y&&Ct(`now`).length>0&&y.abort(`interrupt`)});let L=async()=>{if(h)return;if(h=!0,g=void 0,tt(`running`),ve.stop(),V(`run_entry`),await j(),V(`after_updateSdkMcp`),P){let e=parseInt(process.env.WORKMATE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=wi(e).then(()=>`timeout`);await Promise.race([P,t])===`timeout`&&q(Error(`WORKMATE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`))}else await P;P=null,await be();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-BIfM53-_.js`);t()}let t=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=Lt(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,yt(t));)i.push(Lt(t));let a=await st(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:N(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...D,...M.clients];A(l);let f=le(s);for(let e of o)$t(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:N(),uuid:J()})}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`&&Hn(x.lastEmitted.text,e,x.lastEmitted.emittedAt,x.lastEmitted.promptId,x.lastEmitted.generationRequestId),x.lastEmitted=null}y=Lr(),V(`before_ask`),yn();let g=r,_=!1;try{if(await di(g.workload??p.workload,async()=>{for await(let e of Ii({commands:Dn([...F,...s.mcp.commands],`name`),prompt:m,promptUuid:g.uuid,isMeta:g.isMeta,cwd:Y(),tools:f,verbose:p.verbose,mcpClients:l,thinkingConfig:p.thinkingConfig,maxTurns:p.maxTurns,maxBudgetUsd:p.maxBudgetUsd,taskBudget:p.taskBudget,canUseTool:c,userSpecifiedModel:ae,fallbackModel:p.fallbackModel,jsonSchema:ce()??p.jsonSchema,mutableMessages:C,getReadFileCache:()=>T.size===0?w:ct(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:I,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{b.enqueue({type:`system`,subtype:`status`,status:e,session_id:N(),uuid:J()})}}))if(e.type===`result`){_=!!e.is_error;for(let e of Sr())b.enqueue(e);Nn(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&dn(e))?v=e:(v=null,b.enqueue(e))}else{for(let e of Sr())b.enqueue(e);b.enqueue(e)}}),_)await ir({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:Y(),priority:`later`,workload:g.workload??p.workload});else{let e=await ir({commands:h,outcome:{type:`completed`},currentDir:Y(),priority:`later`,workload:g.workload??p.workload});for(let t of e)Er({...t,uuid:J()})}}catch(e){throw await ir({commands:h,outcome:{type:`failed`,error:e},currentDir:Y(),priority:`later`,workload:g.workload??p.workload}),e}for(let e of o)$t(e,`completed`);if(p.promptSuggestions&&!e(process.env.WORKMATE_ENABLE_PROMPT_SUGGESTION)){x.abortController?.abort();let e=new AbortController;x.abortController=e;let t=Ut();if(!t)ht(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await Dt(e,C,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:J(),session_id:N()},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`)){ht(`aborted`,void 0,void 0,`sdk`);return}q(Wr(e))}finally{x.inflightPromise===n.promise&&(x.inflightPromise=null)}})(),x.inflightPromise=n.promise}}Qe(),br(),Oe()}};do{for(let e of Sr())b.enqueue(e);g=`draining_commands`,await a(),i=!1;{let e=Nn(u()).some(e=>dn(e)),n=yt(t)!==void 0;(e||n)&&(i=!0,n||(g=`waiting_for_agents`,await wi(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:N(),total_cost_usd:0,usage:nr,modelUsage:{},permission_denials:[],uuid:J(),errors:[U(e),...ti().map(e=>e.error)]})}catch{}x.abortController?.abort(),B(1);return}finally{if(g=`finally_flush`,await n.flushInternalEvents(),g=`finally_post_flush`,!ln()){tt(`idle`);for(let e of Sr())b.enqueue(e)}h=!1,ve.start()}if(ot()&&!tr()&&yt(t)===void 0&&!_){Ce();return}if(yt(t)!==void 0){L();return}_&&(x.inflightPromise&&await Promise.race([x.inflightPromise,wi(5e3)]),x.abortController?.abort(),x.abortController=null,await fr(),Se(),Ir.delete(S),b.done())},R=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},z=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},we=new Set;return n.setUnexpectedResponseCallback(async e=>{await Bc({message:e,setAppState:d,handledToolUseIds:we,onEnqueued:()=>{L()}})}),(async()=>{let e=!1;ee(`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`&&$t(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,R(r);else if(o.subtype===`end_session`){W(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,R(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,ie,n,p,f,u),r.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),r.request.agentProgressSummaries&&fe(!0),e=!0,Wn()&&L()}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"?pi():e;ae=t,_e(t),Ue({model:t}),E(e,t),R(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},R(r);else if(r.request.subtype===`mcp_status`)R(r,{mcpServers:me()});else if(r.request.subtype===`get_context_usage`)try{let e=u(),t=await Hi({messages:C,getAppState:u,options:{mainLoopModel:mi(),tools:le(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt}});R(r,{...t})}catch(e){z(r,U(e))}else if(r.request.subtype===`mcp_message`){let e=r.request,t=D.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),R(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?R(r,t):z(r,t.error??`Unexpected error`)}else if(r.request.subtype===`cancel_async_message`){let e=r.request.message_uuid,t=Ie(t=>t.uuid===e);R(r,{cancelled:t.length>0})}else if(r.request.subtype===`seed_read_state`){try{let e=te(r.request.path),t=Math.floor((await ta(e)).mtimeMs);if(t<=r.request.mtime){let n=await ea(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{}R(r)}else if(r.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await de(r.request.servers);R(r,e),t&&j()}else if(r.request.subtype===`reload_plugins`)try{let e=await Xi(d),t=I.filter(e=>e.source===`flagSettings`);I=[...e.agentDefinitions.allAgents,...t];let n=[],[i,a,o]=await Promise.allSettled([Ve(Y()),xe(),$e()]);i.status===`fulfilled`?F=i.value:q(i.reason),a.status===`rejected`&&q(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),R(r,{commands:F.filter(e=>e.userInvocable!==!1).map(e=>({name:vt(e),description:Rt(e),argumentHint:e.argumentHint||``})),agents:I.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:me(),error_count:e.error_count})}catch(e){z(r,U(e))}else if(r.request.subtype===`mcp_reconnect`){let e=u(),{serverName:t}=r.request;k.delete(t);let n=dr(t)??i.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)z(r,`Server not found: ${t}`);else{let e=await jt(t,n),i=ne(t);if(d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...Di(n.mcp.tools,e=>e.name?.startsWith(i)),...e.tools],commands:[...Di(n.mcp.commands,e=>Te(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:Ei(n.mcp.resources,t)}})),M={...M,clients:[...M.clients.filter(e=>e.name!==t),e.client],tools:[...M.tools.filter(e=>!e.name?.startsWith(i)),...e.tools]},e.client.type===`connected`)A([e.client]),R(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;z(r,t)}}}else if(r.request.subtype===`mcp_toggle`){let e=u(),{serverName:t,enabled:n}=r.request;k.delete(t);let a=dr(t)??i.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)z(r,`Server not found: ${t}`);else if(n){Fn(t,!0);let e=await jt(t,a),n=ne(t);if(d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...Di(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...Di(r.mcp.commands,e=>Te(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:Ei(r.mcp.resources,t)}})),e.client.type===`connected`)A([e.client]),R(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;z(r,t)}}else{Fn(t,!1);let n=[...i,...D,...M.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Un(t,a);let o=ne(t);d(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:Di(e.mcp.tools,e=>e.name?.startsWith(o)),commands:Di(e.mcp.commands,e=>Te(e,t)),resources:Ei(e.mcp.resources,t)}})),R(r)}}else if(r.request.subtype===`apply_flag_settings`){let e=mi(),t=pe()??{},n=r.request.settings,i={...t,...n};for(let e of Object.keys(i))i[e]===null&&delete i[e];ge(i),mr.notifyChange(`flagSettings`),`model`in n&&(n.model==null?_e(void 0):_e(String(n.model)));let a=mi();if(a!==e){ae=a;let e=n.model?String(n.model):`default`;Ue({model:a}),E(e,a)}R(r)}else if(r.request.subtype===`get_settings`){let e=mi();R(r,{...se(),applied:{model:e}})}else if(r.request.subtype===`stop_task`){let{task_id:e}=r.request;try{await Kt(e,{getAppState:u,setAppState:d}),R(r,{})}catch(e){z(r,U(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(y&&!y.signal.aborted?y:Lr()).signal;(async()=>{try{let i=await Ri(e,n);if(i&&t)try{ye(N(),i)}catch(e){q(e)}R(r,{title:i})}catch(e){z(r,U(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=Ut(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:Lr()}}:await Pi({tools:le(u()),commands:F,mcpClients:[...u().mcp.clients,...D,...M.clients],messages:C,readFileState:w,getAppState:u,setAppState:d,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,thinkingConfig:p.thinkingConfig,agents:I}),i=await Vi({question:e,cacheSafeParams:n});R(r,{response:i.response})}catch(e){z(r,U(e))}})()}else r.request.subtype===`set_proactive`?(r.request.enabled?ot()||(Gt(`command`),Ce()):Xe(),R(r)):z(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=Li([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=N(),t=await Ke(e,o.uuid);if(t||Cc.has(o.uuid)){W(`Skipping duplicate user message: ${o.uuid}`),p.replayUserMessages&&(W(`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&&$t(o.uuid,`completed`);continue}Tc(o.uuid)}Er({mode:`prompt`,value:o.message.content,uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:On(e.attribution,e=>{dt(e).catch(e=>{W(`Attribution: Failed to save snapshot: ${e}`)})})})),L()}_=!0,h||(x.inflightPromise&&await Promise.race([x.inflightPromise,wi(5e3)]),x.abortController?.abort(),x.abortController=null,await fr(),Se(),Ir.delete(S),b.done())})(),b}function jc(e){let t=async(n,r,i,a,o,s)=>{let c=s??await we(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=un(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(v(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 we(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=>_i(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`),B(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`),B(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=En(e.agents,`flagSettings`);c.push(...t)}if(s.agent){let e=he()===s.agent,t=c.find(e=>e.agentType===s.agent);if(t&&!e){if(ve(t.agentType),!s.systemPrompt&&!lr(t)){let e=t.getSystemPrompt();e&&(s.systemPrompt=e)}!s.userSpecifiedModel&&t.model&&t.model!==`inherit`&&_e(hi(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let u=b()?.outputStyle||`default`,d=await Re(zr());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}});de(t)}e.jsonSchema&&P(e.jsonSchema);let f={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:vt(e),description:Rt(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:si()},pid:process.pid};if(gt()&&Bn()){let e=l();f.fast_mode_state=Le(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(!I())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Ot(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Tn(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await zn(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${U(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Fc(e,t,n,r){if(e.mode===`bypassPermissions`){if(Cr())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`&&!je()){let e=jr();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${yr(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...be(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:N(),total_cost_usd:0,usage:nr,modelUsage:{},permission_denials:[],uuid:J(),errors:[e]};process.stdout.write(`${H(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=!le();if(t.continue)try{let r=await Ni(void 0,void 0);if(r)return t.forkSession||r.sessionId&&(ue(Ne(r.sessionId),r.fullPath?Qi(r.fullPath):null),n&&await sn()),qi(r,e),rn(t.forkSession?{...r,worktreeSession:void 0}:r),{messages:r.messages,turnInterruptionState:r.turnInterruptionState,agentSetting:r.agentSetting}}catch(e){return q(e),B(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: wm -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),B(1),{messages:[]}}let i=await Ni(r.sessionId,r.jsonlFile||void 0);if(!i||i.messages.length===0)return Ic(`No conversation found with session ID: ${r.sessionId}`,t.outputFormat),B(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),B(1),{messages:[]};i.messages=e>=0?i.messages.slice(0,e+1):[]}return!t.forkSession&&i.sessionId&&(ue(Ne(i.sessionId),i.fullPath?Qi(i.fullPath):null),n&&await sn()),qi(i,e),rn(t.forkSession?{...i,worktreeSession:void 0}:i),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}catch(e){return q(e),Ic(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),B(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??Xn(`startup`))}}function zc(e,t){let n;return n=typeof e==`string`?e.trim()===``?qn([]):qn([H({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(W(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return W(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await an(t);return a?(r.add(t),W(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Er({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(W(`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}=mn(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||!xt(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){q(e)}await Un(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 Ce(t,r);if(d.push(e),e.type===`connected`){let t=await _t(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Wr(e);u[t]=n.message,q(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};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./process-gEbdy6uY.js";e();export{t as exitWithError};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(e){return t=>{t.code===`EPIPE`&&e.destroy()}}function n(){process.stdout.on(`error`,t(process.stdout)),process.stderr.on(`error`,t(process.stderr))}function r(e,t){e.destroyed||e.write(t)}function i(e){r(process.stdout,e)}function a(e){r(process.stderr,e)}function o(e){console.error(e),process.exit(1)}function s(e,t){return new Promise(n=>{let r=t=>{clearTimeout(o),e.off(`end`,i),e.off(`data`,a),n(t)},i=()=>r(!1),a=()=>clearTimeout(o),o=setTimeout(r,t,!0);e.once(`end`,i),e.once(`data`,a)})}var c=e((()=>{}));export{a,n as i,c as n,i as o,s as r,o as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,t as n}from"./src-BX54x08P.js";import{t as r}from"./jsx-runtime-Bb4Xn-E0.js";import{m as i,t as a}from"./settings-D4M13toi.js";import{$x as o,Ac as s,Eg as c,Ji as l,Qu as u,Qx as d,Tg as f,Yx as p,Zu as m,_m as h,gm as g,kc as _,mb as v,nS as y,pb as b,vm as x,ym as S}from"./loadAgentsDir-bmpKLPdG.js";import{A as C,I as w,M as T}from"./debug-2pVES-2G.js";import{n as E}from"./analytics-COpjZpvd.js";import{St as D,xt as O}from"./prompt-BnDapYGL.js";import{randomUUID as k}from"crypto";n(),h(),u(),S();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)(x,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):g.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}w(),E(),b(),l(),i();function M(){return a().defaultShell??`bash`}h(),O(),c();async function N(t,n,r,i,a){let c=D()&&M()===`powershell`,l=o({content:y({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;a({jsx:(0,A.jsx)(j,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{u=e?.jsx}},d=e=>{a({jsx:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(j,{input:t,progress:e.data,verbose:i.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},m=null;c&&(m=(s(),e(_)).PowerShellTool);let h=m??g,y=(m?await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d):await g.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await v(h,{...y,stderr:``},k()),S=typeof x.content==`string`?x.content:f(y.stdout);return{messages:[p(),l,...r,o({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${f(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof C?e.interrupted?{messages:[p(),l,d({toolUse:!1}),...r],shouldQuery:!1}:{messages:[p(),l,...r,o({content:`<bash-stdout>${f(e.stdout)}</bash-stdout><bash-stderr>${f(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[p(),l,...r,o({content:`<bash-stderr>Command failed: ${f(T(e))}</bash-stderr>`})],shouldQuery:!1}}finally{a(null)}}export{N as processBashCommand};