@readmagic/workmate 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-YAhnVwyN.js → AddWorkspaceDirectory-9FcHMKgX.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-Bny8WDwC.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-Ba4GYFl3.js → AgentsMdExternalIncludesDialog-DLnj3JQO.js} +1 -1
  4. package/dist/chunks/{App-mri25OrC.js → App-NkBqbDbC.js} +1 -1
  5. package/dist/chunks/ApproveApiKey-BKzkEkW-.js +1 -0
  6. package/dist/chunks/{ApproveApiKey-DCw6d7dm.js → ApproveApiKey-rgB6AsYD.js} +1 -1
  7. package/dist/chunks/BackgroundTasksDialog-CcViruUO.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-B5QBJTB4.js → BypassPermissionsModeDialog-D254L98G.js} +1 -1
  9. package/dist/chunks/{DiffDialog-Bd-DcTsK.js → DiffDialog-6Srcz3NW.js} +2 -2
  10. package/dist/chunks/Doctor-DYEdLRxR.js +1 -0
  11. package/dist/chunks/Doctor-DiNxlXfC.js +3 -0
  12. package/dist/chunks/ExitFlow-Bt2De110.js +2 -0
  13. package/dist/chunks/{Grove-CClEZT2e.js → Grove-DC4jyxeB.js} +1 -1
  14. package/dist/chunks/{HybridTransport-DyEuslQB.js → HybridTransport-DArmWb1V.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-Wyrk_cXR.js → InvalidConfigDialog-DFiB0Kzc.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-Cr9fmSyh.js → InvalidSettingsDialog-BHNo2__T.js} +1 -1
  17. package/dist/chunks/MCPConnectionManager-CdpO2Tj9.js +1 -0
  18. package/dist/chunks/MCPToolListView-Ch4jOk_x.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-BF4np2Y3.js → McpParsingWarnings-D4UQ8Q2e.js} +1 -1
  20. package/dist/chunks/MessageSelector-BgsrdJur.js +3 -0
  21. package/dist/chunks/Messages-DB1pmDY_.js +10 -0
  22. package/dist/chunks/{Onboarding-BAJXV7Ay.js → Onboarding-BnjdTwci.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-Cm4WN3qd.js → PromptInputFooterSuggestions-Chg9U-BC.js} +1 -1
  24. package/dist/chunks/{PromptInputHelpMenu-ESj8sOpK.js → PromptInputHelpMenu-C0ZSo12s.js} +1 -1
  25. package/dist/chunks/QueryEngine-bKlupZpA.js +1 -0
  26. package/dist/chunks/REPL-Cg8UXYpX.js +128 -0
  27. package/dist/chunks/REPL-yzvMFfaU.js +1 -0
  28. package/dist/chunks/RemoteSessionManager-CRWOHvKf.js +2 -0
  29. package/dist/chunks/{ResumeConversation-NSVT3gn7.js → ResumeConversation-Ld7tYLKO.js} +1 -1
  30. package/dist/chunks/{SSETransport-CDGMGrxN.js → SSETransport-pPrlSZNF.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-CdgQlm--.js +1 -0
  32. package/dist/chunks/Settings-CsOlPcIW.js +2 -0
  33. package/dist/chunks/{TeleportProgress-8cS6aHVO.js → TeleportProgress-Di-PMey7.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-B0epkMgp.js → TeleportRepoMismatchDialog-CDv1cbo-.js} +1 -1
  35. package/dist/chunks/{TeleportResumeWrapper-Bb14JeEk.js → TeleportResumeWrapper-Bmf13tGU.js} +1 -1
  36. package/dist/chunks/{ThemePicker-CnX8faYA.js → ThemePicker-B3AO3_jA.js} +1 -1
  37. package/dist/chunks/{TrustDialog-6wJF3W6K.js → TrustDialog-C0aiR_LU.js} +1 -1
  38. package/dist/chunks/{ValidationErrorsList-Cuq6W2yc.js → ValidationErrorsList-BfZ5gcIv.js} +1 -1
  39. package/dist/chunks/add-dir-w1Ay3861.js +1 -0
  40. package/dist/chunks/{agentDisplay-QqGqcHGz.js → agentDisplay-D01ZlnVX.js} +1 -1
  41. package/dist/chunks/agents-B_hUgPnR.js +101 -0
  42. package/dist/chunks/{agents-DFPEienW.js → agents-Bxenhf8S.js} +1 -1
  43. package/dist/chunks/allErrors-C_iHQOlK.js +1 -0
  44. package/dist/chunks/{api-B3Wnozaf.js → api-C5ULzZny.js} +1 -1
  45. package/dist/chunks/api-CB3e0De0.js +1 -0
  46. package/dist/chunks/auth-CsYEYXBO.js +1 -0
  47. package/dist/chunks/auth-CubXYcRl.js +1 -0
  48. package/dist/chunks/{auth-CQGJitIV.js → auth-DvcZHXGk.js} +1 -1
  49. package/dist/chunks/backgroundHousekeeping-BGKR5cdA.js +17 -0
  50. package/dist/chunks/backgroundHousekeeping-CykbtljP.js +1 -0
  51. package/dist/chunks/{banner-HfMnBd03.js → banner-BkUdig-T.js} +1 -1
  52. package/dist/chunks/{bg-DltfF1_K.js → bg-tGgpwpYx.js} +2 -2
  53. package/dist/chunks/branch-CqQxCSHG.js +2 -0
  54. package/dist/chunks/{break-cache-Cd1yQ-0h.js → break-cache-CcwOjTKt.js} +3 -3
  55. package/dist/chunks/bridgeConfig-Cp2x_wtE.js +1 -0
  56. package/dist/chunks/{bridgeConfig-B3mR0kJ0.js → bridgeConfig-MxsnEEPx.js} +1 -1
  57. package/dist/chunks/{bridgeMessaging-wZ5EKxW_.js → bridgeMessaging-Bx5pkkkx.js} +1 -1
  58. package/dist/chunks/bridgePointer-DfTOjgtX.js +1 -0
  59. package/dist/chunks/bridgeStatusUtil-B9EcQksI.js +1 -0
  60. package/dist/chunks/btw-DeznoRrw.js +1 -0
  61. package/dist/chunks/caches-BiVRgePi.js +1 -0
  62. package/dist/chunks/caches-CGzKSWiP.js +1 -0
  63. package/dist/chunks/{capacityWake-LRiPhPeM.js → capacityWake-BpP6c7x3.js} +1 -1
  64. package/dist/chunks/{ccrClient-EisctZbc.js → ccrClient-CimQTd0b.js} +1 -1
  65. package/dist/chunks/{claudeDesktop-CB3UCt7U.js → claudeDesktop-DPc_SaVn.js} +1 -1
  66. package/dist/chunks/{clear-BjtPf2Jb.js → clear-KvoD-lFN.js} +1 -1
  67. package/dist/chunks/{cliLaunch-xIVvtPZy.js → cliLaunch-DDtwAolw.js} +1 -1
  68. package/dist/chunks/{client-DNEVh6Wu.js → client-9uHzAmFH.js} +1 -1
  69. package/dist/chunks/client-BVal_QII.js +1 -0
  70. package/dist/chunks/{client-Bb2eZnuq.js → client-C_jBL1yC.js} +1 -1
  71. package/dist/chunks/client-CmnPWgLq.js +1 -0
  72. package/dist/chunks/client-Dd7CKMRX.js +1 -0
  73. package/dist/chunks/commands-CrzVgHxp.js +1 -0
  74. package/dist/chunks/{compact-w8AhLkr6.js → compact-Dgzve3dI.js} +2 -2
  75. package/dist/chunks/{config-BSkuQZNf.js → config-DRy1I12M.js} +2 -2
  76. package/dist/chunks/config-Df8jooTW.js +1 -0
  77. package/dist/chunks/{config-D78R57VA.js → config-e0Goy478.js} +1 -1
  78. package/dist/chunks/{context-Btn2JU2y.js → context-Dz-bbYCw.js} +1 -1
  79. package/dist/chunks/{context-noninteractive-044464Vs.js → context-noninteractive-ApbVPU86.js} +5 -5
  80. package/dist/chunks/context-noninteractive-m4O3VtG7.js +1 -0
  81. package/dist/chunks/conversation-BYBX07j8.js +1 -0
  82. package/dist/chunks/conversation-CJ-d0O-U.js +1 -0
  83. package/dist/chunks/{createSSHSession-C0KSI0fJ.js → createSSHSession-DOz_Ox1_.js} +1 -1
  84. package/dist/chunks/createSession-C_-ZEQT5.js +1 -0
  85. package/dist/chunks/{createSession-8ScCWTKb.js → createSession-yR87Rhiv.js} +1 -1
  86. package/dist/chunks/crossProjectResume-DNnZo3gU.js +40 -0
  87. package/dist/chunks/cwd-DLK3znO7.js +1 -0
  88. package/dist/chunks/cwd-Nh5IZNKO.js +1 -0
  89. package/dist/chunks/{datadog-BqINRWAW.js → datadog-DBgIEaEd.js} +1 -1
  90. package/dist/chunks/{debug-BQj6h99Q.js → debug-D58GQBDG.js} +1 -1
  91. package/dist/chunks/{debugUtils-B86DM1Sp.js → debugUtils-DXBRbwCE.js} +1 -1
  92. package/dist/chunks/{detached--wGwkuHX.js → detached-Biz-xhu0.js} +1 -1
  93. package/dist/chunks/{detectRepository-Qy3zKoyn.js → detectRepository-CDOJ-M7h.js} +1 -1
  94. package/dist/chunks/detectRepository-Cv9-k6dg.js +1 -0
  95. package/dist/chunks/{diff-CcrSQNvQ.js → diff-qOom_T1G.js} +1 -1
  96. package/dist/chunks/{directoryCompletion-i2oWpaUe.js → directoryCompletion-BDGcGDuv.js} +1 -1
  97. package/dist/chunks/doctor-CflXjqVK.js +1 -0
  98. package/dist/chunks/{entry-oVZ7Z59B.js → entry-EmOA7oWN.js} +4 -4
  99. package/dist/chunks/{esm-BZciQG9N.js → esm-DBMVQDVv.js} +1 -1
  100. package/dist/chunks/{execFileNoThrow-DYm1GeGn.js → execFileNoThrow-Bmb5HEFz.js} +1 -1
  101. package/dist/chunks/{execSyncWrapper-CqvQqke-.js → execSyncWrapper-C3ZFV9od.js} +1 -1
  102. package/dist/chunks/{exit-jikLI2Zh.js → exit-DDrAFCzE.js} +1 -1
  103. package/dist/chunks/{extraUsage-BT3in1Aj.js → extraUsage-DylXI7Fc.js} +1 -1
  104. package/dist/chunks/extractMemories-B_8wZpXA.js +1 -0
  105. package/dist/chunks/fast-4ajfJv-M.js +1 -0
  106. package/dist/chunks/{fast-CKhtBOx7.js → fast-BCkhj9Dq.js} +1 -1
  107. package/dist/chunks/{fetchModelList-DmaMgpa2.js → fetchModelList-BbjuFHQT.js} +1 -1
  108. package/dist/chunks/fetchModelList-V8_e2O1N.js +1 -0
  109. package/dist/chunks/{fileSuggestions-BfG3sbET.js → fileSuggestions-Ct7vKEpR.js} +2 -2
  110. package/dist/chunks/{firstPartyEventLogger-Q3fMF0BR.js → firstPartyEventLogger-CxUuXQhL.js} +2 -2
  111. package/dist/chunks/firstPartyEventLogger-YQm0DoVu.js +1 -0
  112. package/dist/chunks/flushGate-BZe_QwEz.js +1 -0
  113. package/dist/chunks/{gemini-L8Gj2B4H.js → gemini-8sSwOtEf.js} +1 -1
  114. package/dist/chunks/{generateSessionName-cAL5T7pG.js → generateSessionName-vT1khubt.js} +1 -1
  115. package/dist/chunks/{genericProcessUtils-Bbcbi11g.js → genericProcessUtils-6E7fB1dI.js} +1 -1
  116. package/dist/chunks/{git-DplvjXEY.js → git-By_J4XJL.js} +1 -1
  117. package/dist/chunks/git-zJCasBa6.js +1 -0
  118. package/dist/chunks/githubRepoPathMapping-CzgPGOHQ.js +1 -0
  119. package/dist/chunks/{goal-D-x2WXm7.js → goal-CznQA1n1.js} +1 -1
  120. package/dist/chunks/{grok-DtypRM4d.js → grok-cEzUsG-s.js} +1 -1
  121. package/dist/chunks/{grove-CSivzrhe.js → grove--HtQL4QZ.js} +1 -1
  122. package/dist/chunks/{help-DKZhC0lL.js → help-B6A_kDQA.js} +1 -1
  123. package/dist/chunks/hooks-CJY5Vfy6.js +1 -0
  124. package/dist/chunks/{hooks-D_afUDcs.js → hooks-CN5hLrhi.js} +2 -2
  125. package/dist/chunks/initReplBridge-BJhmlcVt.js +1 -0
  126. package/dist/chunks/install-DUOtI2Hq.js +1 -0
  127. package/dist/chunks/{instrumentation-IljwxX0V.js → instrumentation-DpgB3GFx.js} +4 -4
  128. package/dist/chunks/{job-N25KhSUu.js → job-DDoX1iFe.js} +1 -1
  129. package/dist/chunks/{jwtUtils-YCoZL0FW.js → jwtUtils-C_LG1txt.js} +1 -1
  130. package/dist/chunks/keybindings-BGTuYfk-.js +1 -0
  131. package/dist/chunks/{launchLocalMemory-DJsuNLIf.js → launchLocalMemory-CoWeLNeP.js} +1 -1
  132. package/dist/chunks/{launchOnboarding-CVvuxeH-.js → launchOnboarding-CTIBGSLV.js} +1 -1
  133. package/dist/chunks/{external-CEp-aPkt.js → lazySchema-DULtBUCI.js} +1 -1
  134. package/dist/chunks/{loadAgentsDir-CbtNPJV3.js → loadAgentsDir-DXOkUcW3.js} +587 -597
  135. package/dist/chunks/loadAgentsDir-Dxz1vp3F.js +1 -0
  136. package/dist/chunks/{loadPluginHooks-BxkDBFd6.js → loadPluginHooks-DrNVtTBq.js} +1 -1
  137. package/dist/chunks/loader-C33o_5kS.js +1 -0
  138. package/dist/chunks/localSearch-CCs5fOd_.js +1 -0
  139. package/dist/chunks/{localSearch-B5mTHBwK.js → localSearch-DnT21UkF.js} +1 -1
  140. package/dist/chunks/{log-BlJ7CcKG.js → log-CZ7ploQm.js} +1 -1
  141. package/dist/chunks/{logoV2Utils-D5nRpirL.js → logoUtils-YwL3izJt.js} +1 -1
  142. package/dist/chunks/{magicDocs-C9aIo4Oe.js → magicDocs-rxv0rR8E.js} +2 -2
  143. package/dist/chunks/{main-DeUt_aE2.js → main-BOvY4O6D.js} +30 -30
  144. package/dist/chunks/{main-Zh18lf2J.js → main-Blm02_Js.js} +2 -2
  145. package/dist/chunks/managedEnv-CpgCYISH.js +1 -0
  146. package/dist/chunks/managedEnv-CrnBYTtQ.js +1 -0
  147. package/dist/chunks/{mappers-Del1KoA7.js → mappers-DYtq2XVS.js} +1 -1
  148. package/dist/chunks/mcp-BPvcoKDY.js +1 -0
  149. package/dist/chunks/mcp-BfqsHRx0.js +2 -0
  150. package/dist/chunks/mcp-BoU3TNFs.js +6 -0
  151. package/dist/chunks/{memoize-_2f7NWDv.js → memoize-CumjjK2Q.js} +1 -1
  152. package/dist/chunks/memory-BPKRdkBb.js +1 -0
  153. package/dist/chunks/{mode-DPbrxU32.js → mode-CXpXux2s.js} +1 -1
  154. package/dist/chunks/model-CxPYKiW1.js +1 -0
  155. package/dist/chunks/model-Cxx3suBa.js +1 -0
  156. package/dist/chunks/model-aEJ54cMA.js +1 -0
  157. package/dist/chunks/{modelOptions-SMq3one0.js → modelOptions-BqBHEyiR.js} +1 -1
  158. package/dist/chunks/{nativeInstaller-DTJ4clp-.js → nativeInstaller-CaXwRpoR.js} +1 -1
  159. package/dist/chunks/omit-DZUxsClb.js +1 -0
  160. package/dist/chunks/onChangeAppState-qHXqufwy.js +1 -0
  161. package/dist/chunks/{openai-D9KvLMrj.js → openai-_FQ9EhuR.js} +2 -2
  162. package/dist/chunks/{panel-Bg_0PHE6.js → panel-CVd1dzYl.js} +1 -1
  163. package/dist/chunks/parser-Cq9X7HMP.js +1 -0
  164. package/dist/chunks/{parser-a2S_eFyE.js → parser-eVu-cTRs.js} +1 -1
  165. package/dist/chunks/partition-BgwHlPsO.js +1 -0
  166. package/dist/chunks/permissions-Dv5d5Nu3.js +3 -0
  167. package/dist/chunks/pidLock-CEhbTkBE.js +3 -0
  168. package/dist/chunks/{plan-dG2H4eQl.js → plan-DVPBW5OS.js} +1 -1
  169. package/dist/chunks/{platform-DVeTi9mp.js → platform-DMQxcm4K.js} +1 -1
  170. package/dist/chunks/plugin-Bh2eBwLW.js +17 -0
  171. package/dist/chunks/{pluginAutoupdate-B9W_vxOG.js → pluginAutoupdate-C2YbEHrP.js} +1 -1
  172. package/dist/chunks/{pluginBlocklist-BvdBsnJG.js → pluginBlocklist-B2NAKaB9.js} +1 -1
  173. package/dist/chunks/{pluginCliCommands-NKIgFTUF.js → pluginCliCommands-Cw5TrYYb.js} +1 -1
  174. package/dist/chunks/{pluginFlagging-C0PtAJEg.js → pluginFlagging-BDTgCYuC.js} +1 -1
  175. package/dist/chunks/pluginOperations-BBwGEdfC.js +2 -0
  176. package/dist/chunks/pluginStartupCheck-CHx379_R.js +1 -0
  177. package/dist/chunks/{pluginStartupCheck-p0njap1l.js → pluginStartupCheck-DhhMk3dA.js} +1 -1
  178. package/dist/chunks/{plugins-B9WBqOAW.js → plugins-r0h93GT_.js} +4 -4
  179. package/dist/chunks/pollConfig-2nFzv6Hy.js +1 -0
  180. package/dist/chunks/poorMode-BTIe8W_H.js +1 -0
  181. package/dist/chunks/poorMode-CKQfWf3S.js +1 -0
  182. package/dist/chunks/print-CDzhHi2F.js +14 -0
  183. package/dist/chunks/processBashCommand-DmdCAWOR.js +1 -0
  184. package/dist/chunks/processSlashCommand-B43TkiaI.js +5 -0
  185. package/dist/chunks/prompt-C50mDqWv.js +1 -0
  186. package/dist/chunks/{prompt-BRGC5U9Y.js → prompt-DEioJrx_.js} +17 -17
  187. package/dist/chunks/prompt-WGH9CcXh.js +1 -0
  188. package/dist/chunks/{promptEditor-CRIw6vJS.js → promptEditor-eJzbtNn4.js} +1 -1
  189. package/dist/chunks/{protocolHandler--eQQuSyx.js → protocolHandler-C-CFTcUJ.js} +1 -1
  190. package/dist/chunks/{proxy-C0j74LqT.js → proxy-BhIc7-mj.js} +1 -1
  191. package/dist/chunks/reconciler-DZP4dJJG.js +1 -0
  192. package/dist/chunks/refresh-vaY-Sr80.js +1 -0
  193. package/dist/chunks/{registerProtocol-DrWIX3Lb.js → registerProtocol-Xsq4ldwg.js} +1 -1
  194. package/dist/chunks/{reload-plugins-Cl6wvT6V.js → reload-plugins-m9CzoIxu.js} +1 -1
  195. package/dist/chunks/{remoteBridgeCore-DnFZoXaw.js → remoteBridgeCore-C4vSr1gp.js} +1 -1
  196. package/dist/chunks/remoteManagedSettings-6RAHPt_g.js +1 -0
  197. package/dist/chunks/{rename-CdzxOzN5.js → rename-DmauGVBX.js} +1 -1
  198. package/dist/chunks/{renderOptions-CkqTbz6d.js → renderOptions-D-aQZbzS.js} +1 -1
  199. package/dist/chunks/resume-ut_pBrLN.js +2 -0
  200. package/dist/chunks/{ripgrep-DsLUmulz.js → ripgrep-C3jtZL7k.js} +1 -1
  201. package/dist/chunks/ripgrep-CBUbn6Po.js +1 -0
  202. package/dist/chunks/{runtimeObserver-Dov-m2dl.js → runtimeObserver-C2vjqtCE.js} +2 -2
  203. package/dist/chunks/{runtimeObserver-CwtRE2cj.js → runtimeObserver-CSroopId.js} +1 -1
  204. package/dist/chunks/sandbox-adapter-CL0qdcxn.js +1 -0
  205. package/dist/chunks/{sandbox-toggle-DWCrG9zV.js → sandbox-toggle-BJKd1ZYk.js} +1 -1
  206. package/dist/chunks/searchExtraTools-ByWuNCGo.js +1 -0
  207. package/dist/chunks/{session-L5191BSn.js → session-DTin6hOR.js} +1 -1
  208. package/dist/chunks/sessionFileAccessHooks-DorzHolr.js +1 -0
  209. package/dist/chunks/sessionObserver-Dy6NFlzL.js +1 -0
  210. package/dist/chunks/{sessionObserver-DpY0DOjI.js → sessionObserver-iAJLH92a.js} +1 -1
  211. package/dist/chunks/{sessionState-BlbRQ3Y6.js → sessionState-DAcub-HK.js} +2 -2
  212. package/dist/chunks/sessionStorage-DItJMkwx.js +1 -0
  213. package/dist/chunks/{sessionTracing-DqVx8aFD.js → sessionTracing-Dvi520eN.js} +1 -1
  214. package/dist/chunks/{settings-CvhsRFaT.js → settings-3xZ0fsvE.js} +5 -5
  215. package/dist/chunks/settings-Crx1cI1u.js +1 -0
  216. package/dist/chunks/settingsSync-aHn3p-6J.js +1 -0
  217. package/dist/chunks/setup-CK3ybjjM.js +3 -0
  218. package/dist/chunks/{shadowedRuleDetection-Gerk3t93.js → shadowedRuleDetection-BL7dEv-u.js} +1 -1
  219. package/dist/chunks/{shellQuote-D3Ocv_U-.js → shellQuote-Ddgr1vif.js} +1 -1
  220. package/dist/chunks/{sideQuestion-RndkXExy.js → sideQuestion-Ct87yvOR.js} +1 -1
  221. package/dist/chunks/{sinks-CfzgqLH5.js → sinks-Bmn3li0M.js} +1 -1
  222. package/dist/chunks/sinks-QQ_6Op7q.js +1 -0
  223. package/dist/chunks/skillChangeDetector-Bco3UoeW.js +1 -0
  224. package/dist/chunks/{skillGapStore-CLxhWLyq.js → skillGapStore-MtlRyYmT.js} +2 -2
  225. package/dist/chunks/{skillLifecycle-CSNX2qOH.js → skillLifecycle-Drs6gEv9.js} +2 -2
  226. package/dist/chunks/{skillSearchPanel-CsQDjy_E.js → skillSearchPanel-DkvmjNaw.js} +3 -3
  227. package/dist/chunks/{skills-DM9ACPW-.js → skills-axToWEo0.js} +1 -1
  228. package/dist/chunks/{startupProfiler-2sjXZkIP.js → startupProfiler-CbzxVmbv.js} +1 -1
  229. package/dist/chunks/startupProfiler-uHetQush.js +1 -0
  230. package/dist/chunks/state-BStOuCh4.js +1 -0
  231. package/dist/chunks/{state-BPFYBqm1.js → state-D5D6QpTX.js} +1 -1
  232. package/dist/chunks/{stats-Dq-5qizS.js → stats-Ce15gc3E.js} +1 -1
  233. package/dist/chunks/status-3uevwSMo.js +1 -0
  234. package/dist/chunks/{status-C5v7KsX4.js → status-CGp4uRlH.js} +2 -2
  235. package/dist/chunks/{statusNoticeHelpers-BY_8pK19.js → statusNoticeHelpers-BrN_2q7H.js} +1 -1
  236. package/dist/chunks/{stringUtils-BjnclTLB.js → stringUtils-CKD8qDqx.js} +1 -1
  237. package/dist/chunks/switcher-99gm2vpe.js +1 -0
  238. package/dist/chunks/switcher-DJDxjLPQ.js +1 -0
  239. package/dist/chunks/syncCache-B3OVvp8K.js +1 -0
  240. package/dist/chunks/{tasks-qVyXOLBf.js → tasks-t5zT_D32.js} +1 -1
  241. package/dist/chunks/{teleport-Deq_ecN9.js → teleport-CvX_nUjQ.js} +1 -1
  242. package/dist/chunks/{templateJobs-CntPyct-.js → templateJobs-Bm8bovHx.js} +1 -1
  243. package/dist/chunks/{terminalSetup-DDvQ0K5e.js → terminalSetup-7PdC4fV5.js} +1 -1
  244. package/dist/chunks/{terminalSetup-JJiXmszo.js → terminalSetup-kWdZRKWq.js} +1 -1
  245. package/dist/chunks/{theme-DVWYzSct.js → theme-DzaSXOpQ.js} +1 -1
  246. package/dist/chunks/{tmux-g0cQ0Buz.js → tmux-CpGd0Aca.js} +1 -1
  247. package/dist/chunks/{toolEventObserver-BZn8ZJB5.js → toolEventObserver-C_nHI27x.js} +1 -1
  248. package/dist/chunks/toolPool-CgKK0K8f.js +1 -0
  249. package/dist/chunks/{trustedDevice-CdLAZK6m.js → trustedDevice-Bb7O8_tj.js} +1 -1
  250. package/dist/chunks/trustedDevice-C2gnF9Lc.js +1 -0
  251. package/dist/chunks/{types-BomO8WUz.js → types-APu4OCXJ.js} +2 -2
  252. package/dist/chunks/{udsClient-DSvRPCvR.js → udsClient-U7MEfYj7.js} +1 -1
  253. package/dist/chunks/{upstreamproxy-DYoLvdM9.js → upstreamproxy-CTOuotLO.js} +1 -1
  254. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-YSWYVWk6.js → useExitOnCtrlCDWithKeybindings-D0uqGxGw.js} +1 -1
  255. package/dist/chunks/useMainLoopModel-BGPOmBkl.js +1 -0
  256. package/dist/chunks/useManagePlugins-ITVFO9dz.js +1 -0
  257. package/dist/chunks/{useMergedTools-B4qRVJ8b.js → useMergedTools-rQ19rFvH.js} +1 -1
  258. package/dist/chunks/{useSearchInput-DfUNYhqC.js → useSearchInput-CXTa-leH.js} +1 -1
  259. package/dist/chunks/useSettingsErrors-Xc6RYjYF.js +1 -0
  260. package/dist/chunks/{userAgent-CNPTS7ix.js → userAgent-CJ5Rp9kc.js} +1 -1
  261. package/dist/chunks/{util-6aJHnBQ_.js → util-CD3ar4of.js} +1 -1
  262. package/dist/chunks/validatePlugin-CxrlCKc1.js +1 -0
  263. package/dist/chunks/{vim-s-wmybpU.js → vim-BagKUX4j.js} +1 -1
  264. package/dist/chunks/{which-BR8YVCCW.js → which-BxQ1hpjp.js} +1 -1
  265. package/dist/chunks/{windowsPaths-BmXyrasP.js → windowsPaths-BdhjMYTm.js} +1 -1
  266. package/dist/chunks/windowsPaths-DtGZ83kH.js +1 -0
  267. package/dist/chunks/{workSecret-BUd8cQ6-.js → workSecret-CaM2yIJD.js} +1 -1
  268. package/dist/chunks/{workerRegistry-BwJ54Lzk.js → workerRegistry-BGJtgrko.js} +2 -2
  269. package/dist/chunks/worktree-CanG5GhE.js +1 -0
  270. package/dist/cli.js +1 -1
  271. package/package.json +1 -1
  272. package/dist/chunks/AgentsMdExternalIncludesDialog--D4BeNAN.js +0 -1
  273. package/dist/chunks/ApproveApiKey-lv4Sg0RR.js +0 -1
  274. package/dist/chunks/BackgroundTasksDialog-CZND8e_Z.js +0 -2
  275. package/dist/chunks/Doctor-C9t7udHN.js +0 -3
  276. package/dist/chunks/Doctor-V-JLC4e3.js +0 -1
  277. package/dist/chunks/ExitFlow-CShdrKmr.js +0 -2
  278. package/dist/chunks/MCPConnectionManager-BnUw0nYN.js +0 -1
  279. package/dist/chunks/MCPToolListView-CY2EezWF.js +0 -1
  280. package/dist/chunks/MessageSelector-Dtt2Sf65.js +0 -3
  281. package/dist/chunks/Messages-D5Uuapmf.js +0 -10
  282. package/dist/chunks/QueryEngine-B79JLwG4.js +0 -1
  283. package/dist/chunks/REPL-B7evbhvN.js +0 -1
  284. package/dist/chunks/REPL-cAXdORs2.js +0 -128
  285. package/dist/chunks/RemoteSessionManager-C5pAD0Lh.js +0 -2
  286. package/dist/chunks/SearchExtraToolsTool-CddjJcAH.js +0 -1
  287. package/dist/chunks/Settings-_b5Yxt_9.js +0 -2
  288. package/dist/chunks/add-dir-LLAv-rGS.js +0 -1
  289. package/dist/chunks/agents-C8wRUTNV.js +0 -101
  290. package/dist/chunks/allErrors-DUYYPpdH.js +0 -1
  291. package/dist/chunks/api-BAT--5sp.js +0 -1
  292. package/dist/chunks/auth-DaJXqwN5.js +0 -1
  293. package/dist/chunks/auth-DkhPycBL.js +0 -1
  294. package/dist/chunks/backgroundHousekeeping-Bjb_Jc7L.js +0 -17
  295. package/dist/chunks/backgroundHousekeeping-V-dg2j2E.js +0 -1
  296. package/dist/chunks/branch-BWq5ynjm.js +0 -2
  297. package/dist/chunks/bridgeConfig-D31i4BRi.js +0 -1
  298. package/dist/chunks/bridgePointer-CiHy2tTN.js +0 -1
  299. package/dist/chunks/bridgeStatusUtil-mvVQSVN-.js +0 -1
  300. package/dist/chunks/btw-XNgXHnNr.js +0 -1
  301. package/dist/chunks/caches-ByLjTvdy.js +0 -1
  302. package/dist/chunks/caches-ckqJ4Qso.js +0 -1
  303. package/dist/chunks/client-Bl43xcRk.js +0 -1
  304. package/dist/chunks/client-Pap_HyZZ.js +0 -1
  305. package/dist/chunks/client-zhozU2ws.js +0 -1
  306. package/dist/chunks/commands-BDhn7EPO.js +0 -1
  307. package/dist/chunks/config-CbAvTdZ7.js +0 -1
  308. package/dist/chunks/context-noninteractive-ulRLlYg5.js +0 -1
  309. package/dist/chunks/conversation-D08lU377.js +0 -1
  310. package/dist/chunks/conversation-a82khZ_n.js +0 -1
  311. package/dist/chunks/createSession-CnlPXXkA.js +0 -1
  312. package/dist/chunks/crossProjectResume-BCN462Wa.js +0 -40
  313. package/dist/chunks/cwd-Besi3Os3.js +0 -1
  314. package/dist/chunks/cwd-DpqwaYHw.js +0 -1
  315. package/dist/chunks/detectRepository-tRUoPOKy.js +0 -1
  316. package/dist/chunks/doctor-DRFDBrH1.js +0 -1
  317. package/dist/chunks/extractMemories-BsQU2bVO.js +0 -1
  318. package/dist/chunks/fast-B9vVL3sY.js +0 -1
  319. package/dist/chunks/fetchModelList-BeL40TyR.js +0 -1
  320. package/dist/chunks/firstPartyEventLogger-6GwZ6VLr.js +0 -1
  321. package/dist/chunks/flushGate-COa_KO98.js +0 -1
  322. package/dist/chunks/git-BaSq69E7.js +0 -1
  323. package/dist/chunks/githubRepoPathMapping-Px3_GeD1.js +0 -1
  324. package/dist/chunks/hooks-DvVuNKRx.js +0 -1
  325. package/dist/chunks/initReplBridge-sTaq4a0K.js +0 -1
  326. package/dist/chunks/install-BWe3Jz4M.js +0 -1
  327. package/dist/chunks/keybindings-DLEorhlY.js +0 -1
  328. package/dist/chunks/lazySchema-B4D4qJVE.js +0 -1
  329. package/dist/chunks/loadAgentsDir-D0gl_H2S.js +0 -1
  330. package/dist/chunks/localSearch-D3UrYUre.js +0 -1
  331. package/dist/chunks/managedEnv-ADMKY7-G.js +0 -1
  332. package/dist/chunks/managedEnv-CDxyrUw1.js +0 -1
  333. package/dist/chunks/mcp-Bh3MNBIj.js +0 -6
  334. package/dist/chunks/mcp-D7vMhEOV.js +0 -2
  335. package/dist/chunks/mcp-nnBVM5Lt.js +0 -1
  336. package/dist/chunks/memory-DtqQhHu8.js +0 -1
  337. package/dist/chunks/model-B50j-O5v.js +0 -1
  338. package/dist/chunks/model-DLG1nrnf.js +0 -1
  339. package/dist/chunks/model-DlLO7TSx.js +0 -1
  340. package/dist/chunks/omit-CMldTqqy.js +0 -1
  341. package/dist/chunks/onChangeAppState-EAnsmOuo.js +0 -1
  342. package/dist/chunks/parser-x-w3ikxt.js +0 -1
  343. package/dist/chunks/partition-B8Y4jvjW.js +0 -1
  344. package/dist/chunks/permissions-cDtIZRM1.js +0 -3
  345. package/dist/chunks/pidLock-Br3_YNi_.js +0 -3
  346. package/dist/chunks/plugin-CzQHuIlP.js +0 -17
  347. package/dist/chunks/pluginOperations-wUUdFpu9.js +0 -2
  348. package/dist/chunks/pluginStartupCheck-hDT6pEAd.js +0 -1
  349. package/dist/chunks/pollConfig-BgpfHQPJ.js +0 -1
  350. package/dist/chunks/poorMode-DD88nPJ4.js +0 -1
  351. package/dist/chunks/poorMode-wm2WkPF0.js +0 -1
  352. package/dist/chunks/print-G3DgPTxy.js +0 -14
  353. package/dist/chunks/processBashCommand-zLWgCRws.js +0 -1
  354. package/dist/chunks/processSlashCommand-BHBnHBjj.js +0 -5
  355. package/dist/chunks/prompt-Ct3Ryb3C.js +0 -1
  356. package/dist/chunks/prompt-TZJKyomz.js +0 -1
  357. package/dist/chunks/reconciler-DiU1RvGD.js +0 -1
  358. package/dist/chunks/refresh-DEXe3Lmx.js +0 -1
  359. package/dist/chunks/remoteManagedSettings-BboLJ46D.js +0 -1
  360. package/dist/chunks/resume-DgFXYWTN.js +0 -2
  361. package/dist/chunks/ripgrep-Di-2j8Ws.js +0 -1
  362. package/dist/chunks/sandbox-adapter-CtEngx-6.js +0 -1
  363. package/dist/chunks/searchExtraTools-zFMN5MqY.js +0 -1
  364. package/dist/chunks/sessionFileAccessHooks-C2VjT-PU.js +0 -1
  365. package/dist/chunks/sessionObserver-BuhXr3FP.js +0 -1
  366. package/dist/chunks/sessionStorage-CiYSwyY3.js +0 -1
  367. package/dist/chunks/settings-BgHApyGL.js +0 -1
  368. package/dist/chunks/settingsSync-BhlegQAU.js +0 -1
  369. package/dist/chunks/setup-DvnKMqDy.js +0 -3
  370. package/dist/chunks/sinks-Cf4vx9UX.js +0 -1
  371. package/dist/chunks/skillChangeDetector-BQx4xe_b.js +0 -1
  372. package/dist/chunks/startupProfiler-B2fyaBEa.js +0 -1
  373. package/dist/chunks/state-CsdHk8n-.js +0 -1
  374. package/dist/chunks/status-C3z0CSBw.js +0 -1
  375. package/dist/chunks/switcher-C9VsM-ip.js +0 -1
  376. package/dist/chunks/switcher-CnBKuiNp.js +0 -1
  377. package/dist/chunks/syncCache-Dff4hbz4.js +0 -1
  378. package/dist/chunks/toolPool-Dzp1ob3I.js +0 -1
  379. package/dist/chunks/trustedDevice-1Q4FTNyX.js +0 -1
  380. package/dist/chunks/useMainLoopModel-C1JRp4zE.js +0 -1
  381. package/dist/chunks/useManagePlugins-DfuI4Nhd.js +0 -1
  382. package/dist/chunks/useSettingsErrors-Bls74ocI.js +0 -1
  383. package/dist/chunks/validatePlugin-BajM6yNf.js +0 -1
  384. package/dist/chunks/windowsPaths-BybjGW7e.js +0 -1
  385. package/dist/chunks/worktree-BFP10vim.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DcaKZlRU.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{B as a,F as o,P as s,R as c,U as l,c as u,f as d,i as f,nt as p,tt as ee,u as te,x as ne}from"./debug-BQj6h99Q.js";import{Kt as re,Yt as ie}from"./settings-CvhsRFaT.js";import{C as m,S as ae,c as oe,h as se,x as ce,y as le}from"./config-BSkuQZNf.js";import{n as h,r as g}from"./execFileNoThrow-DYm1GeGn.js";import{o as _,s as v}from"./log-BlJ7CcKG.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{dn as x,fn as ue}from"./model-DlLO7TSx.js";import{_t as de,gt as fe,vt as pe}from"./sessionState-BlbRQ3Y6.js";import{ft as me,ut as he}from"./esm-BZciQG9N.js";import{C as ge,E as _e,S as ve,T as ye,_ as be,a as S,b as xe,c as Se,d as Ce,f as we,g as Te,i as Ee,l as De,m as Oe,n as ke,o as C,p as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,x as w,y as Ie}from"./pidLock-Br3_YNi_.js";import{homedir as T}from"os";import{basename as Le,delimiter as Re,dirname as E,join as D,resolve as O}from"path";import{constants as ze}from"fs";import{createHash as Be}from"crypto";import{access as k,chmod as A,copyFile as j,mkdir as M,readdir as N,readlink as P,rename as F,rm as I,rmdir as Ve,stat as L,symlink as He,unlink as R,writeFile as z}from"fs/promises";async function Ue(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return b(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),b(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw v(c),c}}async function We(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return Ue(t,B)}function Ge(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||V}async function Ke(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,d=()=>{c&&(clearTimeout(c),c=void 0)},f=()=>{d(),c=setTimeout(e=>e.abort(),Ge(),s)};try{f();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{f()},...i});d();let o=Be(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await z(n,Buffer.from(a.data)),await A(n,493);return}catch(e){d();let t=r.isCancel(e);if(a=t?new H:l(e),t&&o<3){u(`Download stalled on attempt ${o}/3, retrying...`),await ue(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function qe(e,t,n,i){let a=te();await a.rm(t,{recursive:!0,force:!0});let o=U(),s=Date.now();b(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),b(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),v(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw b(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=W(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let p=D(t,d);try{await Ke(f,u,p,i||{}),b(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),b(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),v(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function Je(e,t){return await qe(e,t,B),`binary`}var B,V,H,Ye=e((()=>{i(),y(),f(),c(),g(),d(),_(),x(),ne(),$(),B=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,V=6e4,H=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function U(){let e=re.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw u(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&he.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function W(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function G(){let e=W(U());return{versions:D(Ce(),`claude`,`versions`),staging:D(Ne(),`claude`,`staging`),locks:D(we(),`claude`,`locks`),executable:D(De(),e)}}async function K(e){try{let t=await L(e);return!t.isFile()||t.size===0?!1:(await k(e,ze.X_OK),!0)}catch{return!1}}async function q(e){let t=G(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>M(e,{recursive:!0}))),await M(E(t.executable),{recursive:!0});let r=D(t.versions,e);try{await L(r)}catch{await z(r,``,{encoding:`utf8`})}return{stagingPath:D(t.staging,e),installPath:r}}async function Xe(e,t,n=0){let r=G(),i=J(r,e);if(await M(r.locks,{recursive:!0}),C()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await Se(e,i,async()=>{try{await t()}catch(e){throw v(e),e}}))return b(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await ue(Math.min(o*2**(r-1),s))}return b(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),Y(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await m(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{u(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return b(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),Y(e,t),!1}try{return await t(),b(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw v(e),e}}finally{a&&await a()}}async function Ze(e,t){await M(E(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await j(e,n),await A(n,493),await F(n,t),u(`Atomically installed binary to ${t}`)}catch(e){try{await R(n)}catch{}throw e}}async function Qe(e,t){try{let n=D(e,`node_modules`,`@anthropic-ai`),r=(await N(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw b(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=D(n,r,`cli`);try{await L(i)}catch{throw b(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await Ze(i,t),await I(e,{recursive:!0,force:!0}),b(`tengu_native_install_package_success`,{})}catch(e){let t=s(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&b(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),v(l(e)),e}}async function $e(e,t){try{let n=D(e,W(U()));try{await L(n)}catch{throw b(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await Ze(n,t),await I(e,{recursive:!0,force:!0}),b(`tengu_native_install_binary_success`,{})}catch(e){throw s(e).includes(`Staged binary not found`)||b(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),v(l(e)),e}}async function et(e,t,n){n===`npm`?await Qe(e,t):await $e(e,t)}async function tt(e,n){let{stagingPath:r,installPath:i}=await q(e),{executable:a}=G(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await nt(e)||n;if(s?(u(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await et(o,i,await Je(e,o))):u(`Version ${e} already installed, updating symlink`),await it(a),await at(a,i),!await K(a)){let e=!1;try{await L(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function nt(e){let{installPath:t}=await q(e);return K(t)}async function rt(e,n=!1){let r=Date.now(),i=await We(e),{executable:a}=G();if(u(`Checking for native installer update to version ${i}`),!n){let e=await be();if(e&&fe(i,e)){if(u(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),de(`0.0.17`,e))return u(`Native installer: current version 0.0.17 is already at or above maxVersion ${e}, skipping update`),b(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.17`&&await nt(i)&&await K(a))return u(`Found ${i} at ${a}, skipping install`),b(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&Ie(i))return b(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await tt(i,n),s=Date.now()-r;else{let{installPath:e}=await q(i);n&&await dt(e);let t=await Xe(e,async()=>{o=await tt(i,n)},3);if(s=Date.now()-r,!t){let t=G(),n;if(C()){let r=J(t,e);S(r)&&(n=je(r)?.pid)}return b(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return b(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),u(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function it(e){try{await Ve(e),u(`Removed empty directory at ${e}`)}catch(t){let n=o(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&u(`Could not remove directory at ${e}: ${t}`)}}async function at(e,t){if(U().startsWith(`win32`))try{await M(E(e),{recursive:!0});let n;try{n=await L(e)}catch{}if(n){try{let e=await L(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await F(e,r);try{await j(t,e);try{await R(r)}catch{}}catch(t){try{await F(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw v(n),n}throw t}}else try{await j(t,e)}catch(e){throw a(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return v(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=E(e);try{await M(n,{recursive:!0}),u(`Created directory ${n} for symlink`)}catch(e){return v(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await L(e),n=!0}catch{}if(n){try{let n=await P(e);if(O(E(e),n)===O(t))return!1}catch{}await R(e)}}catch(e){v(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await F(r,e),u(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await R(r)}catch{}return v(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ot(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Oe();if(n===`development`||!(e||n===`native`))return[];let r=G(),i=[],o=E(r.executable),s=O(o),c=U().startsWith(`win32`);try{await k(o)}catch{i.push({message:`installMethod is native, but directory ${o} does not exist`,userActionRequired:!0,type:`error`})}if(c)await K(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await P(r.executable);await K(O(E(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){a(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await K(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).some(e=>{try{let t=O(e);return c?t.toLowerCase()===s.toLowerCase():t===s}catch{return!1}}))if(c){let e=o.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=ye(),t=w()[e],n=t?t.replace(T(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function st(e,t=!1){if(t)return ct(e,t);if(Q)return u(`installLatest: joining in-flight call`),Q;let n=ct(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ct(e,t=!1){let n=await rt(e,t);return n.success?(oe().installMethod!==`native`&&(le(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),u(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),X(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function lt(e){try{let t=await P(e),n=O(E(e),t);if(await K(n))return n}catch{}return null}function J(e,t){let n=Le(t);return D(e.locks,`${n}.lock`)}async function ut(){let e=G();if(!process.execPath.includes(e.versions))return;let t=O(process.execPath);try{let n=J(e,t);if(await M(e.locks,{recursive:!0}),C()){if(!await Me(t,n)){b(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),Y(t,Error(`Lock already held by another process`));return}b(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),u(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await m(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{u(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),b(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),u(`Acquired mtime-based lock on running version: ${t}`),p(async()=>{try{await e?.()}catch{}})}catch(e){if(a(e)){u(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}b(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),Y(t,e);return}}}catch(e){if(a(e)){u(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}u(`NON-FATAL: Failed to lock current version during execution ${s(e)}`,{level:`info`})}}function Y(e,t){v(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function dt(e){let t=J(G(),e);try{await R(t),u(`Force-removed lock file at ${t}`)}catch(e){u(`Failed to force-remove lock file: ${s(e)}`)}}async function X(){await Promise.resolve();let e=G(),t=Date.now()-36e5;if(U().startsWith(`win32`)){let t=E(e.executable);try{let e=await N(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await R(D(t,r)),n++}catch{}n>0&&u(`Cleaned up ${n} old Windows executables on startup`)}catch(e){a(e)||u(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await N(e.staging),r=0;for(let i of n){let n=D(e.staging,i);try{(await L(n)).mtime.getTime()<t&&(await I(n,{recursive:!0,force:!0}),r++,u(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(u(`Cleaned up ${r} orphaned staging directories`),b(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){a(e)||u(`Failed to clean up staging directories: ${e}`)}if(C()){let t=ke(e.locks);t>0&&(u(`Cleaned up ${t} stale version locks`),b(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await N(e.versions)}catch(e){a(e)||u(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=D(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await L(n)).mtime.getTime()<t&&(await R(n),i++,u(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await L(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:O(n),mtime:e.mtime})}catch{}}if(i>0&&(u(`Cleaned up ${i} orphaned temp install files`),b(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(O(t));let i=await lt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=J(e,t.resolvedPath),i=!1;if(C())i=S(r);else try{i=await ce(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),u(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){b(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await Xe(e.path,async()=>{await R(e.path)})?o++:(s++,u(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,v(Error(`Failed to delete version ${e.name}: ${t}`))}})),b(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){a(e)||v(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=w();for(let[n,r]of Object.entries(t))try{let t=await ge(r);if(!t)continue;let{filtered:i,hadAlias:a}=xe(t);a&&(await Fe(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),u(`Cleaned up claude alias from ${n} config`))}catch(t){v(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await h(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await R(e),u(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(U().startsWith(`win32`)){let e=D(n,`claude.cmd`),t=D(n,`claude.ps1`),a=D(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(D(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(u(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${U().startsWith(`win32`)?D(n,`node_modules`,e):D(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return u(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await h(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return u(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){u(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),u(`Attempting manual removal due to ENOTEMPTY error`);let t=await pt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return u(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function ht(){let e=[],t=[],n=0,r=await mt(`@anthropic-ai/workmate`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=D(T(),`.workmate`,`local`);try{await I(i,{recursive:!0}),n++,u(`Removed local installation at ${i}`)}catch(t){a(t)||(e.push(`Failed to remove ${i}: ${t}`),u(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{y(),Pe(),ee(),se(),f(),Te(),ie(),me(),n(),c(),g(),_e(),ae(),_(),pe(),ve(),x(),Ae(),Ye(),Ee(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,ut as c,X as i,ot as n,$ as o,ht as r,st as s,gt as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DcaKZlRU.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{B as a,F as o,P as s,R as c,U as l,c as u,f as d,i as f,nt as p,tt as ee,u as te,x as ne}from"./debug-D58GQBDG.js";import{Gt as re,Jt as ie}from"./settings-3xZ0fsvE.js";import{C as m,S as ae,c as oe,h as se,x as ce,y as le}from"./config-DRy1I12M.js";import{n as h,r as g}from"./execFileNoThrow-Bmb5HEFz.js";import{o as _,s as v}from"./log-CZ7ploQm.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{dn as x,fn as ue}from"./model-Cxx3suBa.js";import{_t as de,gt as fe,vt as pe}from"./sessionState-DAcub-HK.js";import{ft as me,ut as he}from"./esm-DBMVQDVv.js";import{C as ge,E as _e,S as ve,T as ye,_ as be,a as S,b as xe,c as Se,d as Ce,f as we,g as Te,i as Ee,l as De,m as Oe,n as ke,o as C,p as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,x as w,y as Ie}from"./pidLock-CEhbTkBE.js";import{homedir as T}from"os";import{basename as Le,delimiter as Re,dirname as E,join as D,resolve as O}from"path";import{constants as ze}from"fs";import{createHash as Be}from"crypto";import{access as k,chmod as A,copyFile as j,mkdir as M,readdir as N,readlink as P,rename as F,rm as I,rmdir as Ve,stat as L,symlink as He,unlink as R,writeFile as z}from"fs/promises";async function Ue(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return b(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),b(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw v(c),c}}async function We(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return Ue(t,B)}function Ge(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||V}async function Ke(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,d=()=>{c&&(clearTimeout(c),c=void 0)},f=()=>{d(),c=setTimeout(e=>e.abort(),Ge(),s)};try{f();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{f()},...i});d();let o=Be(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await z(n,Buffer.from(a.data)),await A(n,493);return}catch(e){d();let t=r.isCancel(e);if(a=t?new H:l(e),t&&o<3){u(`Download stalled on attempt ${o}/3, retrying...`),await ue(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function qe(e,t,n,i){let a=te();await a.rm(t,{recursive:!0,force:!0});let o=U(),s=Date.now();b(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),b(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),v(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw b(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=W(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let p=D(t,d);try{await Ke(f,u,p,i||{}),b(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),b(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),v(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function Je(e,t){return await qe(e,t,B),`binary`}var B,V,H,Ye=e((()=>{i(),y(),f(),c(),g(),d(),_(),x(),ne(),$(),B=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,V=6e4,H=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function U(){let e=re.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw u(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&he.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function W(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function G(){let e=W(U());return{versions:D(Ce(),`claude`,`versions`),staging:D(Ne(),`claude`,`staging`),locks:D(we(),`claude`,`locks`),executable:D(De(),e)}}async function K(e){try{let t=await L(e);return!t.isFile()||t.size===0?!1:(await k(e,ze.X_OK),!0)}catch{return!1}}async function q(e){let t=G(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>M(e,{recursive:!0}))),await M(E(t.executable),{recursive:!0});let r=D(t.versions,e);try{await L(r)}catch{await z(r,``,{encoding:`utf8`})}return{stagingPath:D(t.staging,e),installPath:r}}async function Xe(e,t,n=0){let r=G(),i=J(r,e);if(await M(r.locks,{recursive:!0}),C()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await Se(e,i,async()=>{try{await t()}catch(e){throw v(e),e}}))return b(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await ue(Math.min(o*2**(r-1),s))}return b(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),Y(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await m(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{u(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return b(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),Y(e,t),!1}try{return await t(),b(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw v(e),e}}finally{a&&await a()}}async function Ze(e,t){await M(E(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await j(e,n),await A(n,493),await F(n,t),u(`Atomically installed binary to ${t}`)}catch(e){try{await R(n)}catch{}throw e}}async function Qe(e,t){try{let n=D(e,`node_modules`,`@anthropic-ai`),r=(await N(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw b(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=D(n,r,`cli`);try{await L(i)}catch{throw b(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await Ze(i,t),await I(e,{recursive:!0,force:!0}),b(`tengu_native_install_package_success`,{})}catch(e){let t=s(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&b(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),v(l(e)),e}}async function $e(e,t){try{let n=D(e,W(U()));try{await L(n)}catch{throw b(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await Ze(n,t),await I(e,{recursive:!0,force:!0}),b(`tengu_native_install_binary_success`,{})}catch(e){throw s(e).includes(`Staged binary not found`)||b(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),v(l(e)),e}}async function et(e,t,n){n===`npm`?await Qe(e,t):await $e(e,t)}async function tt(e,n){let{stagingPath:r,installPath:i}=await q(e),{executable:a}=G(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await nt(e)||n;if(s?(u(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await et(o,i,await Je(e,o))):u(`Version ${e} already installed, updating symlink`),await it(a),await at(a,i),!await K(a)){let e=!1;try{await L(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function nt(e){let{installPath:t}=await q(e);return K(t)}async function rt(e,n=!1){let r=Date.now(),i=await We(e),{executable:a}=G();if(u(`Checking for native installer update to version ${i}`),!n){let e=await be();if(e&&fe(i,e)){if(u(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),de(`0.0.19`,e))return u(`Native installer: current version 0.0.19 is already at or above maxVersion ${e}, skipping update`),b(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.19`&&await nt(i)&&await K(a))return u(`Found ${i} at ${a}, skipping install`),b(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&Ie(i))return b(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await tt(i,n),s=Date.now()-r;else{let{installPath:e}=await q(i);n&&await dt(e);let t=await Xe(e,async()=>{o=await tt(i,n)},3);if(s=Date.now()-r,!t){let t=G(),n;if(C()){let r=J(t,e);S(r)&&(n=je(r)?.pid)}return b(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return b(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),u(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function it(e){try{await Ve(e),u(`Removed empty directory at ${e}`)}catch(t){let n=o(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&u(`Could not remove directory at ${e}: ${t}`)}}async function at(e,t){if(U().startsWith(`win32`))try{await M(E(e),{recursive:!0});let n;try{n=await L(e)}catch{}if(n){try{let e=await L(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await F(e,r);try{await j(t,e);try{await R(r)}catch{}}catch(t){try{await F(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw v(n),n}throw t}}else try{await j(t,e)}catch(e){throw a(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return v(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=E(e);try{await M(n,{recursive:!0}),u(`Created directory ${n} for symlink`)}catch(e){return v(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await L(e),n=!0}catch{}if(n){try{let n=await P(e);if(O(E(e),n)===O(t))return!1}catch{}await R(e)}}catch(e){v(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await F(r,e),u(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await R(r)}catch{}return v(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ot(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Oe();if(n===`development`||!(e||n===`native`))return[];let r=G(),i=[],o=E(r.executable),s=O(o),c=U().startsWith(`win32`);try{await k(o)}catch{i.push({message:`installMethod is native, but directory ${o} does not exist`,userActionRequired:!0,type:`error`})}if(c)await K(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await P(r.executable);await K(O(E(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){a(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await K(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).some(e=>{try{let t=O(e);return c?t.toLowerCase()===s.toLowerCase():t===s}catch{return!1}}))if(c){let e=o.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=ye(),t=w()[e],n=t?t.replace(T(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function st(e,t=!1){if(t)return ct(e,t);if(Q)return u(`installLatest: joining in-flight call`),Q;let n=ct(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ct(e,t=!1){let n=await rt(e,t);return n.success?(oe().installMethod!==`native`&&(le(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),u(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),X(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function lt(e){try{let t=await P(e),n=O(E(e),t);if(await K(n))return n}catch{}return null}function J(e,t){let n=Le(t);return D(e.locks,`${n}.lock`)}async function ut(){let e=G();if(!process.execPath.includes(e.versions))return;let t=O(process.execPath);try{let n=J(e,t);if(await M(e.locks,{recursive:!0}),C()){if(!await Me(t,n)){b(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),Y(t,Error(`Lock already held by another process`));return}b(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),u(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await m(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{u(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),b(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),u(`Acquired mtime-based lock on running version: ${t}`),p(async()=>{try{await e?.()}catch{}})}catch(e){if(a(e)){u(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}b(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),Y(t,e);return}}}catch(e){if(a(e)){u(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}u(`NON-FATAL: Failed to lock current version during execution ${s(e)}`,{level:`info`})}}function Y(e,t){v(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function dt(e){let t=J(G(),e);try{await R(t),u(`Force-removed lock file at ${t}`)}catch(e){u(`Failed to force-remove lock file: ${s(e)}`)}}async function X(){await Promise.resolve();let e=G(),t=Date.now()-36e5;if(U().startsWith(`win32`)){let t=E(e.executable);try{let e=await N(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await R(D(t,r)),n++}catch{}n>0&&u(`Cleaned up ${n} old Windows executables on startup`)}catch(e){a(e)||u(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await N(e.staging),r=0;for(let i of n){let n=D(e.staging,i);try{(await L(n)).mtime.getTime()<t&&(await I(n,{recursive:!0,force:!0}),r++,u(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(u(`Cleaned up ${r} orphaned staging directories`),b(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){a(e)||u(`Failed to clean up staging directories: ${e}`)}if(C()){let t=ke(e.locks);t>0&&(u(`Cleaned up ${t} stale version locks`),b(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await N(e.versions)}catch(e){a(e)||u(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=D(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await L(n)).mtime.getTime()<t&&(await R(n),i++,u(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await L(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:O(n),mtime:e.mtime})}catch{}}if(i>0&&(u(`Cleaned up ${i} orphaned temp install files`),b(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(O(t));let i=await lt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=J(e,t.resolvedPath),i=!1;if(C())i=S(r);else try{i=await ce(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),u(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){b(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await Xe(e.path,async()=>{await R(e.path)})?o++:(s++,u(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,v(Error(`Failed to delete version ${e.name}: ${t}`))}})),b(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){a(e)||v(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=w();for(let[n,r]of Object.entries(t))try{let t=await ge(r);if(!t)continue;let{filtered:i,hadAlias:a}=xe(t);a&&(await Fe(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),u(`Cleaned up claude alias from ${n} config`))}catch(t){v(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await h(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await R(e),u(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(U().startsWith(`win32`)){let e=D(n,`claude.cmd`),t=D(n,`claude.ps1`),a=D(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(D(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(u(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${U().startsWith(`win32`)?D(n,`node_modules`,e):D(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return u(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await h(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return u(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){u(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),u(`Attempting manual removal due to ENOTEMPTY error`);let t=await pt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return u(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function ht(){let e=[],t=[],n=0,r=await mt(`@anthropic-ai/workmate`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=D(T(),`.workmate`,`local`);try{await I(i,{recursive:!0}),n++,u(`Removed local installation at ${i}`)}catch(t){a(t)||(e.push(`Failed to remove ${i}: ${t}`),u(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{y(),Pe(),ee(),se(),f(),Te(),ie(),me(),n(),c(),g(),_e(),ae(),_(),pe(),ve(),x(),Ae(),Ye(),Ee(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,ut as c,X as i,ot as n,$ as o,ht as r,st as s,gt as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{TT as r,dE as i,fE as a,vT as o,wT as s,yT as c}from"./loadAgentsDir-DXOkUcW3.js";import{Ar as l,Dr as u,Er as d,Nr as f,Or as p,Pr as m,Si as h,Tr as g,bi as _,kr as v,li as y,ui as b,xi as x,yi as S}from"./state-D5D6QpTX.js";import{$n as C,Qn as w,Tr as T,Xn as E,Zn as D,er as O,tr as k,wr as A}from"./settings-3xZ0fsvE.js";import{I as j,L as M}from"./config-DRy1I12M.js";function N(e){return _(e)||b(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),y(),S(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):x(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{h(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return D(C(e,void 0,R),e+``)}var V=e((()=>{z(),w(),E()}));function H(e,t){return t.length<2?e:g(e,s(t,0,-1))}var U=e((()=>{d(),r()}));function W(e,t){t=v(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=p(t[n]);if(i===`__proto__`&&!G.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=H(e,t);return a==null||delete a[p(c(t))]}var G,K=e((()=>{l(),o(),U(),u(),G=Object.prototype.hasOwnProperty}));function q(e){return k(e)?void 0:e}var J=e((()=>{O()})),Y,X,Z,Q,$=e((()=>{m(),a(),K(),l(),T(),J(),V(),M(),Y=1,X=2,Z=4,Q=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=f(t,function(t){return t=v(t,e),r||(r=t.length>1),t}),A(e,j(e),n),r&&(n=i(n,Y|X|Z,q));for(var a=t.length;a--;)W(n,t[a]);return n})}));export{Q as n,$ as t};
@@ -0,0 +1 @@
1
+ import{Ut as e,jn as t}from"./state-D5D6QpTX.js";import{R as n,U as r}from"./debug-D58GQBDG.js";import{Pt as i,Rt as a,jt as o}from"./settings-3xZ0fsvE.js";import{c as s,h as c,y as l}from"./config-DRy1I12M.js";import{o as u,s as d}from"./log-CZ7ploQm.js";import{Pt as f,dt as p,ft as m,ut as h}from"./model-Cxx3suBa.js";import{a as g,i as _,n as v}from"./sessionState-DAcub-HK.js";import{r as y,t as b}from"./managedEnv-CpgCYISH.js";e(),f(),c(),n(),u(),y(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:i(e.permission_mode)}}:{}})}function S({newState:e,oldState:n}){let i=n.toolPermissionContext.mode,o=e.toolPermissionContext.mode;if(i!==o){let e=a(i),t=a(o);e!==t&&g({permission_mode:t}),_(o)}if(e.mainLoopModel!==n.mainLoopModel&&t(e.mainLoopModel),e.expandedView!==n.expandedView){let t=e.expandedView===`tasks`;s().showExpandedTodos!==t&&l(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==n.verbose&&s().verbose!==e.verbose){let t=e.verbose;l(e=>({...e,verbose:t}))}if(e.settings!==n.settings)try{h(),p(),m(),e.settings.env!==n.settings.env&&b()}catch(e){d(r(e))}}export{S as n,x as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DcaKZlRU.js";import{F_ as i,Ka as a,La as o,N_ as s,Ny as c,P_ as l,Sa as u,Wa as d,it as ee,ky as f,pa as p,tt as m}from"./loadAgentsDir-CbtNPJV3.js";import{c as h,i as g}from"./debug-BQj6h99Q.js";import{Bn as _,F as te,Ln as v,R as y}from"./model-DlLO7TSx.js";import{i as ne,r as b,t as x,vn as re,xn as ie,yn as S}from"./prompt-BRGC5U9Y.js";import{E as C,O as w,T,Z as E,j as D,k as ae}from"./sessionState-BlbRQ3Y6.js";import{n as oe,r as O}from"./client-Bb2eZnuq.js";import{n as se,t as k}from"./openaiShared-G2-w4gJt.js";import{homedir as A}from"os";import{join as j}from"path";import{randomUUID as M}from"crypto";import{chmod as ce,mkdir as N,readFile as P,writeFile as F}from"fs/promises";function I(){return j(L(),J)}function L(){return(process.env.WORKMATE_CONFIG_DIR??j(A(),`.workmate`)).normalize(`NFC`)}function R(){return j(process.env.CODEX_HOME??j(process.env.HOME??``,`.codex`),`auth.json`)}function z(e){return typeof e==`string`&&e.length>0?e:void 0}function B(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function V(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return B(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function H(e){let t=V(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function U(e){let t=V(e)?.exp;return typeof t==`number`?t*1e3:null}function W(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=H(t),n=z(e.chatgpt_account_id)??z(e.chatgpt_account_user_id)??z(e.account_id);if(n)return n}}async function G(e){try{let t=await P(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:W({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function le(e){let t=I();await N(L(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:W(e)},last_refresh:new Date().toISOString()};await F(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await ce(t,384).catch(()=>void 0)}async function ue(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function de(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:q,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await ue(`${K}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:W({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function fe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function pe(){let e=await G(I());if(e||(e=await G(R()),e&&h(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in.`);let t=U(e.accessToken);return t!==null&&t<=Date.now()+Y&&(e=await de(e),await le(e)),{accessToken:e.accessToken,accountId:e.accountId??W(e)}}var K,q,J,Y,X=e((()=>{g(),K=`https://auth.openai.com`,q=`app_EMoamEEZ73f0CkXaXp7hrann`,J=`openai-chatgpt-auth.json`,Y=300*1e3}));function Z(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DcaKZlRU.js";import{F_ as i,Ka as a,La as o,N_ as s,Ny as c,P_ as l,Sa as u,Wa as d,it as ee,ky as f,pa as p,tt as m}from"./loadAgentsDir-DXOkUcW3.js";import{c as h,i as g}from"./debug-D58GQBDG.js";import{Bn as _,F as te,Ln as v,R as y}from"./model-Cxx3suBa.js";import{_n as ne,bn as re,i as ie,r as b,t as x,vn as S}from"./prompt-DEioJrx_.js";import{E as C,O as w,T,Z as E,j as D,k as ae}from"./sessionState-DAcub-HK.js";import{n as oe,r as O}from"./client-C_jBL1yC.js";import{n as se,t as k}from"./openaiShared-G2-w4gJt.js";import{homedir as A}from"os";import{join as j}from"path";import{randomUUID as M}from"crypto";import{chmod as ce,mkdir as N,readFile as P,writeFile as F}from"fs/promises";function I(){return j(L(),J)}function L(){return(process.env.WORKMATE_CONFIG_DIR??j(A(),`.workmate`)).normalize(`NFC`)}function R(){return j(process.env.CODEX_HOME??j(process.env.HOME??``,`.codex`),`auth.json`)}function z(e){return typeof e==`string`&&e.length>0?e:void 0}function B(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function V(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return B(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function H(e){let t=V(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function U(e){let t=V(e)?.exp;return typeof t==`number`?t*1e3:null}function W(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=H(t),n=z(e.chatgpt_account_id)??z(e.chatgpt_account_user_id)??z(e.account_id);if(n)return n}}async function G(e){try{let t=await P(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:W({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function le(e){let t=I();await N(L(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:W(e)},last_refresh:new Date().toISOString()};await F(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await ce(t,384).catch(()=>void 0)}async function ue(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function de(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:q,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await ue(`${K}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:W({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function fe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function pe(){let e=await G(I());if(e||(e=await G(R()),e&&h(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in.`);let t=U(e.accessToken);return t!==null&&t<=Date.now()+Y&&(e=await de(e),await le(e)),{accessToken:e.accessToken,accountId:e.accountId??W(e)}}var K,q,J,Y,X=e((()=>{g(),K=`https://auth.openai.com`,q=`app_EMoamEEZ73f0CkXaXp7hrann`,J=`openai-chatgpt-auth.json`,Y=300*1e3}));function Z(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
2
2
  `):``}function me(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return Z(e);let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type===`text`&&typeof e.text==`string`)t.push({type:`input_text`,text:e.text});else if(e.type===`image_url`){let n=e.image_url;typeof n?.url==`string`&&t.push({type:`input_image`,image_url:n.url})}}return t.length>0?t:Z(e)}function he(e){let t=[],n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.role;if(i===`system`||i===`developer`){let t=Z(e.content);t&&n.push(t);continue}if(i===`tool`){let n=e.tool_call_id;typeof n==`string`&&t.push({type:`function_call_output`,call_id:n,output:Z(e.content)});continue}if(i===`assistant`){let n=Z(e.content);n&&t.push({role:`assistant`,content:n});let r=e.tool_calls;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=n.function,i=typeof n.id==`string`?n.id:void 0,a=typeof r?.name==`string`?r.name:void 0;!i||!a||t.push({type:`function_call`,call_id:i,name:a,arguments:typeof r?.arguments==`string`?r.arguments:`{}`})}continue}i===`user`&&t.push({role:`user`,content:me(e.content)})}return{input:t,instructions:n.length>0?n.join(`
3
3
 
4
4
  `):void 0}}function ge(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.function,r=typeof e?.name==`string`?e.name:void 0;r&&t.push({type:`function`,name:r,description:typeof e?.description==`string`?e.description:``,parameters:e?.parameters&&typeof e.parameters==`object`?e.parameters:{type:`object`,properties:{}},strict:!1})}return t}function _e(e){if(e===`required`)return`required`;if(e===`auto`)return`auto`;if(!e||typeof e!=`object`)return e;let t=e,n=t.function;return t.type===`function`&&typeof n?.name==`string`?{type:`function`,name:n.name}:e}function ve(e){let{input:t,instructions:n}=he(e.messages),r=ge(e.tools);return{model:e.model,stream:!0,store:!1,input:t,...n?{instructions:n}:{},...r.length>0?{tools:r}:{},...e.toolChoice?{tool_choice:_e(e.toolChoice)}:{},parallel_tool_calls:!0}}async function*ye(e){if(!e.body)throw Error(`ChatGPT response did not include a body`);let t=e.body.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
@@ -7,4 +7,4 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}f
7
7
  `);if(t&&t!==`[DONE]`){let e=JSON.parse(t);e&&typeof e==`object`&&(yield e)}a=r.indexOf(`
8
8
 
9
9
  `)}}}function be(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function xe(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*Q(e,t){let n=`msg_${M().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:xe(e),stop_sequence:null},usage:be(e)},yield{type:`message_stop`}}}}async function Se(e){let t=await pe(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`workmate`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return ye(i)}var Ce=e((()=>{X()}));function we(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(n(process.env.OPENAI_ENABLE_THINKING))return!0;let r=e.toLowerCase();return r.includes(`deepseek`)||r.includes(`mimo`)}function Te(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function Ee(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var De=e((()=>{r()}));function Oe(e,t,n,r){if(!r||l())return e;let i=t.filter(e=>n.has(e.name)).map(x).sort().join(`
10
- `);return i?[u({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function ke(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:a,stopReason:o,maxTokens:s}=e,c=[],l=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return l.length>0&&t&&c.push({message:{...t,content:d(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:M(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(p({content:`Output truncated: response exceeded the ${s} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),c}async function*Ae(e,t,n,r,o){try{let s=E(o.model),c=a(e,n),l=await i(o.model,n,o.getToolPermissionContext||(async()=>re()),o.agents||[],o.querySource),u=new Set;if(l)for(let e of n)ne(e)&&u.add(e.name);let d=n;l&&u.size>0&&(d=n.filter(e=>!!(!u.has(e.name)||ie(e,`SearchExtraTools`))));let p=(await Promise.all(d.map(e=>ee(e,{getToolPermissionContext:o.getToolPermissionContext,tools:n,agents:o.agents,allowedAgentTypes:o.allowedAgentTypes,model:o.model,deferLoading:l&&u.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),m=we(s),g=D(Oe(c.filter(ke),n,u,l),t,{enableThinking:m}),_=ae(p),y=w(o.toolChoice);if(l){let e=d.filter(e=>u.has(e.name)).length;h(`[OpenAI] Tool search enabled: ${e}/${u.size} deferred tools included, total tools=${_.length}`)}else h(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:b}=v(s),x=Te(b,o.maxOutputTokensOverride);h(`[OpenAI] Calling model=${s}, messages=${g.length}, tools=${_.length}, thinking=${m}`);let S=fe()?Q(await Se({request:ve({model:s,messages:g,tools:_,toolChoice:y}),signal:r,fetchOverride:o.fetchOverride}),s):C(await oe({maxRetries:0,fetchOverride:o.fetchOverride,source:o.querySource}).chat.completions.create(Ee({model:s,messages:g,tools:_,toolChoice:y,enableThinking:m,maxTokens:x,temperatureOverride:o.temperatureOverride}),{signal:r}),s),T={},O=null,k=null,A={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},j=0,M=Date.now();for await(let e of S){switch(e.type){case`message_start`:O=e.message,j=Date.now()-M,e.message.usage&&(A={...A,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?T[t]={...n,input:``}:n.type===`text`?T[t]={...n,text:``}:n.type===`thinking`?T[t]={...n,thinking:``,signature:``}:T[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=T[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(A=se(A,t)),e.delta.stop_reason!=null&&(k=e.delta.stop_reason);break}case`message_stop`:if(O){for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:o.agentId,usage:A,stopReason:k,maxTokens:x}))yield e;O=null}A.input_tokens+A.output_tokens>0&&f(te(s,A),A,o.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:j}:void 0}}if(O)for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:o.agentId,usage:A,stopReason:k,maxTokens:x}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);h(`[OpenAI] Error: ${t}`,{level:`error`}),yield p({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{O(),k(),T(),X(),Ce(),o(),m(),S(),g(),c(),y(),De(),_(),s(),b()}))();export{Ae as queryModelOpenAI};
10
+ `);return i?[u({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function ke(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:a,stopReason:o,maxTokens:s}=e,c=[],l=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return l.length>0&&t&&c.push({message:{...t,content:d(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:M(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(p({content:`Output truncated: response exceeded the ${s} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),c}async function*Ae(e,t,n,r,o){try{let s=E(o.model),c=a(e,n),l=await i(o.model,n,o.getToolPermissionContext||(async()=>ne()),o.agents||[],o.querySource),u=new Set;if(l)for(let e of n)ie(e)&&u.add(e.name);let d=n;l&&u.size>0&&(d=n.filter(e=>!!(!u.has(e.name)||re(e,`SearchExtraTools`))));let p=(await Promise.all(d.map(e=>ee(e,{getToolPermissionContext:o.getToolPermissionContext,tools:n,agents:o.agents,allowedAgentTypes:o.allowedAgentTypes,model:o.model,deferLoading:l&&u.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),m=we(s),g=D(Oe(c.filter(ke),n,u,l),t,{enableThinking:m}),_=ae(p),y=w(o.toolChoice);if(l){let e=d.filter(e=>u.has(e.name)).length;h(`[OpenAI] Tool search enabled: ${e}/${u.size} deferred tools included, total tools=${_.length}`)}else h(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:b}=v(s),x=Te(b,o.maxOutputTokensOverride);h(`[OpenAI] Calling model=${s}, messages=${g.length}, tools=${_.length}, thinking=${m}`);let S=fe()?Q(await Se({request:ve({model:s,messages:g,tools:_,toolChoice:y}),signal:r,fetchOverride:o.fetchOverride}),s):C(await oe({maxRetries:0,fetchOverride:o.fetchOverride,source:o.querySource}).chat.completions.create(Ee({model:s,messages:g,tools:_,toolChoice:y,enableThinking:m,maxTokens:x,temperatureOverride:o.temperatureOverride}),{signal:r}),s),T={},O=null,k=null,A={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},j=0,M=Date.now();for await(let e of S){switch(e.type){case`message_start`:O=e.message,j=Date.now()-M,e.message.usage&&(A={...A,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?T[t]={...n,input:``}:n.type===`text`?T[t]={...n,text:``}:n.type===`thinking`?T[t]={...n,thinking:``,signature:``}:T[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=T[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(A=se(A,t)),e.delta.stop_reason!=null&&(k=e.delta.stop_reason);break}case`message_stop`:if(O){for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:o.agentId,usage:A,stopReason:k,maxTokens:x}))yield e;O=null}A.input_tokens+A.output_tokens>0&&f(te(s,A),A,o.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:j}:void 0}}if(O)for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:o.agentId,usage:A,stopReason:k,maxTokens:x}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);h(`[OpenAI] Error: ${t}`,{level:`error`}),yield p({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{O(),k(),T(),X(),Ce(),o(),m(),S(),g(),c(),y(),De(),_(),s(),b()}))();export{Ae as queryModelOpenAI};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,hn as a,t as o,y as s}from"./src-DL3w8VPk2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{o as l,r as u}from"./break-cache-Cd1yQ-0h.js";async function d(e,t){let n=await u(e);n.type===`text`&&t(n.value,{display:`system`})}function f({onDone:e}){let[t,i]=(0,m.useState)(0),o=(0,m.useMemo)(()=>[{label:`Status`,description:`显示 pending 标记、always 模式与打断次数`,run:()=>void d(`status`,e)},{label:`Once`,description:`仅在下一次 API 调用打断 prompt cache`,run:()=>void d(`once`,e)},{label:`Always`,description:`在每次 API 调用都打断 prompt cache`,run:()=>void d(`always`,e)},{label:`Off`,description:`关闭 always 模式并清除 pending 的一次性标记`,run:()=>void d(`off`,e)},{label:`Clear Once`,description:`取消待生效的一次性 cache 打断`,run:()=>void d(`--clear`,e)}],[e]),c=()=>{let e=o[t];e&&e.run()};return a((e,t)=>{if(t.upArrow){i(e=>Math.max(0,e-1));return}if(t.downArrow){i(e=>Math.min(o.length-1,e+1));return}t.return&&c()}),(0,h.jsx)(s,{title:`Break Cache`,subtitle:`${o.length} actions`,onCancel:()=>e(`Break-cache panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,h.jsxs)(n,{flexDirection:`column`,children:[o.map((e,i)=>(0,h.jsxs)(n,{flexDirection:`row`,children:[(0,h.jsx)(r,{children:`${i===t?`›`:` `} ${e.label}`.padEnd(g)}),(0,h.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function p(e,t,n){let r=n?.trim()??``;return r?(await d(r,e),null):(0,h.jsx)(f,{onDone:e})}var m,h,g;e((()=>{m=t(i(),1),o(),l(),h=c(),g=28}))();export{p as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,hn as a,t as o,y as s}from"./src-DL3w8VPk2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{o as l,r as u}from"./break-cache-CcwOjTKt.js";async function d(e,t){let n=await u(e);n.type===`text`&&t(n.value,{display:`system`})}function f({onDone:e}){let[t,i]=(0,m.useState)(0),o=(0,m.useMemo)(()=>[{label:`Status`,description:`显示 pending 标记、always 模式与打断次数`,run:()=>void d(`status`,e)},{label:`Once`,description:`仅在下一次 API 调用打断 prompt cache`,run:()=>void d(`once`,e)},{label:`Always`,description:`在每次 API 调用都打断 prompt cache`,run:()=>void d(`always`,e)},{label:`Off`,description:`关闭 always 模式并清除 pending 的一次性标记`,run:()=>void d(`off`,e)},{label:`Clear Once`,description:`取消待生效的一次性 cache 打断`,run:()=>void d(`--clear`,e)}],[e]),c=()=>{let e=o[t];e&&e.run()};return a((e,t)=>{if(t.upArrow){i(e=>Math.max(0,e-1));return}if(t.downArrow){i(e=>Math.min(o.length-1,e+1));return}t.return&&c()}),(0,h.jsx)(s,{title:`Break Cache`,subtitle:`${o.length} actions`,onCancel:()=>e(`Break-cache panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,h.jsxs)(n,{flexDirection:`column`,children:[o.map((e,i)=>(0,h.jsxs)(n,{flexDirection:`row`,children:[(0,h.jsx)(r,{children:`${i===t?`›`:` `} ${e.label}`.padEnd(g)}),(0,h.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function p(e,t,n){let r=n?.trim()??``;return r?(await d(r,e),null):(0,h.jsx)(f,{onDone:e})}var m,h,g;e((()=>{m=t(i(),1),o(),l(),h=c(),g=28}))();export{p as call};
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./parser-eVu-cTRs.js";t();export{e as parseCommand};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t}from"./debug-BQj6h99Q.js";var n,r=e((()=>{Promise.resolve(),n=new Set([`if`,`then`,`elif`,`else`,`fi`,`while`,`until`,`for`,`in`,`do`,`done`,`case`,`esac`,`function`,`select`])}));async function i(e){return!e||e.length,null}async function a(e){return!e||e.length,null}function o(e){if(e.type===`declaration_command`){let t=e.children[0];return t&&c.has(t.text)?[t.text]:[]}let t=[],n=!1;for(let r of e.children)if(r.type!==`variable_assignment`){if(r.type===`command_name`||!n&&r.type===`word`){n=!0,t.push(r.text);continue}if(l.has(r.type))t.push(s(r.text));else if(u.has(r.type))break}return t}function s(e){return e.length>=2&&(e[0]===`"`&&e.at(-1)===`"`||e[0]===`'`&&e.at(-1)===`'`)?e.slice(1,-1):e}var c,l,u,d,f=e((()=>{t(),r(),c=new Set([`export`,`declare`,`typeset`,`readonly`,`local`,`unset`,`unsetenv`]),l=new Set([`word`,`string`,`raw_string`,`number`]),u=new Set([`command_substitution`,`process_substitution`]),d=Symbol(`parse-aborted`)}));export{a,i,o as n,n as o,f as r,r as s,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t}from"./debug-D58GQBDG.js";var n,r=e((()=>{Promise.resolve(),n=new Set([`if`,`then`,`elif`,`else`,`fi`,`while`,`until`,`for`,`in`,`do`,`done`,`case`,`esac`,`function`,`select`])}));async function i(e){return!e||e.length,null}async function a(e){return!e||e.length,null}function o(e){if(e.type===`declaration_command`){let t=e.children[0];return t&&c.has(t.text)?[t.text]:[]}let t=[],n=!1;for(let r of e.children)if(r.type!==`variable_assignment`){if(r.type===`command_name`||!n&&r.type===`word`){n=!0,t.push(r.text);continue}if(l.has(r.type))t.push(s(r.text));else if(u.has(r.type))break}return t}function s(e){return e.length>=2&&(e[0]===`"`&&e.at(-1)===`"`||e[0]===`'`&&e.at(-1)===`'`)?e.slice(1,-1):e}var c,l,u,d,f=e((()=>{t(),r(),c=new Set([`export`,`declare`,`typeset`,`readonly`,`local`,`unset`,`unsetenv`]),l=new Set([`word`,`string`,`raw_string`,`number`]),u=new Set([`command_substitution`,`process_substitution`]),d=Symbol(`parse-aborted`)}));export{a,i,o as n,n as o,f as r,r as s,d as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{bT as t,xT as n}from"./loadAgentsDir-DXOkUcW3.js";import{Sr as r,bi as i,xr as a,yi as o}from"./state-D5D6QpTX.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,n,r,i){return t(e,function(e,t,a){n(i,e,r(e),a)}),i}var u=e((()=>{n()}));function d(e,t){return function(n,r){var o=i(n)?s:l,c=t?t():{};return o(n,e,a(r,2),c)}}var f=e((()=>{c(),u(),r(),o()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{$h as i,$u as a,Gg as o,H as s,Hg as c,I as l,Kg as u,L as d,La as f,Qu as p,Qw as m,R as ee,Um as h,V as g,Wm as te,Xh as _,Zh as ne,_a as v,cd as re,gC as ie,ld as y,tT as b,uC as x,z as ae}from"./loadAgentsDir-DXOkUcW3.js";import{I as S,P as C,Wt as oe,Xn as se,a as w,ai as T,di as E,fi as D,hn as O,k,kt as A,n as j,o as M,ot as ce,r as le,s as ue,t as N,x as de,y as P}from"./src-DL3w8VPk2.js";import{t as F}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as I,Ut as L}from"./state-D5D6QpTX.js";import{C as R,x as fe}from"./debug-D58GQBDG.js";import{B as z,R as B,V,a as H,cn as pe,h as me,nn as he}from"./settings-3xZ0fsvE.js";import{l as ge,o as _e}from"./stringUtils-CKD8qDqx.js";import{n as ve,t as ye}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-9FcHMKgX.js";import{t as Se}from"./SearchBox-CwwV0W-w.js";import{n as Ce,t as we}from"./useSearchInput-CXTa-leH.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-BL7dEv-u.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case h.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(C,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(C,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(C,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(C,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(C,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(C,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(C,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{N(),te(),W=F()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${H(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${H(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.workmate/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:i,setToolPermissionContext:a}){let o=he.map(je),s=(0,Ne.useCallback)(o=>{if(o===`cancel`){t();return}else if(he.includes(o)){let t=o,s=c(i,{type:`addRules`,rules:n,behavior:r,destination:t});u({type:`addRules`,rules:n,behavior:r,destination:t}),a(s);let l=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),d=Ee(s,{sandboxAutoAllowEnabled:m.isSandboxingEnabled()&&m.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(l,d.length>0?d:void 0)}},[e,t,n,r,i,a]);return(0,G.jsxs)(P,{title:`Add ${r} permission ${ge(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(S,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsx)(C,{bold:!0,children:V(e)}),(0,G.jsx)(ke,{ruleValue:e})]},V(e)))}),(0,G.jsxs)(S,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(C,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(p,{options:o,onChange:s})]})]})}var Ne,G,Pe=e((()=>{Ne=t(T(),1),a(),N(),o(),B(),Te(),b(),pe(),me(),_e(),Ae(),G=F()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Ie.useState)(``),[o,s]=(0,Ie.useState)(0),c=ve();oe(`confirm:no`,e,{context:`Settings`});let{columns:l}=ce(),u=l-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(S,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(C,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(S,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(A,{}),`e.g., `,(0,K.jsx)(C,{bold:!0,children:V({toolName:h.name})}),(0,K.jsx)(C,{bold:!1,children:` or `}),(0,K.jsx)(C,{bold:!0,children:V({toolName:h.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(S,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(re,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(z(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:u,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,K.jsx)(S,{marginLeft:3,children:c.pending?(0,K.jsxs)(C,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,K.jsx)(C,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(T(),1),y(),ye(),ie(),N(),x(),te(),B(),K=F()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=w();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,q.useState)(()=>De()),[a,o]=(0,q.useState)(()=>new Set),[s,c]=(0,q.useState)(()=>new Set),[l,u]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,q.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),f=(0,q.useCallback)(e=>{u(Number(e))},[]);if(O((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,J.jsx)(C,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let m=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(C,{children:[(0,J.jsx)(ue,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(C,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(S,{flexDirection:`column`,children:[(0,J.jsx)(C,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(S,{marginTop:1,children:(0,J.jsx)(p,{options:m,onChange:d,onFocus:f,visibleOptionCount:Math.min(10,m.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(T(),1),N(),Oe(),a(),J=F()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let a=(0,Ve.useCallback)(()=>{i(c(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),o=(0,Ve.useCallback)(e=>{e===`yes`?a():n()},[a,n]);return(0,Y.jsxs)(P,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(S,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(C,{bold:!0,children:e})}),(0,Y.jsx)(C,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(p,{onChange:o,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(T(),1),a(),N(),o(),Y=F()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=w();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t?.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=We.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,Z.jsxs)(S,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(S,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(C,{children:`- ${I()}`}),(0,Z.jsx)(C,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(p,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var We,X,Z,Ge=e((()=>{n(),We=t(T(),1),X=t(T(),1),L(),a(),N(),Z=F()}));function Ke({rule:e}){return(0,$.jsx)(C,{dimColor:!0,children:`From ${s(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=ve();oe(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(S,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(C,{bold:!0,children:V(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),a=(0,$.jsx)(S,{marginLeft:3,children:r.pending?(0,$.jsxs)(C,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(C,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(S,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(C,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(C,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
+ `,`Contact your system administrator for more information.`]})]}),a]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(S,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(C,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),i,(0,$.jsx)(C,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(p,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),a]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:i,onSelect:a,onCancel:o,lastFocusedRuleKey:s,cursorOffset:c,onHeaderFocusChange:l}=e,u=M(),{headerFocused:d,focusHeader:f,blurHeader:m}=w();return(0,Q.useEffect)(()=>{r&&d&&m()},[r,d,m]),(0,Q.useEffect)(()=>{l?.(d)},[d,l]),(0,$.jsxs)(S,{flexDirection:`column`,children:[(0,$.jsx)(S,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(k,{query:n,isFocused:r&&!d,isTerminalFocused:i,width:u,cursorOffset:c})}),(0,$.jsx)(p,{options:t,onChange:a,onCancel:o,visibleOptionCount:Math.min(10,t.length),isDisabled:r||d,defaultFocusValue:s,onUpFromFirstItem:f})]})}function Xe({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(S,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(C,{children:{allow:`Work Mate won't ask before using allowed tools.`,ask:`Work Mate will always ask for confirmation before using these tools.`,deny:`Work Mate will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Ye,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Ze({onExit:e,initialTab:t,onRetryDenials:n}){let a=De().length>0,o=t??(a?`recent`:`allow`),[s,f]=(0,Q.useState)([]),p=ne(e=>e.toolPermissionContext),m=i(),h=se(),g=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),te=(0,Q.useCallback)(e=>{g.current=e},[]),[_,v]=(0,Q.useState)(),[re,ie]=(0,Q.useState)(),[y,b]=(0,Q.useState)(null),[x,w]=(0,Q.useState)(null),[T,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(!1),[ce,ue]=(0,Q.useState)(!0),N=(0,Q.useCallback)(e=>{ue(e)},[]),P=(0,Q.useMemo)(()=>{let e=new Map;return d(p).forEach(t=>{e.set(R(t),t)}),e},[p]),F=(0,Q.useMemo)(()=>{let e=new Map;return ae(p).forEach(t=>{e.set(R(t),t)}),e},[p]),I=(0,Q.useMemo)(()=>{let e=new Map;return ee(p).forEach(t=>{e.set(R(t),t)}),e},[p]),L=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return P;case`deny`:return F;case`ask`:return I;case`workspace`:case`recent`:return new Map}})(),i=[];e!==`workspace`&&e!==`recent`&&!t&&i.push({label:`Add a new rule${r.ellipsis}`,value:`add-new-rule`});let a=Array.from(n.keys()).sort((e,t)=>{let r=n.get(e),i=n.get(t);if(r&&i){let e=V(r.ruleValue).toLowerCase(),t=V(i.ruleValue).toLowerCase();return e.localeCompare(t)}return 0}),o=t.toLowerCase();for(let e of a){let r=n.get(e);if(r){let n=V(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[P,F,I]),fe=ve(),z=!_&&!y&&!x&&!T&&!O,{query:B,setQuery:H,cursorOffset:pe}=Ce({isActive:z&&A,onExit:()=>{M(!1)}}),me=(0,Q.useCallback)(e=>{z&&(A||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),M(!0),H(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),M(!0),H(e.key))))},[z,A,H]),he=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=L(t);if(e===`add-new-rule`){b(t);return}else{v(n.get(e));return}},[L]),ge=(0,Q.useCallback)(()=>{b(null)},[]),_e=(0,Q.useCallback)((e,t)=>{w({ruleValue:e,ruleBehavior:t}),b(null)},[]),ye=(0,Q.useCallback)((e,t)=>{w(null);for(let t of e)f(e=>[...e,`Added ${t.ruleBehavior} rule ${E.bold(V(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;f(n=>[...n,E.yellow(`${r.warning} Warning: ${V(e.rule.ruleValue)} is ${t}`),E.dim(` ${e.reason}`),E.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{w(null)},[]),Se=(0,Q.useCallback)(()=>D(!0),[]),we=(0,Q.useCallback)(e=>k(e),[]),Te=(0,Q.useCallback)(()=>{let t=g.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let a=r(t.approved);a.length>0||s.length>0?e([...a.length>0?[`Approved ${a.map(e=>E.bold(e.display)).join(`, `)}`]:[],...s].join(`
3
+ `)):e(`Permissions dialog dismissed`,{display:`system`})},[s,e,n]);oe(`confirm:no`,Te,{context:`Settings`,isActive:z&&!A});let Ee=()=>{if(!_)return;let{options:e}=L(_.ruleBehavior),t=R(_),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),ie(i),l({rule:_,initialContext:p,setToolPermissionContext(e){m(t=>({...t,toolPermissionContext:e}))}}),f(e=>[...e,`Deleted ${_.ruleBehavior} rule ${E.bold(V(_.ruleValue))}`]),v(void 0)};if(_)return(0,$.jsx)(Je,{rule:_,onDelete:Ee,onCancel:()=>v(void 0)});if(y&&y!==`workspace`&&y!==`recent`)return(0,$.jsx)(Fe,{onCancel:ge,onSubmit:_e,ruleBehavior:y});if(x)return(0,$.jsx)(Me,{onAddRules:ye,onCancel:be,ruleValues:[x.ruleValue],ruleBehavior:x.ruleBehavior,initialContext:p,setToolPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});if(T)return(0,$.jsx)(xe,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=c(p,n);m(e=>({...e,toolPermissionContext:r})),t&&u(n),f(n=>[...n,`Added directory ${E.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),D(!1)},onCancel:()=>D(!1),permissionContext:p});if(O)return(0,$.jsx)(Be,{directoryPath:O,onRemove:()=>{f(e=>[...e,`Removed directory ${E.bold(O)} from workspace`]),k(null)},onCancel:()=>k(null),permissionContext:p,setPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:B,isSearchMode:A,isFocused:h,onCancel:Te,lastFocusedRuleKey:re,cursorOffset:pe,getRulesOptions:L,handleToolSelect:he,onHeaderFocusChange:N};return(0,$.jsx)(S,{flexDirection:`column`,onKeyDown:me,children:(0,$.jsxs)(de,{color:`permission`,children:[(0,$.jsxs)(le,{title:`Permissions:`,color:`permission`,defaultTab:o,hidden:!!_||!!y||!!x||T||!!O,initialHeaderFocused:!a,navFromContent:!A,children:[(0,$.jsx)(j,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:N,onStateChange:te})}),(0,$.jsx)(j,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Xe,{tab:`allow`,...U})}),(0,$.jsx)(j,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Xe,{tab:`ask`,...U})}),(0,$.jsx)(j,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Xe,{tab:`deny`,...U})}),(0,$.jsx)(j,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(S,{flexDirection:`column`,children:[(0,$.jsx)(C,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:p,onRequestAddDirectory:Se,onRequestRemoveDirectory:we,onHeaderFocusChange:N})]})})]}),(0,$.jsx)(S,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(C,{dimColor:!0,children:fe.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,fe.keyName,` again to exit`]}):ce?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):A?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):a&&o===`recent`?(0,$.jsx)($.Fragment,{children:`Enter approve · r retry · ↑↓ navigate · ←/→ switch · Esc cancel`}):(0,$.jsx)($.Fragment,{children:`↑↓ navigate · Enter select · Type to search · ←/→ switch · Esc cancel`})})})]})})}var Q,$,Qe=e((()=>{D(),n(),Q=t(T(),1),_(),o(),a(),ye(),we(),N(),x(),Oe(),B(),g(),fe(),Se(),Pe(),be(),Ae(),Le(),ze(),He(),Ge(),$=F()})),$e,et;e((()=>{Qe(),f(),$e=F(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,v(e)])}})}))();export{et as call};
@@ -0,0 +1,3 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,i,l as a,o}from"./envUtils-DcaKZlRU.js";import{$d as s,Qw as c,tT as ee}from"./loadAgentsDir-DXOkUcW3.js";import{n as te}from"./cwd-Nh5IZNKO.js";import{B as ne,C as re,D as ie,R as l,S as u,T as ae,U as oe,V as se,c as d,f,i as p,u as m,x as h}from"./debug-D58GQBDG.js";import{Gt as ce,Jt as le,N as ue,Yt as de,Zt as fe,h as pe,j as g,t as me}from"./settings-3xZ0fsvE.js";import{a as _,c as v,h as y,i as he}from"./config-DRy1I12M.js";import{c as ge,n as _e,o as ve,r as b,t as x}from"./execFileNoThrow-Bmb5HEFz.js";import{o as S,s as C}from"./log-CZ7ploQm.js";import{n as w,t as ye}from"./which-BxQ1hpjp.js";import{i as T,o as be}from"./platform-DMQxcm4K.js";import{n as E,t as xe}from"./bundledMode--fG1S62b.js";import{_t as Se,vt as Ce}from"./sessionState-DAcub-HK.js";import{a as we,i as Te}from"./ripgrep-C3jtZL7k.js";import{i as Ee,r as De}from"./genericProcessUtils-6E7fB1dI.js";import{homedir as D}from"os";import{basename as Oe,delimiter as ke,join as O,posix as k,win32 as A}from"path";import{constants as Ae}from"fs";import{access as je,open as Me,readFile as j,realpath as Ne,stat as Pe}from"fs/promises";function M(){return O(i(),`local`)}function Fe(){return O(M(),`claude`)}function Ie(){return(process.argv[1]||``).includes(`/.workmate/local/node_modules/`)}async function N(){try{return await je(O(M(),`node_modules`,`.bin`,`claude`)),!0}catch{return!1}}function P(){let e=process.env.SHELL||``;return e.includes(`zsh`)?`zsh`:e.includes(`bash`)?`bash`:e.includes(`fish`)?`fish`:`unknown`}var F=e((()=>{y(),o(),l(),b(),f(),S(),h()}));function I(e){let t=e?.homedir??D();return{zsh:O((e?.env??process.env).ZDOTDIR||t,`.zshrc`),bash:O(t,`.bashrc`),fish:O(t,`.config/fish/config.fish`)}}function Le(e){let t=!1;return{filtered:e.filter(e=>{if(z.test(e)){let n=e.match(/alias\s+claude\s*=\s*["']([^"']+)["']/);if(n||(n=e.match(/alias\s+claude\s*=\s*([^#\n]+)/)),n?.[1]&&n[1].trim()===Fe())return t=!0,!1}return!0}),hadAlias:t}}async function L(e){try{return(await j(e,{encoding:`utf8`})).split(`
2
+ `)}catch(e){if(se(e))return null;throw e}}async function Re(e,t){let n=await Me(e,`w`);try{await n.writeFile(t.join(`
3
+ `),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function R(e){let t=I(e);for(let e of Object.values(t)){let t=await L(e);if(t){for(let e of t)if(z.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function ze(e){let t=await R(e);if(!t)return null;let n=e?.homedir??D(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Pe(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var z,B=e((()=>{l(),F(),z=/^\s*alias\s+claude\s*=/}));async function Be(){}function Ve(e){let t=me()?.minimumVersion;if(!t)return!1;let n=!Se(e,t);return n&&d(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function He(){let e=ce.isRunningWithBun(),t=null;return t=e?await _e(`bun`,[`pm`,`bin`,`-g`],{cwd:D()}):await _e(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:D()}),t.code===0?t.stdout.trim():(C(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ue(){try{let e=await He();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await je(e,Ae.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return C(new We(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return C(e),{hasPermissions:!1,npmPrefix:null}}}var We,Ge=e((()=>{y(),p(),le(),o(),l(),b(),f(),s(),S(),Ce(),pe(),B(),We=class extends ie{}}));function V(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function Ke(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(d(`Detected mise installation: ${e}`),!0):!1}function qe(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(d(`Detected asdf installation: ${e}`),!0):!1}function H(){let e=T();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(d(`Detected Homebrew cask installation: ${t}`),!0):!1}function Je(){if(T()!==`windows`)return!1;let e=process.execPath||process.argv[0]||``;for(let t of[/Microsoft[/\\]WinGet[/\\]Packages/i,/Microsoft[/\\]WinGet[/\\]Links/i])if(t.test(e))return d(`Detected winget installation: ${e}`),!0;return!1}var U,W,G,K,q,Ye,Xe=e((()=>{n(),p(),b(),be(),U=t(async()=>{try{let e=await j(`/etc/os-release`,`utf8`),t=e.match(/^ID=["']?(\S+?)["']?\s*$/m),n=e.match(/^ID_LIKE=["']?(.+?)["']?\s*$/m);return{id:t?.[1]??``,idLike:n?.[1]?.split(` `)??[]}}catch{return null}}),W=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`arch`]))return!1;let t=await x(`pacman`,[`-Qo`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),G=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`debian`]))return!1;let t=await x(`dpkg`,[`-S`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`fedora`,`rhel`,`suse`]))return!1;let t=await x(`rpm`,[`-qf`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`alpine`]))return!1;let t=await x(`apk`,[`info`,`--who-owns`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),Ye=t(async()=>H()?`homebrew`:Je()?`winget`:Ke()?`mise`:qe()?`asdf`:await W()?`pacman`:await q()?`apk`:await G()?`deb`:await K()?`rpm`:`unknown`)}));function Ze(){let e=process.argv[1]||``,t=process.execPath||process.argv[0]||``;return T()===`windows`&&(e=e.split(A.sep).join(k.sep),t=t.split(A.sep).join(k.sep)),[e,t]}async function Qe(){let[e]=Ze();if(E())return H()||Je()||Ke()||qe()||await W()||await G()||await K()||await q()?`package-manager`:`native`;if(Ie())return`npm-local`;if([`/usr/local/lib/node_modules`,`/usr/lib/node_modules`,`/opt/homebrew/lib/node_modules`,`/opt/homebrew/bin`,`/usr/local/bin`,`/.nvm/versions/node/`].some(t=>e.includes(t))||e.includes(`/npm/`)||e.includes(`/nvm/`))return`npm-global`;let t=await ve(`npm config get prefix`,{shell:!0,reject:!1}),n=t.exitCode===0?t.stdout.trim():null;return n&&e.startsWith(n)?`npm-global`:`unknown`}async function $e(){if(E()){try{return await Ne(process.execPath)}catch{}try{let e=await w(`claude`);if(e)return e}catch{}try{return await m().stat(O(D(),`.local/bin/claude`)),O(D(),`.local/bin/claude`)}catch{}return`native`}try{return process.argv[0]||`unknown`}catch{return`unknown`}}function et(){try{return E()?process.execPath||`unknown`:process.argv[1]||`unknown`}catch{return`unknown`}}async function tt(){let e=m(),t=[],n=O(D(),`.workmate`,`local`);await N()&&t.push({type:`npm-local`,path:n});let r=[`@anthropic-ai/workmate`],i=await x(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=T()===`windows`,o=a?O(n,`claude`):O(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await Ne(o)).includes(`/Caskroom/`)&&(e=H())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?O(n,`node_modules`,i):O(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=O(D(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=O(D(),`.local`,`share`,`claude`);try{await e.stat(n),t.some(e=>e.type===`native`)||t.push({type:`native`,path:n})}catch{}}return t}async function nt(e){let t=[];try{let e=u(await j(O(de(),`managed-settings.json`),`utf-8`)),n=e&&typeof e==`object`?e.strictPluginOnlyCustomization:void 0;if(n!==void 0&&typeof n!=`boolean`)if(!Array.isArray(n))t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has an invalid value (expected true or an array, got ${typeof n})`,fix:`The field is silently ignored (schema .catch rescues it). Set it to true, or an array of: ${g.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!g.includes(e));e.length>0&&t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has ${e.length} value(s) this client doesn't recognize: ${e.map(String).join(`, `)}`,fix:`These are silently ignored (forwards-compat). Known surfaces for this version: ${g.join(`, `)}. Either remove them, or this client is older than the managed-settings intended.`})}}catch{}let n=v();if(e===`development`)return t;if(e===`native`){let e=(process.env.PATH||``).split(ke),n=O(D(),`.local`,`bin`),r=n;if(T()===`windows`&&(r=n.split(A.sep).join(k.sep)),!e.some(e=>{let t=e;T()===`windows`&&(t=e.split(A.sep).join(k.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(T()===`windows`){let e=n.split(k.sep).join(A.sep);t.push({issue:`Native installation exists but ${e} is not in your PATH`,fix:`Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`})}else{let e=P(),n=I()[e],r=n?n.replace(D(),`~`):`your shell config file`;t.push({issue:`Native installation exists but ~/.local/bin is not in your PATH`,fix:`Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ${r} then open a new terminal or run: source ${r}`})}}a(process.env.DISABLE_INSTALLATION_CHECKS)||(e===`npm-local`&&n.installMethod!==`local`&&t.push({issue:`Running from local installation but config install method is '${n.installMethod}'`,fix:`Consider using native installation: claude install`}),e===`native`&&n.installMethod!==`native`&&t.push({issue:`Running native installation but config install method is '${n.installMethod}'`,fix:`Run claude install to update configuration`})),e===`npm-global`&&await N()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await R(),i=await ze();return e===`npm-local`&&!await w(`claude`)&&!i&&(r?t.push({issue:`Local installation not accessible`,fix:`Alias exists but points to invalid target: ${r}. Update alias: alias claude="~/.workmate/local/claude"`}):t.push({issue:`Local installation not accessible`,fix:`Create alias: alias claude="~/.workmate/local/claude"`})),t}function rt(){if(T()!==`linux`)return[];let e=[],t=c.getLinuxGlobPatternWarnings();if(t.length>0){let n=t.slice(0,3).join(`, `),r=t.length-3,i=r>0?`${n} (${r} more)`:n;e.push({issue:`Glob patterns in sandbox permission rules are not fully supported on Linux`,fix:`Found ${t.length} pattern(s): ${i}. On Linux, glob patterns in Edit/Read rules will be ignored.`})}return e}async function it(){let e=await Qe(),t=typeof MACRO<`u`?`0.0.19`:`unknown`,n=await $e(),r=et(),i=await tt(),a=await nt(e);if(a.push(...rt()),e===`native`){let e=i.filter(e=>e.type===`npm-global`||e.type===`npm-global-orphan`||e.type===`npm-local`),t=T()===`windows`;for(let n of e)n.type===`npm-global`?a.push({issue:`Leftover npm global installation at ${n.path}`,fix:`Run: npm -g uninstall @anthropic-ai/workmate`}):n.type===`npm-global-orphan`?a.push({issue:`Orphaned npm global package at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`}):n.type===`npm-local`&&a.push({issue:`Leftover npm local installation at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`})}let o=v().installMethod||`not set`,s=null;e===`npm-global`&&(s=(await Ue()).hasPermissions,!s&&!_()&&a.push({issue:`Insufficient permissions for auto-updates`,fix:"Do one of: (1) Re-install node without sudo, or (2) Use `claude install` for native installation"}));let c=Te(),ee={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},te=e===`package-manager`?await Ye():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=_();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:te,ripgrepStatus:ee}}var at=e((()=>{ge(),Ge(),xe(),y(),te(),o(),b(),f(),F(),Xe(),be(),we(),ee(),fe(),ue(),B(),h(),ye()}));function J(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??D()}}function Y(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?k.join(e,...t):O(e,...t)}function ot(e){let{env:t,home:n}=J(e);return t.XDG_STATE_HOME??Y(n,`.local`,`state`)}function st(e){let{env:t,home:n}=J(e);return t.XDG_CACHE_HOME??Y(n,`.cache`)}function ct(e){let{env:t,home:n}=J(e);return t.XDG_DATA_HOME??Y(n,`.local`,`share`)}function lt(e){let{home:t}=J(e);return Y(t,`.local`,`bin`)}var ut=e((()=>{}));function dt(){let e=process.env.ENABLE_PID_BASED_VERSION_LOCKING;return a(e)?!0:(r(e),!1)}function X(e){if(e<=1)return!1;try{return process.kill(e,0),!0}catch{return!1}}function ft(e,t){if(!X(e))return!1;if(e===process.pid)return!0;try{let n=De(e);if(!n)return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r.includes(`claude`)||r.includes(i)}catch{return!0}}function Z(e){let t=m();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=u(n);return typeof r.pid!=`number`||!r.version||!r.execPath?null:r}catch{return null}}function Q(e){let t=Z(e);if(!t)return!1;let{pid:n,execPath:r}=t;if(!X(n))return!1;if(!ft(n,r))return d(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=m();try{let t=i.statSync(e);if(Date.now()-t.mtimeMs>$&&!X(n))return!1}catch{}return!0}function pt(e,t){let n=m(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{ae(r,re(t,null,2),{encoding:`utf8`,flush:!0}),n.renameSync(r,e)}catch(e){try{n.unlinkSync(r)}catch{}throw e}}async function mt(e,t){let n=m(),r=Oe(e);if(Q(t))return d(`Cannot acquire lock for ${r} - held by PID ${Z(t)?.pid}`),null;let i={pid:process.pid,version:r,execPath:process.execPath,acquiredAt:Date.now()};try{return pt(t,i),Z(t)?.pid===process.pid?(d(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Z(t)?.pid===process.pid&&(n.unlinkSync(t),d(`Released PID lock for ${r}`))}catch(e){d(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return d(`Failed to acquire lock for ${r}: ${e}`),null}}async function ht(e,t){let n=await mt(e,t);if(!n)return!1;let r=()=>{try{n()}catch{}};return process.on(`exit`,r),process.on(`SIGINT`,r),process.on(`SIGTERM`,r),!0}async function gt(e,t,n){let r=await mt(e,t);if(!r)return!1;try{return await n(),!0}finally{r()}}function _t(e){let t=m(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=O(e,t),i=Z(r);i&&n.push({version:i.version,pid:i.pid,isProcessRunning:X(i.pid),execPath:i.execPath,acquiredAt:new Date(i.acquiredAt),lockFilePath:r})}}catch(e){if(ne(e))return n;C(oe(e))}return n}function vt(e){let t=m(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=O(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,d(`Cleaned up legacy directory lock: ${i}`)):Q(r)||(t.unlinkSync(r),n++,d(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(ne(e))return 0;C(oe(e))}return n}var $,yt=e((()=>{p(),o(),l(),f(),Ee(),S(),h(),$=7200*1e3}));export{L as C,F as E,B as S,P as T,Be as _,Q as a,Le as b,gt as c,ct as d,ot as f,at as g,it as h,yt as i,lt as l,Qe as m,vt as n,dt as o,ut as p,_t as r,Z as s,ht as t,st as u,Ge as v,Re as w,I as x,Ve as y};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,Gg as n,Hg as r,XT as i,ZT as a,_b as o,b as s,eE as c,lb as l}from"./loadAgentsDir-CbtNPJV3.js";import{I as u,P as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as m,zt as h}from"./state-BPFYBqm1.js";import{a as g,i as _,r as v,t as y}from"./promptEditor-CRIw6vJS.js";import{r as b,t as x}from"./staticRender-D9AbnQFr.js";function S({planContent:e,planPath:t,editorName:n}){return(0,w.jsxs)(u,{flexDirection:`column`,children:[(0,w.jsx)(d,{bold:!0,children:`Current Plan`}),(0,w.jsx)(d,{dimColor:!0,children:t}),(0,w.jsx)(u,{marginTop:1,children:(0,w.jsx)(d,{children:e})}),n&&(0,w.jsxs)(u,{marginTop:1,children:[(0,w.jsx)(d,{dimColor:!0,children:`"/plan open"`}),(0,w.jsx)(d,{dimColor:!0,children:` to edit this plan in `}),(0,w.jsx)(d,{bold:!0,dimColor:!0,children:n})]})]})}async function C(e,n,s){let{getAppState:c,setAppState:l}=n,u=c().toolPermissionContext.mode;if(u!==`plan`){h(u,`plan`),l(e=>({...e,toolPermissionContext:r(t(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let n=s.trim();return n&&n!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let d=i(),f=a();if(!d)return e(`Already in plan mode. No plan written yet.`),null;if(s.trim().split(/\s+/)[0]===`open`){let t=await y(f);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${f}`),null}let p=_();return e(await b((0,w.jsx)(S,{planContent:d,planPath:f,editorName:p?o(p):void 0}))),null}var w;e((()=>{m(),f(),g(),l(),n(),s(),c(),v(),x(),w=p()}))();export{C as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,GT as n,Gg as r,Hg as i,KT as a,YT as o,b as s,fb as c,sb as l}from"./loadAgentsDir-DXOkUcW3.js";import{I as u,P as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Rt as m,Ut as h}from"./state-D5D6QpTX.js";import{a as g,i as _,r as v,t as y}from"./promptEditor-eJzbtNn4.js";import{r as b,t as x}from"./staticRender-D9AbnQFr.js";function S({planContent:e,planPath:t,editorName:n}){return(0,w.jsxs)(u,{flexDirection:`column`,children:[(0,w.jsx)(d,{bold:!0,children:`Current Plan`}),(0,w.jsx)(d,{dimColor:!0,children:t}),(0,w.jsx)(u,{marginTop:1,children:(0,w.jsx)(d,{children:e})}),n&&(0,w.jsxs)(u,{marginTop:1,children:[(0,w.jsx)(d,{dimColor:!0,children:`"/plan open"`}),(0,w.jsx)(d,{dimColor:!0,children:` to edit this plan in `}),(0,w.jsx)(d,{bold:!0,dimColor:!0,children:n})]})]})}async function C(e,r,o){let{getAppState:s,setAppState:l}=r,u=s().toolPermissionContext.mode;if(u!==`plan`){m(u,`plan`),l(e=>({...e,toolPermissionContext:i(t(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let n=o.trim();return n&&n!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let d=n(),f=a();if(!d)return e(`Already in plan mode. No plan written yet.`),null;if(o.trim().split(/\s+/)[0]===`open`){let t=await y(f);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${f}`),null}let p=_();return e(await b((0,w.jsx)(S,{planContent:d,planPath:f,editorName:p?c(p):void 0}))),null}var w;e((()=>{h(),f(),g(),l(),r(),s(),o(),v(),x(),w=p()}))();export{C as call};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i}from"./debug-BQj6h99Q.js";import{o as a,s as o}from"./log-BlJ7CcKG.js";import{release as s}from"os";import{readFile as c,readdir as l}from"fs/promises";async function u(e){let t=new Set;process.env.P4PORT&&t.add(`perforce`);try{let n=e??i().cwd(),r=new Set(await l(n));for(let[e,n]of h)r.has(e)&&t.add(n)}catch{}return[...t]}var d,f,p,m,h,g=e((()=>{n(),r(),a(),d=[`macos`,`wsl`],f=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){o(e)}return`linux`}return`unknown`}catch(e){return o(e),`unknown`}}),p=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){o(e);return}}),m=t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:s()};try{let t=await c(`/etc/os-release`,`utf8`);for(let n of t.split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i}from"./debug-D58GQBDG.js";import{o as a,s as o}from"./log-CZ7ploQm.js";import{release as s}from"os";import{readFile as c,readdir as l}from"fs/promises";async function u(e){let t=new Set;process.env.P4PORT&&t.add(`perforce`);try{let n=e??i().cwd(),r=new Set(await l(n));for(let[e,n]of h)r.has(e)&&t.add(n)}catch{}return[...t]}var d,f,p,m,h,g=e((()=>{n(),r(),a(),d=[`macos`,`wsl`],f=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){o(e)}return`linux`}return`unknown`}catch(e){return o(e),`unknown`}}),p=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){o(e);return}}),m=t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:s()};try{let t=await c(`/etc/os-release`,`utf8`);for(let n of t.split(`
2
2
  `)){let t=n.match(/^(ID|VERSION_ID)=(.*)$/);if(t?.[1]&&t[2]){let n=t[2].replace(/^"|"$/g,``);t[1]===`ID`?e.linuxDistroId=n:e.linuxDistroVersion=n}}}catch{}return e}),h=[[`.git`,`git`],[`.hg`,`mercurial`],[`.svn`,`svn`],[`.p4config`,`perforce`],[`$tf`,`tfs`],[`.tfvc`,`tfs`],[`.jj`,`jujutsu`],[`.sl`,`sapling`]]}));export{p as a,f as i,u as n,g as o,m as r,d as t};
@@ -0,0 +1,17 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$h as o,$o as s,$x as c,Ao as l,Aw as u,Bo as d,Do as f,Dp as p,Fw as m,Go as h,Gx as g,Ho as ee,Hx as _,Io as v,Jo as y,Jx as b,Kx as x,Lo as te,Lw as S,Mu as ne,No as C,Op as w,Ow as T,Pu as E,Pw as D,Qo as O,Qx as k,Rw as A,To as re,Vx as j,Wo as ie,Xh as M,Xo as ae,Xx as N,Yo as oe,Yx as se,Zh as ce,Zo as le,Zx as ue,as as P,cd as F,co as de,dg as fe,dw as pe,eS as me,es as he,gC as ge,ho as I,hw as _e,hx as ve,is as ye,ld as be,lo as xe,mo as L,mw as Se,ns as Ce,qx as we,tS as Te,uC as Ee,ug as De,vx as Oe,wo as ke,ww as Ae,xo as je}from"./loadAgentsDir-DXOkUcW3.js";import{D as Me,Gr as Ne,Gt as R,H as Pe,I as z,P as B,T as V,Wt as Fe,Xn as Ie,ai as Le,hn as Re,j as ze,k as Be,n as Ve,ot as He,r as Ue,t as We,x as Ge,y as Ke}from"./src-DL3w8VPk2.js";import{t as qe}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Je,R as Ye,S as Xe,U as Ze,c as Qe,i as $e,x as et}from"./debug-D58GQBDG.js";import{In as tt,Ln as nt,_t as rt,b as it,bt as at,d as ot,h as st,s as ct}from"./settings-3xZ0fsvE.js";import{b as lt,h as ut}from"./config-DRy1I12M.js";import{o as dt,s as ft}from"./log-CZ7ploQm.js";import{n as pt,r as mt}from"./analytics-DJobLaWP.js";import{C as ht,y as gt}from"./startupProfiler-CbzxVmbv.js";import{l as H,o as _t}from"./stringUtils-CKD8qDqx.js";import{n as vt,t as yt}from"./pluginStartupCheck-DhhMk3dA.js";import{a as bt,d as xt,f as St,i as Ct,l as wt,o as Tt,s as Et,u as Dt}from"./pluginOperations-BBwGEdfC.js";import{a as Ot,c as kt,i as At,n as jt,o as Mt,s as Nt,t as Pt}from"./validatePlugin-CxrlCKc1.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-BDTgCYuC.js";import{i as zt,n as Bt}from"./MCPConnectionManager-CdpO2Tj9.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";import{t as Ut}from"./SearchBox-CwwV0W-w.js";import{n as Wt,t as Gt}from"./useSearchInput-CXTa-leH.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-Ch4jOk_x.js";import{i as en,n as tn}from"./pluginAutoupdate-C2YbEHrP.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:u,cliMode:d=!1}){let f=(0,on.useRef)(!1),[m,h]=(0,on.useState)(!1),[g,ee]=(0,on.useState)(``),_=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ot(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{h(!0),ee(``);let{name:e,resolvedSource:t}=await l(n,e=>{ee(e)});ie(e,{source:t}),ye();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),u&&await u(),ee(``),h(!1),d?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),ee(``),h(!1),s(d?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!f.current&&!i&&!o&&(f.current=!0,_())},[]),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsxs)(z,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(z,{marginBottom:1,children:(0,U.jsx)(B,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsx)(B,{children:`Enter marketplace source:`}),(0,U.jsx)(B,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(B,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(B,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(B,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(B,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(F,{value:e,onChange:t,onSubmit:_,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),m&&(0,U.jsxs)(z,{marginTop:1,children:[(0,U.jsx)(ne,{}),(0,U.jsx)(B,{children:g||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{color:`error`,children:i})}),o&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{children:o})})]}),(0,U.jsx)(z,{marginLeft:3,children:(0,U.jsx)(B,{dimColor:!0,italic:!0,children:(0,U.jsxs)(V,{children:[(0,U.jsx)(Me,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(p,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{on=t(Le(),1),pt(),w(),We(),E(),be(),Ye(),dt(),P(),v(),At(),U=qe()}));function cn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Fe(`confirm:no`,o,{context:`Settings`}),R({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Re((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let ee=g.sensitive===!0,_=g.required===!0,v=ee?`*`.repeat(Ne(p)):p;return(0,dn.jsxs)(Ke,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{bold:!0,children:[g.title||h,_&&(0,dn.jsx)(B,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(B,{dimColor:!0,children:g.description}),(0,dn.jsxs)(z,{marginTop:1,children:[(0,dn.jsxs)(B,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(B,{children:v}),(0,dn.jsx)(B,{children:`█`})]})]}),(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(Le(),1),We(),Ee(),r(),dn=qe()}));async function pn(e){let{enabled:t,disabled:n}=await xe();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=g(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>we(t),save:n=>b(t,n,e.manifest.userConfig)});let i=j(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>ue(t,r.server)??void 0,save:e=>c(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),o=hn.useRef(n);if(o.current=n,hn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function l(e){try{s.save(e)}catch(e){n(`error`,Je(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,gn.jsx)(ln,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:l,onCancel:()=>n(`skipped`)},s.key)}var hn,gn,_n=e((()=>{hn=t(Le(),1),Ye(),se(),_(),de(),x(),fn(),gn=qe()}));function vn(){let e=s();return(0,yn.jsxs)(z,{marginBottom:1,children:[(0,yn.jsxs)(B,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(B,{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(),We(),he(),yn=qe()}));function xn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function Sn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Cn({hasSelection:e}){return(0,wn.jsx)(z,{marginTop:1,children:(0,wn.jsx)(B,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(V,{children:[e&&(0,wn.jsx)(p,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(p,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{w(),We(),wn=qe()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var Dn,On,kn=e((()=>{Dn=t(Le(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:c}){let[l,u]=(0,W.useState)(`marketplace-list`),[d,f]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,ee]=(0,W.useState)([]),[_,v]=(0,W.useState)([]),[b,x]=(0,W.useState)(!0),[S,ne]=(0,W.useState)(null),[w,T]=(0,W.useState)(0),[E,D]=(0,W.useState)(new Set),[k,A]=(0,W.useState)(new Set),j=En({totalItems:_.length,selectedIndex:w}),[ie,M]=(0,W.useState)(0),[N,oe]=(0,W.useState)(!1),[se,ce]=(0,W.useState)(null),[ue,P]=(0,W.useState)(null);Fe(`confirm:no`,jn.useCallback(()=>{l===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):g.length===1?i({type:`menu`}):(u(`marketplace-list`),f(null),D(new Set)):l===`plugin-details`?(u(`plugin-list`),h(null)):i({type:`menu`})},[l,s,i,g.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await te(),{marketplaces:n,failures:r}=await Ce(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>re(y(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:O(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),ee(i);let a=le(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)P(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!c){let e=i[0];e&&(f(e.name),u(`plugin-list`))}if(c){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await C(t);if(e){let i=e.plugins.find(e=>e.name===c);if(i){let e=y(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:ke(e)},r=t;break}}}if(n&&r){let e=n.pluginId;ke(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(f(r),h(n),u(`plugin-details`))}else t(`Plugin "${c}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(f(s),u(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{x(!1)}}e()},[t,s,c]),(0,W.useEffect)(()=>{if(!d)return;let e=!1;async function n(n){x(!0);try{let t=await C(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=y(e.name,n);fe(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:ke(t)})}try{let t=await Nt();if(e)return;ne(t),t?r.sort((e,n)=>{let r=t.get(e.pluginId)??0,i=t.get(n.pluginId)??0;return r===i?e.entry.name.localeCompare(n.entry.name):i-r}):r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(t){if(e)return;Qe(`Failed to fetch install counts: ${Je(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}v(r),T(0),D(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{x(!1)}}return n(d),()=>{e=!0}},[d,t]);let F=async()=>{if(E.size===0)return;let e=_.filter(e=>E.has(e.pluginId));A(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await I({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}A(new Set),D(new Set),ye(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},de=async(e,t=`user`)=>{oe(!0),ce(null);let n=await I({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){oe(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else oe(!1),ce(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),R({"select:previous":()=>{w>0&&T(w-1)},"select:next":()=>{w<g.length-1&&T(w+1)},"select:accept":()=>{let e=g[w];e&&(f(e.name),u(`plugin-list`))}},{context:`Select`,isActive:l===`marketplace-list`}),R({"select:previous":()=>{w>0&&j.handleSelectionChange(w-1,T)},"select:next":()=>{w<_.length-1&&j.handleSelectionChange(w+1,T)},"select:accept":()=>{if(w===_.length&&E.size>0)F();else if(w<_.length){let e=_[w];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(h(e),u(`plugin-details`),M(0),ce(null)))}}},{context:`Select`,isActive:l===`plugin-list`}),R({"plugin:toggle":()=>{if(w<_.length){let e=_[w];if(e&&!e.isInstalled){let t=new Set(E);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),D(t)}}},"plugin:install":()=>{E.size>0&&F()}},{context:`Plugin`,isActive:l===`plugin-list`});let pe=jn.useMemo(()=>{if(!m)return[];let e=m.entry.homepage;return Sn(e,xn(m))},[m]);if(R({"select:previous":()=>{ie>0&&M(ie-1)},"select:next":()=>{ie<pe.length-1&&M(ie+1)},"select:accept":()=>{if(!m)return;let e=pe[ie]?.action,t=m.entry.homepage,n=xn(m);e===`install-user`?de(m,`user`):e===`install-project`?de(m,`project`):e===`install-local`?de(m,`local`):e===`homepage`&&t?Te(t):e===`github`&&n?Te(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),h(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!m}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(mn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(b)return(0,G.jsx)(B,{children:`Loading…`});if(e)return(0,G.jsx)(B,{color:`error`,children:e});if(l===`marketplace-list`)return g.length===0?(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(B,{children:`No marketplaces configured.`}),(0,G.jsxs)(B,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),ue&&(0,G.jsx)(z,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(B,{color:`warning`,children:[a.warning,` `,ue]})}),g.map((e,t)=>(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:+(t<g.length-1),children:[(0,G.jsx)(z,{children:(0,G.jsxs)(B,{color:w===t?`suggestion`:void 0,children:[w===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(z,{marginLeft:2,children:(0,G.jsxs)(B,{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)(z,{marginTop:1,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(l===`plugin-details`&&m){let e=m.entry.homepage,t=Sn(e,xn(m));return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:m.entry.name}),m.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[`Version: `,m.entry.version]}),m.entry.description&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsx)(B,{children:m.entry.description})}),m.entry.author&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof m.entry.author==`string`?m.entry.author:m.entry.author.name]})})]}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:`Will install:`}),m.entry.commands&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(m.entry.commands)?m.entry.commands.join(`, `):Object.keys(m.entry.commands).join(`, `)]}),m.entry.agents&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(m.entry.agents)?m.entry.agents.join(`, `):Object.keys(m.entry.agents).join(`, `)]}),m.entry.hooks&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Hooks: `,Object.keys(m.entry.hooks).join(`, `)]}),m.entry.mcpServers&&(0,G.jsxs)(B,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(m.entry.mcpServers)?m.entry.mcpServers.join(`, `):typeof m.entry.mcpServers==`object`?Object.keys(m.entry.mcpServers).join(`, `):`configured`]}),!m.entry.commands&&!m.entry.agents&&!m.entry.hooks&&!m.entry.mcpServers&&(typeof m.entry.source==`object`&&`source`in m.entry.source&&(m.entry.source.source===`github`||m.entry.source.source===`url`||m.entry.source.source===`npm`||m.entry.source.source===`pip`)?(0,G.jsx)(B,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(B,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(vn,{}),se&&(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsxs)(B,{color:`error`,children:[`Error: `,se]})}),(0,G.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(z,{children:[ie===t&&(0,G.jsx)(B,{children:`> `}),ie!==t&&(0,G.jsx)(B,{children:` `}),(0,G.jsx)(B,{bold:ie===t,children:N&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(_.length===0)return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(B,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(B,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(z,{marginLeft:3,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let me=j.getVisibleItems(_);return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install Plugins`})}),j.scrollPosition.canScrollUp&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),me.map((t,n)=>{let r=j.toActualIndex(n),i=w===r,o=E.has(t.pluginId),s=k.has(t.pluginId);return(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:n===me.length-1&&!e?0:1,children:[(0,G.jsxs)(z,{children:[(0,G.jsxs)(B,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(B,{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)(B,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(B,{dimColor:!0,children:` (installed)`}),S&&d===`claude-plugins-official`&&(0,G.jsxs)(B,{dimColor:!0,children:[` · `,Mt(S.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(z,{marginLeft:4,children:[(0,G.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),j.scrollPosition.canScrollDown&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:E.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(Le(),1),W=t(Le(),1),w(),We(),Ee(),nt(),me(),$e(),Ye(),P(),kt(),je(),he(),v(),Ae(),L(),De(),_t(),gt(),_n(),bn(),Tn(),kn(),G=qe()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:c}){let[l,u]=(0,K.useState)(`plugin-list`),[d,f]=(0,K.useState)(null),[m,h]=(0,K.useState)([]),[g,ee]=(0,K.useState)(!0),[_,v]=(0,K.useState)(null),[b,x]=(0,K.useState)(!1),S=(0,K.useCallback)(e=>{x(e),s?.(e)},[s]),{query:ne,setQuery:C,cursorOffset:w}=Wt({isActive:l===`plugin-list`&&b&&!g,onExit:()=>{S(!1)}}),T=Ie(),{columns:E}=He(),D=(0,K.useMemo)(()=>{if(!ne)return m;let e=ne.toLowerCase();return m.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[m,ne]),[O,k]=(0,K.useState)(0),[A,re]=(0,K.useState)(new Set),[j,ie]=(0,K.useState)(new Set),M=En({totalItems:D.length,selectedIndex:O});(0,K.useEffect)(()=>{k(0)},[ne]);let[N,se]=(0,K.useState)(0),[ce,ue]=(0,K.useState)(!1),[P,F]=(0,K.useState)(null),[de,pe]=(0,K.useState)(null),[me,he]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await te(),{marketplaces:n,failures:r}=await Ce(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=y(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:ke(t)})}let a=i.filter(e=>!e.isInstalled&&!fe(e.pluginId));try{let e=await Nt();v(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){Qe(`Failed to fetch install counts: ${Je(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}h(a);let o=Object.keys(e).length;if(a.length===0){let e=await oe({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});he(e)}let s=le(r,tt(n,e=>e.data!==null));if(s)if(s.type===`warning`)pe(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(c){let e=i.find(e=>e.entry.name===c);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(f(e),u(`plugin-details`)):t(`Plugin "${c}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{ee(!1)}}e()},[t,c]);let ge=async()=>{if(A.size===0)return;let e=m.filter(e=>A.has(e.pluginId));ie(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await I({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ie(new Set),re(new Set),ye(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},_e=async(e,t=`user`)=>{ue(!0),F(null);let n=await I({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){ue(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else ue(!1),F(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Fe(`confirm:no`,()=>{u(`plugin-list`),f(null)},{context:`Confirmation`,isActive:l===`plugin-details`}),Fe(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:l===`plugin-list`&&!b}),Re((e,t)=>{let n=!t.ctrl&&!t.meta;b||(e===`/`&&n?(S(!0),C(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(S(!0),C(e)))},{isActive:l===`plugin-list`&&!g}),R({"select:previous":()=>{O===0?S(!0):M.handleSelectionChange(O-1,k)},"select:next":()=>{O<D.length-1&&M.handleSelectionChange(O+1,k)},"select:accept":()=>{if(O===D.length&&A.size>0)ge();else if(O<D.length){let e=D[O];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(f(e),u(`plugin-details`),se(0),F(null)))}}},{context:`Select`,isActive:l===`plugin-list`&&!b}),R({"plugin:toggle":()=>{if(O<D.length){let e=D[O];if(e&&!e.isInstalled){let t=new Set(A);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),re(t)}}},"plugin:install":()=>{A.size>0&&ge()}},{context:`Plugin`,isActive:l===`plugin-list`&&!b});let ve=In.useMemo(()=>{if(!d)return[];let e=d.entry.homepage;return Sn(e,xn(d))},[d]);if(R({"select:previous":()=>{N>0&&se(N-1)},"select:next":()=>{N<ve.length-1&&se(N+1)},"select:accept":()=>{if(!d)return;let e=ve[N]?.action,t=d.entry.homepage,n=xn(d);e===`install-user`?_e(d,`user`):e===`install-project`?_e(d,`project`):e===`install-local`?_e(d,`local`):e===`homepage`&&t?Te(t):e===`github`&&n?Te(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),f(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!d}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(mn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(g)return(0,q.jsx)(B,{children:`Loading…`});if(e)return(0,q.jsx)(B,{color:`error`,children:e});if(l===`plugin-details`&&d){let e=d.entry.homepage,t=Sn(e,xn(d));return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(B,{bold:!0,children:d.entry.name}),(0,q.jsxs)(B,{dimColor:!0,children:[`from `,d.marketplaceName]}),d.entry.version&&(0,q.jsxs)(B,{dimColor:!0,children:[`Version: `,d.entry.version]}),d.entry.description&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{children:d.entry.description})}),d.entry.author&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof d.entry.author==`string`?d.entry.author:d.entry.author.name]})})]}),(0,q.jsx)(vn,{}),P&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`error`,children:[`Error: `,P]})}),(0,q.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(z,{children:[N===t&&(0,q.jsx)(B,{children:`> `}),N!==t&&(0,q.jsx)(B,{children:` `}),(0,q.jsx)(B,{bold:N===t,children:ce&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,children:(0,q.jsxs)(V,{children:[(0,q.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(m.length===0)return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:me}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let be=M.getVisibleItems(D);return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{bold:!0,children:`Discover plugins`}),M.needsPagination&&(0,q.jsxs)(B,{dimColor:!0,children:[` `,`(`,M.scrollPosition.current,`/`,M.scrollPosition.total,`)`]})]}),(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(Be,{query:ne,isFocused:b,isTerminalFocused:T,width:E-4,cursorOffset:w})}),de&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`warning`,children:[a.warning,` `,de]})}),D.length===0&&ne&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`No plugins match "`,ne,`"`]})}),M.scrollPosition.canScrollUp&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),be.map((t,n)=>{let r=M.toActualIndex(n),i=O===r,o=A.has(t.pluginId),s=j.has(t.pluginId);return(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:n===be.length-1&&!e?0:1,children:[(0,q.jsxs)(z,{children:[(0,q.jsxs)(B,{color:i&&!b?`suggestion`:void 0,children:[i&&!b?a.pointer:` `,` `]}),(0,q.jsxs)(B,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(B,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),_&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(B,{dimColor:!0,children:[` · `,Mt(_.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(z,{marginLeft:4,children:(0,q.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)})})]},`${M.startIndex}-${t.pluginId}`)}),M.scrollPosition.canScrollDown&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:A.size>0,canToggle:O<D.length&&!D[O]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:(0,q.jsxs)(V,{children:[e&&(0,q.jsx)(p,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(B,{children:`type to search`}),t&&(0,q.jsx)(p,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(p,{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)(B,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(B,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(B,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(Le(),1),K=t(Le(),1),w(),Ut(),We(),Gt(),ge(),Ee(),nt(),me(),$e(),Ye(),P(),kt(),je(),he(),v(),Ae(),L(),De(),_t(),gt(),_n(),bn(),Tn(),kn(),q=qe()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:c}){let[l,u]=(0,Bn.useState)([]),[f,m]=(0,Bn.useState)(!0),[g,_]=(0,Bn.useState)(0),[v,b]=(0,Bn.useState)(!1),[x,S]=(0,Bn.useState)(null),[ne,C]=(0,Bn.useState)(null),[w,T]=(0,Bn.useState)(null),[E,D]=(0,Bn.useState)(`list`),[k,A]=(0,Bn.useState)(null),[re,j]=(0,Bn.useState)(0),ie=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await te(),{enabled:r,disabled:i}=await xe(),a=[...r,...i],{marketplaces:o,failures:l}=await Ce(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:O(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:at(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=le(l,tt(o,e=>e.data!==null));if(f)if(f.type===`warning`)S(f.message);else throw Error(f.message);if(s&&!ie.current&&!t){ie.current=!0;let e=d.findIndex(e=>e.name===s);if(e>=0){let t=d[e];if(c){_(e+1);let t=[...d];c===`update`?t[e].pendingUpdate=!0:c===`remove`&&(t[e].pendingRemove=!0),u(t),setTimeout(N,100,t)}else t&&(_(e+1),A(t),D(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),S(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{m(!1)}}e()},[s,c,t]);let M=()=>l.some(e=>e.pendingUpdate||e.pendingRemove),ae=()=>({updateCount:tt(l,e=>e.pendingUpdate),removeCount:tt(l,e=>e.pendingRemove)}),N=async t=>{let i=t||l,s=E===`details`;b(!0),S(null),C(null),T(null);try{let t=ct(`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=y(t.name,e.name);n[r]=!1}it(`userSettings`,{enabledPlugins:n})}await ee(e.name),c++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await d(e.name,e=>{T(e)}),n++,l.add(e.name.toLowerCase()),mt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let f=0;l.size>0&&(f=(await en(l)).length),ye(),o&&await o();let p=await te(),{enabled:m,disabled:h}=await xe(),g=[...m,...h],{marketplaces:_}=await Ce(p),v=[];for(let{name:e,config:t,data:n}of _){let r=g.filter(t=>t.source.endsWith(`@${e}`));v.push({name:e,source:O(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:at(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&&k){let e=v.find(e=>e.name===k.name);e&&A(e)}let b=[];if(n>0){let e=f>0?` (${f} ${H(f,`plugin`)} bumped)`:``;b.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&b.push(`Removed ${c} ${H(c,`marketplace`)}`),b.length>0){let t=`${a.tick} ${b.join(`, `)}`;s?C(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Je(e);S(t),n&&n(t)}finally{b(!1),T(null)}},oe=async()=>{if(!k)return;let e=l.map(e=>e.name===k.name?{...e,pendingRemove:!0}:e);u(e),await N(e)},se=e=>{if(!e)return[];let t=[{label:`Browse plugins (${e.pluginCount??0})`,value:`browse`},{label:`Update marketplace`,secondaryLabel:e.lastUpdated?`(last updated ${new Date(e.lastUpdated).toLocaleDateString()})`:void 0,value:`update`}];return lt()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},ce=async e=>{let t=!e.autoUpdate;try{await h(e.name,t),u(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),A(e=>e&&{...e,autoUpdate:t})}catch(e){S(e instanceof Error?e.message:`Failed to update setting`)}};if(Fe(`confirm:no`,()=>{D(`list`),j(0)},{context:`Confirmation`,isActive:!v&&(E===`details`||E===`confirm-remove`)}),Fe(`confirm:no`,()=>{u(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),_(0)},{context:`Confirmation`,isActive:!v&&E===`list`&&M()}),Fe(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!v&&E===`list`&&!M()}),R({"select:previous":()=>_(e=>Math.max(0,e-1)),"select:next":()=>{let e=l.length+1;_(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=g-1;if(g===0)e({type:`add-marketplace`});else if(M())N();else{let e=l[t];e&&(A(e),D(`details`),j(0))}}},{context:`Select`,isActive:!v&&E===`list`}),Re(e=>{let t=g-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&&(A(e),D(`confirm-remove`))}},{isActive:!v&&E===`list`}),R({"select:previous":()=>j(e=>Math.max(0,e-1)),"select:next":()=>{let e=se(k);j(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!k)return;let t=se(k)[re];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:k.name});else if(t?.value===`update`){let e=l.map(e=>e.name===k.name?{...e,pendingUpdate:!0}:e);u(e),N(e)}else t?.value===`toggle-auto-update`?ce(k):t?.value===`remove`&&D(`confirm-remove`)}},{context:`Select`,isActive:!v&&E===`details`}),Re(e=>{e===`y`||e===`Y`?oe():(e===`n`||e===`N`)&&(D(`list`),A(null))},{isActive:!v&&E===`confirm-remove`}),f)return(0,J.jsx)(B,{children:`Loading marketplaces…`});if(l.length===0)return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(B,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(V,{children:[(0,J.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(E===`confirm-remove`&&k){let e=k.installedPlugins?.length||0;return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsxs)(B,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(B,{italic:!0,children:k.name}),`?`]}),(0,J.jsxs)(z,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),k.installedPlugins&&k.installedPlugins.length>0&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,marginLeft:2,children:k.installedPlugins.map(e=>(0,J.jsxs)(B,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[`Press `,(0,J.jsx)(B,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(B,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(E===`details`&&k){let e=k.pendingUpdate||v,t=se(k);return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{bold:!0,children:k.name}),(0,J.jsx)(B,{dimColor:!0,children:k.source}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[k.pluginCount||0,` available `,H(k.pluginCount||0,`plugin`)]})}),k.installedPlugins&&k.installedPlugins.length>0&&(0,J.jsxs)(z,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(B,{bold:!0,children:[`Installed plugins (`,k.installedPlugins.length,`):`]}),(0,J.jsx)(z,{flexDirection:`column`,marginLeft:1,children:k.installedPlugins.map(e=>(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(B,{children:a.bullet}),(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{children:e.name}),(0,J.jsx)(B,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(B,{color:`claude`,children:`Updating marketplace…`}),w&&(0,J.jsx)(B,{dimColor:!0,children:w})]}),!e&&ne&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:ne})}),!e&&x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),!e&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===re;return(0,J.jsxs)(z,{children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(B,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!lt()&&k.autoUpdate&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(V,{children:[(0,J.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:ue,removeCount:P}=ae();return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:g===0?`suggestion`:void 0,children:[g===0?a.pointer:` `,` +`]}),(0,J.jsx)(B,{bold:!0,color:g===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(z,{flexDirection:`column`,children:l.map((e,t)=>{let n=t+1===g,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(z,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(B,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(B,{dimColor:!0,children:e.source}),(0,J.jsxs)(B,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),M()&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(B,{children:[(0,J.jsx)(B,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(B,{dimColor:!0,children:`Enter to apply`})]}),ue>0&&(0,J.jsxs)(B,{children:[`• Update `,ue,` `,H(ue,`marketplace`)]}),P>0&&(0,J.jsxs)(B,{color:`warning`,children:[`• Remove `,P,` `,H(P,`marketplace`)]})]}),v&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:`Processing changes…`})}),x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:M()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:(0,J.jsxs)(V,{children:[t&&(0,J.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(Me,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(Me,{shortcut:`r`,action:`remove`}),(0,J.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),Bn=t(Le(),1),pt(),w(),We(),Ee(),nt(),ut(),Ye(),P(),he(),v(),tn(),de(),rt(),st(),_t(),J=qe()}));function Hn(e){switch(e.type){case`path-not-found`:return`${e.component} path not found: ${e.path}`;case`git-auth-failed`:return`Git ${e.authType.toUpperCase()} authentication failed for ${e.gitUrl}`;case`git-timeout`:return`Git ${e.operation} timed out for ${e.gitUrl}`;case`network-error`:return`Network error accessing ${e.url}${e.details?`: ${e.details}`:``}`;case`manifest-parse-error`:return`Failed to parse manifest at ${e.manifestPath}: ${e.parseError}`;case`manifest-validation-error`:return`Invalid manifest at ${e.manifestPath}: ${e.validationErrors.join(`, `)}`;case`plugin-not-found`:return`Plugin "${e.pluginId}" not found in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return`Marketplace "${e.marketplace}" not found`;case`marketplace-load-failed`:return`Failed to load marketplace "${e.marketplace}": ${e.reason}`;case`mcp-config-invalid`:return`Invalid MCP server config for "${e.serverName}": ${e.validationError}`;case`mcp-server-suppressed-duplicate`:{let t=e.duplicateOf.startsWith(`plugin:`)?`server provided by plugin "${e.duplicateOf.split(`:`)[1]??`?`}"`:`already-configured "${e.duplicateOf}"`;return`MCP server "${e.serverName}" skipped — same command/URL as ${t}`}case`hook-load-failed`:return`Failed to load hooks from ${e.hookPath}: ${e.reason}`;case`component-load-failed`:return`Failed to load ${e.component} from ${e.path}: ${e.reason}`;case`mcpb-download-failed`:return`Failed to download MCPB from ${e.url}: ${e.reason}`;case`mcpb-extract-failed`:return`Failed to extract MCPB ${e.mcpbPath}: ${e.reason}`;case`mcpb-invalid-manifest`:return`MCPB manifest invalid at ${e.mcpbPath}: ${e.validationError}`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`Marketplace "${e.marketplace}" is blocked by enterprise policy`:`Marketplace "${e.marketplace}" is not in the allowed marketplace list`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Dependency "${e.dependency}" is disabled`:`Dependency "${e.dependency}" is not installed`;case`lsp-config-invalid`:return`Invalid LSP server config for "${e.serverName}": ${e.validationError}`;case`lsp-server-start-failed`:return`LSP server "${e.serverName}" failed to start: ${e.reason}`;case`lsp-server-crashed`:return e.signal?`LSP server "${e.serverName}" crashed with signal ${e.signal}`:`LSP server "${e.serverName}" crashed with exit code ${e.exitCode??`unknown`}`;case`lsp-request-timeout`:return`LSP server "${e.serverName}" timed out on ${e.method} after ${e.timeoutMs}ms`;case`lsp-request-failed`:return`LSP server "${e.serverName}" ${e.method} failed: ${e.error}`;case`plugin-cache-miss`:return`Plugin "${e.plugin}" not cached at ${e.installPath}`;case`generic-error`:return e.error}return S(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((()=>{A()}));function Gn({item:e,isSelected:t}){let[n]=Pe();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=ze(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=ze(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=ze(`success`,n)(a.tick),i=`enabled`):(r=ze(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=ze(`warning`,n)(a.warning);return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=ze(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=ze(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=ze(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=ze(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=ze(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=ze(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{dimColor:!t,children:`└ `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]}):(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),We(),_t(),Y=qe()}));async function qn(e){try{return(await rn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>nn.basename(e.name,`.md`))}catch(t){return Qe(`Failed to read plugin components from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}async function Jn(e){try{let t=await rn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=nn.join(e,r.name,`SKILL.md`);try{(await rn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return Qe(`Failed to read skill directories from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}function Yn({plugin:e,marketplace:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{async function n(){try{if(t===`builtin`){let t=D(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 C(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)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Components:`}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(B,{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)(B,{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)(B,{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)(B,{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)(B,{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 C(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!fe(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let c=ce(e=>e.mcp.clients),l=ce(e=>e.mcp.tools),d=ce(e=>e.plugins.errors),m=It(),[h,g]=(0,X.useState)(!1),ee=(0,X.useCallback)(e=>{g(e),r?.(e)},[r]),_=Ie(),{columns:v}=He(),[y,x]=(0,X.useState)(`plugin-list`),{query:te,setQuery:S,cursorOffset:ne}=Wt({isActive:y===`plugin-list`&&h,onExit:()=>{ee(!1)}}),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)([]),[A,re]=(0,X.useState)(!0),[j,ie]=(0,X.useState)(new Map),M=(0,X.useRef)(!1),ae=(0,X.useRef)(void 0),oe=zt();Fe(`confirm:no`,$n.useCallback(()=>{if(y===`plugin-details`)x(`plugin-list`),w(null),L(null);else if(typeof y==`object`&&y.type===`failed-plugin-details`)x(`plugin-list`),L(null);else if(y===`configuring`)x(`plugin-details`),Ce(null);else if(typeof y==`object`&&(y.type===`plugin-options`||y.type===`configuring-options`))x(`plugin-list`),w(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof y==`object`&&y.type===`flagged-detail`)x(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-detail`)x(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-tools`)x({type:`mcp-detail`,client:y.client});else if(typeof y==`object`&&y.type===`mcp-tool-detail`)x({type:`mcp-tools`,client:y.client});else{if(j.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[y,e,j,t]),{context:`Confirmation`,isActive:(y!==`plugin-list`||!h)&&y!==`confirm-project-uninstall`&&!(typeof y==`object`&&y.type===`confirm-data-cleanup`)});let se=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,le=(0,X.useMemo)(()=>{let e=ot(),t=new Map;for(let e of c)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:j.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of d){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=yt(),s=[];for(let[e,t]of a){if(e in m)continue;let n=u(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 l=[];for(let e of c)e.name!==`ide`&&(e.name.startsWith(`plugin:`)||l.push({type:`mcp`,id:`mcp:${e.name}`,name:e.name,description:void 0,scope:e.config.scope,status:se(e),client:e}));let f={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],h=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;h.has(n)||h.set(n,[]),h.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;h.has(r)||h.set(r,[]),h.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:se(n),client:n,indented:!0})}}for(let e of l){let t=e.scope;h.has(t)||h.set(t,[]),h.get(t).push(e)}for(let e of s){let t=e.scope;h.has(t)||h.set(t,[]),h.get(t).push(e)}for(let[e,t]of Object.entries(m)){let n=u(e),r=n.name||e,i=n.marketplace||`unknown`;h.has(`flagged`)||h.set(`flagged`,[]),h.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let g=[...h.keys()].sort((e,t)=>(f[e]??99)-(f[t]??99));for(let e of g){let t=h.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,c,d,j,m]),ue=(0,X.useMemo)(()=>le.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[le]);(0,X.useEffect)(()=>{ue.length>0&&Ft(ue)},[ue]);let P=(0,X.useMemo)(()=>{if(!te)return le;let e=te.toLowerCase();return le.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[le,te]),[F,de]=(0,X.useState)(0),fe=En({totalItems:P.length,selectedIndex:F,maxVisible:8}),[me,he]=(0,X.useState)(0),[ge,I]=(0,X.useState)(!1),[be,L]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!C){ke(!1);return}async function e(){let e=C.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&N(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&N(e))),!t)try{let e=nn.join(C.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Xe(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===C.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&N(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&N(e))}}catch(e){Qe(`Failed to read raw marketplace.json: ${e}`)}ke(t)}e()},[C]),(0,X.useEffect)(()=>{async function e(){re(!0);try{let{enabled:e,disabled:t}=await xe(),n=ot(),r=Zn([...e,...t]),i={};for(let e of r){let t=e.source.split(`@`)[1]||`local`;i[t]||(i[t]=[]),i[t].push(e)}let a=[];for(let[e,t]of Object.entries(i)){let r=tt(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),E(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:Tt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}O(o),de(0)}finally{re(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!M.current&&i&&T.length>0&&!A){let{name:e,marketplace:n}=u(i),r=o??n,a=r?T.filter(e=>e.name===r):T;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};w(r),x(`plugin-details`),ae.current=s,M.current=!0;return}}let c=le.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(x({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),M.current=!0),!M.current&&s&&(M.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,T,A,le,s,t]);let Ae=async r=>{if(!C)return;let i=C.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){L(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){L(`This plugin is managed by your organization. Contact your admin to disable it.`);return}I(!0),L(null);try{let o=`${C.plugin.name}@${C.marketplace}`,s;switch(r){case`enable`:{let e=await bt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await Ct(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!wt(i))break;if(Dt(o)){I(!1),x(`confirm-project-uninstall`);return}let e=f().plugins[o],t=!e||e.length<=1?await pe(o):null;if(t){I(!1),x({type:`confirm-data-cleanup`,size:t});return}let n=await xt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await St(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${C.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}ye();let c=`${C.plugin.name}@${C.marketplace}`;if(ot()?.enabledPlugins?.[c]!==!1){I(!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} ${C.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){I(!1);let t=e instanceof Error?e.message:String(e);L(`Failed to ${r}: ${t}`),ft(Ze(e))}},je=(0,X.useRef)(Ae);je.current=Ae,(0,X.useEffect)(()=>{if(y===`plugin-details`&&C&&ae.current){let e=ae.current;ae.current=void 0,je.current(e)}},[y,C]);let Me=$n.useCallback(()=>{if(F>=P.length)return;let e=P[F];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=ot(),r=j.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(j);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),ye()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),ye()}catch(e){ft(e)}})()),ie(e)}}else e?.type===`mcp`&&oe(e.client.name)},[F,P,j,D,oe]);R({"select:previous":()=>{F===0?ee(!0):fe.handleSelectionChange(F-1,de)},"select:next":()=>{F<P.length-1&&fe.handleSelectionChange(F+1,de)},"select:accept":$n.useCallback(()=>{if(F>=P.length)return;let e=P[F];if(e?.type===`plugin`){let t=D.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(w(t),x(`plugin-details`),he(0),L(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}}),L(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}}),he(0),L(null)):e?.type===`mcp`&&(x({type:`mcp-detail`,client:e.client}),L(null))},[F,P,D])},{context:`Select`,isActive:y===`plugin-list`&&!h}),R({"plugin:toggle":Me},{context:`Plugin`,isActive:y===`plugin-list`&&!h}),R({"select:accept":$n.useCallback(()=>{typeof y!=`object`||y.type!==`flagged-detail`||(Lt(y.plugin.id),x(`plugin-list`))},[y])},{context:`Select`,isActive:typeof y==`object`&&y.type===`flagged-detail`});let Ne=$n.useMemo(()=>{if(y!==`plugin-details`||!C)return[];let e=ot(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=C.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Ae(n?`disable`:`enable`)}),r||(i.push({label:C.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(C.plugin.name,C.marketplace);if(e){L(e);return}let t=[...D],n=t.findIndex(e=>e.plugin.name===C.plugin.name&&e.marketplace===C.marketplace);n!==-1&&(t[n].pendingUpdate=!C.pendingUpdate,O(t),w({...C,pendingUpdate:!C.pendingUpdate}))}catch(e){L(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Oe&&i.push({label:`Configure`,action:async()=>{De(!0);try{let e=C.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&N(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&N(n)){t=n;break}}if(!t){L(`No MCPB file found in plugin`),De(!1);return}let n=`${C.plugin.name}@${C.marketplace}`,r=await k(t,C.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ce(r),x(`configuring`)):L(`Failed to load MCPB for configuration`)}catch(e){let t=Je(e);L(`Failed to load configuration: ${t}`)}finally{De(!1)}}}),C.plugin.manifest.userConfig&&Object.keys(C.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{x({type:`configuring-options`,schema:C.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Ae(`update`)}),i.push({label:`Uninstall`,action:()=>void Ae(`uninstall`)})),C.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void Te(C.plugin.manifest.homepage)}),C.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void Te(C.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{x(`plugin-list`),w(null),L(null)}}),i},[y,C,Oe,D]);if(R({"select:previous":()=>{me>0&&he(me-1)},"select:next":()=>{me<Ne.length-1&&he(me+1)},"select:accept":()=>{Ne[me]&&Ne[me].action()}},{context:`Select`,isActive:y===`plugin-details`&&!!C}),R({"select:accept":()=>{typeof y==`object`&&y.type===`failed-plugin-details`&&(async()=>{I(!0),L(null);let e=y.plugin.id,t=y.plugin.scope,r=wt(t)?await xt(e,t,!1):await xt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=ct(t);n?.enabledPlugins?.[e]!==void 0&&(it(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}ye()}i?(n&&await n(),I(!1),x(`plugin-list`)):(I(!1),L(r.message))})()}},{context:`Select`,isActive:typeof y==`object`&&y.type===`failed-plugin-details`&&y.plugin.scope!==`managed`}),R({"confirm:yes":()=>{if(!C)return;I(!0),L(null);let r=`${C.plugin.name}@${C.marketplace}`,{error:i}=it(`localSettings`,{enabledPlugins:{...ct(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){I(!1),L(`Failed to write settings: ${i.message}`);return}ye(),t(`✓ Disabled ${C.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{x(`plugin-details`),L(null)}},{context:`Confirmation`,isActive:y===`confirm-project-uninstall`&&!!C&&!ge}),Re((r,i)=>{if(!C)return;let o=`${C.plugin.name}@${C.marketplace}`,s=C.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{I(!0),L(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);ye();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){I(!1),L(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(x(`plugin-details`),L(null))},{isActive:typeof y==`object`&&y.type===`confirm-data-cleanup`&&!!C&&!ge}),$n.useEffect(()=>{de(0)},[te]),Re((e,t)=>{let n=!t.ctrl&&!t.meta;h||(e===`/`&&n?(ee(!0),S(``),de(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(ee(!0),S(e),de(0)))},{isActive:y===`plugin-list`}),A)return(0,Z.jsx)(B,{children:`Loading installed plugins…`});if(le.length===0)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(B,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Esc to go back`})})]});if(typeof y==`object`&&y.type===`plugin-options`&&C){let r=`${C.plugin.name}@${C.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:C.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof y==`object`&&y.type===`configuring-options`&&C){let e=`${C.plugin.name}@${C.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${C.plugin.name}`,subtitle:`Plugin options`,configSchema:y.schema,initialValues:we(e),onSave:n=>{try{b(e,n,y.schema),ye(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){L(`Failed to save configuration: ${Je(e)}`)}x(`plugin-details`)},onCancel:()=>x(`plugin-details`)})}if(y===`configuring`&&Se&&C){let e=`${C.plugin.name}@${C.marketplace}`;async function n(n){if(!(!Se||!C))try{let r=C.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&N(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&N(e)){i=e;break}}if(!i){L(`No MCPB file found`),x(`plugin-details`);return}await k(i,C.plugin.path,e,void 0,n),L(null),Ce(null),x(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Je(e);L(`Failed to save configuration: ${t}`),x(`plugin-details`)}}function r(){Ce(null),x(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${Se.manifest.name}`,subtitle:`Plugin: ${C.plugin.name}`,configSchema:Se.configSchema,initialValues:Se.existingConfig,onSave:n,onCancel:r})}if(typeof y==`object`&&y.type===`flagged-detail`){let e=y.plugin;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(z,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(B,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(B,{children:e.text}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(B,{children:[a.pointer,` `]}),(0,Z.jsx)(B,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(y===`confirm-project-uninstall`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,color:`warning`,children:[C.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(B,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ge?(0,Z.jsx)(B,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(V,{children:[(0,Z.jsx)(p,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof y==`object`&&y.type===`confirm-data-cleanup`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` has `,y.size.human,` of persistent data`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(B,{dimColor:!0,children:_e(`${C.plugin.name}@${C.marketplace}`)})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ge?(0,Z.jsx)(B,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(B,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(B,{bold:!0,children:`esc`}),` to cancel`]})})]});if(y===`plugin-details`&&C){let e=ot(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===C.plugin.name||e.source===t||e.source.startsWith(`${C.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(B,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(z,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(B,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(B,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` @ `,C.marketplace]})}),(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(B,{children:C.scope||`user`})]}),C.plugin.manifest.version&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.version})]}),C.plugin.manifest.description&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{children:C.plugin.manifest.description})}),C.plugin.manifest.author&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.author.name})]}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),C.pendingUpdate&&(0,Z.jsx)(B,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:C.plugin,marketplace:C.marketplace}),i,(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:Ne.map((e,t)=>{let n=t===me;return(0,Z.jsxs)(z,{children:[n&&(0,Z.jsxs)(B,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(B,{children:` `}),(0,Z.jsx)(B,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),ge&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{children:`Processing…`})}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(p,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`failed-plugin-details`){let e=y.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:e.name}),(0,Z.jsxs)(B,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(B,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(B,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(z,{marginTop:1,children:[(0,Z.jsxs)(B,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(B,{bold:!0,children:`Remove`})]}),ge&&(0,Z.jsx)(B,{children:`Processing…`}),be&&(0,Z.jsx)(B,{color:`error`,children:be}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[e.scope!==`managed`&&(0,Z.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`mcp-detail`){let e=y.client,n=ve(l,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 y==`object`&&y.type===`mcp-tools`){let e=y.client,t=e.config.scope,n=e.config.type,r;return r=n===`stdio`?{name:e.name,client:e,scope:t,transport:`stdio`,config:e.config}:n===`sse`?{name:e.name,client:e,scope:t,transport:`sse`,isAuthenticated:void 0,config:e.config}:n===`http`?{name:e.name,client:e,scope:t,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:t,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)($t,{server:r,onSelectTool:t=>{x({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>x({type:`mcp-detail`,client:e})})}if(typeof y==`object`&&y.type===`mcp-tool-detail`){let{client:e,tool:t}=y,n=e.config.scope,r=e.config.type,i;return i=r===`stdio`?{name:e.name,client:e,scope:n,transport:`stdio`,config:e.config}:r===`sse`?{name:e.name,client:e,scope:n,transport:`sse`,isAuthenticated:void 0,config:e.config}:r===`http`?{name:e.name,client:e,scope:n,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:n,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Zt,{tool:t,server:i,onBack:()=>x({type:`mcp-tools`,client:e})})}let Pe=fe.getVisibleItems(P);return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(Be,{query:te,isFocused:h,isTerminalFocused:_,width:v-4,cursorOffset:ne})}),P.length===0&&te&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsxs)(B,{dimColor:!0,children:[`No items match "`,te,`"`]})}),fe.scrollPosition.canScrollUp&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Pe.map((e,t)=>{let n=fe.toActualIndex(t)===F&&!h,r=t>0?Pe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(z,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(B,{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)}),fe.scrollPosition.canScrollDown&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(z,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(B,{children:`type to search`}),(0,Z.jsx)(p,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),j.size>0&&(0,Z.jsx)(z,{marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(Le(),1),X=t(Le(),1),w(),We(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),ge(),Ee(),m(),Bt(),Oe(),Et(),M(),nt(),me(),$e(),Ye(),dt(),P(),je(),v(),se(),Se(),Rt(),T(),de(),x(),De(),vt(),st(),et(),_t(),Wn(),fn(),_n(),Kn(),kn(),Z=qe()}));function tr(e){if(!e)return{type:`menu`};let t=e.trim().split(/\s+/);switch(t[0]?.toLowerCase()){case`help`:case`--help`:case`-h`:return{type:`help`};case`install`:case`i`:{let e=t[1];if(!e)return{type:`install`};if(e.includes(`@`)){let[t,n]=e.split(`@`);return{type:`install`,plugin:t,marketplace:n}}return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`file://`)||e.includes(`/`)||e.includes(`\\`)?{type:`install`,marketplace:e}:{type:`install`,plugin:e}}case`manage`:return{type:`manage`};case`uninstall`:return{type:`uninstall`,plugin:t[1]};case`enable`:return{type:`enable`,plugin:t[1]};case`disable`:return{type:`disable`,plugin:t[1]};case`validate`:return{type:`validate`,path:t.slice(1).join(` `).trim()||void 0};case`marketplace`:case`market`:{let e=t[1]?.toLowerCase(),n=t.slice(2).join(` `);switch(e){case`add`:return{type:`marketplace`,action:`add`,target:n};case`remove`:case`rm`:return{type:`marketplace`,action:`remove`,target:n};case`update`:return{type:`marketplace`,action:`update`,target:n};case`list`:return{type:`marketplace`,action:`list`};default:return{type:`marketplace`}}}default:return{type:`menu`}}}var nr=e((()=>{}));function rr({onComplete:e,path:t}){return(0,ir.useEffect)(()=>{async function n(){if(!t){e(`Usage: /plugin validate <path>
2
+
3
+ Validate a plugin or marketplace manifest file or directory.
4
+
5
+ Examples:
6
+ /plugin validate .claude-plugin/plugin.json
7
+ /plugin validate /path/to/plugin-directory
8
+ /plugin validate .
9
+
10
+ When given a directory, automatically validates .claude-plugin/marketplace.json
11
+ or .claude-plugin/plugin.json (prefers marketplace if both exist).
12
+
13
+ Or from the command line:
14
+ claude plugin validate <path>`);return}try{let n=await jt(t),r=``;r+=`Validating ${n.fileType} manifest: ${n.filePath}\n\n`,n.errors.length>0&&(r+=`${a.cross} Found ${n.errors.length} ${H(n.errors.length,`error`)}:\n\n`,n.errors.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
15
+ `),n.warnings.length>0&&(r+=`${a.warning} Found ${n.warnings.length} ${H(n.warnings.length,`warning`)}:\n\n`,n.warnings.forEach(e=>{r+=` ${a.pointer} ${e.path}: ${e.message}\n`}),r+=`
16
+ `),n.success?(n.warnings.length>0?r+=`${a.tick} Validation passed with warnings\n`:r+=`${a.tick} Validation passed\n`,process.exitCode=0):(r+=`${a.cross} Validation failed\n`,process.exitCode=1),e(r)}catch(t){process.exitCode=2,ft(t),e(`${a.cross} Unexpected error during validation: ${Je(t)}`)}}n()},[e,t]),(0,ar.jsx)(z,{flexDirection:`column`,children:(0,ar.jsx)(B,{children:`Running validation...`})})}var ir,ar,or=e((()=>{i(),ir=t(Le(),1),We(),Ye(),dt(),Pt(),_t(),ar=qe()}));function sr({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await te(),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: ${Je(t)}`)}}t()},[e]),(0,$.jsx)(B,{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`}])ct(n)?.extraKnownMarketplaces?.[e]&&t.push({source:n,scope:r});return{editableSources:t,isInPolicy:!!ct(`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=ct(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&&it(n,r)}}function hr({setViewState:e,setActiveTab:t,markPluginsChanged:n}){let r=ce(e=>e.plugins.errors),i=ce(e=>e.plugins.installationStatus),s=o(),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(null),[f,m]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await Ce(await te());m(e)}catch{}})()},[]);let h=i.marketplaces.filter(e=>e.status===`failed`),g=new Set(h.map(e=>e.name)),_=r.filter(dr),v=pr(h,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!g.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),f,_,yt());Fe(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),R({"select:previous":()=>l(e=>Math.max(0,e-1)),"select:next":()=>l(e=>Math.min(v.length-1,e+1)),"select:accept":()=>{let r=v[c];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),ye(),s(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)}}})),d(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await ee(i.name),ye(),m(e=>e.filter(e=>e.name!==i.name)),d(`${a.tick} Removed marketplace "${i.name}"`),n()}catch(e){d(`Failed to remove "${i.name}": ${e instanceof Error?e.message:String(e)}`)}})();break;case`managed-only`:break;case`none`:break}}},{context:`Select`,isActive:v.length>0});let y=Math.min(c,Math.max(0,v.length-1));y!==c&&l(y);let b=v[y]?.action,x=b&&b.kind!==`none`&&b.kind!==`managed-only`;return v.length===0?(0,$.jsxs)(z,{flexDirection:`column`,children:[(0,$.jsx)(z,{marginLeft:1,children:(0,$.jsx)(B,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(z,{marginTop:1,children:(0,$.jsx)(B,{dimColor:!0,italic:!0,children:(0,$.jsx)(p,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(z,{flexDirection:`column`,children:[v.map((e,t)=>{let n=t===y;return(0,$.jsxs)(z,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(B,{children:[(0,$.jsxs)(B,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(B,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(B,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(z,{marginLeft:3,children:(0,$.jsx)(B,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(z,{marginLeft:3,children:(0,$.jsx)(B,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),u&&(0,$.jsx)(z,{marginTop:1,marginLeft:1,children:(0,$.jsx)(B,{color:`claude`,children:u})}),(0,$.jsx)(z,{marginTop:1,children:(0,$.jsx)(B,{dimColor:!0,italic:!0,children:(0,$.jsxs)(V,{children:[(0,$.jsx)(p,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),x&&(0,$.jsx)(p,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(p,{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),[s,c]=(0,Q.useState)(_r(r)),[l,u]=(0,Q.useState)(i.type===`add-marketplace`&&i.initialValue||``),[d,f]=(0,Q.useState)(0),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[ee,_]=(0,Q.useState)(!1),v=o(),y=ce(e=>{let t=e.plugins.errors.length;for(let n of e.plugins.installationStatus.marketplaces)n.status===`failed`&&t++;return t}),b=y>0?`Errors (${y})`:`Errors`,x=Vt(),te=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,S=(0,Q.useCallback)(()=>{v(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[v]),ne=(0,Q.useCallback)(e=>{let t=e;switch(c(t),m(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`&&!h&&e()},[i.type,h,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&s!==`discover`&&c(`discover`)},[i.type,s]),Fe(`confirm:no`,(0,Q.useCallback)(()=>{c(`marketplaces`),a({type:`manage-marketplaces`}),u(``),m(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{h&&e(h)},[h,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(z,{flexDirection:`column`,children:[(0,$.jsx)(B,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(B,{children:` `}),(0,$.jsx)(B,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(B,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(B,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(B,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(B,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(B,{children:` `}),(0,$.jsx)(B,{dimColor:!0,children:`Management:`}),(0,$.jsx)(B,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(B,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(B,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(B,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(B,{children:` `}),(0,$.jsx)(B,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(B,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(B,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(B,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(B,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(B,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(B,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(B,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(B,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(B,{children:` `}),(0,$.jsx)(B,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(B,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(B,{children:` `}),(0,$.jsx)(B,{dimColor:!0,children:`Other:`}),(0,$.jsx)(B,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(B,{children:` /plugin help - Show this help`}),(0,$.jsx)(B,{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:l,setInputValue:u,cursorOffset:d,setCursorOffset:f,error:p,setError:m,result:h,setResult:g,setViewState:a,onAddComplete:S,cliMode:te}):(0,$.jsx)(Ge,{color:`suggestion`,children:(0,$.jsxs)(Ue,{title:`Plugins`,selectedTab:s,onTabChange:ne,color:`suggestion`,disableNavigation:ee,children:[(0,$.jsx)(Ve,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(An,{error:p,setError:m,result:h,setResult:g,setViewState:a,onInstallComplete:S,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Nn,{error:p,setError:m,result:h,setResult:g,setViewState:a,onInstallComplete:S,onSearchModeChange:_,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(Ve,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Qn,{setViewState:a,setResult:g,onManageComplete:S,onSearchModeChange:_,targetPlugin:i.type===`manage-plugins`?i.targetPlugin:void 0,targetMarketplace:i.type===`manage-plugins`?i.targetMarketplace:void 0,action:i.type===`manage-plugins`?i.action:void 0})}),(0,$.jsx)(Ve,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Rn,{setViewState:a,error:p,setError:m,setResult:g,exitState:x,onManageComplete:S,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(Ve,{id:`errors`,title:b,children:(0,$.jsx)(hr,{setViewState:a,setActiveTab:c,markPluginsChanged:S})})]})})}var Q,$,yr,br=e((()=>{i(),Q=t(Le(),1),w(),We(),Ht(),Ee(),M(),Ye(),P(),he(),v(),vt(),st(),sn(),Mn(),Ln(),Vn(),er(),Wn(),nr(),or(),$=qe(),yr=new Set([`git-auth-failed`,`git-timeout`,`network-error`])}));async function xr(e,t,n){return(0,Sr.jsx)(vr,{onComplete:e,args:n})}var Sr;e((()=>{br(),Sr=qe()}))();export{xr as call};