@readmagic/workmate 0.0.9 → 0.0.10
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.
- package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-Vmmm7p1c.js} +1 -1
- package/dist/chunks/App-C2yQjBgY.js +1 -0
- package/dist/chunks/ApproveApiKey-CKbv5C1x.js +1 -0
- package/dist/chunks/{ApproveApiKey-DHAbdwkC.js → ApproveApiKey-MscC-ssL.js} +1 -1
- package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-BuRFF1fQ.js → BypassPermissionsModeDialog-CLSACUmo.js} +1 -1
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.js → ClaudeMdExternalIncludesDialog-BqNxQOXJ.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +1 -0
- package/dist/chunks/{DiffDialog-BIcwpgSr.js → DiffDialog-9AYwtupw.js} +3 -3
- package/dist/chunks/Doctor-DmgAwce2.js +1 -0
- package/dist/chunks/Doctor-jEs9chPk.js +3 -0
- package/dist/chunks/ExitFlow-DVKxFdpX.js +2 -0
- package/dist/chunks/{Grove-BmirUB6V.js → Grove-B9-hhkZA.js} +1 -1
- package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-MxJ_W_np.js} +3 -3
- package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-o9DF1REI.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.js → InvalidSettingsDialog-YyQcHocx.js} +1 -1
- package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +1 -0
- package/dist/chunks/MCPToolListView-CvqB4nCw.js +1 -0
- package/dist/chunks/{McpParsingWarnings-CH4yyMAL.js → McpParsingWarnings-BCpfHaBK.js} +1 -1
- package/dist/chunks/MessageSelector-BLzw172f.js +3 -0
- package/dist/chunks/Messages-4K5sLmNh.js +11 -0
- package/dist/chunks/{Onboarding-BboWs1pp.js → Onboarding-ClwHS5rh.js} +1 -1
- package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-BSA9NrZc.js} +1 -1
- package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +1 -0
- package/dist/chunks/QueryEngine-DPHLSsax.js +1 -0
- package/dist/chunks/REPL-Bf46iQCN.js +1 -0
- package/dist/chunks/REPL-DIaAo9M9.js +133 -0
- package/dist/chunks/RemoteSessionManager-CS6mywIn.js +2 -0
- package/dist/chunks/ResumeConversation-Br2KsBoe.js +1 -0
- package/dist/chunks/{SSETransport-1KBBUikF.js → SSETransport-CoxQ8YpH.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +1 -0
- package/dist/chunks/Settings-BMXysXIx.js +2 -0
- package/dist/chunks/{TeleportProgress-BmgPAZAi.js → TeleportProgress-Doucj-50.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-B5I73j7Y.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-D6kpr2c6.js} +1 -1
- package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-DrC8tlp0.js} +1 -1
- package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-Fk4m_Sy4.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-D_OUa4RT.js} +1 -1
- package/dist/chunks/WelcomeV2-DvfQHnZY.js +1 -0
- package/dist/chunks/add-dir-CZ6Clvq8.js +1 -0
- package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-B755vMZE.js} +1 -1
- package/dist/chunks/{agents-Bz1MLp4A.js → agents-CIvP8l0s.js} +1 -1
- package/dist/chunks/agents-DHnNg4h6.js +103 -0
- package/dist/chunks/allErrors-CU89tF-z.js +1 -0
- package/dist/chunks/api-BSeE6MwB.js +1 -0
- package/dist/chunks/{api-DzccRM_z.js → api-nSHc_GIQ.js} +1 -1
- package/dist/chunks/{auth-Cjnyy10u.js → auth-5QB6tsfB.js} +1 -1
- package/dist/chunks/auth-BIGJth5U.js +1 -0
- package/dist/chunks/auth-CDQMhIZP.js +1 -0
- package/dist/chunks/{autoMode-CQ5nqP9c.js → autoMode-BnUiK9Cu.js} +5 -5
- package/dist/chunks/{autonomy-CPUCe-YU.js → autonomy-C1aSgWPQ.js} +1 -1
- package/dist/chunks/autonomy-Src6sKCp.js +15 -0
- package/dist/chunks/{autonomyPanel-Ccr9ilei.js → autonomyPanel-DnHpuiy4.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +17 -0
- package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +1 -0
- package/dist/chunks/{banner-BJZNMppT.js → banner-D0P7wXdw.js} +1 -1
- package/dist/chunks/bg-50rllUNh.js +1 -0
- package/dist/chunks/{bg-w3Vlsm3Y.js → bg-DAPORXF3.js} +2 -2
- package/dist/chunks/{branch-CG0AKS1J.js → branch-DFWa4Oxo.js} +2 -2
- package/dist/chunks/{break-cache-DXV0brco.js → break-cache-Chj9i9MP.js} +2 -2
- package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-Bb6URf4Q.js} +1 -1
- package/dist/chunks/bridgeConfig-BeqChxJC.js +1 -0
- package/dist/chunks/bridgeMessaging-C3huGcR3.js +1 -0
- package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-DLYyvRKb.js} +1 -1
- package/dist/chunks/bridgeStatusUtil-DFMftajD.js +1 -0
- package/dist/chunks/{btw-DDUC_t0w.js → btw-DSK9R2C8.js} +1 -1
- package/dist/chunks/caches-BTQAW9zc.js +1 -0
- package/dist/chunks/caches-BVtSCnV1.js +1 -0
- package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-amzeeBz0.js} +1 -1
- package/dist/chunks/{ccrClient-CG6HTv_n.js → ccrClient-Bu7Tf1Z5.js} +1 -1
- package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-CsJfF1b-.js} +1 -1
- package/dist/chunks/{clear-DdWexxbM.js → clear-ClFDpWVJ.js} +1 -1
- package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BWcoyZDP.js} +1 -1
- package/dist/chunks/client-BWQ4-rN7.js +1 -0
- package/dist/chunks/{client-CoXtVRzi.js → client-DFlE4fYh.js} +1 -1
- package/dist/chunks/client-c-3-PW1F.js +1 -0
- package/dist/chunks/commands-Bi7k3Wg-.js +1 -0
- package/dist/chunks/compact-J-h0Yf4b.js +2 -0
- package/dist/chunks/{config-CVvUNkj2.js → config-CVHMRMwd.js} +1 -1
- package/dist/chunks/config-Do1870_d.js +3 -0
- package/dist/chunks/config-yyFe87vW.js +1 -0
- package/dist/chunks/context-Tb1Ca2Q-.js +1 -0
- package/dist/chunks/{context-noninteractive-c7jGVWHQ.js → context-noninteractive-D5iQhasu.js} +2 -2
- package/dist/chunks/context-noninteractive-soPYKAc9.js +1 -0
- package/dist/chunks/conversation-CSEtUxOY.js +1 -0
- package/dist/chunks/conversation-Dk1WDQuN.js +1 -0
- package/dist/chunks/{createSSHSession-DP7B8yvb.js → createSSHSession-CJtzNQdZ.js} +1 -1
- package/dist/chunks/{createSession-CPo6GBSb.js → createSession-DkT1GL8y.js} +1 -1
- package/dist/chunks/createSession-eE8mswkv.js +1 -0
- package/dist/chunks/crossProjectResume-04n3Ppy9.js +40 -0
- package/dist/chunks/cwd-Cfdf7z7s.js +1 -0
- package/dist/chunks/cwd-ClLru_7T.js +1 -0
- package/dist/chunks/datadog-DjeJThpV.js +1 -0
- package/dist/chunks/{debug-BdqxZ7rV.js → debug-RAynG_nM.js} +1 -1
- package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-DX0KAXNK.js} +1 -1
- package/dist/chunks/{detached-CkPpYMJj.js → detached-X_yjYR7x.js} +1 -1
- package/dist/chunks/{detectRepository-DvxoaPlk.js → detectRepository-DgpNd87p.js} +1 -1
- package/dist/chunks/detectRepository-ctF9KDbb.js +1 -0
- package/dist/chunks/{diff-DHzz9WAp.js → diff-jEJJe58I.js} +1 -1
- package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BbXR2bfy.js} +1 -1
- package/dist/chunks/doctor-B-Wag4C1.js +1 -0
- package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
- package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
- package/dist/chunks/entry-oIqjxIjQ.js +14 -0
- package/dist/chunks/esm-Cf4nSRjF.js +1 -0
- package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-Dwu6psHW.js} +1 -1
- package/dist/chunks/{execSyncWrapper-DKuxVTaf.js → execSyncWrapper-BTZJjCuv.js} +1 -1
- package/dist/chunks/exit-BtW7LfRX.js +1 -0
- package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-Mi66JwFZ.js} +1 -1
- package/dist/chunks/extractMemories-CUrdiNcr.js +1 -0
- package/dist/chunks/{fast-ClYQcEv5.js → fast-BU4iUZ8E.js} +1 -1
- package/dist/chunks/fast-C60p6AqJ.js +1 -0
- package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
- package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
- package/dist/chunks/{fileSuggestions-fNxREjpe.js → fileSuggestions-BMfQIDdW.js} +1 -1
- package/dist/chunks/firstPartyEventLogger-B3cXgR67.js +5 -0
- package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +1 -0
- package/dist/chunks/flushGate-DgSDVGKZ.js +1 -0
- package/dist/chunks/gemini-BwvSxGgn.js +1 -0
- package/dist/chunks/{generateSessionName-nZj_VvKZ.js → generateSessionName-DlrdedOk.js} +1 -1
- package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-CmsUPyRz.js} +1 -1
- package/dist/chunks/{git-B9uvt96d.js → git-2c7WlGDL.js} +1 -1
- package/dist/chunks/git-XtKbtJMc.js +1 -0
- package/dist/chunks/{githubRepoPathMapping-Cqx3pSfc.js → githubRepoPathMapping-DbWG4hFQ.js} +1 -1
- package/dist/chunks/goal-ZmSRBx4q.js +3 -0
- package/dist/chunks/{grok-Dk3LyzMa.js → grok-BXMvezWb.js} +1 -1
- package/dist/chunks/{grove-BE4fQ6tG.js → grove-CeOjTaY6.js} +1 -1
- package/dist/chunks/help-5DNZO6_H.js +1 -0
- package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C637tFtd.js} +2 -2
- package/dist/chunks/hooks-DWg07LmS.js +1 -0
- package/dist/chunks/initReplBridge-D1h10vQ9.js +1 -0
- package/dist/chunks/{install-CVGZ55wV.js → install-C-6ItpH0.js} +1 -1
- package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DaiPDUst.js} +4 -4
- package/dist/chunks/intl-D2kgJmX7.js +1 -0
- package/dist/chunks/{job-DEXxW_Zo.js → job-BeYzQUiR.js} +1 -1
- package/dist/chunks/{jwtUtils-C9sdGhvT.js → jwtUtils-CUPXdX3W.js} +1 -1
- package/dist/chunks/keybindings-DgIPdBy9.js +2 -0
- package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-CE4J98xO.js} +2 -2
- package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-BfTdC6vp.js} +1 -1
- package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-C7lOqvfh.js} +2194 -2329
- package/dist/chunks/loadAgentsDir-zikjxLvn.js +1 -0
- package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +1 -0
- package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-BKrznW5x.js} +1 -1
- package/dist/chunks/localSearch-ZFyFy5FN.js +1 -0
- package/dist/chunks/log-CezCRpAN.js +1 -0
- package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-BkQfyQ1-.js} +1 -1
- package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-BpVcON9o.js} +2 -2
- package/dist/chunks/{main-BIiwW4mM.js → main-9r5gLzUW.js} +55 -55
- package/dist/chunks/{main-ClXu1ilx.js → main-CvOv59-7.js} +4 -4
- package/dist/chunks/managedEnv-B61yLpwp.js +1 -0
- package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DhWRJ5DK.js} +1 -1
- package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-bOab8ipV.js} +1 -1
- package/dist/chunks/mcp-BckPBjaM.js +6 -0
- package/dist/chunks/mcp-CS1DA3JL.js +1 -0
- package/dist/chunks/mcp-VcGPYCkW.js +2 -0
- package/dist/chunks/{memoize-FJv2HV1u.js → memoize-DsqYrbeR.js} +1 -1
- package/dist/chunks/memory-C5ohwh-T.js +1 -0
- package/dist/chunks/{mode-lYTs0XHs.js → mode-DlKnUM8l.js} +2 -2
- package/dist/chunks/model-BGu1AGq0.js +1 -0
- package/dist/chunks/model-BsZ4sP_H.js +1 -0
- package/dist/chunks/model-D19IIcll.js +1 -0
- package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-CxP067Qv.js} +1 -1
- package/dist/chunks/nativeInstaller-QB8cEJ18.js +1 -0
- package/dist/chunks/omit-DDUIPHnl.js +1 -0
- package/dist/chunks/onChangeAppState-RBl6H7ho.js +1 -0
- package/dist/chunks/{openai-DJLYqiRl.js → openai-B9C2XN5Q.js} +3 -3
- package/dist/chunks/{panel-q0_iT9cg.js → panel-KW-wmEvU.js} +1 -1
- package/dist/chunks/{parser-BdCj2GrE.js → parser-BwPXQomy.js} +1 -1
- package/dist/chunks/parser-xSBaQRLH.js +1 -0
- package/dist/chunks/partition-D-UhsUCx.js +1 -0
- package/dist/chunks/permissions-BoLXYN1j.js +3 -0
- package/dist/chunks/{pidLock-BR5M6RQw.js → pidLock-nJHbufJN.js} +2 -2
- package/dist/chunks/plan-CyU2zrCK.js +1 -0
- package/dist/chunks/{platform-D6IMiyqT.js → platform-BMPbglug.js} +1 -1
- package/dist/chunks/plugin-C6-GQke5.js +17 -0
- package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +1 -0
- package/dist/chunks/pluginBlocklist-n6Imlh3y.js +1 -0
- package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +1 -0
- package/dist/chunks/{pluginFlagging-CxuRF2Vc.js → pluginFlagging-DZaYzecY.js} +1 -1
- package/dist/chunks/pluginOperations-D90IRawu.js +2 -0
- package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +1 -0
- package/dist/chunks/{pluginStartupCheck-B6leNWq9.js → pluginStartupCheck-CB2q2dLv.js} +1 -1
- package/dist/chunks/plugins-B9eSjLSA.js +4 -0
- package/dist/chunks/poorMode-BAnubpn1.js +1 -0
- package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-DEwQOAJt.js} +1 -1
- package/dist/chunks/print-eCRv_Li-.js +26 -0
- package/dist/chunks/processBashCommand-B5F2Cl7K.js +1 -0
- package/dist/chunks/processSlashCommand-BC_D3cH5.js +5 -0
- package/dist/chunks/prompt-C1JPqinc.js +1 -0
- package/dist/chunks/prompt-DZhBz_Vu.js +1 -0
- package/dist/chunks/{prompt-CybUvG8G.js → prompt-M2lu8_Oa.js} +34 -34
- package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-DhcZY-iu.js} +2 -2
- package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-CkFaJKKo.js} +1 -1
- package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CuMaO_YV.js} +1 -1
- package/dist/chunks/reconciler-B4GDm_iC.js +1 -0
- package/dist/chunks/refresh-DBVizOzg.js +1 -0
- package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-CsNYRZKr.js} +1 -1
- package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-B7JAE3b4.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CFLJhsB6.js} +1 -1
- package/dist/chunks/{remoteManagedSettings-CCrq-qL-.js → remoteManagedSettings-xh_MViZH.js} +1 -1
- package/dist/chunks/rename-BCp2Vtqu.js +1 -0
- package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-Q5oCLFIC.js} +1 -1
- package/dist/chunks/resume-DVCSzKvv.js +2 -0
- package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-DvOOsDMv.js} +1 -1
- package/dist/chunks/ripgrep-e-iewvTf.js +1 -0
- package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-CS_3BDNo.js} +4 -4
- package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-DYUva6g-.js} +1 -1
- package/dist/chunks/sandbox-adapter-BFZFHplu.js +1 -0
- package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle--zNSKce_.js} +1 -1
- package/dist/chunks/searchExtraTools-ui5y2VSE.js +1 -0
- package/dist/chunks/{session-BbQlh2S5.js → session-CO3gEqQP.js} +2 -2
- package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +1 -0
- package/dist/chunks/sessionObserver-Ba7um95p.js +1 -0
- package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-YkRHC-Aa.js} +1 -1
- package/dist/chunks/sessionState-Bifmu95-.js +11 -0
- package/dist/chunks/sessionStorage-CedwLLQs.js +1 -0
- package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-COBSgSXS.js} +2 -2
- package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-BrNx1k2V.js} +2 -2
- package/dist/chunks/settings-DkDH7WQT.js +1 -0
- package/dist/chunks/{settings-Xbq6AaD-.js → settings-DnptdP79.js} +5 -5
- package/dist/chunks/settingsSync-PmU7SmkU.js +1 -0
- package/dist/chunks/setup-BEsBuzsk.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-DEaw-X5j.js} +1 -1
- package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-BYeOv3Ip.js} +1 -1
- package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-D0OKljee.js} +3 -3
- package/dist/chunks/sinks-BJHgxz6Y.js +1 -0
- package/dist/chunks/sinks-D5-yhcgU.js +2 -0
- package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +1 -0
- package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-N_kmvXML.js} +2 -2
- package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-C4F5RXuh.js} +2 -2
- package/dist/chunks/{skillSearchPanel-mpaC62y4.js → skillSearchPanel-CftorvAM.js} +3 -3
- package/dist/chunks/{skills-t6krW8GZ.js → skills-C4CTRN9o.js} +1 -1
- package/dist/chunks/startupProfiler-D4FBdEQr.js +1 -0
- package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-L_UWZ03w.js} +2 -2
- package/dist/chunks/state-BemZdQIl.js +1 -0
- package/dist/chunks/state-D_lk6z-C.js +1 -0
- package/dist/chunks/{stats-BJBhl-Lc.js → stats-IzV0_vEc.js} +1 -1
- package/dist/chunks/{status-BtsnKNVY.js → status-CeVP_uDT.js} +1 -1
- package/dist/chunks/status-Dzuw3hBv.js +2 -0
- package/dist/chunks/statusNoticeHelpers-Bb9gxdSt.js +1 -0
- package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C84IJ91d.js} +1 -1
- package/dist/chunks/switcher-4KzBvuKH.js +1 -0
- package/dist/chunks/{switcher-77h2J5HC.js → switcher-CCs9xl1z.js} +1 -1
- package/dist/chunks/{syncCache-By_-buUC.js → syncCache-CBRiRU5x.js} +1 -1
- package/dist/chunks/{tasks-BNrdmF9p.js → tasks-DZDhgx0w.js} +1 -1
- package/dist/chunks/teleport-Bw0jSxe9.js +1 -0
- package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CrNPEKkh.js} +1 -1
- package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-CBqcwQll.js} +1 -1
- package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-D-N8YPiQ.js} +1 -1
- package/dist/chunks/{theme-BjpBVRf5.js → theme-Dazsirbw.js} +1 -1
- package/dist/chunks/{tmux-CMRiI6CD.js → tmux-DewYVEBm.js} +1 -1
- package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-lnHJ9fLQ.js} +1 -1
- package/dist/chunks/toolPool-CkXFlqsn.js +1 -0
- package/dist/chunks/{trustedDevice-j1u2TG5U.js → trustedDevice-CFf5yaG-.js} +1 -1
- package/dist/chunks/trustedDevice-CuwSv8dG.js +1 -0
- package/dist/chunks/{types-DWRxAH0E.js → types-3j8PS-Du.js} +1 -1
- package/dist/chunks/{udsClient-Cm3HqYUu.js → udsClient-e9dIkwVA.js} +1 -1
- package/dist/chunks/{updateCCB-BlUAU2Vp.js → updateCCB-BPe9_FW6.js} +1 -1
- package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-DF00RzGG.js} +1 -1
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js} +1 -1
- package/dist/chunks/useMainLoopModel-2-eujv0n.js +1 -0
- package/dist/chunks/useManagePlugins-CYBIkaB1.js +1 -0
- package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-Dk5cPqLc.js} +1 -1
- package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-C7Y1I9P9.js} +1 -1
- package/dist/chunks/useSettingsErrors-DAEO7AyB.js +1 -0
- package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CIq27vUR.js} +1 -1
- package/dist/chunks/util-VO98TdOz.js +1 -0
- package/dist/chunks/validatePlugin-Kk6pxnO2.js +1 -0
- package/dist/chunks/{vim-3mUqsEJm.js → vim-EYQn94Kx.js} +1 -1
- package/dist/chunks/{which-DznMOwny.js → which-DzFN5TNM.js} +1 -1
- package/dist/chunks/{windowsPaths-BVztIhXM.js → windowsPaths-BU3yQWTB.js} +1 -1
- package/dist/chunks/windowsPaths-DgZ3YY4a.js +1 -0
- package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-DUqdPy44.js} +1 -1
- package/dist/chunks/workerRegistry-C07BcZIw.js +6 -0
- package/dist/chunks/worktree-dFUkhVE_.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/App-DW4elk6E.js +0 -1
- package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +0 -1
- package/dist/chunks/Doctor-D160J8Ad.js +0 -3
- package/dist/chunks/Doctor-VhJi2cmL.js +0 -1
- package/dist/chunks/ExitFlow-CoWHhKHJ.js +0 -2
- package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +0 -1
- package/dist/chunks/MCPToolListView-BPmE0C2o.js +0 -1
- package/dist/chunks/MessageSelector-kOn2GaU-.js +0 -3
- package/dist/chunks/Messages-4EnHFeh1.js +0 -11
- package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +0 -1
- package/dist/chunks/QueryEngine-J6ElcO16.js +0 -1
- package/dist/chunks/REPL-DBjbAJsm.js +0 -133
- package/dist/chunks/REPL-oBemMXvp.js +0 -1
- package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +0 -2
- package/dist/chunks/ResumeConversation-wBG8OD9P.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +0 -1
- package/dist/chunks/Settings-DptKuJE7.js +0 -2
- package/dist/chunks/WelcomeV2-BWF-cJOu.js +0 -1
- package/dist/chunks/add-dir-DBVT1cEK.js +0 -1
- package/dist/chunks/agents-CnwTOlqO.js +0 -103
- package/dist/chunks/allErrors-DYw_q14e.js +0 -1
- package/dist/chunks/api-DXDXTFGa.js +0 -1
- package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
- package/dist/chunks/auth-CnLb6RWc.js +0 -1
- package/dist/chunks/auth-D-SGHS0K.js +0 -1
- package/dist/chunks/autonomy-dSJl0hN1.js +0 -15
- package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
- package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
- package/dist/chunks/bg-DWloqGwk.js +0 -1
- package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
- package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
- package/dist/chunks/caches-1IFb6_M_.js +0 -1
- package/dist/chunks/caches-CB8MHqy2.js +0 -1
- package/dist/chunks/client-Crrwkw7g.js +0 -1
- package/dist/chunks/client-D8hKghba.js +0 -1
- package/dist/chunks/color-Cuq0c6xy.js +0 -1
- package/dist/chunks/commands-D3sESsTp.js +0 -1
- package/dist/chunks/compact-DIpwuBDq.js +0 -2
- package/dist/chunks/config-D4G8_MqJ.js +0 -3
- package/dist/chunks/config-q9D4hFiK.js +0 -1
- package/dist/chunks/context-BWcfhhDj.js +0 -1
- package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
- package/dist/chunks/conversation-Bjo_8kia.js +0 -1
- package/dist/chunks/conversation-DrHZIQX2.js +0 -1
- package/dist/chunks/createSession-DnykRoia.js +0 -1
- package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
- package/dist/chunks/cwd--q1ONL7P.js +0 -1
- package/dist/chunks/cwd-L4wygFqJ.js +0 -1
- package/dist/chunks/daemon-D2vFIVOz.js +0 -2
- package/dist/chunks/datadog-DrmHyl3_.js +0 -1
- package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
- package/dist/chunks/doctor-PWqB46xd.js +0 -1
- package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
- package/dist/chunks/entry-4JtoJONR.js +0 -14
- package/dist/chunks/esm-DcIr7tVd.js +0 -1
- package/dist/chunks/exit-OW9g7b9A.js +0 -1
- package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
- package/dist/chunks/fast-CrvLdpy3.js +0 -1
- package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
- package/dist/chunks/featureCheck-HslM03dr.js +0 -1
- package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
- package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
- package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
- package/dist/chunks/gemini-fZ0VPU2A.js +0 -1
- package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
- package/dist/chunks/git-BfS5Hk4S.js +0 -1
- package/dist/chunks/goal-IasZVqKh.js +0 -3
- package/dist/chunks/help-D2-v9Ug9.js +0 -1
- package/dist/chunks/hooks-DGd02IKF.js +0 -1
- package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
- package/dist/chunks/intl-cKc-V6Mq.js +0 -1
- package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
- package/dist/chunks/language-C0cIpKE2.js +0 -1
- package/dist/chunks/language-CxThoWRC.js +0 -1
- package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
- package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
- package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
- package/dist/chunks/log-CTFl4qpD.js +0 -1
- package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
- package/dist/chunks/mcp-B_m1XBDt.js +0 -6
- package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
- package/dist/chunks/mcp-BjlaPUWX.js +0 -2
- package/dist/chunks/memory-LN8f_p2b.js +0 -1
- package/dist/chunks/model-C2e73CJD.js +0 -1
- package/dist/chunks/model-CvmS-Esk.js +0 -1
- package/dist/chunks/model-DJ8mFfuR.js +0 -1
- package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
- package/dist/chunks/omit-CLPZGevl.js +0 -1
- package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
- package/dist/chunks/panelCall-sum-3zvi.js +0 -1
- package/dist/chunks/parser-BcdhBGx0.js +0 -1
- package/dist/chunks/partition-CpfoVrg1.js +0 -1
- package/dist/chunks/permissions-DTb9wkAP.js +0 -3
- package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
- package/dist/chunks/plan-BeoIjNPv.js +0 -1
- package/dist/chunks/plugin-D_dHjTud.js +0 -17
- package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
- package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
- package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
- package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
- package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
- package/dist/chunks/plugins-pmipe7kE.js +0 -4
- package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
- package/dist/chunks/print-CAUvczBM.js +0 -23
- package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
- package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
- package/dist/chunks/prompt-RBn4JdEg.js +0 -1
- package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
- package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
- package/dist/chunks/refresh-D8TLHO_T.js +0 -1
- package/dist/chunks/rename-CKsSc7Z3.js +0 -1
- package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
- package/dist/chunks/resume-B1a5gLVR.js +0 -2
- package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
- package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
- package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
- package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
- package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
- package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
- package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
- package/dist/chunks/sessionState-BvECKycx.js +0 -11
- package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
- package/dist/chunks/settings-B-R9ZJNY.js +0 -1
- package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
- package/dist/chunks/setup-uZ0dSekt.js +0 -3
- package/dist/chunks/sinks-C7q46rvE.js +0 -2
- package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
- package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
- package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
- package/dist/chunks/state-B4HwLt8i.js +0 -1
- package/dist/chunks/state-Bs5xweDL.js +0 -1
- package/dist/chunks/status-nZQEar7T.js +0 -2
- package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
- package/dist/chunks/switcher-B2CYzCC_.js +0 -1
- package/dist/chunks/teleport-mdnhIZBj.js +0 -1
- package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
- package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
- package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
- package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
- package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
- package/dist/chunks/util-D-X8i5Z2.js +0 -1
- package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
- package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
- package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
- package/dist/chunks/worktree-BX1ULzrw.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-BDhHQY0-.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$C as o,$o as s,Eo as c,Ew as l,GC as u,GE as d,Ho as f,Hv as p,KC as m,Mo as h,QC as g,QE as _,Ro as v,Sd as y,Ss as b,To as x,VE as ee,Vo as te,Vu as S,Vv as C,Wo as w,XC as T,Xo as ne,YC as E,ZC as D,ZE as O,_m as k,_s as re,as as ie,aw as ae,cs as A,ds as oe,eD as j,eE as se,es as ce,ew as M,fs as le,gC as ue,gs as de,hs as fe,iE as pe,iw as me,jo as N,lv as P,ms as he,nw as ge,ov as _e,ps as ve,pw as ye,qE as be,qo as xe,rE as F,rs as Se,rw as I,ss as Ce,sv as we,tD as Te,tw as Ee,vm as De,xd as Oe,xs as ke,yC as Ae,ys as je,zu as Me}from"./loadAgentsDir-CKSb56Gp.js";import{D as Ne,Gr as Pe,Gt as L,H as Fe,I as R,P as z,T as B,Wt as Ie,Xn as Le,fi as V,hn as Re,j as ze,k as Be,n as Ve,ot as He,r as Ue,t as We,x as Ge,y as Ke}from"./src-P_wYS_NJ2.js";import{t as qe}from"./jsx-runtime-Bb4Xn-E0.js";import{C as Je,F as Ye,S as Xe,W as Ze,a as Qe,l as $e,z as et}from"./debug-BdqxZ7rV.js";import{In as tt,Ln as nt,c as rt,f as it,g as at,vt as ot,x as st,xt as ct}from"./settings-Xbq6AaD-.js";import{b as lt,h as ut}from"./config-D4G8_MqJ.js";import{o as dt,s as ft}from"./log-CTFl4qpD.js";import{n as pt,r as mt}from"./analytics-DJobLaWP.js";import{C as ht,y as gt}from"./startupProfiler-jeId9f2i.js";import{l as H,o as _t}from"./stringUtils-CbS6OkmE.js";import{n as vt,t as yt}from"./pluginStartupCheck-B6leNWq9.js";import{a as bt,d as xt,f as St,i as Ct,l as wt,o as Tt,s as Et,u as Dt}from"./pluginOperations-BTq4AjYB.js";import{a as Ot,c as kt,i as At,n as jt,o as Mt,s as Nt,t as Pt}from"./validatePlugin-DSw08u76.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-CxuRF2Vc.js";import{i as zt,n as Bt}from"./MCPConnectionManager-DPFe4hPh.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import{t as Ut}from"./SearchBox-C9vUA4IM.js";import{n as Wt,t as Gt}from"./useSearchInput-C6d6nt9S.js";import{a as Kt,c as qt,i as Jt,n as Yt,o as Xt,r as Zt,s as Qt,t as $t}from"./MCPToolListView-BPmE0C2o.js";import{i as en,n as tn}from"./pluginAutoupdate-BHKlOOXI.js";import*as nn from"path";import*as rn from"fs/promises";function an({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:o,setResult:s,setViewState:c,onAddComplete:l,cliMode:u=!1}){let d=(0,on.useRef)(!1),[f,p]=(0,on.useState)(!1),[m,h]=(0,on.useState)(``),g=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ot(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{p(!0),h(``);let{name:e,resolvedSource:t}=await xe(n,e=>{h(e)});Ce(e,{source:t}),ke();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),l&&await l(),h(``),p(!1),u?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),h(``),p(!1),s(u?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!d.current&&!i&&!o&&(d.current=!0,g())},[]),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsxs)(R,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(R,{marginBottom:1,children:(0,U.jsx)(z,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsx)(z,{children:`Enter marketplace source:`}),(0,U.jsx)(z,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(z,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(z,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(z,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(z,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(Oe,{value:e,onChange:t,onSubmit:g,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),f&&(0,U.jsxs)(R,{marginTop:1,children:[(0,U.jsx)(Me,{}),(0,U.jsx)(z,{children:m||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{color:`error`,children:i})}),o&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{children:o})})]}),(0,U.jsx)(R,{marginLeft:3,children:(0,U.jsx)(z,{dimColor:!0,italic:!0,children:(0,U.jsxs)(B,{children:[(0,U.jsx)(Ne,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(k,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{V(),on=t(V(),1),pt(),De(),We(),S(),y(),et(),dt(),b(),s(),At(),U=qe()}));function cn(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 ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Ie(`confirm:no`,o,{context:`Settings`}),L({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Re((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let _=g.sensitive===!0,v=g.required===!0,y=_?`*`.repeat(Pe(p)):p;return(0,dn.jsxs)(Ke,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{bold:!0,children:[g.title||h,v&&(0,dn.jsx)(z,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(z,{dimColor:!0,children:g.description}),(0,dn.jsxs)(R,{marginTop:1,children:[(0,dn.jsxs)(z,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(z,{children:y}),(0,dn.jsx)(z,{children:`█`})]})]}),(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(V(),1),We(),l(),r(),dn=qe()}));async function pn(e){let{enabled:t,disabled:n}=await c();return[...t,...n].find(t=>t.repository===e||t.source===e)}function mn({plugin:e,pluginId:t,onDone:n}){let[r]=hn.useState(()=>{let n=[],r=E(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>D(t),save:n=>g(t,n,e.manifest.userConfig)});let i=u(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>Ee(t,r.server)??void 0,save:e=>I(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),o=hn.useRef(n);if(o.current=n,hn.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`,Ye(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,gn.jsx)(ln,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:c,onCancel:()=>n(`skipped`)},s.key)}var hn,gn,_n=e((()=>{hn=t(V(),1),et(),o(),m(),x(),T(),fn(),gn=qe()}));function vn(){let e=de();return(0,yn.jsxs)(R,{marginBottom:1,children:[(0,yn.jsxs)(z,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(z,{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 yn,bn=e((()=>{i(),V(),We(),re(),yn=qe()}));function xn(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 Sn(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 Cn({hasSelection:e}){return(0,wn.jsx)(R,{marginTop:1,children:(0,wn.jsx)(z,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(B,{children:[e&&(0,wn.jsx)(k,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(k,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{V(),De(),We(),wn=qe()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.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,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.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 Dn,On,kn=e((()=>{Dn=t(V(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:c}){let[l,u]=(0,W.useState)(`marketplace-list`),[d,m]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)([]),[ee,S]=(0,W.useState)(!0),[C,w]=(0,W.useState)(null),[T,E]=(0,W.useState)(0),[D,O]=(0,W.useState)(new Set),[re,ie]=(0,W.useState)(new Set),A=En({totalItems:b.length,selectedIndex:T}),[j,se]=(0,W.useState)(0),[M,le]=(0,W.useState)(!1),[ue,de]=(0,W.useState)(null),[pe,me]=(0,W.useState)(null);Ie(`confirm:no`,jn.useCallback(()=>{l===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):v.length===1?i({type:`menu`}):(u(`marketplace-list`),m(null),O(new Set)):l===`plugin-details`?(u(`plugin-list`),_(null)):i({type:`menu`})},[l,s,i,v.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await ce(),{marketplaces:n,failures:r}=await je(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>f(oe(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:fe(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),y(i);let a=he(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)me(a.message+`. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!c){let e=i[0];e&&(m(e.name),u(`plugin-list`))}if(c){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await ne(t);if(e){let i=e.plugins.find(e=>e.name===c);if(i){let e=oe(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:te(e)},r=t;break}}}if(n&&r){let e=n.pluginId;te(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(m(r),_(n),u(`plugin-details`))}else t(`Plugin "${c}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(m(s),u(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{S(!1)}}e()},[t,s,c]),(0,W.useEffect)(()=>{if(!d)return;let e=!1;async function n(n){S(!0);try{let t=await ne(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=oe(e.name,n);p(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:te(t)})}try{let t=await Nt();if(e)return;w(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;$e(`Failed to fetch install counts: ${Ye(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}x(r),E(0),O(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{S(!1)}}return n(d),()=>{e=!0}},[d,t]);let N=async()=>{if(D.size===0)return;let e=b.filter(e=>D.has(e.pluginId));ie(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await h({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ie(new Set),O(new Set),ke(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ve(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ve(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},P=async(e,t=`user`)=>{le(!0),de(null);let n=await h({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){le(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else le(!1),de(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),L({"select:previous":()=>{T>0&&E(T-1)},"select:next":()=>{T<v.length-1&&E(T+1)},"select:accept":()=>{let e=v[T];e&&(m(e.name),u(`plugin-list`))}},{context:`Select`,isActive:l===`marketplace-list`}),L({"select:previous":()=>{T>0&&A.handleSelectionChange(T-1,E)},"select:next":()=>{T<b.length-1&&A.handleSelectionChange(T+1,E)},"select:accept":()=>{if(T===b.length&&D.size>0)N();else if(T<b.length){let e=b[T];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(_(e),u(`plugin-details`),se(0),de(null)))}}},{context:`Select`,isActive:l===`plugin-list`}),L({"plugin:toggle":()=>{if(T<b.length){let e=b[T];if(e&&!e.isInstalled){let t=new Set(D);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),O(t)}}},"plugin:install":()=>{D.size>0&&N()}},{context:`Plugin`,isActive:l===`plugin-list`});let ge=jn.useMemo(()=>{if(!g)return[];let e=g.entry.homepage;return Sn(e,xn(g))},[g]);if(L({"select:previous":()=>{j>0&&se(j-1)},"select:next":()=>{j<ge.length-1&&se(j+1)},"select:accept":()=>{if(!g)return;let e=ge[j]?.action,t=g.entry.homepage,n=xn(g);e===`install-user`?P(g,`user`):e===`install-project`?P(g,`project`):e===`install-local`?P(g,`local`):e===`homepage`&&t?ae(t):e===`github`&&n?ae(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),_(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!g}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(mn,{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)(z,{children:`Loading…`});if(e)return(0,G.jsx)(z,{color:`error`,children:e});if(l===`marketplace-list`)return v.length===0?(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(z,{children:`No marketplaces configured.`}),(0,G.jsxs)(z,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),pe&&(0,G.jsx)(R,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(z,{color:`warning`,children:[a.warning,` `,pe]})}),v.map((e,t)=>(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:+(t<v.length-1),children:[(0,G.jsx)(R,{children:(0,G.jsxs)(z,{color:T===t?`suggestion`:void 0,children:[T===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(R,{marginLeft:2,children:(0,G.jsxs)(z,{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)(R,{marginTop:1,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(l===`plugin-details`&&g){let e=g.entry.homepage,t=Sn(e,xn(g));return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:g.entry.name}),g.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[`Version: `,g.entry.version]}),g.entry.description&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{children:g.entry.description})}),g.entry.author&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof g.entry.author==`string`?g.entry.author:g.entry.author.name]})})]}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:`Will install:`}),g.entry.commands&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(g.entry.commands)?g.entry.commands.join(`, `):Object.keys(g.entry.commands).join(`, `)]}),g.entry.agents&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(g.entry.agents)?g.entry.agents.join(`, `):Object.keys(g.entry.agents).join(`, `)]}),g.entry.hooks&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Hooks: `,Object.keys(g.entry.hooks).join(`, `)]}),g.entry.mcpServers&&(0,G.jsxs)(z,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(g.entry.mcpServers)?g.entry.mcpServers.join(`, `):typeof g.entry.mcpServers==`object`?Object.keys(g.entry.mcpServers).join(`, `):`configured`]}),!g.entry.commands&&!g.entry.agents&&!g.entry.hooks&&!g.entry.mcpServers&&(0,G.jsx)(G.Fragment,{children:typeof g.entry.source==`object`&&`source`in g.entry.source&&(g.entry.source.source===`github`||g.entry.source.source===`url`||g.entry.source.source===`npm`||g.entry.source.source===`pip`)?(0,G.jsx)(z,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(z,{dimColor:!0,children:`· Components will be discovered at installation`})})]}),(0,G.jsx)(vn,{}),ue&&(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsxs)(z,{color:`error`,children:[`Error: `,ue]})}),(0,G.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(R,{children:[j===t&&(0,G.jsx)(z,{children:`> `}),j!==t&&(0,G.jsx)(z,{children:` `}),(0,G.jsx)(z,{bold:j===t,children:M&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(b.length===0)return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(z,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(z,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(R,{marginLeft:3,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let _e=A.getVisibleItems(b);return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install Plugins`})}),A.scrollPosition.canScrollUp&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),_e.map((t,n)=>{let r=A.toActualIndex(n),i=T===r,o=D.has(t.pluginId),s=re.has(t.pluginId);return(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:n===_e.length-1&&!e?0:1,children:[(0,G.jsxs)(R,{children:[(0,G.jsxs)(z,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(z,{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)(z,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(z,{dimColor:!0,children:` (installed)`}),C&&d===`claude-plugins-official`&&(0,G.jsxs)(z,{dimColor:!0,children:[` · `,Mt(C.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(R,{marginLeft:4,children:[(0,G.jsx)(z,{dimColor:!0,children:ht(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),A.scrollPosition.canScrollDown&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:D.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(V(),1),W=t(V(),1),De(),We(),l(),nt(),me(),Qe(),et(),b(),kt(),v(),re(),s(),ee(),N(),C(),_t(),gt(),_n(),bn(),Tn(),kn(),G=qe()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:c}){let[l,u]=(0,K.useState)(`plugin-list`),[d,f]=(0,K.useState)(null),[m,g]=(0,K.useState)([]),[_,v]=(0,K.useState)(!0),[y,b]=(0,K.useState)(null),[x,ee]=(0,K.useState)(!1),S=(0,K.useCallback)(e=>{ee(e),s?.(e)},[s]),{query:C,setQuery:w,cursorOffset:T}=Wt({isActive:l===`plugin-list`&&x&&!_,onExit:()=>{S(!1)}}),ne=Le(),{columns:E}=He(),D=(0,K.useMemo)(()=>{if(!C)return m;let e=C.toLowerCase();return m.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[m,C]),[O,re]=(0,K.useState)(0),[ie,A]=(0,K.useState)(new Set),[j,se]=(0,K.useState)(new Set),M=En({totalItems:D.length,selectedIndex:O});(0,K.useEffect)(()=>{re(0)},[C]);let[ue,de]=(0,K.useState)(0),[fe,pe]=(0,K.useState)(!1),[me,N]=(0,K.useState)(null),[P,ge]=(0,K.useState)(null),[_e,ye]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await ce(),{marketplaces:n,failures:r}=await je(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=oe(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:te(t)})}let a=i.filter(e=>!e.isInstalled&&!p(e.pluginId));try{let e=await Nt();b(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){$e(`Failed to fetch install counts: ${Ye(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}g(a);let o=Object.keys(e).length;if(a.length===0){let e=await le({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ye(e)}let s=he(r,tt(n,e=>e.data!==null));if(s)if(s.type===`warning`)ge(s.message+`. Showing available plugins.`);else throw Error(s.message);if(c){let e=i.find(e=>e.entry.name===c);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(f(e),u(`plugin-details`)):t(`Plugin "${c}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{v(!1)}}e()},[t,c]);let be=async()=>{if(ie.size===0)return;let e=m.filter(e=>ie.has(e.pluginId));se(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await h({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}se(new Set),A(new Set),ke(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ve(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ve(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},xe=async(e,t=`user`)=>{pe(!0),N(null);let n=await h({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){pe(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else pe(!1),N(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Ie(`confirm:no`,()=>{u(`plugin-list`),f(null)},{context:`Confirmation`,isActive:l===`plugin-details`}),Ie(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:l===`plugin-list`&&!x}),Re((e,t)=>{let n=!t.ctrl&&!t.meta;x||(e===`/`&&n?(S(!0),w(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(S(!0),w(e)))},{isActive:l===`plugin-list`&&!_}),L({"select:previous":()=>{O===0?S(!0):M.handleSelectionChange(O-1,re)},"select:next":()=>{O<D.length-1&&M.handleSelectionChange(O+1,re)},"select:accept":()=>{if(O===D.length&&ie.size>0)be();else if(O<D.length){let e=D[O];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(f(e),u(`plugin-details`),de(0),N(null)))}}},{context:`Select`,isActive:l===`plugin-list`&&!x}),L({"plugin:toggle":()=>{if(O<D.length){let e=D[O];if(e&&!e.isInstalled){let t=new Set(ie);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),A(t)}}},"plugin:install":()=>{ie.size>0&&be()}},{context:`Plugin`,isActive:l===`plugin-list`&&!x});let F=In.useMemo(()=>{if(!d)return[];let e=d.entry.homepage;return Sn(e,xn(d))},[d]);if(L({"select:previous":()=>{ue>0&&de(ue-1)},"select:next":()=>{ue<F.length-1&&de(ue+1)},"select:accept":()=>{if(!d)return;let e=F[ue]?.action,t=d.entry.homepage,n=xn(d);e===`install-user`?xe(d,`user`):e===`install-project`?xe(d,`project`):e===`install-local`?xe(d,`local`):e===`homepage`&&t?ae(t):e===`github`&&n?ae(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),f(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!d}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(mn,{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(_)return(0,q.jsx)(z,{children:`Loading…`});if(e)return(0,q.jsx)(z,{color:`error`,children:e});if(l===`plugin-details`&&d){let e=d.entry.homepage,t=Sn(e,xn(d));return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(z,{bold:!0,children:d.entry.name}),(0,q.jsxs)(z,{dimColor:!0,children:[`from `,d.marketplaceName]}),d.entry.version&&(0,q.jsxs)(z,{dimColor:!0,children:[`Version: `,d.entry.version]}),d.entry.description&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{children:d.entry.description})}),d.entry.author&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof d.entry.author==`string`?d.entry.author:d.entry.author.name]})})]}),(0,q.jsx)(vn,{}),me&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`error`,children:[`Error: `,me]})}),(0,q.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(R,{children:[ue===t&&(0,q.jsx)(z,{children:`> `}),ue!==t&&(0,q.jsx)(z,{children:` `}),(0,q.jsx)(z,{bold:ue===t,children:fe&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,children:(0,q.jsxs)(B,{children:[(0,q.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(m.length===0)return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:_e}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Se=M.getVisibleItems(D);return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{bold:!0,children:`Discover plugins`}),M.needsPagination&&(0,q.jsxs)(z,{dimColor:!0,children:[` `,`(`,M.scrollPosition.current,`/`,M.scrollPosition.total,`)`]})]}),(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(Be,{query:C,isFocused:x,isTerminalFocused:ne,width:E-4,cursorOffset:T})}),P&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`warning`,children:[a.warning,` `,P]})}),D.length===0&&C&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`No plugins match "`,C,`"`]})}),M.scrollPosition.canScrollUp&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Se.map((t,n)=>{let r=M.toActualIndex(n),i=O===r,o=ie.has(t.pluginId),s=j.has(t.pluginId);return(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:n===Se.length-1&&!e?0:1,children:[(0,q.jsxs)(R,{children:[(0,q.jsxs)(z,{color:i&&!x?`suggestion`:void 0,children:[i&&!x?a.pointer:` `,` `]}),(0,q.jsxs)(z,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(z,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),y&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(z,{dimColor:!0,children:[` · `,Mt(y.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(R,{marginLeft:4,children:(0,q.jsx)(z,{dimColor:!0,children:ht(t.entry.description,60)})})]},`${M.startIndex}-${t.pluginId}`)}),M.scrollPosition.canScrollDown&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:ie.size>0,canToggle:O<D.length&&!D[O]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:(0,q.jsxs)(B,{children:[e&&(0,q.jsx)(k,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(z,{children:`type to search`}),t&&(0,q.jsx)(k,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(z,{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)(z,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(z,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(z,{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)(z,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(z,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(V(),1),K=t(V(),1),De(),Ut(),We(),Gt(),ye(),l(),nt(),me(),Qe(),et(),b(),kt(),v(),re(),s(),ee(),N(),C(),_t(),gt(),_n(),bn(),Tn(),kn(),q=qe()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:l}){let[u,d]=(0,Bn.useState)([]),[f,p]=(0,Bn.useState)(!0),[m,h]=(0,Bn.useState)(0),[g,_]=(0,Bn.useState)(!1),[v,y]=(0,Bn.useState)(null),[b,x]=(0,Bn.useState)(null),[ee,te]=(0,Bn.useState)(null),[S,C]=(0,Bn.useState)(`list`),[w,T]=(0,Bn.useState)(null),[ne,E]=(0,Bn.useState)(0),D=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await ce(),{enabled:r,disabled:i}=await c(),a=[...r,...i],{marketplaces:o,failures:u}=await je(e),f=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));f.push({name:e,source:fe(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}f.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(f);let p=he(u,tt(o,e=>e.data!==null));if(p)if(p.type===`warning`)y(p.message);else throw Error(p.message);if(s&&!D.current&&!t){D.current=!0;let e=f.findIndex(e=>e.name===s);if(e>=0){let t=f[e];if(l){h(e+1);let t=[...f];l===`update`?t[e].pendingUpdate=!0:l===`remove`&&(t[e].pendingRemove=!0),d(t),setTimeout(ae,100,t)}else t&&(h(e+1),T(t),C(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),y(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{p(!1)}}e()},[s,l,t]);let O=()=>u.some(e=>e.pendingUpdate||e.pendingRemove),re=()=>({updateCount:tt(u,e=>e.pendingUpdate),removeCount:tt(u,e=>e.pendingRemove)}),ae=async t=>{let i=t||u,s=S===`details`;_(!0),y(null),x(null),te(null);try{let t=rt(`userSettings`),n=0,l=0,u=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=oe(t.name,e.name);n[r]=!1}st(`userSettings`,{enabledPlugins:n})}await ie(e.name),l++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await Se(e.name,e=>{te(e)}),n++,u.add(e.name.toLowerCase()),mt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let f=0;u.size>0&&(f=(await en(u)).length),ke(),o&&await o();let p=await ce(),{enabled:m,disabled:h}=await c(),g=[...m,...h],{marketplaces:_}=await je(p),v=[];for(let{name:e,config:t,data:n}of _){let r=g.filter(t=>t.source.endsWith(`@${e}`));v.push({name:e,source:fe(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}if(v.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(v),s&&w){let e=v.find(e=>e.name===w.name);e&&T(e)}let y=[];if(n>0){let e=f>0?` (${f} ${H(f,`plugin`)} bumped)`:``;y.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(l>0&&y.push(`Removed ${l} ${H(l,`marketplace`)}`),y.length>0){let t=`${a.tick} ${y.join(`, `)}`;s?x(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Ye(e);y(t),n&&n(t)}finally{_(!1),te(null)}},j=async()=>{if(!w)return;let e=u.map(e=>e.name===w.name?{...e,pendingRemove:!0}:e);d(e),await ae(e)},se=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 lt()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},M=async e=>{let t=!e.autoUpdate;try{await A(e.name,t),d(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),T(e=>e&&{...e,autoUpdate:t})}catch(e){y(e instanceof Error?e.message:`Failed to update setting`)}};if(Ie(`confirm:no`,()=>{C(`list`),E(0)},{context:`Confirmation`,isActive:!g&&(S===`details`||S===`confirm-remove`)}),Ie(`confirm:no`,()=>{d(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),h(0)},{context:`Confirmation`,isActive:!g&&S===`list`&&O()}),Ie(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!g&&S===`list`&&!O()}),L({"select:previous":()=>h(e=>Math.max(0,e-1)),"select:next":()=>{let e=u.length+1;h(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=m-1;if(m===0)e({type:`add-marketplace`});else if(O())ae();else{let e=u[t];e&&(T(e),C(`details`),E(0))}}},{context:`Select`,isActive:!g&&S===`list`}),Re(e=>{let t=m-1;if((e===`u`||e===`U`)&&t>=0)d(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=u[t];e&&(T(e),C(`confirm-remove`))}},{isActive:!g&&S===`list`}),L({"select:previous":()=>E(e=>Math.max(0,e-1)),"select:next":()=>{let e=se(w);E(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!w)return;let t=se(w)[ne];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:w.name});else if(t?.value===`update`){let e=u.map(e=>e.name===w.name?{...e,pendingUpdate:!0}:e);d(e),ae(e)}else t?.value===`toggle-auto-update`?M(w):t?.value===`remove`&&C(`confirm-remove`)}},{context:`Select`,isActive:!g&&S===`details`}),Re(e=>{e===`y`||e===`Y`?j():(e===`n`||e===`N`)&&(C(`list`),T(null))},{isActive:!g&&S===`confirm-remove`}),f)return(0,J.jsx)(z,{children:`Loading marketplaces…`});if(u.length===0)return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(z,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(B,{children:[(0,J.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(S===`confirm-remove`&&w){let e=w.installedPlugins?.length||0;return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsxs)(z,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(z,{italic:!0,children:w.name}),`?`]}),(0,J.jsxs)(R,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),w.installedPlugins&&w.installedPlugins.length>0&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,marginLeft:2,children:w.installedPlugins.map(e=>(0,J.jsxs)(z,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[`Press `,(0,J.jsx)(z,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(z,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(S===`details`&&w){let e=w.pendingUpdate||g,t=se(w);return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{bold:!0,children:w.name}),(0,J.jsx)(z,{dimColor:!0,children:w.source}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[w.pluginCount||0,` available `,H(w.pluginCount||0,`plugin`)]})}),w.installedPlugins&&w.installedPlugins.length>0&&(0,J.jsxs)(R,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(z,{bold:!0,children:[`Installed plugins (`,w.installedPlugins.length,`):`]}),(0,J.jsx)(R,{flexDirection:`column`,marginLeft:1,children:w.installedPlugins.map(e=>(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(z,{children:a.bullet}),(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{children:e.name}),(0,J.jsx)(z,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(z,{color:`claude`,children:`Updating marketplace…`}),ee&&(0,J.jsx)(z,{dimColor:!0,children:ee})]}),!e&&b&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:b})}),!e&&v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),!e&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===ne;return(0,J.jsxs)(R,{children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(z,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!lt()&&w.autoUpdate&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(B,{children:[(0,J.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:le,removeCount:ue}=re();return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:m===0?`suggestion`:void 0,children:[m===0?a.pointer:` `,` +`]}),(0,J.jsx)(z,{bold:!0,color:m===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(R,{flexDirection:`column`,children:u.map((e,t)=>{let n=t+1===m,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(R,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(z,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(z,{dimColor:!0,children:e.source}),(0,J.jsxs)(z,{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)})}),O()&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(z,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(z,{dimColor:!0,children:`Enter to apply`})]}),le>0&&(0,J.jsxs)(z,{children:[`• Update `,le,` `,H(le,`marketplace`)]}),ue>0&&(0,J.jsxs)(z,{color:`warning`,children:[`• Remove `,ue,` `,H(ue,`marketplace`)]})]}),g&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:`Processing changes…`})}),v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:O()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:(0,J.jsxs)(B,{children:[t&&(0,J.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(Ne,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(Ne,{shortcut:`r`,action:`remove`}),(0,J.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),V(),Bn=t(V(),1),pt(),De(),We(),l(),nt(),ut(),et(),b(),re(),s(),tn(),x(),ot(),at(),_t(),J=qe()}));function Hn(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 j(e)}function Un(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 Wn=e((()=>{Te()}));function Gn({item:e,isSelected:t}){let[n]=Fe();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=ze(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=ze(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=ze(`success`,n)(a.tick),i=`enabled`):(r=ze(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=ze(`warning`,n)(a.warning);return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=ze(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=ze(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=ze(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=ze(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=ze(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=ze(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{dimColor:!t,children:`└ `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]}):(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),V(),We(),_t(),Y=qe()}));async function qn(e){try{return(await rn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>nn.basename(e.name,`.md`))}catch(t){return $e(`Failed to read plugin components from ${e}: ${Ye(t)}`,{level:`error`}),ft(Ze(t)),[]}}async function Jn(e){try{let t=await rn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=nn.join(e,r.name,`SKILL.md`);try{(await rn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return $e(`Failed to read skill directories from ${e}: ${Ye(t)}`,{level:`error`}),ft(Ze(t)),[]}}function Yn({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=O(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 ne(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 qn(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 qn(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 Jn(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)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Components:`}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(z,{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)(z,{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)(z,{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)(z,{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)(z,{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 Xn(e,t){let n=(await ne(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 Zn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!p(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=we(e=>e.mcp.clients),u=we(e=>e.mcp.tools),d=we(e=>e.plugins.errors),f=It(),[p,m]=(0,X.useState)(!1),h=(0,X.useCallback)(e=>{m(e),r?.(e)},[r]),_=Le(),{columns:v}=He(),[y,b]=(0,X.useState)(`plugin-list`),{query:x,setQuery:ee,cursorOffset:te}=Wt({isActive:y===`plugin-list`&&p,onExit:()=>{h(!1)}}),[S,C]=(0,X.useState)(null),[T,ne]=(0,X.useState)([]),[E,O]=(0,X.useState)([]),[re,ie]=(0,X.useState)(!0),[A,oe]=(0,X.useState)(new Map),j=(0,X.useRef)(!1),ce=(0,X.useRef)(void 0),le=zt();Ie(`confirm:no`,$n.useCallback(()=>{if(y===`plugin-details`)b(`plugin-list`),C(null),I(null);else if(typeof y==`object`&&y.type===`failed-plugin-details`)b(`plugin-list`),I(null);else if(y===`configuring`)b(`plugin-details`),Te(null);else if(typeof y==`object`&&(y.type===`plugin-options`||y.type===`configuring-options`))b(`plugin-list`),C(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof y==`object`&&y.type===`flagged-detail`)b(`plugin-list`),I(null);else if(typeof y==`object`&&y.type===`mcp-detail`)b(`plugin-list`),I(null);else if(typeof y==`object`&&y.type===`mcp-tools`)b({type:`mcp-detail`,client:y.client});else if(typeof y==`object`&&y.type===`mcp-tool-detail`)b({type:`mcp-tools`,client:y.client});else{if(A.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[y,e,A,t]),{context:`Confirmation`,isActive:(y!==`plugin-list`||!p)&&y!==`confirm-project-uninstall`&&!(typeof y==`object`&&y.type===`confirm-data-cleanup`)});let de=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,fe=(0,X.useMemo)(()=>{let e=it(),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 E){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=d.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:A.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 d){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=yt(),s=[];for(let[e,t]of a){if(e in f)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:de(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],m=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;m.has(n)||m.set(n,[]),m.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;m.has(r)||m.set(r,[]),m.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:de(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let e of s){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let[e,t]of Object.entries(f)){let n=be(e),r=n.name||e,i=n.marketplace||`unknown`;m.has(`flagged`)||m.set(`flagged`,[]),m.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let h=[...m.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of h){let t=m.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)p.push(...e);p.push(...r)}return p},[E,l,d,A,f]),me=(0,X.useMemo)(()=>fe.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[fe]);(0,X.useEffect)(()=>{me.length>0&&Ft(me)},[me]);let N=(0,X.useMemo)(()=>{if(!x)return fe;let e=x.toLowerCase();return fe.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[fe,x]),[P,he]=(0,X.useState)(0),_e=En({totalItems:N.length,selectedIndex:P,maxVisible:8}),[ve,ye]=(0,X.useState)(0),[xe,F]=(0,X.useState)(!1),[Se,I]=(0,X.useState)(null),[Ce,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(!1),[Oe,Ae]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!S){Ae(!1);return}async function e(){let e=S.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&M(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&M(e))),!t)try{let e=nn.join(S.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Je(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===S.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&M(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&M(e))}}catch(e){$e(`Failed to read raw marketplace.json: ${e}`)}Ae(t)}e()},[S]),(0,X.useEffect)(()=>{async function e(){ie(!0);try{let{enabled:e,disabled:t}=await c(),n=it(),r=Zn([...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=tt(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)),ne(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:Tt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}O(o),he(0)}finally{ie(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!j.current&&i&&T.length>0&&!re){let{name:e,marketplace:n}=be(i),r=o??n,a=r?T.filter(e=>e.name===r):T;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};C(r),b(`plugin-details`),ce.current=s,j.current=!0;return}}let c=fe.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(b({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),j.current=!0),!j.current&&s&&(j.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,T,re,fe,s,t]);let je=async r=>{if(!S)return;let i=S.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){I(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){I(`This plugin is managed by your organization. Contact your admin to disable it.`);return}F(!0),I(null);try{let o=`${S.plugin.name}@${S.marketplace}`,s;switch(r){case`enable`:{let e=await bt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await Ct(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!wt(i))break;if(Dt(o)){F(!1),b(`confirm-project-uninstall`);return}let e=w().plugins[o],t=!e||e.length<=1?await se(o):null;if(t){F(!1),b({type:`confirm-data-cleanup`,size:t});return}let n=await xt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await St(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${S.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}ke();let c=`${S.plugin.name}@${S.marketplace}`;if(it()?.enabledPlugins?.[c]!==!1){F(!1),b({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} ${S.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){F(!1);let t=e instanceof Error?e.message:String(e);I(`Failed to ${r}: ${t}`),ft(Ze(e))}},Me=(0,X.useRef)(je);Me.current=je,(0,X.useEffect)(()=>{if(y===`plugin-details`&&S&&ce.current){let e=ce.current;ce.current=void 0,Me.current(e)}},[y,S]);let Ne=$n.useCallback(()=>{if(P>=N.length)return;let e=N[P];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=it(),r=A.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(A);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),ke()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),ke()}catch(e){ft(e)}})()),oe(e)}}else e?.type===`mcp`&&le(e.client.name)},[P,N,A,E,le]);L({"select:previous":()=>{P===0?h(!0):_e.handleSelectionChange(P-1,he)},"select:next":()=>{P<N.length-1&&_e.handleSelectionChange(P+1,he)},"select:accept":$n.useCallback(()=>{if(P>=N.length)return;let e=N[P];if(e?.type===`plugin`){let t=E.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(C(t),b(`plugin-details`),ye(0),I(null))}else e?.type===`flagged-plugin`?(b({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),I(null)):e?.type===`failed-plugin`?(b({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),ye(0),I(null)):e?.type===`mcp`&&(b({type:`mcp-detail`,client:e.client}),I(null))},[P,N,E])},{context:`Select`,isActive:y===`plugin-list`&&!p}),L({"plugin:toggle":Ne},{context:`Plugin`,isActive:y===`plugin-list`&&!p}),L({"select:accept":$n.useCallback(()=>{typeof y!=`object`||y.type!==`flagged-detail`||(Lt(y.plugin.id),b(`plugin-list`))},[y])},{context:`Select`,isActive:typeof y==`object`&&y.type===`flagged-detail`});let Pe=$n.useMemo(()=>{if(y!==`plugin-details`||!S)return[];let e=it(),t=`${S.plugin.name}@${S.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=S.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void je(n?`disable`:`enable`)}),r||(i.push({label:S.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(S.plugin.name,S.marketplace);if(e){I(e);return}let t=[...E],n=t.findIndex(e=>e.plugin.name===S.plugin.name&&e.marketplace===S.marketplace);n!==-1&&(t[n].pendingUpdate=!S.pendingUpdate,O(t),C({...S,pendingUpdate:!S.pendingUpdate}))}catch(e){I(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Oe&&i.push({label:`Configure`,action:async()=>{De(!0);try{let e=S.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&M(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&M(n)){t=n;break}}if(!t){I(`No MCPB file found in plugin`),De(!1);return}let n=`${S.plugin.name}@${S.marketplace}`,r=await ge(t,S.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Te(r),b(`configuring`)):I(`Failed to load MCPB for configuration`)}catch(e){let t=Ye(e);I(`Failed to load configuration: ${t}`)}finally{De(!1)}}}),S.plugin.manifest.userConfig&&Object.keys(S.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{b({type:`configuring-options`,schema:S.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void je(`update`)}),i.push({label:`Uninstall`,action:()=>void je(`uninstall`)})),S.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void ae(S.plugin.manifest.homepage)}),S.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void ae(S.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{b(`plugin-list`),C(null),I(null)}}),i},[y,S,Oe,E]);if(L({"select:previous":()=>{ve>0&&ye(ve-1)},"select:next":()=>{ve<Pe.length-1&&ye(ve+1)},"select:accept":()=>{Pe[ve]&&Pe[ve].action()}},{context:`Select`,isActive:y===`plugin-details`&&!!S}),L({"select:accept":()=>{typeof y==`object`&&y.type===`failed-plugin-details`&&(async()=>{F(!0),I(null);let e=y.plugin.id,t=y.plugin.scope,r=wt(t)?await xt(e,t,!1):await xt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=rt(t);n?.enabledPlugins?.[e]!==void 0&&(st(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}ke()}i?(n&&await n(),F(!1),b(`plugin-list`)):(F(!1),I(r.message))})()}},{context:`Select`,isActive:typeof y==`object`&&y.type===`failed-plugin-details`&&y.plugin.scope!==`managed`}),L({"confirm:yes":()=>{if(!S)return;F(!0),I(null);let r=`${S.plugin.name}@${S.marketplace}`,{error:i}=st(`localSettings`,{enabledPlugins:{...rt(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){F(!1),I(`Failed to write settings: ${i.message}`);return}ke(),t(`✓ Disabled ${S.plugin.name} in .claude/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{b(`plugin-details`),I(null)}},{context:`Confirmation`,isActive:y===`confirm-project-uninstall`&&!!S&&!xe}),Re((r,i)=>{if(!S)return;let o=`${S.plugin.name}@${S.marketplace}`,s=S.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{F(!0),I(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);ke();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){F(!1),I(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(b(`plugin-details`),I(null))},{isActive:typeof y==`object`&&y.type===`confirm-data-cleanup`&&!!S&&!xe}),$n.useEffect(()=>{he(0)},[x]),Re((e,t)=>{let n=!t.ctrl&&!t.meta;p||(e===`/`&&n?(h(!0),ee(``),he(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(h(!0),ee(e),he(0)))},{isActive:y===`plugin-list`}),re)return(0,Z.jsx)(z,{children:`Loading installed plugins…`});if(fe.length===0)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(z,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Esc to go back`})})]});if(typeof y==`object`&&y.type===`plugin-options`&&S){let r=`${S.plugin.name}@${S.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:S.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${S.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${S.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof y==`object`&&y.type===`configuring-options`&&S){let e=`${S.plugin.name}@${S.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${S.plugin.name}`,subtitle:`Plugin options`,configSchema:y.schema,initialValues:D(e),onSave:n=>{try{g(e,n,y.schema),ke(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){I(`Failed to save configuration: ${Ye(e)}`)}b(`plugin-details`)},onCancel:()=>b(`plugin-details`)})}if(y===`configuring`&&Ce&&S){let e=`${S.plugin.name}@${S.marketplace}`;async function n(n){if(!(!Ce||!S))try{let r=S.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&M(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&M(e)){i=e;break}}if(!i){I(`No MCPB file found`),b(`plugin-details`);return}await ge(i,S.plugin.path,e,void 0,n),I(null),Te(null),b(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Ye(e);I(`Failed to save configuration: ${t}`),b(`plugin-details`)}}function r(){Te(null),b(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${Ce.manifest.name}`,subtitle:`Plugin: ${S.plugin.name}`,configSchema:Ce.configSchema,initialValues:Ce.existingConfig,onSave:n,onCancel:r})}if(typeof y==`object`&&y.type===`flagged-detail`){let e=y.plugin;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(R,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(z,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(z,{children:e.text}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsxs)(z,{children:[a.pointer,` `]}),(0,Z.jsx)(z,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(y===`confirm-project-uninstall`&&S)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,color:`warning`,children:[S.plugin.name,` is enabled in .claude/settings.json (shared with your team)`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Disable it just for you in .claude/settings.local.json?`}),(0,Z.jsx)(z,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),Se&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Se})}),(0,Z.jsx)(R,{marginTop:1,children:xe?(0,Z.jsx)(z,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(k,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof y==`object`&&y.type===`confirm-data-cleanup`&&S)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,children:[S.plugin.name,` has `,y.size.human,` of persistent data`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(z,{dimColor:!0,children:pe(`${S.plugin.name}@${S.marketplace}`)})]}),Se&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Se})}),(0,Z.jsx)(R,{marginTop:1,children:xe?(0,Z.jsx)(z,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(z,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(z,{bold:!0,children:`esc`}),` to cancel`]})})]});if(y===`plugin-details`&&S){let e=it(),t=`${S.plugin.name}@${S.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===S.plugin.name||e.source===t||e.source.startsWith(`${S.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(z,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(R,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(z,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(z,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[S.plugin.name,` @ `,S.marketplace]})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(z,{children:S.scope||`user`})]}),S.plugin.manifest.version&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(z,{children:S.plugin.manifest.version})]}),S.plugin.manifest.description&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{children:S.plugin.manifest.description})}),S.plugin.manifest.author&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(z,{children:S.plugin.manifest.author.name})]}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),S.pendingUpdate&&(0,Z.jsx)(z,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:S.plugin,marketplace:S.marketplace}),i,(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:Pe.map((e,t)=>{let n=t===ve;return(0,Z.jsxs)(R,{children:[n&&(0,Z.jsxs)(z,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(z,{children:` `}),(0,Z.jsx)(z,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),xe&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{children:`Processing…`})}),Se&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Se})}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(k,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`failed-plugin-details`){let e=y.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:e.name}),(0,Z.jsxs)(z,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(z,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(R,{marginTop:1,children:[(0,Z.jsxs)(z,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(z,{bold:!0,children:`Remove`})]}),xe&&(0,Z.jsx)(z,{children:`Processing…`}),Se&&(0,Z.jsx)(z,{color:`error`,children:Se}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[e.scope!==`managed`&&(0,Z.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`mcp-detail`){let e=y.client,n=ue(u,e.name).length,r=()=>{b({type:`mcp-tools`,client:e})},i=()=>{b(`plugin-list`)},a=e=>{e&&t(e),b(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Kt,{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)(Qt,{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)(Qt,{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)(Qt,{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}):(b(`plugin-list`),null)}if(typeof y==`object`&&y.type===`mcp-tools`){let e=y.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)($t,{server:r,onSelectTool:t=>{b({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>b({type:`mcp-detail`,client:e})})}if(typeof y==`object`&&y.type===`mcp-tool-detail`){let{client:e,tool:t}=y,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)(Zt,{tool:t,server:i,onBack:()=>b({type:`mcp-tools`,client:e})})}let Fe=_e.getVisibleItems(N);return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(Be,{query:x,isFocused:p,isTerminalFocused:_,width:v-4,cursorOffset:te})}),N.length===0&&x&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsxs)(z,{dimColor:!0,children:[`No items match "`,x,`"`]})}),_e.scrollPosition.canScrollUp&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Fe.map((e,t)=>{let n=_e.toActualIndex(t)===P&&!p,r=t>0?Fe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(R,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(z,{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)(Gn,{item:e,isSelected:n})]},e.id)}),_e.scrollPosition.canScrollDown&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(R,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(z,{children:`type to search`}),(0,Z.jsx)(k,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),A.size>0&&(0,Z.jsx)(R,{marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(V(),1),X=t(V(),1),De(),We(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),ye(),l(),_(),Bt(),Ae(),Et(),_e(),nt(),me(),Qe(),et(),dt(),b(),v(),s(),o(),F(),Rt(),d(),x(),T(),C(),vt(),at(),Xe(),_t(),Wn(),fn(),_n(),Kn(),kn(),Z=qe()}));function tr(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 nr=e((()=>{}));function rr({onComplete:e,path:t}){return(0,ir.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 jt(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,ft(t),e(`${a.cross} Unexpected error during validation: ${Ye(t)}`)}}n()},[e,t]),(0,ar.jsx)(R,{flexDirection:`column`,children:(0,ar.jsx)(z,{children:`Running validation...`})})}var ir,ar,or=e((()=>{i(),V(),ir=t(V(),1),We(),et(),dt(),Pt(),_t(),ar=qe()}));function sr({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await ce(),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: ${Ye(t)}`)}}t()},[e]),(0,$.jsx)(z,{children:`Loading marketplaces...`})}function cr(e){let t=[];for(let{source:n,scope:r}of[{source:`userSettings`,scope:`user`},{source:`projectSettings`,scope:`project`},{source:`localSettings`,scope:`local`}])rt(n)?.extraKnownMarketplaces?.[e]&&t.push({source:n,scope:r});return{editableSources:t,isInPolicy:!!rt(`policySettings`)?.extraKnownMarketplaces?.[e]}}function lr(e){let{editableSources:t,isInPolicy:n}=cr(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 ur(e){return{kind:`navigate`,tab:`installed`,viewState:{type:`manage-plugins`,targetPlugin:e,action:`uninstall`}}}function dr(e){return yr.has(e.type)}function fr(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 pr(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:Hn(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=lr(t.name),n=cr(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=lr(t),r=cr(t),i=r.isInPolicy?`managed`:r.editableSources[0]?.scope;s.push({label:t,message:Hn(e),guidance:n.kind===`managed-only`?`Managed by your organization — contact your admin`:Un(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=fr(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:Hn(e),guidance:Un(e),action:t?ur(t):{kind:`none`},scope:r})}for(let e of r)s.push({label:e.source,message:Hn(e),guidance:Un(e),action:{kind:`none`}});return s}function mr(e,t){for(let{source:n}of t){let t=rt(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&&st(n,r)}}function hr({setViewState:e,setActiveTab:t,markPluginsChanged:n}){let r=we(e=>e.plugins.errors),i=we(e=>e.plugins.installationStatus),o=P(),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await je(await ce());f(e)}catch{}})()},[]);let p=i.marketplaces.filter(e=>e.status===`failed`),m=new Set(p.map(e=>e.name)),h=r.filter(dr),g=pr(p,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!m.has(e.marketplace)),r.filter(e=>dr(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:fr(e)!==void 0),r.filter(e=>dr(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:fr(e)===void 0),d,h,yt());Ie(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),L({"select:previous":()=>c(e=>Math.max(0,e-1)),"select:next":()=>c(e=>Math.min(g.length-1,e+1)),"select:accept":()=>{let r=g[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(`, `);mr(i.name,i.sources),ke(),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)}}})),u(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await ie(i.name),ke(),f(e=>e.filter(e=>e.name!==i.name)),u(`${a.tick} Removed marketplace "${i.name}"`),n()}catch(e){u(`Failed to remove "${i.name}": ${e instanceof Error?e.message:String(e)}`)}})();break;case`managed-only`:break;case`none`:break}}},{context:`Select`,isActive:g.length>0});let _=Math.min(s,Math.max(0,g.length-1));_!==s&&c(_);let v=g[_]?.action,y=v&&v.kind!==`none`&&v.kind!==`managed-only`;return g.length===0?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(R,{marginLeft:1,children:(0,$.jsx)(z,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(R,{flexDirection:`column`,children:[g.map((e,t)=>{let n=t===_;return(0,$.jsxs)(R,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(z,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),l&&(0,$.jsx)(R,{marginTop:1,marginLeft:1,children:(0,$.jsx)(z,{color:`claude`,children:l})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(k,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),y&&(0,$.jsx)(k,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}function gr(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 _r(e){return e.type===`manage-plugins`?`installed`:e.type===`manage-marketplaces`?`marketplaces`:`discover`}function vr({onComplete:e,args:t}){let n=tr(t),r=gr(n),[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(_r(r)),[c,l]=(0,Q.useState)(i.type===`add-marketplace`&&i.initialValue||``),[u,d]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=P(),y=we(e=>{let t=e.plugins.errors.length;for(let n of e.plugins.installationStatus.marketplaces)n.status===`failed`&&t++;return t}),b=y>0?`Errors (${y})`:`Errors`,x=Vt(),ee=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,te=(0,Q.useCallback)(()=>{v(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[v]),S=(0,Q.useCallback)(e=>{let t=e;switch(s(t),p(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`&&!m&&e()},[i.type,m,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&o!==`discover`&&s(`discover`)},[i.type,o]),Ie(`confirm:no`,(0,Q.useCallback)(()=>{s(`marketplaces`),a({type:`manage-marketplaces`}),l(``),p(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{m&&e(m)},[m,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(z,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(z,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(z,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(z,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Management:`}),(0,$.jsx)(z,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(z,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(z,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(z,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(z,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(z,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(z,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(z,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(z,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Other:`}),(0,$.jsx)(z,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(z,{children:` /plugin help - Show this help`}),(0,$.jsx)(z,{children:` /plugins - Alias for /plugin`})]}):i.type===`validate`?(0,$.jsx)(rr,{onComplete:e,path:i.path}):i.type===`marketplace-menu`?(a({type:`menu`}),null):i.type===`marketplace-list`?(0,$.jsx)(sr,{onComplete:e}):i.type===`add-marketplace`?(0,$.jsx)(an,{inputValue:c,setInputValue:l,cursorOffset:u,setCursorOffset:d,error:f,setError:p,result:m,setResult:h,setViewState:a,onAddComplete:te,cliMode:ee}):(0,$.jsx)(Ge,{color:`suggestion`,children:(0,$.jsxs)(Ue,{title:`Plugins`,selectedTab:o,onTabChange:S,color:`suggestion`,disableNavigation:g,children:[(0,$.jsx)(Ve,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(An,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:te,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Nn,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:te,onSearchModeChange:_,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(Ve,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Qn,{setViewState:a,setResult:h,onManageComplete:te,onSearchModeChange:_,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)(Ve,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Rn,{setViewState:a,error:f,setError:p,setResult:h,exitState:x,onManageComplete:te,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(Ve,{id:`errors`,title:b,children:(0,$.jsx)(hr,{setViewState:a,setActiveTab:s,markPluginsChanged:te})})]})})}var Q,$,yr,br=e((()=>{i(),V(),Q=t(V(),1),De(),We(),Ht(),l(),_e(),et(),b(),re(),s(),vt(),at(),sn(),Mn(),Ln(),Vn(),er(),Wn(),nr(),or(),$=qe(),yr=new Set([`git-auth-failed`,`git-timeout`,`network-error`])}));async function xr(e,t,n){return(0,Sr.jsx)(vr,{onComplete:e,args:n})}var Sr;e((()=>{V(),br(),Sr=qe()}))();export{xr as call};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$o as t,Bo as n,GE as r,Ro as i,Uo as a,Yo as o,es as s,qE as c,rs as l}from"./loadAgentsDir-CKSb56Gp.js";import{F as u,a as d,l as f,z as p}from"./debug-BdqxZ7rV.js";import{vt as m,xt as h}from"./settings-Xbq6AaD-.js";import{b as g,h as _}from"./config-D4G8_MqJ.js";import{o as v,s as y}from"./log-CTFl4qpD.js";import{f as b,s as x}from"./pluginOperations-BTq4AjYB.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await s(),t=o(),n=new Set;for(let[r,i]of Object.entries(e)){let e=t[r]?.autoUpdate;(e===void 0?h(r,i):e)&&n.add(r.toLowerCase())}return n}async function w(e,t){let n=!1;for(let{scope:r}of t)try{let t=await b(e,r);t.success&&!t.alreadyUpToDate?(n=!0,f(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||f(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){f(`Plugin autoupdate: error updating ${e}: ${u(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=a(),r=Object.keys(t.plugins);return r.length===0?[]:(await Promise.allSettled(r.map(async r=>{let{marketplace:i}=c(r);if(!i||!e.has(i.toLowerCase()))return null;let a=t.plugins[r];if(!a||a.length===0)return null;let o=a.filter(n);return o.length===0?null:w(r,o)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(g()){f(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let t=(await Promise.allSettled(Array.from(e).map(async e=>{try{await l(e,void 0,{disableCredentialHelper:!0})}catch(t){f(`Plugin autoupdate: failed to refresh marketplace ${e}: ${u(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);t.length>0&&f(`Plugin autoupdate: ${t.length} marketplace refresh(es) failed`,{level:`warn`}),f(`Plugin autoupdate: checking installed plugins`);let n=await E(e);n.length>0&&(O?O(n):k=n)}catch(e){y(e)}})()}var O,k,A=e((()=>{x(),_(),d(),p(),v(),i(),t(),r(),m(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$o as e,Ro as t,Wo as n,Xo as r,ts as i}from"./loadAgentsDir-CKSb56Gp.js";import{F as a,a as o,l as s,z as c}from"./debug-BdqxZ7rV.js";import{d as l,s as u}from"./pluginOperations-BTq4AjYB.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-CxuRF2Vc.js";u(),o(),c(),t(),e(),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=n(),t=f(),o=await i(),c=[];for(let n of Object.keys(o))try{let i=await r(n);if(!i.forceRemoveDeletedPlugins)continue;let o=h(e,i,n);for(let n of o){if(n in t)continue;let r=e.plugins[n]??[];if(r.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let e of r){let{scope:t}=e;if(!(t!==`user`&&t!==`project`&&t!==`local`))try{await l(n,t)}catch(e){s(`Failed to auto-uninstall delisted plugin ${n} from ${t}: ${a(e)}`,{level:`error`})}}await m(n),c.push(n)}}}catch(e){s(`Failed to check for delisted plugins in "${n}": ${a(e)}`,{level:`warn`})}return c}export{g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{GE as n,Gf as r,Io as i,Lo as a,Uf as o,Wf as s,ff as c,qE as l,uf as u}from"./loadAgentsDir-CKSb56Gp.js";import{F as d,z as f}from"./debug-BdqxZ7rV.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-CTFl4qpD.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-BTq4AjYB.js";e(),f(),c(),h(),a(),n(),p(),r(),_(),T();function E(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}: ${d(e)}`);let c=r?(()=>{let{name:e,marketplace:t}=l(r);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...o(e,t,i())}})():{};v(`tengu_plugin_command_failed`,{command:n,error_category:s(e),...c}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await b(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:s}=l(r.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:a,...s&&{_PROTO_marketplace_name:s},scope:r.scope||n,install_source:`cli-explicit`,...o(a,s,i())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,r=!1){try{let a=await x(e,n,!r);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:s,marketplace:c}=l(a.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:s,...c&&{_PROTO_marketplace_name:c},scope:a.scope||n,...o(s,c,i())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:s}=l(r.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:a,...s&&{_PROTO_marketplace_name:s},scope:r.scope,...o(a,s,i())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let r=await C(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:s}=l(r.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:a,...s&&{_PROTO_marketplace_name:s},scope:r.scope,...o(a,s,i())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),v(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await S(e,n);if(!r.success)throw Error(r.message);if(m(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=l(r.pluginId||e);v(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:r.oldVersion||`unknown`,new_version:r.newVersion||`unknown`,...o(t,n,i())})}await u(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$E as t,$T as n,$o as r,Ao as i,Co as a,Cs as o,Eo as s,Fo as c,GE as l,Go as u,HE as d,Hv as f,JC as p,JE as m,Ko as h,No as g,Oo as _,Po as v,QE as y,Qo as b,Ro as x,So as S,Ss as C,To as w,UE as T,Uo as E,Vv as D,WE as O,Wo as k,XC as ee,Xo as te,bo as ne,es as A,jo as j,qE as M,rE as re,wo as ie,xs as N}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as ae,tt as P}from"./state-Bs5xweDL.js";import{V as F,W as oe,d as se,p as ce,z as I}from"./debug-BdqxZ7rV.js";import{c as L,g as R,x as z}from"./settings-Xbq6AaD-.js";import{o as B,s as V}from"./log-CTFl4qpD.js";import{l as H,o as U}from"./stringUtils-CbS6OkmE.js";import{n as W,t as G}from"./pluginStartupCheck-B6leNWq9.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`?P():void 0}function de(e){return L(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=L(m(n))?.enabledPlugins;if(r){for(let i of Object.keys(r))if(t?i===e:i.startsWith(`${e}@`))return{pluginId:i,scope:n}}}return null}function pe(e,t){let{name:n,marketplace:r}=M(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}=M(e),n=k();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=M(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=k().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=P(),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 a=t.find(e=>e.scope===`user`);return a?{scope:a.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=M(e),a,o,s;if(r){let t=await b(e);t&&(a=t.entry,o=r,s=t.marketplaceInstallLocation)}else{let e=await A();for(let[t,r]of Object.entries(e))try{let e=(await te(t)).plugins.find(e=>e.name===n);if(e){a=e,o=t,s=r.installLocation;break}}catch(e){V(oe(e))}}if(!a||!o)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let c=a,l=`${c.name}@${o}`,u=await g({pluginId:l,entry:c,scope:t,marketplaceInstallLocation:s});if(!u.ok){let e=u;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:i(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: ${l} (scope: ${t})${u.depNote}`,pluginId:l,pluginName:c.name,scope:t}}async function ge(e,t=`user`,r=!0){q(t);let{enabled:i,disabled:a}=await s(),c=[...i,...a],l=pe(e,c),f=m(t),h=L(f),g,_;if(l)g=Object.keys(h?.enabledPlugins??{}).find(t=>t===e||t===l.name||t.startsWith(`${l.name}@`))??(e.includes(`@`)?e:l.name),_=l.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};g=t.pluginId,_=t.pluginName}let v=J(t),y=k().plugins[g],b=y?.find(e=>e.scope===t&&e.projectPath===v);if(!b){let{scope:n}=Y(g);return n!==t&&y&&y.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.claude/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 x=b.installPath,S={...h?.enabledPlugins};S[g]=void 0,z(f,{enabledPlugins:S}),N(),u(g,t,v);let C=k().plugins[g],w=!C||C.length===0;w&&x&&await o(x),w&&(p(g),r&&await n(g));let E=d(g,c),D=T(E);return{success:!0,message:`Successfully uninstalled plugin: ${_} (scope: ${t})${D}`,pluginId:g,pluginName:_,scope:t,reverseDependents:E.length>0?E:void 0}}async function X(e,n,r){let i=n?`enable`:`disable`;if(t(e)){let{error:t}=z(`userSettings`,{enabledPlugins:{...L(`userSettings`)?.enabledPlugins,[e]:n}});if(t)return{success:!1,message:`Failed to ${i} built-in plugin: ${t.message}`};N();let{name:r}=M(e);return{success:!0,message:`Successfully ${i}d built-in plugin: ${r}`,pluginId:e,pluginName:r,scope:`user`}}r&&q(r);let a,o,c=fe(e);if(r)if(o=r,c)a=c.pluginId;else if(e.includes(`@`))a=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)a=c.pluginId,o=c.scope;else if(e.includes(`@`))a=e,o=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(n&&f(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let l=m(o),u=L(l)?.enabledPlugins?.[a],p={user:0,project:1,local:2},h=r&&c&&p[r]>p[c.scope];if(r&&u===void 0&&c&&c.scope!==r&&!h)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${r}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(n===(r&&!h?u===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${n?`enabled`:`disabled`}${r?` at ${r} scope`:``}`};let g;if(!n){let{enabled:e,disabled:t}=await s(),n=d(a,[...e,...t]);n.length>0&&(g=n)}let{error:_}=z(l,{enabledPlugins:{...L(l)?.enabledPlugins,[a]:n}});if(_)return{success:!1,message:`Failed to ${i} plugin: ${_.message}`};N();let{name:v}=M(a),y=T(g);return{success:!0,message:`Successfully ${i}d plugin: ${v} (scope: ${o})${y}`,pluginId:a,pluginName:v,scope:o,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}=M(e),i=r?`${n}@${r}`:e,a=await b(e);if(!a)return{success:!1,message:`Plugin "${n}" not found`,pluginId:i,scope:t};let{entry:o,marketplaceInstallLocation:s}=a,c=E().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:s,projectPath:c}){let l=se(),u=i.version,d,f,p=!1,m;if(typeof n.source!=`string`){let t=await ne(n.source,{manifest:{name:n.name}});d=t.path,p=!0,m=t.gitCommitSha,f=await v(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await l.stat(r)}catch(t){if(F(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:s};throw t}d=K(t.isDirectory()?r:le(r),n.source);try{await l.stat(d)}catch(t){if(F(t))return{success:!1,message:`Plugin source not found at ${d}`,pluginId:e,scope:s};throw t}let i,a=K(d,`.claude-plugin`,`plugin.json`);try{i=await _(a,n.name,n.source)}catch{}f=await v(e,n.source,i,d,n.version)}try{let r=a(e,f),l=ie(e,f);if(i.version===f||i.installPath===r||i.installPath===l)return{success:!0,message:`${t} is already at the latest version (${f}).`,pluginId:e,newVersion:f,oldVersion:u,alreadyUpToDate:!0,scope:s};r=await S(d,e,f,n);let p=i.installPath;if(h(e,s,c,r,f,m),p&&p!==r){let e=E();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===p))||await o(p)}let g=c?`${s} (${c})`:s;return{success:!0,message:`Plugin "${t}" updated from ${u||`unknown`} to ${f} for scope ${g}. Restart to apply changes.`,pluginId:e,newVersion:f,oldVersion:u,scope:s}}finally{p&&d!==a(e,f)&&await l.rm(d,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{ae(),y(),I(),ce(),B(),C(),O(),x(),r(),re(),l(),j(),w(),ee(),D(),W(),c(),R(),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-B6leNWq9.js";e();export{t as getPluginEditableScopes};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{$o as n,Eo as r,GE as i,Ho as a,JE as o,KC as s,Ro as c,Ss as l,To as u,Wo as d,_s as f,as as p,ds as m,eD as h,es as g,ns as _,qC as v,qE as y,qo as b,rs as x,ss as S,tD as C,xs as w,ys as T}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as ee,or as E}from"./state-Bs5xweDL.js";import{F as D,S as te,w as O,z as k}from"./debug-BdqxZ7rV.js";import{o as ne,s as A}from"./log-CTFl4qpD.js";import{n as j,r as M}from"./analytics-DJobLaWP.js";import{l as N,o as P}from"./stringUtils-CbS6OkmE.js";import{n as F,t as I}from"./exit-BOhGfSlm.js";import{n as L,s as R,t as z}from"./pluginOperations-BTq4AjYB.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./pluginCliCommands-vv0wNt4O.js";import{a as K,c as re,i as q,n as J,r as Y,s as X,t as ie}from"./validatePlugin-DSw08u76.js";import{basename as ae,dirname as Z}from"path";e(),ee(),j(),R(),C(),k(),ne(),l(),re(),c(),f(),n(),s(),q(),i(),u(),ie(),te(),P();function Q(e,n){A(e),I(`${t.cross} Failed to ${n}: ${D(e)}`)}function $(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${N(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} ${N(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function oe(e,n){n.cowork&&E(!0);try{let n=await J(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),$(n);let r=[];if(n.fileType===`plugin`){let e=Z(n.filePath);if(ae(e)===`.claude-plugin`){r=await Y(Z(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),$(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?F(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){A(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&E(!0),M(`tengu_plugin_list_command`,{});let n=d(),{getPluginEditableScopes:i}=await import(`./pluginStartupCheck-DBOCHUHQ.js`),o=i(),s=Object.keys(n.plugins),{enabled:c,disabled:l,errors:u}=await r(),f=[...c,...l],p=f.filter(e=>e.source.endsWith(`@inline`)),_=u.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(f.map(e=>[e.source,e])),r=[];for(let e of s.sort()){let i=n.plugins[e];if(!i||i.length===0)continue;let a=y(e).name,s=u.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(h);for(let n of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await v(i);e&&Object.keys(e).length>0&&(a=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:o.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:a,errors:s.length>0?s:void 0})}}for(let e of p){let t=e.mcpServers||await v(e),n=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(h);r.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:n.length>0?n:void 0})}for(let e of _.filter(e=>e.source.startsWith(`inline[`)))r.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[h(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([g(),X()]),{marketplaces:r}=await T(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=m(r.name,t);a(i)||e.push({pluginId:i,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(i)})}}catch{}F(O({installed:r,available:e},null,2))}else F(O(r,null,2))}s.length===0&&p.length===0&&_.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),s.length>0&&console.log(`Installed plugins:
|
|
2
|
-
`);for(let e of s.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let i=y(e).name,a=u.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let n of r){let r=o.has(e),i=a.length>0?`${t.cross} failed to load`:r?`${t.tick} enabled`:`${t.cross} disabled`,s=n.version||`unknown`,c=n.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${s}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${h(e)}`);console.log(``)}}if(p.length>0||_.length>0){console.log(`Session-only plugins (--plugin-dir):
|
|
3
|
-
`);for(let e of p){let n=_.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: ${h(e)}`);console.log(``)}for(let e of _.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${h(e)}\n`)}F()}async function ce(e,n){n.cowork&&E(!0);try{let r=await K(e);r||I(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in r&&I(`${t.cross} ${r.error}`);let i=n.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&I(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=o(i),s=r;n.sparse&&n.sparse.length>0&&(s.source===`github`||s.source===`git`?s={...s,sparsePaths:n.sparse}:I(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${s.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:l,resolvedSource:u}=await b(s,e=>{console.log(e)});S(c,{source:u},a),w();let d=s.source;s.source===`github`&&(d=s.repo),M(`tengu_marketplace_added`,{source_type:d}),F(l?`${t.tick} Marketplace '${c}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${i} settings)`)}catch(e){Q(e,`add marketplace`)}}async function le(e){e.cowork&&E(!0);try{let n=await g(),r=Object.keys(n);e.json&&F(O(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&&F(`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(``)}),F()}catch(e){Q(e,`list marketplaces`)}}async function ue(e,n){n.cowork&&E(!0);try{await p(e),w(),M(`tengu_marketplace_removed`,{marketplace_name:e}),F(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Q(e,`remove marketplace`)}}async function de(e,n){n.cowork&&E(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await x(e,e=>{console.log(e)}),w(),M(`tengu_marketplace_updated`,{marketplace_name:e}),F(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await g(),n=Object.keys(e);n.length===0&&F(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await _(),w(),M(`tengu_marketplace_updated_all`,{count:n.length}),F(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Q(e,`update marketplace(s)`)}}async function fe(e,t){t.cowork&&E(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&I(`--cowork can only be used with user scope`),z.includes(n)||I(`Invalid scope: ${n}. Must be one of: ${z.join(`, `)}.`);let{name:r,marketplace:i}=y(e);M(`tengu_plugin_install_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await V(e,n)}async function pe(e,t){t.cowork&&E(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&I(`--cowork can only be used with user scope`),z.includes(n)||I(`Invalid scope: ${n}. Must be one of: ${z.join(`, `)}.`);let{name:r,marketplace:i}=y(e);M(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await B(e,n,t.keepData)}async function me(e,t){t.cowork&&E(!0);let n;t.scope&&(z.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${z.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=y(e);M(`tengu_plugin_enable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await W(e,n)}async function he(e,t){if(t.all&&e&&I(`Cannot use --all with a specific plugin`),!t.all&&!e&&I(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&E(!0),t.all){t.scope&&I(`Cannot use --scope with --all`),M(`tengu_plugin_disable_command`,{}),await G();return}let n;t.scope&&(z.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${z.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=y(e);M(`tengu_plugin_disable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await H(e,n)}async function ge(e,t){t.cowork&&E(!0);let{name:n,marketplace:r}=y(e);M(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...r&&{_PROTO_marketplace_name:r}});let i=`user`;t.scope&&(L.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),i=t.scope),t.cowork&&i!==`user`&&I(`--cowork can only be used with user scope`),await U(e,i)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,ue as marketplaceRemoveHandler,de as marketplaceUpdateHandler,he as pluginDisableHandler,me as pluginEnableHandler,fe as pluginInstallHandler,se as pluginListHandler,pe as pluginUninstallHandler,ge as pluginUpdateHandler,oe as pluginValidateHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./poorMode-BxsyllUK.js";t();export{e as isPoorModeActive};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,n as r,o as i,s as a}from"./envUtils-BDhHQY0-.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{n as c,t as l}from"./axios-DaWTGg7G.js";import{$c as u,$o as d,$r as f,AS as p,Aa as m,Ar as h,As as g,Au as _,C as v,CE as y,CS as ee,CT as b,Cc as x,Cf as S,Cn as C,D as te,DC as ne,DS as re,Db as ie,Di as ae,Do as oe,Ds as w,Du as T,E,EC as se,Es as ce,Fb as le,GS as ue,Gs as de,Gv as fe,Hb as pe,Ht as me,Hx as he,Ib as ge,Ji as D,Jo as O,Js as _e,Ks as ve,Kv as ye,LC as be,MC as k,Ms as xe,N as A,NC as Se,Ns as Ce,OS as we,Ob as Te,Oi as Ee,Or as De,Os as Oe,Pb as ke,Qa as Ae,Ri as je,Sc as Me,Sn as Ne,TS as Pe,Tb as Fe,Th as j,To as M,Ts as Ie,U as Le,Ui as Re,Ux as ze,Vi as Be,W as Ve,WS as N,Wv as P,Wx as He,Xi as Ue,Xm as F,Xv as We,Ym as Ge,Yo as Ke,Yp as qe,Zp as Je,Zv as Ye,_b as Xe,_h as Ze,_y as I,aE as Qe,ac as $e,al as et,au as tt,b as nt,bE as rt,bh as it,cD as at,cE as ot,cT as st,cg as ct,cl as lt,dD as ut,df as L,dh as dt,di as ft,dv as pt,el as mt,f as ht,fD as gt,fE as _t,fS as vt,ff as yt,fh as bt,fi as xt,fl as St,gC as Ct,gb as wt,gc as Tt,gh as Et,gi as Dt,hS as Ot,hc as kt,hh as At,hi as jt,is as Mt,js as Nt,ju as Pt,kC as Ft,kS as It,kb as Lt,kr as Rt,ks as zt,lD as Bt,ld as Vt,lg as Ht,lh as R,ll as Ut,mS as Wt,mc as Gt,mh as Kt,my as qt,nl as Jt,np as Yt,o as Xt,oC as Zt,oT as Qt,od as $t,ou as en,pE as tn,pf as nn,ph as rn,py as an,qS as on,qs as sn,rl as cn,rp as ln,rr as un,s as dn,sc as fn,sg as pn,sr as mn,ts as hn,uf as gn,ug as _n,uh as vn,uv as yn,vS as bn,vc as xn,vh as Sn,vn as Cn,vo as wn,vy as Tn,wE as z,wS as En,wb as Dn,ws as On,x as kn,xS as An,xf as jn,xo as Mn,yC as Nn,yE as Pn,yh as Fn,yo as In,zT as Ln,zb as Rn}from"./loadAgentsDir-CKSb56Gp.js";import{A as zn,p as Bn,w as Vn}from"./external-CEp-aPkt.js";import{n as Hn,r as Un,t as Wn}from"./lazySchema-B4D4qJVE.js";import{Fn as Gn,Kt as Kn,M as qn,P as Jn,Pn as Yn,X as Xn,Yn as Zn,_n as Qn,lr as $n,mt as B,qt as er,tn as tr,xn as nr}from"./state-Bs5xweDL.js";import{n as rr,t as ir}from"./cwd-L4wygFqJ.js";import{C as ar,F as V,S as or,W as sr,a as H,d as cr,l as U,nt as lr,o as ur,p as dr,rt as fr,w as W,z as pr}from"./debug-BdqxZ7rV.js";import{G as mr,Ln as hr,ar as gr,d as _r,dt as vr,f as yr,g as br,it as xr,nt as G,sr as Sr,vt as Cr,zn as wr}from"./settings-Xbq6AaD-.js";import{F as Tr,M as Er}from"./config-D4G8_MqJ.js";import{i as Dr,n as Or,o as K}from"./process-gEbdy6uY.js";import{A as kr,O as Ar,k as jr}from"./git-B9uvt96d.js";import{J as Mr,U as Nr,c as Pr,i as Fr,o as Ir,s as q}from"./log-CTFl4qpD.js";import{s as Lr,u as Rr}from"./types-DWRxAH0E.js";import{n as zr,r as J}from"./analytics-DJobLaWP.js";import{Bt as Br,C as Vr,Gr as Hr,Mn as Ur,Y as Wr,_ as Gr,_n as Kr,_r as qr,ai as Jr,bt as Yr,et as Xr,ii as Zr,it as Qr,jn as $r,o as ei,qr as ti,ri as ni,rt as ri,si as ii,tt as ai,u as oi,vn as si,vr as ci,x as li}from"./model-C2e73CJD.js";import{Kt as ui,at as di,bn as fi,en as pi,ht as mi,mt as hi,ot as gi,xn as _i}from"./prompt-CybUvG8G.js";import{A as vi,C as yi,D as bi,F as xi,I as Si,N as Ci,U as wi,a as Ti,c as Ei,l as Di,n as Oi,o as ki,s as Ai,t as ji,vt as Mi}from"./sessionState-BvECKycx.js";import{n as Ni,t as Pi}from"./omit-CLPZGevl.js";import{a as Fi,n as Ii,t as Li}from"./bridgeConfig-vORehbGG.js";import{i as Ri,n as zi,s as Bi}from"./mappers-xQC-Z4-h.js";import{n as Vi,r as Hi}from"./sessionTitle-E1FvsKM9.js";import{t as Ui}from"./pollConfig-BgpfHQPJ.js";import{n as Wi,t as Gi}from"./ccrClient-CG6HTv_n.js";import{n as Ki,t as qi}from"./HybridTransport-BVmSUHf0.js";import{n as Ji,t as Yi}from"./SSETransport-1KBBUikF.js";import{a as Xi,n as Zi}from"./grove-BE4fQ6tG.js";import{o as Qi}from"./remoteManagedSettings-CCrq-qL-.js";import{i as $i,r as ea}from"./auth-Cjnyy10u.js";import{t as ta}from"./pluginBlocklist-D93Hd1GF.js";import{t as na}from"./onChangeAppState-DhBO34OK.js";import{t as ra}from"./settingsSync-NCN0a4sc.js";import{a as ia,i as aa,n as oa,o as sa,r as ca,s as la}from"./reconciler-Drq3HSkj.js";import{n as ua,t as da}from"./toolPool-Di30gn_Y.js";import{n as fa,r as pa}from"./QueryEngine-J6ElcO16.js";import{n as ma,r as ha}from"./sideQuestion-D2dPToW8.js";import{n as ga,r as _a}from"./context-noninteractive-c7jGVWHQ.js";import{n as va,t as ya}from"./modelOptions-efCGKnXT.js";import{a as ba,o as xa,t as Sa}from"./skillChangeDetector-C1EJ7rUL.js";import{n as Ca,t as wa}from"./refresh-D8TLHO_T.js";import{basename as Ta,dirname as Ea,join as Da}from"path";import{PassThrough as Oa}from"stream";import{randomUUID as Y}from"crypto";import{mkdir as ka,readFile as Aa,stat as ja,writeFile as Ma}from"fs/promises";import{URL as Na}from"url";import{cwd as X}from"process";o(),l(),Un(),Kn(),rr(),lr(),pr(),or(),dr(),Or(),H(),Ar(),Mr(),Ir(),Sr(),hr(),Lr(),br(),ii(),fi(),ti(),ci(),$r(),Kr(),Br(),Gr(),pi(),Si(),Ci(),qt(),rn(),Ge(),yt(),Oi(),In(),Ae(),D(),h(),ra(),i(),Ji();function Pa(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new Na(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=n.pathname.replace(/\/$/,``)+`/worker/events/stream`,new Yi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new qi(e,t,r,i):new Ki(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}i(),Ji();var Fa=class extends aa{constructor(e,t,r){let i=new Oa({encoding:`utf8`});super(i,r),s(this,`url`,void 0),s(this,`transport`,void 0),s(this,`inputStream`,void 0),s(this,`isBridge`,!1),s(this,`isDebug`,!1),s(this,`ccrClient`,null),s(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new Na(e);let a={},o=xi();o?a.Authorization=`Bearer ${o}`:U(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;c&&(a[`x-environment-runner-version`]=c);let l=()=>{let e={},t=xi();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e};if(this.transport=Pa(this.url,a,B(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=ur(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&K(e.endsWith(`
|
|
2
|
-
`)?e:e+`
|
|
3
|
-
`)}),this.transport.setOnClose(()=>{this.inputStream.end()}),n(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof Yi))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new Gi(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{jr(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof Wi?e.reason:`unknown`}),q(Error(`CCRClient initialization failed: ${V(e)}`)),gn(1,`other`)}),fr(async()=>this.ccrClient?.close()),Ee((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),ae(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};At((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),Di((e,t)=>{this.ccrClient?.reportState(e,t)}),Ei(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=Ui().session_keepalive_interval_v2_ms;if(this.isBridge&&u>0&&(this.keepAliveTimer=setInterval(()=>{U(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{U(`[remote-io] keep_alive write failed: ${V(e)}`)})},u),this.keepAliveTimer.unref?.()),fr(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
|
|
4
|
-
`)})()}}flushInternalEvents(){return this.ccrClient?.flushInternalEvents()??Promise.resolve()}get internalEventsPending(){return this.ccrClient?.internalEventsPending??0}async write(e){this.ccrClient?await this.ccrClient.writeEvent(e):await this.transport.write(e),this.isBridge&&(e.type===`control_request`||this.isDebug)&&K(ia(e)+`
|
|
5
|
-
`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};ui(),mr(),mi(),[...hi],lr(),H();var Ia=`[stdout-guard]`,La=!1,Z=``,Q=null;function Ra(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function za(){La||(La=!0,Q=process.stdout.write.bind(process.stdout),process.stdout.write=function(e,t,n){let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);Z+=r;let i,a=!0;for(;(i=Z.indexOf(`
|
|
6
|
-
`))!==-1;){let e=Z.slice(0,i);Z=Z.slice(i+1),Ra(e)?a=Q(e+`
|
|
7
|
-
`):(process.stderr.write(`${Ia} ${e}\n`),U(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a},fr(async()=>{Z.length>0&&(Q&&Ra(Z)?Q(Z+`
|
|
8
|
-
`):process.stderr.write(`${Ia} ${Z}\n`),Z=``),Q&&(process.stdout.write=Q,Q=null),La=!1}))}Wn(),Cr(),xr(),Er(),wi(),Pn(),_t(),ot(),k(),Nn(),p(),ze(),ge(),gi(),I(),Ye(),pn(),_(),St(),mt(),fn(),sn(),ve(),Nt(),d(),M(),C(),Cn(),Ve(),Xt(),da(),T(),pr(),Ir(),Si(),Ln(),H(),yt();function Ba(e){let t=process.env.CLAUDE_CODE_EXIT_AFTER_STOP_DELAY,n=t?parseInt(t,10):null,r=n&&!isNaN(n)&&n>0,i=null,a=0;return{start(){i&&(clearTimeout(i),i=null),r&&(a=Date.now(),i=setTimeout(()=>{let t=Date.now()-a;e()&&t>=n&&(U(`Exiting after ${n}ms of idle time`),L())},n))},stop(){i&&(clearTimeout(i),i=null)}}}gt(),Pi(),y(),jn(),Vt(),Kn(),H(),i(),Fi();var Va=3e4;function Ha(e){U(`[bridge:inbound-attach] ${e}`)}var Ua=Hn(()=>Vn({file_uuid:zn(),file_name:zn()})),Wa=Hn(()=>Bn(Ua()));function Ga(e){if(typeof e!=`object`||!e||!(`file_attachments`in e))return[];let t=Wa().safeParse(e.file_attachments);return t.success?t.data:[]}function Ka(e){return Ta(e).replace(/[^a-zA-Z0-9._-]/g,`_`)||`attachment`}function qa(){return Da(r(),`uploads`,B())}async function Ja(e){let t=Li();if(!t){Ha(`skip: no oauth token`);return}let n;try{let r=`${Ii()}/api/oauth/files/${encodeURIComponent(e.file_uuid)}/content`,i=await c.get(r,{headers:{Authorization:`Bearer ${t}`},responseType:`arraybuffer`,timeout:Va,validateStatus:()=>!0});if(i.status!==200){Ha(`fetch ${e.file_uuid} failed: status=${i.status}`);return}n=Buffer.from(i.data)}catch(t){Ha(`fetch ${e.file_uuid} threw: ${t}`);return}let r=Ka(e.file_name),i=(e.file_uuid.slice(0,8)||Y().slice(0,8)).replace(/[^a-zA-Z0-9_-]/g,`_`),a=qa(),o=Da(a,`${i}-${r}`);try{await ka(a,{recursive:!0}),await Ma(o,n)}catch(e){Ha(`write ${o} failed: ${e}`);return}return Ha(`resolved ${e.file_uuid} → ${o} (${n.length} bytes)`),o}async function Ya(e){if(e.length===0)return``;Ha(`resolving ${e.length} attachment(s)`);let t=(await Promise.all(e.map(Ja))).filter(e=>e!==void 0);return t.length===0?``:t.map(e=>`@"${e}"`).join(` `)+` `}function Xa(e,t){if(!t)return e;if(typeof e==`string`)return t+e;let n=e.findLastIndex(e=>e.type===`text`);if(n!==-1){let r=e[n];if(r.type===`text`)return[...e.slice(0,n),{...r,text:t+r.text},...e.slice(n+1)]}return[...e,{type:`text`,text:t.trimEnd()}]}async function Za(e,t){let n=Ga(e);return n.length===0?t:Xa(t,await Ya(n))}Xr(),wt(),pt(),x(),Gt(),v(),Hi(),ma();function Qa(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Y(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(F(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:Y(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}ni(),Bt(),b(),N(),Pe(),An(),j(),Fn(),dt(),qe(),Jt(),zi(),_a(),va(),H();async function $a(){try{let e=await Aa(Oe(),`utf-8`),t=vr().safeParse(ar(e));return t.success?t.data:(U(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function eo(e){await On(Oe(),W(e,null,2))}async function to(e,t){let n=w();if(!n)return;let r=await no(t);r!==null&&await On(Da(n,ce(e)),r)}async function no(e){let t=[Da(e,`.claude-plugin`,`marketplace.json`),Da(e,`marketplace.json`),e];for(let e of t)try{return await Aa(e,`utf-8`)}catch{}return null}async function ro(){let e=await hn();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await to(t,n.installLocation)}catch(e){U(`Failed to save marketplace JSON for ${t}: ${e}`)}await eo({...await $a(),...e})}zr(),lr(),H(),Ar(),Ir(),d(),Nt();async function io(){let e=Ce();U(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await Mt();t&&(O(),Mn(`headlessPluginInstall: seed marketplaces registered`)),e&&(await cr().mkdir(zt()),await cr().mkdir(g()));let n=Object.keys(Ke()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)U(`installPluginsForHeadless: no marketplaces declared`);else{let t=await kr(`headless_marketplace_reconcile`,()=>oa({skip:e?(e,t)=>!xe(t):void 0,onProgress:e=>{e.type===`installed`?U(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&U(`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&&U(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(O(),Mn(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await ro();let t=await ta();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&Mn(`headlessPluginInstall: plugins changed`),e&&fr(Ie),i}catch(e){return q(e),!1}finally{J(`tengu_headless_plugin_install`,r)}}zr(),H(),Ar(),rn(),Oi(),Ir(),Or(),Ge(),yt(),lr(),rr(),Kn(),h(),Ae(),or(),i(),wa(),M(),Fe(),Yt(),tt(),pr();var $=(yi(),e(bi)),ao=1e4,oo=new Set,so=[];function co(e){if(oo.has(e))return!1;if(oo.add(e),so.push(e),so.length>ao){let e=so.splice(0,so.length-ao);for(let t of e)oo.delete(t)}return!0}function lo(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function uo(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
|
|
9
|
-
`):e.flatMap(lo)}function fo(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function po(e,t,r,i,a,o,s,c){if(tn.subscribe(e=>{yn(e,r),ri()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),$&&!$.isProactiveActive()&&n(process.env.CLAUDE_CODE_PROACTIVE)&&$.activateProactive(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),vn(),R(`runHeadless_entry`),await Xi()&&await Zi(),R(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
10
|
-
`),L(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
11
|
-
`),L(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
12
|
-
`),L(1);return}let l=Co(e,c);c.outputFormat===`stream-json`&&za();let u=Qe.getSandboxUnavailableReason();if(u){if(Qe.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),L(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(Qe.isSandboxingEnabled())try{await Qe.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${V(e)}\n`),L(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&_e(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:Y(),session_id:B()};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:Y(),session_id:B()};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:Y(),session_id:B()}}})();l.write(t)}),c.setupTrigger&&await Ht(c.setupTrigger),R(`before_loadInitialMessages`);let d=t(),{messages:f,turnInterruptionState:p,agentSetting:m}=await So(r,{continue:c.continue,teleport:c.teleport,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),h=_n();if(h&&l.prependUserMessage(h),!c.agent&&!Xn()&&m){let{agentDefinition:e}=ba(m,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!dn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}jt(e.agentType)}}if(f.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){let e=f.find(e=>e.uuid===c.rewindFiles);if(!e||e.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`),L(1);return}let n=t(),i=await vo(c.rewindFiles,n,r,!1);if(!i.canRewind){process.stderr.write(`Error: ${i.error||`Unexpected error`}\n`),L(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),L(0);return}let g=typeof c.resume==`string`&&(!!F(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
|
|
13
|
-
`),L(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
14
|
-
`),L(1);return}let v=Ut(d.mcp.tools,d.toolPermissionContext),y=[...a,...v],ee=go(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),ki(`requires_action`,e)});c.permissionPromptToolName&&(y=y.filter(e=>!_i(e,c.permissionPromptToolName))),Dr(),R(`after_loadInitialMessages`),await Hr(),R(`after_modelStrings`);let b=c.outputFormat===`json`&&c.verbose,x=[],S;R(`before_runHeadlessStreaming`);for await(let e of mo(l,d.mcp.clients,[...i,...d.mcp.commands],y,f,ee,o,t,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`&&(b&&x.push(e),S=e);switch(c.outputFormat){case`json`:if(!S||S.type!==`result`)throw Error(`No messages returned`);if(c.verbose){K(W(x)+`
|
|
15
|
-
`);break}K(W(S)+`
|
|
16
|
-
`);break;case`stream-json`:break;default:if(!S||S.type!==`result`)throw Error(`No messages returned`);switch(S.subtype){case`success`:K(S.result.endsWith(`
|
|
17
|
-
`)?S.result:S.result+`
|
|
18
|
-
`);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.
|
|
19
|
-
Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(bt(),Tr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-1VlmCGwa.js`);await e()}catch{}L(S?.type===`result`&&S?.is_error?1:0)}function mo(e,r,i,o,s,c,l,u,d,p,h,g){let _=!1,v,y=!1,b=null,x,S=e.outbound;process.on(`SIGINT`,()=>{jr(`info`,`shutdown_signal`,{signal:`SIGINT`}),x&&!x.signal.aborted&&x.abort(),gn(0)}),fr(async()=>{let t={};for(let e of Dn(u()))ln(e)&&(t[e.type]=(t[e.type]??0)+1);jr(`info`,`run_state_at_shutdown`,{run_active:_,run_phase:v,worker_status:ji(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),Ai(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&S.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:B()})});let C={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},te;h.enableAuthStatus&&(te=qr.getInstance().subscribe(e=>{S.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:B()})}));let ae=e=>{let t=Bi(e);t&&S.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:B()})};Xe.add(ae);let w=s,T=$e(s,X(),100),E=he(100),se=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;g&&g.kind!==`none`&&se&&(U(`[print.ts] Auto-resuming interrupted turn (kind: ${g.kind})`),xo(w,g.message),Lt({mode:`prompt`,value:g.message.message.content,uuid:Y()}));let ce=ya().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?ei():Vr(t),r=Je(n),i=Qr(e.value),a=Ur(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),fe=h.userSpecifiedModel;function ge(e,t){let n=m(e,li(t));w.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&S.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:B(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let D=[],O=[],_e=new Set;function ve(t){for(let n of t){if(n.type!==`connected`||_e.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(Qt,async(n,r)=>{Pr(t,`Elicitation request received in print mode: ${W(n)}`);let i=n.params.mode===`url`?`url`:`form`;J(`tengu_mcp_elicitation_shown`,{mode:i});let a=await re(t,n.params,r.signal);if(a)return Pr(t,`Elicitation resolved by hook: ${W(a)}`),J(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in n.params?n.params.url:void 0,s=`requestedSchema`in n.params?n.params.requestedSchema:void 0,c=`elicitationId`in n.params?n.params.elicitationId:void 0,l=await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),u=await we(t,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler(st,e=>{let{elicitationId:n}=e.params;Pr(t,`Elicitation completion notification: ${n}`),me({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),S.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:B()})}),_e.add(t)}catch{}}}async function ye(){let t=new Set(Object.keys(l)),n=new Set(D.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=D.some(e=>e.type===`pending`),o=D.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of D)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await En(l,(t,n)=>e.sendMcpMessage(t,n));D=r.clients,O=r.tools;let i=wr([...n,...t]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(G(t)))),...O]}})),Tn(D)}}ye();let k={clients:[],tools:[],configs:{}},xe=e=>{let t=lt(e.toolPermissionContext,e.mcp.tools),n=rt(ua([...o,...O,...k.tools],t,e.toolPermissionContext.mode),`name`);h.permissionPromptToolName&&(n=n.filter(e=>!_i(e,h.permissionPromptToolName)));let r=Jn();if(r&&!h.jsonSchema){let e=di(r);`tool`in e&&(n=[...n,e.tool])}return n},A=null,Ce=0;function Ee(){if(!A)return;let e=Math.min(Ce,w.length),t=w.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Ce=w.length,t.length>0&&A.writeMessages(t)}let De=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Oe(e){let t=async()=>{let t=new Set(D.map(e=>e.name)),n=await Eo(e,{configs:l,clients:D,tools:O},k,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,k=n.newDynamicState,n.sdkServersChanged){let e=new Set(D.map(e=>e.name)),n=wr([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(G(t)))),...O]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return De=De.then(t,t),De}function Ae(){let e=u(),t=e.mcp.clients,n=rt([...e.mcp.tools,...k.tools],`name`),r=new Set([...t.map(e=>e.name),...D.map(e=>e.name)]);return[...t,...D,...k.clients.filter(e=>!r.has(e.name))].map(e=>{let t;if(e.config.type===`sse`||e.config.type===`http`)t={type:e.config.type,url:e.config.url,headers:e.config.headers,oauth:e.config.oauth};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`?Ct(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 Ne(){try{await Promise.all([Promise.resolve(),kr(`headless_managed_settings_wait`,()=>Qi())]),await io()&&await Le()}catch(e){q(e)}}let Pe=null;a()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Pe=Ne():Ne());let Fe=Ba(()=>!_),j=i,M=p;async function Ie(){let{agentDefinitions:e}=await Ca(d);j=await Re(X());let t=M.filter(e=>e.source===`flagSettings`);M=[...e.allAgents,...t]}async function Le(){let{servers:e}=await ne(),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 Oe(t);r&&ye(),U(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let ze=Sa.subscribe(()=>{je(),Re(X()).then(e=>{j=e})}),Ve=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||y||(async()=>{let e=await it({basePrompt:`<${Nr}>${new Date().toLocaleTimeString()}</${Nr}>`,currentDir:X(),shouldCreate:()=>!y});if(y){await Et({commands:e});return}for(let t of e)Lt({...t,uuid:Y()});N()})().catch(e=>{q(e),U(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};pe(()=>{x&&ke(`now`).length>0&&x.abort(`interrupt`)});let N=async()=>{if(_)return;if(_=!0,v=void 0,ki(`running`),Fe.stop(),R(`run_entry`),await ye(),R(`after_updateSdkMcp`),Pe){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=si(e).then(()=>`timeout`);await Promise.race([Pe,t])===`timeout`&&(q(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),J(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await Pe;Pe=null,await Ie();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-LbaURHVH.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=ie(n);){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(;fo(r,Rn(n));)i.push(ie(n));let a=await Ze(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:uo(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(h.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&S.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:B(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...D,...k.clients];ve(l);let f=xe(s);for(let e of o)Kt(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&&S.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:B(),uuid:Y()})}let p=r.value,m=a.claimedCommands;if(e instanceof Fa&&r.mode===`prompt`&&J(`tengu_bridge_message_received`,{is_repl:!1}),C.abortController?.abort(),C.abortController=null,C.pendingSuggestion=null,C.pendingLastEmittedEntry=null,C.lastEmitted&&r.mode===`prompt`){let e=typeof p==`string`?p:p.find(e=>e.type===`text`)?.text;typeof e==`string`&&kt(C.lastEmitted.text,e,C.lastEmitted.emittedAt,C.lastEmitted.promptId,C.lastEmitted.generationRequestId),C.lastEmitted=null}x=It(),R(`before_ask`),et();let g=r,_=!1;try{if(await Zr(g.workload??h.workload,async()=>{for await(let t of fa({commands:rt([...j,...s.mcp.commands],`name`),prompt:p,promptUuid:g.uuid,isMeta:g.isMeta,cwd:X(),tools:f,verbose:h.verbose,mcpClients:l,thinkingConfig:h.thinkingConfig,maxTurns:h.maxTurns,maxBudgetUsd:h.maxBudgetUsd,taskBudget:h.taskBudget,canUseTool:c,userSpecifiedModel:fe,fallbackModel:h.fallbackModel,jsonSchema:Jn()??h.jsonSchema,mutableMessages:w,getReadFileCache:()=>E.size===0?T:He(T,E),setReadFileCache:e=>{T=e;for(let[e,t]of E.entries()){let n=T.get(e);(!n||t.timestamp>n.timestamp)&&T.set(e,t)}E.clear()},customSystemPrompt:h.systemPrompt,appendSystemPrompt:h.appendSystemPrompt,getAppState:u,setAppState:d,abortController:x,replayUserMessages:h.replayUserMessages,includePartialMessages:h.includePartialMessages,handleElicitation:(t,n,r)=>e.handleElicitation(t,n.message,void 0,r,n.mode,n.url,`elicitationId`in n?n.elicitationId:void 0),agents:M,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{S.enqueue({type:`system`,subtype:`status`,status:e,session_id:B(),uuid:Y()})}}))if(Ee(),t.type===`result`){_=!!t.is_error;for(let e of vi())S.enqueue(e);Dn(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&ln(e))?b=t:(b=null,S.enqueue(t))}else{for(let e of vi())S.enqueue(e);S.enqueue(t)}}),_)await Sn({commands:m,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:g.workload??h.workload});else{let e=await Sn({commands:m,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:g.workload??h.workload});for(let t of e)Lt({...t,uuid:Y()})}}catch(e){throw await Sn({commands:m,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:g.workload??h.workload}),e}for(let e of o)Kt(e,`completed`);if(Ee(),A?.sendResult(),h.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){C.abortController?.abort();let e=new AbortController;C.abortController=e;let t=Me();if(!t)Tt(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await xn(e,w,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:B()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};b?(C.pendingSuggestion=r,C.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(C.lastEmitted=i,S.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){Tt(`aborted`,void 0,void 0,`sdk`);return}q(sr(e))}finally{C.inflightPromise===n.promise&&(C.inflightPromise=null)}})(),C.inflightPromise=n.promise}}bt(),cn(),vn()}};do{for(let e of vi())S.enqueue(e);v=`draining_commands`,await a(),i=!1;{let e=Dn(u()).some(e=>ln(e)),t=Rn(n)!==void 0;(e||t)&&(i=!0,t||(v=`waiting_for_agents`,await si(100)))}}while(i);b&&(S.enqueue(b),b=null,C.pendingSuggestion&&(S.enqueue(C.pendingSuggestion),C.pendingLastEmittedEntry&&(C.lastEmitted={...C.pendingLastEmittedEntry,emittedAt:Date.now()},C.pendingLastEmittedEntry=null),C.pendingSuggestion=null))}catch(t){try{await e.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:B(),total_cost_usd:0,usage:Mi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[V(t),...Fr().map(e=>e.error)]})}catch{}C.abortController?.abort(),L(1);return}finally{if(v=`finally_flush`,await e.flushInternalEvents(),v=`finally_post_flush`,!nn()){ki(`idle`);for(let e of vi())S.enqueue(e)}_=!1,Fe.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Rn(n)===void 0&&!y){Ve();return}if(Rn(n)!==void 0){N();return}y&&(C.inflightPromise&&await Promise.race([C.inflightPromise,si(5e3)]),C.abortController?.abort(),C.abortController=null,await de(),ze(),te?.(),Xe.delete(ae),S.done())},P=function(e,t){S.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},F=function(e,t){S.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},We=new Set;e.setUnexpectedResponseCallback(async e=>{await wo({message:e,setAppState:d,handledToolUseIds:We,onEnqueued:()=>{N()}})});let Ge=new Map,Ke=new Map,qe=new Set,Ye=new Map,I=null;return(async()=>{let t=!1;jr(`info`,`cli_message_loop_started`);for await(let n of e.structuredInput){let a=`uuid`in n?n.uuid:void 0;if(a&&n.type!==`user`&&n.type!==`control_response`&&Kt(a,`completed`),n.type===`control_request`){let a=n,o=a.request;if(a.request.subtype===`interrupt`)d(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),x&&x.abort(),C.abortController?.abort(),C.abortController=null,C.lastEmitted=null,C.pendingSuggestion=null,P(a);else if(o.subtype===`end_session`){U(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),x&&x.abort(),C.abortController?.abort(),C.abortController=null,C.lastEmitted=null,C.pendingSuggestion=null,P(a);break}else if(a.request.subtype===`initialize`){if(a.request.sdkMcpServers&&a.request.sdkMcpServers.length>0)for(let e of a.request.sdkMcpServers)l[e]={type:`sdk`,name:e};await _o(a.request,a.request_id,t,S,i,ce,e,!!h.enableAuthStatus,h,p,u),a.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),a.request.agentProgressSummaries&&Zn(!0),t=!0,le()&&N()}else if(a.request.subtype===`set_permission_mode`){let e=a.request;d(t=>({...t,toolPermissionContext:yo(e,a.request_id,t.toolPermissionContext,S)}))}else if(a.request.subtype===`set_model`){let e=a.request.model??`default`,t=e==="default"?ei():e;fe=t,Yn(t),Ti({model:t}),ge(e,t),P(a)}else if(a.request.subtype===`set_max_thinking_tokens`)a.request.max_thinking_tokens===null?h.thinkingConfig=void 0:a.request.max_thinking_tokens===0?h.thinkingConfig={type:`disabled`}:h.thinkingConfig={type:`enabled`,budgetTokens:a.request.max_thinking_tokens},P(a);else if(a.request.subtype===`mcp_status`)P(a,{mcpServers:Ae()});else if(a.request.subtype===`get_context_usage`)try{let e=u(),t=await ga({messages:w,getAppState:u,options:{mainLoopModel:oi(),tools:xe(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:h.systemPrompt,appendSystemPrompt:h.appendSystemPrompt}});P(a,{...t})}catch(e){F(a,V(e))}else if(a.request.subtype===`mcp_message`){let e=a.request,t=D.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),P(a)}else if(a.request.subtype===`rewind_files`){let e=u(),t=await vo(a.request.user_message_id,e,d,a.request.dry_run??!1);t.canRewind||a.request.dry_run?P(a,t):F(a,t.error??`Unexpected error`)}else if(a.request.subtype===`cancel_async_message`){let e=a.request.message_uuid,t=Te(t=>t.uuid===e);P(a,{cancelled:t.length>0})}else if(a.request.subtype===`seed_read_state`){try{let e=gr(a.request.path),t=Math.floor((await ja(e)).mtimeMs);if(t<=a.request.mtime){let n=await Aa(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
|
|
20
|
-
`,`
|
|
21
|
-
`);E.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}P(a)}else if(a.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Oe(a.request.servers);P(a,e),t&&ye()}else if(a.request.subtype===`reload_plugins`)try{let e=await Ca(d),t=M.filter(e=>e.source===`flagSettings`);M=[...e.agentDefinitions.allAgents,...t];let n=[],[r,i,o]=await Promise.allSettled([Re(X()),Le(),oe()]);r.status===`fulfilled`?j=r.value:q(r.reason),i.status===`rejected`&&q(i.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),P(a,{commands:j.filter(e=>e.userInvocable!==!1).map(e=>({name:Ue(e),description:Be(e),argumentHint:e.argumentHint||``})),agents:M.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Ae(),error_count:e.error_count})}catch(e){F(a,V(e))}else if(a.request.subtype===`mcp_reconnect`){let e=u(),{serverName:t}=a.request;_e.delete(t);let n=Ft(t)??r.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??k.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)F(a,`Server not found: ${t}`);else{let e=await ee(t,n),r=G(t);if(d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...z(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...z(n.mcp.commands,e=>Zt(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:Ni(n.mcp.resources,t)}})),k={...k,clients:[...k.clients.filter(e=>e.name!==t),e.client],tools:[...k.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`)ve([e.client]),P(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;F(a,t)}}}else if(a.request.subtype===`mcp_toggle`){let e=u(),{serverName:t,enabled:n}=a.request;_e.delete(t);let i=Ft(t)??r.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??k.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!i)F(a,`Server not found: ${t}`);else if(n){be(t,!0);let e=await ee(t,i),n=G(t);if(d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...z(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...z(r.mcp.commands,e=>Zt(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:Ni(r.mcp.resources,t)}})),e.client.type===`connected`)ve([e.client]),P(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;F(a,t)}}else{be(t,!1);let n=[...r,...D,...k.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Wt(t,i);let o=G(t);d(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:i}:e),tools:z(e.mcp.tools,e=>e.name?.startsWith(o)),commands:z(e.mcp.commands,e=>Zt(e,t)),resources:Ni(e.mcp.resources,t)}})),P(a)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=u(),n=Ft(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)F(a,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)F(a,`Server type "${n.type}" does not support OAuth authentication`);else try{Ge.get(e)?.abort();let t=new AbortController;Ge.set(e,t);let r,i=new Promise(e=>{r=e}),o=ue(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{Ke.set(e,t)}}),s=await Promise.race([i,o.then(()=>null)]);s?P(a,{authUrl:s,requiresUserAction:!0}):P(a,{requiresUserAction:!1}),Ye.set(e,o),o.then(async()=>{if(Se(e)||qe.has(e))return;let t=await ee(e,n),r=G(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...z(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...z(n.mcp.commands,t=>Zt(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:Ni(n.mcp.resources,e)}})),k={...k,clients:[...k.clients.filter(t=>t.name!==e),t.client],tools:[...k.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{U(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Ge.get(e)===t&&(Ge.delete(e),Ke.delete(e),qe.delete(e),Ye.delete(e))})}catch(e){F(a,V(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=Ke.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)F(a,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{qe.add(e),n(t);let r=Ye.get(e);if(r)try{await r,P(a)}catch(e){F(a,e instanceof Error?e.message:`OAuth authentication failed`)}else P(a)}}else F(a,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;I?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new $i,n,r=new Promise(e=>{n=e}),i=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await ea(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),I?.service===t&&(I=null)});I={service:t,flow:i},i.catch(e=>U(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,i.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);P(a,{manualUrl:e,automaticUrl:t})}catch(e){F(a,V(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!I)F(a,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&I.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=I;e.then(()=>{let e=Yr();P(a,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Jr()}})},e=>F(a,V(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=u(),n=Ft(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)F(a,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)F(a,`Cannot clear auth for server type "${n.type}"`);else{await on(e,n);let t=await ee(e,n),r=G(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...z(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...z(n.mcp.commands,t=>Zt(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:Ni(n.mcp.resources,e)}})),P(a,{})}}else if(a.request.subtype===`apply_flag_settings`){let e=oi(),t=qn()??{},n=a.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];Qn(r),tn.notifyChange(`flagSettings`),`model`in n&&(n.model==null?Yn(void 0):Yn(String(n.model)));let i=oi();if(i!==e){fe=i;let e=n.model?String(n.model):`default`;Ti({model:i}),ge(e,i)}P(a)}else if(a.request.subtype===`get_settings`){let e=oi();P(a,{..._r(),applied:{model:e}})}else if(a.request.subtype===`stop_task`){let{task_id:e}=a.request;try{await en(e,{getAppState:u,setAppState:d}),P(a,{})}catch(e){F(a,V(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(x&&!x.signal.aborted?x:It()).signal;(async()=>{try{let r=await Vi(e,n);if(r&&t)try{Dt(B(),r)}catch(e){q(e)}P(a,{title:r})}catch(e){F(a,V(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=Me(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:It()}}:await pa({tools:xe(u()),commands:j,mcpClients:[...u().mcp.clients,...D,...k.clients],messages:w,readFileState:T,getAppState:u,setAppState:d,customSystemPrompt:h.systemPrompt,appendSystemPrompt:h.appendSystemPrompt,thinkingConfig:h.thinkingConfig,agents:M}),r=await ha({question:e,cacheSafeParams:n});P(a,{response:r.response})}catch(e){F(a,V(e))}})()}else if(a.request.subtype===`set_proactive`)a.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Ve()):$.deactivateProactive(),P(a);else if(o.subtype===`remote_control`)if(o.enabled)if(A)P(a,{session_url:ut(A.bridgeSessionId,A.sessionIngressUrl),connect_url:$t(A.environmentId,A.sessionIngressUrl),environment_id:A.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-RhCAlmHE.js`),r=await n({onInboundMessage(e){let t=ca(e);if(!t)return;let{content:n,uuid:r}=t;Lt({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),N()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){x?.abort()},onSetModel(e){let t=e==="default"?ei():e;fe=t,Yn(t)},onSetMaxThinkingTokens(e){e===null?h.thinkingConfig=void 0:e===0?h.thinkingConfig={type:`disabled`}:h.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),U(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),S.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:B()})},initialMessages:w.length>0?w:void 0});r?(A=r,Ce=w.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),P(a,{session_url:ut(r.bridgeSessionId,r.sessionIngressUrl),connect_url:$t(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):F(a,t??`Remote Control initialization failed`)}catch(e){F(a,V(e))}}else A&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await A.teardown(),A=null),P(a);else F(a,`Unsupported control request subtype: ${a.request.subtype}`);continue}else if(n.type===`control_response`){h.replayUserMessages&&S.enqueue(n);continue}else if(n.type===`keep_alive`)continue;else if(n.type===`update_environment_variables`)continue;else if(n.type===`assistant`||n.type===`system`){let e=Ri([n]);w.push(...e),n.type===`assistant`&&h.replayUserMessages&&S.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=B(),t=await un(e,o.uuid);if(t||oo.has(o.uuid)){U(`Skipping duplicate user message: ${o.uuid}`),h.replayUserMessages&&(U(`Sending acknowledgment for duplicate user message: ${o.uuid}`),S.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&&Kt(o.uuid,`completed`);continue}co(o.uuid)}Lt({mode:`prompt`,value:await Za(o,o.message.content),uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:at(e.attribution,e=>{f(e).catch(e=>{U(`Attribution: Failed to save snapshot: ${e}`)})})})),N()}y=!0,_||(C.inflightPromise&&await Promise.race([C.inflightPromise,si(5e3)]),C.abortController?.abort(),C.abortController=null,await de(),ze(),te?.(),Xe.delete(ae),S.done())})(),S}function ho(e){let t=async(n,r,i,a,o,s)=>{let c=s??await Le(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=Ne(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 la(sa().parse(Rr(h.content[0].text)),e,r,i)};return t}function go(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await Le(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`),L(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`),L(1),Error(t)}i=ho(r)}return i(t,r,a,o,s,c)}}async function _o(e,t,n,r,i,a,o,s,c,l,u){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&&(c.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(c.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(c.promptSuggestions=e.promptSuggestions),e.agents){let t=ht(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=Xn()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(Gn(t.agentType),!c.systemPrompt&&!dn(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&Yn(Vr(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let d=yr()?.outputStyle||`default`,f=await wn(ir()),p=Yr();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}});tr(t)}e.jsonSchema&&nr(e.jsonSchema);let m={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:Ue(e),description:Be(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:d,available_output_styles:Object.keys(f),models:a,account:{email:p?.email,organization:p?.organization,subscriptionType:p?.subscription,tokenSource:p?.tokenSource,apiKeySource:p?.apiKeySource,apiProvider:Jr()},pid:process.pid};if(ri()&&ai()){let e=u();m.fast_mode_state=Wr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:m}}),s){let e=qr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:B()})}}async function vo(e,t,n,r){if(!fe())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!P(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await ye(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await We(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${V(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function yo(e,t,n,r){if(e.mode===`bypassPermissions`){if(te())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`&&!E()){let e=kn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${nt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...A(n.mode,e.mode,n),mode:e.mode}}function bo(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:B(),total_cost_usd:0,usage:Mi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(W(t)+`
|
|
22
|
-
`)}else process.stderr.write(e+`
|
|
23
|
-
`)}function xo(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function So(e,t){let r=!er();if(t.continue)try{J(`tengu_continue_print`,{});let n=await Pt(void 0,void 0);if(n)return t.forkSession||n.sessionId&&($n(an(n.sessionId),n.fullPath?Ea(n.fullPath):null),r&&await ft()),xa(n,e),xt(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return q(e),L(1),{messages:[]}}if(t.teleport)try{if(!S(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(J(`tengu_teleport_print`,{}),typeof t.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:n,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-mdnhIZBj.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return q(e),L(1),{messages:[]}}if(t.resume)try{J(`tengu_resume_print`,{});let i=Qa(typeof t.resume==`string`?t.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),bo(e,t.outputFormat),L(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([De(i.sessionId),t.restoredWorkerState]);n&&(e(na(n)),typeof n.model==`string`&&Yn(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await Rt(i.sessionId,i.ingressUrl);let a=await Pt(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||n(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??ct(`startup`))}:(bo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),L(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return bo(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),L(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&($n(an(a.sessionId),a.fullPath?Ea(a.fullPath):null),r&&await ft()),xa(a,e),xt(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),bo(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),L(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??ct(`startup`))}}function Co(e,t){let n;return n=typeof e==`string`?e.trim()===``?u([]):u([W({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new Fa(t.sdkUrl,n,t.replayUserMessages):new aa(n,t.replayUserMessages)}async function wo({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(U(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return U(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await mn(t);return a?(r.add(t),U(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Lt({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(U(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function To(e){return{...e,scope:`dynamic`}}async function Eo(e,t,n,r){let{allowed:i,blocked:a}=se(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 Do(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 Do(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||!vt(r,To(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 Wt(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=To(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await Ot(t,r);if(d.push(e),e.type===`connected`){let t=await bn(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=sr(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=To(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{po as runHeadless};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{FS as t,Fa as n,IS as r,Ia as i,Jg as a,Ma as o,Qa as s,a_ as c,co as l,gy as u,hy as d,i_ as f,im as p,n_ as m,qg as h,r_ as g,rm as _}from"./loadAgentsDir-CKSb56Gp.js";import{I as v,fi as y,t as b}from"./src-P_wYS_NJ2.js";import{t as x}from"./jsx-runtime-Bb4Xn-E0.js";import{F as S,j as C,z as w}from"./debug-BdqxZ7rV.js";import{g as T,n as E}from"./settings-Xbq6AaD-.js";import{n as D,r as O}from"./analytics-DJobLaWP.js";import{gt as k,ht as A}from"./prompt-CybUvG8G.js";import{randomUUID as j}from"crypto";y(),b(),g(),p(),c();var M=x();function N({input:e,progress:t,verbose:n}){return(0,M.jsxs)(v,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(_,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),t?(0,M.jsx)(f,{fullOutput:t.fullOutput,output:t.output,elapsedTimeSeconds:t.elapsedTimeSeconds,totalLines:t.totalLines,verbose:n}):m.renderToolUseProgressMessage?.([],{verbose:n,tools:[],terminalSize:void 0})]})}w(),D(),t(),s(),T();function P(){return E().defaultShell??`bash`}g(),A(),u();async function F(t,s,c,u,f){let p=k()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:p});let g=i({content:l({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:s})}),_;f({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:u.options.verbose}),shouldHidePromptInput:!1});try{let n={...u,setToolJSX:e=>{_=e?.jsx}},s=e=>{f({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:u.options.verbose}),_]}),shouldHidePromptInput:!1,showSpinner:!1})},l=null;p&&(l=(a(),e(h)).PowerShellTool);let v=l??m,y=(l?await l.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s):await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await r(v,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:d(y.stdout);return{messages:[o(),g,...c,i({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${d(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof C?e.interrupted?{messages:[o(),g,n({toolUse:!1}),...c],shouldQuery:!1}:{messages:[o(),g,...c,i({content:`<bash-stdout>${d(e.stdout)}</bash-stdout><bash-stderr>${d(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[o(),g,...c,i({content:`<bash-stderr>Command failed: ${d(S(e))}</bash-stderr>`})],shouldQuery:!1}}finally{f(null)}}export{F as processBashCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,$a as n,AS as r,Ab as i,Ba as a,Bf as o,Bi as s,C as c,Cc as l,Cm as u,Fa as d,GE as f,Gf as p,HC as m,Hf as h,Hi as g,Ia as _,Ib as v,Ii as y,Jf as b,Ji as x,Jm as S,KE as C,Ma as w,Na as T,Qa as E,Rs as D,Sh as O,Th as k,Tm as A,U as j,UC as M,Vf as ee,Vs as te,W as ne,WC as re,Xi as N,Yf as ie,Ym as ae,bm as P,co as F,el as oe,ev as se,jy as ce,k as le,kS as ue,ka as I,kb as de,ky as fe,nD as pe,ob as me,oo as he,qE as L,qi as R,rD as ge,rb as _e,rg as ve,ro as ye,tg as be,tl as xe,wc as Se,wm as Ce,xc as z,xh as we,ym as Te,zs as Ee}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as De,mt as Oe,qn as ke,t as Ae}from"./state-Bs5xweDL.js";import{A as B,D as je,a as V,d as Me,l as H,p as Ne,z as Pe}from"./debug-BdqxZ7rV.js";import{Dt as Fe,Ot as Ie}from"./settings-Xbq6AaD-.js";import{J as Le,T as U,o as Re,s as W,w as G}from"./log-CTFl4qpD.js";import{n as ze,r as K}from"./analytics-DJobLaWP.js";import{_n as Be,ni as Ve,ri as He,vn as Ue}from"./model-C2e73CJD.js";import{ct as We,ot as Ge}from"./esm-DcIr7tVd.js";import{E as Ke,T as qe,w as Je}from"./sessionTracing-ClGQ08jM.js";import{randomUUID as q}from"crypto";function Ye(e,t,n,r,i){let a=0;for(let o of Fe){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{H(`Removing one-shot hook for event ${o} in skill '${r}'`),A(e,t,o,s)}:void 0;u(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var Xe=e((()=>{Ie(),V(),Ce()}));function Ze(e){let t=e.trim();if(!t.startsWith(`/`))return null;let n=t.slice(1).split(` `);if(!n[0])return null;let r=n[0],i=!1,a=1;n.length>1&&n[1]===`(MCP)`&&(r+=` (MCP)`,i=!0,a=2);let o=n.slice(a).join(` `);return{commandName:r,args:o,isMcp:i}}var Qe=e((()=>{}));function $e(){return!1}function J(){if(!$e())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function et(e,t,n,r,a,o,s){let c=S(),l=e.pluginInfo?L(e.pluginInfo.repository).marketplace:void 0;K(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...l&&{_PROTO_marketplace_name:l},...h(e.pluginInfo)}});let{skillContent:u,modifiedGetAppState:d,baseAgent:f,promptMessages:p}=await Se(e,t,n);H(`Executing forked slash command /${e.name} with agent ${f.agentType}`);let m=await n.getAppState(),g=n.options.allowBackgroundForkedSlashCommands===!0;g&&J();let v=!1;if(m.kairosEnabled&&g&&(v=!0),v){let t=ue(),r=N(e),a=Ve(),l=e=>i({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:a}),u=async()=>{if(!s?.runId)return;let e=await we({runId:s.runId,rootDir:s.rootDir,priority:`later`,workload:a});for(let t of e)de(t)},m=async e=>{s?.runId&&await O({runId:s.runId,rootDir:s.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await Ue(Q);let a=n.options.refreshTools?.()??n.options.tools,s=[];for await(let r of P({agentDefinition:f,promptMessages:p,toolUseContext:{...n,getAppState:d,abortController:t},canUseTool:o,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:a,override:{agentId:c}}))s.push(r);let m=z(s,`Command completed`);H(`Background forked command /${r} completed (agent ${c})`),l(`<scheduled-task-result command="/${r}">\n${m}\n</scheduled-task-result>`);try{await u()}catch(e){W(e)}})().catch(async e=>{W(e),l(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await m(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!s?.runId}}let y=[],b=[],x=`forked-command-${e.name}`,C=0,w=e=>(C++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:u,agentId:c},parentToolUseID:x,toolUseID:`${x}-${C}`,timestamp:new Date().toISOString(),uuid:q()}),T=()=>{a({jsx:ie(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};T();try{for await(let t of P({agentDefinition:f,promptMessages:p,toolUseContext:{...n,getAppState:d},canUseTool:o,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){y.push(t);let e=he([t]);if(t.type===`assistant`){let r=_e(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(w(t)),T())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(w(t)),T())}}}finally{a(null)}let E=z(y,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${c}`),{messages:[_({content:F({inputString:`/${N(e)} ${t}`.trim(),precedingInputBlocks:r})}),_({content:`<local-command-stdout>\n${E}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:E}}function tt(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function nt(e,t,r,i,a,o,s,c,l,u){let d=Ze(e);if(!d){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[w(),...i,_({content:F({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:f,args:p,isMcp:m}=d,g=m?`mcp`:y().has(f)?f:`custom`;if(!R(f,a.options.commands)){let n=!1;try{await Me().stat(`/${f}`),n=!0}catch{}if(tt(f)&&!n){K(`tengu_input_slash_invalid`,{input:f});let e=`Unknown skill: ${f}`;return{messages:[w(),...i,_({content:F({inputString:e,precedingInputBlocks:t})}),...p?[T(`Args from unknown skill: ${p}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let r=q();return ke(r),K(`tengu_input_prompt`,{}),qe(`user_prompt`,{prompt_length:String(e.length),prompt:Ke(e),"prompt.id":r}),{messages:[_({content:F({inputString:e,precedingInputBlocks:t}),uuid:s}),...i],shouldQuery:!0}}let{messages:v,shouldQuery:b,allowedTools:x,model:S,command:E,resultText:D,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}=await rt(f,p,o,a,t,r,c,l,s,u);if(v.length===0){let e={input:g};if(E.type===`prompt`&&E.pluginInfo){let{pluginManifest:t,repository:n}=E.pluginInfo,{marketplace:r}=L(n),i=C(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,h(E.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`}),{messages:[],shouldQuery:!1,model:S,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}}if(v.length===2&&v[1].type===`user`&&typeof v[1].message.content==`string`&&v[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:f}),{messages:[w(),...v],shouldQuery:b,allowedTools:x,model:S};let j={input:g};if(E.type===`prompt`&&E.pluginInfo){let{pluginManifest:e,repository:t}=E.pluginInfo,{marketplace:n}=L(t),r=C(n);j._PROTO_plugin_name=e.name,n&&(j._PROTO_marketplace_name=n),j.plugin_repository=r?t:`third-party`,j.plugin_name=r?e.name:`third-party`,r&&e.version&&(j.plugin_version=e.version),Object.assign(j,h(E.pluginInfo))}K(`tengu_input_command`,{...j,invocation_trigger:`user-slash`});let M=v.length>0&&v[0]&&n(v[0]);return{messages:b||v.every(ye)||M?v:[w(),...v],shouldQuery:b,allowedTools:x,model:S,resultText:D,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}}async function rt(e,t,n,r,i,a,o,s,c,l){let u=g(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&ee(e),u.userInvocable===!1)return{messages:[_({content:F({inputString:`/${e}`,precedingInputBlocks:i})}),_({content:`This skill can only be invoked by Claude, not directly by users. Ask Claude to use the "${e}" skill for you.`})],shouldQuery:!1,command:u};try{switch(u.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>_({content:e,isMeta:!0})),s=se()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[I(Y(u,c)),I(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[_({content:F({inputString:Y(u,c),precedingInputBlocks:i})}),_(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${pe}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};u.load().then(e=>e.call(o,{...r,canUseTool:s},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:u});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:u.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:u}))})});case`local`:{let e=_({content:F({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=w(),i=await(await u.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:u};if(i.type===`compact`){let t=[n,e,...i.displayText?[_({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return ce(),{messages:be(r),shouldQuery:!1,command:u}}return{messages:[e,I(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return W(t),{messages:[e,I(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await et(u,t,r,i,n,s??j,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof je?{messages:[_({content:F({inputString:Y(u,t),precedingInputBlocks:i})}),d({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[_({content:F({inputString:Y(u,t),precedingInputBlocks:i})}),_({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof B)return{messages:[_({content:F({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return a(N(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
-
`)}function it(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
3
|
-
`)}function at(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):it(e.name,t)}async function ot(e,t,n,r,i=[]){let a=s(e,n);if(!a)throw new B(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return Z(a,t,r,[],i)}async function Z(e,t,n,r=[],i=[],a){let o=await e.getPromptForCommand(t,n),s=!M(`hooks`)||re(e.source);if(e.hooks&&s){let t=Oe();Ye(n.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let c=e.source?`${e.source}:${e.name}`:e.name,l=o.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
4
|
-
|
|
5
|
-
`);Ae(e.name,c,l,Ge()?.agentId??null);let u=at(e,t),d=le(e.allowedTools??[]),f=i.length>0||r.length>0?[...i,...r,...o]:o,p=await xe(Ee(o.filter(e=>e.type===`text`).map(e=>e.text).join(` `),n,null,[],n.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[_({content:u,uuid:a}),_({content:f,isMeta:!0}),...p,D({type:`command_permissions`,allowedTools:d,model:e.model})],shouldQuery:!0,allowedTools:d,model:e.model,command:e}}var Q,$;e((()=>{De(),x(),ge(),Le(),ze(),ve(),fe(),Te(),b(),r(),We(),te(),V(),Pe(),l(),Ne(),t(),oe(),Xe(),Re(),v(),E(),c(),ne(),f(),m(),Qe(),Be(),o(),Je(),p(),me(),ae(),k(),He(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ot as processPromptSlashCommand,nt as processSlashCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{KT as e,QT as t}from"./loadAgentsDir-CKSb56Gp.js";t();export{e as clearPromptCache};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t}from"./prompt-CybUvG8G.js";t();export{e as isDeferredTool};
|