@readmagic/workmate 0.0.8 → 0.0.9
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 +1 -0
- package/dist/chunks/App-DW4elk6E.js +1 -0
- package/dist/chunks/ApproveApiKey-D05WywHU.js +1 -0
- package/dist/chunks/ApproveApiKey-DHAbdwkC.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-BuRFF1fQ.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-CDrArsSX.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +1 -0
- package/dist/chunks/DiffDialog-BIcwpgSr.js +6 -0
- package/dist/chunks/Doctor-D160J8Ad.js +3 -0
- package/dist/chunks/Doctor-VhJi2cmL.js +1 -0
- package/dist/chunks/ExitFlow-CoWHhKHJ.js +2 -0
- package/dist/chunks/Grove-BmirUB6V.js +11 -0
- package/dist/chunks/{HybridTransport-BJPOG2wl.js → HybridTransport-BVmSUHf0.js} +1 -1
- package/dist/chunks/InvalidConfigDialog-WRywkKeS.js +1 -0
- package/dist/chunks/InvalidSettingsDialog-C4n3A72C.js +1 -0
- package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +1 -0
- package/dist/chunks/MCPToolListView-BPmE0C2o.js +1 -0
- package/dist/chunks/McpParsingWarnings-CH4yyMAL.js +1 -0
- package/dist/chunks/MessageSelector-kOn2GaU-.js +3 -0
- package/dist/chunks/Messages-4EnHFeh1.js +11 -0
- package/dist/chunks/Onboarding-BboWs1pp.js +1 -0
- package/dist/chunks/{PermissionDialog-0ya1CU5k.js → PermissionDialog-Cb3z8OUP.js} +1 -1
- package/dist/chunks/{PressEnterToContinue-Dl9Hg9Mf.js → PressEnterToContinue-Dq0Imo9c.js} +1 -1
- package/dist/chunks/PromptInputFooterSuggestions-BpC9COmh.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +1 -0
- package/dist/chunks/QueryEngine-J6ElcO16.js +1 -0
- package/dist/chunks/REPL-DBjbAJsm.js +133 -0
- package/dist/chunks/REPL-oBemMXvp.js +1 -0
- package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +2 -0
- package/dist/chunks/ResumeConversation-wBG8OD9P.js +1 -0
- package/dist/chunks/{SSETransport-CrwbKuVt.js → SSETransport-1KBBUikF.js} +1 -1
- package/dist/chunks/{SearchBox-vfLXEPed.js → SearchBox-C9vUA4IM.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +1 -0
- package/dist/chunks/Settings-DptKuJE7.js +2 -0
- package/dist/chunks/TeleportProgress-BmgPAZAi.js +1 -0
- package/dist/chunks/TeleportRepoMismatchDialog-sgxNOeM_.js +1 -0
- package/dist/chunks/TeleportResumeWrapper-GptvrUdv.js +1 -0
- package/dist/chunks/ThemePicker-gAMqqD1P.js +1 -0
- package/dist/chunks/{TrustDialog-BukWGvHZ.js → TrustDialog-CWt-4Evl.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-DokTJQwi.js → ValidationErrorsList-De3kzHtz.js} +1 -1
- package/dist/chunks/{WelcomeV2-Ci9VwPYh.js → WelcomeV2-BWF-cJOu.js} +1 -1
- package/dist/chunks/add-dir-DBVT1cEK.js +1 -0
- package/dist/chunks/{agentDisplay-DBQYOaOh.js → agentDisplay-5gnCQwUY.js} +1 -1
- package/dist/chunks/{agents-HlKk68Qc.js → agents-Bz1MLp4A.js} +1 -1
- package/dist/chunks/agents-CnwTOlqO.js +103 -0
- package/dist/chunks/allErrors-DYw_q14e.js +1 -0
- package/dist/chunks/analytics-DJobLaWP.js +1 -0
- package/dist/chunks/api-DXDXTFGa.js +1 -0
- package/dist/chunks/{api-CF5IVtj0.js → api-DzccRM_z.js} +1 -1
- package/dist/chunks/auth-Cjnyy10u.js +15 -0
- package/dist/chunks/auth-CnLb6RWc.js +1 -0
- package/dist/chunks/auth-D-SGHS0K.js +1 -0
- package/dist/chunks/{autoMode-Cr0AhS1G.js → autoMode-CQ5nqP9c.js} +4 -4
- package/dist/chunks/{autonomy-ARUQt-Lu.js → autonomy-CPUCe-YU.js} +1 -1
- package/dist/chunks/autonomy-dSJl0hN1.js +15 -0
- package/dist/chunks/{autonomyPanel-BQK9MoeB.js → autonomyPanel-Ccr9ilei.js} +1 -1
- package/dist/chunks/backgroundHousekeeping--cs5crp7.js +17 -0
- package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +1 -0
- package/dist/chunks/{banner-Ca7rki2V.js → banner-BJZNMppT.js} +1 -1
- package/dist/chunks/bg-DWloqGwk.js +1 -0
- package/dist/chunks/{bg-DxRHF1yn.js → bg-w3Vlsm3Y.js} +2 -2
- package/dist/chunks/branch-CG0AKS1J.js +3 -0
- package/dist/chunks/{break-cache-BKvoMOZx.js → break-cache-DXV0brco.js} +2 -2
- package/dist/chunks/bridgeConfig-Dmc1ZDev.js +1 -0
- package/dist/chunks/{bridgeConfig-jDEva6Eh.js → bridgeConfig-vORehbGG.js} +1 -1
- package/dist/chunks/{bridgeMessaging-YqYdl6ej.js → bridgeMessaging-DlczTV9X.js} +1 -1
- package/dist/chunks/{bridgePointer-DIM0sj0x.js → bridgePointer-D4W9GpWw.js} +1 -1
- package/dist/chunks/btw-DDUC_t0w.js +1 -0
- package/dist/chunks/caches-1IFb6_M_.js +1 -0
- package/dist/chunks/caches-CB8MHqy2.js +1 -0
- package/dist/chunks/{capacityWake-CKOiRELo.js → capacityWake-L7b1mMft.js} +1 -1
- package/dist/chunks/{ccrClient-BC2q3k44.js → ccrClient-CG6HTv_n.js} +1 -1
- package/dist/chunks/{claudeDesktop-DQXL5bGm.js → claudeDesktop-CAmnheYx.js} +1 -1
- package/dist/chunks/{clear-1etSJhdg.js → clear-DdWexxbM.js} +1 -1
- package/dist/chunks/{cliLaunch-CQjLYRzM.js → cliLaunch-BWWOgBFh.js} +1 -1
- package/dist/chunks/{client-DQwf_b9o.js → client-CoXtVRzi.js} +1 -1
- package/dist/chunks/client-Crrwkw7g.js +1 -0
- package/dist/chunks/client-D8hKghba.js +1 -0
- package/dist/chunks/color-Cuq0c6xy.js +1 -0
- package/dist/chunks/commands-D3sESsTp.js +1 -0
- package/dist/chunks/compact-DIpwuBDq.js +2 -0
- package/dist/chunks/config-CVvUNkj2.js +1 -0
- package/dist/chunks/config-D4G8_MqJ.js +3 -0
- package/dist/chunks/config-q9D4hFiK.js +1 -0
- package/dist/chunks/context-BWcfhhDj.js +1 -0
- package/dist/chunks/context-noninteractive-Bwt9A3XD.js +1 -0
- package/dist/chunks/{context-noninteractive-Ct_ttQfP.js → context-noninteractive-c7jGVWHQ.js} +2 -2
- package/dist/chunks/conversation-Bjo_8kia.js +1 -0
- package/dist/chunks/conversation-DrHZIQX2.js +1 -0
- package/dist/chunks/{createSSHSession-BmHXA2me.js → createSSHSession-DP7B8yvb.js} +1 -1
- package/dist/chunks/{createSession-C4rukWkv.js → createSession-CPo6GBSb.js} +1 -1
- package/dist/chunks/createSession-DnykRoia.js +1 -0
- package/dist/chunks/crossProjectResume-D2A-qjgP.js +40 -0
- package/dist/chunks/cwd--q1ONL7P.js +1 -0
- package/dist/chunks/{cwd-C5ce-7WB.js → cwd-L4wygFqJ.js} +1 -1
- package/dist/chunks/{daemon-ZtpTZWgQ.js → daemon-D2vFIVOz.js} +1 -1
- package/dist/chunks/datadog-DrmHyl3_.js +1 -0
- package/dist/chunks/{debug-RZ4NuXyS.js → debug-BdqxZ7rV.js} +4 -4
- package/dist/chunks/{debugUtils-D30M1cbN.js → debugUtils-CezNYZ-4.js} +1 -1
- package/dist/chunks/{detached-jrVP11oU.js → detached-CkPpYMJj.js} +1 -1
- package/dist/chunks/detectRepository-DA1Q_Skc.js +1 -0
- package/dist/chunks/{detectRepository-CFiHe6Rv.js → detectRepository-DvxoaPlk.js} +1 -1
- package/dist/chunks/{diff-BKiK3xHv.js → diff-DHzz9WAp.js} +1 -1
- package/dist/chunks/directoryCompletion-D5AvL7TF.js +1 -0
- package/dist/chunks/doctor-PWqB46xd.js +1 -0
- package/dist/chunks/entry-4JtoJONR.js +14 -0
- package/dist/chunks/envUtils-BDhHQY0-.js +1 -0
- package/dist/chunks/{esm-BLPbfHQd.js → esm-DcIr7tVd.js} +1 -1
- package/dist/chunks/{execFileNoThrow-CCX-JY8h.js → execFileNoThrow-5SylUnAI.js} +1 -1
- package/dist/chunks/{execSyncWrapper-dhRSYGFW.js → execSyncWrapper-DKuxVTaf.js} +1 -1
- package/dist/chunks/exit-OW9g7b9A.js +1 -0
- package/dist/chunks/extraUsage-Dt5mw35U.js +1 -0
- package/dist/chunks/extractMemories-1VlmCGwa.js +1 -0
- package/dist/chunks/fast-ClYQcEv5.js +1 -0
- package/dist/chunks/fast-CrvLdpy3.js +1 -0
- package/dist/chunks/fileSuggestions-fNxREjpe.js +3 -0
- package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +1 -0
- package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +5 -0
- package/dist/chunks/{flushGate-Cnsu4HET.js → flushGate-ch-Tvwjj.js} +1 -1
- package/dist/chunks/{fpsMetrics-Cf_hdtiJ.js → fpsMetrics-DffAomdg.js} +1 -1
- package/dist/chunks/{gemini-Cudre91e.js → gemini-fZ0VPU2A.js} +1 -1
- package/dist/chunks/generateRecap-BIBVlB__.js +1 -0
- package/dist/chunks/generateSessionName-nZj_VvKZ.js +1 -0
- package/dist/chunks/{genericProcessUtils-DVfMHhfy.js → genericProcessUtils-BmDSLcMf.js} +1 -1
- package/dist/chunks/{git-BerW9bId.js → git-B9uvt96d.js} +1 -1
- package/dist/chunks/git-BfS5Hk4S.js +1 -0
- package/dist/chunks/githubRepoPathMapping-Cqx3pSfc.js +1 -0
- package/dist/chunks/goal-IasZVqKh.js +3 -0
- package/dist/chunks/grok-Dk3LyzMa.js +1 -0
- package/dist/chunks/grove-BE4fQ6tG.js +7 -0
- package/dist/chunks/help-D2-v9Ug9.js +1 -0
- package/dist/chunks/{hooks-BZJTWD07.js → hooks-BrKy5XWQ.js} +2 -2
- package/dist/chunks/hooks-DGd02IKF.js +1 -0
- package/dist/chunks/initReplBridge-RhCAlmHE.js +1 -0
- package/dist/chunks/{install-BI---dv0.js → install-CVGZ55wV.js} +1 -1
- package/dist/chunks/{instrumentation-CcWzhGfE.js → instrumentation-BmWotlxR.js} +4 -4
- package/dist/chunks/{job-B0ftcqPF.js → job-DEXxW_Zo.js} +1 -1
- package/dist/chunks/{jwtUtils-C0cE-1Ey.js → jwtUtils-C9sdGhvT.js} +1 -1
- package/dist/chunks/keybindings-BRdSOSUD.js +2 -0
- package/dist/chunks/language-C0cIpKE2.js +1 -0
- package/dist/chunks/{language-s-dLbdVz.js → language-CxThoWRC.js} +1 -1
- package/dist/chunks/launchLocalMemory-CLSSVFoj.js +3 -0
- package/dist/chunks/launchOnboarding-BkJfKviO.js +8 -0
- package/dist/chunks/loadAgentsDir-8UprzS4w.js +1 -0
- package/dist/chunks/{loadAgentsDir-ByO8eJqU.js → loadAgentsDir-CKSb56Gp.js} +673 -759
- package/dist/chunks/loadPluginHooks-LbaURHVH.js +1 -0
- package/dist/chunks/{localSearch-CHHCH16D.js → localSearch-CPOnyi8I.js} +1 -1
- package/dist/chunks/localSearch-DNjbr4S9.js +1 -0
- package/dist/chunks/{log-CZ0zYP_c.js → log-CTFl4qpD.js} +1 -1
- package/dist/chunks/logoV2Utils-we1sfJvf.js +1 -0
- package/dist/chunks/{magicDocs-C5i5ruuU.js → magicDocs-DmKlTQvK.js} +3 -3
- package/dist/chunks/main-BIiwW4mM.js +605 -0
- package/dist/chunks/{main-BLD4QAQg.js → main-ClXu1ilx.js} +2 -2
- package/dist/chunks/{managedEnv-C-9XSN14.js → managedEnv-Cl7YbYzf.js} +1 -1
- package/dist/chunks/managedEnv-CpiiQx_v.js +1 -0
- package/dist/chunks/{mappers-CHRFic5q.js → mappers-xQC-Z4-h.js} +1 -1
- package/dist/chunks/mcp-B_m1XBDt.js +6 -0
- package/dist/chunks/mcp-BiyfH9Sd.js +1 -0
- package/dist/chunks/mcp-BjlaPUWX.js +2 -0
- package/dist/chunks/{memoize-B8hfb1JN.js → memoize-FJv2HV1u.js} +1 -1
- package/dist/chunks/memory-LN8f_p2b.js +1 -0
- package/dist/chunks/{modalContext-DFjKLCB6.js → modalContext-CUThy6Ph.js} +1 -1
- package/dist/chunks/mode-lYTs0XHs.js +2 -0
- package/dist/chunks/model-C2e73CJD.js +1 -0
- package/dist/chunks/model-CvmS-Esk.js +1 -0
- package/dist/chunks/model-DJ8mFfuR.js +1 -0
- package/dist/chunks/modelOptions-efCGKnXT.js +1 -0
- package/dist/chunks/nativeInstaller-DQIFwdat.js +1 -0
- package/dist/chunks/oauth-BN2I0_jl.js +1 -0
- package/dist/chunks/oauth-C9VBDB0Y.js +1 -0
- package/dist/chunks/omit-CLPZGevl.js +1 -0
- package/dist/chunks/onChangeAppState-DhBO34OK.js +1 -0
- package/dist/chunks/{openai-DPH6rXOZ.js → openai-DJLYqiRl.js} +2 -2
- package/dist/chunks/{panel-mD094ALT.js → panel-q0_iT9cg.js} +1 -1
- package/dist/chunks/panelCall-sum-3zvi.js +1 -0
- package/dist/chunks/parser-BcdhBGx0.js +1 -0
- package/dist/chunks/{parser-dbHRgXb8.js → parser-BdCj2GrE.js} +1 -1
- package/dist/chunks/partition-CpfoVrg1.js +1 -0
- package/dist/chunks/permissions-DTb9wkAP.js +3 -0
- package/dist/chunks/pidLock-BR5M6RQw.js +3 -0
- package/dist/chunks/{pipeTransport-DVOKR4c_.js → pipeTransport-B3TIkTAp.js} +1 -1
- package/dist/chunks/plan-BeoIjNPv.js +1 -0
- package/dist/chunks/{platform-DCXXznJg.js → platform-D6IMiyqT.js} +1 -1
- package/dist/chunks/plugin-D_dHjTud.js +17 -0
- package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +1 -0
- package/dist/chunks/pluginBlocklist-D93Hd1GF.js +1 -0
- package/dist/chunks/pluginCliCommands-vv0wNt4O.js +1 -0
- package/dist/chunks/{pluginFlagging-pBxSselw.js → pluginFlagging-CxuRF2Vc.js} +1 -1
- package/dist/chunks/pluginOperations-BTq4AjYB.js +2 -0
- package/dist/chunks/{pluginStartupCheck-Di4LjHXf.js → pluginStartupCheck-B6leNWq9.js} +1 -1
- package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +1 -0
- package/dist/chunks/plugins-pmipe7kE.js +4 -0
- package/dist/chunks/{poorMode-CYXmr_mU.js → poorMode-BxsyllUK.js} +1 -1
- package/dist/chunks/poorMode-iV1NwC5L.js +1 -0
- package/dist/chunks/print-CAUvczBM.js +23 -0
- package/dist/chunks/processBashCommand-CdeQg_c6.js +1 -0
- package/dist/chunks/processSlashCommand-CbkshIC6.js +5 -0
- package/dist/chunks/{projectContext-D9MDwJUF.js → projectContext-CIxul6vA.js} +1 -1
- package/dist/chunks/{projectContext-BaDZBAoK.js → projectContext-RUMJB798.js} +1 -1
- package/dist/chunks/prompt-CybUvG8G.js +139 -0
- package/dist/chunks/prompt-RBn4JdEg.js +1 -0
- package/dist/chunks/prompt-Rb8zXlDo.js +1 -0
- package/dist/chunks/promptEditor-0Ug93P2I.js +4 -0
- package/dist/chunks/{protocolHandler-RNKkhq91.js → protocolHandler-ClfbHTjI.js} +1 -1
- package/dist/chunks/{proxy-BmtEnJ02.js → proxy-Blq4W6Ox.js} +1 -1
- package/dist/chunks/reconciler-Drq3HSkj.js +4 -0
- package/dist/chunks/refresh-D8TLHO_T.js +1 -0
- package/dist/chunks/{registerProtocol-DoKqmqu2.js → registerProtocol-3_ozAuDK.js} +1 -1
- package/dist/chunks/reload-plugins-Dn1ibOiI.js +1 -0
- package/dist/chunks/{remoteBridgeCore-Cddqv2WW.js → remoteBridgeCore-Dpg6Se9C.js} +1 -1
- package/dist/chunks/remoteManagedSettings-CCrq-qL-.js +1 -0
- package/dist/chunks/rename-CKsSc7Z3.js +1 -0
- package/dist/chunks/{renderOptions-ChLwxtVu.js → renderOptions-CLcco6fc.js} +1 -1
- package/dist/chunks/replBridgeHandle-DNC797_T.js +1 -0
- package/dist/chunks/resume-B1a5gLVR.js +2 -0
- package/dist/chunks/ripgrep-BisRODQ2.js +1 -0
- package/dist/chunks/{ripgrep-gaT9Njwi.js → ripgrep-DkL2S7-I.js} +1 -1
- package/dist/chunks/{runtimeObserver-CsIwinzh.js → runtimeObserver-B0xfyLiA.js} +1 -1
- package/dist/chunks/{runtimeObserver-Dbxxw4ls.js → runtimeObserver-DonWCJOx.js} +4 -4
- package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +1 -0
- package/dist/chunks/sandbox-toggle-CSdnHWp-.js +1 -0
- package/dist/chunks/searchExtraTools-DbgfnQkH.js +1 -0
- package/dist/chunks/session-BbQlh2S5.js +2 -0
- package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +1 -0
- package/dist/chunks/sessionMemory-7UOFdp29.js +1 -0
- package/dist/chunks/sessionMemory-fAzgAS7Q.js +1 -0
- package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +1 -0
- package/dist/chunks/sessionObserver-Cl26OdaW.js +1 -0
- package/dist/chunks/{sessionObserver-DoYc0ZOP.js → sessionObserver-XV6N0XER.js} +2 -2
- package/dist/chunks/{sessionState-CjNY991n.js → sessionState-BvECKycx.js} +1 -1
- package/dist/chunks/sessionStorage-DSj9yZkl.js +1 -0
- package/dist/chunks/{sessionStoragePortable-Cx6JQ5Ye.js → sessionStoragePortable-JZnGwqUM.js} +1 -1
- package/dist/chunks/sessionTitle-E1FvsKM9.js +14 -0
- package/dist/chunks/sessionTracing-ClGQ08jM.js +11 -0
- package/dist/chunks/settings-B-R9ZJNY.js +1 -0
- package/dist/chunks/settings-Xbq6AaD-.js +20 -0
- package/dist/chunks/settingsSync-NCN0a4sc.js +1 -0
- package/dist/chunks/setup-uZ0dSekt.js +3 -0
- package/dist/chunks/shadowedRuleDetection-B9iSx6mB.js +1 -0
- package/dist/chunks/{shellQuote-BUVKMu_P.js → shellQuote-Bth6IZgX.js} +1 -1
- package/dist/chunks/{sideQuestion-C780iYwd.js → sideQuestion-D2dPToW8.js} +3 -3
- package/dist/chunks/sinks-C7q46rvE.js +2 -0
- package/dist/chunks/sinks-D3bXeHlQ.js +1 -0
- package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +1 -0
- package/dist/chunks/{skillGapStore-Dc1arohs.js → skillGapStore-DylpOKJ6.js} +2 -2
- package/dist/chunks/{skillLifecycle-DP6mY1Kp.js → skillLifecycle-GK-8eyyn.js} +2 -2
- package/dist/chunks/{skillSearchPanel-CpLTImaL.js → skillSearchPanel-mpaC62y4.js} +4 -4
- package/dist/chunks/skills-t6krW8GZ.js +1 -0
- package/dist/chunks/{src-CDCSSo0U2.js → src-P_wYS_NJ2.js} +1 -1
- package/dist/chunks/{src-CST_jFnT.js → src-r6ZFgWPx2.js} +1 -1
- package/dist/chunks/startupProfiler-BaiXZ9tr.js +1 -0
- package/dist/chunks/{startupProfiler-DCn_NxMH.js → startupProfiler-jeId9f2i.js} +2 -2
- package/dist/chunks/state-B4HwLt8i.js +1 -0
- package/dist/chunks/{state-Cn_m2NOf.js → state-BAGmpVBn.js} +1 -1
- package/dist/chunks/state-Bs5xweDL.js +1 -0
- package/dist/chunks/{staticRender-BIxpgNUq.js → staticRender-DrU6eWoq.js} +1 -1
- package/dist/chunks/{stats-Duk7_xjQ.js → stats-BJBhl-Lc.js} +1 -1
- package/dist/chunks/{status-peiVB_2j.js → status-BtsnKNVY.js} +1 -1
- package/dist/chunks/status-nZQEar7T.js +2 -0
- package/dist/chunks/{statusNoticeHelpers-B5U5c9PE.js → statusNoticeHelpers-DMqRGFOh.js} +1 -1
- package/dist/chunks/{stringUtils-B6FudhoZ.js → stringUtils-CbS6OkmE.js} +1 -1
- package/dist/chunks/subprocessEnv-CZkA9Cdp.js +1 -0
- package/dist/chunks/{subprocessEnv-vrwzMgKn.js → subprocessEnv-Ci8VV_bi.js} +1 -1
- package/dist/chunks/{switcher-BAMqSX7Z.js → switcher-77h2J5HC.js} +1 -1
- package/dist/chunks/switcher-B2CYzCC_.js +1 -0
- package/dist/chunks/{syncCache-Zl9kZRRl.js → syncCache-By_-buUC.js} +1 -1
- package/dist/chunks/tasks-BNrdmF9p.js +1 -0
- package/dist/chunks/teleport-mdnhIZBj.js +1 -0
- package/dist/chunks/{templateJobs-DR5fKFiO.js → templateJobs-Dkv4I9c1.js} +1 -1
- package/dist/chunks/{terminalSetup-DgRBt-JJ.js → terminalSetup-DQopnSPR.js} +1 -1
- package/dist/chunks/terminalSetup-DTGm1Eo2.js +33 -0
- package/dist/chunks/{theme-Bz6esfST.js → theme-BjpBVRf5.js} +1 -1
- package/dist/chunks/{tmux-DSU9tYIo.js → tmux-CMRiI6CD.js} +1 -1
- package/dist/chunks/{toolEventObserver-BSekCkM2.js → toolEventObserver-D-sNBvOe.js} +1 -1
- package/dist/chunks/toolPool-Di30gn_Y.js +1 -0
- package/dist/chunks/trustedDevice-CupLMpO8.js +1 -0
- package/dist/chunks/{trustedDevice-B0x9X0fb.js → trustedDevice-j1u2TG5U.js} +1 -1
- package/dist/chunks/{types-D7_37tP2.js → types-DWRxAH0E.js} +1 -1
- package/dist/chunks/{udsClient-CHoMMH28.js → udsClient-Cm3HqYUu.js} +1 -1
- package/dist/chunks/{updateCCB-D_kGQKPT.js → updateCCB-BlUAU2Vp.js} +8 -8
- package/dist/chunks/{upstreamproxy-Hmq-n8fw.js → upstreamproxy-DDVMwoRi.js} +1 -1
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-D2FvHieH.js +1 -0
- package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +1 -0
- package/dist/chunks/useManagePlugins-BbWJNLe8.js +1 -0
- package/dist/chunks/useMergedTools-B-Z9XQ6U.js +1 -0
- package/dist/chunks/useSearchInput-C6d6nt9S.js +1 -0
- package/dist/chunks/useSettingsErrors-DKh4rkGi.js +1 -0
- package/dist/chunks/{userAgent-BxTG7IMk.js → userAgent-Ng_TTjWr.js} +1 -1
- package/dist/chunks/util-D-X8i5Z2.js +1 -0
- package/dist/chunks/validatePlugin-DSw08u76.js +1 -0
- package/dist/chunks/vim-3mUqsEJm.js +1 -0
- package/dist/chunks/{which-CHLNJmtJ.js → which-DznMOwny.js} +1 -1
- package/dist/chunks/windowsPaths-1mgenSWa.js +1 -0
- package/dist/chunks/{windowsPaths-o62uq6LF.js → windowsPaths-BVztIhXM.js} +1 -1
- package/dist/chunks/{workSecret-DG9shvG0.js → workSecret-DtiFreRl.js} +1 -1
- package/dist/chunks/workerRegistry-DdOYjLm3.js +6 -0
- package/dist/chunks/worktree-BX1ULzrw.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/AddWorkspaceDirectory-CwLtQld4.js +0 -1
- package/dist/chunks/App-Ba52HvYC.js +0 -1
- package/dist/chunks/ApproveApiKey-CEIfuUh0.js +0 -1
- package/dist/chunks/ApproveApiKey-D2MLQu2P.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-IGDrkbWl.js +0 -2
- package/dist/chunks/BypassPermissionsModeDialog-GYhq--JR.js +0 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-C-CTa-95.js +0 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-Catv6BCJ.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-BeQXqUtX.js +0 -1
- package/dist/chunks/DiffDialog-AC5DSJrq.js +0 -6
- package/dist/chunks/Doctor-B9Rxsoy0.js +0 -1
- package/dist/chunks/Doctor-lhUBhEy5.js +0 -3
- package/dist/chunks/ExitFlow-Cu8SoQHs.js +0 -2
- package/dist/chunks/Grove-Bc4CofEj.js +0 -11
- package/dist/chunks/InvalidConfigDialog-BI13il58.js +0 -1
- package/dist/chunks/InvalidSettingsDialog-CtOheV1K.js +0 -1
- package/dist/chunks/MCPConnectionManager-ao-P3xSA.js +0 -1
- package/dist/chunks/MCPToolListView-dkofcJs4.js +0 -1
- package/dist/chunks/McpParsingWarnings-BS4JoR5l.js +0 -1
- package/dist/chunks/MessageSelector-B88b2ypw.js +0 -3
- package/dist/chunks/Messages-BPeI7lLV.js +0 -11
- package/dist/chunks/Onboarding-c2fQ8Io_.js +0 -1
- package/dist/chunks/PromptInputFooterSuggestions-D1cH9sDX.js +0 -1
- package/dist/chunks/PromptInputHelpMenu-DDD5WuK0.js +0 -1
- package/dist/chunks/QueryEngine-Cv_meCam.js +0 -1
- package/dist/chunks/REPL-BXhAQOXb.js +0 -139
- package/dist/chunks/REPL-YqjLnr3A.js +0 -1
- package/dist/chunks/RemoteSessionManager-CT7T8BaR.js +0 -2
- package/dist/chunks/ResumeConversation-CIZCjms9.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-Dx6093yw.js +0 -1
- package/dist/chunks/Settings-CyUm0AtU.js +0 -2
- package/dist/chunks/TeleportProgress-C3qyp5zy.js +0 -1
- package/dist/chunks/TeleportRepoMismatchDialog-BV--nyYn.js +0 -1
- package/dist/chunks/TeleportResumeWrapper-Blo2cZg-.js +0 -1
- package/dist/chunks/ThemePicker-EQ6hPUeI.js +0 -1
- package/dist/chunks/add-dir-DPQV0qml.js +0 -1
- package/dist/chunks/agents-DmybpgDN.js +0 -103
- package/dist/chunks/allErrors-BPn_2TrB.js +0 -1
- package/dist/chunks/analytics-CkYUHW_U.js +0 -1
- package/dist/chunks/ant-DjdvlLOo.js +0 -1
- package/dist/chunks/api-AMgj1zf_.js +0 -1
- package/dist/chunks/asciicast-BJNYO5sh.js +0 -4
- package/dist/chunks/asciicast-CH6hdK0a.js +0 -1
- package/dist/chunks/auth-CNjDn1VY.js +0 -15
- package/dist/chunks/auth-CZzP483s.js +0 -1
- package/dist/chunks/auth-DDSBm_Yj.js +0 -1
- package/dist/chunks/autonomy-D4xZLOdJ.js +0 -15
- package/dist/chunks/backgroundHousekeeping--eBgphcg.js +0 -17
- package/dist/chunks/backgroundHousekeeping-VV1V_Y2Z.js +0 -1
- package/dist/chunks/bg-BK_9J6F6.js +0 -1
- package/dist/chunks/branch-BYq0zpzT.js +0 -3
- package/dist/chunks/bridgeConfig-C82un7rJ.js +0 -1
- package/dist/chunks/btw-CUV3nRrE.js +0 -1
- package/dist/chunks/caches-BZ59_En6.js +0 -1
- package/dist/chunks/caches-Cg-HtWKG.js +0 -1
- package/dist/chunks/client-DQXvVKND.js +0 -1
- package/dist/chunks/client-DkgC-mFB.js +0 -1
- package/dist/chunks/color-CBsNbt1s.js +0 -1
- package/dist/chunks/commands-qM5z_Uld.js +0 -1
- package/dist/chunks/compact-BclJiRJe.js +0 -2
- package/dist/chunks/completionCache-BMHAktkM.js +0 -1
- package/dist/chunks/config-CE058cvr.js +0 -3
- package/dist/chunks/config-D81avYye.js +0 -1
- package/dist/chunks/config-DpOOllGk.js +0 -1
- package/dist/chunks/context-noninteractive-DJb8H_hN.js +0 -1
- package/dist/chunks/context-sR9fJmXE.js +0 -1
- package/dist/chunks/conversation-D48Kt3ar.js +0 -1
- package/dist/chunks/conversation-fOFTa7k5.js +0 -1
- package/dist/chunks/createSession-CSwlW2T2.js +0 -1
- package/dist/chunks/crossProjectResume-lDFB2ZcY.js +0 -40
- package/dist/chunks/cwd-5Xr-Qka6.js +0 -1
- package/dist/chunks/datadog-BJn5ECIu.js +0 -1
- package/dist/chunks/detectRepository-DqQvyj_a.js +0 -1
- package/dist/chunks/directoryCompletion-BagQcynj.js +0 -1
- package/dist/chunks/doctor-BEHYm34V.js +0 -1
- package/dist/chunks/entry-BzL1MFQG.js +0 -14
- package/dist/chunks/envUtils-DSxRz_kt.js +0 -1
- package/dist/chunks/eventLoopStallDetector-Cg_RXU1q.js +0 -1
- package/dist/chunks/exit-DE2YiAhQ.js +0 -1
- package/dist/chunks/extraUsage-Dw7AXiH7.js +0 -1
- package/dist/chunks/extractMemories-DxTUMiv3.js +0 -1
- package/dist/chunks/fast-CHmMkIpE.js +0 -1
- package/dist/chunks/fast-uQASHWqR.js +0 -1
- package/dist/chunks/fileSuggestions-Dyu2kQtE.js +0 -3
- package/dist/chunks/firstPartyEventLogger-D5ohKbIe.js +0 -5
- package/dist/chunks/firstPartyEventLogger-LsNY6yOt.js +0 -1
- package/dist/chunks/generateRecap-CiFxXlmH.js +0 -1
- package/dist/chunks/generateSessionName-DitoBxJT.js +0 -1
- package/dist/chunks/git-D6dOU2mT.js +0 -1
- package/dist/chunks/githubRepoPathMapping-DGr0kJ8D.js +0 -1
- package/dist/chunks/goal-DuUayfDg.js +0 -3
- package/dist/chunks/grok-tRbmZzEh.js +0 -1
- package/dist/chunks/grove-Cv19v6Sv.js +0 -7
- package/dist/chunks/help-DkqxbFDM.js +0 -1
- package/dist/chunks/hooks-CsP42iOp.js +0 -1
- package/dist/chunks/initReplBridge-DdsSWVqN.js +0 -1
- package/dist/chunks/keybindings-DZU3vwo3.js +0 -2
- package/dist/chunks/language-DHhXLb_Y.js +0 -1
- package/dist/chunks/launchLocalMemory-twLxpPvg.js +0 -3
- package/dist/chunks/launchOnboarding-BWz2XSb9.js +0 -8
- package/dist/chunks/lib-rQZENxQg.js +0 -8
- package/dist/chunks/loadAgentsDir-CMNFLt7R.js +0 -1
- package/dist/chunks/loadPluginHooks-BPnxcgrL.js +0 -1
- package/dist/chunks/localSearch-DzQODFap.js +0 -1
- package/dist/chunks/logoV2Utils-CGUJ-5gY.js +0 -1
- package/dist/chunks/main-D4Uk-WUs.js +0 -862
- package/dist/chunks/managedEnv-DLVRBaA9.js +0 -1
- package/dist/chunks/mcp-BMVdGknC.js +0 -1
- package/dist/chunks/mcp-COS5RJFS.js +0 -6
- package/dist/chunks/mcp-tGsOW1GN.js +0 -2
- package/dist/chunks/memory-DR6poqeH.js +0 -1
- package/dist/chunks/mode-QV-NW1Wd.js +0 -2
- package/dist/chunks/model-BF_4ebyl.js +0 -1
- package/dist/chunks/model-BNU_ulDJ.js +0 -1
- package/dist/chunks/model-CwO-g1RW.js +0 -1
- package/dist/chunks/nativeInstaller-B-lNJjM-.js +0 -1
- package/dist/chunks/oauth-BqJqV-2M.js +0 -1
- package/dist/chunks/oauth-C8X_p8Gc.js +0 -1
- package/dist/chunks/omit-DZCEXri5.js +0 -1
- package/dist/chunks/onChangeAppState-BmfM5g-D.js +0 -1
- package/dist/chunks/p-map-B1EeBuI8.js +0 -1
- package/dist/chunks/p-map-HKDr3iDo.js +0 -1
- package/dist/chunks/panelCall-SbffM7G4.js +0 -1
- package/dist/chunks/parser-DrBC8nWp.js +0 -1
- package/dist/chunks/partition-DKuAFJkc.js +0 -1
- package/dist/chunks/path-Cv9QMBAX.js +0 -1
- package/dist/chunks/permissions-ey-bfanE.js +0 -3
- package/dist/chunks/pidLock-DJnS_38v.js +0 -3
- package/dist/chunks/plan-Brg9XnRr.js +0 -1
- package/dist/chunks/plugin-CRwa39Y1.js +0 -17
- package/dist/chunks/pluginAutoupdate-D0LIP7cy.js +0 -1
- package/dist/chunks/pluginBlocklist-PwHHD3nj.js +0 -1
- package/dist/chunks/pluginCliCommands-BJM5Bdpf.js +0 -1
- package/dist/chunks/pluginOperations-C7p_Qr2r.js +0 -2
- package/dist/chunks/pluginStartupCheck-C0HqhG6D.js +0 -1
- package/dist/chunks/plugins-DUKNjLq6.js +0 -4
- package/dist/chunks/poorMode-CejPNCp-.js +0 -1
- package/dist/chunks/print-gyTOCJzk.js +0 -23
- package/dist/chunks/processBashCommand-Cze9vCm6.js +0 -1
- package/dist/chunks/processSlashCommand-BRajh1v7.js +0 -5
- package/dist/chunks/prompt-B7joRiqj.js +0 -139
- package/dist/chunks/prompt-DqSMh2x9.js +0 -1
- package/dist/chunks/prompt-Eysh8Et_.js +0 -1
- package/dist/chunks/promptEditor-R_acDAgI.js +0 -4
- package/dist/chunks/reconciler-BfkO6X2X.js +0 -4
- package/dist/chunks/refresh-C1X3sptR.js +0 -1
- package/dist/chunks/reload-plugins-C0osFcNh.js +0 -1
- package/dist/chunks/remoteManagedSettings-B1mnRDmA.js +0 -1
- package/dist/chunks/rename-B3tf-YiD.js +0 -1
- package/dist/chunks/replBridgeHandle-CNwNIijW.js +0 -1
- package/dist/chunks/resume-Be1G_GBL.js +0 -2
- package/dist/chunks/ripgrep-C2PhTJDh.js +0 -1
- package/dist/chunks/rollback-BPWRKlIZ.js +0 -11
- package/dist/chunks/sandbox-adapter-C6GBuJPB.js +0 -1
- package/dist/chunks/sandbox-toggle-jEySONTW.js +0 -1
- package/dist/chunks/sdkHeapDumpMonitor-WdXUV7DV.js +0 -1
- package/dist/chunks/searchExtraTools-C_UTryh_.js +0 -1
- package/dist/chunks/session-DDI1Eb2x.js +0 -2
- package/dist/chunks/sessionDataUploader-CaCjwsA2.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-DfJ7Htfl.js +0 -1
- package/dist/chunks/sessionMemory-CQBxPkTQ.js +0 -1
- package/dist/chunks/sessionMemory-s0ALUHvc.js +0 -1
- package/dist/chunks/sessionMemoryUtils-xt7dTHGC.js +0 -1
- package/dist/chunks/sessionObserver-C2sYqWL3.js +0 -1
- package/dist/chunks/sessionStorage-DqsY-7pi.js +0 -1
- package/dist/chunks/sessionTitle-B0OYf5nM.js +0 -14
- package/dist/chunks/sessionTracing-CwsXt_uA.js +0 -11
- package/dist/chunks/settings-BWtOA9A7.js +0 -1
- package/dist/chunks/settings-hQDLwPVj.js +0 -20
- package/dist/chunks/settingsSync-DdFagwHV.js +0 -1
- package/dist/chunks/setup-DzC22EkN.js +0 -3
- package/dist/chunks/shadowedRuleDetection-C86PTj1m.js +0 -1
- package/dist/chunks/sinks-5G_xhc1Q.js +0 -1
- package/dist/chunks/sinks-Cftq7Es0.js +0 -2
- package/dist/chunks/skillChangeDetector-plLveEbf.js +0 -1
- package/dist/chunks/skills-zGYaYfFV.js +0 -1
- package/dist/chunks/startupProfiler-JbpAkfNE.js +0 -1
- package/dist/chunks/state-C2OSZkV1.js +0 -1
- package/dist/chunks/state-DU9lRJ9x.js +0 -1
- package/dist/chunks/status-CFw-FpZM.js +0 -2
- package/dist/chunks/subprocessEnv-BSQSomcK.js +0 -1
- package/dist/chunks/switcher-hgBgVzLb.js +0 -1
- package/dist/chunks/tasks-BxpyRhmD.js +0 -1
- package/dist/chunks/teleport-CwxeD5vL.js +0 -1
- package/dist/chunks/terminalSetup-DlaFWI81.js +0 -33
- package/dist/chunks/toolPool-B7SIoDw5.js +0 -1
- package/dist/chunks/trustedDevice-CjHQtVkO.js +0 -1
- package/dist/chunks/up-B8wBSpLg.js +0 -12
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-Cce612uS.js +0 -1
- package/dist/chunks/useMainLoopModel-BICP6_Fi.js +0 -1
- package/dist/chunks/useManagePlugins-DtbY_vPL.js +0 -1
- package/dist/chunks/useMergedTools-Ckx2IEhF.js +0 -1
- package/dist/chunks/useSearchInput-BAgljZUl.js +0 -1
- package/dist/chunks/useSettingsErrors-CAJR_wpd.js +0 -1
- package/dist/chunks/util-DDtmyq_r.js +0 -1
- package/dist/chunks/validatePlugin-AHl-g4ct.js +0 -1
- package/dist/chunks/vim-kg-mRVbu.js +0 -1
- package/dist/chunks/windowsPaths-Pmx8LDR6.js +0 -1
- package/dist/chunks/workerRegistry-C7H_lsQX.js +0 -6
- package/dist/chunks/worktree-O2p-mJdF.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-DSxRz_kt.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{D as o,Gr as s,Gt as c,H as l,I as u,P as d,T as f,Wt as ee,Xn as p,fi as m,hn as h,j as g,k as _,n as v,ot as y,r as b,t as x,x as te,y as ne}from"./src-CDCSSo0U2.js";import{t as S}from"./jsx-runtime-Bb4Xn-E0.js";import{$C as C,$v as w,Bo as T,Cs as E,DC as D,Do as O,Jp as k,Ko as A,No as re,Oo as ie,Po as ae,Pw as j,Qo as M,Qv as N,Uo as oe,Wo as P,Yo as F,_D as se,_E as ce,_s as le,_v as ue,as as I,aw as de,bE as fe,bv as pe,cD as me,cw as he,dp as L,dw as R,ew as ge,fw as _e,gs as ve,hD as ye,hs as be,iD as z,im as xe,iw as B,ls as Se,lw as Ce,mD as we,ms as Te,ns as Ee,ow as De,pp as Oe,ps as ke,pw as Ae,qp as V,rm as je,rw as Me,ss as Ne,sw as Pe,ts as Fe,uD as Ie,us as Le,uw as Re,vD as ze,vs as Be,vv as Ve,wC as He,ws as Ue,xE as We,xs as Ge,xw as Ke,ys as qe}from"./loadAgentsDir-ByO8eJqU.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-RZ4NuXyS.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-hQDLwPVj.js";import{g as lt,x as ut}from"./config-CE058cvr.js";import{o as dt,s as ft}from"./log-CZ0zYP_c.js";import{n as pt,r as mt}from"./analytics-CkYUHW_U.js";import{b as ht,w as gt}from"./startupProfiler-DCn_NxMH.js";import{l as H,o as _t}from"./stringUtils-B6FudhoZ.js";import{n as vt,t as yt}from"./pluginStartupCheck-Di4LjHXf.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-C7p_Qr2r.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-AHl-g4ct.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-pBxSselw.js";import{i as zt,n as Bt}from"./MCPConnectionManager-ao-P3xSA.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-Cce612uS.js";import{t as Ut}from"./SearchBox-vfLXEPed.js";import{n as Wt,t as Gt}from"./useSearchInput-BAgljZUl.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-dkofcJs4.js";import{i as en,n as tn}from"./pluginAutoupdate-D0LIP7cy.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:s,setResult:c,setViewState:l,onAddComplete:ee,cliMode:p=!1}){let m=(0,on.useRef)(!1),[h,g]=(0,on.useState)(!1),[_,v]=(0,on.useState)(``),y=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{g(!0),v(``);let{name:e,resolvedSource:t}=await F(n,e=>{v(e)});Se(e,{source:t}),E();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),ee&&await ee(),v(``),g(!1),p?c(`Successfully added marketplace: ${e}`):l({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),v(``),g(!1),c(p?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!m.current&&!i&&!s&&(m.current=!0,y())},[]),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsxs)(u,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(u,{marginBottom:1,children:(0,U.jsx)(d,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsx)(d,{children:`Enter marketplace source:`}),(0,U.jsx)(d,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(d,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(d,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(d,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(d,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(je,{value:e,onChange:t,onSubmit:y,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),h&&(0,U.jsxs)(u,{marginTop:1,children:[(0,U.jsx)(L,{}),(0,U.jsx)(d,{children:_||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{color:`error`,children:i})}),s&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{children:s})})]}),(0,U.jsx)(u,{marginLeft:3,children:(0,U.jsx)(d,{dimColor:!0,italic:!0,children:(0,U.jsxs)(f,{children:[(0,U.jsx)(o,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(V,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{m(),on=t(m(),1),pt(),k(),x(),Oe(),xe(),et(),dt(),Ue(),Fe(),At(),U=S()}));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 l=Object.keys(n),f=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[p,m]=(0,un.useState)(0),[g,_]=(0,un.useState)({}),[v,y]=(0,un.useState)(()=>l[0]?f(l[0]):``),b=l[p],x=b?n[b]:null;if(ee(`confirm:no`,o,{context:`Settings`}),c({"confirm:nextField":(0,un.useCallback)(()=>{if(p<l.length-1&&b){_(e=>({...e,[b]:v})),m(e=>e+1);let e=l[p+1];y(e?f(e):``)}},[p,l,b,v,f]),"confirm:yes":(0,un.useCallback)(()=>{if(!b)return;let e={...g,[b]:v};if(p===l.length-1)i(cn(l,e,n,r));else{_(e),m(e=>e+1);let t=l[p+1];y(t?f(t):``)}},[b,g,v,p,l,n,i,f,r])},{context:`Confirmation`}),h((e,t)=>{if(t.backspace||t.delete){y(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&y(t=>t+e)}),!x||!b)return null;let te=x.sensitive===!0,S=x.required===!0,C=te?`*`.repeat(s(v)):v;return(0,dn.jsxs)(ne,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(u,{flexDirection:`column`,children:[(0,dn.jsxs)(d,{bold:!0,children:[x.title||b,S&&(0,dn.jsx)(d,{color:`error`,children:` *`})]}),x.description&&(0,dn.jsx)(d,{dimColor:!0,children:x.description}),(0,dn.jsxs)(u,{marginTop:1,children:[(0,dn.jsxs)(d,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(d,{children:C}),(0,dn.jsx)(d,{children:`█`})]})]}),(0,dn.jsxs)(u,{flexDirection:`column`,children:[(0,dn.jsxs)(d,{dimColor:!0,children:[`Field `,p+1,` of `,l.length]}),p<l.length-1&&(0,dn.jsx)(d,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),p===l.length-1&&(0,dn.jsx)(d,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(m(),1),x(),j(),r(),dn=S()}));async function pn(e){let{enabled:t,disabled:n}=await ie();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=Me(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>de(t),save:n=>De(t,n,e.manifest.userConfig)});let i=C(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>Ce(t,r.server)??void 0,save:e=>R(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(m(),1),et(),Pe(),ge(),O(),B(),fn(),gn=S()}));function vn(){let e=Be();return(0,yn.jsxs)(u,{marginBottom:1,children:[(0,yn.jsxs)(d,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(d,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var yn,bn=e((()=>{i(),m(),x(),qe(),yn=S()}));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)(u,{marginTop:1,children:(0,wn.jsx)(d,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(f,{children:[e&&(0,wn.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{m(),k(),x(),wn=S()}));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)(()=>{},[]),ee=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),m=(0,Dn.useCallback)((e,t)=>!1,[]),h=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:h,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:ee,handleSelectionChange:p,handlePageNavigation:m,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var Dn,On,kn=e((()=>{Dn=t(m(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:l}){let[p,m]=(0,W.useState)(`marketplace-list`),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)([]),[x,te]=(0,W.useState)([]),[ne,S]=(0,W.useState)(!0),[C,T]=(0,W.useState)(null),[D,O]=(0,W.useState)(0),[k,A]=(0,W.useState)(new Set),[re,ie]=(0,W.useState)(new Set),j=En({totalItems:x.length,selectedIndex:D}),[N,F]=(0,W.useState)(0),[se,ce]=(0,W.useState)(!1),[ue,I]=(0,W.useState)(null),[de,fe]=(0,W.useState)(null);ee(`confirm:no`,jn.useCallback(()=>{p===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):y.length===1?i({type:`menu`}):(m(`marketplace-list`),g(null),A(new Set)):p===`plugin-details`?(m(`plugin-list`),v(null)):i({type:`menu`})},[p,s,i,y.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await Ee(),{marketplaces:n,failures:r}=await Ge(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>P(ke(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:le(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),b(i);let a=ve(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)fe(a.message+`. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!l){let e=i[0];e&&(g(e.name),m(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await M(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=ke(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:oe(e)},r=t;break}}}if(n&&r){let e=n.pluginId;oe(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(g(r),v(n),m(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(g(s),m(`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,l]),(0,W.useEffect)(()=>{if(!h)return;let e=!1;async function n(n){S(!0);try{let t=await M(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=ke(e.name,n);w(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:oe(t)})}try{let t=await Nt();if(e)return;T(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))}te(r),O(0),A(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{S(!1)}}return n(h),()=>{e=!0}},[h,t]);let pe=async()=>{if(k.size===0)return;let e=x.filter(e=>k.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 ae({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),A(new Set),E(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${be(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${be(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},me=async(e,t=`user`)=>{ce(!0),I(null);let n=await ae({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){ce(!1),m({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else ce(!1),I(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),c({"select:previous":()=>{D>0&&O(D-1)},"select:next":()=>{D<y.length-1&&O(D+1)},"select:accept":()=>{let e=y[D];e&&(g(e.name),m(`plugin-list`))}},{context:`Select`,isActive:p===`marketplace-list`}),c({"select:previous":()=>{D>0&&j.handleSelectionChange(D-1,O)},"select:next":()=>{D<x.length-1&&j.handleSelectionChange(D+1,O)},"select:accept":()=>{if(D===x.length&&k.size>0)pe();else if(D<x.length){let e=x[D];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(v(e),m(`plugin-details`),F(0),I(null)))}}},{context:`Select`,isActive:p===`plugin-list`}),c({"plugin:toggle":()=>{if(D<x.length){let e=x[D];if(e&&!e.isInstalled){let t=new Set(k);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),A(t)}}},"plugin:install":()=>{k.size>0&&pe()}},{context:`Plugin`,isActive:p===`plugin-list`});let he=jn.useMemo(()=>{if(!_)return[];let e=_.entry.homepage;return Sn(e,xn(_))},[_]);if(c({"select:previous":()=>{N>0&&F(N-1)},"select:next":()=>{N<he.length-1&&F(N+1)},"select:accept":()=>{if(!_)return;let e=he[N]?.action,t=_.entry.homepage,n=xn(_);e===`install-user`?me(_,`user`):e===`install-project`?me(_,`project`):e===`install-local`?me(_,`local`):e===`homepage`&&t?Ae(t):e===`github`&&n?Ae(`https://github.com/${n}`):e===`back`&&(m(`plugin-list`),v(null))}},{context:`Select`,isActive:p===`plugin-details`&&!!_}),typeof p==`object`&&p.type===`plugin-options`){let{plugin:e,pluginId:t}=p;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(ne)return(0,G.jsx)(d,{children:`Loading…`});if(e)return(0,G.jsx)(d,{color:`error`,children:e});if(p===`marketplace-list`)return y.length===0?(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(d,{children:`No marketplaces configured.`}),(0,G.jsxs)(d,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),de&&(0,G.jsx)(u,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(d,{color:`warning`,children:[a.warning,` `,de]})}),y.map((e,t)=>(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:+(t<y.length-1),children:[(0,G.jsx)(u,{children:(0,G.jsxs)(d,{color:D===t?`suggestion`:void 0,children:[D===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(u,{marginLeft:2,children:(0,G.jsxs)(d,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(p===`plugin-details`&&_){let e=_.entry.homepage,t=Sn(e,xn(_));return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:_.entry.name}),_.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[`Version: `,_.entry.version]}),_.entry.description&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{children:_.entry.description})}),_.entry.author&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof _.entry.author==`string`?_.entry.author:_.entry.author.name]})})]}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:`Will install:`}),_.entry.commands&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(_.entry.commands)?_.entry.commands.join(`, `):Object.keys(_.entry.commands).join(`, `)]}),_.entry.agents&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(_.entry.agents)?_.entry.agents.join(`, `):Object.keys(_.entry.agents).join(`, `)]}),_.entry.hooks&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Hooks: `,Object.keys(_.entry.hooks).join(`, `)]}),_.entry.mcpServers&&(0,G.jsxs)(d,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(_.entry.mcpServers)?_.entry.mcpServers.join(`, `):typeof _.entry.mcpServers==`object`?Object.keys(_.entry.mcpServers).join(`, `):`configured`]}),!_.entry.commands&&!_.entry.agents&&!_.entry.hooks&&!_.entry.mcpServers&&(0,G.jsx)(G.Fragment,{children:typeof _.entry.source==`object`&&`source`in _.entry.source&&(_.entry.source.source===`github`||_.entry.source.source===`url`||_.entry.source.source===`npm`||_.entry.source.source===`pip`)?(0,G.jsx)(d,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(d,{dimColor:!0,children:`· Components will be discovered at installation`})})]}),(0,G.jsx)(vn,{}),ue&&(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsxs)(d,{color:`error`,children:[`Error: `,ue]})}),(0,G.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(u,{children:[N===t&&(0,G.jsx)(d,{children:`> `}),N!==t&&(0,G.jsx)(d,{children:` `}),(0,G.jsx)(d,{bold:N===t,children:se&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(x.length===0)return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(d,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(d,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(u,{marginLeft:3,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let L=j.getVisibleItems(x);return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install Plugins`})}),j.scrollPosition.canScrollUp&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),L.map((t,n)=>{let r=j.toActualIndex(n),i=D===r,o=k.has(t.pluginId),s=re.has(t.pluginId);return(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:n===L.length-1&&!e?0:1,children:[(0,G.jsxs)(u,{children:[(0,G.jsxs)(d,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(d,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(d,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(d,{dimColor:!0,children:` (installed)`}),C&&h===`claude-plugins-official`&&(0,G.jsxs)(d,{dimColor:!0,children:[` · `,Mt(C.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(u,{marginLeft:4,children:[(0,G.jsx)(d,{dimColor:!0,children:gt(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),j.scrollPosition.canScrollDown&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:k.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(m(),1),W=t(m(),1),k(),x(),j(),nt(),_e(),Qe(),et(),Ue(),kt(),T(),qe(),Fe(),z(),re(),N(),_t(),ht(),_n(),bn(),Tn(),kn(),G=S()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:l}){let[m,g]=(0,K.useState)(`plugin-list`),[v,b]=(0,K.useState)(null),[x,te]=(0,K.useState)([]),[ne,S]=(0,K.useState)(!0),[C,T]=(0,K.useState)(null),[D,O]=(0,K.useState)(!1),k=(0,K.useCallback)(e=>{O(e),s?.(e)},[s]),{query:A,setQuery:re,cursorOffset:ie}=Wt({isActive:m===`plugin-list`&&D&&!ne,onExit:()=>{k(!1)}}),j=p(),{columns:M}=y(),N=(0,K.useMemo)(()=>{if(!A)return x;let e=A.toLowerCase();return x.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[x,A]),[P,F]=(0,K.useState)(0),[se,ce]=(0,K.useState)(new Set),[le,ue]=(0,K.useState)(new Set),I=En({totalItems:N.length,selectedIndex:P});(0,K.useEffect)(()=>{F(0)},[A]);let[de,fe]=(0,K.useState)(0),[pe,me]=(0,K.useState)(!1),[he,L]=(0,K.useState)(null),[R,ge]=(0,K.useState)(null),[_e,ye]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await Ee(),{marketplaces:n,failures:r}=await Ge(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=ke(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:oe(t)})}let a=i.filter(e=>!e.isInstalled&&!w(e.pluginId));try{let e=await Nt();T(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))}te(a);let o=Object.keys(e).length;if(a.length===0){let e=await Te({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ye(e)}let s=ve(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(l){let e=i.find(e=>e.entry.name===l);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(b(e),g(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{S(!1)}}e()},[t,l]);let z=async()=>{if(se.size===0)return;let e=x.filter(e=>se.has(e.pluginId));ue(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await ae({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ue(new Set),ce(new Set),E(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${be(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${be(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},xe=async(e,t=`user`)=>{me(!0),L(null);let n=await ae({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){me(!1),g({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else me(!1),L(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),ee(`confirm:no`,()=>{g(`plugin-list`),b(null)},{context:`Confirmation`,isActive:m===`plugin-details`}),ee(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:m===`plugin-list`&&!D}),h((e,t)=>{let n=!t.ctrl&&!t.meta;D||(e===`/`&&n?(k(!0),re(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(k(!0),re(e)))},{isActive:m===`plugin-list`&&!ne}),c({"select:previous":()=>{P===0?k(!0):I.handleSelectionChange(P-1,F)},"select:next":()=>{P<N.length-1&&I.handleSelectionChange(P+1,F)},"select:accept":()=>{if(P===N.length&&se.size>0)z();else if(P<N.length){let e=N[P];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(b(e),g(`plugin-details`),fe(0),L(null)))}}},{context:`Select`,isActive:m===`plugin-list`&&!D}),c({"plugin:toggle":()=>{if(P<N.length){let e=N[P];if(e&&!e.isInstalled){let t=new Set(se);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ce(t)}}},"plugin:install":()=>{se.size>0&&z()}},{context:`Plugin`,isActive:m===`plugin-list`&&!D});let B=In.useMemo(()=>{if(!v)return[];let e=v.entry.homepage;return Sn(e,xn(v))},[v]);if(c({"select:previous":()=>{de>0&&fe(de-1)},"select:next":()=>{de<B.length-1&&fe(de+1)},"select:accept":()=>{if(!v)return;let e=B[de]?.action,t=v.entry.homepage,n=xn(v);e===`install-user`?xe(v,`user`):e===`install-project`?xe(v,`project`):e===`install-local`?xe(v,`local`):e===`homepage`&&t?Ae(t):e===`github`&&n?Ae(`https://github.com/${n}`):e===`back`&&(g(`plugin-list`),b(null))}},{context:`Select`,isActive:m===`plugin-details`&&!!v}),typeof m==`object`&&m.type===`plugin-options`){let{plugin:e,pluginId:t}=m;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,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(ne)return(0,q.jsx)(d,{children:`Loading…`});if(e)return(0,q.jsx)(d,{color:`error`,children:e});if(m===`plugin-details`&&v){let e=v.entry.homepage,t=Sn(e,xn(v));return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(d,{bold:!0,children:v.entry.name}),(0,q.jsxs)(d,{dimColor:!0,children:[`from `,v.marketplaceName]}),v.entry.version&&(0,q.jsxs)(d,{dimColor:!0,children:[`Version: `,v.entry.version]}),v.entry.description&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{children:v.entry.description})}),v.entry.author&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof v.entry.author==`string`?v.entry.author:v.entry.author.name]})})]}),(0,q.jsx)(vn,{}),he&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`error`,children:[`Error: `,he]})}),(0,q.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(u,{children:[de===t&&(0,q.jsx)(d,{children:`> `}),de!==t&&(0,q.jsx)(d,{children:` `}),(0,q.jsx)(d,{bold:de===t,children:pe&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,children:(0,q.jsxs)(f,{children:[(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(x.length===0)return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:_e}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Se=I.getVisibleItems(N);return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsxs)(u,{children:[(0,q.jsx)(d,{bold:!0,children:`Discover plugins`}),I.needsPagination&&(0,q.jsxs)(d,{dimColor:!0,children:[` `,`(`,I.scrollPosition.current,`/`,I.scrollPosition.total,`)`]})]}),(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(_,{query:A,isFocused:D,isTerminalFocused:j,width:M-4,cursorOffset:ie})}),R&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`warning`,children:[a.warning,` `,R]})}),N.length===0&&A&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`No plugins match "`,A,`"`]})}),I.scrollPosition.canScrollUp&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Se.map((t,n)=>{let r=I.toActualIndex(n),i=P===r,o=se.has(t.pluginId),s=le.has(t.pluginId);return(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:n===Se.length-1&&!e?0:1,children:[(0,q.jsxs)(u,{children:[(0,q.jsxs)(d,{color:i&&!D?`suggestion`:void 0,children:[i&&!D?a.pointer:` `,` `]}),(0,q.jsxs)(d,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(d,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),C&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(d,{dimColor:!0,children:[` · `,Mt(C.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(u,{marginLeft:4,children:(0,q.jsx)(d,{dimColor:!0,children:gt(t.entry.description,60)})})]},`${I.startIndex}-${t.pluginId}`)}),I.scrollPosition.canScrollDown&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:se.size>0,canToggle:P<N.length&&!N[P]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:(0,q.jsxs)(f,{children:[e&&(0,q.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(d,{children:`type to search`}),t&&(0,q.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(d,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(d,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(m(),1),K=t(m(),1),k(),Ut(),x(),Gt(),Ke(),j(),nt(),_e(),Qe(),et(),Ue(),kt(),T(),qe(),Fe(),z(),re(),N(),_t(),ht(),_n(),bn(),Tn(),kn(),q=S()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:l}){let[p,m]=(0,Bn.useState)([]),[g,_]=(0,Bn.useState)(!0),[v,y]=(0,Bn.useState)(0),[b,x]=(0,Bn.useState)(!1),[te,ne]=(0,Bn.useState)(null),[S,C]=(0,Bn.useState)(null),[w,T]=(0,Bn.useState)(null),[D,O]=(0,Bn.useState)(`list`),[k,A]=(0,Bn.useState)(null),[re,ae]=(0,Bn.useState)(0),j=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await Ee(),{enabled:r,disabled:i}=await ie(),a=[...r,...i],{marketplaces:o,failures:c}=await Ge(e),u=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));u.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),m(u);let d=ve(c,tt(o,e=>e.data!==null));if(d)if(d.type===`warning`)ne(d.message);else throw Error(d.message);if(s&&!j.current&&!t){j.current=!0;let e=u.findIndex(e=>e.name===s);if(e>=0){let t=u[e];if(l){y(e+1);let t=[...u];l===`update`?t[e].pendingUpdate=!0:l===`remove`&&(t[e].pendingRemove=!0),m(t),setTimeout(oe,100,t)}else t&&(y(e+1),A(t),O(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),ne(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{_(!1)}}e()},[s,l,t]);let M=()=>p.some(e=>e.pendingUpdate||e.pendingRemove),N=()=>({updateCount:tt(p,e=>e.pendingUpdate),removeCount:tt(p,e=>e.pendingRemove)}),oe=async t=>{let i=t||p,s=D===`details`;x(!0),ne(null),C(null),T(null);try{let t=rt(`userSettings`),n=0,c=0,l=new Set;for(let e of i){if(e.pendingRemove){if(e.installedPlugins&&e.installedPlugins.length>0){let n={...t?.enabledPlugins};for(let t of e.installedPlugins){let r=ke(t.name,e.name);n[r]=!1}st(`userSettings`,{enabledPlugins:n})}await Ne(e.name),c++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await I(e.name,e=>{T(e)}),n++,l.add(e.name.toLowerCase()),mt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let u=0;l.size>0&&(u=(await en(l)).length),E(),o&&await o();let d=await Ee(),{enabled:f,disabled:ee}=await ie(),p=[...f,...ee],{marketplaces:h}=await Ge(d),g=[];for(let{name:e,config:t,data:n}of h){let r=p.filter(t=>t.source.endsWith(`@${e}`));g.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}if(g.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),m(g),s&&k){let e=g.find(e=>e.name===k.name);e&&A(e)}let _=[];if(n>0){let e=u>0?` (${u} ${H(u,`plugin`)} bumped)`:``;_.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&_.push(`Removed ${c} ${H(c,`marketplace`)}`),_.length>0){let t=`${a.tick} ${_.join(`, `)}`;s?C(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Ye(e);ne(t),n&&n(t)}finally{x(!1),T(null)}},P=async()=>{if(!k)return;let e=p.map(e=>e.name===k.name?{...e,pendingRemove:!0}:e);m(e),await oe(e)},F=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 ut()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},se=async e=>{let t=!e.autoUpdate;try{await Le(e.name,t),m(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),A(e=>e&&{...e,autoUpdate:t})}catch(e){ne(e instanceof Error?e.message:`Failed to update setting`)}};if(ee(`confirm:no`,()=>{O(`list`),ae(0)},{context:`Confirmation`,isActive:!b&&(D===`details`||D===`confirm-remove`)}),ee(`confirm:no`,()=>{m(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),y(0)},{context:`Confirmation`,isActive:!b&&D===`list`&&M()}),ee(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!b&&D===`list`&&!M()}),c({"select:previous":()=>y(e=>Math.max(0,e-1)),"select:next":()=>{let e=p.length+1;y(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=v-1;if(v===0)e({type:`add-marketplace`});else if(M())oe();else{let e=p[t];e&&(A(e),O(`details`),ae(0))}}},{context:`Select`,isActive:!b&&D===`list`}),h(e=>{let t=v-1;if((e===`u`||e===`U`)&&t>=0)m(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=p[t];e&&(A(e),O(`confirm-remove`))}},{isActive:!b&&D===`list`}),c({"select:previous":()=>ae(e=>Math.max(0,e-1)),"select:next":()=>{let e=F(k);ae(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!k)return;let t=F(k)[re];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:k.name});else if(t?.value===`update`){let e=p.map(e=>e.name===k.name?{...e,pendingUpdate:!0}:e);m(e),oe(e)}else t?.value===`toggle-auto-update`?se(k):t?.value===`remove`&&O(`confirm-remove`)}},{context:`Select`,isActive:!b&&D===`details`}),h(e=>{e===`y`||e===`Y`?P():(e===`n`||e===`N`)&&(O(`list`),A(null))},{isActive:!b&&D===`confirm-remove`}),g)return(0,J.jsx)(d,{children:`Loading marketplaces…`});if(p.length===0)return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(d,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(D===`confirm-remove`&&k){let e=k.installedPlugins?.length||0;return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsxs)(d,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(d,{italic:!0,children:k.name}),`?`]}),(0,J.jsxs)(u,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),k.installedPlugins&&k.installedPlugins.length>0&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,marginLeft:2,children:k.installedPlugins.map(e=>(0,J.jsxs)(d,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[`Press `,(0,J.jsx)(d,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(d,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(D===`details`&&k){let e=k.pendingUpdate||b,t=F(k);return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{bold:!0,children:k.name}),(0,J.jsx)(d,{dimColor:!0,children:k.source}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[k.pluginCount||0,` available `,H(k.pluginCount||0,`plugin`)]})}),k.installedPlugins&&k.installedPlugins.length>0&&(0,J.jsxs)(u,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(d,{bold:!0,children:[`Installed plugins (`,k.installedPlugins.length,`):`]}),(0,J.jsx)(u,{flexDirection:`column`,marginLeft:1,children:k.installedPlugins.map(e=>(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(d,{children:a.bullet}),(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{children:e.name}),(0,J.jsx)(d,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(d,{color:`claude`,children:`Updating marketplace…`}),w&&(0,J.jsx)(d,{dimColor:!0,children:w})]}),!e&&S&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:S})}),!e&&te&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:te})}),!e&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===re;return(0,J.jsxs)(u,{children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(d,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!ut()&&k.autoUpdate&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:ce,removeCount:ue}=N();return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:v===0?`suggestion`:void 0,children:[v===0?a.pointer:` `,` +`]}),(0,J.jsx)(d,{bold:!0,color:v===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(u,{flexDirection:`column`,children:p.map((e,t)=>{let n=t+1===v,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(u,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(d,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(d,{dimColor:!0,children:e.source}),(0,J.jsxs)(d,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),M()&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(d,{children:[(0,J.jsx)(d,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(d,{dimColor:!0,children:`Enter to apply`})]}),ce>0&&(0,J.jsxs)(d,{children:[`• Update `,ce,` `,H(ce,`marketplace`)]}),ue>0&&(0,J.jsxs)(d,{color:`warning`,children:[`• Remove `,ue,` `,H(ue,`marketplace`)]})]}),b&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:`Processing changes…`})}),te&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:te})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:M()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:(0,J.jsxs)(f,{children:[t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(o,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(o,{shortcut:`r`,action:`remove`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),m(),Bn=t(m(),1),pt(),k(),x(),j(),nt(),lt(),et(),Ue(),qe(),Fe(),tn(),O(),ot(),at(),_t(),J=S()}));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 se(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((()=>{ze()}));function Gn({item:e,isSelected:t}){let[n]=l();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=g(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=g(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=g(`success`,n)(a.tick),i=`enabled`):(r=g(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=g(`warning`,n)(a.warning);return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=g(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=g(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=g(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=g(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=g(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=g(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{dimColor:!t,children:`└ `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]}):(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),m(),x(),_t(),Y=S()}));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=we(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 M(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)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Components:`}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(d,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Xn(e,t){let n=(await M(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!w(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=Ve(e=>e.mcp.clients),m=Ve(e=>e.mcp.tools),g=Ve(e=>e.plugins.errors),v=It(),[b,x]=(0,X.useState)(!1),te=(0,X.useCallback)(e=>{x(e),r?.(e)},[r]),ne=p(),{columns:S}=y(),[C,w]=(0,X.useState)(`plugin-list`),{query:T,setQuery:D,cursorOffset:O}=Wt({isActive:C===`plugin-list`&&b,onExit:()=>{te(!1)}}),[k,re]=(0,X.useState)(null),[ae,j]=(0,X.useState)([]),[M,N]=(0,X.useState)([]),[oe,P]=(0,X.useState)(!0),[F,se]=(0,X.useState)(new Map),le=(0,X.useRef)(!1),ue=(0,X.useRef)(void 0),I=zt();ee(`confirm:no`,$n.useCallback(()=>{if(C===`plugin-details`)w(`plugin-list`),re(null),B(null);else if(typeof C==`object`&&C.type===`failed-plugin-details`)w(`plugin-list`),B(null);else if(C===`configuring`)w(`plugin-details`),Ce(null);else if(typeof C==`object`&&(C.type===`plugin-options`||C.type===`configuring-options`))w(`plugin-list`),re(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof C==`object`&&C.type===`flagged-detail`)w(`plugin-list`),B(null);else if(typeof C==`object`&&C.type===`mcp-detail`)w(`plugin-list`),B(null);else if(typeof C==`object`&&C.type===`mcp-tools`)w({type:`mcp-detail`,client:C.client});else if(typeof C==`object`&&C.type===`mcp-tool-detail`)w({type:`mcp-tools`,client:C.client});else{if(F.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[C,e,F,t]),{context:`Confirmation`,isActive:(C!==`plugin-list`||!b)&&C!==`confirm-project-uninstall`&&!(typeof C==`object`&&C.type===`confirm-data-cleanup`)});let fe=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,pe=(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 M){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=g.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:F.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 g){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 v)continue;let n=Ie(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:fe(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},d=[],f=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;f.has(n)||f.set(n,[]),f.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;f.has(r)||f.set(r,[]),f.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:fe(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let e of s){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let[e,t]of Object.entries(v)){let n=Ie(e),r=n.name||e,i=n.marketplace||`unknown`;f.has(`flagged`)||f.set(`flagged`,[]),f.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let ee=[...f.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of ee){let t=f.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)d.push(...e);d.push(...r)}return d},[M,l,g,F,v]),me=(0,X.useMemo)(()=>pe.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[pe]);(0,X.useEffect)(()=>{me.length>0&&Ft(me)},[me]);let L=(0,X.useMemo)(()=>{if(!T)return pe;let e=T.toLowerCase();return pe.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[pe,T]),[R,ge]=(0,X.useState)(0),_e=En({totalItems:L.length,selectedIndex:R,maxVisible:8}),[ve,ye]=(0,X.useState)(0),[be,z]=(0,X.useState)(!1),[xe,B]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(null),[we,Te]=(0,X.useState)(!1),[Ee,Oe]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!k){Oe(!1);return}async function e(){let e=k.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&he(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&he(e))),!t)try{let e=nn.join(k.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Je(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===k.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&he(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&he(e))}}catch(e){$e(`Failed to read raw marketplace.json: ${e}`)}Oe(t)}e()},[k]),(0,X.useEffect)(()=>{async function e(){P(!0);try{let{enabled:e,disabled:t}=await ie(),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)),j(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})}N(o),ge(0)}finally{P(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!le.current&&i&&ae.length>0&&!oe){let{name:e,marketplace:n}=Ie(i),r=o??n,a=r?ae.filter(e=>e.name===r):ae;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};re(r),w(`plugin-details`),ue.current=s,le.current=!0;return}}let c=pe.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(w({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),le.current=!0),!le.current&&s&&(le.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,ae,oe,pe,s,t]);let ke=async r=>{if(!k)return;let i=k.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){B(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){B(`This plugin is managed by your organization. Contact your admin to disable it.`);return}z(!0),B(null);try{let o=`${k.plugin.name}@${k.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)){z(!1),w(`confirm-project-uninstall`);return}let e=A().plugins[o],t=!e||e.length<=1?await ce(o):null;if(t){z(!1),w({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(`${k.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}E();let c=`${k.plugin.name}@${k.marketplace}`;if(it()?.enabledPlugins?.[c]!==!1){z(!1),w({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} ${k.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){z(!1);let t=e instanceof Error?e.message:String(e);B(`Failed to ${r}: ${t}`),ft(Ze(e))}},je=(0,X.useRef)(ke);je.current=ke,(0,X.useEffect)(()=>{if(C===`plugin-details`&&k&&ue.current){let e=ue.current;ue.current=void 0,je.current(e)}},[C,k]);let Me=$n.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=it(),r=F.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(F);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),E()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),E()}catch(e){ft(e)}})()),se(e)}}else e?.type===`mcp`&&I(e.client.name)},[R,L,F,M,I]);c({"select:previous":()=>{R===0?te(!0):_e.handleSelectionChange(R-1,ge)},"select:next":()=>{R<L.length-1&&_e.handleSelectionChange(R+1,ge)},"select:accept":$n.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type===`plugin`){let t=M.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(re(t),w(`plugin-details`),ye(0),B(null))}else e?.type===`flagged-plugin`?(w({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),B(null)):e?.type===`failed-plugin`?(w({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),ye(0),B(null)):e?.type===`mcp`&&(w({type:`mcp-detail`,client:e.client}),B(null))},[R,L,M])},{context:`Select`,isActive:C===`plugin-list`&&!b}),c({"plugin:toggle":Me},{context:`Plugin`,isActive:C===`plugin-list`&&!b}),c({"select:accept":$n.useCallback(()=>{typeof C!=`object`||C.type!==`flagged-detail`||(Lt(C.plugin.id),w(`plugin-list`))},[C])},{context:`Select`,isActive:typeof C==`object`&&C.type===`flagged-detail`});let Ne=$n.useMemo(()=>{if(C!==`plugin-details`||!k)return[];let e=it(),t=`${k.plugin.name}@${k.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=k.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void ke(n?`disable`:`enable`)}),r||(i.push({label:k.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(k.plugin.name,k.marketplace);if(e){B(e);return}let t=[...M],n=t.findIndex(e=>e.plugin.name===k.plugin.name&&e.marketplace===k.marketplace);n!==-1&&(t[n].pendingUpdate=!k.pendingUpdate,N(t),re({...k,pendingUpdate:!k.pendingUpdate}))}catch(e){B(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Ee&&i.push({label:`Configure`,action:async()=>{Te(!0);try{let e=k.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&he(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&he(n)){t=n;break}}if(!t){B(`No MCPB file found in plugin`),Te(!1);return}let n=`${k.plugin.name}@${k.marketplace}`,r=await Re(t,k.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ce(r),w(`configuring`)):B(`Failed to load MCPB for configuration`)}catch(e){let t=Ye(e);B(`Failed to load configuration: ${t}`)}finally{Te(!1)}}}),k.plugin.manifest.userConfig&&Object.keys(k.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{w({type:`configuring-options`,schema:k.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void ke(`update`)}),i.push({label:`Uninstall`,action:()=>void ke(`uninstall`)})),k.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void Ae(k.plugin.manifest.homepage)}),k.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void Ae(k.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{w(`plugin-list`),re(null),B(null)}}),i},[C,k,Ee,M]);if(c({"select:previous":()=>{ve>0&&ye(ve-1)},"select:next":()=>{ve<Ne.length-1&&ye(ve+1)},"select:accept":()=>{Ne[ve]&&Ne[ve].action()}},{context:`Select`,isActive:C===`plugin-details`&&!!k}),c({"select:accept":()=>{typeof C==`object`&&C.type===`failed-plugin-details`&&(async()=>{z(!0),B(null);let e=C.plugin.id,t=C.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)}E()}i?(n&&await n(),z(!1),w(`plugin-list`)):(z(!1),B(r.message))})()}},{context:`Select`,isActive:typeof C==`object`&&C.type===`failed-plugin-details`&&C.plugin.scope!==`managed`}),c({"confirm:yes":()=>{if(!k)return;z(!0),B(null);let r=`${k.plugin.name}@${k.marketplace}`,{error:i}=st(`localSettings`,{enabledPlugins:{...rt(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){z(!1),B(`Failed to write settings: ${i.message}`);return}E(),t(`✓ Disabled ${k.plugin.name} in .claude/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{w(`plugin-details`),B(null)}},{context:`Confirmation`,isActive:C===`confirm-project-uninstall`&&!!k&&!be}),h((r,i)=>{if(!k)return;let o=`${k.plugin.name}@${k.marketplace}`,s=k.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{z(!0),B(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);E();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){z(!1),B(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(w(`plugin-details`),B(null))},{isActive:typeof C==`object`&&C.type===`confirm-data-cleanup`&&!!k&&!be}),$n.useEffect(()=>{ge(0)},[T]),h((e,t)=>{let n=!t.ctrl&&!t.meta;b||(e===`/`&&n?(te(!0),D(``),ge(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(te(!0),D(e),ge(0)))},{isActive:C===`plugin-list`}),oe)return(0,Z.jsx)(d,{children:`Loading installed plugins…`});if(pe.length===0)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(d,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Esc to go back`})})]});if(typeof C==`object`&&C.type===`plugin-options`&&k){let r=`${k.plugin.name}@${k.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:k.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${k.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${k.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof C==`object`&&C.type===`configuring-options`&&k){let e=`${k.plugin.name}@${k.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${k.plugin.name}`,subtitle:`Plugin options`,configSchema:C.schema,initialValues:de(e),onSave:n=>{try{De(e,n,C.schema),E(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){B(`Failed to save configuration: ${Ye(e)}`)}w(`plugin-details`)},onCancel:()=>w(`plugin-details`)})}if(C===`configuring`&&Se&&k){let e=`${k.plugin.name}@${k.marketplace}`;async function n(n){if(!(!Se||!k))try{let r=k.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&he(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&he(e)){i=e;break}}if(!i){B(`No MCPB file found`),w(`plugin-details`);return}await Re(i,k.plugin.path,e,void 0,n),B(null),Ce(null),w(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Ye(e);B(`Failed to save configuration: ${t}`),w(`plugin-details`)}}function r(){Ce(null),w(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${Se.manifest.name}`,subtitle:`Plugin: ${k.plugin.name}`,configSchema:Se.configSchema,initialValues:Se.existingConfig,onSave:n,onCancel:r})}if(typeof C==`object`&&C.type===`flagged-detail`){let e=C.plugin;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(u,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(d,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(d,{children:e.text}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(u,{children:[(0,Z.jsxs)(d,{children:[a.pointer,` `]}),(0,Z.jsx)(d,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(C===`confirm-project-uninstall`&&k)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,color:`warning`,children:[k.plugin.name,` is enabled in .claude/settings.json (shared with your team)`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Disable it just for you in .claude/settings.local.json?`}),(0,Z.jsx)(d,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),xe&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:xe})}),(0,Z.jsx)(u,{marginTop:1,children:be?(0,Z.jsx)(d,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof C==`object`&&C.type===`confirm-data-cleanup`&&k)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,children:[k.plugin.name,` has `,C.size.human,` of persistent data`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(d,{dimColor:!0,children:We(`${k.plugin.name}@${k.marketplace}`)})]}),xe&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:xe})}),(0,Z.jsx)(u,{marginTop:1,children:be?(0,Z.jsx)(d,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(d,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(d,{bold:!0,children:`esc`}),` to cancel`]})})]});if(C===`plugin-details`&&k){let e=it(),t=`${k.plugin.name}@${k.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=g.filter(e=>`plugin`in e&&e.plugin===k.plugin.name||e.source===t||e.source.startsWith(`${k.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(d,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(u,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(d,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(d,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[k.plugin.name,` @ `,k.marketplace]})}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(d,{children:k.scope||`user`})]}),k.plugin.manifest.version&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(d,{children:k.plugin.manifest.version})]}),k.plugin.manifest.description&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{children:k.plugin.manifest.description})}),k.plugin.manifest.author&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(d,{children:k.plugin.manifest.author.name})]}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),k.pendingUpdate&&(0,Z.jsx)(d,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:k.plugin,marketplace:k.marketplace}),i,(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:Ne.map((e,t)=>{let n=t===ve;return(0,Z.jsxs)(u,{children:[n&&(0,Z.jsxs)(d,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(d,{children:` `}),(0,Z.jsx)(d,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),be&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{children:`Processing…`})}),xe&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:xe})}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof C==`object`&&C.type===`failed-plugin-details`){let e=C.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:e.name}),(0,Z.jsxs)(d,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(d,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(u,{marginTop:1,children:[(0,Z.jsxs)(d,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(d,{bold:!0,children:`Remove`})]}),be&&(0,Z.jsx)(d,{children:`Processing…`}),xe&&(0,Z.jsx)(d,{color:`error`,children:xe}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[e.scope!==`managed`&&(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof C==`object`&&C.type===`mcp-detail`){let e=C.client,n=He(m,e.name).length,r=()=>{w({type:`mcp-tools`,client:e})},i=()=>{w(`plugin-list`)},a=e=>{e&&t(e),w(`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}):(w(`plugin-list`),null)}if(typeof C==`object`&&C.type===`mcp-tools`){let e=C.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=>{w({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>w({type:`mcp-detail`,client:e})})}if(typeof C==`object`&&C.type===`mcp-tool-detail`){let{client:e,tool:t}=C,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:()=>w({type:`mcp-tools`,client:e})})}let Pe=_e.getVisibleItems(L);return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(_,{query:T,isFocused:b,isTerminalFocused:ne,width:S-4,cursorOffset:O})}),L.length===0&&T&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsxs)(d,{dimColor:!0,children:[`No items match "`,T,`"`]})}),_e.scrollPosition.canScrollUp&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Pe.map((e,t)=>{let n=_e.toActualIndex(t)===R&&!b,r=t>0?Pe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(u,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(d,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Gn,{item:e,isSelected:n})]},e.id)}),_e.scrollPosition.canScrollDown&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(u,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(d,{children:`type to search`}),(0,Z.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),F.size>0&&(0,Z.jsx)(u,{marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(m(),1),X=t(m(),1),k(),x(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),Ke(),j(),ye(),Bt(),D(),Et(),ue(),nt(),_e(),Qe(),et(),dt(),Ue(),T(),Fe(),Pe(),fe(),Rt(),me(),O(),B(),N(),vt(),at(),Xe(),_t(),Wn(),fn(),_n(),Kn(),kn(),Z=S()}));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)(u,{flexDirection:`column`,children:(0,ar.jsx)(d,{children:`Running validation...`})})}var ir,ar,or=e((()=>{i(),m(),ir=t(m(),1),x(),et(),dt(),Pt(),_t(),ar=S()}));function sr({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await Ee(),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)(d,{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=Ve(e=>e.plugins.errors),i=Ve(e=>e.plugins.installationStatus),o=pe(),[s,l]=(0,Q.useState)(0),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await Ge(await Ee());g(e)}catch{}})()},[]);let _=i.marketplaces.filter(e=>e.status===`failed`),v=new Set(_.map(e=>e.name)),y=r.filter(dr),b=pr(_,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!v.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),h,y,yt());ee(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),c({"select:previous":()=>l(e=>Math.max(0,e-1)),"select:next":()=>l(e=>Math.min(b.length-1,e+1)),"select:accept":()=>{let r=b[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),E(),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)}}})),m(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await Ne(i.name),E(),g(e=>e.filter(e=>e.name!==i.name)),m(`${a.tick} Removed marketplace "${i.name}"`),n()}catch(e){m(`Failed to remove "${i.name}": ${e instanceof Error?e.message:String(e)}`)}})();break;case`managed-only`:break;case`none`:break}}},{context:`Select`,isActive:b.length>0});let x=Math.min(s,Math.max(0,b.length-1));x!==s&&l(x);let te=b[x]?.action,ne=te&&te.kind!==`none`&&te.kind!==`managed-only`;return b.length===0?(0,$.jsxs)(u,{flexDirection:`column`,children:[(0,$.jsx)(u,{marginLeft:1,children:(0,$.jsx)(d,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(u,{marginTop:1,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:(0,$.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(u,{flexDirection:`column`,children:[b.map((e,t)=>{let n=t===x;return(0,$.jsxs)(u,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(d,{children:[(0,$.jsxs)(d,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(d,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(u,{marginLeft:3,children:(0,$.jsx)(d,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(u,{marginLeft:3,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),p&&(0,$.jsx)(u,{marginTop:1,marginLeft:1,children:(0,$.jsx)(d,{color:`claude`,children:p})}),(0,$.jsx)(u,{marginTop:1,children:(0,$.jsx)(d,{dimColor:!0,italic:!0,children:(0,$.jsxs)(f,{children:[(0,$.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),ne&&(0,$.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}function 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||``),[f,p]=(0,Q.useState)(0),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[y,x]=(0,Q.useState)(!1),ne=pe(),S=Ve(e=>{let t=e.plugins.errors.length;for(let n of e.plugins.installationStatus.marketplaces)n.status===`failed`&&t++;return t}),C=S>0?`Errors (${S})`:`Errors`,w=Vt(),T=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,E=(0,Q.useCallback)(()=>{ne(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[ne]),D=(0,Q.useCallback)(e=>{let t=e;switch(s(t),h(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`&&!g&&e()},[i.type,g,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&o!==`discover`&&s(`discover`)},[i.type,o]),ee(`confirm:no`,(0,Q.useCallback)(()=>{s(`marketplaces`),a({type:`manage-marketplaces`}),l(``),h(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{g&&e(g)},[g,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(u,{flexDirection:`column`,children:[(0,$.jsx)(d,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(d,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(d,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(d,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(d,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Management:`}),(0,$.jsx)(d,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(d,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(d,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(d,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(d,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(d,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(d,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(d,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(d,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(d,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(d,{children:` `}),(0,$.jsx)(d,{dimColor:!0,children:`Other:`}),(0,$.jsx)(d,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(d,{children:` /plugin help - Show this help`}),(0,$.jsx)(d,{children:` /plugins - Alias for /plugin`})]}):i.type===`validate`?(0,$.jsx)(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:f,setCursorOffset:p,error:m,setError:h,result:g,setResult:_,setViewState:a,onAddComplete:E,cliMode:T}):(0,$.jsx)(te,{color:`suggestion`,children:(0,$.jsxs)(b,{title:`Plugins`,selectedTab:o,onTabChange:D,color:`suggestion`,disableNavigation:y,children:[(0,$.jsx)(v,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(An,{error:m,setError:h,result:g,setResult:_,setViewState:a,onInstallComplete:E,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Nn,{error:m,setError:h,result:g,setResult:_,setViewState:a,onInstallComplete:E,onSearchModeChange:x,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(v,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Qn,{setViewState:a,setResult:_,onManageComplete:E,onSearchModeChange:x,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)(v,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Rn,{setViewState:a,error:m,setError:h,setResult:_,exitState:w,onManageComplete:E,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(v,{id:`errors`,title:C,children:(0,$.jsx)(hr,{setViewState:a,setActiveTab:s,markPluginsChanged:E})})]})})}var Q,$,yr,br=e((()=>{i(),m(),Q=t(m(),1),k(),x(),Ht(),j(),ue(),et(),Ue(),qe(),Fe(),vt(),at(),sn(),Mn(),Ln(),Vn(),er(),Wn(),nr(),or(),$=S(),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((()=>{m(),br(),Sr=S()}))();export{xr as call};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Bo as t,Go as n,Ho as r,Zo as i,as as a,cD as o,ns as s,ts as c,uD as l}from"./loadAgentsDir-ByO8eJqU.js";import{F as u,a as d,l as f,z as p}from"./debug-RZ4NuXyS.js";import{vt as m,xt as h}from"./settings-hQDLwPVj.js";import{g,x as _}from"./config-CE058cvr.js";import{o as v,s as y}from"./log-CZ0zYP_c.js";import{f as b,s as x}from"./pluginOperations-C7p_Qr2r.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=i(),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=n(),i=Object.keys(t.plugins);return i.length===0?[]:(await Promise.allSettled(i.map(async n=>{let{marketplace:i}=l(n);if(!i||!e.has(i.toLowerCase()))return null;let a=t.plugins[n];if(!a||a.length===0)return null;let o=a.filter(r);return o.length===0?null:w(n,o)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(_()){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 a(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(),g(),d(),p(),v(),t(),c(),o(),m(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Bo as e,Ko as t,Qo as n,rs as r,ts as i}from"./loadAgentsDir-ByO8eJqU.js";import{F as a,a as o,l as s,z as c}from"./debug-RZ4NuXyS.js";import{d as l,s as u}from"./pluginOperations-C7p_Qr2r.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-pBxSselw.js";u(),o(),c(),e(),i(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let e=t(),i=f(),o=await r(),c=[];for(let t of Object.keys(o))try{let r=await n(t);if(!r.forceRemoveDeletedPlugins)continue;let o=h(e,r,t);for(let t of o){if(t in i)continue;let n=e.plugins[t]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let e of n){let{scope:n}=e;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(t,n)}catch(e){s(`Failed to auto-uninstall delisted plugin ${t} from ${n}: ${a(e)}`,{level:`error`})}}await m(t),c.push(t)}}}catch(e){s(`Failed to check for delisted plugins in "${t}": ${a(e)}`,{level:`warn`})}return c}export{g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{Fu as n,Jm as r,Km as i,Nu as a,Pu as o,Ro as s,cD as c,uD as l,zo as u}from"./loadAgentsDir-ByO8eJqU.js";import{F as d,z as f}from"./debug-RZ4NuXyS.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-CZ0zYP_c.js";import{n as _,r as v}from"./analytics-CkYUHW_U.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-C7p_Qr2r.js";e(),f(),r(),h(),u(),c(),p(),n(),_(),T();function E(e,n,r){g(e);let i=r?`${n} plugin "${r}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${i}: ${d(e)}`);let c=r?(()=>{let{name:e,marketplace:t}=l(r);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...a(e,t,s())}})():{};v(`tengu_plugin_command_failed`,{command:n,error_category:o(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:i,marketplace:o}=l(r.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope||n,install_source:`cli-explicit`,...a(i,o,s())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,r=!1){try{let i=await x(e,n,!r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:o,marketplace:c}=l(i.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:o,...c&&{_PROTO_marketplace_name:c},scope:i.scope||n,...a(o,c,s())}),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:i,marketplace:o}=l(r.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...a(i,o,s())}),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:i,marketplace:o}=l(r.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...a(i,o,s())}),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`,...a(t,n,s())})}await i(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{$t as t,tt as n}from"./state-C2OSZkV1.js";import{$v as r,Ao as i,Bo as a,Cs as o,Do as s,Eo as c,Fo as l,Go as u,Io as d,Jo as f,Ko as p,Lo as m,Mo as h,No as g,Oo as _,Qo as v,Qv as y,So as b,To as x,Ts as S,aD as C,bE as w,cD as ee,dD as T,es as E,gD as te,gE as ne,hD as D,iw as O,ns as k,nw as A,oD as j,qo as re,sD as ie,ts as ae,uD as M,wo as oe,ws as se}from"./loadAgentsDir-ByO8eJqU.js";import{V as N,W as ce,d as P,p as F,z as I}from"./debug-RZ4NuXyS.js";import{c as L,g as R,x as z}from"./settings-hQDLwPVj.js";import{o as B,s as V}from"./log-CZ0zYP_c.js";import{l as H,o as U}from"./stringUtils-B6FudhoZ.js";import{n as W,t as G}from"./pluginStartupCheck-Di4LjHXf.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`?n():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(T(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=p();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=p().plugins[e];if(!t||t.length===0)return{scope:`user`};let r=n(),i=t.find(e=>e.scope===`local`&&e.projectPath===r);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`project`&&e.projectPath===r);if(a)return{scope:a.scope,projectPath:a.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=M(e),i,a,o;if(r){let t=await E(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await k();for(let[t,r]of Object.entries(e))try{let e=(await v(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){V(ce(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,c=`${s.name}@${a}`,u=await l({pluginId:c,entry:s,scope:t,marketplaceInstallLocation:o});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:h(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${c} (scope: ${t})${u.depNote}`,pluginId:c,pluginName:s.name,scope:t}}async function ge(e,t=`user`,n=!0){q(t);let{enabled:r,disabled:i}=await _(),a=[...r,...i],s=pe(e,a),c=T(t),l=L(c),u,d;if(s)u=Object.keys(l?.enabledPlugins??{}).find(t=>t===e||t===s.name||t.startsWith(`${s.name}@`))??(e.includes(`@`)?e:s.name),d=s.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};u=t.pluginId,d=t.pluginName}let f=J(t),m=p().plugins[u],h=m?.find(e=>e.scope===t&&e.projectPath===f);if(!h){let{scope:n}=Y(u);return n!==t&&m&&m.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 g=h.installPath,v={...l?.enabledPlugins};v[u]=void 0,z(c,{enabledPlugins:v}),o(),re(u,t,f);let y=p().plugins[u],b=!y||y.length===0;b&&g&&await S(g),b&&(A(u),n&&await ne(u));let x=C(u,a),w=j(x);return{success:!0,message:`Successfully uninstalled plugin: ${d} (scope: ${t})${w}`,pluginId:u,pluginName:d,scope:t,reverseDependents:x.length>0?x:void 0}}async function X(e,t,n){let i=t?`enable`:`disable`;if(te(e)){let{error:n}=z(`userSettings`,{enabledPlugins:{...L(`userSettings`)?.enabledPlugins,[e]:t}});if(n)return{success:!1,message:`Failed to ${i} built-in plugin: ${n.message}`};o();let{name:r}=M(e);return{success:!0,message:`Successfully ${i}d built-in plugin: ${r}`,pluginId:e,pluginName:r,scope:`user`}}n&&q(n);let a,s,c=fe(e);if(n)if(s=n,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,s=c.scope;else if(e.includes(`@`))a=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&r(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let l=T(s),u=L(l)?.enabledPlugins?.[a],d={user:0,project:1,local:2},f=n&&c&&d[n]>d[c.scope];if(n&&u===void 0&&c&&c.scope!==n&&!f)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${n}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(n&&!f?u===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${n?` at ${n} scope`:``}`};let p;if(!t){let{enabled:e,disabled:t}=await _(),n=C(a,[...e,...t]);n.length>0&&(p=n)}let{error:m}=z(l,{enabledPlugins:{...L(l)?.enabledPlugins,[a]:t}});if(m)return{success:!1,message:`Failed to ${i} plugin: ${m.message}`};o();let{name:h}=M(a),g=j(p);return{success:!0,message:`Successfully ${i}d plugin: ${h} (scope: ${s})${g}`,pluginId:a,pluginName:h,scope:s,reverseDependents:p}}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 E(e);if(!a)return{success:!1,message:`Plugin "${n}" not found`,pluginId:i,scope:t};let{entry:o,marketplaceInstallLocation:s}=a,c=u().plugins[i];if(!c||c.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:i,scope:t};let l=J(t),d=c.find(e=>e.scope===t&&e.projectPath===l);return d?be({pluginId:i,pluginName:n,entry:o,marketplaceInstallLocation:s,installation:d,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:a,scope:o,projectPath:s}){let l=P(),p=a.version,m,h,g=!1,_;if(typeof n.source!=`string`){let t=await b(n.source,{manifest:{name:n.name}});m=t.path,g=!0,_=t.gitCommitSha,h=await d(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await l.stat(r)}catch(t){if(N(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:o};throw t}m=K(t.isDirectory()?r:le(r),n.source);try{await l.stat(m)}catch(t){if(N(t))return{success:!1,message:`Plugin source not found at ${m}`,pluginId:e,scope:o};throw t}let a,s=K(m,`.claude-plugin`,`plugin.json`);try{a=await i(s,n.name,n.source)}catch{}h=await d(e,n.source,a,m,n.version)}try{let r=x(e,h),i=c(e,h);if(a.version===h||a.installPath===r||a.installPath===i)return{success:!0,message:`${t} is already at the latest version (${h}).`,pluginId:e,newVersion:h,oldVersion:p,alreadyUpToDate:!0,scope:o};r=await oe(m,e,h,n);let l=a.installPath;if(f(e,o,s,r,h,_),l&&l!==r){let e=u();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===l))||await S(l)}let d=s?`${o} (${s})`:o;return{success:!0,message:`Plugin "${t}" updated from ${p||`unknown`} to ${h} for scope ${d}. Restart to apply changes.`,pluginId:e,newVersion:h,oldVersion:p,scope:o}}finally{g&&m!==x(e,h)&&await l.rm(m,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{t(),D(),I(),F(),B(),se(),ie(),a(),ae(),w(),ee(),g(),s(),O(),y(),W(),m(),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-Di4LjHXf.js";e();export{t as getPluginEditableScopes};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{$t as n,pr as r}from"./state-C2OSZkV1.js";import{Bo as i,Cs as a,Do as o,Ko as s,Oo as c,Wo as l,Yo as u,_D as d,as as f,cD as p,dD as m,ew as h,is as g,ls as _,ns as v,ps as y,ss as b,ts as x,tw as S,uD as C,vD as w,ws as T,xs as E,ys as ee}from"./loadAgentsDir-ByO8eJqU.js";import{F as D,S as O,w as k,z as te}from"./debug-RZ4NuXyS.js";import{o as ne,s as A}from"./log-CZ0zYP_c.js";import{n as j,r as M}from"./analytics-CkYUHW_U.js";import{l as N,o as P}from"./stringUtils-B6FudhoZ.js";import{n as F,t as I}from"./exit-BOhGfSlm.js";import{n as L,s as R,t as z}from"./pluginOperations-C7p_Qr2r.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./pluginCliCommands-BJM5Bdpf.js";import{a as re,c as K,i as q,n as J,r as Y,s as X,t as ie}from"./validatePlugin-AHl-g4ct.js";import{basename as ae,dirname as Z}from"path";e(),n(),j(),R(),w(),te(),ne(),T(),K(),i(),ee(),x(),h(),q(),p(),o(),ie(),O(),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&&r(!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&&r(!0),M(`tengu_plugin_list_command`,{});let n=s(),{getPluginEditableScopes:i}=await import(`./pluginStartupCheck-C0HqhG6D.js`),a=i(),o=Object.keys(n.plugins),{enabled:u,disabled:f,errors:p}=await c(),m=[...u,...f],h=m.filter(e=>e.source.endsWith(`@inline`)),g=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),r=[];for(let e of o.sort()){let i=n.plugins[e];if(!i||i.length===0)continue;let o=C(e).name,s=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===o).map(d);for(let n of i){let i=t.get(e),o;if(i){let e=i.mcpServers||await S(i);e&&Object.keys(e).length>0&&(o=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:a.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:o,errors:s.length>0?s:void 0})}}for(let e of h){let t=e.mcpServers||await S(e),n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(d);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 g.filter(e=>e.source.startsWith(`inline[`)))r.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[d(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([v(),X()]),{marketplaces:r}=await E(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=y(r.name,t);l(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(k({installed:r,available:e},null,2))}else F(k(r,null,2))}o.length===0&&h.length===0&&g.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),o.length>0&&console.log(`Installed plugins:
|
|
2
|
-
`);for(let e of o.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let i=C(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let n of r){let r=a.has(e),i=o.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 o)console.log(` Error: ${d(e)}`);console.log(``)}}if(h.length>0||g.length>0){console.log(`Session-only plugins (--plugin-dir):
|
|
3
|
-
`);for(let e of h){let n=g.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: ${d(e)}`);console.log(``)}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${d(e)}\n`)}F()}async function ce(e,n){n.cowork&&r(!0);try{let r=await re(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 o=m(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:d}=await u(s,e=>{console.log(e)});_(c,{source:d},o),a();let f=s.source;s.source===`github`&&(f=s.repo),M(`tengu_marketplace_added`,{source_type:f}),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&&r(!0);try{let n=await v(),r=Object.keys(n);e.json&&F(k(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&&r(!0);try{await b(e),a(),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&&r(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await f(e,e=>{console.log(e)}),a(),M(`tengu_marketplace_updated`,{marketplace_name:e}),F(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await v(),n=Object.keys(e);n.length===0&&F(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await g(),a(),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&&r(!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:i,marketplace:a}=C(e);M(`tengu_plugin_install_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await V(e,n)}async function pe(e,t){t.cowork&&r(!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:i,marketplace:a}=C(e);M(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await B(e,n,t.keepData)}async function me(e,t){t.cowork&&r(!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:i,marketplace:a}=C(e);M(`tengu_plugin_enable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},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&&r(!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:i,marketplace:a}=C(e);M(`tengu_plugin_disable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n??`auto`}),await H(e,n)}async function ge(e,t){t.cowork&&r(!0);let{name:n,marketplace:i}=C(e);M(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(L.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&I(`--cowork can only be used with user scope`),await U(e,a)}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-CYXmr_mU.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-DSxRz_kt.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{A as u,p as d,w as f}from"./external-CEp-aPkt.js";import{n as p,r as m,t as h}from"./lazySchema-B4D4qJVE.js";import{$t as g,Hn as _,M as ee,On as v,P as te,Vn as y,X as b,cn as x,en as S,gr as ne,mt as C,nr as re,wn as ie}from"./state-C2OSZkV1.js";import{$S as ae,$f as oe,AE as se,Af as w,Ah as ce,Ar as T,As as E,BC as le,BE as ue,C as de,CS as fe,Ch as D,Cn as O,Co as k,D as pe,DC as me,Db as A,Dh as he,Do as ge,Ds as j,E as _e,ED as ve,ES as ye,Ec as be,Eh as xe,Es as Se,FC as Ce,FS as we,Fb as Te,Fh as Ee,Fs as De,G as Oe,GC as ke,Gl as M,Hb as Ae,Hi as je,IE as N,IS as Me,Ib as Ne,Jm as Pe,Js as Fe,Km as Ie,LC as Le,LE as Re,LS as ze,Lb as Be,Lp as Ve,MS as He,Mb as Ue,Ms as We,NS as P,Nb as F,Nd as Ge,Ns as I,OD as Ke,Ob as qe,Oh as Je,Oi as Ye,Os as Xe,Oy as Ze,P as Qe,PC as $e,Pp as et,Ps as L,QS as tt,Qx as nt,RS as rt,SE as it,SS as at,Sh as ot,Sv as st,TD as ct,TE as lt,Tc as ut,Th as dt,Ty as ft,Ub as pt,Ut as mt,VC as ht,VE as R,W as gt,Wb as _t,Wi as vt,Wl as yt,Xb as bt,Xo as xt,Xs as St,Xx as Ct,Yi as wt,Ym as Tt,Ys as Et,Zi as Dt,Zo as Ot,Zx as kt,_c as At,_g as jt,_i as Mt,ah as Nt,al as Pt,b as Ft,bS as It,bg as Lt,bh as Rt,bo as zt,cc as Bt,cl as Vt,cr as Ht,cy as Ut,dl as Wt,ei as Gt,eo as Kt,f as qt,fi as Jt,fl as Yt,gT as Xt,gi as Zt,hl as Qt,hp as $t,hu as en,ir as tn,jS as nn,jT as rn,ja as an,jd as on,jr as sn,js as cn,kD as ln,kE as un,kS as dn,kf as fn,kh as pn,ki as mn,ko as hn,kr as gn,ks as _n,ky as vn,mC as yn,mT as bn,mp as xn,mu as Sn,nl as Cn,np as wn,ny as Tn,o as En,ol as Dn,os as On,pi as kn,qT as An,qb as jn,qm as z,qs as Mn,rh as Nn,rl as Pn,rp as Fn,rs as In,ry as Ln,s as Rn,sy as zn,tC as Bn,ts as Vn,ty as Hn,uc as Un,vc as Wn,vg as Gn,wC as Kn,wh as qn,wn as Jn,wy as Yn,x as Xn,xc as Zn,xh as Qn,xo as $n,xv as er,yc as tr,yg as nr,yh as B,yn as rr,zi as ir}from"./loadAgentsDir-ByO8eJqU.js";import{n as ar,t as or}from"./cwd-C5ce-7WB.js";import{C as sr,F as V,S as cr,W as lr,a as H,d as ur,l as U,nt as dr,o as fr,p as pr,rt as mr,w as W,z as hr}from"./debug-RZ4NuXyS.js";import{G as gr,Ln as _r,d as vr,dt as yr,f as br,g as xr,it as Sr,nt as G,vt as Cr,zn as wr}from"./settings-hQDLwPVj.js";import{L as Tr,P as Er}from"./config-CE058cvr.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-BerW9bId.js";import{J as Mr,U as Nr,c as Pr,i as Fr,o as Ir,s as q}from"./log-CZ0zYP_c.js";import{i as Lr,n as Rr}from"./path-Cv9QMBAX.js";import{s as zr,u as Br}from"./types-D7_37tP2.js";import{n as Vr,r as J}from"./analytics-CkYUHW_U.js";import{Bt as Hr,C as Ur,Mn as Wr,Y as Gr,_ as Kr,_i as qr,_n as Jr,_r as Yr,bi as Xr,bt as Zr,et as Qr,gi as $r,it as ei,jn as ti,o as ni,ri,rt as ii,ti as ai,tt as oi,u as si,vi as ci,vn as li,vr as ui,x as di}from"./model-CwO-g1RW.js";import{Sn as fi,gt as pi,ht as mi,ot as hi,qt as gi,st as _i,tn as vi,xn as yi}from"./prompt-B7joRiqj.js";import{A as bi,C as xi,D as Si,F as Ci,I as wi,N as Ti,U as Ei,a as Di,c as Oi,l as ki,n as Ai,o as ji,s as Mi,t as Ni,vt as Pi}from"./sessionState-CjNY991n.js";import{n as Fi,t as Ii}from"./omit-DZCEXri5.js";import{a as Li,n as Ri,t as zi}from"./bridgeConfig-jDEva6Eh.js";import{i as Bi,n as Vi,s as Hi}from"./mappers-CHRFic5q.js";import{n as Ui,r as Wi}from"./sessionTitle-B0OYf5nM.js";import{t as Gi}from"./pollConfig-BgpfHQPJ.js";import{n as Ki,t as qi}from"./ccrClient-BC2q3k44.js";import{n as Ji,t as Yi}from"./HybridTransport-BJPOG2wl.js";import{n as Xi,t as Zi}from"./SSETransport-CrwbKuVt.js";import{a as Qi,n as $i}from"./grove-Cv19v6Sv.js";import{o as ea}from"./remoteManagedSettings-B1mnRDmA.js";import{i as ta,r as na}from"./auth-CNjDn1VY.js";import{t as ra}from"./pluginBlocklist-PwHHD3nj.js";import{t as ia}from"./onChangeAppState-BmfM5g-D.js";import{t as aa}from"./settingsSync-DdFagwHV.js";import{a as oa,i as sa,n as ca,o as la,r as ua,s as da}from"./reconciler-BfkO6X2X.js";import{n as fa,t as pa}from"./toolPool-B7SIoDw5.js";import{n as ma,r as ha}from"./QueryEngine-Cv_meCam.js";import{n as ga,r as _a}from"./sideQuestion-C780iYwd.js";import{n as va,r as ya}from"./context-noninteractive-Ct_ttQfP.js";import{a as ba,o as xa,t as Sa}from"./skillChangeDetector-plLveEbf.js";import{n as Ca,t as wa}from"./refresh-C1X3sptR.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(),m(),g(),ar(),dr(),hr(),cr(),pr(),Or(),H(),Ar(),Mr(),Ir(),Lr(),_r(),zr(),xr(),Xr(),yi(),ri(),ui(),ti(),Jr(),Hr(),Kr(),vi(),wi(),Ti(),ft(),D(),Pe(),fn(),Ai(),$n(),Kt(),wt(),sn(),aa(),i(),Xi();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 Zi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new Yi(e,t,r,i):new Ji(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}i(),Xi();var Fa=class extends sa{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=Ci();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=Ci();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,C(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=fr(),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 Zi))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new qi(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 Ki?e.reason:`unknown`}),q(Error(`CCRClient initialization failed: ${V(e)}`)),Ie(1,`other`)}),mr(async()=>this.ccrClient?.close()),mn((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Ye(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};dt((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),ki((e,t)=>{this.ccrClient?.reportState(e,t)}),Oi(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=Gi().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?.()),mr(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(oa(e)+`
|
|
5
|
-
`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};gi(),gr(),pi(),[...mi],dr(),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},mr(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}))}h(),Cr(),Sr(),Er(),Ei(),N(),un(),lt(),le(),me(),rt(),kt(),_t(),_i(),Ze(),Ut(),jt(),wn(),Qt(),Pn(),Un(),Et(),Fe(),I(),Vn(),ge(),Jn(),rr(),Oe(),En(),pa(),oe(),hr(),Ir(),wi(),An(),H(),Pe();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`),z())},n))},stop(){i&&(clearTimeout(i),i=null)}}}ln(),Ii(),ue(),Nn(),Ve(),g(),H(),i(),Li();var Va=3e4;function Ha(e){U(`[bridge:inbound-attach] ${e}`)}var Ua=p(()=>f({file_uuid:u(),file_name:u()})),Wa=p(()=>d(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`,C())}async function Ja(e){let t=zi();if(!t){Ha(`skip: no oauth token`);return}let n;try{let r=`${Ri()}/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))}Qr(),A(),st(),be(),At(),de(),Wi(),ga();function Qa(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Y(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(w(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}$r(),ve(),rn(),tt(),P(),dn(),Ee(),pn(),Qn(),on(),M(),Pt(),Vi(),ya(),H();async function $a(){try{let e=await Aa(E(),`utf-8`),t=yr().safeParse(sr(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 Se(E(),W(e,null,2))}async function to(e,t){let n=_n();if(!n)return;let r=await no(t);r!==null&&await Se(Da(n,Xe(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 In();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})}Vr(),dr(),H(),Ar(),Ir(),Vn(),I();async function io(){let e=De();U(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await On();t&&(xt(),k(`headlessPluginInstall: seed marketplaces registered`)),e&&(await ur().mkdir(cn()),await ur().mkdir(We()));let n=Object.keys(Ot()).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`,()=>ca({skip:e?(e,t)=>!L(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&&(xt(),k(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await ro();let t=await ra();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&k(`headlessPluginInstall: plugins changed`),e&&mr(j),i}catch(e){return q(e),!1}finally{J(`tengu_headless_plugin_install`,r)}}Vr(),H(),Ar(),D(),Ai(),Ir(),Or(),fn(),Pe(),dr(),ar(),g(),sn(),Kt(),cr(),i(),wa(),ge(),F(),xn(),Sn(),hr();var $=(xi(),e(Si)),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(process.env.USER_TYPE===`ant`&&n(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0)),se.subscribe(e=>{er(e,r),ii()&&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(),Rt(),B(`runHeadless_entry`),await Qi()&&await $i(),B(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
10
|
-
`),z(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
11
|
-
`),z(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
12
|
-
`),z(1);return}let l=Co(e,c);c.outputFormat===`stream-json`&&za();let u=it.getSandboxUnavailableReason();if(u){if(it.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),z(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${u}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(it.isSandboxingEnabled())try{await it.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${V(e)}\n`),z(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&St(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:C()};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:C()};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:C()}}})();l.write(t)}),c.setupTrigger&&await nr(c.setupTrigger),B(`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=Lt();if(h&&l.prependUserMessage(h),!c.agent&&!b()&&m){let{agentDefinition:e}=ba(m,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!Rn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}Zt(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`),z(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`),z(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),z(0);return}let g=typeof c.resume==`string`&&(!!w(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
|
-
`),z(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
14
|
-
`),z(1);return}let ee=Yt(d.mcp.tools,d.toolPermissionContext),v=[...a,...ee],te=go(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),ji(`requires_action`,e)});c.permissionPromptToolName&&(v=v.filter(e=>!fi(e,c.permissionPromptToolName))),Dr(),B(`after_loadInitialMessages`),await ai(),B(`after_modelStrings`);let y=c.outputFormat===`json`&&c.verbose,x=[],S;B(`before_runHeadlessStreaming`);for await(let e of mo(l,d.mcp.clients,[...i,...d.mcp.commands],v,f,te,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`&&(y&&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(ot(),Tr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-DxTUMiv3.js`);await e()}catch{}z(S?.type===`result`&&S?.is_error?1:0)}function mo(e,r,i,o,s,c,l,u,d,f,p,m){let h=!1,g,_=!1,v=null,b,x=e.outbound;process.on(`SIGINT`,()=>{jr(`info`,`shutdown_signal`,{signal:`SIGINT`}),b&&!b.signal.aborted&&b.abort(),Ie(0)}),mr(async()=>{let t={};for(let e of Ue(u()))$t(e)&&(t[e.type]=(t[e.type]??0)+1);jr(`info`,`run_state_at_shutdown`,{run_active:h,run_phase:g,worker_status:Ni(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),Mi(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&x.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:C()})});let S={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ne;p.enableAuthStatus&&(ne=Yr.getInstance().subscribe(e=>{x.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:C()})}));let oe=e=>{let t=Hi(e);t&&x.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:C()})};qe.add(oe);let w=s,T=Bt(s,X(),100),E=Ct(100),le=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;m&&m.kind!==`none`&&le&&(U(`[print.ts] Auto-resuming interrupted turn (kind: ${m.kind})`),xo(w,m.message),Be({mode:`prompt`,value:m.message.message.content,uuid:Y()}));let ue=yt().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?ni():Ur(t),r=Ge(n),i=ei(e.value),a=Wr(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),de=p.userSpecifiedModel;function fe(e,t){let n=an(e,di(t));w.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&x.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:C(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let D=[],O=[],k=new Set;function pe(t){for(let n of t){if(n.type!==`connected`||k.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(bn,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 we(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 Me(t,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler(Xt,e=>{let{elicitationId:n}=e.params;Pr(t,`Elicitation completion notification: ${n}`),mt({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),x.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:C()})}),k.add(t)}catch{}}}async function me(){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 He(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]}})),vn(D)}}me();let A={clients:[],tools:[],configs:{}},ge=e=>{let t=Wt(e.toolPermissionContext,e.mcp.tools),n=Re(fa([...o,...O,...A.tools],t,e.toolPermissionContext.mode),`name`);p.permissionPromptToolName&&(n=n.filter(e=>!fi(e,p.permissionPromptToolName)));let r=te();if(r&&!p.jsonSchema){let e=hi(r);`tool`in e&&(n=[...n,e.tool])}return n},j=null,_e=0;function ve(){if(!j)return;let e=Math.min(_e,w.length),t=w.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);_e=w.length,t.length>0&&j.writeMessages(t)}let ye=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function be(e){let t=async()=>{let t=new Set(D.map(e=>e.name)),n=await Eo(e,{configs:l,clients:D,tools:O},A,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,A=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 ye=ye.then(t,t),ye}function Se(){let e=u(),t=e.mcp.clients,n=Re([...e.mcp.tools,...A.tools],`name`),r=new Set([...t.map(e=>e.name),...D.map(e=>e.name)]);return[...t,...D,...A.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`?Kn(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 Ee(){try{await Promise.all([Promise.resolve(),kr(`headless_managed_settings_wait`,()=>ea())]),await io()&&await Fe()}catch(e){q(e)}}let De=null;a()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?De=Ee():Ee());let Oe=Ba(()=>!h),M=i,N=f;async function Pe(){let{agentDefinitions:e}=await Ca(d);M=await vt(X());let t=N.filter(e=>e.source===`flagSettings`);N=[...e.allAgents,...t]}async function Fe(){let{servers:e}=await Ce(),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 be(t);r&&me(),U(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ve=Sa.subscribe(()=>{ir(),vt(X()).then(e=>{M=e})}),We=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||_||(async()=>{let e=await ce({basePrompt:`<${Nr}>${new Date().toLocaleTimeString()}</${Nr}>`,currentDir:X(),shouldCreate:()=>!_});if(_){await xe({commands:e});return}for(let t of e)Be({...t,uuid:Y()});P()})().catch(e=>{q(e),U(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};bt(()=>{b&&Ae(`now`).length>0&&b.abort(`interrupt`)});let P=async()=>{if(h)return;if(h=!0,g=void 0,ji(`running`),Oe.stop(),B(`run_entry`),await me(),B(`after_updateSdkMcp`),De){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=li(e).then(()=>`timeout`);await Promise.race([De,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 De;De=null,await Pe();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-BPnxcgrL.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=Te(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,jn(n));)i.push(Te(n));let a=await he(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(p.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&x.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:C(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...D,...A.clients];pe(l);let f=ge(s);for(let e of o)qn(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&&x.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:C(),uuid:Y()})}let m=r.value,h=a.claimedCommands;if(e instanceof Fa&&r.mode===`prompt`&&J(`tengu_bridge_message_received`,{is_repl:!1}),S.abortController?.abort(),S.abortController=null,S.pendingSuggestion=null,S.pendingLastEmittedEntry=null,S.lastEmitted&&r.mode===`prompt`){let e=typeof m==`string`?m:m.find(e=>e.type===`text`)?.text;typeof e==`string`&&Wn(S.lastEmitted.text,e,S.lastEmitted.emittedAt,S.lastEmitted.promptId,S.lastEmitted.generationRequestId),S.lastEmitted=null}b=ze(),B(`before_ask`),Vt();let g=r,_=!1;try{if(await qr(g.workload??p.workload,async()=>{for await(let t of ma({commands:Re([...M,...s.mcp.commands],`name`),prompt:m,promptUuid:g.uuid,isMeta:g.isMeta,cwd:X(),tools:f,verbose:p.verbose,mcpClients:l,thinkingConfig:p.thinkingConfig,maxTurns:p.maxTurns,maxBudgetUsd:p.maxBudgetUsd,taskBudget:p.taskBudget,canUseTool:c,userSpecifiedModel:de,fallbackModel:p.fallbackModel,jsonSchema:te()??p.jsonSchema,mutableMessages:w,getReadFileCache:()=>E.size===0?T:nt(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:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,getAppState:u,setAppState:d,abortController:b,replayUserMessages:p.replayUserMessages,includePartialMessages:p.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:N,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{x.enqueue({type:`system`,subtype:`status`,status:e,session_id:C(),uuid:Y()})}}))if(ve(),t.type===`result`){_=!!t.is_error;for(let e of bi())x.enqueue(e);Ue(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&$t(e))?v=t:(v=null,x.enqueue(t))}else{for(let e of bi())x.enqueue(e);x.enqueue(t)}}),_)await Je({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:g.workload??p.workload});else{let e=await Je({commands:h,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:g.workload??p.workload});for(let t of e)Be({...t,uuid:Y()})}}catch(e){throw await Je({commands:h,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:g.workload??p.workload}),e}for(let e of o)qn(e,`completed`);if(ve(),j?.sendResult(),p.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){S.abortController?.abort();let e=new AbortController;S.abortController=e;let t=ut();if(!t)tr(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await Zn(e,w,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:C()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};v?(S.pendingSuggestion=r,S.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(S.lastEmitted=i,x.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){tr(`aborted`,void 0,void 0,`sdk`);return}q(lr(e))}finally{S.inflightPromise===n.promise&&(S.inflightPromise=null)}})(),S.inflightPromise=n.promise}}ot(),Dn(),Rt()}};do{for(let e of bi())x.enqueue(e);g=`draining_commands`,await a(),i=!1;{let e=Ue(u()).some(e=>$t(e)),t=jn(n)!==void 0;(e||t)&&(i=!0,t||(g=`waiting_for_agents`,await li(100)))}}while(i);v&&(x.enqueue(v),v=null,S.pendingSuggestion&&(x.enqueue(S.pendingSuggestion),S.pendingLastEmittedEntry&&(S.lastEmitted={...S.pendingLastEmittedEntry,emittedAt:Date.now()},S.pendingLastEmittedEntry=null),S.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:C(),total_cost_usd:0,usage:Pi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[V(t),...Fr().map(e=>e.error)]})}catch{}S.abortController?.abort(),z(1);return}finally{if(g=`finally_flush`,await e.flushInternalEvents(),g=`finally_post_flush`,!Tt()){ji(`idle`);for(let e of bi())x.enqueue(e)}h=!1,Oe.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&jn(n)===void 0&&!_){We();return}if(jn(n)!==void 0){P();return}_&&(S.inflightPromise&&await Promise.race([S.inflightPromise,li(5e3)]),S.abortController?.abort(),S.abortController=null,await Mn(),Ve(),ne?.(),qe.delete(oe),x.done())},F=function(e,t){x.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},I=function(e,t){x.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},Ye=new Set;e.setUnexpectedResponseCallback(async e=>{await wo({message:e,setAppState:d,handledToolUseIds:Ye,onEnqueued:()=>{P()}})});let Xe=new Map,Ze=new Map,Qe=new Set,$e=new Map,L=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`&&qn(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}})),b&&b.abort(),S.abortController?.abort(),S.abortController=null,S.lastEmitted=null,S.pendingSuggestion=null,F(a);else if(o.subtype===`end_session`){U(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),b&&b.abort(),S.abortController?.abort(),S.abortController=null,S.lastEmitted=null,S.pendingSuggestion=null,F(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,x,i,ue,e,!!p.enableAuthStatus,p,f,u),a.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),a.request.agentProgressSummaries&&re(!0),t=!0,pt()&&P()}else if(a.request.subtype===`set_permission_mode`){let e=a.request;d(t=>({...t,toolPermissionContext:yo(e,a.request_id,t.toolPermissionContext,x)}))}else if(a.request.subtype===`set_model`){let e=a.request.model??`default`,t=e==="default"?ni():e;de=t,y(t),Di({model:t}),fe(e,t),F(a)}else if(a.request.subtype===`set_max_thinking_tokens`)a.request.max_thinking_tokens===null?p.thinkingConfig=void 0:a.request.max_thinking_tokens===0?p.thinkingConfig={type:`disabled`}:p.thinkingConfig={type:`enabled`,budgetTokens:a.request.max_thinking_tokens},F(a);else if(a.request.subtype===`mcp_status`)F(a,{mcpServers:Se()});else if(a.request.subtype===`get_context_usage`)try{let e=u(),t=await va({messages:w,getAppState:u,options:{mainLoopModel:si(),tools:ge(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt}});F(a,{...t})}catch(e){I(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),F(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?F(a,t):I(a,t.error??`Unexpected error`)}else if(a.request.subtype===`cancel_async_message`){let e=a.request.message_uuid,t=Ne(t=>t.uuid===e);F(a,{cancelled:t.length>0})}else if(a.request.subtype===`seed_read_state`){try{let e=Rr(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{}F(a)}else if(a.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await be(a.request.servers);F(a,e),t&&me()}else if(a.request.subtype===`reload_plugins`)try{let e=await Ca(d),t=N.filter(e=>e.source===`flagSettings`);N=[...e.agentDefinitions.allAgents,...t];let n=[],[r,i,o]=await Promise.allSettled([vt(X()),Fe(),hn()]);r.status===`fulfilled`?M=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),F(a,{commands:M.filter(e=>e.userInvocable!==!1).map(e=>({name:Dt(e),description:je(e),argumentHint:e.argumentHint||``})),agents:N.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Se(),error_count:e.error_count})}catch(e){I(a,V(e))}else if(a.request.subtype===`mcp_reconnect`){let e=u(),{serverName:t}=a.request;k.delete(t);let n=Le(t)??r.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??A.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)I(a,`Server not found: ${t}`);else{let e=await nn(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:[...R(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...R(n.mcp.commands,e=>yn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:Fi(n.mcp.resources,t)}})),A={...A,clients:[...A.clients.filter(e=>e.name!==t),e.client],tools:[...A.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`)pe([e.client]),F(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;I(a,t)}}}else if(a.request.subtype===`mcp_toggle`){let e=u(),{serverName:t,enabled:n}=a.request;k.delete(t);let i=Le(t)??r.find(e=>e.name===t)?.config??D.find(e=>e.name===t)?.config??A.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!i)I(a,`Server not found: ${t}`);else if(n){ke(t,!0);let e=await nn(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:[...R(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...R(r.mcp.commands,e=>yn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:Fi(r.mcp.resources,t)}})),e.client.type===`connected`)pe([e.client]),F(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;I(a,t)}}else{ke(t,!1);let n=[...r,...D,...A.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await at(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:R(e.mcp.tools,e=>e.name?.startsWith(o)),commands:R(e.mcp.commands,e=>yn(e,t)),resources:Fi(e.mcp.resources,t)}})),F(a)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=u(),n=Le(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)I(a,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)I(a,`Server type "${n.type}" does not support OAuth authentication`);else try{Xe.get(e)?.abort();let t=new AbortController;Xe.set(e,t);let r,i=new Promise(e=>{r=e}),o=ae(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{Ze.set(e,t)}}),s=await Promise.race([i,o.then(()=>null)]);s?F(a,{authUrl:s,requiresUserAction:!0}):F(a,{requiresUserAction:!1}),$e.set(e,o),o.then(async()=>{if(ht(e)||Qe.has(e))return;let t=await nn(e,n),r=G(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...R(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...R(n.mcp.commands,t=>yn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:Fi(n.mcp.resources,e)}})),A={...A,clients:[...A.clients.filter(t=>t.name!==e),t.client],tools:[...A.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{U(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Xe.get(e)===t&&(Xe.delete(e),Ze.delete(e),Qe.delete(e),$e.delete(e))})}catch(e){I(a,V(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=Ze.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)I(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=$e.get(e);if(r)try{await r,F(a)}catch(e){I(a,e instanceof Error?e.message:`OAuth authentication failed`)}else F(a)}}else I(a,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;L?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new ta,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 na(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),L?.service===t&&(L=null)});L={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`)})]);F(a,{manualUrl:e,automaticUrl:t})}catch(e){I(a,V(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!L)I(a,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&L.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=L;e.then(()=>{let e=Zr();F(a,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:ci()}})},e=>I(a,V(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=u(),n=Le(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)I(a,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)I(a,`Cannot clear auth for server type "${n.type}"`);else{await Bn(e,n);let t=await nn(e,n),r=G(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...R(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...R(n.mcp.commands,t=>yn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:Fi(n.mcp.resources,e)}})),F(a,{})}}else if(a.request.subtype===`apply_flag_settings`){let e=si(),t=ee()??{},n=a.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];ie(r),se.notifyChange(`flagSettings`),`model`in n&&(n.model==null?y(void 0):y(String(n.model)));let i=si();if(i!==e){de=i;let e=n.model?String(n.model):`default`;Di({model:i}),fe(e,i)}F(a)}else if(a.request.subtype===`get_settings`){let e=si();F(a,{...vr(),applied:{model:e}})}else if(a.request.subtype===`stop_task`){let{task_id:e}=a.request;try{await en(e,{getAppState:u,setAppState:d}),F(a,{})}catch(e){I(a,V(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(b&&!b.signal.aborted?b:ze()).signal;(async()=>{try{let r=await Ui(e,n);if(r&&t)try{Mt(C(),r)}catch(e){q(e)}F(a,{title:r})}catch(e){I(a,V(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=ut(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:ze()}}:await ha({tools:ge(u()),commands:M,mcpClients:[...u().mcp.clients,...D,...A.clients],messages:w,readFileState:T,getAppState:u,setAppState:d,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,thinkingConfig:p.thinkingConfig,agents:N}),r=await _a({question:e,cacheSafeParams:n});F(a,{response:r.response})}catch(e){I(a,V(e))}})()}else if(a.request.subtype===`set_proactive`)a.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),We()):$.deactivateProactive(),F(a);else if(o.subtype===`remote_control`)if(o.enabled)if(j)F(a,{session_url:Ke(j.bridgeSessionId,j.sessionIngressUrl),connect_url:et(j.environmentId,j.sessionIngressUrl),environment_id:j.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-DdsSWVqN.js`),r=await n({onInboundMessage(e){let t=ua(e);if(!t)return;let{content:n,uuid:r}=t;Be({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),P()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){b?.abort()},onSetModel(e){let t=e==="default"?ni():e;de=t,y(t)},onSetMaxThinkingTokens(e){e===null?p.thinkingConfig=void 0:e===0?p.thinkingConfig={type:`disabled`}:p.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),U(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),x.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:C()})},initialMessages:w.length>0?w:void 0});r?(j=r,_e=w.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),F(a,{session_url:Ke(r.bridgeSessionId,r.sessionIngressUrl),connect_url:et(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):I(a,t??`Remote Control initialization failed`)}catch(e){I(a,V(e))}}else j&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await j.teardown(),j=null),F(a);else I(a,`Unsupported control request subtype: ${a.request.subtype}`);continue}else if(n.type===`control_response`){p.replayUserMessages&&x.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=Bi([n]);w.push(...e),n.type===`assistant`&&p.replayUserMessages&&x.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=C(),t=await tn(e,o.uuid);if(t||oo.has(o.uuid)){U(`Skipping duplicate user message: ${o.uuid}`),p.replayUserMessages&&(U(`Sending acknowledgment for duplicate user message: ${o.uuid}`),x.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&&qn(o.uuid,`completed`);continue}co(o.uuid)}Be({mode:`prompt`,value:await Za(o,o.message.content),uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:ct(e.attribution,e=>{Gt(e).catch(e=>{U(`Attribution: Failed to save snapshot: ${e}`)})})})),P()}_=!0,h||(S.inflightPromise&&await Promise.race([S.inflightPromise,li(5e3)]),S.abortController?.abort(),S.abortController=null,await Mn(),Ve(),ne?.(),qe.delete(oe),x.done())})(),x}function ho(e){let t=async(n,r,i,a,o,s)=>{let c=s??await gt(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=O(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 da(la().parse(Br(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 gt(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=>fi(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),z(1),Error(n)}if(!r.inputJSONSchema){let t=`Error: tool ${e} (passed via --permission-prompt-tool) must be an MCP tool`;throw process.stderr.write(`${t}\n`),z(1),Error(t)}i=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=qt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=b()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(_(t.agentType),!c.systemPrompt&&!Rn(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&y(Ur(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let d=br()?.outputStyle||`default`,f=await zt(or()),p=Zr();if(e.hooks){let t={};for(let[n,r]of Object.entries(e.hooks))t[n]=r.map(e=>{let t=e.hookCallbackIds.map(t=>o.createHookCallback(t,e.timeout));return{matcher:e.matcher,hooks:t}});x(t)}e.jsonSchema&&v(e.jsonSchema);let m={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:Dt(e),description:je(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:ci()},pid:process.pid};if(ii()&&oi()){let e=u();m.fast_mode_state=Gr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:m}}),s){let e=Yr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:C()})}}async function vo(e,t,n,r){if(!Tn())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Hn(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Ln(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await zn(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${V(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function yo(e,t,n,r){if(e.mode===`bypassPermissions`){if(pe())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=Xn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${Ft(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...Qe(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:C(),total_cost_usd:0,usage:Pi,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=!S();if(t.continue)try{J(`tengu_continue_print`,{});let n=await Fn(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(ne(Yn(n.sessionId),n.fullPath?Ea(n.fullPath):null),r&&await Jt()),xa(n,e),kn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return q(e),z(1),{messages:[]}}if(t.teleport)try{if(!Nt(`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-CwxeD5vL.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),z(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),z(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([gn(i.sessionId),t.restoredWorkerState]);n&&(e(ia(n)),typeof n.model==`string`&&y(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await T(i.sessionId,i.ingressUrl);let a=await Fn(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??Gn(`startup`))}:(bo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),z(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),z(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(ne(Yn(a.sessionId),a.fullPath?Ea(a.fullPath):null),r&&await Jt()),xa(a,e),kn(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),z(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??Gn(`startup`))}}function Co(e,t){let n;return n=typeof e==`string`?e.trim()===``?Cn([]):Cn([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 sa(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 Ht(t);return a?(r.add(t),U(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Be({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}=$e(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||!It(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 at(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 fe(t,r);if(d.push(e),e.type===`connected`){let t=await ye(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=lr(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{I as t,fi as n,t as r}from"./src-CDCSSo0U2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Bd as a,Dy as o,Ey as s,Ia as c,La as l,Na as u,US as d,WS as f,eo as p,f_ as m,h_ as h,i_ as g,m_ as _,p_ as v,r_ as y,uo as b,zd as x}from"./loadAgentsDir-ByO8eJqU.js";import{F as S,j as C,z as w}from"./debug-RZ4NuXyS.js";import{g as T,n as E}from"./settings-hQDLwPVj.js";import{n as D,r as O}from"./analytics-CkYUHW_U.js";import{_t as k,gt as A}from"./prompt-B7joRiqj.js";import{randomUUID as j}from"crypto";n(),r(),v(),a(),h();var M=i();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(x,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(_,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):m.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}w(),D(),d(),p(),T();function P(){return E().defaultShell??`bash`}v(),A(),o();async function F(t,n,r,i,a){let o=k()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:o});let d=l({content:b({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),p;a({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{p=e?.jsx}},c=e=>{a({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),p]}),shouldHidePromptInput:!1,showSpinner:!1})},h=null;o&&(h=(g(),e(y)).PowerShellTool);let _=h??m,v=(h?await h.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,c):await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,c)).data;if(!v)throw Error(`No result received from shell command`);let b=v.stderr,x=await f(_,{...v,stderr:``},j()),S=typeof x.content==`string`?x.content:s(v.stdout);return{messages:[u(),d,...r,l({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${s(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof C?e.interrupted?{messages:[u(),d,c({toolUse:!1}),...r],shouldQuery:!1}:{messages:[u(),d,...r,l({content:`<bash-stdout>${s(e.stdout)}</bash-stdout><bash-stderr>${s(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[u(),d,...r,l({content:`<bash-stderr>Command failed: ${s(S(e))}</bash-stderr>`})],shouldQuery:!1}}finally{a(null)}}export{F as processBashCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$t as t,er as n,mt as r,t as i}from"./state-C2OSZkV1.js";import{$d as a,Aa as o,Au as s,Bs as c,By as l,C as u,Dc as d,Ec as f,Fh as p,Fu as m,G as h,Hy as g,Ia as _,Ji as v,LS as y,La as b,Lb as x,Li as S,Mh as C,Mu as w,Na as T,Of as E,Pa as D,QC as O,RS as k,Rb as A,Ru as j,Ui as M,Us as ee,Va as te,Vi as ne,Vs as re,W as ie,Wb as ae,XC as oe,Yi as se,ZC as ce,Zi as N,_b as le,af as ue,ao as de,bD as fe,cD as pe,co as me,dg as he,dv as ge,ef as P,eo as _e,gh as ve,hh as F,if as ye,il as be,jh as xe,ju as Se,k as Ce,kf as we,lD as I,mb as Te,pg as Ee,rf as De,rl as Oe,to as ke,uD as L,uo as R,uv as Ae,wc as z,yD as je,zu as Me}from"./loadAgentsDir-ByO8eJqU.js";import{A as B,D as Ne,a as V,d as Pe,l as H,p as Fe,z as Ie}from"./debug-RZ4NuXyS.js";import{Cn as Le,Dt as Re,Ot as ze,bn as Be}from"./settings-hQDLwPVj.js";import{J as Ve,T as U,o as He,s as W,w as G}from"./log-CZ0zYP_c.js";import{n as Ue,r as K}from"./analytics-CkYUHW_U.js";import{_n as We,gi as Ge,hi as Ke,vn as qe}from"./model-CwO-g1RW.js";import{ct as Je,ot as Ye}from"./esm-BLPbfHQd.js";import{E as Xe,T as Ze,w as Qe}from"./sessionTracing-CwsXt_uA.js";import{randomUUID as q}from"crypto";function $e(e,t,n,r,i){let a=0;for(let o of Re){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}'`),ue(e,t,o,s)}:void 0;De(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var J=e((()=>{ze(),V(),ye()}));function et(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 tt=e((()=>{}));function nt(){return!1}function rt(){if(!nt())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function it(e,t,n,r,i,a,o){let s=E(),c=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,...c&&{_PROTO_marketplace_name:c},...w(e.pluginInfo)}});let{skillContent:l,modifiedGetAppState:u,baseAgent:f,promptMessages:p}=await d(e,t,n);H(`Executing forked slash command /${e.name} with agent ${f.agentType}`);let m=await n.getAppState(),h=n.options.allowBackgroundForkedSlashCommands===!0;h&&rt();let g=!1;if(m.kairosEnabled&&h&&(g=!0),g){let t=y(),r=N(e),i=Ke(),c=e=>A({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),l=async()=>{if(!o?.runId)return;let e=await xe({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)x(t)},d=async e=>{o?.runId&&await C({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await qe(Q);let o=n.options.refreshTools?.()??n.options.tools,d=[];for await(let r of P({agentDefinition:f,promptMessages:p,toolUseContext:{...n,getAppState:u,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:s}}))d.push(r);let m=z(d,`Command completed`);H(`Background forked command /${r} completed (agent ${s})`),c(`<scheduled-task-result command="/${r}">\n${m}\n</scheduled-task-result>`);try{await l()}catch(e){W(e)}})().catch(async e=>{W(e),c(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await d(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let _=[],v=[],S=`forked-command-${e.name}`,T=0,D=e=>(T++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:l,agentId:s},parentToolUseID:S,toolUseID:`${S}-${T}`,timestamp:new Date().toISOString(),uuid:q()}),O=()=>{i({jsx:Me(v,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};O();try{for await(let t of P({agentDefinition:f,promptMessages:p,toolUseContext:{...n,getAppState:u},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){_.push(t);let e=me([t]);if(t.type===`assistant`){let r=Te(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(v.push(D(t)),O())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(v.push(D(t)),O())}}}finally{i(null)}let k=z(_,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),process.env.USER_TYPE===`ant`&&(k=`[ANT-ONLY] API calls: ${Be(F(s))}\n${k}`),{messages:[b({content:R({inputString:`/${N(e)} ${t}`.trim(),precedingInputBlocks:r})}),b({content:`<local-command-stdout>\n${k}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:k}}function at(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function ot(e,t,r,i,a,o,s,c,l,u){let d=et(e);if(!d){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[T(),...i,b({content:R({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:f,args:p,isMcp:m}=d,h=m?`mcp`:S().has(f)?f:`custom`;if(!v(f,a.options.commands)){let r=!1;try{await Pe().stat(`/${f}`),r=!0}catch{}if(at(f)&&!r){K(`tengu_input_slash_invalid`,{input:f});let e=`Unknown skill: ${f}`;return{messages:[T(),...i,b({content:R({inputString:e,precedingInputBlocks:t})}),...p?[D(`Args from unknown skill: ${p}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let a=q();return n(a),K(`tengu_input_prompt`,{}),Ze(`user_prompt`,{prompt_length:String(e.length),prompt:Xe(e),"prompt.id":a}),{messages:[b({content:R({inputString:e,precedingInputBlocks:t}),uuid:s}),...i],shouldQuery:!0}}let{messages:g,shouldQuery:_,allowedTools:y,model:x,command:C,resultText:E,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}=await st(f,p,o,a,t,r,c,l,s,u);if(g.length===0){let e={input:h};if(C.type===`prompt`&&C.pluginInfo){let{pluginManifest:t,repository:n}=C.pluginInfo,{marketplace:r}=L(n),i=I(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,w(C.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:f,...C.type===`prompt`&&{skill_source:C.source},...C.loadedFrom&&{skill_loaded_from:C.loadedFrom},...C.kind&&{skill_kind:C.kind}}}),{messages:[],shouldQuery:!1,model:x,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}}if(g.length===2&&g[1].type===`user`&&typeof g[1].message.content==`string`&&g[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:f}),{messages:[T(),...g],shouldQuery:_,allowedTools:y,model:x};let j={input:h};if(C.type===`prompt`&&C.pluginInfo){let{pluginManifest:e,repository:t}=C.pluginInfo,{marketplace:n}=L(t),r=I(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,w(C.pluginInfo))}K(`tengu_input_command`,{...j,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:f,...C.type===`prompt`&&{skill_source:C.source},...C.loadedFrom&&{skill_loaded_from:C.loadedFrom},...C.kind&&{skill_kind:C.kind}}});let M=g.length>0&&g[0]&&ke(g[0]);return{messages:_||g.every(de)||M?g:[T(),...g],shouldQuery:_,allowedTools:y,model:x,resultText:E,nextInput:O,submitNextInput:k,deferAutonomyCompletion:A}}async function st(e,t,n,r,i,a,s,c,l,u){let d=M(e,r.options.commands);if(d.type===`prompt`&&d.userInvocable!==!1&&Se(e),d.userInvocable===!1)return{messages:[b({content:R({inputString:`/${e}`,precedingInputBlocks:i})}),b({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:d};try{switch(d.type){case`local-jsx`:return new Promise(e=>{let a=!1,s=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:d,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let s=(r?.metaMessages??[]).map(e=>b({content:e,isMeta:!0})),c=ge()&&typeof n==`string`&&n.endsWith(` dismissed`),l=r?.displayArgs??t;e({messages:r?.display===`system`?c?s:[o(Y(d,l)),o(`<local-command-stdout>${n}</local-command-stdout>`),...s]:[b({content:R({inputString:Y(d,l),precedingInputBlocks:i})}),b(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${je}</local-command-stdout>`}),...s],shouldQuery:r?.shouldQuery??!1,command:d,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};d.load().then(e=>e.call(s,{...r,canUseTool:c},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:d});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:d.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:d}))})});case`local`:{let e=b({content:R({inputString:Y(d,d.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=T(),i=await(await d.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:d};if(i.type===`compact`){let t=[n,e,...i.displayText?[b({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return g(),{messages:he(r),shouldQuery:!1,command:d}}return{messages:[e,o(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:d,resultText:i.value}}catch(t){return W(t),{messages:[e,o(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:d}}}case`prompt`:try{return d.context===`fork`?await it(d,t,r,i,n,c??ie,u):await Z(d,t,r,i,a,l)}catch(e){return e instanceof Ne?{messages:[b({content:R({inputString:Y(d,t),precedingInputBlocks:i})}),_({toolUse:!1})],shouldQuery:!1,command:d}:{messages:[b({content:R({inputString:Y(d,t),precedingInputBlocks:i})}),b({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:d}}}}catch(e){if(e instanceof B)return{messages:[b({content:R({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:d};throw e}}function Y(e,t){return te(N(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
-
`)}function ct(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
3
|
-
`)}function lt(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):ct(e.name,t)}async function ut(e,t,n,r,i=[]){let a=ne(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,a=[],o=[],s){let l=await e.getPromptForCommand(t,n),u=!ce(`hooks`)||O(e.source);if(e.hooks&&u){let t=r();$e(n.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let d=e.source?`${e.source}:${e.name}`:e.name,f=l.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
4
|
-
|
|
5
|
-
`);i(e.name,d,f,Ye()?.agentId??null);let p=lt(e,t),m=Ce(e.allowedTools??[]),h=o.length>0||a.length>0?[...o,...a,...l]:l,g=await be(re(l.filter(e=>e.type===`text`).map(e=>e.text).join(` `),n,null,[],n.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[b({content:p,uuid:s}),b({content:h,isMeta:!0}),...g,c({type:`command_permissions`,allowedTools:m,model:e.model})],shouldQuery:!0,allowedTools:m,model:e.model,command:e}}var Q,$;e((()=>{t(),se(),fe(),Ve(),Ue(),ve(),Ee(),l(),a(),j(),k(),Je(),ee(),V(),Ie(),Le(),f(),Fe(),Ae(),Oe(),J(),He(),ae(),_e(),u(),h(),pe(),oe(),tt(),We(),s(),Qe(),m(),le(),we(),p(),Ge(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ut as processPromptSlashCommand,ot as processSlashCommand};
|