@readmagic/workmate 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/AddWorkspaceDirectory-Y5S_lMjD.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-DVbU-BaD.js +1 -0
- package/dist/chunks/App-B8q8PV77.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-DjqGAL4C.js +1 -0
- package/dist/chunks/CustomSelect-BvTftqEH.js +1 -0
- package/dist/chunks/DiffDialog-v5r8cBKW.js +6 -0
- package/dist/chunks/Doctor-DKpBnbuI.js +1 -0
- package/dist/chunks/Doctor-uvO6NM5m.js +3 -0
- package/dist/chunks/ExitFlow-Dh9QdaYK.js +2 -0
- package/dist/chunks/InvalidConfigDialog-C9boykQn.js +1 -0
- package/dist/chunks/{InvalidSettingsDialog-Dtmpzeps.js → InvalidSettingsDialog-UN5mleCK.js} +1 -1
- package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +1 -0
- package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +1 -0
- package/dist/chunks/MCPToolListView-De1W4jpj.js +1 -0
- package/dist/chunks/McpParsingWarnings-zkM_lGd0.js +1 -0
- package/dist/chunks/MessageSelector-DW_itlX-.js +3 -0
- package/dist/chunks/Messages-BFsCpACq.js +10 -0
- package/dist/chunks/Onboarding-BT90cFkn.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-CCTZYbWI.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +1 -0
- package/dist/chunks/{ProviderSetup-XcBHjUnd.js → ProviderSetup-yIj8YOKF.js} +1 -1
- package/dist/chunks/QueryEngine-egz5mbaW.js +1 -0
- package/dist/chunks/REPL-D27CE4WN.js +124 -0
- package/dist/chunks/REPL-e8wAT1wN.js +1 -0
- package/dist/chunks/ResumeConversation-CWA27Lke.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +1 -0
- package/dist/chunks/{SelectMulti-Bc6l11_K.js → SelectMulti-BW7Ffk1G.js} +1 -1
- package/dist/chunks/Settings-axHLvYIy.js +3 -0
- package/dist/chunks/Spinner-VjwI7m_g.js +1 -0
- package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CqrOK3Mx.js} +1 -1
- package/dist/chunks/TextInput-Cev5Awdd.js +22 -0
- package/dist/chunks/ThemePicker-CtQYHmOr.js +1 -0
- package/dist/chunks/TrustDialog-8Sjmuu0e.js +1 -0
- package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-INwwoerV.js} +1 -1
- package/dist/chunks/_baseEach-DrPH_FGo.js +1 -0
- package/dist/chunks/add-dir-D3RMaYxy.js +1 -0
- package/dist/chunks/{agentDisplay-BReJUBWg.js → agentDisplay-B3npXoCS.js} +1 -1
- package/dist/chunks/{agents-B3x8yJ_r.js → agents-2mPGmeq6.js} +1 -1
- package/dist/chunks/agents-DEnmg8Xo.js +101 -0
- package/dist/chunks/allErrors-C9kx6lnk.js +1 -0
- package/dist/chunks/analytics-COpjZpvd.js +1 -0
- package/dist/chunks/{appleTerminalBackup-BArZWB21.js → appleTerminalBackup-CT7g8yOs.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-BkFxfjOf.js +1 -0
- package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +1 -0
- package/dist/chunks/banner-DHpTmEO7.js +2 -0
- package/dist/chunks/branch-Be_yDFU8.js +2 -0
- package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-UUt6Dkf2.js} +2 -2
- package/dist/chunks/btw-DUml5L1w.js +1 -0
- package/dist/chunks/caches-DWjwe-DN.js +1 -0
- package/dist/chunks/caches-VLs1tQkZ.js +1 -0
- package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-mBGFDbI6.js} +1 -1
- package/dist/chunks/{clear-Bdhb6b39.js → clear-CrGjNe6E.js} +1 -1
- package/dist/chunks/{client-CpTCeWba.js → client-BDuhbzLD.js} +1 -1
- package/dist/chunks/{client-4iqhC8xq.js → client-BYFVVMcf.js} +1 -1
- package/dist/chunks/client-CO_6v4yl.js +1 -0
- package/dist/chunks/client-DO-O441l.js +1 -0
- package/dist/chunks/commands-Cn1P7Tms.js +1 -0
- package/dist/chunks/compact-DGUhdXcc.js +2 -0
- package/dist/chunks/config-C7GTF4iI.js +1 -0
- package/dist/chunks/config-CWPHVTic.js +3 -0
- package/dist/chunks/config-Cox0TM2Z.js +1 -0
- package/dist/chunks/context-mV5zjqmc.js +1 -0
- package/dist/chunks/context-noninteractive--OuiZUzL.js +1 -0
- package/dist/chunks/{context-noninteractive-Dd4xIoP1.js → context-noninteractive-DvfVvmSE.js} +2 -2
- package/dist/chunks/conversation--y8PD2Lk.js +1 -0
- package/dist/chunks/conversation-BIPJEOwO.js +1 -0
- package/dist/chunks/conversationRecovery-BBJzrA0g.js +1 -0
- package/dist/chunks/crossProjectResume-CwZb3cEU.js +40 -0
- package/dist/chunks/cwd-BZMp3CZ8.js +1 -0
- package/dist/chunks/cwd-BvNt_018.js +1 -0
- package/dist/chunks/debug-CRnGsZOV.js +39 -0
- package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-CsJLbVEe.js} +1 -1
- package/dist/chunks/{diff-BOAElpfQ.js → diff-DUEoNCnJ.js} +1 -1
- package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-Bgi8DBT5.js} +1 -1
- package/dist/chunks/doctor-4NiE46ZG.js +1 -0
- package/dist/chunks/entry-D1iD76SW.js +13 -0
- package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
- package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
- package/dist/chunks/{execFileNoThrow-BTachNBI.js → execFileNoThrow-BgRsj_SW.js} +3 -3
- package/dist/chunks/exit-CrsQsjbx.js +1 -0
- package/dist/chunks/extraUsage-BtHE-SBX.js +1 -0
- package/dist/chunks/extractMemories-kogJzpit.js +1 -0
- package/dist/chunks/fast-CuNVwVTr.js +1 -0
- package/dist/chunks/fast-RlFnwGRV.js +1 -0
- package/dist/chunks/fetchModelList-Cjow_QGy.js +1 -0
- package/dist/chunks/fetchModelList-uiCPVqbJ.js +1 -0
- package/dist/chunks/fileSuggestions-C96V9-Ne.js +3 -0
- package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
- package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
- package/dist/chunks/{gemini-D_ORb_L6.js → gemini-4YGElN3H.js} +2 -2
- package/dist/chunks/generateSessionName-BHIKyXpz.js +1 -0
- package/dist/chunks/{genericProcessUtils-DwQFuna9.js → genericProcessUtils-BNlr-QxM.js} +1 -1
- package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
- package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
- package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
- package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
- package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
- package/dist/chunks/goal-ePK_jLo3.js +3 -0
- package/dist/chunks/grok-DnmklTrm.js +1 -0
- package/dist/chunks/help-B7xRle-V.js +1 -0
- package/dist/chunks/history-kOw3CcLT.js +1 -0
- package/dist/chunks/hooks-BDY1jMbS.js +1 -0
- package/dist/chunks/{hooks-DIvN6gdv.js → hooks-BN5f58HY.js} +2 -2
- package/dist/chunks/install-DrMiHa2Q.js +1 -0
- package/dist/chunks/instrumentation-Oj5xagJG.js +21 -0
- package/dist/chunks/{job-R6c4-3c8.js → job-D9ypO0cd.js} +1 -1
- package/dist/chunks/keybindings-BRRN_eap.js +1 -0
- package/dist/chunks/launchLocalMemory-DliLezJw.js +3 -0
- package/dist/chunks/launchOnboarding-A-kk-7ID.js +8 -0
- package/dist/chunks/loadAgentsDir-CJAK4kif.js +1 -0
- package/dist/chunks/{loadAgentsDir-DlPbtIsS.js → loadAgentsDir-DGozQu_6.js} +550 -550
- package/dist/chunks/{loadPluginHooks-C_msxVIc.js → loadPluginHooks-BiHPKDaY.js} +1 -1
- package/dist/chunks/{loader-CICGtLp2.js → loader-CtoR-vO-.js} +1 -1
- package/dist/chunks/{localSearch-CK-sFzPm.js → localSearch-BU02Qsv9.js} +1 -1
- package/dist/chunks/localSearch-DyaB2Rm-.js +1 -0
- package/dist/chunks/{log-D2TIwHBV.js → log-DoSpAwRP.js} +1 -1
- package/dist/chunks/logoUtils-DLd6JKqW.js +1 -0
- package/dist/chunks/{magicDocs-BEF8D3if.js → magicDocs-Bj8LYrN2.js} +2 -2
- package/dist/chunks/main-B_09WbaG.js +345 -0
- package/dist/chunks/managedEnv-BJGfe3m7.js +1 -0
- package/dist/chunks/{managedEnv-OPlzUPbJ.js → managedEnv-CIWJsuty.js} +1 -1
- package/dist/chunks/mcp-1nBvcNxw.js +1 -0
- package/dist/chunks/mcp-7DXpXMdT.js +2 -0
- package/dist/chunks/mcp-kw99WVi2.js +6 -0
- package/dist/chunks/memory-CjWvzR_9.js +1 -0
- package/dist/chunks/mode-CBKawxnD.js +2 -0
- package/dist/chunks/model-DpZaKZMb.js +1 -0
- package/dist/chunks/model-DwbqvCY2.js +1 -0
- package/dist/chunks/modelOptions-CXBfKFXA.js +1 -0
- package/dist/chunks/nativeInstaller-SmPeEisk.js +1 -0
- package/dist/chunks/{notifications-4wP1Tx9Y.js → notifications-ql0eSo0Y.js} +1 -1
- package/dist/chunks/onChangeAppState-D85b33R5.js +1 -0
- package/dist/chunks/open-Cyrr4E5x.js +1 -0
- package/dist/chunks/openai-D_j7-KW6.js +2 -0
- package/dist/chunks/overlayContext-CLjlCFBl.js +1 -0
- package/dist/chunks/{panel-CVS4SK_E.js → panel-DMZkOEiU.js} +1 -1
- package/dist/chunks/parser-2usBI4G-.js +1 -0
- package/dist/chunks/{parser-Cg6hSCmn.js → parser-UqADrvxF.js} +1 -1
- package/dist/chunks/partition-CwxTlmMd.js +1 -0
- package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-ovtxMVR5.js} +1 -1
- package/dist/chunks/permissions-CgsvWOk_.js +3 -0
- package/dist/chunks/pidLock-B-SW3Nhx.js +3 -0
- package/dist/chunks/plan-BJrWtXEh.js +1 -0
- package/dist/chunks/platform-DsMIk3eq.js +2 -0
- package/dist/chunks/plugin-D97VJAxW.js +17 -0
- package/dist/chunks/{pluginAutoupdate-8qugAFhb.js → pluginAutoupdate-DQqYDPVg.js} +1 -1
- package/dist/chunks/{pluginBlocklist-q01ackCf.js → pluginBlocklist-BAr9WTup.js} +1 -1
- package/dist/chunks/pluginCliCommands-CUGPc853.js +1 -0
- package/dist/chunks/{pluginFlagging-BG2MHCQJ.js → pluginFlagging-BO_3qjfs.js} +1 -1
- package/dist/chunks/pluginOperations-rTrzu6Vg.js +2 -0
- package/dist/chunks/pluginStartupCheck-BRHnXlym.js +1 -0
- package/dist/chunks/{pluginStartupCheck-DTMa6TgL.js → pluginStartupCheck-BX6cv-vs.js} +1 -1
- package/dist/chunks/plugins-9crasx2V.js +4 -0
- package/dist/chunks/poorMode-BaS0DBUO.js +1 -0
- package/dist/chunks/{poorMode-B0QGV6Ci.js → poorMode-DmvzFAz_.js} +1 -1
- package/dist/chunks/print-Bi3xVdB3.js +13 -0
- package/dist/chunks/processBashCommand-BBtnCx-7.js +1 -0
- package/dist/chunks/processSlashCommand-jzF0GmLO.js +5 -0
- package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState--L3BKjOE.js} +1 -1
- package/dist/chunks/prompt-CmijKW7G.js +1 -0
- package/dist/chunks/prompt-DYBx_D0H.js +1 -0
- package/dist/chunks/{prompt-mM79EGnT.js → prompt-DzO1um1h.js} +4 -4
- package/dist/chunks/{promptEditor-DLGN_eLu.js → promptEditor-B6S_Rzcu.js} +2 -2
- package/dist/chunks/protocolHandler-BWgH1jaF.js +13 -0
- package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BjkGlmBu.js} +1 -1
- package/dist/chunks/reconciler-CVMmAaCy.js +1 -0
- package/dist/chunks/refresh-CAGv8BJY.js +1 -0
- package/dist/chunks/reject-CEUkoI2G.js +1 -0
- package/dist/chunks/{reload-plugins-C42xSB5l.js → reload-plugins-DeyJTx4s.js} +1 -1
- package/dist/chunks/rename-DPFis9g_.js +1 -0
- package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DRS2EslG.js} +1 -1
- package/dist/chunks/resume-N4O5YI-S.js +2 -0
- package/dist/chunks/ripgrep-3omwGI-l.js +1 -0
- package/dist/chunks/ripgrep-CgQrN3XX.js +5 -0
- package/dist/chunks/{runtimeObserver-1wQO8HSZ.js → runtimeObserver-C0CJvA3q.js} +1 -1
- package/dist/chunks/{runtimeObserver-XQrOux41.js → runtimeObserver-DMSzdFWt.js} +4 -4
- package/dist/chunks/sandbox-adapter-D15jjHJR.js +1 -0
- package/dist/chunks/sandbox-toggle-Tbbaw18C.js +1 -0
- package/dist/chunks/searchExtraTools-BoFc__Eg.js +1 -0
- package/dist/chunks/select-Fq6g2Ejk.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +1 -0
- package/dist/chunks/{sessionObserver-DS4G6mb9.js → sessionObserver-CRie77tp.js} +2 -2
- package/dist/chunks/sessionObserver-PcaVCVkX.js +1 -0
- package/dist/chunks/sessionStorage-Dkf7FRgA.js +1 -0
- package/dist/chunks/sessionTracing-D7rekMdW.js +11 -0
- package/dist/chunks/settings-8fwIkMDV.js +1 -0
- package/dist/chunks/settings-CodSADx8.js +24 -0
- package/dist/chunks/setup-DBiIrXrh.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-BRxZjobz.js → shadowedRuleDetection-CTnYVrmP.js} +1 -1
- package/dist/chunks/{sideQuestion-DLJxyrlp.js → sideQuestion-Cl8m2qYx.js} +3 -3
- package/dist/chunks/sinks-CiupmfTg.js +1 -0
- package/dist/chunks/sinks-DH83d_kd.js +1 -0
- package/dist/chunks/skillChangeDetector-BrrZaFkT.js +1 -0
- package/dist/chunks/{skillGapStore-CKN_d3pO.js → skillGapStore-es3K-aYe.js} +2 -2
- package/dist/chunks/{skillLifecycle-BMY2JGGG.js → skillLifecycle-BcgoOQBk.js} +2 -2
- package/dist/chunks/{skillSearchPanel-D9trHULQ.js → skillSearchPanel-CuDDb1L-.js} +4 -4
- package/dist/chunks/skills-BRtgqnLz.js +1 -0
- package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
- package/dist/chunks/src-Db7K3F_i.js +3 -0
- package/dist/chunks/startupProfiler-D1NRu2nj.js +1 -0
- package/dist/chunks/startupProfiler-DF0AjiDf.js +3 -0
- package/dist/chunks/{state-B4jiUise.js → state-BQ4BEGin.js} +1 -1
- package/dist/chunks/state-D3gvDiu8.js +1 -0
- package/dist/chunks/status-WXA16wIM.js +1 -0
- package/dist/chunks/statusNoticeHelpers-BfmIub5L.js +1 -0
- package/dist/chunks/{stringUtils-C718f5ey.js → stringUtils-Bu_lJH5c.js} +1 -1
- package/dist/chunks/switcher-5gilU5_R.js +1 -0
- package/dist/chunks/{switcher-CAajZeNL.js → switcher-DMfuKuw_.js} +1 -1
- package/dist/chunks/{tasks-BWNQr2d3.js → tasks-B6gYXxOx.js} +1 -1
- package/dist/chunks/{templateJobs-gUET39Ho.js → templateJobs-BW6TaqEC.js} +1 -1
- package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-BgIXFBpd.js} +4 -4
- package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-C-g9Xvj3.js} +1 -1
- package/dist/chunks/{theme-B7fKI6E5.js → theme-9AZceq_m.js} +1 -1
- package/dist/chunks/tipRegistry-DtO1H_Wo.js +2 -0
- package/dist/chunks/{toolEventObserver-BL06sDI4.js → toolEventObserver-DTuJcREC.js} +1 -1
- package/dist/chunks/toolPool-DHS8jWaL.js +1 -0
- package/dist/chunks/{types-Dx7P7JLQ.js → types-97nL3naE.js} +16 -16
- package/dist/chunks/{udsClient-cQz6nJ_T.js → udsClient-CmYHFiBD.js} +1 -1
- package/dist/chunks/{use-select-navigation-BiUJdWai.js → use-select-navigation-BStVRvcX.js} +1 -1
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-DWRFdFoU.js +1 -0
- package/dist/chunks/useMainLoopModel-DSN5HjV1.js +1 -0
- package/dist/chunks/useManagePlugins-ntnOf5OU.js +1 -0
- package/dist/chunks/useMergedTools-C5Yns9Ij.js +1 -0
- package/dist/chunks/useSearchInput-B_mY9wBq.js +1 -0
- package/dist/chunks/useSettingsErrors-CM7tThcp.js +1 -0
- package/dist/chunks/util-Bb2S6g9N.js +1 -0
- package/dist/chunks/{validatePlugin-D6tFo87L.js → validatePlugin-D8WQ5z4W.js} +1 -1
- package/dist/chunks/vim-Dpnhgoz_.js +1 -0
- package/dist/chunks/worktree-a5oOPSYl.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -12
- package/dist/chunks/AddWorkspaceDirectory-OgcBcK5A.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CDNd5-7E.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CNEifEyV.js +0 -1
- package/dist/chunks/App-B-3tPQ3k.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-COuhHcey.js +0 -2
- package/dist/chunks/BypassPermissionsModeDialog-bJek4siJ.js +0 -1
- package/dist/chunks/CustomSelect-DoeEXOIP.js +0 -1
- package/dist/chunks/DiffDialog-B3X9FMpO.js +0 -6
- package/dist/chunks/Doctor-6PXyjIi6.js +0 -3
- package/dist/chunks/Doctor-DNgkgYhB.js +0 -1
- package/dist/chunks/ExitFlow-DgAZp_8U.js +0 -2
- package/dist/chunks/Grove-CHatOzcE.js +0 -11
- package/dist/chunks/InvalidConfigDialog-DXL92MN9.js +0 -1
- package/dist/chunks/KeybindingProviderSetup-DA37QUFs.js +0 -1
- package/dist/chunks/MCPConnectionManager-thZd-xA_.js +0 -1
- package/dist/chunks/MCPToolListView-CpY-YJg4.js +0 -1
- package/dist/chunks/McpParsingWarnings-JvChf3xr.js +0 -1
- package/dist/chunks/MessageSelector-C0_iw7SI.js +0 -3
- package/dist/chunks/Messages-K4DDsDP9.js +0 -10
- package/dist/chunks/Onboarding-C1UdzM-1.js +0 -1
- package/dist/chunks/PromptInputFooterSuggestions-AyLog8p7.js +0 -1
- package/dist/chunks/PromptInputHelpMenu-oyic20ip.js +0 -1
- package/dist/chunks/QueryEngine-DYxBjJ4i.js +0 -1
- package/dist/chunks/REPL-CQBJRrT0.js +0 -124
- package/dist/chunks/REPL-CrVuMQY2.js +0 -1
- package/dist/chunks/ResumeConversation-Dl8H9Gfy.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-lv7VE50N.js +0 -1
- package/dist/chunks/Settings-TGp3fPrS.js +0 -3
- package/dist/chunks/Spinner-zYPFVFHN.js +0 -1
- package/dist/chunks/TextInput-CD9iau2k.js +0 -22
- package/dist/chunks/ThemePicker-0F0hZYPX.js +0 -1
- package/dist/chunks/TrustDialog-C76YiMKz.js +0 -1
- package/dist/chunks/_baseEach-4ff-vRlp.js +0 -1
- package/dist/chunks/add-dir-JMsRLGfx.js +0 -1
- package/dist/chunks/agents-9qQ8I6zW.js +0 -101
- package/dist/chunks/allErrors-DfWylHSw.js +0 -1
- package/dist/chunks/analytics-DJobLaWP.js +0 -1
- package/dist/chunks/backgroundHousekeeping-BGxHB_OX.js +0 -1
- package/dist/chunks/backgroundHousekeeping-CVNIhQg8.js +0 -17
- package/dist/chunks/banner-Cu2-XUek.js +0 -2
- package/dist/chunks/branch-C4TsMEkx.js +0 -2
- package/dist/chunks/btw-Dn1eYFAz.js +0 -1
- package/dist/chunks/caches-BGzKwpnc.js +0 -1
- package/dist/chunks/caches-DArHxBgL.js +0 -1
- package/dist/chunks/client-BiqbIkwr.js +0 -1
- package/dist/chunks/client-CZ8nyVh5.js +0 -1
- package/dist/chunks/commands-QepeBbFn.js +0 -1
- package/dist/chunks/compact-Bu9BUpxV.js +0 -2
- package/dist/chunks/config-C-Y2qtB2.js +0 -3
- package/dist/chunks/config-D58C3_Lu.js +0 -1
- package/dist/chunks/config-DD8fCYXn.js +0 -1
- package/dist/chunks/context-CY_yfdYa.js +0 -1
- package/dist/chunks/context-noninteractive-BDDi3NLF.js +0 -1
- package/dist/chunks/conversation-B0wxBwzv.js +0 -1
- package/dist/chunks/conversation-DUu9qBnq.js +0 -1
- package/dist/chunks/conversationRecovery-2ft8sCPE.js +0 -1
- package/dist/chunks/crossProjectResume-6boHMUBx.js +0 -40
- package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
- package/dist/chunks/cwd-Pa83R95t.js +0 -1
- package/dist/chunks/datadog-BPuGcxxC.js +0 -1
- package/dist/chunks/debug-Bglx1aTu.js +0 -39
- package/dist/chunks/doctor-CkLzqAMd.js +0 -1
- package/dist/chunks/entry-TNOoyy7_.js +0 -13
- package/dist/chunks/esm-eTAUP-La.js +0 -1
- package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
- package/dist/chunks/exit-DXApFJIP.js +0 -1
- package/dist/chunks/extraUsage-CmQaLPV1.js +0 -1
- package/dist/chunks/extractMemories-xP63mv6R.js +0 -1
- package/dist/chunks/fast-C5nQH8rm.js +0 -1
- package/dist/chunks/fast-eGx2IxD7.js +0 -1
- package/dist/chunks/fetchModelList-CxLsVNsu.js +0 -1
- package/dist/chunks/fetchModelList-D24lRIgR.js +0 -1
- package/dist/chunks/fileSuggestions-DHxdwq28.js +0 -3
- package/dist/chunks/firstPartyEventLogger-BVAogAX8.js +0 -1
- package/dist/chunks/firstPartyEventLogger-M6UMli2c.js +0 -3
- package/dist/chunks/generateSessionName-BQoDduyA.js +0 -1
- package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
- package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
- package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
- package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
- package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
- package/dist/chunks/goal-D7c2mSds.js +0 -3
- package/dist/chunks/grok-B2-ZbUiR.js +0 -1
- package/dist/chunks/grove-O6qp7ITR.js +0 -1
- package/dist/chunks/help-CZJdRviD.js +0 -1
- package/dist/chunks/history-CQiUERTL.js +0 -1
- package/dist/chunks/hooks-BNuUlMzL.js +0 -1
- package/dist/chunks/install-T_CV1Slu.js +0 -1
- package/dist/chunks/instrumentation-BjqUZ383.js +0 -21
- package/dist/chunks/keybindings-CLRaiL_Z.js +0 -1
- package/dist/chunks/launchLocalMemory-DrbKrwXc.js +0 -3
- package/dist/chunks/launchOnboarding-tqsMD8ni.js +0 -8
- package/dist/chunks/loadAgentsDir-CcmY8zCj.js +0 -1
- package/dist/chunks/localSearch-DrUj0B-d.js +0 -1
- package/dist/chunks/logoUtils-x2pHV-Nl.js +0 -1
- package/dist/chunks/main-kOVUGxOS.js +0 -345
- package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
- package/dist/chunks/mcp-BNd29r6p.js +0 -6
- package/dist/chunks/mcp-D0wAJrRT.js +0 -1
- package/dist/chunks/mcp-mgOlm1cY.js +0 -2
- package/dist/chunks/memory-DDLk9_LJ.js +0 -1
- package/dist/chunks/mode-CcNsWgK3.js +0 -2
- package/dist/chunks/model-BwBG0V1u.js +0 -1
- package/dist/chunks/model-DzCP4K-9.js +0 -1
- package/dist/chunks/modelOptions-DRaG3bo0.js +0 -1
- package/dist/chunks/nativeInstaller-C3pVPqrZ.js +0 -1
- package/dist/chunks/onChangeAppState-BlaoFbYF.js +0 -1
- package/dist/chunks/open-BtQHzzL9.js +0 -1
- package/dist/chunks/openai-CDN71NdX.js +0 -2
- package/dist/chunks/overlayContext-BT2Lq8ei.js +0 -1
- package/dist/chunks/parser-CG5RuOCK.js +0 -1
- package/dist/chunks/partition-CIl_ORUT.js +0 -1
- package/dist/chunks/permissions-zSNOZSwr.js +0 -3
- package/dist/chunks/pidLock-BTqO-h7Y.js +0 -3
- package/dist/chunks/plan-Bs6em6lk.js +0 -1
- package/dist/chunks/platform-BacQ6ACS.js +0 -2
- package/dist/chunks/plugin-DDDxjBa0.js +0 -17
- package/dist/chunks/pluginCliCommands-DXZfCZsv.js +0 -1
- package/dist/chunks/pluginOperations-hXYLrzM2.js +0 -2
- package/dist/chunks/pluginStartupCheck-HS1ZceZa.js +0 -1
- package/dist/chunks/plugins-COoGBYk6.js +0 -4
- package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
- package/dist/chunks/print-BASybEtO.js +0 -13
- package/dist/chunks/processBashCommand-DDi_Pymt.js +0 -1
- package/dist/chunks/processSlashCommand-Cq9kaoSF.js +0 -5
- package/dist/chunks/prompt-CHobfCB1.js +0 -1
- package/dist/chunks/prompt-CMm6RHHc.js +0 -1
- package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
- package/dist/chunks/reconciler-CeXqh95g.js +0 -1
- package/dist/chunks/refresh-Ce2yk28a.js +0 -1
- package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
- package/dist/chunks/reject-Bld5E-bn.js +0 -1
- package/dist/chunks/rename-CtBghpxZ.js +0 -1
- package/dist/chunks/resume-BWkaTDqd.js +0 -2
- package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
- package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
- package/dist/chunks/sandbox-adapter-8GO6eJxw.js +0 -1
- package/dist/chunks/sandbox-toggle-Dir9Polo.js +0 -1
- package/dist/chunks/searchExtraTools-BhDq8DTJ.js +0 -1
- package/dist/chunks/select-Bxf5-5sI.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-CozocHQE.js +0 -1
- package/dist/chunks/sessionObserver-DGEQM4cO.js +0 -1
- package/dist/chunks/sessionStorage-BcAscOGE.js +0 -1
- package/dist/chunks/sessionTracing-BoDDYLxW.js +0 -11
- package/dist/chunks/settings-B2jvL8Dp.js +0 -24
- package/dist/chunks/settings-CisDe8DB.js +0 -1
- package/dist/chunks/setup-BRypY6iT.js +0 -3
- package/dist/chunks/sinks-CGdKmq_8.js +0 -1
- package/dist/chunks/sinks-Cz2HfgMU.js +0 -1
- package/dist/chunks/skillChangeDetector-xviGstqm.js +0 -1
- package/dist/chunks/skills-CX_AvwLG.js +0 -1
- package/dist/chunks/src-CHw1lvBc.js +0 -3
- package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
- package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
- package/dist/chunks/state-BhOKSFi5.js +0 -1
- package/dist/chunks/status-Daaak6Bo.js +0 -1
- package/dist/chunks/statusNoticeHelpers-vFVgIYuw.js +0 -1
- package/dist/chunks/switcher-BpgmH4AI.js +0 -1
- package/dist/chunks/tipRegistry-DamZr34w.js +0 -2
- package/dist/chunks/toolPool-CX5wDBi1.js +0 -1
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js +0 -1
- package/dist/chunks/useMainLoopModel-DwjSVzzO.js +0 -1
- package/dist/chunks/useManagePlugins-BqfIVa6E.js +0 -1
- package/dist/chunks/useMergedTools-Bw8FchX8.js +0 -1
- package/dist/chunks/useSearchInput-B25K1RnK.js +0 -1
- package/dist/chunks/useSettingsErrors-DYQ44kX4.js +0 -1
- package/dist/chunks/util-CtlC2dsN.js +0 -1
- package/dist/chunks/vim-CoRp9lY1.js +0 -1
- package/dist/chunks/worktree-B8apCnVe.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-DfkgIdYf.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{Bv as o,Co as s,Cx as c,Do as l,Eo as u,Fa as d,Gv as f,Ha as p,Hv as m,Ia as h,Ip as g,Ja as _,Jp as v,Kx as y,Lp as ee,Lv as b,Lx as x,Mo as S,Nv as C,Nx as w,Pv as T,Qa as te,Rv as E,So as ne,To as D,Uv as O,Ux as re,Va as k,Vv as A,Wv as ie,Wx as ae,Yp as oe,Za as se,_o as j,bb as ce,bx as le,eo as ue,gv as de,ho as fe,jo as pe,ko as me,lo as M,mb as N,md as P,oo as he,pd as F,po as ge,pv as _e,qx as ve,ro as ye,uo as be,vo as I,vu as xe,wo as Se,wx as Ce,xo as we,yu as Te,zp as Ee,zv as De,zx as Oe}from"./loadAgentsDir-DlPbtIsS.js";import{D as ke,Gr as Ae,Gt as L,H as je,I as R,P as z,T as B,Wt as Me,Xn as Ne,ai as V,hn as Pe,j as Fe,k as Ie,n as Le,ot as Re,r as ze,t as Be,x as Ve,y as He}from"./src-DL3w8VPk.js";import{t as Ue}from"./jsx-runtime-Bb4Xn-E0.js";import{I as We,M as Ge,S as Ke,V as qe,c as Je,i as Ye,x as Xe}from"./debug-Bglx1aTu.js";import{Hn as Ze,Vn as Qe,_t as $e,b as et,bt as tt,d as nt,h as rt,s as it}from"./settings-B2jvL8Dp.js";import{p as at,v as ot}from"./config-C-Y2qtB2.js";import{o as st,s as ct}from"./log-D2TIwHBV.js";import{l as H,o as lt}from"./stringUtils-C718f5ey.js";import{n as ut,r as dt}from"./analytics-DJobLaWP.js";import{S as ft,v as pt}from"./startupProfiler-CJdr3SxP.js";import{n as mt,t as ht}from"./TextInput-CD9iau2k.js";import{n as gt,t as _t}from"./pluginStartupCheck-DTMa6TgL.js";import{a as vt,d as yt,f as bt,i as xt,l as St,o as Ct,s as wt,u as Tt}from"./pluginOperations-hXYLrzM2.js";import{a as Et,c as Dt,i as Ot,n as kt,o as At,s as jt,t as Mt}from"./validatePlugin-D6tFo87L.js";import{a as Nt,n as Pt,o as Ft,r as It}from"./pluginFlagging-BG2MHCQJ.js";import{i as Lt,n as Rt}from"./MCPConnectionManager-thZd-xA_.js";import{n as zt,t as Bt}from"./useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js";import{r as Vt,t as Ht}from"./Spinner-zYPFVFHN.js";import{t as Ut}from"./SearchBox-C9xxQzh1.js";import{n as Wt,t as Gt}from"./useSearchInput-B25K1RnK.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-CpY-YJg4.js";import{i as en,n as tn}from"./pluginAutoupdate-8qugAFhb.js";import*as nn from"path";import*as rn from"fs/promises";function an({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:o,setResult:s,setViewState:c,onAddComplete:l,cliMode:u=!1}){let d=(0,on.useRef)(!1),[f,p]=(0,on.useState)(!1),[m,h]=(0,on.useState)(``),g=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Et(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{p(!0),h(``);let{name:e,resolvedSource:t}=await ye(n,e=>{h(e)});j(e,{source:t}),pe();let r=n.source;n.source===`github`&&(r=n.repo),dt(`tengu_marketplace_added`,{source_type:r}),l&&await l(),h(``),p(!1),u?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=qe(e);ct(t),a(t.message),h(``),p(!1),s(u?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!d.current&&!i&&!o&&(d.current=!0,g())},[]),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsxs)(R,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(R,{marginBottom:1,children:(0,U.jsx)(z,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsx)(z,{children:`Enter marketplace source:`}),(0,U.jsx)(z,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(z,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(z,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(z,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(z,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(ht,{value:e,onChange:t,onSubmit:g,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),f&&(0,U.jsxs)(R,{marginTop:1,children:[(0,U.jsx)(Ht,{}),(0,U.jsx)(z,{children:m||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{color:`error`,children:i})}),o&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{children:o})})]}),(0,U.jsx)(R,{marginLeft:3,children:(0,U.jsx)(z,{dimColor:!0,italic:!0,children:(0,U.jsxs)(B,{children:[(0,U.jsx)(ke,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(F,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{on=t(V(),1),ut(),P(),Be(),Vt(),mt(),We(),st(),S(),M(),Ot(),U=Ue()}));function cn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Me(`confirm:no`,o,{context:`Settings`}),L({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Pe((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let _=g.sensitive===!0,v=g.required===!0,y=_?`*`.repeat(Ae(p)):p;return(0,dn.jsxs)(He,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{bold:!0,children:[g.title||h,v&&(0,dn.jsx)(z,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(z,{dimColor:!0,children:g.description}),(0,dn.jsxs)(R,{marginTop:1,children:[(0,dn.jsxs)(z,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(z,{children:y}),(0,dn.jsx)(z,{children:`█`})]})]}),(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(V(),1),Be(),N(),r(),dn=Ue()}));async function pn(e){let{enabled:t,disabled:n}=await h();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=b(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=>o(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:()=>O(t,r.server)??void 0,save:e=>f(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),s=hn.useRef(n);if(s.current=n,hn.useEffect(()=>{r.length===0&&s.current(`skipped`)},[r.length]),r.length===0)return null;let c=r[i];function l(e){try{c.save(e)}catch(e){n(`error`,Ge(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,gn.jsx)(ln,{title:c.title,subtitle:c.subtitle,configSchema:c.schema,initialValues:c.load(),onSave:l,onCancel:()=>n(`skipped`)},c.key)}var hn,gn,_n=e((()=>{hn=t(V(),1),We(),A(),T(),d(),E(),fn(),gn=Ue()}));function vn(){let e=u();return(0,yn.jsxs)(R,{marginBottom:1,children:[(0,yn.jsxs)(z,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(z,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var yn,bn=e((()=>{i(),Be(),l(),yn=Ue()}));function xn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function Sn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Cn({hasSelection:e}){return(0,wn.jsx)(R,{marginTop:1,children:(0,wn.jsx)(z,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(B,{children:[e&&(0,wn.jsx)(F,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(F,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{P(),Be(),wn=Ue()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var Dn,On,kn=e((()=>{Dn=t(V(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:c,targetPlugin:l}){let[u,d]=(0,W.useState)(`marketplace-list`),[f,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)([]),[y,ee]=(0,W.useState)([]),[b,x]=(0,W.useState)(!0),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(0),[E,ne]=(0,W.useState)(new Set),[O,re]=(0,W.useState)(new Set),k=En({totalItems:y.length,selectedIndex:w}),[A,ie]=(0,W.useState)(0),[ae,j]=(0,W.useState)(!1),[ce,le]=(0,W.useState)(null),[ue,de]=(0,W.useState)(null);Me(`confirm:no`,jn.useCallback(()=>{u===`plugin-list`?c?i({type:`manage-marketplaces`,targetMarketplace:c}):_.length===1?i({type:`menu`}):(d(`marketplace-list`),m(null),ne(new Set)):u===`plugin-details`?(d(`plugin-list`),g(null)):i({type:`menu`})},[u,c,i,_.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await be(),{marketplaces:n,failures:r}=await me(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=Qe(r.plugins,t=>te(we(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:D(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),v(i);let a=Se(r,Qe(n,e=>e.data!==null));if(a)if(a.type===`warning`)de(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!c&&!l){let e=i[0];e&&(m(e.name),d(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await he(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=we(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:se(e)},r=t;break}}}if(n&&r){let e=n.pluginId;se(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(m(r),g(n),d(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else c&&(i.some(e=>e.name===c)?(m(c),d(`plugin-list`)):t(`Marketplace "${c}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{x(!1)}}e()},[t,c,l]),(0,W.useEffect)(()=>{if(!f)return;let e=!1;async function n(n){x(!0);try{let t=await he(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=we(e.name,n);oe(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:se(t)})}try{let t=await jt();if(e)return;C(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;Je(`Failed to fetch install counts: ${Ge(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}ee(r),T(0),ne(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{x(!1)}}return n(f),()=>{e=!0}},[f,t]);let fe=async()=>{if(E.size===0)return;let e=y.filter(e=>E.has(e.pluginId));re(new Set(e.map(e=>e.pluginId)));let n=0,a=0,c=[];for(let t of e){let e=await p({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,c.push({name:t.entry.name,reason:e.error}))}re(new Set),ne(new Set),pe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${s(c,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${s(c,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},M=async(e,t=`user`)=>{j(!0),le(null);let n=await p({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){j(!1),d({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else j(!1),le(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),L({"select:previous":()=>{w>0&&T(w-1)},"select:next":()=>{w<_.length-1&&T(w+1)},"select:accept":()=>{let e=_[w];e&&(m(e.name),d(`plugin-list`))}},{context:`Select`,isActive:u===`marketplace-list`}),L({"select:previous":()=>{w>0&&k.handleSelectionChange(w-1,T)},"select:next":()=>{w<y.length-1&&k.handleSelectionChange(w+1,T)},"select:accept":()=>{if(w===y.length&&E.size>0)fe();else if(w<y.length){let e=y[w];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(g(e),d(`plugin-details`),ie(0),le(null)))}}},{context:`Select`,isActive:u===`plugin-list`}),L({"plugin:toggle":()=>{if(w<y.length){let e=y[w];if(e&&!e.isInstalled){let t=new Set(E);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ne(t)}}},"plugin:install":()=>{E.size>0&&fe()}},{context:`Plugin`,isActive:u===`plugin-list`});let N=jn.useMemo(()=>{if(!h)return[];let e=h.entry.homepage;return Sn(e,xn(h))},[h]);if(L({"select:previous":()=>{A>0&&ie(A-1)},"select:next":()=>{A<N.length-1&&ie(A+1)},"select:accept":()=>{if(!h)return;let e=N[A]?.action,t=h.entry.homepage,n=xn(h);e===`install-user`?M(h,`user`):e===`install-project`?M(h,`project`):e===`install-local`?M(h,`local`):e===`homepage`&&t?Te(t):e===`github`&&n?Te(`https://github.com/${n}`):e===`back`&&(d(`plugin-list`),g(null))}},{context:`Select`,isActive:u===`plugin-details`&&!!h}),typeof u==`object`&&u.type===`plugin-options`){let{plugin:e,pluginId:t}=u;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(b)return(0,G.jsx)(z,{children:`Loading…`});if(e)return(0,G.jsx)(z,{color:`error`,children:e});if(u===`marketplace-list`)return _.length===0?(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(z,{children:`No marketplaces configured.`}),(0,G.jsxs)(z,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),ue&&(0,G.jsx)(R,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(z,{color:`warning`,children:[a.warning,` `,ue]})}),_.map((e,t)=>(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:+(t<_.length-1),children:[(0,G.jsx)(R,{children:(0,G.jsxs)(z,{color:w===t?`suggestion`:void 0,children:[w===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(R,{marginLeft:2,children:(0,G.jsxs)(z,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(u===`plugin-details`&&h){let e=h.entry.homepage,t=Sn(e,xn(h));return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:h.entry.name}),h.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[`Version: `,h.entry.version]}),h.entry.description&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{children:h.entry.description})}),h.entry.author&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof h.entry.author==`string`?h.entry.author:h.entry.author.name]})})]}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:`Will install:`}),h.entry.commands&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(h.entry.commands)?h.entry.commands.join(`, `):Object.keys(h.entry.commands).join(`, `)]}),h.entry.agents&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(h.entry.agents)?h.entry.agents.join(`, `):Object.keys(h.entry.agents).join(`, `)]}),h.entry.hooks&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Hooks: `,Object.keys(h.entry.hooks).join(`, `)]}),h.entry.mcpServers&&(0,G.jsxs)(z,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(h.entry.mcpServers)?h.entry.mcpServers.join(`, `):typeof h.entry.mcpServers==`object`?Object.keys(h.entry.mcpServers).join(`, `):`configured`]}),!h.entry.commands&&!h.entry.agents&&!h.entry.hooks&&!h.entry.mcpServers&&(typeof h.entry.source==`object`&&`source`in h.entry.source&&(h.entry.source.source===`github`||h.entry.source.source===`url`||h.entry.source.source===`npm`||h.entry.source.source===`pip`)?(0,G.jsx)(z,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(z,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(vn,{}),ce&&(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsxs)(z,{color:`error`,children:[`Error: `,ce]})}),(0,G.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(R,{children:[A===t&&(0,G.jsx)(z,{children:`> `}),A!==t&&(0,G.jsx)(z,{children:` `}),(0,G.jsx)(z,{bold:A===t,children:ae&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(y.length===0)return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(z,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(z,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(R,{marginLeft:3,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let P=k.getVisibleItems(y);return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install Plugins`})}),k.scrollPosition.canScrollUp&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),P.map((t,n)=>{let r=k.toActualIndex(n),i=w===r,o=E.has(t.pluginId),s=O.has(t.pluginId);return(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:n===P.length-1&&!e?0:1,children:[(0,G.jsxs)(R,{children:[(0,G.jsxs)(z,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(z,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(z,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(z,{dimColor:!0,children:` (installed)`}),S&&f===`claude-plugins-official`&&(0,G.jsxs)(z,{dimColor:!0,children:[` · `,At(S.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(R,{marginLeft:4,children:[(0,G.jsx)(z,{dimColor:!0,children:ft(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),k.scrollPosition.canScrollDown&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:E.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(V(),1),W=t(V(),1),P(),Be(),N(),Ze(),xe(),Ye(),We(),S(),Dt(),_(),l(),M(),w(),k(),v(),lt(),pt(),_n(),bn(),Tn(),kn(),G=Ue()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:c,targetPlugin:l}){let[u,d]=(0,K.useState)(`plugin-list`),[f,m]=(0,K.useState)(null),[h,g]=(0,K.useState)([]),[_,v]=(0,K.useState)(!0),[y,ee]=(0,K.useState)(null),[b,x]=(0,K.useState)(!1),S=(0,K.useCallback)(e=>{x(e),c?.(e)},[c]),{query:C,setQuery:w,cursorOffset:T}=Wt({isActive:u===`plugin-list`&&b&&!_,onExit:()=>{S(!1)}}),te=Ne(),{columns:E}=Re(),D=(0,K.useMemo)(()=>{if(!C)return h;let e=C.toLowerCase();return h.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[h,C]),[O,re]=(0,K.useState)(0),[k,A]=(0,K.useState)(new Set),[ie,ae]=(0,K.useState)(new Set),j=En({totalItems:D.length,selectedIndex:O});(0,K.useEffect)(()=>{re(0)},[C]);let[ce,le]=(0,K.useState)(0),[ue,de]=(0,K.useState)(!1),[fe,M]=(0,K.useState)(null),[N,P]=(0,K.useState)(null),[he,ge]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await be(),{marketplaces:n,failures:r}=await me(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=we(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:se(t)})}let a=i.filter(e=>!e.isInstalled&&!oe(e.pluginId));try{let e=await jt();ee(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){Je(`Failed to fetch install counts: ${Ge(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}g(a);let o=Object.keys(e).length;if(a.length===0){let e=await ne({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ge(e)}let s=Se(r,Qe(n,e=>e.data!==null));if(s)if(s.type===`warning`)P(`${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.`):(m(e),d(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{v(!1)}}e()},[t,l]);let _e=async()=>{if(k.size===0)return;let e=h.filter(e=>k.has(e.pluginId));ae(new Set(e.map(e=>e.pluginId)));let n=0,a=0,c=[];for(let t of e){let e=await p({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,c.push({name:t.entry.name,reason:e.error}))}ae(new Set),A(new Set),pe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${s(c,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${s(c,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},ve=async(e,t=`user`)=>{de(!0),M(null);let n=await p({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){de(!1),d({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else de(!1),M(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Me(`confirm:no`,()=>{d(`plugin-list`),m(null)},{context:`Confirmation`,isActive:u===`plugin-details`}),Me(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:u===`plugin-list`&&!b}),Pe((e,t)=>{let n=!t.ctrl&&!t.meta;b||(e===`/`&&n?(S(!0),w(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(S(!0),w(e)))},{isActive:u===`plugin-list`&&!_}),L({"select:previous":()=>{O===0?S(!0):j.handleSelectionChange(O-1,re)},"select:next":()=>{O<D.length-1&&j.handleSelectionChange(O+1,re)},"select:accept":()=>{if(O===D.length&&k.size>0)_e();else if(O<D.length){let e=D[O];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(m(e),d(`plugin-details`),le(0),M(null)))}}},{context:`Select`,isActive:u===`plugin-list`&&!b}),L({"plugin:toggle":()=>{if(O<D.length){let e=D[O];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&&_e()}},{context:`Plugin`,isActive:u===`plugin-list`&&!b});let ye=In.useMemo(()=>{if(!f)return[];let e=f.entry.homepage;return Sn(e,xn(f))},[f]);if(L({"select:previous":()=>{ce>0&&le(ce-1)},"select:next":()=>{ce<ye.length-1&&le(ce+1)},"select:accept":()=>{if(!f)return;let e=ye[ce]?.action,t=f.entry.homepage,n=xn(f);e===`install-user`?ve(f,`user`):e===`install-project`?ve(f,`project`):e===`install-local`?ve(f,`local`):e===`homepage`&&t?Te(t):e===`github`&&n?Te(`https://github.com/${n}`):e===`back`&&(d(`plugin-list`),m(null))}},{context:`Select`,isActive:u===`plugin-details`&&!!f}),typeof u==`object`&&u.type===`plugin-options`){let{plugin:e,pluginId:t}=u;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(mn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(_)return(0,q.jsx)(z,{children:`Loading…`});if(e)return(0,q.jsx)(z,{color:`error`,children:e});if(u===`plugin-details`&&f){let e=f.entry.homepage,t=Sn(e,xn(f));return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(z,{bold:!0,children:f.entry.name}),(0,q.jsxs)(z,{dimColor:!0,children:[`from `,f.marketplaceName]}),f.entry.version&&(0,q.jsxs)(z,{dimColor:!0,children:[`Version: `,f.entry.version]}),f.entry.description&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{children:f.entry.description})}),f.entry.author&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof f.entry.author==`string`?f.entry.author:f.entry.author.name]})})]}),(0,q.jsx)(vn,{}),fe&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`error`,children:[`Error: `,fe]})}),(0,q.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(R,{children:[ce===t&&(0,q.jsx)(z,{children:`> `}),ce!==t&&(0,q.jsx)(z,{children:` `}),(0,q.jsx)(z,{bold:ce===t,children:ue&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,children:(0,q.jsxs)(B,{children:[(0,q.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(h.length===0)return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:he}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let I=j.getVisibleItems(D);return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{bold:!0,children:`Discover plugins`}),j.needsPagination&&(0,q.jsxs)(z,{dimColor:!0,children:[` `,`(`,j.scrollPosition.current,`/`,j.scrollPosition.total,`)`]})]}),(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(Ie,{query:C,isFocused:b,isTerminalFocused:te,width:E-4,cursorOffset:T})}),N&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`warning`,children:[a.warning,` `,N]})}),D.length===0&&C&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`No plugins match "`,C,`"`]})}),j.scrollPosition.canScrollUp&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),I.map((t,n)=>{let r=j.toActualIndex(n),i=O===r,o=k.has(t.pluginId),s=ie.has(t.pluginId);return(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:n===I.length-1&&!e?0:1,children:[(0,q.jsxs)(R,{children:[(0,q.jsxs)(z,{color:i&&!b?`suggestion`:void 0,children:[i&&!b?a.pointer:` `,` `]}),(0,q.jsxs)(z,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(z,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),y&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(z,{dimColor:!0,children:[` · `,At(y.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(R,{marginLeft:4,children:(0,q.jsx)(z,{dimColor:!0,children:ft(t.entry.description,60)})})]},`${j.startIndex}-${t.pluginId}`)}),j.scrollPosition.canScrollDown&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:k.size>0,canToggle:O<D.length&&!D[O]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:(0,q.jsxs)(B,{children:[e&&(0,q.jsx)(F,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(z,{children:`type to search`}),t&&(0,q.jsx)(F,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(z,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(z,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(z,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(z,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(V(),1),K=t(V(),1),P(),Ut(),Be(),Gt(),ce(),N(),Ze(),xe(),Ye(),We(),S(),Dt(),_(),l(),M(),w(),k(),v(),lt(),pt(),_n(),bn(),Tn(),kn(),q=Ue()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:c}){let[l,u]=(0,Bn.useState)([]),[d,f]=(0,Bn.useState)(!0),[p,m]=(0,Bn.useState)(0),[g,_]=(0,Bn.useState)(!1),[v,y]=(0,Bn.useState)(null),[ee,b]=(0,Bn.useState)(null),[x,S]=(0,Bn.useState)(null),[C,w]=(0,Bn.useState)(`list`),[T,te]=(0,Bn.useState)(null),[E,ne]=(0,Bn.useState)(0),O=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await be(),{enabled:r,disabled:i}=await h(),a=[...r,...i],{marketplaces:o,failures:l}=await me(e),d=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));d.push({name:e,source:D(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:tt(e,t)})}d.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),u(d);let f=Se(l,Qe(o,e=>e.data!==null));if(f)if(f.type===`warning`)y(f.message);else throw Error(f.message);if(s&&!O.current&&!t){O.current=!0;let e=d.findIndex(e=>e.name===s);if(e>=0){let t=d[e];if(c){m(e+1);let t=[...d];c===`update`?t[e].pendingUpdate=!0:c===`remove`&&(t[e].pendingRemove=!0),u(t),setTimeout(A,100,t)}else t&&(m(e+1),te(t),w(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),y(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{f(!1)}}e()},[s,c,t]);let re=()=>l.some(e=>e.pendingUpdate||e.pendingRemove),k=()=>({updateCount:Qe(l,e=>e.pendingUpdate),removeCount:Qe(l,e=>e.pendingRemove)}),A=async t=>{let i=t||l,s=C===`details`;_(!0),y(null),b(null),S(null);try{let t=it(`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=we(t.name,e.name);n[r]=!1}et(`userSettings`,{enabledPlugins:n})}await fe(e.name),c++,dt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await ge(e.name,e=>{S(e)}),n++,l.add(e.name.toLowerCase()),dt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let d=0;l.size>0&&(d=(await en(l)).length),pe(),o&&await o();let f=await be(),{enabled:p,disabled:m}=await h(),g=[...p,...m],{marketplaces:_}=await me(f),v=[];for(let{name:e,config:t,data:n}of _){let r=g.filter(t=>t.source.endsWith(`@${e}`));v.push({name:e,source:D(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:tt(e,t)})}if(v.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),u(v),s&&T){let e=v.find(e=>e.name===T.name);e&&te(e)}let y=[];if(n>0){let e=d>0?` (${d} ${H(d,`plugin`)} bumped)`:``;y.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&y.push(`Removed ${c} ${H(c,`marketplace`)}`),y.length>0){let t=`${a.tick} ${y.join(`, `)}`;s?b(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Ge(e);y(t),n&&n(t)}finally{_(!1),S(null)}},ie=async()=>{if(!T)return;let e=l.map(e=>e.name===T.name?{...e,pendingRemove:!0}:e);u(e),await A(e)},ae=e=>{if(!e)return[];let t=[{label:`Browse plugins (${e.pluginCount??0})`,value:`browse`},{label:`Update marketplace`,secondaryLabel:e.lastUpdated?`(last updated ${new Date(e.lastUpdated).toLocaleDateString()})`:void 0,value:`update`}];return ot()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},oe=async e=>{let t=!e.autoUpdate;try{await I(e.name,t),u(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),te(e=>e&&{...e,autoUpdate:t})}catch(e){y(e instanceof Error?e.message:`Failed to update setting`)}};if(Me(`confirm:no`,()=>{w(`list`),ne(0)},{context:`Confirmation`,isActive:!g&&(C===`details`||C===`confirm-remove`)}),Me(`confirm:no`,()=>{u(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),m(0)},{context:`Confirmation`,isActive:!g&&C===`list`&&re()}),Me(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!g&&C===`list`&&!re()}),L({"select:previous":()=>m(e=>Math.max(0,e-1)),"select:next":()=>{let e=l.length+1;m(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=p-1;if(p===0)e({type:`add-marketplace`});else if(re())A();else{let e=l[t];e&&(te(e),w(`details`),ne(0))}}},{context:`Select`,isActive:!g&&C===`list`}),Pe(e=>{let t=p-1;if((e===`u`||e===`U`)&&t>=0)u(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=l[t];e&&(te(e),w(`confirm-remove`))}},{isActive:!g&&C===`list`}),L({"select:previous":()=>ne(e=>Math.max(0,e-1)),"select:next":()=>{let e=ae(T);ne(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!T)return;let t=ae(T)[E];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:T.name});else if(t?.value===`update`){let e=l.map(e=>e.name===T.name?{...e,pendingUpdate:!0}:e);u(e),A(e)}else t?.value===`toggle-auto-update`?oe(T):t?.value===`remove`&&w(`confirm-remove`)}},{context:`Select`,isActive:!g&&C===`details`}),Pe(e=>{e===`y`||e===`Y`?ie():(e===`n`||e===`N`)&&(w(`list`),te(null))},{isActive:!g&&C===`confirm-remove`}),d)return(0,J.jsx)(z,{children:`Loading marketplaces…`});if(l.length===0)return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(z,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(B,{children:[(0,J.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(C===`confirm-remove`&&T){let e=T.installedPlugins?.length||0;return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsxs)(z,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(z,{italic:!0,children:T.name}),`?`]}),(0,J.jsxs)(R,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),T.installedPlugins&&T.installedPlugins.length>0&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,marginLeft:2,children:T.installedPlugins.map(e=>(0,J.jsxs)(z,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[`Press `,(0,J.jsx)(z,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(z,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(C===`details`&&T){let e=T.pendingUpdate||g,t=ae(T);return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{bold:!0,children:T.name}),(0,J.jsx)(z,{dimColor:!0,children:T.source}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[T.pluginCount||0,` available `,H(T.pluginCount||0,`plugin`)]})}),T.installedPlugins&&T.installedPlugins.length>0&&(0,J.jsxs)(R,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(z,{bold:!0,children:[`Installed plugins (`,T.installedPlugins.length,`):`]}),(0,J.jsx)(R,{flexDirection:`column`,marginLeft:1,children:T.installedPlugins.map(e=>(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(z,{children:a.bullet}),(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{children:e.name}),(0,J.jsx)(z,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(z,{color:`claude`,children:`Updating marketplace…`}),x&&(0,J.jsx)(z,{dimColor:!0,children:x})]}),!e&&ee&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:ee})}),!e&&v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),!e&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===E;return(0,J.jsxs)(R,{children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(z,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!ot()&&T.autoUpdate&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(B,{children:[(0,J.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:se,removeCount:j}=k();return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:p===0?`suggestion`:void 0,children:[p===0?a.pointer:` `,` +`]}),(0,J.jsx)(z,{bold:!0,color:p===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(R,{flexDirection:`column`,children:l.map((e,t)=>{let n=t+1===p,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(R,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(z,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(z,{dimColor:!0,children:e.source}),(0,J.jsxs)(z,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),re()&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(z,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(z,{dimColor:!0,children:`Enter to apply`})]}),se>0&&(0,J.jsxs)(z,{children:[`• Update `,se,` `,H(se,`marketplace`)]}),j>0&&(0,J.jsxs)(z,{color:`warning`,children:[`• Remove `,j,` `,H(j,`marketplace`)]})]}),g&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:`Processing changes…`})}),v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:re()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:(0,J.jsxs)(B,{children:[t&&(0,J.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(ke,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(ke,{shortcut:`r`,action:`remove`}),(0,J.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),Bn=t(V(),1),ut(),P(),Be(),N(),Ze(),at(),We(),S(),l(),M(),tn(),d(),$e(),rt(),lt(),J=Ue()}));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 y(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((()=>{ve()}));function Gn({item:e,isSelected:t}){let[n]=je();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=Fe(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=Fe(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=Fe(`success`,n)(a.tick),i=`enabled`):(r=Fe(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=Fe(`warning`,n)(a.warning);return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=Fe(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=Fe(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=Fe(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=Fe(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=Fe(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=Fe(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{dimColor:!t,children:`└ `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]}):(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),Be(),lt(),Y=Ue()}));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 Je(`Failed to read plugin components from ${e}: ${Ge(t)}`,{level:`error`}),ct(qe(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 Je(`Failed to read skill directories from ${e}: ${Ge(t)}`,{level:`error`}),ct(qe(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=re(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 he(t)).plugins.find(t=>t.name===e.name);if(n){let t=[];e.commandsPath&&t.push(e.commandsPath),e.commandsPaths&&t.push(...e.commandsPaths);let i=[];for(let e of t)if(typeof e==`string`){let t=await qn(e);i.push(...t)}let a=[];e.agentsPath&&a.push(e.agentsPath),e.agentsPaths&&a.push(...e.agentsPaths);let o=[];for(let e of a)if(typeof e==`string`){let t=await qn(e);o.push(...t)}let s=[];e.skillsPath&&s.push(e.skillsPath),e.skillsPaths&&s.push(...e.skillsPaths);let c=[];for(let e of s)if(typeof e==`string`){let t=await Jn(e);c.push(...t)}let l=[];e.hooksConfig&&l.push(Object.keys(e.hooksConfig)),n.hooks&&l.push(n.hooks);let u=[];e.mcpServers&&u.push(Object.keys(e.mcpServers)),n.mcpServers&&u.push(n.mcpServers),r({commands:i.length>0?i:null,agents:o.length>0?o:null,skills:c.length>0?c:null,hooks:l.length>0?l:null,mcpServers:u.length>0?u:null})}else s(`Plugin ${e.name} not found in marketplace`)}catch(e){s(e instanceof Error?e.message:`Failed to load components`)}finally{a(!1)}}n()},[e.name,e.commandsPath,e.commandsPaths,e.agentsPath,e.agentsPaths,e.skillsPath,e.skillsPaths,e.hooksConfig,e.mcpServers,t]),i?null:o?(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Components:`}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(z,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Xn(e,t){let n=(await he(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!oe(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:s,action:c}){let l=ee(e=>e.mcp.clients),u=ee(e=>e.mcp.tools),d=ee(e=>e.plugins.errors),f=Pt(),[p,g]=(0,X.useState)(!1),_=(0,X.useCallback)(e=>{g(e),r?.(e)},[r]),v=Ne(),{columns:y}=Re(),[b,x]=(0,X.useState)(`plugin-list`),{query:S,setQuery:C,cursorOffset:w}=Wt({isActive:b===`plugin-list`&&p,onExit:()=>{_(!1)}}),[T,te]=(0,X.useState)(null),[E,ne]=(0,X.useState)([]),[D,O]=(0,X.useState)([]),[re,k]=(0,X.useState)(!0),[A,ae]=(0,X.useState)(new Map),oe=(0,X.useRef)(!1),se=(0,X.useRef)(void 0),j=Lt();Me(`confirm:no`,$n.useCallback(()=>{if(b===`plugin-details`)x(`plugin-list`),te(null),I(null);else if(typeof b==`object`&&b.type===`failed-plugin-details`)x(`plugin-list`),I(null);else if(b===`configuring`)x(`plugin-details`),Se(null);else if(typeof b==`object`&&(b.type===`plugin-options`||b.type===`configuring-options`))x(`plugin-list`),te(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof b==`object`&&b.type===`flagged-detail`)x(`plugin-list`),I(null);else if(typeof b==`object`&&b.type===`mcp-detail`)x(`plugin-list`),I(null);else if(typeof b==`object`&&b.type===`mcp-tools`)x({type:`mcp-detail`,client:b.client});else if(typeof b==`object`&&b.type===`mcp-tool-detail`)x({type:`mcp-tools`,client:b.client});else{if(A.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[b,e,A,t]),{context:`Confirmation`,isActive:(b!==`plugin-list`||!p)&&b!==`confirm-project-uninstall`&&!(typeof b==`object`&&b.type===`confirm-data-cleanup`)});let ce=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,de=(0,X.useMemo)(()=>{let e=nt(),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 D){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=d.filter(e=>`plugin`in e&&e.plugin===r.plugin.name||e.source===i||e.source.startsWith(`${r.plugin.name}@`)),s=r.plugin.isBuiltin?`builtin`:r.scope||`user`;n.push({item:{type:`plugin`,id:i,name:r.plugin.name,description:r.plugin.manifest.description,marketplace:r.marketplace,scope:s,isEnabled:a,errorCount:o.length,errors:o,plugin:r.plugin,pendingEnable:r.pendingEnable,pendingUpdate:r.pendingUpdate,pendingToggle:A.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of d){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=_t(),s=[];for(let[e,t]of a){if(e in f)continue;let n=Oe(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:ce(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],m=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;m.has(n)||m.set(n,[]),m.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;m.has(r)||m.set(r,[]),m.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:ce(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let e of s){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let[e,t]of Object.entries(f)){let n=Oe(e),r=n.name||e,i=n.marketplace||`unknown`;m.has(`flagged`)||m.set(`flagged`,[]),m.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let h=[...m.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of h){let t=m.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)p.push(...e);p.push(...r)}return p},[D,l,d,A,f]),fe=(0,X.useMemo)(()=>de.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[de]);(0,X.useEffect)(()=>{fe.length>0&&Nt(fe)},[fe]);let me=(0,X.useMemo)(()=>{if(!S)return de;let e=S.toLowerCase();return de.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[de,S]),[M,N]=(0,X.useState)(0),P=En({totalItems:me.length,selectedIndex:M,maxVisible:8}),[he,ge]=(0,X.useState)(0),[ve,ye]=(0,X.useState)(!1),[be,I]=(0,X.useState)(null),[xe,Se]=(0,X.useState)(null),[we,Ee]=(0,X.useState)(!1),[ke,Ae]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!T){Ae(!1);return}async function e(){let e=T.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&m(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&m(e))),!t)try{let e=nn.join(T.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Ke(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===T.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&m(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&m(e))}}catch(e){Je(`Failed to read raw marketplace.json: ${e}`)}Ae(t)}e()},[T]),(0,X.useEffect)(()=>{async function e(){k(!0);try{let{enabled:e,disabled:t}=await h(),n=nt(),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=Qe(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),ne(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:Ct(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}O(o),N(0)}finally{k(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!oe.current&&i&&E.length>0&&!re){let{name:e,marketplace:n}=Oe(i),r=s??n,a=r?E.filter(e=>e.name===r):E;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Ct(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};te(r),x(`plugin-details`),se.current=c,oe.current=!0;return}}let o=de.find(t=>t.type===`failed-plugin`&&t.name===e);o&&o.type===`failed-plugin`&&(x({type:`failed-plugin-details`,plugin:{id:o.id,name:o.name,marketplace:o.marketplace,errors:o.errors,scope:o.scope}}),oe.current=!0),!oe.current&&c&&(oe.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,s,E,re,de,c,t]);let je=async r=>{if(!T)return;let i=T.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){I(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!St(i)&&r!==`update`){I(`This plugin is managed by your organization. Contact your admin to disable it.`);return}ye(!0),I(null);try{let o=`${T.plugin.name}@${T.marketplace}`,s;switch(r){case`enable`:{let e=await vt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await xt(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!St(i))break;if(Tt(o)){ye(!1),x(`confirm-project-uninstall`);return}let e=ue().plugins[o],t=!e||e.length<=1?await le(o):null;if(t){ye(!1),x({type:`confirm-data-cleanup`,size:t});return}let n=await yt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await bt(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${T.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}pe();let c=`${T.plugin.name}@${T.marketplace}`;if(nt()?.enabledPlugins?.[c]!==!1){ye(!1),x({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} ${T.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){ye(!1);let t=e instanceof Error?e.message:String(e);I(`Failed to ${r}: ${t}`),ct(qe(e))}},V=(0,X.useRef)(je);V.current=je,(0,X.useEffect)(()=>{if(b===`plugin-details`&&T&&se.current){let e=se.current;se.current=void 0,V.current(e)}},[b,T]);let Fe=$n.useCallback(()=>{if(M>=me.length)return;let e=me[M];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=nt(),r=A.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||St(a)){let e=new Map(A);r?(e.delete(t),(async()=>{try{r===`will-disable`?await vt(t):await xt(t),pe()}catch(e){ct(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await xt(t):await vt(t),pe()}catch(e){ct(e)}})()),ae(e)}}else e?.type===`mcp`&&j(e.client.name)},[M,me,A,D,j]);L({"select:previous":()=>{M===0?_(!0):P.handleSelectionChange(M-1,N)},"select:next":()=>{M<me.length-1&&P.handleSelectionChange(M+1,N)},"select:accept":$n.useCallback(()=>{if(M>=me.length)return;let e=me[M];if(e?.type===`plugin`){let t=D.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(te(t),x(`plugin-details`),ge(0),I(null))}else e?.type===`flagged-plugin`?(x({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),I(null)):e?.type===`failed-plugin`?(x({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),ge(0),I(null)):e?.type===`mcp`&&(x({type:`mcp-detail`,client:e.client}),I(null))},[M,me,D])},{context:`Select`,isActive:b===`plugin-list`&&!p}),L({"plugin:toggle":Fe},{context:`Plugin`,isActive:b===`plugin-list`&&!p}),L({"select:accept":$n.useCallback(()=>{typeof b!=`object`||b.type!==`flagged-detail`||(Ft(b.plugin.id),x(`plugin-list`))},[b])},{context:`Select`,isActive:typeof b==`object`&&b.type===`flagged-detail`});let Le=$n.useMemo(()=>{if(b!==`plugin-details`||!T)return[];let e=nt(),t=`${T.plugin.name}@${T.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=T.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void je(n?`disable`:`enable`)}),r||(i.push({label:T.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(T.plugin.name,T.marketplace);if(e){I(e);return}let t=[...D],n=t.findIndex(e=>e.plugin.name===T.plugin.name&&e.marketplace===T.marketplace);n!==-1&&(t[n].pendingUpdate=!T.pendingUpdate,O(t),te({...T,pendingUpdate:!T.pendingUpdate}))}catch(e){I(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),ke&&i.push({label:`Configure`,action:async()=>{Ee(!0);try{let e=T.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&m(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&m(n)){t=n;break}}if(!t){I(`No MCPB file found in plugin`),Ee(!1);return}let n=`${T.plugin.name}@${T.marketplace}`,r=await ie(t,T.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Se(r),x(`configuring`)):I(`Failed to load MCPB for configuration`)}catch(e){let t=Ge(e);I(`Failed to load configuration: ${t}`)}finally{Ee(!1)}}}),T.plugin.manifest.userConfig&&Object.keys(T.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{x({type:`configuring-options`,schema:T.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void je(`update`)}),i.push({label:`Uninstall`,action:()=>void je(`uninstall`)})),T.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void Te(T.plugin.manifest.homepage)}),T.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void Te(T.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{x(`plugin-list`),te(null),I(null)}}),i},[b,T,ke,D]);if(L({"select:previous":()=>{he>0&&ge(he-1)},"select:next":()=>{he<Le.length-1&&ge(he+1)},"select:accept":()=>{Le[he]&&Le[he].action()}},{context:`Select`,isActive:b===`plugin-details`&&!!T}),L({"select:accept":()=>{typeof b==`object`&&b.type===`failed-plugin-details`&&(async()=>{ye(!0),I(null);let e=b.plugin.id,t=b.plugin.scope,r=St(t)?await yt(e,t,!1):await yt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=it(t);n?.enabledPlugins?.[e]!==void 0&&(et(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}pe()}i?(n&&await n(),ye(!1),x(`plugin-list`)):(ye(!1),I(r.message))})()}},{context:`Select`,isActive:typeof b==`object`&&b.type===`failed-plugin-details`&&b.plugin.scope!==`managed`}),L({"confirm:yes":()=>{if(!T)return;ye(!0),I(null);let r=`${T.plugin.name}@${T.marketplace}`,{error:i}=et(`localSettings`,{enabledPlugins:{...it(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){ye(!1),I(`Failed to write settings: ${i.message}`);return}pe(),t(`✓ Disabled ${T.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{x(`plugin-details`),I(null)}},{context:`Confirmation`,isActive:b===`confirm-project-uninstall`&&!!T&&!ve}),Pe((r,i)=>{if(!T)return;let o=`${T.plugin.name}@${T.marketplace}`,s=T.scope;if(!s||s===`builtin`||!St(s))return;let c=async r=>{ye(!0),I(null);try{let i=await yt(o,s,r);if(!i.success)throw Error(i.message);pe();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){ye(!1),I(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(x(`plugin-details`),I(null))},{isActive:typeof b==`object`&&b.type===`confirm-data-cleanup`&&!!T&&!ve}),$n.useEffect(()=>{N(0)},[S]),Pe((e,t)=>{let n=!t.ctrl&&!t.meta;p||(e===`/`&&n?(_(!0),C(``),N(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(_(!0),C(e),N(0)))},{isActive:b===`plugin-list`}),re)return(0,Z.jsx)(z,{children:`Loading installed plugins…`});if(de.length===0)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(z,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Esc to go back`})})]});if(typeof b==`object`&&b.type===`plugin-options`&&T){let r=`${T.plugin.name}@${T.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:T.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${T.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${T.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof b==`object`&&b.type===`configuring-options`&&T){let e=`${T.plugin.name}@${T.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${T.plugin.name}`,subtitle:`Plugin options`,configSchema:b.schema,initialValues:De(e),onSave:n=>{try{o(e,n,b.schema),pe(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){I(`Failed to save configuration: ${Ge(e)}`)}x(`plugin-details`)},onCancel:()=>x(`plugin-details`)})}if(b===`configuring`&&xe&&T){let e=`${T.plugin.name}@${T.marketplace}`;async function n(n){if(!(!xe||!T))try{let r=T.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&m(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&m(e)){i=e;break}}if(!i){I(`No MCPB file found`),x(`plugin-details`);return}await ie(i,T.plugin.path,e,void 0,n),I(null),Se(null),x(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Ge(e);I(`Failed to save configuration: ${t}`),x(`plugin-details`)}}function r(){Se(null),x(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${xe.manifest.name}`,subtitle:`Plugin: ${T.plugin.name}`,configSchema:xe.configSchema,initialValues:xe.existingConfig,onSave:n,onCancel:r})}if(typeof b==`object`&&b.type===`flagged-detail`){let e=b.plugin;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(R,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(z,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(z,{children:e.text}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsxs)(z,{children:[a.pointer,` `]}),(0,Z.jsx)(z,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(b===`confirm-project-uninstall`&&T)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,color:`warning`,children:[T.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(z,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),be&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:be})}),(0,Z.jsx)(R,{marginTop:1,children:ve?(0,Z.jsx)(z,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(F,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof b==`object`&&b.type===`confirm-data-cleanup`&&T)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,children:[T.plugin.name,` has `,b.size.human,` of persistent data`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(z,{dimColor:!0,children:Ce(`${T.plugin.name}@${T.marketplace}`)})]}),be&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:be})}),(0,Z.jsx)(R,{marginTop:1,children:ve?(0,Z.jsx)(z,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(z,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(z,{bold:!0,children:`esc`}),` to cancel`]})})]});if(b===`plugin-details`&&T){let e=nt(),t=`${T.plugin.name}@${T.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===T.plugin.name||e.source===t||e.source.startsWith(`${T.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(z,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(R,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(z,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(z,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[T.plugin.name,` @ `,T.marketplace]})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(z,{children:T.scope||`user`})]}),T.plugin.manifest.version&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(z,{children:T.plugin.manifest.version})]}),T.plugin.manifest.description&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{children:T.plugin.manifest.description})}),T.plugin.manifest.author&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(z,{children:T.plugin.manifest.author.name})]}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),T.pendingUpdate&&(0,Z.jsx)(z,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:T.plugin,marketplace:T.marketplace}),i,(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:Le.map((e,t)=>{let n=t===he;return(0,Z.jsxs)(R,{children:[n&&(0,Z.jsxs)(z,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(z,{children:` `}),(0,Z.jsx)(z,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),ve&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{children:`Processing…`})}),be&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:be})}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(F,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof b==`object`&&b.type===`failed-plugin-details`){let e=b.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:e.name}),(0,Z.jsxs)(z,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(z,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(R,{marginTop:1,children:[(0,Z.jsxs)(z,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(z,{bold:!0,children:`Remove`})]}),ve&&(0,Z.jsx)(z,{children:`Processing…`}),be&&(0,Z.jsx)(z,{color:`error`,children:be}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[e.scope!==`managed`&&(0,Z.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof b==`object`&&b.type===`mcp-detail`){let e=b.client,n=_e(u,e.name).length,r=()=>{x({type:`mcp-tools`,client:e})},i=()=>{x(`plugin-list`)},a=e=>{e&&t(e),x(`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}):(x(`plugin-list`),null)}if(typeof b==`object`&&b.type===`mcp-tools`){let e=b.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=>{x({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>x({type:`mcp-detail`,client:e})})}if(typeof b==`object`&&b.type===`mcp-tool-detail`){let{client:e,tool:t}=b,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:()=>x({type:`mcp-tools`,client:e})})}let ze=P.getVisibleItems(me);return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(Ie,{query:S,isFocused:p,isTerminalFocused:v,width:y-4,cursorOffset:w})}),me.length===0&&S&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsxs)(z,{dimColor:!0,children:[`No items match "`,S,`"`]})}),P.scrollPosition.canScrollUp&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),ze.map((e,t)=>{let n=P.toActualIndex(t)===M&&!p,r=t>0?ze[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(R,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(z,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Gn,{item:e,isSelected:n})]},e.id)}),P.scrollPosition.canScrollDown&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(R,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(z,{children:`type to search`}),(0,Z.jsx)(F,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),A.size>0&&(0,Z.jsx)(R,{marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(V(),1),X=t(V(),1),P(),Be(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),ce(),N(),ae(),Rt(),de(),wt(),g(),Ze(),xe(),Ye(),We(),st(),S(),_(),M(),A(),c(),It(),x(),d(),E(),v(),gt(),rt(),Xe(),lt(),Wn(),fn(),_n(),Kn(),kn(),Z=Ue()}));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 kt(t),r=``;r+=`Validating ${n.fileType} manifest: ${n.filePath}\n\n`,n.errors.length>0&&(r+=`${a.cross} Found ${n.errors.length} ${H(n.errors.length,`error`)}:\n\n`,n.errors.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
|
|
15
|
-
`),n.warnings.length>0&&(r+=`${a.warning} Found ${n.warnings.length} ${H(n.warnings.length,`warning`)}:\n\n`,n.warnings.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
|
|
16
|
-
`),n.success?(n.warnings.length>0?r+=`${a.tick} Validation passed with warnings\n`:r+=`${a.tick} Validation passed\n`,process.exitCode=0):(r+=`${a.cross} Validation failed\n`,process.exitCode=1),e(r)}catch(t){process.exitCode=2,ct(t),e(`${a.cross} Unexpected error during validation: ${Ge(t)}`)}}n()},[e,t]),(0,ar.jsx)(R,{flexDirection:`column`,children:(0,ar.jsx)(z,{children:`Running validation...`})})}var ir,ar,or=e((()=>{i(),ir=t(V(),1),Be(),We(),st(),Mt(),lt(),ar=Ue()}));function sr({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await be(),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: ${Ge(t)}`)}}t()},[e]),(0,$.jsx)(z,{children:`Loading marketplaces...`})}function cr(e){let t=[];for(let{source:n,scope:r}of[{source:`userSettings`,scope:`user`},{source:`projectSettings`,scope:`project`},{source:`localSettings`,scope:`local`}])it(n)?.extraKnownMarketplaces?.[e]&&t.push({source:n,scope:r});return{editableSources:t,isInPolicy:!!it(`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=it(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&&et(n,r)}}function hr({setViewState:e,setActiveTab:t,markPluginsChanged:n}){let r=ee(e=>e.plugins.errors),i=ee(e=>e.plugins.installationStatus),o=Ee(),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await me(await be());f(e)}catch{}})()},[]);let p=i.marketplaces.filter(e=>e.status===`failed`),m=new Set(p.map(e=>e.name)),h=r.filter(dr),g=pr(p,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!m.has(e.marketplace)),r.filter(e=>dr(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:fr(e)!==void 0),r.filter(e=>dr(e)||e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`?!1:fr(e)===void 0),d,h,_t());Me(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),L({"select:previous":()=>c(e=>Math.max(0,e-1)),"select:next":()=>c(e=>Math.min(g.length-1,e+1)),"select:accept":()=>{let r=g[s];if(!r)return;let{action:i}=r;switch(i.kind){case`navigate`:t(i.tab),e(i.viewState);break;case`remove-extra-marketplace`:{let e=i.sources.map(e=>e.scope).join(`, `);mr(i.name,i.sources),pe(),o(e=>({...e,plugins:{...e.plugins,errors:e.plugins.errors.filter(e=>!(`marketplace`in e&&e.marketplace===i.name)),installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.filter(e=>e.name!==i.name)}}})),u(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await fe(i.name),pe(),f(e=>e.filter(e=>e.name!==i.name)),u(`${a.tick} Removed marketplace "${i.name}"`),n()}catch(e){u(`Failed to remove "${i.name}": ${e instanceof Error?e.message:String(e)}`)}})();break;case`managed-only`:break;case`none`:break}}},{context:`Select`,isActive:g.length>0});let _=Math.min(s,Math.max(0,g.length-1));_!==s&&c(_);let v=g[_]?.action,y=v&&v.kind!==`none`&&v.kind!==`managed-only`;return g.length===0?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(R,{marginLeft:1,children:(0,$.jsx)(z,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(R,{flexDirection:`column`,children:[g.map((e,t)=>{let n=t===_;return(0,$.jsxs)(R,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(z,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),l&&(0,$.jsx)(R,{marginTop:1,marginLeft:1,children:(0,$.jsx)(z,{color:`claude`,children:l})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(F,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),y&&(0,$.jsx)(F,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(F,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}function gr(e){switch(e.type){case`help`:return{type:`help`};case`validate`:return{type:`validate`,path:e.path};case`install`:return e.marketplace?{type:`browse-marketplace`,targetMarketplace:e.marketplace,targetPlugin:e.plugin}:e.plugin?{type:`discover-plugins`,targetPlugin:e.plugin}:{type:`discover-plugins`};case`manage`:return{type:`manage-plugins`};case`uninstall`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`uninstall`};case`enable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`enable`};case`disable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`disable`};case`marketplace`:return e.action===`list`?{type:`marketplace-list`}:e.action===`add`?{type:`add-marketplace`,initialValue:e.target}:e.action===`remove`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`remove`}:e.action===`update`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`update`}:{type:`marketplace-menu`};default:return{type:`discover-plugins`}}}function _r(e){return e.type===`manage-plugins`?`installed`:e.type===`manage-marketplaces`?`marketplaces`:`discover`}function vr({onComplete:e,args:t}){let n=tr(t),r=gr(n),[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(_r(r)),[c,l]=(0,Q.useState)(i.type===`add-marketplace`&&i.initialValue||``),[u,d]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=Ee(),y=ee(e=>{let t=e.plugins.errors.length;for(let n of e.plugins.installationStatus.marketplaces)n.status===`failed`&&t++;return t}),b=y>0?`Errors (${y})`:`Errors`,x=zt(),S=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,C=(0,Q.useCallback)(()=>{v(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[v]),w=(0,Q.useCallback)(e=>{let t=e;switch(s(t),p(null),t){case`discover`:a({type:`discover-plugins`});break;case`installed`:a({type:`manage-plugins`});break;case`marketplaces`:a({type:`manage-marketplaces`});break;case`errors`:break}},[]);return(0,Q.useEffect)(()=>{i.type===`menu`&&!m&&e()},[i.type,m,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&o!==`discover`&&s(`discover`)},[i.type,o]),Me(`confirm:no`,(0,Q.useCallback)(()=>{s(`marketplaces`),a({type:`manage-marketplaces`}),l(``),p(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{m&&e(m)},[m,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(z,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(z,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(z,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(z,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Management:`}),(0,$.jsx)(z,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(z,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(z,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(z,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(z,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(z,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(z,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(z,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(z,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Other:`}),(0,$.jsx)(z,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(z,{children:` /plugin help - Show this help`}),(0,$.jsx)(z,{children:` /plugins - Alias for /plugin`})]}):i.type===`validate`?(0,$.jsx)(rr,{onComplete:e,path:i.path}):i.type===`marketplace-menu`?(a({type:`menu`}),null):i.type===`marketplace-list`?(0,$.jsx)(sr,{onComplete:e}):i.type===`add-marketplace`?(0,$.jsx)(an,{inputValue:c,setInputValue:l,cursorOffset:u,setCursorOffset:d,error:f,setError:p,result:m,setResult:h,setViewState:a,onAddComplete:C,cliMode:S}):(0,$.jsx)(Ve,{color:`suggestion`,children:(0,$.jsxs)(ze,{title:`Plugins`,selectedTab:o,onTabChange:w,color:`suggestion`,disableNavigation:g,children:[(0,$.jsx)(Le,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(An,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:C,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Nn,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:C,onSearchModeChange:_,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(Le,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Qn,{setViewState:a,setResult:h,onManageComplete:C,onSearchModeChange:_,targetPlugin:i.type===`manage-plugins`?i.targetPlugin:void 0,targetMarketplace:i.type===`manage-plugins`?i.targetMarketplace:void 0,action:i.type===`manage-plugins`?i.action:void 0})}),(0,$.jsx)(Le,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Rn,{setViewState:a,error:f,setError:p,setResult:h,exitState:x,onManageComplete:C,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(Le,{id:`errors`,title:b,children:(0,$.jsx)(hr,{setViewState:a,setActiveTab:s,markPluginsChanged:C})})]})})}var Q,$,yr,br=e((()=>{i(),Q=t(V(),1),P(),Be(),Bt(),N(),g(),We(),S(),l(),M(),gt(),rt(),sn(),Mn(),Ln(),Vn(),er(),Wn(),nr(),or(),$=Ue(),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((()=>{br(),Sr=Ue()}))();export{xr as call};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{Ka as n,Lx as r,_i as i,hi as a,iu as o,nu as s,qa as c,ru as l,zx as u}from"./loadAgentsDir-DlPbtIsS.js";import{I as d,M as f}from"./debug-Bglx1aTu.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-D2TIwHBV.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-hXYLrzM2.js";e(),d(),i(),h(),c(),r(),p(),o(),_(),T();function E(e,r,i){g(e);let a=i?`${r} plugin "${i}"`:r===`disable-all`?`disable all plugins`:`${r} plugins`;console.error(`${t.cross} Failed to ${a}: ${f(e)}`);let o=i?(()=>{let{name:e,marketplace:t}=u(i);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...s(e,t,n())}})():{};v(`tengu_plugin_command_failed`,{command:r,error_category:l(e),...o}),process.exit(1)}async function D(e,r=`user`){try{console.log(`Installing plugin "${e}"...`);let i=await b(e,r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:o}=u(i.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:a,...o&&{_PROTO_marketplace_name:o},scope:i.scope||r,install_source:`cli-explicit`,...s(a,o,n())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,r=`user`,i=!1){try{let a=await x(e,r,!i);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:c}=u(a.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:o,...c&&{_PROTO_marketplace_name:c},scope:a.scope||r,...s(o,c,n())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,r){try{let i=await y(e,r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:o}=u(i.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:a,...o&&{_PROTO_marketplace_name:o},scope:i.scope,...s(a,o,n())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,r){try{let i=await C(e,r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:o}=u(i.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:a,...o&&{_PROTO_marketplace_name:o},scope:i.scope,...s(a,o,n())}),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,r){try{m(`Checking for updates for plugin "${e}" at ${r} scope…\n`);let i=await S(e,r);if(!i.success)throw Error(i.message);if(m(`${t.tick} ${i.message}\n`),!i.alreadyUpToDate){let{name:t,marketplace:r}=u(i.pluginId||e);v(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...r&&{_PROTO_marketplace_name:r},old_version:i.oldVersion||`unknown`,new_version:i.newVersion||`unknown`,...s(t,r,n())})}await a(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{$a as t,Aa as n,Ba as r,Bx as i,Cx as a,Fa as o,Fx as s,Ga as c,Gx as l,Ia as u,Iv as d,Ix as f,Ja as p,Jp as m,Lx as h,Ma as g,Mo as _,Na as v,No as y,Pa as b,Px as x,Ra as S,Rv as C,Ua as w,Va as T,Wa as E,Wx as ee,Yp as te,co as D,eo as O,jo as k,lo as ne,no as A,oo as j,to as M,uo as re,yx as ie,zx as N}from"./loadAgentsDir-DlPbtIsS.js";import{It as ae,J as P}from"./state-B4jiUise.js";import{I as oe,R as F,V as se,f as ce,u as I}from"./debug-Bglx1aTu.js";import{b as L,h as R,s as z}from"./settings-B2jvL8Dp.js";import{o as B,s as V}from"./log-D2TIwHBV.js";import{l as H,o as U}from"./stringUtils-C718f5ey.js";import{n as W,t as G}from"./pluginStartupCheck-DTMa6TgL.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?P():void 0}function de(e){return z(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=z(i(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}=N(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}=N(e),n=O();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=N(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=O().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=P(),r=t.find(e=>e.scope===`local`&&e.projectPath===n);if(r)return{scope:r.scope,projectPath:r.projectPath};let i=t.find(e=>e.scope===`project`&&e.projectPath===n);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`user`);return a?{scope:a.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:i}=N(e),a,o,s;if(i){let t=await D(e);t&&(a=t.entry,o=i,s=t.marketplaceInstallLocation)}else{let e=await re();for(let[t,r]of Object.entries(e))try{let e=(await j(t)).plugins.find(e=>e.name===n);if(e){a=e,o=t,s=r.installLocation;break}}catch(e){V(se(e))}}if(!a||!o)return{success:!1,message:`Plugin "${n}" not found in ${i?`marketplace "${i}"`:`any configured marketplace`}`};let c=a,l=`${c.name}@${o}`,u=await w({pluginId:l,entry:c,scope:t,marketplaceInstallLocation:s});if(!u.ok){let e=u;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:r(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${l} (scope: ${t})${u.depNote}`,pluginId:l,pluginName:c.name,scope:t}}async function ge(e,t=`user`,n=!0){q(t);let{enabled:r,disabled:a}=await u(),o=[...r,...a],c=pe(e,o),l=i(t),f=z(l),p,m;if(c)p=Object.keys(f?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),m=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};p=t.pluginId,m=t.pluginName}let h=J(t),g=O().plugins[p],_=g?.find(e=>e.scope===t&&e.projectPath===h);if(!_){let{scope:n}=Y(p);return n!==t&&g&&g.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.workmate/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let v=_.installPath,b={...f?.enabledPlugins};b[p]=void 0,L(l,{enabledPlugins:b}),k(),M(p,t,h);let S=O().plugins[p],C=!S||S.length===0;C&&v&&await y(v),C&&(d(p),n&&await ie(p));let w=x(p,o),T=s(w);return{success:!0,message:`Successfully uninstalled plugin: ${m} (scope: ${t})${T}`,pluginId:p,pluginName:m,scope:t,reverseDependents:w.length>0?w:void 0}}async function X(e,t,n){let r=t?`enable`:`disable`;if(l(e)){let{error:n}=L(`userSettings`,{enabledPlugins:{...z(`userSettings`)?.enabledPlugins,[e]:t}});if(n)return{success:!1,message:`Failed to ${r} built-in plugin: ${n.message}`};k();let{name:i}=N(e);return{success:!0,message:`Successfully ${r}d built-in plugin: ${i}`,pluginId:e,pluginName:i,scope:`user`}}n&&q(n);let a,o,c=fe(e);if(n)if(o=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,o=c.scope;else if(e.includes(`@`))a=e,o=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&te(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let d=i(o),f=z(d)?.enabledPlugins?.[a],p={user:0,project:1,local:2},m=n&&c&&p[n]>p[c.scope];if(n&&f===void 0&&c&&c.scope!==n&&!m)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&&!m?f===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${n?` at ${n} scope`:``}`};let h;if(!t){let{enabled:e,disabled:t}=await u(),n=x(a,[...e,...t]);n.length>0&&(h=n)}let{error:g}=L(d,{enabledPlugins:{...z(d)?.enabledPlugins,[a]:t}});if(g)return{success:!1,message:`Failed to ${r} plugin: ${g.message}`};k();let{name:_}=N(a),v=s(h);return{success:!0,message:`Successfully ${r}d plugin: ${_} (scope: ${o})${v}`,pluginId:a,pluginName:_,scope:o,reverseDependents:h}}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,n){let{name:r,marketplace:i}=N(e),a=i?`${r}@${i}`:e,o=await D(e);if(!o)return{success:!1,message:`Plugin "${r}" not found`,pluginId:a,scope:n};let{entry:s,marketplaceInstallLocation:c}=o,l=t().plugins[a];if(!l||l.length===0)return{success:!1,message:`Plugin "${r}" is not installed`,pluginId:a,scope:n};let u=J(n),d=l.find(e=>e.scope===n&&e.projectPath===u);return d?be({pluginId:a,pluginName:r,entry:s,marketplaceInstallLocation:c,installation:d,scope:n,projectPath:u}):{success:!1,message:`Plugin "${r}" is not installed at scope ${u?`${n} (${u})`:n}`,pluginId:a,scope:n}}async function be({pluginId:e,pluginName:r,entry:i,marketplaceInstallLocation:a,installation:o,scope:s,projectPath:c}){let l=I(),u=o.version,d,f,p=!1,m;if(typeof i.source!=`string`){let t=await n(i.source,{manifest:{name:i.name}});d=t.path,p=!0,m=t.gitCommitSha,f=await E(e,i.source,t.manifest,t.path,i.version,t.gitCommitSha)}else{let t;try{t=await l.stat(a)}catch(t){if(F(t))return{success:!1,message:`Marketplace directory not found at ${a}`,pluginId:e,scope:s};throw t}d=K(t.isDirectory()?a:le(a),i.source);try{await l.stat(d)}catch(t){if(F(t))return{success:!1,message:`Plugin source not found at ${d}`,pluginId:e,scope:s};throw t}let n,r=K(d,`.claude-plugin`,`plugin.json`);try{n=await S(r,i.name,i.source)}catch{}f=await E(e,i.source,n,d,i.version)}try{let n=v(e,f),a=b(e,f);if(o.version===f||o.installPath===n||o.installPath===a)return{success:!0,message:`${r} is already at the latest version (${f}).`,pluginId:e,newVersion:f,oldVersion:u,alreadyUpToDate:!0,scope:s};n=await g(d,e,f,i);let l=o.installPath;if(A(e,s,c,n,f,m),l&&l!==n){let e=t();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===l))||await y(l)}let p=c?`${s} (${c})`:s;return{success:!0,message:`Plugin "${r}" updated from ${u||`unknown`} to ${f} for scope ${p}. Restart to apply changes.`,pluginId:e,newVersion:f,oldVersion:u,scope:s}}finally{p&&d!==v(e,f)&&await l.rm(d,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{ae(),ee(),oe(),ce(),B(),_(),f(),p(),ne(),a(),h(),T(),o(),C(),m(),W(),c(),R(),U(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./pluginStartupCheck-DTMa6TgL.js";e();export{t as getPluginEditableScopes};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{Bx as n,Do as r,Fa as i,Fv as a,Ia as o,Ja as s,Kx as c,Lx as l,Mo as u,Pv as d,Qa as f,_o as p,eo as m,fo as h,ho as g,jo as _,ko as v,lo as ee,po as te,qx as y,ro as b,uo as x,xo as S,zx as C}from"./loadAgentsDir-DlPbtIsS.js";import{Hn as w,It as T}from"./state-B4jiUise.js";import{C as E,I as ne,M as D,x as re}from"./debug-Bglx1aTu.js";import{o as O,s as k}from"./log-D2TIwHBV.js";import{l as A,o as j}from"./stringUtils-C718f5ey.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";import{n as P,t as F}from"./exit-s9XGerrH.js";import{n as I,s as L,t as R}from"./pluginOperations-hXYLrzM2.js";import{a as z,i as B,n as V,o as H,r as U,t as ie}from"./pluginCliCommands-DXZfCZsv.js";import{a as W,c as G,i as K,n as q,r as J,s as Y,t as ae}from"./validatePlugin-D6tFo87L.js";import{basename as oe,dirname as X}from"path";e(),T(),M(),L(),y(),ne(),O(),u(),G(),s(),r(),ee(),d(),K(),l(),i(),ae(),re(),j();function Z(e,n){k(e),F(`${t.cross} Failed to ${n}: ${D(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${A(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} ${A(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function $(e,n){n.cowork&&w(!0);try{let n=await q(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(oe(e)===`.claude-plugin`){r=await J(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?P(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){k(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&w(!0),N(`tengu_plugin_list_command`,{});let n=m(),{getPluginEditableScopes:r}=await import(`./pluginStartupCheck-HS1ZceZa.js`),i=r(),s=Object.keys(n.plugins),{enabled:l,disabled:u,errors:d}=await o(),p=[...l,...u],h=p.filter(e=>e.source.endsWith(`@inline`)),g=d.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(p.map(e=>[e.source,e])),r=[];for(let e of s.sort()){let o=n.plugins[e];if(!o||o.length===0)continue;let s=C(e).name,l=d.filter(t=>t.source===e||`plugin`in t&&t.plugin===s).map(c);for(let n of o){let o=t.get(e),s;if(o){let e=o.mcpServers||await a(o);e&&Object.keys(e).length>0&&(s=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:i.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:s,errors:l.length>0?l:void 0})}}for(let e of h){let t=e.mcpServers||await a(e),n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(c);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:[c(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([x(),Y()]),{marketplaces:r}=await v(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=S(r.name,t);f(i)||e.push({pluginId:i,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(i)})}}catch{}P(E({installed:r,available:e},null,2))}else P(E(r,null,2))}s.length===0&&h.length===0&&g.length===0&&P("No plugins installed. Use `claude plugin install` to install a plugin."),s.length>0&&console.log(`Installed plugins:
|
|
2
|
-
`);for(let e of s.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let a=C(e).name,o=d.filter(t=>t.source===e||`plugin`in t&&t.plugin===a);for(let n of r){let r=i.has(e),a=o.length>0?`${t.cross} failed to load`:r?`${t.tick} enabled`:`${t.cross} disabled`,s=n.version||`unknown`,l=n.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${s}`),console.log(` Scope: ${l}`),console.log(` Status: ${a}`);for(let e of o)console.log(` Error: ${c(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: ${c(e)}`);console.log(``)}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${c(e)}\n`)}P()}async function ce(e,r){r.cowork&&w(!0);try{let i=await W(e);i||F(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in i&&F(`${t.cross} ${i.error}`);let a=r.scope??`user`;a!==`user`&&a!==`project`&&a!==`local`&&F(`${t.cross} Invalid scope '${a}'. Use: user, project, or local`);let o=n(a),s=i;r.sparse&&r.sparse.length>0&&(s.source===`github`||s.source===`git`?s={...s,sparsePaths:r.sparse}:F(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${s.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:l,resolvedSource:u}=await b(s,e=>{console.log(e)});p(c,{source:u},o),_();let d=s.source;s.source===`github`&&(d=s.repo),N(`tengu_marketplace_added`,{source_type:d}),P(l?`${t.tick} Marketplace '${c}' already on disk — declared in ${a} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${a} settings)`)}catch(e){Z(e,`add marketplace`)}}async function le(e){e.cowork&&w(!0);try{let n=await x(),r=Object.keys(n);e.json&&P(E(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&P(`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(``)}),P()}catch(e){Z(e,`list marketplaces`)}}async function ue(e,n){n.cowork&&w(!0);try{await g(e),_(),N(`tengu_marketplace_removed`,{marketplace_name:e}),P(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Z(e,`remove marketplace`)}}async function de(e,n){n.cowork&&w(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await te(e,e=>{console.log(e)}),_(),N(`tengu_marketplace_updated`,{marketplace_name:e}),P(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await x(),n=Object.keys(e);n.length===0&&P(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await h(),_(),N(`tengu_marketplace_updated_all`,{count:n.length}),P(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Z(e,`update marketplace(s)`)}}async function fe(e,t){t.cowork&&w(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:r,marketplace:i}=C(e);N(`tengu_plugin_install_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await B(e,n)}async function pe(e,t){t.cowork&&w(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:r,marketplace:i}=C(e);N(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await z(e,n,t.keepData)}async function me(e,t){t.cowork&&w(!0);let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=C(e);N(`tengu_plugin_enable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await U(e,n)}async function he(e,t){if(t.all&&e&&F(`Cannot use --all with a specific plugin`),!t.all&&!e&&F(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&w(!0),t.all){t.scope&&F(`Cannot use --scope with --all`),N(`tengu_plugin_disable_command`,{}),await ie();return}let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=C(e);N(`tengu_plugin_disable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await V(e,n)}async function ge(e,t){t.cowork&&w(!0);let{name:n,marketplace:r}=C(e);N(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...r&&{_PROTO_marketplace_name:r}});let i=`user`;t.scope&&(I.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${I.join(`, `)}`),i=t.scope),t.cowork&&i!==`user`&&F(`--cowork can only be used with user scope`),await H(e,i)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,ue as marketplaceRemoveHandler,de as marketplaceUpdateHandler,he as pluginDisableHandler,me as pluginEnableHandler,fe as pluginInstallHandler,se as pluginListHandler,pe as pluginUninstallHandler,ge as pluginUpdateHandler,$ as pluginValidateHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./poorMode-B0QGV6Ci.js";t();export{e as isPoorModeActive};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{c as e,l as t,o as n,s as r}from"./envUtils-DfkgIdYf.js";import{n as i,t as a}from"./defineProperty-C-QyHrDq.js";import{_t as o,vt as s}from"./esm-eTAUP-La.js";import{$_ as c,$d as l,$m as u,$p as d,$r as f,$v as p,A as m,Ag as h,Al as g,As as ee,B as _,Bl as te,Bo as ne,Bp as re,Bt as v,By as y,C as ie,CC as b,Cc as x,Cg as S,Cn as C,Cv as ae,Cy as oe,D_ as se,Dm as ce,Dv as w,E_ as le,Ec as ue,Ei as de,Fa as fe,Fl as pe,Fo as me,GC as he,Ho as ge,Hs as _e,Id as ve,Ig as ye,Il as be,Io as T,K_ as xe,Kn as Se,Ku as Ce,La as we,Ld as Te,Lo as Ee,Ls as De,Mv as Oe,Mw as ke,Ng as Ae,Ni as E,Ns as je,OC as Me,Oa as Ne,Og as Pe,Oi as Fe,PS as Ie,Pi as Le,Pl as Re,Po as ze,Qd as Be,Qm as Ve,Qp as He,Ro as Ue,Rr as We,Rs as Ge,Sc as Ke,Sg as qe,Sn as Je,Ss as Ye,Sv as Xe,T_ as Ze,Tm as Qe,Ty as $e,Uo as et,Us as tt,V as nt,Vo as D,Vp as O,WC as rt,W_ as it,Wu as at,XC as ot,X_ as st,Xd as k,Xn as ct,Xr as lt,YC as ut,Yi as dt,Zd as ft,Zp as pt,Zr as mt,Zv as ht,_c as gt,_g as _t,_i as vt,_r as yt,af as bt,ao as xt,b as St,bc as Ct,bg as wt,bm as Tt,bn as Et,bs as Dt,cs as Ot,do as kt,ef as At,eh as jt,ei as Mt,ey as Nt,f as Pt,gC as Ft,gc as It,gg as Lt,gi as A,gu as Rt,gv as zt,hi as Bt,hu as Vt,if as Ht,im as Ut,io as Wt,ja as Gt,jl as Kt,jm as qt,js as Jt,kC as Yt,ka as Xt,kg as Zt,km as Qt,ks as $t,lf as en,lo as tn,lp as nn,ls as rn,mc as an,mn as on,mo as sn,nf as cn,nv as ln,ny as un,o as dn,of as fn,os as pn,pc as mn,pv as hn,qC as gn,q_ as _n,rf as vn,rm as yn,rv as bn,s as xn,sC as Sn,sS as Cn,ss as wn,tf as Tn,th as En,tv as Dn,ty as On,up as kn,v as An,vg as jn,vi as Mn,vn as Nn,w as Pn,wC as Fn,wg as In,wi as Ln,wm as Rn,wv as zn,xc as Bn,xm as Vn,xn as Hn,y as Un,yC as Wn,yc as Gn,yn as Kn,zl as qn,zo as Jn,zt as Yn}from"./loadAgentsDir-DlPbtIsS.js";import{$ as j,A as M,B as Xn,F as N,G as P,L as Zn,N as Qn,P as F,Q as I,S as L,V as R,W as z,Y as B,Z as V,f as $n,j as er,l as tr,o as nr,s as H,x as rr}from"./types-Dx7P7JLQ.js";import{G as ir,It as ar,Lt as or,Pn as sr,Wn as cr,Wt as lr,bn as ur,cn as dr,in as fr,j as pr,k as mr,st as U,xn as hr}from"./state-B4jiUise.js";import{n as gr,t as _r}from"./cwd-Pa83R95t.js";import{$ as vr,C as W,E as yr,I as br,M as G,S as xr,V as Sr,c as K,et as Cr,f as wr,i as q,u as Tr,x as Er}from"./debug-Bglx1aTu.js";import{Hn as Dr,W as Or,Wn as kr,Xr as Ar,Yr as jr,Zr as Mr,_t as Nr,d as Pr,er as Fr,h as Ir,nr as Lr,rt as Rr,tt as zr,u as Br,ut as Vr}from"./settings-B2jvL8Dp.js";import{O as Hr,j as Ur}from"./config-C-Y2qtB2.js";import{i as Wr,n as Gr,o as Kr}from"./process-gEbdy6uY.js";import{H as qr,c as Jr,i as Yr,o as Xr,q as Zr,s as J}from"./log-D2TIwHBV.js";import{n as Qr,r as $r}from"./analytics-DJobLaWP.js";import{G as ei,H as ti,Jt as ni,K as ri,L as ii,U as ai,Yt as oi,Zt as si,_ as ci,d as li,et as ui,h as di,n as fi,nt as pi,o as mi,qt as hi}from"./model-BwBG0V1u.js";import{_t as gi,at as _i,bn as vi,it as yi,tn as bi,vn as xi,vt as Si,yt as Ci}from"./prompt-mM79EGnT.js";import{i as wi,n as Ti,r as Ei,t as Di}from"./reject-Bld5E-bn.js";import{h as Oi,m as ki}from"./firstPartyEventLogger-M6UMli2c.js";import{t as Ai}from"./pluginBlocklist-q01ackCf.js";import{n as ji,t as Mi}from"./toolPool-CX5wDBi1.js";import{n as Ni}from"./conversationRecovery-2ft8sCPE.js";import{a as Pi,i as Fi,n as Ii,r as Li}from"./QueryEngine-DYxBjJ4i.js";import{n as Ri,r as zi}from"./sessionTitle-k4wpUS5l.js";import{n as Bi,r as Vi}from"./sideQuestion-DLJxyrlp.js";import{a as Hi,n as Ui}from"./grove-O6qp7ITR.js";import{n as Wi,r as Gi}from"./context-noninteractive-Dd4xIoP1.js";import{n as Ki,r as qi}from"./modelOptions-DRaG3bo0.js";import{a as Ji,o as Yi,t as Xi}from"./skillChangeDetector-xviGstqm.js";import{n as Zi}from"./reconciler-CeXqh95g.js";import{n as Qi,t as $i}from"./refresh-Ce2yk28a.js";import{dirname as ea,join as ta}from"path";import{randomUUID as Y}from"crypto";import{readFile as na,stat as ra}from"fs/promises";import{cwd as X}from"process";rr(),nr();var ia=H(()=>P({inputTokens:z(),outputTokens:z(),cacheReadInputTokens:z(),cacheCreationInputTokens:z(),webSearchRequests:z(),costUSD:z(),contextWindow:z(),maxOutputTokens:z()})),aa=H(()=>R(`json_schema`));H(()=>P({type:aa()}));var oa=H(()=>P({type:R(`json_schema`),schema:B(V(),j())}));H(()=>oa());var sa=H(()=>M([`user`,`project`,`org`,`temporary`,`oauth`]));H(()=>M([`local`,`user`,`project`]).describe(`Config scope for settings.`)),H(()=>R(`context-1m-2025-08-07`));var ca=H(()=>P({type:R(`adaptive`)}).describe(`Work Mate decides when and how much to think (Opus 4.6+).`)),la=H(()=>P({type:R(`enabled`),budgetTokens:z().optional()}).describe(`Fixed thinking token budget (older models)`)),ua=H(()=>P({type:R(`disabled`)}).describe(`No extended thinking`));H(()=>I([ca(),la(),ua()]).describe(`Controls Work Mate's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var da=H(()=>P({type:R(`stdio`).optional(),command:V(),args:F(V()).optional(),env:B(V(),V()).optional()})),fa=H(()=>P({type:R(`sse`),url:V(),headers:B(V(),V()).optional()})),pa=H(()=>P({type:R(`http`),url:V(),headers:B(V(),V()).optional()})),ma=H(()=>P({type:R(`sdk`),name:V()})),ha=H(()=>I([da(),fa(),pa(),ma()])),ga=H(()=>P({type:R(`claudeai-proxy`),url:V(),id:V()})),_a=H(()=>I([ha(),ga()])),va=H(()=>P({name:V().describe(`Server name as configured`),status:M([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:P({name:V(),version:V()}).optional().describe(`Server information (available when connected)`),error:V().optional().describe(`Error message (available when status is 'failed')`),config:_a().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:V().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:F(P({name:V(),description:V().optional(),annotations:P({readOnly:N().optional(),destructive:N().optional(),openWorld:N().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:P({experimental:B(V(),j()).optional()}).optional().describe(`@internal Server capabilities (available when connected). experimental['claude/channel'] is only present if the server's plugin is on the approved channels allowlist — use its presence to decide whether to show an Enable-channel prompt.`)}).describe(`Status information for an MCP server connection.`));H(()=>P({added:F(V()).describe(`Names of servers that were added`),removed:F(V()).describe(`Names of servers that were removed`),errors:B(V(),V()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var ya=H(()=>M([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),ba=H(()=>M([`allow`,`deny`,`ask`])),xa=H(()=>P({toolName:V(),ruleContent:V().optional()})),Sa=H(()=>Zn(`type`,[P({type:R(`addRules`),rules:F(xa()),behavior:ba(),destination:ya()}),P({type:R(`replaceRules`),rules:F(xa()),behavior:ba(),destination:ya()}),P({type:R(`removeRules`),rules:F(xa()),behavior:ba(),destination:ya()}),P({type:R(`setMode`),mode:Xn(()=>wa()),destination:ya()}),P({type:R(`addDirectories`),directories:F(V()),destination:ya()}),P({type:R(`removeDirectories`),directories:F(V()),destination:ya()})])),Ca=H(()=>M([`user_temporary`,`user_permanent`,`user_reject`]).describe(`Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs).`));H(()=>I([P({behavior:R(`allow`),updatedInput:B(V(),j()).optional(),updatedPermissions:F(Sa()).optional(),toolUseID:V().optional(),decisionClassification:Ca().optional()}),P({behavior:R(`deny`),message:V(),interrupt:N().optional(),toolUseID:V().optional(),decisionClassification:Ca().optional()})]));var wa=H(()=>M([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).describe(`Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved. 'auto' - Automatic mode (transcript classifier).`)),Ta=`PreToolUse.PostToolUse.PostToolUseFailure.Notification.UserPromptSubmit.SessionStart.SessionEnd.Stop.StopFailure.SubagentStart.SubagentStop.PreCompact.PostCompact.PermissionRequest.PermissionDenied.Setup.TeammateIdle.TaskCreated.TaskCompleted.Elicitation.ElicitationResult.ConfigChange.WorktreeCreate.WorktreeRemove.InstructionsLoaded.CwdChanged.FileChanged`.split(`.`),Ea=H(()=>M(Ta)),Z=H(()=>P({session_id:V(),transcript_path:V(),cwd:V(),permission_mode:V().optional(),agent_id:V().optional().describe(`Subagent identifier. Present only when the hook fires from within a subagent (e.g., a tool called by an AgentTool worker). Absent for the main thread, even in --agent sessions. Use this field (not agent_type) to distinguish subagent calls from main-thread calls.`),agent_type:V().optional().describe(`Agent type name (e.g., "general-purpose", "code-reviewer"). Present when the hook fires from within a subagent (alongside agent_id), or on the main thread of a session started with --agent (without agent_id).`)})),Da=H(()=>Z().and(P({hook_event_name:R(`PreToolUse`),tool_name:V(),tool_input:j(),tool_use_id:V()}))),Oa=H(()=>Z().and(P({hook_event_name:R(`PermissionRequest`),tool_name:V(),tool_input:j(),permission_suggestions:F(Sa()).optional()}))),ka=H(()=>Z().and(P({hook_event_name:R(`PostToolUse`),tool_name:V(),tool_input:j(),tool_response:j(),tool_use_id:V()}))),Aa=H(()=>Z().and(P({hook_event_name:R(`PostToolUseFailure`),tool_name:V(),tool_input:j(),tool_use_id:V(),error:V(),is_interrupt:N().optional()}))),ja=H(()=>Z().and(P({hook_event_name:R(`PermissionDenied`),tool_name:V(),tool_input:j(),tool_use_id:V(),reason:V()}))),Ma=H(()=>Z().and(P({hook_event_name:R(`Notification`),message:V(),title:V().optional(),notification_type:V()}))),Na=H(()=>Z().and(P({hook_event_name:R(`UserPromptSubmit`),prompt:V()}))),Pa=H(()=>Z().and(P({hook_event_name:R(`SessionStart`),source:M([`startup`,`resume`,`clear`,`compact`]),agent_type:V().optional(),model:V().optional()}))),Fa=H(()=>Z().and(P({hook_event_name:R(`Setup`),trigger:M([`init`,`maintenance`])}))),Ia=H(()=>Z().and(P({hook_event_name:R(`Stop`),stop_hook_active:N(),last_assistant_message:V().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),La=H(()=>Z().and(P({hook_event_name:R(`StopFailure`),error:Fo(),error_details:V().optional(),last_assistant_message:V().optional()}))),Ra=H(()=>Z().and(P({hook_event_name:R(`SubagentStart`),agent_id:V(),agent_type:V()}))),za=H(()=>Z().and(P({hook_event_name:R(`SubagentStop`),stop_hook_active:N(),agent_id:V(),agent_transcript_path:V(),agent_type:V(),last_assistant_message:V().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Ba=H(()=>Z().and(P({hook_event_name:R(`PreCompact`),trigger:M([`manual`,`auto`]),custom_instructions:V().nullable()}))),Va=H(()=>Z().and(P({hook_event_name:R(`PostCompact`),trigger:M([`manual`,`auto`]),compact_summary:V().describe(`The conversation summary produced by compaction`)}))),Ha=H(()=>Z().and(P({hook_event_name:R(`TeammateIdle`),teammate_name:V(),team_name:V()}))),Ua=H(()=>Z().and(P({hook_event_name:R(`TaskCreated`),task_id:V(),task_subject:V(),task_description:V().optional(),teammate_name:V().optional(),team_name:V().optional()}))),Wa=H(()=>Z().and(P({hook_event_name:R(`TaskCompleted`),task_id:V(),task_subject:V(),task_description:V().optional(),teammate_name:V().optional(),team_name:V().optional()}))),Ga=H(()=>Z().and(P({hook_event_name:R(`Elicitation`),mcp_server_name:V(),message:V(),mode:M([`form`,`url`]).optional(),url:V().optional(),elicitation_id:V().optional(),requested_schema:B(V(),j()).optional()})).describe(`Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog.`)),Ka=H(()=>Z().and(P({hook_event_name:R(`ElicitationResult`),mcp_server_name:V(),elicitation_id:V().optional(),mode:M([`form`,`url`]).optional(),action:M([`accept`,`decline`,`cancel`]),content:B(V(),j()).optional()})).describe(`Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server.`)),qa=[`user_settings`,`project_settings`,`local_settings`,`policy_settings`,`skills`],Ja=H(()=>Z().and(P({hook_event_name:R(`ConfigChange`),source:M(qa),file_path:V().optional()}))),Ya=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Xa=[`User`,`Project`,`Local`,`Managed`],Za=H(()=>Z().and(P({hook_event_name:R(`InstructionsLoaded`),file_path:V(),memory_type:M(Xa),load_reason:M(Ya),globs:F(V()).optional(),trigger_file_path:V().optional(),parent_file_path:V().optional()}))),Qa=H(()=>Z().and(P({hook_event_name:R(`WorktreeCreate`),name:V()}))),$a=H(()=>Z().and(P({hook_event_name:R(`WorktreeRemove`),worktree_path:V()}))),eo=H(()=>Z().and(P({hook_event_name:R(`CwdChanged`),old_cwd:V(),new_cwd:V()}))),to=H(()=>Z().and(P({hook_event_name:R(`FileChanged`),file_path:V(),event:M([`change`,`add`,`unlink`])}))),no=[`clear`,`resume`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],ro=H(()=>M(no)),io=H(()=>Z().and(P({hook_event_name:R(`SessionEnd`),reason:ro()}))),ao=H(()=>I([Da(),ka(),Aa(),ja(),Ma(),Na(),Pa(),io(),Ia(),La(),Ra(),za(),Ba(),Va(),Oa(),Fa(),Ha(),Ua(),Wa(),Ga(),Ka(),Ja(),Za(),Qa(),$a(),eo(),to()])),oo=H(()=>P({async:R(!0),asyncTimeout:z().optional()})),so=H(()=>P({hookEventName:R(`PreToolUse`),permissionDecision:ba().optional(),permissionDecisionReason:V().optional(),updatedInput:B(V(),j()).optional(),additionalContext:V().optional()})),co=H(()=>P({hookEventName:R(`UserPromptSubmit`),additionalContext:V().optional()})),lo=H(()=>P({hookEventName:R(`SessionStart`),additionalContext:V().optional(),initialUserMessage:V().optional(),watchPaths:F(V()).optional()})),uo=H(()=>P({hookEventName:R(`Setup`),additionalContext:V().optional()})),fo=H(()=>P({hookEventName:R(`SubagentStart`),additionalContext:V().optional()})),po=H(()=>P({hookEventName:R(`PostToolUse`),additionalContext:V().optional(),updatedMCPToolOutput:j().optional()})),mo=H(()=>P({hookEventName:R(`PostToolUseFailure`),additionalContext:V().optional()})),ho=H(()=>P({hookEventName:R(`PermissionDenied`),retry:N().optional()})),go=H(()=>P({hookEventName:R(`Notification`),additionalContext:V().optional()})),_o=H(()=>P({hookEventName:R(`PermissionRequest`),decision:I([P({behavior:R(`allow`),updatedInput:B(V(),j()).optional(),updatedPermissions:F(Sa()).optional()}),P({behavior:R(`deny`),message:V().optional(),interrupt:N().optional()})])})),vo=H(()=>P({hookEventName:R(`CwdChanged`),watchPaths:F(V()).optional()})),yo=H(()=>P({hookEventName:R(`FileChanged`),watchPaths:F(V()).optional()})),bo=H(()=>P({continue:N().optional(),suppressOutput:N().optional(),stopReason:V().optional(),decision:M([`approve`,`block`]).optional(),systemMessage:V().optional(),reason:V().optional(),hookSpecificOutput:I([so(),co(),lo(),uo(),fo(),po(),mo(),ho(),go(),_o(),xo(),So(),vo(),yo(),Co()]).optional()})),xo=H(()=>P({hookEventName:R(`Elicitation`),action:M([`accept`,`decline`,`cancel`]).optional(),content:B(V(),j()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),So=H(()=>P({hookEventName:R(`ElicitationResult`),action:M([`accept`,`decline`,`cancel`]).optional(),content:B(V(),j()).optional()}).describe(`Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server.`)),Co=H(()=>P({hookEventName:R(`WorktreeCreate`),worktreePath:V()}).describe(`Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead.`));H(()=>I([oo(),bo()]));var wo=H(()=>P({key:V().describe(`Unique key for this option, returned in the response`),label:V().describe(`Display text for this option`),description:V().optional().describe(`Optional description shown below the label`)}));H(()=>P({prompt:V().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:V().describe(`The prompt message to display to the user`),options:F(wo()).describe(`Available options for the user to choose from`)})),H(()=>P({prompt_response:V().describe(`The request ID from the corresponding prompt request`),selected:V().describe(`The key of the selected option`)}));var To=H(()=>P({name:V().describe(`Skill name (without the leading slash)`),description:V().describe(`Description of what the skill does`),argumentHint:V().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),Eo=H(()=>P({name:V().describe(`Agent type identifier (e.g., "Explore")`),description:V().describe(`Description of when to use this agent`),model:V().optional().describe(`Model alias this agent uses. If omitted, inherits the parent's model`)}).describe(`Information about an available subagent that can be invoked via the Task tool.`)),Do=H(()=>P({value:V().describe(`Model identifier to use in API calls`),displayName:V().describe(`Human-readable display name`),description:V().describe(`Description of the model's capabilities`),supportsAdaptiveThinking:N().optional().describe(`Whether this model supports adaptive thinking (Work Mate decides when and how much to think)`),supportsFastMode:N().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:N().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),Oo=H(()=>P({email:V().optional(),organization:V().optional(),subscriptionType:V().optional(),tokenSource:V().optional(),apiKeySource:V().optional(),apiProvider:M([`firstParty`,`bedrock`,`vertex`,`foundry`]).optional().describe(`Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).`)}).describe(`Information about the logged in user's account.`)),ko=H(()=>I([V(),B(V(),ha())])),Ao=H(()=>P({description:V().describe(`Natural language description of when to use this agent`),tools:F(V()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:F(V()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:V().describe(`The agent's system prompt`),model:V().optional().describe(`Model alias (e.g. 'sonnet', 'opus', 'haiku') or full model ID (e.g. 'claude-opus-4-5'). If omitted or 'inherit', uses the main model`),mcpServers:F(ko()).optional(),criticalSystemReminder_EXPERIMENTAL:V().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:F(V()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:V().optional().describe(`Auto-submitted as the first user turn when this agent is the main thread agent. Slash commands are processed. Prepended to any user-provided prompt.`),maxTurns:z().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:N().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:M([`user`,`project`,`local`]).optional().describe(`Scope for auto-loading agent memory files. 'user' - ~/.workmate/agent-memory/<agentType>/, 'project' - .workmate/agent-memory/<agentType>/, 'local' - .workmate/agent-memory-local/<agentType>/`),permissionMode:wa().optional().describe(`Permission mode controlling how tool executions are handled`)}).describe(`Definition for a custom subagent that can be invoked via the Agent tool.`));H(()=>M([`user`,`project`,`local`]).describe(`Source for loading filesystem-based settings. 'user' - Global user settings (~/.workmate/settings.json). 'project' - Project settings (.workmate/settings.json). 'local' - Local settings (.workmate/settings.local.json).`)),H(()=>P({type:R(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:V().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),H(()=>P({canRewind:N(),error:V().optional(),filesChanged:F(V()).optional(),insertions:z().optional(),deletions:z().optional()}).describe(`Result of a rewindFiles operation.`));var jo=H(()=>j()),Mo=H(()=>j()),No=H(()=>j()),Q=H(()=>V()),Po=H(()=>j()),Fo=H(()=>M([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),Io=H(()=>I([R(`compacting`),er()])),Lo=H(()=>P({type:R(`user`),message:jo(),parent_tool_use_id:V().nullable(),isSynthetic:N().optional(),tool_use_result:j().optional(),priority:M([`now`,`next`,`later`]).optional(),timestamp:V().optional().describe(`ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.`)})),Ro=H(()=>Lo().extend({uuid:Q().optional(),session_id:V().optional()})),zo=H(()=>Lo().extend({uuid:Q(),session_id:V(),isReplay:R(!0)})),Bo=H(()=>P({status:M([`allowed`,`allowed_warning`,`rejected`]),resetsAt:z().optional(),rateLimitType:M([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:z().optional(),overageStatus:M([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:z().optional(),overageDisabledReason:M([`overage_not_provisioned`,`org_level_disabled`,`org_level_disabled_until`,`out_of_credits`,`seat_tier_level_disabled`,`member_level_disabled`,`seat_tier_zero_credit_limit`,`group_zero_credit_limit`,`member_zero_credit_limit`,`org_service_level_disabled`,`org_service_zero_credit_limit`,`no_limits_configured`,`unknown`]).optional(),isUsingOverage:N().optional(),surpassedThreshold:z().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),Vo=H(()=>P({type:R(`assistant`),message:Mo(),parent_tool_use_id:V().nullable(),error:Fo().optional(),uuid:Q(),session_id:V()})),Ho=H(()=>P({type:R(`rate_limit_event`),rate_limit_info:Bo(),uuid:Q(),session_id:V()}).describe(`Rate limit event emitted when rate limit info changes.`)),Uo=H(()=>P({type:R(`streamlined_text`),text:V().describe(`Text content preserved from the assistant message`),session_id:V(),uuid:Q()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),Wo=H(()=>P({type:R(`streamlined_tool_use_summary`),tool_summary:V().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:V(),uuid:Q()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),Go=H(()=>P({tool_name:V(),tool_use_id:V(),tool_input:B(V(),j())})),Ko=H(()=>P({type:R(`result`),subtype:R(`success`),duration_ms:z(),duration_api_ms:z(),is_error:N(),num_turns:z(),result:V(),stop_reason:V().nullable(),total_cost_usd:z(),usage:Po(),modelUsage:B(V(),ia()),permission_denials:F(Go()),structured_output:j().optional(),fast_mode_state:gs().optional(),uuid:Q(),session_id:V()})),qo=H(()=>P({type:R(`result`),subtype:M([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:z(),duration_api_ms:z(),is_error:N(),num_turns:z(),stop_reason:V().nullable(),total_cost_usd:z(),usage:Po(),modelUsage:B(V(),ia()),permission_denials:F(Go()),errors:F(V()),fast_mode_state:gs().optional(),uuid:Q(),session_id:V()})),Jo=H(()=>I([Ko(),qo()])),Yo=H(()=>P({type:R(`system`),subtype:R(`init`),agents:F(V()).optional(),apiKeySource:sa(),betas:F(V()).optional(),claude_code_version:V(),cwd:V(),tools:F(V()),mcp_servers:F(P({name:V(),status:V()})),model:V(),permissionMode:wa(),slash_commands:F(V()),output_style:V(),skills:F(V()),plugins:F(P({name:V(),path:V(),source:V().optional().describe(`@internal Plugin source identifier in "name\\@marketplace" format. Sentinels: "name\\@inline" for --plugin-dir, "name\\@builtin" for built-in plugins.`)})),fast_mode_state:gs().optional(),uuid:Q(),session_id:V()})),Xo=H(()=>P({type:R(`stream_event`),event:No(),parent_tool_use_id:V().nullable(),uuid:Q(),session_id:V()})),Zo=H(()=>P({type:R(`system`),subtype:R(`compact_boundary`),compact_metadata:P({trigger:M([`manual`,`auto`]),pre_tokens:z(),preserved_segment:P({head_uuid:Q(),anchor_uuid:Q(),tail_uuid:Q()}).optional().describe(`Relink info for messagesToKeep. Loaders splice the preserved segment at anchor_uuid (summary for suffix-preserving, boundary for prefix-preserving partial compact) so resume includes preserved content. Unset when compaction summarizes everything (no messagesToKeep).`)}),uuid:Q(),session_id:V()})),Qo=H(()=>P({type:R(`system`),subtype:R(`status`),status:Io(),permissionMode:wa().optional(),uuid:Q(),session_id:V()})),$o=H(()=>P({type:R(`system`),subtype:R(`post_turn_summary`),summarizes_uuid:V(),status_category:M([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:V(),is_noteworthy:N(),title:V(),description:V(),recent_action:V(),needs_action:V(),artifact_urls:F(V()),uuid:Q(),session_id:V()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),es=H(()=>P({type:R(`system`),subtype:R(`api_retry`),attempt:z(),max_retries:z(),retry_delay_ms:z(),error_status:z().nullable(),error:Fo(),uuid:Q(),session_id:V()}).describe(`Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response.`)),ts=H(()=>P({type:R(`system`),subtype:R(`local_command_output`),content:V(),uuid:Q(),session_id:V()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),ns=H(()=>P({type:R(`system`),subtype:R(`hook_started`),hook_id:V(),hook_name:V(),hook_event:V(),uuid:Q(),session_id:V()})),rs=H(()=>P({type:R(`system`),subtype:R(`hook_progress`),hook_id:V(),hook_name:V(),hook_event:V(),stdout:V(),stderr:V(),output:V(),uuid:Q(),session_id:V()})),is=H(()=>P({type:R(`system`),subtype:R(`hook_response`),hook_id:V(),hook_name:V(),hook_event:V(),output:V(),stdout:V(),stderr:V(),exit_code:z().optional(),outcome:M([`success`,`error`,`cancelled`]),uuid:Q(),session_id:V()})),as=H(()=>P({type:R(`tool_progress`),tool_use_id:V(),tool_name:V(),parent_tool_use_id:V().nullable(),elapsed_time_seconds:z(),task_id:V().optional(),uuid:Q(),session_id:V()})),os=H(()=>P({type:R(`auth_status`),isAuthenticating:N(),output:F(V()),error:V().optional(),uuid:Q(),session_id:V()})),ss=H(()=>P({type:R(`system`),subtype:R(`files_persisted`),files:F(P({filename:V(),file_id:V()})),failed:F(P({filename:V(),error:V()})),processed_at:V(),uuid:Q(),session_id:V()})),cs=H(()=>P({type:R(`system`),subtype:R(`task_notification`),task_id:V(),tool_use_id:V().optional(),status:M([`completed`,`failed`,`stopped`]),output_file:V(),summary:V(),usage:P({total_tokens:z(),tool_uses:z(),duration_ms:z()}).optional(),uuid:Q(),session_id:V()})),ls=H(()=>P({type:R(`system`),subtype:R(`task_started`),task_id:V(),tool_use_id:V().optional(),description:V(),task_type:V().optional(),workflow_name:V().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:V().optional(),uuid:Q(),session_id:V()})),us=H(()=>P({type:R(`system`),subtype:R(`session_state_changed`),state:M([`idle`,`running`,`requires_action`]),uuid:Q(),session_id:V()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),ds=H(()=>P({type:R(`system`),subtype:R(`task_progress`),task_id:V(),tool_use_id:V().optional(),description:V(),usage:P({total_tokens:z(),tool_uses:z(),duration_ms:z()}),last_tool_name:V().optional(),summary:V().optional(),uuid:Q(),session_id:V()})),fs=H(()=>P({type:R(`tool_use_summary`),summary:V(),preceding_tool_use_ids:F(V()),uuid:Q(),session_id:V()})),ps=H(()=>P({type:R(`system`),subtype:R(`elicitation_complete`),mcp_server_name:V(),elicitation_id:V(),uuid:Q(),session_id:V()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),ms=H(()=>P({type:R(`prompt_suggestion`),suggestion:V(),uuid:Q(),session_id:V()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));H(()=>P({sessionId:V().describe(`Unique session identifier (UUID).`),summary:V().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:z().describe(`Last modified time in milliseconds since epoch.`),fileSize:z().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:V().optional().describe(`User-set session title via /rename.`),firstPrompt:V().optional().describe(`First meaningful user prompt in the session.`),gitBranch:V().optional().describe(`Git branch at the end of the session.`),cwd:V().optional().describe(`Working directory for the session.`),tag:V().optional().describe(`User-set session tag.`),createdAt:z().optional().describe(`Creation time in milliseconds since epoch, extracted from the first entry's timestamp.`)}).describe(`Session metadata returned by listSessions and getSessionInfo.`));var hs=H(()=>I([Vo(),Ro(),zo(),Jo(),Yo(),Xo(),Zo(),Qo(),es(),ts(),ns(),rs(),is(),as(),os(),cs(),ls(),ds(),us(),ss(),fs(),Ho(),ps(),ms()])),gs=H(()=>M([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));rr(),nr();var _s=H(()=>j()),vs=H(()=>P({matcher:V().optional(),hookCallbackIds:F(V()),timeout:z().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),ys=H(()=>P({subtype:R(`initialize`),hooks:B(Ea(),F(vs())).optional(),sdkMcpServers:F(V()).optional(),jsonSchema:B(V(),j()).optional(),systemPrompt:V().optional(),appendSystemPrompt:V().optional(),agents:B(V(),Ao()).optional(),promptSuggestions:N().optional(),agentProgressSummaries:N().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));H(()=>P({commands:F(To()),agents:F(Eo()),output_style:V(),available_output_styles:F(V()),models:F(Do()),account:Oo(),pid:z().optional().describe(`@internal CLI process PID for tmux socket isolation`),fast_mode_state:gs().optional()}).describe(`Response from session initialization with available commands, models, and account info.`));var bs=H(()=>P({subtype:R(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),xs=H(()=>P({subtype:R(`can_use_tool`),tool_name:V(),input:B(V(),j()),permission_suggestions:F(Sa()).optional(),blocked_path:V().optional(),decision_reason:V().optional(),title:V().optional(),display_name:V().optional(),tool_use_id:V(),agent_id:V().optional(),description:V().optional()}).describe(`Requests permission to use a tool with the given input.`)),Ss=H(()=>P({subtype:R(`set_permission_mode`),mode:wa()}).describe(`Sets the permission mode for tool execution handling.`)),Cs=H(()=>P({subtype:R(`set_model`),model:V().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),ws=H(()=>P({subtype:R(`set_max_thinking_tokens`),max_thinking_tokens:z().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Ts=H(()=>P({subtype:R(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));H(()=>P({mcpServers:F(va())}).describe(`Response containing the current status of all MCP server connections.`));var Es=H(()=>P({subtype:R(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),Ds=H(()=>P({name:V(),tokens:z(),color:V(),isDeferred:N().optional()})),Os=H(()=>P({color:V(),isFilled:N(),categoryName:V(),tokens:z(),percentage:z(),squareFullness:z()}));H(()=>P({categories:F(Ds()),totalTokens:z(),maxTokens:z(),rawMaxTokens:z(),percentage:z(),gridRows:F(F(Os())),model:V(),memoryFiles:F(P({path:V(),type:V(),tokens:z()})),mcpTools:F(P({name:V(),serverName:V(),tokens:z(),isLoaded:N().optional()})),deferredBuiltinTools:F(P({name:V(),tokens:z(),isLoaded:N()})).optional(),systemTools:F(P({name:V(),tokens:z()})).optional(),systemPromptSections:F(P({name:V(),tokens:z()})).optional(),agents:F(P({agentType:V(),source:V(),tokens:z()})),slashCommands:P({totalCommands:z(),includedCommands:z(),tokens:z()}).optional(),skills:P({totalSkills:z(),includedSkills:z(),tokens:z(),skillFrontmatter:F(P({name:V(),source:V(),tokens:z()}))}).optional(),autoCompactThreshold:z().optional(),isAutoCompactEnabled:N(),messageBreakdown:P({toolCallTokens:z(),toolResultTokens:z(),attachmentTokens:z(),assistantMessageTokens:z(),userMessageTokens:z(),toolCallsByType:F(P({name:V(),callTokens:z(),resultTokens:z()})),attachmentsByType:F(P({name:V(),tokens:z()}))}).optional(),apiUsage:P({input_tokens:z(),output_tokens:z(),cache_creation_input_tokens:z(),cache_read_input_tokens:z()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var ks=H(()=>P({subtype:R(`rewind_files`),user_message_id:V(),dry_run:N().optional()}).describe(`Rewinds file changes made since a specific user message.`));H(()=>P({canRewind:N(),error:V().optional(),filesChanged:F(V()).optional(),insertions:z().optional(),deletions:z().optional()}).describe(`Result of a rewindFiles operation.`));var As=H(()=>P({subtype:R(`cancel_async_message`),message_uuid:V()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));H(()=>P({cancelled:N()}).describe(`Result of a cancel_async_message operation. cancelled=false means the message was not in the queue (already dequeued or never enqueued).`));var js=H(()=>P({subtype:R(`seed_read_state`),path:V(),mtime:z()}).describe(`Seeds the readFileState cache with a path+mtime entry. Use when a prior Read was removed from context (e.g. by snip) so Edit validation would fail despite the client having observed the Read. The mtime lets the CLI detect if the file changed since the seeded Read — same staleness check as the normal path.`)),Ms=H(()=>P({subtype:R(`hook_callback`),callback_id:V(),input:ao(),tool_use_id:V().optional()}).describe(`Delivers a hook callback with its input data.`)),Ns=H(()=>P({subtype:R(`mcp_message`),server_name:V(),message:_s()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),Ps=H(()=>P({subtype:R(`mcp_set_servers`),servers:B(V(),ha())}).describe(`Replaces the set of dynamically managed MCP servers.`));H(()=>P({added:F(V()),removed:F(V()),errors:B(V(),V())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var Fs=H(()=>P({subtype:R(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));H(()=>P({commands:F(To()),agents:F(Eo()),plugins:F(P({name:V(),path:V(),source:V().optional()})),mcpServers:F(va()),error_count:z()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var Is=H(()=>P({subtype:R(`mcp_reconnect`),serverName:V()}).describe(`Reconnects a disconnected or failed MCP server.`)),Ls=H(()=>P({subtype:R(`mcp_toggle`),serverName:V(),enabled:N()}).describe(`Enables or disables an MCP server.`)),Rs=H(()=>P({subtype:R(`stop_task`),task_id:V()}).describe(`Stops a running task.`)),zs=H(()=>P({subtype:R(`apply_flag_settings`),settings:B(V(),j())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),Bs=H(()=>P({subtype:R(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));H(()=>P({effective:B(V(),j()),sources:F(P({source:M([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:B(V(),j())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:P({model:V()}).optional().describe("Runtime-resolved values after env overrides, session state, and model-specific defaults are applied. Unlike `effective` (disk merge), these reflect what will actually be sent to the API.")}).describe(`Effective merged settings plus raw per-source settings in merge order.`));var Vs=H(()=>P({subtype:R(`elicitation`),mcp_server_name:V(),message:V(),mode:M([`form`,`url`]).optional(),url:V().optional(),elicitation_id:V().optional(),requested_schema:B(V(),j()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),Hs=H(()=>P({action:M([`accept`,`decline`,`cancel`]),content:B(V(),j()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),Us=H(()=>I([bs(),xs(),ys(),Ss(),Cs(),ws(),Ts(),Es(),Ms(),Ns(),ks(),As(),js(),Ps(),Fs(),Is(),Ls(),Rs(),zs(),Bs(),Vs()])),Ws=H(()=>P({type:R(`control_request`),request_id:V(),request:Us()})),Gs=H(()=>P({subtype:R(`success`),request_id:V(),response:B(V(),j()).optional()})),Ks=H(()=>P({subtype:R(`error`),request_id:V(),error:V(),pending_permission_requests:F(Xn(()=>Ws())).optional()})),qs=H(()=>P({type:R(`control_response`),response:I([Gs(),Ks()])})),Js=H(()=>P({type:R(`control_cancel_request`),request_id:V()}).describe(`Cancels a currently open control request.`)),Ys=H(()=>P({type:R(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),Xs=H(()=>P({type:R(`update_environment_variables`),variables:B(V(),V())}).describe(`Updates environment variables at runtime.`));H(()=>I([hs(),Uo(),Wo(),$o(),qs(),Ws(),Js(),Ys()])),H(()=>I([Ro(),Ws(),qs(),Ys(),Xs()])),n(),i(),ar(),vr(),br(),Er(),wr(),Gr(),jr(),Hn(),rr(),q(),nr(),Qt(),Je(),H(()=>L.object({tool_name:L.string().describe(`The name of the tool requesting permission`),input:L.record(L.string(),L.unknown()).describe(`The input for the tool`),tool_use_id:L.string().optional().describe(`The unique tool use request ID`)}));var Zs=H(()=>L.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),Qs=H(()=>L.object({behavior:L.literal(`allow`),updatedInput:L.record(L.string(),L.unknown()),updatedPermissions:L.array(C()).optional().catch(e=>{K(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:L.string().optional(),decisionClassification:Zs()})),$s=H(()=>L.object({behavior:L.literal(`deny`),message:L.string(),interrupt:L.boolean().optional(),toolUseID:L.string().optional(),decisionClassification:Zs()})),ec=H(()=>L.union([Qs(),$s()]));function tc(e,t,n,r){let i={type:`permissionPromptTool`,permissionPromptToolName:t.name,toolResult:e};if(e.behavior===`allow`){let t=e.updatedPermissions;t&&(r.setAppState(e=>({...e,toolPermissionContext:ce(e.toolPermissionContext,t)})),qt(t));let a=Object.keys(e.updatedInput).length>0?e.updatedInput:n;return{...e,updatedInput:a,decisionReason:i}}else e.behavior===`deny`&&e.interrupt&&(K(`SDK permission prompt deny+interrupt: tool=${t.name} message=${e.message}`),r.abortController.abort());return{...e,decisionReason:i}}gr(),Zr(),Xr(),Lr(),tr(),Nr(),Rr(),Ir(),xi(),bi(),gn(),b(),Wn(),un(),h(),wt(),Vn(),At(),ve(),Kt(),Bn(),an(),Ot(),wn(),dt(),E(),vt(),yt(),Kn(),on(),nt();var nc=/\u2028|\u2029/g;function rc(e){return e.replace(nc,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function ic(e){return rc(W(e))}q(),Er(),rr(),Qt();var ac=`SandboxNetworkAccess`;function oc(e){if(e){if(e.type===`classifier`)return e.reason;switch(e.type){case`rule`:case`mode`:case`subcommandResults`:case`permissionPromptTool`:return;case`hook`:case`asyncAgent`:case`sandboxOverride`:case`workingDir`:case`safetyCheck`:case`other`:return e.reason}}}function sc(e,t,n,r){let i;try{i=e.getActivityDescription?.(t)??e.getToolUseSummary?.(t)??e.userFacingName(t)}catch{i=e.name}return{tool_name:e.name,action_description:i,tool_use_id:n,request_id:r,input:t}}var cc=1e3,lc=class{constructor(e,t){a(this,`input`,void 0),a(this,`replayUserMessages`,void 0),a(this,`structuredInput`,void 0),a(this,`pendingRequests`,new Map),a(this,`restoredWorkerState`,Promise.resolve(null)),a(this,`inputClosed`,!1),a(this,`unexpectedResponseCallback`,void 0),a(this,`resolvedToolUseIds`,new Set),a(this,`prependedLines`,[]),a(this,`onControlRequestSent`,void 0),a(this,`onControlRequestResolved`,void 0),a(this,`outbound`,new Ct),this.input=e,this.replayUserMessages=t,this.input=e,this.structuredInput=this.read()}trackResolvedToolUseId(e){let t=e.request;if(t.subtype===`can_use_tool`&&(this.resolvedToolUseIds.add(t.tool_use_id),this.resolvedToolUseIds.size>cc)){let e=this.resolvedToolUseIds.values().next().value;e!==void 0&&this.resolvedToolUseIds.delete(e)}}flushInternalEvents(){return Promise.resolve()}get internalEventsPending(){return 0}prependUserMessage(e){this.prependedLines.push(`${W({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})}\n`)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
|
|
2
|
-
`);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&(Ar(`info`,`cli_stdin_message_parsed`,{type:r.type}),yield r)}}.bind(this);yield*t();for await(let n of this.input)e+=n,yield*t();if(e){let t=await this.processLine(e);t&&(yield t)}this.inputClosed=!0;for(let e of this.pendingRequests.values())e.reject(Error(`Tool permission stream closed before response received`))}getPendingPermissionRequests(){return Array.from(this.pendingRequests.values()).map(e=>e.request).filter(e=>e.request.subtype===`can_use_tool`)}setUnexpectedResponseCallback(e){this.unexpectedResponseCallback=e}injectControlResponse(e){let t=e.response,n=t?.request_id;if(!n)return;let r=this.pendingRequests.get(n);if(r)if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n),this.write({type:`control_cancel_request`,request_id:n}),t.subtype===`error`)r.reject(Error(t.error));else{let e=t.response;if(r.schema)try{r.resolve(r.schema.parse(e))}catch(e){r.reject(e)}else r.resolve({})}}setOnControlRequestSent(e){this.onControlRequestSent=e}setOnControlRequestResolved(e){this.onControlRequestResolved=e}async processLine(e){if(e)try{let t=xr(e);if(t.type===`keep_alive`)return;if(t.type===`update_environment_variables`){let e=t.variables??{},n=Object.keys(e);for(let[t,n]of Object.entries(e))process.env[t]=n;K(`[structuredIO] applied update_environment_variables: ${n.join(`, `)}`);return}if(t.type===`control_response`){let e=`uuid`in t&&typeof t.uuid==`string`?t.uuid:void 0;e&&Tn(e,`completed`);let n=t.response,r=this.pendingRequests.get(n.request_id);if(!r){let e=(n.subtype===`success`?n.response:void 0)?.toolUseID;if(typeof e==`string`&&this.resolvedToolUseIds.has(e)){K(`Ignoring duplicate control_response for already-resolved toolUseID=${e} request_id=${n.request_id}`);return}this.unexpectedResponseCallback&&await this.unexpectedResponseCallback(t);return}if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n.request_id),r.request.request.subtype===`can_use_tool`&&this.onControlRequestResolved&&this.onControlRequestResolved(n.request_id),n.subtype===`error`){r.reject(Error(n.error??`Unknown error`));return}let i=n.response;if(r.schema)try{r.resolve(r.schema.parse(i))}catch(e){r.reject(e)}else r.resolve({});return this.replayUserMessages?t:void 0}if(t.type!==`user`&&t.type!==`control_request`&&t.type!==`assistant`&&t.type!==`system`){K(`Ignoring unknown message type: ${t.type}`,{level:`warn`});return}return t.type===`control_request`?(t.request||uc(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&uc(`Error: Expected message role 'user', got '${t.message?.role}'`),t)}catch(t){console.error(`Error parsing streaming input line: ${e}: ${t}`),process.exit(1)}}async write(e){Kr(`${ic(e)}\n`)}async sendRequest(e,t,n,r=Y()){let i={type:`control_request`,request_id:r,request:e};if(this.inputClosed)throw Error(`Stream closed`);if(n?.aborted)throw Error(`Request aborted`);this.outbound.enqueue(i),e.subtype===`can_use_tool`&&this.onControlRequestSent&&this.onControlRequestSent(i);let a=()=>{this.outbound.enqueue({type:`control_cancel_request`,request_id:r});let e=this.pendingRequests.get(r);e&&(this.trackResolvedToolUseId(e.request),e.reject(new yr))};n&&n.addEventListener(`abort`,a,{once:!0});try{return await new Promise((n,i)=>{this.pendingRequests.set(r,{request:{type:`control_request`,request_id:r,request:e},resolve:e=>{n(e)},reject:i,schema:t})})}finally{n&&n.removeEventListener(`abort`,a),this.pendingRequests.delete(r)}}createCanUseTool(e){return async(t,n,r,i,a,o)=>{let s=o??await _(t,n,r,i,a);if(s.behavior===`allow`||s.behavior===`deny`)return s;let c=new AbortController,l=r.abortController.signal,u=()=>c.abort();l.addEventListener(`abort`,u,{once:!0});try{let i=dc(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=Y();e?.(sc(t,n,a,o));let l=this.sendRequest({subtype:`can_use_tool`,tool_name:t.name,input:n,permission_suggestions:s.suggestions,blocked_path:s.blockedPath,decision_reason:oc(s.decisionReason),tool_use_id:a,agent_id:r.agentId},ec(),c.signal,o).then(e=>({source:`sdk`,result:e})),u=await Promise.race([i,l]);return u.source===`hook`?u.decision?(l.catch(()=>{}),c.abort(),u.decision):tc((await l).result,t,n,r):tc(u.result,t,n,r)}catch(e){return tc({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&pe(`running`),l.removeEventListener(`abort`,u)}}}createHookCallback(e,t){return{type:`callback`,timeout:t,callback:async(t,n,r)=>{try{return await this.sendRequest({subtype:`hook_callback`,callback_id:e,input:t,tool_use_id:n||void 0},Et(),r)}catch(t){return console.error(`Error in hook callback ${e}:`,t),{}}}}}async handleElicitation(e,t,n,r,i,a,o){try{return await this.sendRequest({subtype:`elicitation`,mcp_server_name:e,message:t,mode:i,url:a,elicitation_id:o,requested_schema:n},Hs(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:ac,input:{host:e.host},tool_use_id:Y(),description:`Allow network connection to ${e.host}?`},ec())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},P({mcp_response:Qn()}))).mcp_response}};function uc(e){console.error(e),process.exit(1)}async function dc(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=v(e,t,n,r,a,i,r.abortController.signal);for await(let e of o)if(e.permissionRequestResult&&(e.permissionRequestResult.behavior===`allow`||e.permissionRequestResult.behavior===`deny`)){let t=e.permissionRequestResult;if(t.behavior===`allow`){let e=t.updatedInput||n,i=t.updatedPermissions??[];if(i.length>0){qt(i);let e=ce(r.getAppState().toolPermissionContext,i);r.setAppState(t=>t.toolPermissionContext===e?t:{...t,toolPermissionContext:e})}return{behavior:`allow`,updatedInput:e,userModified:!1,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}else return{behavior:`deny`,message:t.message||`Permission denied by PermissionRequest hook`,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}}gi(),Or(),Ci(),[...Si],q();var fc=`[stdout-guard]`,pc=!1,$=``,mc=null;function hc(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function gc(){pc||(pc=!0,mc=process.stdout.write.bind(process.stdout),process.stdout.write=((e,t,n)=>{let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);$+=r;let i,a=!0;for(;(i=$.indexOf(`
|
|
3
|
-
`))!==-1;){let e=$.slice(0,i);$=$.slice(i+1),hc(e)?a=mc(`${e}\n`):(process.stderr.write(`${fc} ${e}\n`),K(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a}),Cr(async()=>{$.length>0&&(mc&&hc($)?mc(`${$}\n`):process.stderr.write(`${fc} ${$}\n`),$=``),mc&&(process.stdout.write=mc,mc=null),pc=!1}))}Hr(),Me(),Ie(),w(),zt(),le(),_i(),ue(),Ye(),D(),tn(),fe(),dn(),Mi(),q(),br(),gr(),br(),Xr(),ke(),q();function _c(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&&(K(`Exiting after ${n}ms of idle time`),A())},n))},stop(){i&&(clearTimeout(i),i=null)}}}si(),pi(),ti(),li(),Ei(),Di(),o(),Ve(),O(),tt(),De(),$t(),Xt(),St(),zi(),Bi();function vc(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Y(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(Te(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}hi(),y(),ht(),c(),Rn(),Ut(),kn(),en(),bt(),Be(),at(),It(),Gi(),qi(),q(),Er();async function yc(){try{let e=await na(Ue(),`utf-8`),t=Vr().safeParse(xr(e));return t.success?t.data:(K(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function bc(e){await ze(Ue(),W(e,null,2))}async function xc(e,t){let n=Ee();if(!n)return;let r=await Sc(t);r!==null&&await ze(ta(n,T(e)),r)}async function Sc(e){let t=[ta(e,`.claude-plugin`,`marketplace.json`),ta(e,`marketplace.json`),e];for(let e of t)try{return await na(e,`utf-8`)}catch{}return null}async function Cc(){let e=await kt();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await xc(t,n.installLocation)}catch(e){K(`Failed to save marketplace JSON for ${t}: ${e}`)}await bc({...await yc(),...e})}Qr(),vr(),q(),jr(),Xr(),tn(),D();async function wc(){let e=et();K(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await sn();t&&(Wt(),Gt(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Tr().mkdir(Jn()),await Tr().mkdir(ne()));let n=Object.keys(xt()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)K(`installPluginsForHeadless: no marketplaces declared`);else{let t=await Mr(`headless_marketplace_reconcile`,()=>Zi({skip:e?(e,t)=>!ge(t):void 0,onProgress:e=>{e.type===`installed`?K(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&K(`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&&K(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(Wt(),Gt(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await Cc();let t=await Ai();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&Gt(`headlessPluginInstall: plugins changed`),e&&Cr(me),i}catch(e){return J(e),!1}finally{$r(`tengu_headless_plugin_install`,r)}}Dr(),Qr(),q(),jr(),At(),Kt(),Xr(),Gr(),ve(),vt(),vr(),gr(),nt(),on(),dt(),Er(),$i(),fe(),_t(),Vt(),qn(),br(),ki();var Tc=1e4,Ec=new Set,Dc=[];function Oc(e){if(Ec.has(e))return!1;if(Ec.add(e),Dc.push(e),Dc.length>Tc){let e=Dc.splice(0,Dc.length-Tc);for(let t of e)Ec.delete(t)}return!0}function kc(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Ac(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
|
|
4
|
-
`):e.flatMap(kc)}function jc(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function Mc(e,n,r,i,a,o,s,c){if(Fn.subscribe(e=>{re(e,r),ei()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),!ut()&&t(process.env.CLAUDE_CODE_PROACTIVE)&&rt(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),ft(),k(`runHeadless_entry`),await Hi()&&await Ui(),k(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
5
|
-
`),A(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
6
|
-
`),A(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
7
|
-
`),A(1);return}let u=Hc(e,c);c.outputFormat===`stream-json`&&gc();let d=Ft.getSandboxUnavailableReason();if(d){if(Ft.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${d}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),A(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${d}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(Ft.isSandboxingEnabled())try{await Ft.initialize(u.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${G(e)}\n`),A(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&rn(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:U()};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:U()};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:U()}}})();u.write(t)}),c.setupTrigger&&await jt(c.setupTrigger),k(`before_loadInitialMessages`);let p=n(),{messages:m,turnInterruptionState:h,agentSetting:g}=await Vc(r,{continue:c.continue,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:u.restoredWorkerState}),ee=En();if(ee&&u.prependUserMessage(ee),!c.agent&&!ir()&&g){let{agentDefinition:e}=Ji(g,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!xn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}f(e.agentType)}}if(m.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){if(m.find(e=>e.uuid===c.rewindFiles)?.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),A(1);return}let e=n(),t=await Lc(c.rewindFiles,e,r,!1);if(!t.canRewind){process.stderr.write(`Error: ${t.error||`Unexpected error`}\n`),A(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),A(0);return}let _=typeof c.resume==`string`&&(!!Te(c.resume)||c.resume.endsWith(`.jsonl`)),te=!!c.sdkUrl;if(!e&&!_&&!te){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
|
|
8
|
-
`),A(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
9
|
-
`),A(1);return}let ne=x(p.mcp.tools,p.toolPermissionContext),v=[...a,...ne],y=Fc(c.sdkUrl?`stdio`:c.permissionPromptToolName,u,()=>n().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),pe(`requires_action`,e)});c.permissionPromptToolName&&(v=v.filter(e=>!vi(e,c.permissionPromptToolName))),Wr(),k(`after_loadInitialMessages`),await ui(),k(`after_modelStrings`);let ie=c.outputFormat===`json`&&c.verbose,b=[],S;k(`before_runHeadlessStreaming`);for await(let e of Nc(u,p.mcp.clients,[...i,...p.mcp.commands],v,m,y,o,n,r,s,c,h))c.outputFormat===`stream-json`&&c.verbose&&await u.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`&&(ie&&b.push(e),S=e);switch(c.outputFormat){case`json`:if(S?.type!==`result`)throw Error(`No messages returned`);if(c.verbose){Kr(`${W(b)}\n`);break}Kr(`${W(S)}\n`);break;case`stream-json`:break;default:if(S?.type!==`result`)throw Error(`No messages returned`);switch(S.subtype){case`success`:Kr(S.result.endsWith(`
|
|
10
|
-
`)?S.result:`${S.result}\n`);break;case`error_during_execution`:Kr(`Execution error`);break;case`error_max_turns`:Kr(`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`:Kr(`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`:Kr(`Error: Failed to provide valid structured output after maximum retries.
|
|
11
|
-
Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(l(),Ur())try{let{drainPendingExtraction:e}=await import(`./extractMemories-xP63mv6R.js`);await e()}catch{}A(S?.type===`result`&&S?.is_error?1:0)}function Nc(n,i,a,o,c,u,d,f,m,h,_,ne){let re=!1,v,y=!1,ie=null,b,x=n.outbound;process.on(`SIGINT`,()=>{Ar(`info`,`shutdown_signal`,{signal:`SIGINT`}),b&&!b.signal.aborted&&b.abort(),Bt(0)}),Cr(async()=>{let e={};for(let t of Lt(f()))Rt(t)&&(e[t.type]=(e[t.type]??0)+1);Ar(`info`,`run_state_at_shutdown`,{run_active:re,run_phase:v,worker_status:g(),internal_events_pending:n.internalEventsPending,bg_tasks:e})}),be(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:U()})});let C={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ce=e=>{let t=Fi(e);t&&x.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:U()})};Ge.add(ce);let w=c,le=Dt(c,X(),100),ue=Ze(100),fe=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;ne&&ne.kind!==`none`&&fe&&(K(`[print.ts] Auto-resuming interrupted turn (kind: ${ne.kind})`),Bc(w,ne.message),In({mode:`prompt`,value:ne.message.message.content,uuid:Y()}));let me=Ki().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?fi():ci(t),r=Ce(n),i=ri(e.value),a=s(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),ge=_.userSpecifiedModel;function ve(e,t){let n=Cn(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:U(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let T=[],Te=[],Ee=new Set;function De(e){for(let t of e){if(t.type!==`connected`||Ee.has(t.name)||t.config.type===`sdk`)continue;let e=t.name;try{t.client.setRequestHandler(oe,async(t,r)=>{Jr(e,`Elicitation request received in print mode: ${W(t)}`);let i=t.params.mode===`url`?`url`:`form`;$r(`tengu_mcp_elicitation_shown`,{mode:i});let a=await p(e,t.params,r.signal);if(a)return Jr(e,`Elicitation resolved by hook: ${W(a)}`),$r(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in t.params?t.params.url:void 0,s=`requestedSchema`in t.params?t.params.requestedSchema:void 0,c=`elicitationId`in t.params?t.params.elicitationId:void 0,l=await n.handleElicitation(e,t.params.message,s,r.signal,i,o,c),u=await Nt(e,l,r.signal,i,c);return $r(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),t.client.setNotificationHandler($e,t=>{let{elicitationId:n}=t.params;Jr(e,`Elicitation completion notification: ${n}`),Yn({message:`MCP server "${e}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),x.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:e,elicitation_id:n,uuid:Y(),session_id:U()})}),Ee.add(e)}catch{}}}async function ke(){let e=new Set(Object.keys(d)),t=new Set(T.map(e=>e.name)),r=Array.from(e).some(e=>!t.has(e)),i=Array.from(t).some(t=>!e.has(t)),a=T.some(e=>e.type===`pending`),o=T.some(e=>e.type===`failed`);if(r||i||a||o){for(let t of T)e.has(t.name)||t.type===`connected`&&await t.cleanup();let r=await ln(d,(e,t)=>n.sendMcpMessage(e,t));T=r.clients,Te=r.tools;let i=kr([...t,...e]);m(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(zr(t)))),...Te]}})),Qe(T)}}ke();let E={clients:[],tools:[],configs:{}},Me=e=>{let t=Ke(e.toolPermissionContext,e.mcp.tools),n=Yt(ji([...o,...Te,...E.tools],t,e.toolPermissionContext.mode),`name`);_.permissionPromptToolName&&(n=n.filter(e=>!vi(e,_.permissionPromptToolName)));let r=pr();if(r&&!_.jsonSchema){let e=yi(r);`tool`in e&&(n=[...n,e.tool])}return n},Ne=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Ie(e){let t=async()=>{let t=new Set(T.map(e=>e.name)),n=await Gc(e,{configs:d,clients:T,tools:Te},E,m);for(let e of Object.keys(d))delete d[e];if(Object.assign(d,n.newSdkState.configs),T=n.newSdkState.clients,Te=n.newSdkState.tools,E=n.newDynamicState,n.sdkServersChanged){let e=new Set(T.map(e=>e.name)),n=kr([...t,...e]);m(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(zr(t)))),...Te]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ne=Ne.then(t,t),Ne}function ze(){let e=f(),t=e.mcp.clients,n=Yt([...e.mcp.tools,...E.tools],`name`),r=new Set([...t.map(e=>e.name),...T.map(e=>e.name)]);return[...t,...T,...E.clients.filter(e=>!r.has(e.name))].map(e=>{let t;if(e.config.type===`sse`||e.config.type===`http`)t={type:e.config.type,url:e.config.url,headers:e.config.headers};else if(e.config.type===`claudeai-proxy`)t={type:`claudeai-proxy`,url:e.config.url,id:e.config.id};else if(e.config.type===`stdio`||e.config.type===void 0){let n=e.config;t={type:`stdio`,command:n.command,args:n.args}}let r=e.type===`connected`?hn(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 Be(){try{await wc()&&await Xe()}catch(e){J(e)}}let Ve=null;r()||(t(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Ve=Be():Be());let He=_c(()=>!re),Ue=a,Je=h;async function Ye(){let{agentDefinitions:e}=await Qi(m);Ue=await Fe(X());let t=Je.filter(e=>e.source===`flagSettings`);Je=[...e.allAgents,...t]}async function Xe(){let{servers:e}=await ae(),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(d))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await Ie(t);r&&ke(),K(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let et=Xi.subscribe(()=>{Ln(),Fe(X()).then(e=>{Ue=e})}),tt=()=>{setTimeout(()=>{!ut()||ot()||y||(async()=>{let e=await fn({basePrompt:`<${qr}>${new Date().toLocaleTimeString()}</${qr}>`,currentDir:X(),shouldCreate:()=>!y});if(y){await cn({commands:e});return}for(let t of e)In({...t,uuid:Y()});nt()})().catch(e=>{J(e),K(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};ye(()=>{b&&Pe(`now`).length>0&&b.abort(`interrupt`)});let nt=async()=>{if(re)return;if(re=!0,v=void 0,pe(`running`),He.stop(),k(`run_entry`),await ke(),k(`after_updateSdkMcp`),Ve){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=Oi(e).then(()=>`timeout`);await Promise.race([Ve,t])===`timeout`&&(J(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),$r(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await Ve;Ve=null,await Ye();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-C_msxVIc.js`);t()}let t=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=qe(t);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;jc(r,Ae(t));)i.push(qe(t));let a=await vn(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Ac(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(_.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:U(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=f(),c=[...s.mcp.clients,...T,...E.clients];De(c);let d=Me(s);for(let e of o)Tn(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:U(),uuid:Y()})}let p=r.value,h=a.claimedCommands;if(C.abortController?.abort(),C.abortController=null,C.pendingSuggestion=null,C.pendingLastEmittedEntry=null,C.lastEmitted&&r.mode===`prompt`){let e=typeof p==`string`?p:p.find(e=>e.type===`text`)?.text;typeof e==`string`&&ee(C.lastEmitted.text,e,C.lastEmitted.emittedAt,C.lastEmitted.promptId,C.lastEmitted.generationRequestId),C.lastEmitted=null}b=On(),k(`before_ask`),Gn();let g=r,te=!1;try{if(await ni(g.workload??_.workload,async()=>{for await(let e of Ii({commands:Yt([...Ue,...s.mcp.commands],`name`),prompt:p,promptUuid:g.uuid,isMeta:g.isMeta,cwd:X(),tools:d,verbose:_.verbose,mcpClients:c,thinkingConfig:_.thinkingConfig,maxTurns:_.maxTurns,maxBudgetUsd:_.maxBudgetUsd,taskBudget:_.taskBudget,canUseTool:u,userSpecifiedModel:ge,fallbackModel:_.fallbackModel,jsonSchema:pr()??_.jsonSchema,mutableMessages:w,getReadFileCache:()=>ue.size===0?le:se(le,ue),setReadFileCache:e=>{le=e;for(let[e,t]of ue.entries()){let n=le.get(e);(!n||t.timestamp>n.timestamp)&&le.set(e,t)}ue.clear()},customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt,getAppState:f,setAppState:m,abortController:b,replayUserMessages:_.replayUserMessages,includePartialMessages:_.includePartialMessages,handleElicitation:(e,t,r)=>n.handleElicitation(e,t.message,void 0,r,t.mode,t.url,`elicitationId`in t?t.elicitationId:void 0),agents:Je,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{x.enqueue({type:`system`,subtype:`status`,status:e,session_id:U(),uuid:Y()})}}))if(e.type===`result`){te=!!e.is_error;for(let e of jn())x.enqueue(e);Lt(f()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Rt(e))?ie=e:(ie=null,x.enqueue(e))}else{for(let e of jn())x.enqueue(e);x.enqueue(e)}}),te)await Ht({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:g.workload??_.workload});else{let e=await Ht({commands:h,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:g.workload??_.workload});for(let t of e)In({...t,uuid:Y()})}}catch(e){throw await Ht({commands:h,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:g.workload??_.workload}),e}for(let e of o)Tn(e,`completed`);if(_.promptSuggestions&&!e(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){C.abortController?.abort();let e=new AbortController;C.abortController=e;let t=_e();if(!t)Jt(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await je(e,w,f,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:U()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};ie?(C.pendingSuggestion=r,C.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(C.lastEmitted=i,x.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){Jt(`aborted`,void 0,void 0,`sdk`);return}J(Sr(e))}finally{C.inflightPromise===n.promise&&(C.inflightPromise=null)}})(),C.inflightPromise=n.promise}}l(),gt(),ft()}};do{for(let e of jn())x.enqueue(e);v=`draining_commands`,await a(),i=!1;{let e=Lt(f()).some(e=>Rt(e)),n=Ae(t)!==void 0;(e||n)&&(i=!0,n||(v=`waiting_for_agents`,await Oi(100)))}}while(i);ie&&(x.enqueue(ie),ie=null,C.pendingSuggestion&&(x.enqueue(C.pendingSuggestion),C.pendingLastEmittedEntry&&(C.lastEmitted={...C.pendingLastEmittedEntry,emittedAt:Date.now()},C.pendingLastEmittedEntry=null),C.pendingSuggestion=null))}catch(e){try{await n.write({type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:U(),total_cost_usd:0,usage:Sn,modelUsage:{},permission_denials:[],uuid:Y(),errors:[G(e),...Yr().map(e=>e.error)]})}catch{}C.abortController?.abort(),A(1);return}finally{if(v=`finally_flush`,await n.flushInternalEvents(),v=`finally_post_flush`,!Mn()){pe(`idle`);for(let e of jn())x.enqueue(e)}re=!1,He.start()}if(ut()&&!ot()&&Ae(t)===void 0&&!y){tt();return}if(Ae(t)!==void 0){nt();return}y&&(C.inflightPromise&&await Promise.race([C.inflightPromise,Oi(5e3)]),C.abortController?.abort(),C.abortController=null,await pn(),et(),Ge.delete(ce),x.done())},D=(e,t)=>{x.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},O=(e,t)=>{x.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},it=new Set;return n.setUnexpectedResponseCallback(async e=>{await Uc({message:e,setAppState:m,handledToolUseIds:it,onEnqueued:()=>{nt()}})}),(async()=>{let e=!1;Ar(`info`,`cli_message_loop_started`);for await(let t of n.structuredInput){let r=`uuid`in t?t.uuid:void 0;if(r&&t.type!==`user`&&t.type!==`control_response`&&Tn(r,`completed`),t.type===`control_request`){let r=t,o=r.request;if(r.request.subtype===`interrupt`)m(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),b&&b.abort(),C.abortController?.abort(),C.abortController=null,C.lastEmitted=null,C.pendingSuggestion=null,D(r);else if(o.subtype===`end_session`){K(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),b&&b.abort(),C.abortController?.abort(),C.abortController=null,C.lastEmitted=null,C.pendingSuggestion=null,D(r);break}else if(r.request.subtype===`initialize`){if(r.request.sdkMcpServers&&r.request.sdkMcpServers.length>0)for(let e of r.request.sdkMcpServers)d[e]={type:`sdk`,name:e};await Ic(r.request,r.request_id,e,x,a,me,n,_,h,f),r.request.promptSuggestions&&m(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),r.request.agentProgressSummaries&&sr(!0),e=!0,Zt()&&nt()}else if(r.request.subtype===`set_permission_mode`){let e=r.request;m(t=>({...t,toolPermissionContext:Rc(e,r.request_id,t.toolPermissionContext,x)}))}else if(r.request.subtype===`set_model`){let e=r.request.model??`default`,t=e==="default"?fi():e;ge=t,ur(t),Re({model:t}),ve(e,t),D(r)}else if(r.request.subtype===`set_max_thinking_tokens`)r.request.max_thinking_tokens===null?_.thinkingConfig=void 0:r.request.max_thinking_tokens===0?_.thinkingConfig={type:`disabled`}:_.thinkingConfig={type:`enabled`,budgetTokens:r.request.max_thinking_tokens},D(r);else if(r.request.subtype===`mcp_status`)D(r,{mcpServers:ze()});else if(r.request.subtype===`get_context_usage`)try{let e=f(),t=await Wi({messages:w,getAppState:f,options:{mainLoopModel:mi(),tools:Me(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt}});D(r,{...t})}catch(e){O(r,G(e))}else if(r.request.subtype===`mcp_message`){let e=r.request,t=T.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),D(r)}else if(r.request.subtype===`rewind_files`){let e=f(),t=await Lc(r.request.user_message_id,e,m,r.request.dry_run??!1);t.canRewind||r.request.dry_run?D(r,t):O(r,t.error??`Unexpected error`)}else if(r.request.subtype===`cancel_async_message`){let e=r.request.message_uuid,t=S(t=>t.uuid===e);D(r,{cancelled:t.length>0})}else if(r.request.subtype===`seed_read_state`){try{let e=Fr(r.request.path),t=Math.floor((await ra(e)).mtimeMs);if(t<=r.request.mtime){let n=await na(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
|
|
12
|
-
`,`
|
|
13
|
-
`);ue.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}D(r)}else if(r.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Ie(r.request.servers);D(r,e),t&&ke()}else if(r.request.subtype===`reload_plugins`)try{let e=await Qi(m),t=Je.filter(e=>e.source===`flagSettings`);Je=[...e.agentDefinitions.allAgents,...t];let n=[],[i,a,o]=await Promise.allSettled([Fe(X()),Xe(),we()]);i.status===`fulfilled`?Ue=i.value:J(i.reason),a.status===`rejected`&&J(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):J(o.reason),D(r,{commands:Ue.filter(e=>e.userInvocable!==!1).map(e=>({name:Le(e),description:de(e),argumentHint:e.argumentHint||``})),agents:Je.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:ze(),error_count:e.error_count})}catch(e){O(r,G(e))}else if(r.request.subtype===`mcp_reconnect`){let e=f(),{serverName:t}=r.request;Ee.delete(t);let n=zn(t)??i.find(e=>e.name===t)?.config??T.find(e=>e.name===t)?.config??E.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)O(r,`Server not found: ${t}`);else{let e=await Dn(t,n),i=zr(t);if(m(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...Ti(n.mcp.tools,e=>e.name?.startsWith(i)),...e.tools],commands:[...Ti(n.mcp.commands,e=>bn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:wi(n.mcp.resources,t)}})),E={...E,clients:[...E.clients.filter(e=>e.name!==t),e.client],tools:[...E.tools.filter(e=>!e.name?.startsWith(i)),...e.tools]},e.client.type===`connected`)De([e.client]),D(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;O(r,t)}}}else if(r.request.subtype===`mcp_toggle`){let e=f(),{serverName:t,enabled:n}=r.request;Ee.delete(t);let a=zn(t)??i.find(e=>e.name===t)?.config??T.find(e=>e.name===t)?.config??E.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)O(r,`Server not found: ${t}`);else if(n){Oe(t,!0);let e=await Dn(t,a),n=zr(t);if(m(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...Ti(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...Ti(r.mcp.commands,e=>bn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:wi(r.mcp.resources,t)}})),e.client.type===`connected`)De([e.client]),D(r);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;O(r,t)}}else{Oe(t,!1);let n=[...i,...T,...E.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await xe(t,a);let o=zr(t);m(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:Ti(e.mcp.tools,e=>e.name?.startsWith(o)),commands:Ti(e.mcp.commands,e=>bn(e,t)),resources:wi(e.mcp.resources,t)}})),D(r)}}else if(r.request.subtype===`apply_flag_settings`){let e=mi(),t=mr()??{},n=r.request.settings,i={...t,...n};for(let e of Object.keys(i))i[e]===null&&delete i[e];fr(i),Fn.notifyChange(`flagSettings`),`model`in n&&(n.model==null?ur(void 0):ur(String(n.model)));let a=mi();if(a!==e){ge=a;let e=n.model?String(n.model):`default`;Re({model:a}),ve(e,a)}D(r)}else if(r.request.subtype===`get_settings`){let e=mi();D(r,{...Br(),applied:{model:e}})}else if(r.request.subtype===`stop_task`){let{task_id:e}=r.request;try{await te(e,{getAppState:f,setAppState:m}),D(r,{})}catch(e){O(r,G(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(b&&!b.signal.aborted?b:On()).signal;(async()=>{try{let i=await Ri(e,n);if(i&&t)try{Mt(U(),i)}catch(e){J(e)}D(r,{title:i})}catch(e){O(r,G(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=_e(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:On()}}:await Pi({tools:Me(f()),commands:Ue,mcpClients:[...f().mcp.clients,...T,...E.clients],messages:w,readFileState:le,getAppState:f,setAppState:m,customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt,thinkingConfig:_.thinkingConfig,agents:Je}),i=await Vi({question:e,cacheSafeParams:n});D(r,{response:i.response})}catch(e){O(r,G(e))}})()}else r.request.subtype===`set_proactive`?(r.request.enabled?ut()||(rt(`command`),tt()):he(),D(r)):O(r,`Unsupported control request subtype: ${r.request.subtype}`);continue}else if(t.type===`control_response`){_.replayUserMessages&&x.enqueue(t);continue}else if(t.type===`keep_alive`)continue;else if(t.type===`update_environment_variables`)continue;else if(t.type===`assistant`||t.type===`system`){let e=Li([t]);w.push(...e),t.type===`assistant`&&_.replayUserMessages&&x.enqueue(t);continue}if(t.type!==`user`)continue;let o=t;if(e=!0,o.uuid){let e=U(),t=await Se(e,o.uuid);if(t||Ec.has(o.uuid)){K(`Skipping duplicate user message: ${o.uuid}`),_.replayUserMessages&&(K(`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&&Tn(o.uuid,`completed`);continue}Oc(o.uuid)}In({mode:`prompt`,value:o.message.content,uuid:o.uuid,priority:o.priority}),m(e=>({...e,attribution:nn(e.attribution,e=>{We(e).catch(e=>{K(`Attribution: Failed to save snapshot: ${e}`)})})})),nt()}y=!0,re||(C.inflightPromise&&await Promise.race([C.inflightPromise,Oi(5e3)]),C.abortController?.abort(),C.abortController=null,await pn(),et(),Ge.delete(ce),x.done())})(),x}function Pc(e){let t=async(n,r,i,a,o,s)=>{let c=s??await _(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=Nn(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 tc(ec().parse($n(h.content[0].text)),e,r,i)};return t}function Fc(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await _(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=>vi(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`),A(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`),A(1),Error(t)}i=Pc(r)}return i(t,r,a,o,s,c)}}async function Ic(e,t,n,r,i,a,o,s,c,l){if(n){r.enqueue({type:`control_response`,response:{subtype:`error`,error:`Already initialized`,request_id:t,pending_permission_requests:o.getPendingPermissionRequests()}});return}if(e.systemPrompt!==void 0&&(s.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(s.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(s.promptSuggestions=e.promptSuggestions),e.agents){let t=Pt(e.agents,`flagSettings`);c.push(...t)}if(s.agent){let e=ir()===s.agent,t=c.find(e=>e.agentType===s.agent);if(t&&!e){if(hr(t.agentType),!s.systemPrompt&&!xn(t)){let e=t.getSystemPrompt();e&&(s.systemPrompt=e)}!s.userSpecifiedModel&&t.model&&t.model!==`inherit`&&ur(ci(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let u=Pr()?.outputStyle||`default`,d=await Ne(_r());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}});lr(t)}e.jsonSchema&&dr(e.jsonSchema);let f={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:Le(e),description:de(e),argumentHint:e.argumentHint||``})),agents:c.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:u,available_output_styles:Object.keys(d),models:a,account:{apiProvider:oi()},pid:process.pid};if(ei()&&ai()){let e=l();f.fast_mode_state=ii(s.userSpecifiedModel??null,e.fastMode)}r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:f}})}async function Lc(e,t,n,r){if(!He())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!pt(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await d(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await yn(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${G(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Rc(e,t,n,r){if(e.mode===`bypassPermissions`){if(Pn())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`&&!ie()){let e=Un();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${An(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...m(n.mode,e.mode,n),mode:e.mode}}function zc(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:U(),total_cost_usd:0,usage:Sn,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(`${W(t)}\n`)}else process.stderr.write(`${e}\n`)}function Bc(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function Vc(e,t){let n=!or();if(t.continue)try{$r(`tengu_continue_print`,{});let r=await Ni(void 0,void 0);if(r)return t.forkSession||r.sessionId&&(cr(Tt(r.sessionId),r.fullPath?ea(r.fullPath):null),n&&await lt()),Yi(r,e),mt(t.forkSession?{...r,worktreeSession:void 0}:r),{messages:r.messages,turnInterruptionState:r.turnInterruptionState,agentSetting:r.agentSetting}}catch(e){return J(e),A(1),{messages:[]}}if(t.resume)try{$r(`tengu_resume_print`,{});let r=vc(typeof t.resume==`string`?t.resume:``);if(!r){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),zc(e,t.outputFormat),A(1),{messages:[]}}let i=await Ni(r.sessionId,r.jsonlFile||void 0);if(!i||i.messages.length===0)return zc(`No conversation found with session ID: ${r.sessionId}`,t.outputFormat),A(1),{messages:[]};if(t.resumeSessionAt){let e=i.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return zc(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),A(1),{messages:[]};i.messages=e>=0?i.messages.slice(0,e+1):[]}return!t.forkSession&&i.sessionId&&(cr(Tt(i.sessionId),i.fullPath?ea(i.fullPath):null),n&&await lt()),Yi(i,e),mt(t.forkSession?{...i,worktreeSession:void 0}:i),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}catch(e){return J(e),zc(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),A(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??u(`startup`))}}function Hc(e,t){let n;return n=typeof e==`string`?e.trim()===``?mn([]):mn([W({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,new lc(n,t.replayUserMessages)}async function Uc({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(K(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return K(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await ct(t);return a?(r.add(t),K(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),In({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(K(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function Wc(e){return{...e,scope:`dynamic`}}async function Gc(e,t,n,r){let{allowed:i,blocked:a}=Xe(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 Kc(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 Kc(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,Wc(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){J(e)}await xe(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=Wc(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await _n(t,r);if(d.push(e),e.type===`connected`){let t=await st(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Sr(e);u[t]=n.message,J(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=Wc(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{Mc as runHeadless};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Af as t,Cm as n,Db as r,Eb as i,Oc as a,Of as o,Sm as s,Xu as c,Yi as l,Zu as u,fS as d,gS as f,jf as p,kc as m,kf as h,lS as g,pS as _}from"./loadAgentsDir-DlPbtIsS.js";import{I as v,t as y}from"./src-DL3w8VPk.js";import{t as b}from"./jsx-runtime-Bb4Xn-E0.js";import{A as x,I as S,M as C}from"./debug-Bglx1aTu.js";import{h as w,t as T}from"./settings-B2jvL8Dp.js";import{n as E,r as D}from"./analytics-DJobLaWP.js";import{bt as O,yt as k}from"./prompt-mM79EGnT.js";import{randomUUID as A}from"crypto";y(),h(),u(),p();var j=b();function M({input:e,progress:n,verbose:r}){return(0,j.jsxs)(v,{flexDirection:`column`,marginTop:1,children:[(0,j.jsx)(c,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,j.jsx)(t,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):o.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}S(),E(),i(),l(),w();function N(){return T().defaultShell??`bash`}h(),k(),n();async function P(t,n,i,c,l){let u=O()&&N()===`powershell`;D(`tengu_input_bash`,{powershell:u});let p=_({content:f({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),h;l({jsx:(0,j.jsx)(M,{input:t,progress:null,verbose:c.options.verbose}),shouldHidePromptInput:!1});try{let n={...c,setToolJSX:e=>{h=e?.jsx}},d=e=>{l({jsx:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(M,{input:t,progress:e.data,verbose:c.options.verbose}),h]}),shouldHidePromptInput:!1,showSpinner:!1})},f=null;u&&(f=(m(),e(a)).PowerShellTool);let v=f??o,y=(f?await f.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d):await o.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await r(v,{...y,stderr:``},A()),S=typeof x.content==`string`?x.content:s(y.stdout);return{messages:[g(),p,...i,_({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${s(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof x?e.interrupted?{messages:[g(),p,d({toolUse:!1}),...i],shouldQuery:!1}:{messages:[g(),p,...i,_({content:`<bash-stdout>${s(e.stdout)}</bash-stdout><bash-stderr>${s(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[g(),p,...i,_({content:`<bash-stderr>Command failed: ${s(C(e))}</bash-stderr>`})],shouldQuery:!1}}finally{l(null)}}export{P as processBashCommand};
|