@readmagic/workmate 0.0.11 → 0.0.12

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 (405) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-ag2JTpmU.js → AddWorkspaceDirectory-CtRxzRny.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-_bI4jo_P.js +1 -0
  3. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CSywJdVL.js → AgentsMdExternalIncludesDialog-_yJJ0wqu.js} +1 -1
  4. package/dist/chunks/{App-BuKmqFPm.js → App-DoAZ7CYS.js} +1 -1
  5. package/dist/chunks/{ApproveApiKey-M6U-NafA.js → ApproveApiKey-C8LwmDM2.js} +1 -1
  6. package/dist/chunks/ApproveApiKey-DQP3qmb0.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-CDA2noEk.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-B05t83wa.js → BypassPermissionsModeDialog-COI_V57z.js} +1 -1
  9. package/dist/chunks/ConsoleOAuthFlow-Dn8fO-o_.js +1 -0
  10. package/dist/chunks/{DiffDialog-DUbFrzKu.js → DiffDialog-CRWtQ1R5.js} +3 -3
  11. package/dist/chunks/Doctor-CZ513Df9.js +3 -0
  12. package/dist/chunks/Doctor-CzPvNZzF.js +1 -0
  13. package/dist/chunks/ExitFlow-BFeftDv0.js +2 -0
  14. package/dist/chunks/{Grove-BDoVj02t.js → Grove-DRZrhbF0.js} +1 -1
  15. package/dist/chunks/{HybridTransport-C_U0IJfz.js → HybridTransport-BadJQe6u.js} +2 -2
  16. package/dist/chunks/{InvalidConfigDialog-bih293Xt.js → InvalidConfigDialog-DQaT6aen.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-Br8kQOHz.js → InvalidSettingsDialog-ISzcIGPU.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-BpjC7CEo.js +1 -0
  19. package/dist/chunks/MCPToolListView-Rb1Q--jG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-COa71S9q.js → McpParsingWarnings-xv0RZCSL.js} +1 -1
  21. package/dist/chunks/MessageSelector-BHB55sZb.js +3 -0
  22. package/dist/chunks/Messages-CPX-nIdA.js +11 -0
  23. package/dist/chunks/Onboarding-CymgipoF.js +1 -0
  24. package/dist/chunks/{PromptInputFooterSuggestions-to5eYBvI.js → PromptInputFooterSuggestions-8-awCxOn.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-BP3UgCdi.js +1 -0
  26. package/dist/chunks/QueryEngine-HkswHUNv.js +1 -0
  27. package/dist/chunks/REPL-CZfg65kg.js +133 -0
  28. package/dist/chunks/REPL-eZsYNBfl.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-B4jqKVd3.js +2 -0
  30. package/dist/chunks/ResumeConversation-B03XN_SP.js +1 -0
  31. package/dist/chunks/{SSETransport-DN4tCDEh.js → SSETransport-je346ofV.js} +1 -1
  32. package/dist/chunks/SearchExtraToolsTool-C85Sanww.js +1 -0
  33. package/dist/chunks/Settings-C8GKWod1.js +2 -0
  34. package/dist/chunks/{TeleportProgress-C2LQVLav.js → TeleportProgress-zmdAsogZ.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-BZL8Zblz.js → TeleportRepoMismatchDialog-CG32I4cO.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-wPiIs8xg.js → TeleportResumeWrapper-2Yjr74Lq.js} +1 -1
  37. package/dist/chunks/{ThemePicker-BT_NaRQC.js → ThemePicker-p7_hHk1V.js} +1 -1
  38. package/dist/chunks/TrustDialog-BVcny9vs.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-C-hWdy_8.js → ValidationErrorsList-DSSUWdgd.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-ZQRKlcT4.js → WelcomeV2-BnSYhyfu.js} +1 -1
  41. package/dist/chunks/add-dir-Bd7pilVx.js +1 -0
  42. package/dist/chunks/{agentDisplay-CuSHqgZc.js → agentDisplay-CfMLGPGH.js} +1 -1
  43. package/dist/chunks/{agents-CMC0iQP4.js → agents-BT82hwBN.js} +1 -1
  44. package/dist/chunks/agents-qR6r94-F.js +103 -0
  45. package/dist/chunks/allErrors-CS77lRvU.js +1 -0
  46. package/dist/chunks/api-C4VflFau.js +1 -0
  47. package/dist/chunks/{api-BbJfMXRS.js → api-DAubp5q9.js} +1 -1
  48. package/dist/chunks/auth-CNCehj7y.js +1 -0
  49. package/dist/chunks/auth-DrD9DW6X.js +1 -0
  50. package/dist/chunks/{auth-7mJGtlZp.js → auth-yDsvFcM7.js} +1 -1
  51. package/dist/chunks/{autoMode-CBtY7ACs.js → autoMode-C2lnBot9.js} +5 -5
  52. package/dist/chunks/backgroundHousekeeping-DbpTGbwl.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-SpTxViUq.js +17 -0
  54. package/dist/chunks/{banner-1Wyeyawe.js → banner-BcAM7iSx.js} +1 -1
  55. package/dist/chunks/bg-Ci7pG4eo.js +9 -0
  56. package/dist/chunks/{branch-k3kirqbA.js → branch-DJiMa8td.js} +1 -1
  57. package/dist/chunks/{break-cache-CAoZ9b72.js → break-cache-4rlQORVk.js} +2 -2
  58. package/dist/chunks/{bridgeConfig-UgaUfuP6.js → bridgeConfig-BB6Hgali.js} +1 -1
  59. package/dist/chunks/bridgeConfig-Ccm79Jze.js +1 -0
  60. package/dist/chunks/{bridgeMessaging-Ci5H68MX.js → bridgeMessaging-C9D0Lly2.js} +1 -1
  61. package/dist/chunks/{bridgePointer-BL8-lGvN.js → bridgePointer-DHWK3LEe.js} +1 -1
  62. package/dist/chunks/{bridgeStatusUtil-C36w15ge.js → bridgeStatusUtil-D8UbcVrZ.js} +1 -1
  63. package/dist/chunks/btw-BO2B23f-.js +1 -0
  64. package/dist/chunks/caches-BQmbXerw.js +1 -0
  65. package/dist/chunks/caches-Dtjmjm6G.js +1 -0
  66. package/dist/chunks/{capacityWake-BOySRJUJ.js → capacityWake-ByL6fM6I.js} +1 -1
  67. package/dist/chunks/{ccrClient-Br4LAofR.js → ccrClient-BG9HU_fW.js} +1 -1
  68. package/dist/chunks/{claudeDesktop-Bgds1-YT.js → claudeDesktop-Ct_hyICL.js} +1 -1
  69. package/dist/chunks/{clear-C4Vtnbye.js → clear-B4XN2fib.js} +1 -1
  70. package/dist/chunks/cliLaunch-OPOtzhvA.js +1 -0
  71. package/dist/chunks/client-7lIxWcaM.js +1 -0
  72. package/dist/chunks/client-B-2ccQZk.js +1 -0
  73. package/dist/chunks/{client-B9404qIP.js → client-BMA05FW8.js} +1 -1
  74. package/dist/chunks/commands-D_-v6_A0.js +1 -0
  75. package/dist/chunks/compact-kM0ETtB2.js +2 -0
  76. package/dist/chunks/config-9rLTDOYW.js +3 -0
  77. package/dist/chunks/config-Crf6Mzu3.js +1 -0
  78. package/dist/chunks/{config-kB2eazPX.js → config-DMKtiMzJ.js} +1 -1
  79. package/dist/chunks/{context-BN7DEjoH.js → context-BY5oO5is.js} +1 -1
  80. package/dist/chunks/{context-noninteractive-D91W2B8e.js → context-noninteractive-mAQt1p9l.js} +2 -2
  81. package/dist/chunks/context-noninteractive-tc4KTYfI.js +1 -0
  82. package/dist/chunks/conversation-CFIn-KsW.js +1 -0
  83. package/dist/chunks/conversation-DPI7VKBL.js +1 -0
  84. package/dist/chunks/createSSHSession-DjLSGm-0.js +6 -0
  85. package/dist/chunks/{createSession-DRqkLZWt.js → createSession-CftIZ3aq.js} +1 -1
  86. package/dist/chunks/createSession-CjdLcRec.js +1 -0
  87. package/dist/chunks/crossProjectResume-BJqXBzkf.js +40 -0
  88. package/dist/chunks/{cwd-Cfdf7z7s.js → cwd-Besi3Os3.js} +1 -1
  89. package/dist/chunks/cwd-DpqwaYHw.js +1 -0
  90. package/dist/chunks/datadog-BGati3aQ.js +1 -0
  91. package/dist/chunks/{debug-BecbSVoN.js → debug-Dr1SjdXn.js} +2 -2
  92. package/dist/chunks/{debugUtils-CmJfIUxW.js → debugUtils-cK-iOsEV.js} +1 -1
  93. package/dist/chunks/detached-CqfQYVOi.js +5 -0
  94. package/dist/chunks/detectRepository-BsKZDRoI.js +1 -0
  95. package/dist/chunks/{detectRepository-C15umvKN.js → detectRepository-CMEkS5_2.js} +1 -1
  96. package/dist/chunks/{diff-DeK4bwjw.js → diff-1HsxKGBh.js} +1 -1
  97. package/dist/chunks/{directoryCompletion-BJCu19HJ.js → directoryCompletion-ByBTSuLu.js} +1 -1
  98. package/dist/chunks/doctor-CJfvt9zR.js +1 -0
  99. package/dist/chunks/entry-CrZCZQQC.js +14 -0
  100. package/dist/chunks/{envUtils-BDhHQY0-.js → envUtils-DcaKZlRU.js} +1 -1
  101. package/dist/chunks/{esm-Ka3lhafK.js → esm-BkOWaWVb.js} +1 -1
  102. package/dist/chunks/{execFileNoThrow-DHyW8FMX.js → execFileNoThrow-mXq4K0rl.js} +1 -1
  103. package/dist/chunks/{execSyncWrapper-CDzB0BM1.js → execSyncWrapper-Ne33rRiD.js} +1 -1
  104. package/dist/chunks/exit-B8MA4Ltm.js +1 -0
  105. package/dist/chunks/{extraUsage-BrKbpBK-.js → extraUsage-0pUcYexI.js} +1 -1
  106. package/dist/chunks/extractMemories-DqhN0lba.js +1 -0
  107. package/dist/chunks/fast-DT5WDe3L.js +1 -0
  108. package/dist/chunks/{fast-DWn40OcQ.js → fast-VOu2FUlV.js} +1 -1
  109. package/dist/chunks/{fileSuggestions-C7Pwq2yj.js → fileSuggestions-Be-pyLLq.js} +1 -1
  110. package/dist/chunks/firstPartyEventLogger-B8RVGBQB.js +1 -0
  111. package/dist/chunks/{firstPartyEventLogger-BHjBQH0J.js → firstPartyEventLogger-aFhcruXA.js} +2 -2
  112. package/dist/chunks/{flushGate-DdJjxCes.js → flushGate-BUSrMj_6.js} +1 -1
  113. package/dist/chunks/{gemini-DHv2iVfy.js → gemini-DB4M-MYv.js} +1 -1
  114. package/dist/chunks/{generateSessionName-DhS_6oHd.js → generateSessionName-DhCypqJ_.js} +1 -1
  115. package/dist/chunks/{genericProcessUtils-B2HcDYhg.js → genericProcessUtils-Dc1pfb7J.js} +1 -1
  116. package/dist/chunks/git-Bs1vtuvX.js +1 -0
  117. package/dist/chunks/{git-DBlOv64X.js → git-CoQQ6YEf.js} +1 -1
  118. package/dist/chunks/{githubRepoPathMapping-CK56bUDe.js → githubRepoPathMapping-CmpEaQoo.js} +1 -1
  119. package/dist/chunks/goal-TxXtfkQ6.js +3 -0
  120. package/dist/chunks/{grok-BS57ZhyW.js → grok-D2a_J5wE.js} +1 -1
  121. package/dist/chunks/{grove-_zlQ83yR.js → grove-BnzBbGsX.js} +2 -2
  122. package/dist/chunks/{help-C_2tdXHC.js → help-C5ankDi4.js} +1 -1
  123. package/dist/chunks/{hooks-C7Bn7MBe.js → hooks-BZS105Rd.js} +3 -3
  124. package/dist/chunks/hooks-D-twhU_z.js +1 -0
  125. package/dist/chunks/{initReplBridge-NkZRcM77.js → initReplBridge-DL4klK0C.js} +1 -1
  126. package/dist/chunks/{install-Du-DSVzj.js → install-NZvHd_40.js} +1 -1
  127. package/dist/chunks/{instrumentation-DMs3b82f.js → instrumentation-CjBlVlFq.js} +4 -4
  128. package/dist/chunks/{job-rbX1VZmp.js → job-D502Zf8J.js} +1 -1
  129. package/dist/chunks/{jwtUtils-OzxN2zts.js → jwtUtils-FQWtM6iM.js} +1 -1
  130. package/dist/chunks/keybindings-D9Boc8FD.js +2 -0
  131. package/dist/chunks/{launchLocalMemory-BLRCK1_o.js → launchLocalMemory-DxC3LojF.js} +2 -2
  132. package/dist/chunks/{launchOnboarding-Al_X75Vz.js → launchOnboarding-BLp5k_H4.js} +1 -1
  133. package/dist/chunks/{loadAgentsDir-BL93ulMm.js → loadAgentsDir-BXtV2jiO.js} +597 -604
  134. package/dist/chunks/loadAgentsDir-BjsAQWqt.js +1 -0
  135. package/dist/chunks/{loadPluginHooks-B0au35a4.js → loadPluginHooks-Dt3XQ-3N.js} +1 -1
  136. package/dist/chunks/{localSearch-C5ipegd9.js → localSearch-CeP4ef0a.js} +1 -1
  137. package/dist/chunks/localSearch-Cz8Ot7k2.js +1 -0
  138. package/dist/chunks/{log-Dauqle-Z.js → log-27kCA_9u.js} +1 -1
  139. package/dist/chunks/{logoV2Utils-CkvOihX7.js → logoV2Utils-CEnU8qad.js} +1 -1
  140. package/dist/chunks/{magicDocs-DLav5QK0.js → magicDocs-YtfrqVC6.js} +3 -3
  141. package/dist/chunks/main-CGLCy2pM.js +31 -0
  142. package/dist/chunks/{main-CVNWNAoh.js → main-CkjTzYj1.js} +42 -42
  143. package/dist/chunks/{managedEnv-DJSCuqCb.js → managedEnv-B-BNY0xC.js} +1 -1
  144. package/dist/chunks/managedEnv-K9Si1UuL.js +1 -0
  145. package/dist/chunks/{mappers-DQxMcezy.js → mappers-IuJeXgvr.js} +1 -1
  146. package/dist/chunks/mcp-DMBoeQzm.js +6 -0
  147. package/dist/chunks/mcp-TMOPfLcW.js +1 -0
  148. package/dist/chunks/mcp-x5rgv-uv.js +2 -0
  149. package/dist/chunks/{memoize-FeyE7JEh.js → memoize-Co4vS6UF.js} +1 -1
  150. package/dist/chunks/memory-DDUoR63T.js +1 -0
  151. package/dist/chunks/{mode-Bl2RZC8M.js → mode-GzBwK--u.js} +2 -2
  152. package/dist/chunks/model-BydaMaPr.js +1 -0
  153. package/dist/chunks/model-CDnVaVDR.js +1 -0
  154. package/dist/chunks/model-CIvbC7rW.js +1 -0
  155. package/dist/chunks/{modelOptions-BtEZe5BB.js → modelOptions-ut0xePEe.js} +1 -1
  156. package/dist/chunks/{nativeInstaller-BEwayifa.js → nativeInstaller-fgCMR_c0.js} +1 -1
  157. package/dist/chunks/oauth-D38aRTUb.js +1 -0
  158. package/dist/chunks/oauth-U649LV5H.js +1 -0
  159. package/dist/chunks/{observationStore-BpjlK0pG.js → observationStore-D0rm3GhP.js} +1 -1
  160. package/dist/chunks/omit-D4Udf-p-.js +1 -0
  161. package/dist/chunks/{onChangeAppState-ZdwI7boX.js → onChangeAppState-WbvtqDtk.js} +1 -1
  162. package/dist/chunks/{openai-DWs4D-nQ.js → openai-DaVFXyBB.js} +3 -3
  163. package/dist/chunks/{panel-CoNfXy3K.js → panel-CoF2a-h4.js} +1 -1
  164. package/dist/chunks/parser-B2PlJg4C.js +1 -0
  165. package/dist/chunks/{parser-BH4u7QiV.js → parser-CUUiH40T.js} +1 -1
  166. package/dist/chunks/partition-CzW_31Y1.js +1 -0
  167. package/dist/chunks/permissions-BT3lxYBM.js +3 -0
  168. package/dist/chunks/{pidLock-DgOBc1Xo.js → pidLock-d1VPd6CG.js} +2 -2
  169. package/dist/chunks/{plan-BNYDTnQd.js → plan-M9DG3AqN.js} +1 -1
  170. package/dist/chunks/{platform-B0uTQc9P.js → platform-Dg1c9F_1.js} +1 -1
  171. package/dist/chunks/plugin-BiNHuq3h.js +17 -0
  172. package/dist/chunks/{pluginAutoupdate-BBU9Jn4p.js → pluginAutoupdate-B5lel6s5.js} +1 -1
  173. package/dist/chunks/{pluginBlocklist-DXQlbG0P.js → pluginBlocklist-CNGmIlwU.js} +1 -1
  174. package/dist/chunks/pluginCliCommands-WLOEhb2M.js +1 -0
  175. package/dist/chunks/{pluginFlagging-DcJ_FQuv.js → pluginFlagging-CXSSOj4J.js} +1 -1
  176. package/dist/chunks/pluginOperations-BFbty6WT.js +2 -0
  177. package/dist/chunks/{pluginStartupCheck-CKBFaMFr.js → pluginStartupCheck-BEd0VeQC.js} +1 -1
  178. package/dist/chunks/pluginStartupCheck-Bcdxg484.js +1 -0
  179. package/dist/chunks/{plugins-CBW7kPyp.js → plugins-BMZ3aYKP.js} +4 -4
  180. package/dist/chunks/poorMode-Djw0P9Gu.js +1 -0
  181. package/dist/chunks/{poorMode-B_xEvuEV.js → poorMode-DxgO_bUb.js} +1 -1
  182. package/dist/chunks/print-DmoLcwVq.js +26 -0
  183. package/dist/chunks/processBashCommand-B-VqME9O.js +1 -0
  184. package/dist/chunks/processSlashCommand-D6zEooTy.js +5 -0
  185. package/dist/chunks/{projectContext-CIxul6vA.js → projectContext-BN2ZWzOG.js} +1 -1
  186. package/dist/chunks/{projectContext-RUMJB798.js → projectContext-Bw3o5BrN.js} +1 -1
  187. package/dist/chunks/prompt-C3RRe4kW.js +1 -0
  188. package/dist/chunks/{prompt-Dx7IWhBt.js → prompt-CRc2QEZ5.js} +4 -4
  189. package/dist/chunks/prompt-EtAanewG.js +1 -0
  190. package/dist/chunks/{promptEditor-WCkmpejM.js → promptEditor-Bo1d8ZLq.js} +2 -2
  191. package/dist/chunks/{protocolHandler-BiVWrpHi.js → protocolHandler-B83fCYI4.js} +1 -1
  192. package/dist/chunks/{proxy-CVn7o19p.js → proxy-BEKNaTXI.js} +1 -1
  193. package/dist/chunks/rcDebugLog-DSchf3Hs.js +1 -0
  194. package/dist/chunks/{reconciler-C2Nd_e4n.js → reconciler-BGav_ezX.js} +1 -1
  195. package/dist/chunks/refresh-DumNiLvM.js +1 -0
  196. package/dist/chunks/{registerProtocol-E0Iu5hEx.js → registerProtocol-DduKPsn_.js} +1 -1
  197. package/dist/chunks/{reload-plugins-D-3AUT9g.js → reload-plugins-DNEgQ5vo.js} +1 -1
  198. package/dist/chunks/{remoteBridgeCore-CV6we3ZA.js → remoteBridgeCore-BGOqHADF.js} +1 -1
  199. package/dist/chunks/{remoteManagedSettings-D26Q09-7.js → remoteManagedSettings-26nhzuca.js} +1 -1
  200. package/dist/chunks/{rename-CSavuBIE.js → rename-BPknfVGF.js} +1 -1
  201. package/dist/chunks/{renderOptions-DDLbSMQU.js → renderOptions-45A-EdsK.js} +1 -1
  202. package/dist/chunks/resume-DGz04xDh.js +2 -0
  203. package/dist/chunks/ripgrep-BLQnqPnE.js +1 -0
  204. package/dist/chunks/{ripgrep-C1ydIMzT.js → ripgrep-DQ_ILUJV.js} +1 -1
  205. package/dist/chunks/{runtimeObserver-L7pSIWBT.js → runtimeObserver-BZrF3GnQ.js} +4 -4
  206. package/dist/chunks/{runtimeObserver-OU8KrZQG.js → runtimeObserver-CBV-7-w7.js} +1 -1
  207. package/dist/chunks/sandbox-adapter-DUqeqkQD.js +1 -0
  208. package/dist/chunks/sandbox-toggle-D61gVqcT.js +1 -0
  209. package/dist/chunks/searchExtraTools-CgsV6kb1.js +1 -0
  210. package/dist/chunks/{session-DUYsfPy_.js → session-Dy-_R7KP.js} +2 -2
  211. package/dist/chunks/sessionFileAccessHooks-BJlrZaRD.js +1 -0
  212. package/dist/chunks/sessionObserver-BGYoLRGx.js +1 -0
  213. package/dist/chunks/{sessionObserver-Dv3Ba8eA.js → sessionObserver-CyLpHSkw.js} +2 -2
  214. package/dist/chunks/{sessionState-D-SaBzWD.js → sessionState-DSWN4tMV.js} +1 -1
  215. package/dist/chunks/sessionStorage-zJ1esSCE.js +1 -0
  216. package/dist/chunks/{sessionStoragePortable-JZnGwqUM.js → sessionStoragePortable-BhkGMZWp.js} +1 -1
  217. package/dist/chunks/{sessionTitle-uCuYaNif.js → sessionTitle-L5tyJgdU.js} +2 -2
  218. package/dist/chunks/{sessionTracing-Bqb3vJTt.js → sessionTracing-DpHGGIZm.js} +1 -1
  219. package/dist/chunks/settings-3ionQKNv.js +1 -0
  220. package/dist/chunks/settings-DiBMs2gM.js +20 -0
  221. package/dist/chunks/settingsSync-dBqlrbcU.js +1 -0
  222. package/dist/chunks/setup-zf3v3ICe.js +3 -0
  223. package/dist/chunks/{shadowedRuleDetection-BzAZ57p2.js → shadowedRuleDetection-DZ0AA2Rw.js} +1 -1
  224. package/dist/chunks/{shellQuote-DS6WrivY.js → shellQuote-C_I6DHLV.js} +1 -1
  225. package/dist/chunks/{sideQuestion-CvMBBjI8.js → sideQuestion-BYT8FdPF.js} +1 -1
  226. package/dist/chunks/sinks-DppGvgz1.js +1 -0
  227. package/dist/chunks/{sinks-f7qYjbKJ.js → sinks-mFsijQ_S.js} +2 -2
  228. package/dist/chunks/skillChangeDetector-D-iq09Xs.js +1 -0
  229. package/dist/chunks/{skillGapStore-CqaT8c0C.js → skillGapStore-DQXHqoP7.js} +2 -2
  230. package/dist/chunks/{skillLifecycle-CnR8IqJM.js → skillLifecycle-BG_RnGSh.js} +2 -2
  231. package/dist/chunks/{skillSearchPanel-D9qrOXpI.js → skillSearchPanel-DxYP4Q6R.js} +5 -5
  232. package/dist/chunks/skills-BD-2ofXA.js +1 -0
  233. package/dist/chunks/startupProfiler-CUlV07MD.js +1 -0
  234. package/dist/chunks/{startupProfiler-CmH_aVy2.js → startupProfiler-Dc5r6LgE.js} +2 -2
  235. package/dist/chunks/{state-BemZdQIl.js → state-BPFYBqm1.js} +1 -1
  236. package/dist/chunks/state-CsdHk8n-.js +1 -0
  237. package/dist/chunks/{stats-B8uQ-UDi.js → stats-BkadEKa-.js} +1 -1
  238. package/dist/chunks/{status-D6KlRJmR.js → status-BmHu-c7I.js} +2 -2
  239. package/dist/chunks/{status-BekdWoIj.js → status-CrmnCDIE.js} +1 -1
  240. package/dist/chunks/{statusNoticeHelpers-BMM8_uJ1.js → statusNoticeHelpers-DakAVtQO.js} +1 -1
  241. package/dist/chunks/{stringUtils-C8PaYpQF.js → stringUtils-Df-Lnjxd.js} +1 -1
  242. package/dist/chunks/{subprocessEnv-Ci8VV_bi.js → subprocessEnv-CNBOhlDV.js} +1 -1
  243. package/dist/chunks/subprocessEnv-DtBCqQIo.js +1 -0
  244. package/dist/chunks/switcher-Dm646gO5.js +1 -0
  245. package/dist/chunks/switcher-sYTxnJQA.js +1 -0
  246. package/dist/chunks/{syncCache-ClP9aBqK.js → syncCache-BofuFJEe.js} +1 -1
  247. package/dist/chunks/{tasks-Dmh6qikm.js → tasks-NpI1iEem.js} +1 -1
  248. package/dist/chunks/teleport-Bs3kEipi.js +1 -0
  249. package/dist/chunks/{templateJobs-CxqU-s5i.js → templateJobs-C94jEE6O.js} +2 -2
  250. package/dist/chunks/{terminalSetup-BKGcmlWp.js → terminalSetup-CbXKCpWM.js} +1 -1
  251. package/dist/chunks/{terminalSetup-Cy19F1Js.js → terminalSetup-fwhFTxGi.js} +1 -1
  252. package/dist/chunks/{theme-U7lMFHQ0.js → theme-CEi3b_8f.js} +1 -1
  253. package/dist/chunks/tmux-d3cNCIZA.js +1 -0
  254. package/dist/chunks/{toolEventObserver-D9qjoVl5.js → toolEventObserver-DlL9CHmI.js} +1 -1
  255. package/dist/chunks/toolPool-DIT_uhtD.js +1 -0
  256. package/dist/chunks/trustedDevice-BokywSKL.js +1 -0
  257. package/dist/chunks/{trustedDevice-DL0pWP4_.js → trustedDevice-Bzz03jCy.js} +1 -1
  258. package/dist/chunks/{types-DafcFtmb.js → types-BJ7qTz75.js} +1 -1
  259. package/dist/chunks/{udsClient-CWnfsgFP.js → udsClient-CF8BmZgN.js} +1 -1
  260. package/dist/chunks/{updateCCB-C6XftzIG.js → updateCCB-CzBxsuJe.js} +6 -6
  261. package/dist/chunks/{upstreamproxy-CXmjxHpl.js → upstreamproxy-BuBFDFAD.js} +1 -1
  262. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DEEJhm_W.js → useExitOnCtrlCDWithKeybindings-BHQfwlAl.js} +1 -1
  263. package/dist/chunks/useMainLoopModel-BkyIIW9t.js +1 -0
  264. package/dist/chunks/useManagePlugins-BWROoGDs.js +1 -0
  265. package/dist/chunks/{useMergedTools-DbhqKk1-.js → useMergedTools-CHxnwR7R.js} +1 -1
  266. package/dist/chunks/{useSearchInput-gUDbkLaC.js → useSearchInput-q2CFPU4W.js} +1 -1
  267. package/dist/chunks/useSettingsErrors-CPVQbsqq.js +1 -0
  268. package/dist/chunks/{userAgent-CU7Ndh79.js → userAgent-B7WkjI6I.js} +1 -1
  269. package/dist/chunks/util-BfqXOA-P.js +1 -0
  270. package/dist/chunks/{validatePlugin-y_O_tCEL.js → validatePlugin-jrcrYEIu.js} +1 -1
  271. package/dist/chunks/{vim-w37BfGZ5.js → vim-C4Hs5U2h.js} +1 -1
  272. package/dist/chunks/{which-BRWBO7Gu.js → which-mplwBbc0.js} +1 -1
  273. package/dist/chunks/windowsPaths-B8p9tFRF.js +1 -0
  274. package/dist/chunks/{windowsPaths-DtWHLjmE.js → windowsPaths-C7Mdo9aU.js} +1 -1
  275. package/dist/chunks/{workSecret-BEhXgH2M.js → workSecret-XLodD7tw.js} +1 -1
  276. package/dist/chunks/workerRegistry-Cfo7bKlm.js +6 -0
  277. package/dist/chunks/worktree-D0k_pCEz.js +1 -0
  278. package/dist/cli.js +1 -1
  279. package/package.json +1 -1
  280. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +0 -1
  281. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +0 -2
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +0 -1
  284. package/dist/chunks/Doctor-BcnUfJ4I.js +0 -1
  285. package/dist/chunks/Doctor-Dz4TuYas.js +0 -3
  286. package/dist/chunks/ExitFlow-BwyAtIHx.js +0 -2
  287. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +0 -1
  288. package/dist/chunks/MCPToolListView-DJ06N1DG.js +0 -1
  289. package/dist/chunks/MessageSelector-o4ULADFg.js +0 -3
  290. package/dist/chunks/Messages-qqwHuAW5.js +0 -11
  291. package/dist/chunks/Onboarding-BzuQjney.js +0 -1
  292. package/dist/chunks/PromptInputHelpMenu-CfMFx-TF.js +0 -1
  293. package/dist/chunks/QueryEngine-Dt0BKUeF.js +0 -1
  294. package/dist/chunks/REPL-CUbEDqEl.js +0 -133
  295. package/dist/chunks/REPL-DMaKNhTa.js +0 -1
  296. package/dist/chunks/RemoteSessionManager-Bf44A0Ol.js +0 -2
  297. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +0 -1
  298. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +0 -1
  299. package/dist/chunks/Settings-DfdcmvOV.js +0 -2
  300. package/dist/chunks/TrustDialog-ACaJ_m7A.js +0 -1
  301. package/dist/chunks/add-dir-SAKTkw0S.js +0 -1
  302. package/dist/chunks/agents-ZgRKpjHv.js +0 -103
  303. package/dist/chunks/allErrors-_cOQksHC.js +0 -1
  304. package/dist/chunks/api-DS1MiW01.js +0 -1
  305. package/dist/chunks/auth-DGZzCbU0.js +0 -1
  306. package/dist/chunks/auth-DN1MUpB8.js +0 -1
  307. package/dist/chunks/autonomy-DuQmYhq6.js +0 -15
  308. package/dist/chunks/autonomy-lJV7yWUl.js +0 -1
  309. package/dist/chunks/autonomyPanel-DAQm6lDz.js +0 -1
  310. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +0 -1
  311. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +0 -17
  312. package/dist/chunks/bg-CJ0YWFli.js +0 -9
  313. package/dist/chunks/bg-CeUrRz_7.js +0 -1
  314. package/dist/chunks/bridgeConfig-CzRUPn-D.js +0 -1
  315. package/dist/chunks/btw-nVoVuIae.js +0 -1
  316. package/dist/chunks/caches-B8sM3Zys.js +0 -1
  317. package/dist/chunks/caches-Bp9MZ7IE.js +0 -1
  318. package/dist/chunks/cliLaunch-BTpfAGGI.js +0 -1
  319. package/dist/chunks/client-BCAbKdNz.js +0 -1
  320. package/dist/chunks/client-CJE6gEvU.js +0 -1
  321. package/dist/chunks/commands-DL-BzoMQ.js +0 -1
  322. package/dist/chunks/compact-Cx7BPXLU.js +0 -2
  323. package/dist/chunks/config-S5OW4Xqr.js +0 -1
  324. package/dist/chunks/config-aRiTrtCv.js +0 -3
  325. package/dist/chunks/context-noninteractive-DPacEFJ1.js +0 -1
  326. package/dist/chunks/conversation-D5Nbu9eT.js +0 -1
  327. package/dist/chunks/conversation-hcUx9e-C.js +0 -1
  328. package/dist/chunks/createSSHSession-DecOR6M5.js +0 -6
  329. package/dist/chunks/createSession-D27zvmOs.js +0 -1
  330. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +0 -40
  331. package/dist/chunks/cwd-ClLru_7T.js +0 -1
  332. package/dist/chunks/datadog-bm551AVV.js +0 -1
  333. package/dist/chunks/detached-CIyF0M5O.js +0 -5
  334. package/dist/chunks/detectRepository-DDfLfKcM.js +0 -1
  335. package/dist/chunks/doctor-BJORBomU.js +0 -1
  336. package/dist/chunks/entry-mdegyj8z.js +0 -14
  337. package/dist/chunks/exit-CF3KBl-S.js +0 -1
  338. package/dist/chunks/extractMemories-4lBn134y.js +0 -1
  339. package/dist/chunks/fast-0Vi354KI.js +0 -1
  340. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +0 -1
  341. package/dist/chunks/git-DF4RFFaT.js +0 -1
  342. package/dist/chunks/goal-BZG4gtnb.js +0 -3
  343. package/dist/chunks/hooks-DT80Arzc.js +0 -1
  344. package/dist/chunks/keybindings-CwdC_8S0.js +0 -2
  345. package/dist/chunks/loadAgentsDir-eVKq8efm.js +0 -1
  346. package/dist/chunks/localSearch-CZlFfR_X.js +0 -1
  347. package/dist/chunks/main-LMyE3jXY.js +0 -31
  348. package/dist/chunks/managedEnv-CYepSnm8.js +0 -1
  349. package/dist/chunks/mcp-BAbbEaBA.js +0 -1
  350. package/dist/chunks/mcp-Ct4Sum6A.js +0 -6
  351. package/dist/chunks/mcp-D5HkCqUh.js +0 -2
  352. package/dist/chunks/memory-COa7aUbx.js +0 -1
  353. package/dist/chunks/model-B7rtZ7KV.js +0 -1
  354. package/dist/chunks/model-Bgh_r4lg.js +0 -1
  355. package/dist/chunks/model-DiuEAv6h.js +0 -1
  356. package/dist/chunks/oauth-BN2I0_jl.js +0 -1
  357. package/dist/chunks/oauth-C9VBDB0Y.js +0 -1
  358. package/dist/chunks/omit--yH_T4rf.js +0 -1
  359. package/dist/chunks/parser-BMIaRErw.js +0 -1
  360. package/dist/chunks/partition-DLcW5Oo_.js +0 -1
  361. package/dist/chunks/permissions-CaucYK3s.js +0 -3
  362. package/dist/chunks/plugin-BN-of1_H.js +0 -17
  363. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +0 -1
  364. package/dist/chunks/pluginOperations-DnhzFbYI.js +0 -2
  365. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +0 -1
  366. package/dist/chunks/poorMode-yH1o41cQ.js +0 -1
  367. package/dist/chunks/print-BZOx09SU.js +0 -26
  368. package/dist/chunks/processBashCommand-dcCNCiBp.js +0 -1
  369. package/dist/chunks/processSlashCommand-YDiM63Qr.js +0 -5
  370. package/dist/chunks/prompt-CXGy0llt.js +0 -1
  371. package/dist/chunks/prompt-DovNDmcx.js +0 -1
  372. package/dist/chunks/rcDebugLog-CARUIORE.js +0 -1
  373. package/dist/chunks/refresh-B84H2Ezd.js +0 -1
  374. package/dist/chunks/resume-CROylN3J.js +0 -2
  375. package/dist/chunks/ripgrep-2M1GkXqJ.js +0 -1
  376. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +0 -1
  377. package/dist/chunks/sandbox-toggle-YrQNWGsr.js +0 -1
  378. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +0 -1
  379. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +0 -1
  380. package/dist/chunks/sessionObserver-B0zucj_c.js +0 -1
  381. package/dist/chunks/sessionStorage-BM1x51Z7.js +0 -1
  382. package/dist/chunks/settings-BG15IFYx.js +0 -1
  383. package/dist/chunks/settings-D4CpDv2y.js +0 -20
  384. package/dist/chunks/settingsSync-BSrpnyqo.js +0 -1
  385. package/dist/chunks/setup-C62oq4AZ.js +0 -3
  386. package/dist/chunks/sinks-WJ7nzLQs.js +0 -1
  387. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +0 -1
  388. package/dist/chunks/skills-BgcFh0vy.js +0 -1
  389. package/dist/chunks/startupProfiler-B4HBBbHN.js +0 -1
  390. package/dist/chunks/state-BAGmpVBn.js +0 -1
  391. package/dist/chunks/state-D_lk6z-C.js +0 -1
  392. package/dist/chunks/subprocessEnv-CZkA9Cdp.js +0 -1
  393. package/dist/chunks/switcher-Ck9CrXrr.js +0 -1
  394. package/dist/chunks/switcher-DnAhkyIn.js +0 -1
  395. package/dist/chunks/teleport-DH3IuAUQ.js +0 -1
  396. package/dist/chunks/tmux-D5EvHWi3.js +0 -1
  397. package/dist/chunks/toolPool-69mfSPAs.js +0 -1
  398. package/dist/chunks/trustedDevice-B6AKlsl_.js +0 -1
  399. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +0 -1
  400. package/dist/chunks/useManagePlugins-CjnsO-Of.js +0 -1
  401. package/dist/chunks/useSettingsErrors-CgPad-H0.js +0 -1
  402. package/dist/chunks/util-B4oMhJKh.js +0 -1
  403. package/dist/chunks/windowsPaths-BY-IVNwQ.js +0 -1
  404. package/dist/chunks/workerRegistry-Bq9bS5pw.js +0 -6
  405. package/dist/chunks/worktree-4SUJ4dtz.js +0 -1
@@ -1,2 +0,0 @@
1
- import{$S as e,Ba as t,Bl as n,CC as r,EC as i,GS as a,JS as o,KS as s,Ob as c,QS as l,SC as u,TC as d,U as f,US as p,Vl as m,W as h,WS as g,XS as _,YS as v,ZS as y,_a as ee,bC as te,cC as b,dC as x,dv as S,dw as C,eC as w,ec as T,el as E,fC as D,gC as O,gx as k,hC as A,hx as j,iC as M,kb as N,lC as P,mC as F,nC as I,oC as L,pC as R,qS as ne,rC as z,tC as B,tc as V,tl as H,uC as U,uv as W,uw as G,wC as K,yC as q}from"./loadAgentsDir-BL93ulMm.js";import{C as J,x as Y}from"./debug-BecbSVoN.js";import{o as X,s as Z}from"./log-Dauqle-Z.js";import{_ as re,u as ie}from"./model-Bgh_r4lg.js";import{bn as ae,vn as oe,yn as Q}from"./prompt-Dx7IWhBt.js";import $ from"node:process";K(),l(),_(),u();var se=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}createMessageStream(e,t){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return this.requestStream({method:`sampling/createMessage`,params:e},I,t)}elicitInputStream(e,t){let n=this._server.getClientCapabilities(),r=e.mode??`form`;switch(r){case`url`:if(!n?.elicitation?.url)throw Error(`Client does not support url elicitation.`);break;case`form`:if(!n?.elicitation?.form)throw Error(`Client does not support form elicitation.`);break}let i=r===`form`&&e.mode===void 0?{...e,mode:`form`}:e;return this.requestStream({method:`elicitation/create`,params:i},L,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};u(),o();var ce=class extends y{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(A.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new v,this.setRequestHandler(U,e=>this._oninitialize(e)),this.setNotificationHandler(x,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(te,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=A.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new se(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=e(this._capabilities,t)}setRequestHandler(e,t){let n=r(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let a;if(d(n)){let e=n;a=e._zod?.def?.value??e.value}else{let e=n;a=e._def?.value??e.value}if(typeof a!=`string`)throw Error(`Schema method literal must be a string`);return a===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=i(w,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new O(P.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:a}=r.data,o=await Promise.resolve(t(e,n));if(a.task){let e=i(M,o);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new O(P.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let s=i(B,o);if(!s.success){let e=s.error instanceof Error?s.error.message:String(s.error);throw new O(P.InvalidParams,`Invalid tools/call result: ${e}`)}return s.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){s(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&ne(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:q.includes(t)?t:D,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},b)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},z,t):this.request({method:`sampling/createMessage`,params:e},I,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},L,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},L,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new O(P.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof O?e:new O(P.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},R,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};g();var le=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new p,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=a(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};u(),V(),ae(),H(),k(),N(),X(),t(),re(),h(),G(),Y(),m(),W();var ue=[];async function de(e,t,r){let i=c(100);C(e);let a=new ce({name:`claude/tengu`,version:`0.0.11`},{capabilities:{tools:{}}});a.setRequestHandler(F,async()=>{let e=Q(),t=E(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=S(n.outputSchema);typeof e==`object`&&e&&`type`in e&&e.type===`object`&&(r=e)}return{...n,description:await n.prompt({getToolPermissionContext:async()=>e,tools:t,agents:[]}),inputSchema:S(n.inputSchema),outputSchema:r}}))}}),a.setRequestHandler(w,async({params:{name:e,arguments:a}})=>{let o=E(Q()),s=oe(o,e);if(!s)throw Error(`Tool ${e} not found`);let c={abortController:j(),options:{commands:ue,tools:o,mainLoopModel:ie(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:r,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>T(),setAppState:()=>{},messages:[],readFileState:i,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!s.isEnabled())throw Error(`Tool ${e} is not enabled`);let t=await s.validateInput?.(a??{},c);if(t&&!t.result)throw Error(`Tool ${e} input is invalid: ${`message`in t?t.message:String(t)}`);let n=await s.call(a??{},c,f,ee({content:[]}));return{content:[{type:`text`,text:typeof n==`string`?n:J(n.data)}]}}catch(e){return Z(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?n(e):[String(e)]).filter(Boolean).join(`
2
- `).trim()||`Error`}]}}});async function o(){let e=new le;await a.connect(e)}return await o()}export{de as startMCPServer};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-BDhHQY0-.js";import{$u as i,Bc as a,FS as o,GC as s,LE as c,LS as l,Sb as u,Sg as d,Vc as ee,_b as f,bb as p,bf as te,ed as ne,xg as m,yf as h,zE as g}from"./loadAgentsDir-BL93ulMm.js";import{I as _,Lt as v,P as y,Wt as b,_ as x,di as S,fi as C,t as w,ui as re,y as T}from"./src-P_wYS_NJ2.js";import{t as E}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as D,et as O}from"./state-BemZdQIl.js";import{n as k,t as A}from"./cwd-Cfdf7z7s.js";import{F as j,R as M}from"./debug-BecbSVoN.js";import{g as N,wn as P,x as F,xn as ie}from"./settings-D4CpDv2y.js";import{M as I,P as L,k as ae}from"./config-aRiTrtCv.js";import{m as R,r as z}from"./git-DBlOv64X.js";import{o as oe,s as se}from"./log-Dauqle-Z.js";import{n as ce,r as B}from"./analytics-DJobLaWP.js";import{m as le,v as V}from"./startupProfiler-CmH_aVy2.js";import{n as H,t as U}from"./useExitOnCtrlCDWithKeybindings-DEEJhm_W.js";import{r as ue,t as de}from"./promptEditor-WCkmpejM.js";import{homedir as fe}from"os";import{join as W,relative as pe}from"path";import{mkdir as G,writeFile as me}from"fs/promises";function he(e){return z(e)!==null}var ge=e((()=>{R()}));function _e({onSelect:e,onCancel:t}){let r=(0,K.use)(p()),i=W(n(),`CLAUDE.md`),a=W(O(),`CLAUDE.md`),o=r.some(e=>e.path===i),s=r.some(e=>e.path===a),u=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...o?[]:[{path:i,type:`User`,content:``,exists:!1}],...s?[]:[{path:a,type:`Project`,content:``,exists:!1}]],f=new Map,m=u.map(e=>{let t=ie(e.path),n=e.exists?``:` (new)`,r=e.parent?(f.get(e.parent)??0)+1:0;f.set(e.path,r);let o=r>0?` `.repeat(r-1):``,s;s=e.type===`User`&&!e.isNested&&e.path===i?`User memory`:e.type===`Project`&&!e.isNested&&e.path===a?`Project memory`:r>0?`${o}L ${t}${n}`:`${t}`;let c,l=he(O());return c=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===a?`${l?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:s,value:e.path,description:c}}),h=[],g=d(e=>e.agentDefinitions);if(L()){h.push({label:`Open auto-memory folder`,value:`${Y}${ae()}`,description:``});for(let e of g.activeAgents)if(e.memory){let t=c(e.agentType,e.memory);h.push({label:`Open ${re.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}m.push(...h);let v=J&&m.some(e=>e.value===J)?J:m[0]?.value||``,[S,C]=(0,K.useState)(L),[w,T]=(0,K.useState)(ee),[E]=(0,K.useState)(L),D=d(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,K.useState)(null);(0,K.useEffect)(()=>{E&&te().then(A)},[E,D]);let j=D?`running`:k===null?``:k===0?`never`:`last ran ${le(new Date(k))}`,[M,N]=(0,K.useState)(null),P=M!==null,I=+!!E;function R(){let e=!S;F(`userSettings`,{autoMemoryEnabled:e}),C(e),B(`tengu_auto_memory_toggled`,{enabled:e})}function z(){let e=!w;F(`userSettings`,{autoDreamEnabled:e}),T(e),B(`tengu_auto_dream_toggled`,{enabled:e})}return H(),b(`confirm:no`,t,{context:`Confirmation`}),b(`confirm:yes`,()=>{M===0?R():M===1&&z()},{context:`Confirmation`,isActive:P}),b(`select:next`,()=>{N(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:P}),b(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:P}),(0,q.jsxs)(_,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(_,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(x,{isFocused:M===0,children:(0,q.jsxs)(y,{children:[`Auto-memory: `,S?`on`:`off`]})}),E&&(0,q.jsx)(x,{isFocused:M===1,styled:!1,children:(0,q.jsxs)(y,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,q.jsxs)(y,{dimColor:!0,children:[` · `,j]}),!D&&w&&(0,q.jsx)(y,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(ne,{defaultFocusValue:v,options:m,isDisabled:P,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>l(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(I)})]})}var K,q,J,Y,ve=e((()=>{S(),C(),K=t(C(),1),D(),U(),w(),s(),I(),ce(),a(),h(),m(),g(),o(),u(),r(),P(),V(),ge(),N(),i(),q=E(),Y=`__open_folder__`}));function ye(e){let t=fe(),n=A(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+pe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var X=e((()=>{C(),w(),k(),E()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await G(n(),{recursive:!0});try{await me(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(j(e)!==`EEXIST`)throw e}await de(t);let r=`default`,i=``;process.env.VISUAL?(r=`$VISUAL`,i=process.env.VISUAL):process.env.EDITOR&&(r=`$EDITOR`,i=process.env.EDITOR);let a=r==="default"?``:`Using ${r}="${i}".`,o=a?`> ${a} To change editor, set $EDITOR or $VISUAL environment variable.`:`> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;e(`Opened memory file at ${ye(t)}\n\n${o}`,{display:`system`})}catch(t){se(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(T,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(_,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_e,{onSelect:t,onCancel:r})}),(0,Q.jsx)(_,{marginTop:1,children:(0,Q.jsxs)(y,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(v,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(C(),1),w(),ve(),X(),u(),r(),M(),oe(),ue(),Q=E(),$=async e=>(f(),await p(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -1 +0,0 @@
1
- import{_ as e,u as t}from"./model-Bgh_r4lg.js";e();export{t as getMainLoopModel};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{d as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./envUtils-BDhHQY0-.js";import{n as ee,t as te}from"./defineProperty-C-QyHrDq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{di as ne,ui as re}from"./src-P_wYS_NJ2.js";import{A as ie,C as ae,p as oe,w as se}from"./external-CEp-aPkt.js";import{n as ce,r as le,t as ue}from"./lazySchema-B4D4qJVE.js";import{$ as de,In as fe,Ir as pe,J as me,Lr as he,Wt as m,Z as ge,Zt as _e,dt as ve,lr as ye,pt as be,sn as xe,ur as Se,vn as Ce,y as we,z as h,zn as Te}from"./state-BemZdQIl.js";import{B as Ee,C as De,F as Oe,G as ke,P as g,R as Ae,S as je,T as Me,W as Ne,c as _,f as Pe,i as v,o as Fe,s as Ie,u as Le,x as Re}from"./debug-BecbSVoN.js";import{Wt as ze,c as y,f as b,g as x,n as Be,x as Ve}from"./settings-D4CpDv2y.js";import{C as He,S as Ue,c as S,h as We,n as C,y as w}from"./config-aRiTrtCv.js";import{a as Ge,c as Ke,i as qe,o as Je,r as Ye,s as Xe,t as Ze}from"./execFileNoThrow-DHyW8FMX.js";import{d as Qe,f as $e,o as et,s as T}from"./log-Dauqle-Z.js";import{r as tt,t as nt}from"./memoize-FeyE7JEh.js";import{s as rt,u as it}from"./types-DafcFtmb.js";import{n as at,r as E}from"./analytics-DJobLaWP.js";import{l as D,n as ot,r as st,s as ct,t as lt,u as O}from"./oauth-C9VBDB0Y.js";import{n as ut,t as dt}from"./bundledMode--fG1S62b.js";import{n as ft,o as pt}from"./stringUtils-C8PaYpQF.js";import{a as mt,i as ht,l as gt}from"./proxy-CVn7o19p.js";import{userInfo as _t}from"os";import{join as vt}from"path";import{chmodSync as yt,mkdirSync as bt,readFileSync as xt,writeFileSync as St}from"fs";import{createHash as Ct,randomUUID as wt}from"crypto";import{mkdir as Tt,stat as Et,writeFile as Dt}from"fs/promises";import{exec as Ot,execFile as kt}from"child_process";import{AsyncLocalStorage as At}from"async_hooks";function k(e=Be()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:s(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:s(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:s(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:s(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:s(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:s(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function jt(){return k()}function Mt(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{return new URL(e).host===`api.anthropic.com`}catch{return!1}}var A=e((()=>{x(),l()}));function Nt(){return Ft.getStore()?.workload}function Pt(e,t){return Ft.run({workload:e},t)}var Ft,It=e((()=>{Ft=new At}));function Lt(e){let t=[],n=!1;async function r(){if(!n&&t.length!==0){for(n=!0;t.length>0;){let{args:n,resolve:r,reject:i,context:a}=t.shift();try{r(await e.apply(a,n))}catch(e){i(e)}}n=!1,t.length>0&&r()}}return function(...e){return new Promise((n,i)=>{t.push({args:e,resolve:n,reject:i,context:this}),r()})}}var Rt=e((()=>{}));function zt(e,t){return e.find(e=>e.includes(t))??null}async function Bt(){let{BedrockClient:e}=await import(`./dist-es-yHGBqhBe.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await ht(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Vt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-Gt_DpXlP.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await ht(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function Ht(e){return e.startsWith(`anthropic.`)}function Ut(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Wt(e){let t=Ut(e);for(let e of Jt)if(t.startsWith(`${e}.anthropic.`))return e}function Gt(e,t){let n=Wt(e);return n?e.replace(`${n}.`,`${t}.`):Ht(e)?`${t}.${e}`:e}var Kt,qt,Jt,Yt=e((()=>{i(),G(),l(),et(),gt(),Kt=r(async function(){let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([Bt(),import(`./dist-es-yHGBqhBe.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw T(e),e}}),qt=r(async function(e){try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([Bt(),import(`./dist-es-yHGBqhBe.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return T(e),null}}),Jt=[`us`,`eu`,`apac`,`global`]})),Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn=e((()=>{Xt={firstParty:`claude-3-7-sonnet-20250219`,bedrock:`us.anthropic.claude-3-7-sonnet-20250219-v1:0`,vertex:`claude-3-7-sonnet@20250219`,foundry:`claude-3-7-sonnet`,openai:`claude-3-7-sonnet-20250219`,gemini:`claude-3-7-sonnet-20250219`,grok:`claude-3-7-sonnet-20250219`},Zt={firstParty:`claude-3-5-sonnet-20241022`,bedrock:`anthropic.claude-3-5-sonnet-20241022-v2:0`,vertex:`claude-3-5-sonnet-v2@20241022`,foundry:`claude-3-5-sonnet`,openai:`claude-3-5-sonnet-20241022`,gemini:`claude-3-5-sonnet-20241022`,grok:`claude-3-5-sonnet-20241022`},Qt={firstParty:`claude-3-5-haiku-20241022`,bedrock:`us.anthropic.claude-3-5-haiku-20241022-v1:0`,vertex:`claude-3-5-haiku@20241022`,foundry:`claude-3-5-haiku`,openai:`claude-3-5-haiku-20241022`,gemini:`claude-3-5-haiku-20241022`,grok:`claude-3-5-haiku-20241022`},$t={firstParty:`claude-haiku-4-5-20251001`,bedrock:`us.anthropic.claude-haiku-4-5-20251001-v1:0`,vertex:`claude-haiku-4-5@20251001`,foundry:`claude-haiku-4-5`,openai:`claude-haiku-4-5-20251001`,gemini:`claude-haiku-4-5-20251001`,grok:`claude-haiku-4-5-20251001`},en={firstParty:`claude-sonnet-4-20250514`,bedrock:`us.anthropic.claude-sonnet-4-20250514-v1:0`,vertex:`claude-sonnet-4@20250514`,foundry:`claude-sonnet-4`,openai:`claude-sonnet-4-20250514`,gemini:`claude-sonnet-4-20250514`,grok:`claude-sonnet-4-20250514`},tn={firstParty:`claude-sonnet-4-5-20250929`,bedrock:`us.anthropic.claude-sonnet-4-5-20250929-v1:0`,vertex:`claude-sonnet-4-5@20250929`,foundry:`claude-sonnet-4-5`,openai:`claude-sonnet-4-5-20250929`,gemini:`claude-sonnet-4-5-20250929`,grok:`claude-sonnet-4-5-20250929`},nn={firstParty:`claude-opus-4-20250514`,bedrock:`us.anthropic.claude-opus-4-20250514-v1:0`,vertex:`claude-opus-4@20250514`,foundry:`claude-opus-4`,openai:`claude-opus-4-20250514`,gemini:`claude-opus-4-20250514`,grok:`claude-opus-4-20250514`},rn={firstParty:`claude-opus-4-1-20250805`,bedrock:`us.anthropic.claude-opus-4-1-20250805-v1:0`,vertex:`claude-opus-4-1@20250805`,foundry:`claude-opus-4-1`,openai:`claude-opus-4-1-20250805`,gemini:`claude-opus-4-1-20250805`,grok:`claude-opus-4-1-20250805`},an={firstParty:`claude-opus-4-5-20251101`,bedrock:`us.anthropic.claude-opus-4-5-20251101-v1:0`,vertex:`claude-opus-4-5@20251101`,foundry:`claude-opus-4-5`,openai:`claude-opus-4-5-20251101`,gemini:`claude-opus-4-5-20251101`,grok:`claude-opus-4-5-20251101`},on={firstParty:`claude-opus-4-6`,bedrock:`us.anthropic.claude-opus-4-6-v1`,vertex:`claude-opus-4-6`,foundry:`claude-opus-4-6`,openai:`claude-opus-4-6`,gemini:`claude-opus-4-6`,grok:`claude-opus-4-6`},sn={firstParty:`claude-opus-4-7`,bedrock:`us.anthropic.claude-opus-4-7-v1`,vertex:`claude-opus-4-7`,foundry:`claude-opus-4-7`,openai:`claude-opus-4-7`,gemini:`claude-opus-4-7`,grok:`claude-opus-4-7`},cn={firstParty:`claude-sonnet-4-6`,bedrock:`us.anthropic.claude-sonnet-4-6`,vertex:`claude-sonnet-4-6`,foundry:`claude-sonnet-4-6`,openai:`claude-sonnet-4-6`,gemini:`claude-sonnet-4-6`,grok:`claude-sonnet-4-6`},ln={haiku35:Qt,haiku45:$t,sonnet35:Zt,sonnet37:Xt,sonnet40:en,sonnet45:tn,sonnet46:cn,opus40:nn,opus41:rn,opus45:an,opus46:on,opus47:sn},Object.values(ln).map(e=>e.firstParty),un=Object.fromEntries(Object.entries(ln).map(([e,t])=>[t.firstParty,e]))}));function fn(e){let t={};for(let n of vn)t[n]=ln[n][e];return t}async function pn(){let e=fn(`bedrock`),t;try{t=await Kt()}catch(t){return T(t),e}if(!t?.length)return e;let n={};for(let r of vn){let i=ln[r].firstParty;n[r]=zt(t,i)||e[r]}return n}function mn(e){let t=Be().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=un[e];t&&r&&(n[t]=r)}return n}function hn(e){let t;try{t=Be().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function gn(){if(ge()===null){if(k()!==`bedrock`){fe(fn(k()));return}yn()}}function j(){let e=ge();return e===null?(gn(),mn(fn(k()))):mn(e)}async function _n(){if(ge()===null){if(k()!==`bedrock`){fe(fn(k()));return}await yn()}}var vn,yn,bn=e((()=>{m(),et(),Rt(),x(),Yt(),dn(),A(),vn=Object.keys(ln),yn=Lt(async()=>{if(ge()===null)try{fe(await pn())}catch(e){T(e)}})}));async function xn(){let e=S().oauthAccount?.accountUuid,t=ta();if(!e||!t)return;let n=`${D().BASE_API_URL}/api/claude_cli_profile`;try{return(await f.get(n,{headers:{"x-api-key":t,"anthropic-beta":ct},params:{account_uuid:e},timeout:1e4})).data}catch(e){T(e)}}async function Sn(e){let t=`${D().BASE_API_URL}/api/oauth/profile`;try{return(await f.get(t,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`},timeout:1e4})).data}catch(e){T(e)}}var Cn=e((()=>{p(),O(),G(),We(),et()}));function wn(e){return!!e?.includes(ot)}function Tn(e){return e?.split(` `).filter(Boolean)??[]}function En({codeChallenge:e,state:t,port:n,isManual:r,loginWithClaudeAi:i,inferenceOnly:a,orgUUID:o,loginHint:s,loginMethod:c}){let l=i?D().CLAUDE_AI_AUTHORIZE_URL:D().CONSOLE_AUTHORIZE_URL,u=new URL(l);u.searchParams.append(`code`,`true`),u.searchParams.append(`client_id`,D().CLIENT_ID),u.searchParams.append(`response_type`,`code`),u.searchParams.append(`redirect_uri`,r?D().MANUAL_REDIRECT_URL:`http://localhost:${n}/callback`);let d=a?[ot]:lt;return u.searchParams.append(`scope`,d.join(` `)),u.searchParams.append(`code_challenge`,e),u.searchParams.append(`code_challenge_method`,`S256`),u.searchParams.append(`state`,t),o&&u.searchParams.append(`orgUUID`,o),s&&u.searchParams.append(`login_hint`,s),c&&u.searchParams.append(`login_method`,c),u.toString()}async function Dn(e,t,n,r,i=!1,a){let o={grant_type:`authorization_code`,code:e,redirect_uri:i?D().MANUAL_REDIRECT_URL:`http://localhost:${r}/callback`,client_id:D().CLIENT_ID,code_verifier:n,state:t};a!==void 0&&(o.expires_in=a);let s=await f.post(D().TOKEN_URL,o,{headers:{"Content-Type":`application/json`},timeout:15e3});if(s.status!==200)throw Error(s.status===401?`Authentication failed: Invalid authorization code`:`Token exchange failed (${s.status}): ${s.statusText}`);return E(`tengu_oauth_token_exchange_success`,{}),s.data}async function On(e,{scopes:t}={}){let n={grant_type:`refresh_token`,refresh_token:e,client_id:D().CLIENT_ID,scope:(t?.length?t:st).join(` `)};try{let t=await f.post(D().TOKEN_URL,n,{headers:{"Content-Type":`application/json`},timeout:15e3});if(t.status!==200)throw Error(`Token refresh failed: ${t.statusText}`);let r=t.data,{access_token:i,refresh_token:a=e,expires_in:o}=r,s=Date.now()+o*1e3,c=Tn(r.scope);E(`tengu_oauth_token_refresh_success`,{});let l=S(),u=W(),d=l.oauthAccount?.billingType!==void 0&&l.oauthAccount?.accountCreatedAt!==void 0&&l.oauthAccount?.subscriptionCreatedAt!==void 0&&u?.subscriptionType!=null&&u?.rateLimitTier!=null?null:await Mn(i);if(d&&l.oauthAccount){let e={};d.displayName!==void 0&&(e.displayName=d.displayName),typeof d.hasExtraUsageEnabled==`boolean`&&(e.hasExtraUsageEnabled=d.hasExtraUsageEnabled),d.billingType!==null&&(e.billingType=d.billingType),d.accountCreatedAt!==void 0&&(e.accountCreatedAt=d.accountCreatedAt),d.subscriptionCreatedAt!==void 0&&(e.subscriptionCreatedAt=d.subscriptionCreatedAt),Object.keys(e).length>0&&w(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:i,refreshToken:a,expiresAt:s,scopes:c,subscriptionType:d?.subscriptionType??u?.subscriptionType??null,rateLimitTier:d?.rateLimitTier??u?.rateLimitTier??null,profile:d?.rawProfile,tokenAccount:r.account?{uuid:r.account.uuid,emailAddress:r.account.email_address,organizationUuid:r.organization?.uuid}:void 0}}catch(e){let t=f.isAxiosError(e)&&e.response?.data?JSON.stringify(e.response.data):void 0;throw E(`tengu_oauth_token_refresh_failure`,{error:e.message,...t&&{responseBody:t}}),e}}async function kn(e){let t=await f.get(D().ROLES_URL,{headers:{Authorization:`Bearer ${e}`}});if(t.status!==200)throw Error(`Failed to fetch user roles: ${t.statusText}`);let n=t.data;if(!S().oauthAccount)throw Error(`OAuth account information not found in config`);w(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),E(`tengu_oauth_roles_stored`,{org_role:n.organization_role})}async function An(e){try{let t=await f.post(D().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await Aa(n),E(`tengu_oauth_api_key`,{status:`success`,statusCode:t.status}),n):null}catch(e){throw E(`tengu_oauth_api_key`,{status:`failure`,error:e instanceof Error?e.message:String(e)}),e}}function jn(e){return e!==null&&Date.now()+300*1e3>=e}async function Mn(e){let t=await Sn(e),n=t?.organization?.organization_type,r=null;switch(n){case`claude_max`:r=`max`;break;case`claude_pro`:r=`pro`;break;case`claude_enterprise`:r=`enterprise`;break;case`claude_team`:r=`team`;break;default:r=null;break}let i={subscriptionType:r,rateLimitTier:t?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:t?.organization?.has_extra_usage_enabled??null,billingType:t?.organization?.billing_type??null};return t?.account?.display_name&&(i.displayName=t.account.display_name),t?.account?.created_at&&(i.accountCreatedAt=t.account.created_at),t?.organization?.subscription_created_at&&(i.subscriptionCreatedAt=t.organization.subscription_created_at),E(`tengu_oauth_profile_fetch_success`,{}),{...i,rawProfile:t}}async function Nn(){let e=S().oauthAccount?.organizationUuid;if(e)return e;let t=W()?.accessToken;return t===void 0||!Ha()?null:(await Sn(t))?.organization?.uuid||null}async function Pn(){let e=process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CLAUDE_CODE_USER_EMAIL,n=process.env.CLAUDE_CODE_ORGANIZATION_UUID,r=!!(e&&t&&n);e&&t&&n&&(S().oauthAccount||Fn({accountUuid:e,emailAddress:t,organizationUuid:n})),await Ba();let i=S();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!R()||!Ha())return!1;let a=W();if(a?.accessToken){let e=await Sn(a.accessToken);if(e)return r&&_(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),Fn({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}function Fn({accountUuid:e,emailAddress:t,organizationUuid:n,displayName:r,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s}){let c={accountUuid:e,emailAddress:t,organizationUuid:n,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s};r&&(c.displayName=r),w(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}var In=e((()=>{p(),at(),O(),G(),We(),v(),Cn()}));function Ln(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{bt(Hn,{recursive:!0,mode:448}),St(e,t,{encoding:`utf8`,mode:384}),_(`Persisted ${n} to ${e} for subprocess access`)}catch(e){_(`Failed to persist ${n} to disk (non-fatal): ${g(e)}`,{level:`error`})}}function Rn(e,t){try{let n=Le().readFileSync(e,{encoding:`utf8`}).trim();return n?(_(`Read ${t} from well-known file ${e}`),n):null}catch(n){return Ee(n)||_(`Failed to read ${t} from ${e}: ${g(n)}`,{level:`debug`}),null}}function zn({envVar:e,wellKnownPath:t,label:n,getCached:r,setCached:i}){let a=r();if(a!==void 0)return a;let o=process.env[e];if(!o){let e=Rn(t,n);return i(e),e}let s=parseInt(o,10);if(Number.isNaN(s))return _(`${e} must be a valid file descriptor number, got: ${o}`,{level:`error`}),i(null),null;try{let e=Le(),r=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${s}`:`/proc/self/fd/${s}`,a=e.readFileSync(r,{encoding:`utf8`}).trim();return a?(_(`Successfully read ${n} from file descriptor ${s}`),i(a),Ln(t,a,n),a):(_(`File descriptor contained empty ${n}`,{level:`error`}),i(null),null)}catch(e){_(`Failed to read ${n} from file descriptor ${s}: ${g(e)}`,{level:`error`});let r=Rn(t,n);return i(r),r}}function Bn(){return zn({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:Un,label:`OAuth token`,getCached:de,setCached:Te})}function Vn(){return zn({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:Wn,label:`API key`,getCached:we,setCached:xe})}var Hn,Un,Wn,Gn,Kn=e((()=>{m(),v(),l(),Ae(),Pe(),Hn=`/home/claude/.claude/remote`,Un=`${Hn}/.oauth_token`,Wn=`${Hn}/.api_key`,Gn=`${Hn}/.session_ingress_token`}));function M(e=``){let t=c(),n=process.env.CLAUDE_CONFIG_DIR?`-${Ct(`sha256`).update(t).digest(`hex`).substring(0,8)}`:``;return`Claude Code${D().OAUTH_FILE_SUFFIX}${e}${n}`}function qn(){try{return process.env.USER||_t().username}catch{return`claude-code-user`}}function N(){P.cache={data:null,cachedAt:0},P.generation++,P.readInFlight=null}function Jn(e){if(P.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}P.cache={data:t,cachedAt:Date.now()}}var Yn,P,Xn=e((()=>{O(),l(),Yn=`-credentials`,P={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function Zn(){if(process.platform===`darwin`&&(await Je(`security delete-generic-password -a $USER -s "${M()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function Qn(e){return e.slice(-20)}var $n=e((()=>{Ke(),Xn()}));function er(e){return e?.name===`CredentialsProviderError`}function tr(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.Credentials||typeof t.Credentials!=`object`)return!1;let n=t.Credentials;return typeof n.AccessKeyId==`string`&&typeof n.SecretAccessKey==`string`&&typeof n.SessionToken==`string`&&n.AccessKeyId.length>0&&n.SecretAccessKey.length>0&&n.SessionToken.length>0}async function nr(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function rr(){try{_(`Clearing AWS credential provider cache`);let{fromIni:e}=await import(`./dist-es-CIULjvtA2.js`);await e({ignoreCache:!0})(),_(`AWS credential provider cache refreshed`)}catch{_(`Failed to clear AWS credential cache (this is expected if no credentials are configured)`)}}var ir=e((()=>{v()})),ar,or=e((()=>{Se(),ee(),ar=class e{constructor(){te(this,`status`,{isAuthenticating:!1,output:[]}),te(this,`changed`,ye()),te(this,`subscribe`,this.changed.subscribe)}static getInstance(){return e.instance||(e.instance=new e),e.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput(e){this.status.output.push(e),this.changed.emit(this.getStatus())}setError(e){this.status.error=e,this.changed.emit(this.getStatus())}endAuthentication(e){e?this.status={isAuthenticating:!1,output:[]}:this.status.isAuthenticating=!1,this.changed.emit(this.getStatus())}static reset(){e.instance&&(e.instance.changed.clear(),e.instance=null)}},te(ar,`instance`,null)})),sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr=e((()=>{sr=`claude-code-20250219`,cr=`interleaved-thinking-2025-05-14`,lr=`context-1m-2025-08-07`,ur=`context-management-2025-06-27`,dr=`structured-outputs-2025-12-15`,fr=`tool-search-tool-2025-10-19`,pr=`task-budgets-2026-03-13`,mr=`prompt-caching-scope-2026-01-05`,hr=`fast-mode-2026-02-01`,gr=`redact-thinking-2026-02-12`,_r=`afk-mode-2026-01-31`,vr=`advisor-tool-2026-03-01`,yr=new Set([cr,lr,fr]),br=new Set([sr,cr,ur])}));function Sr(e,t){return pe(e,t)}var Cr=e((()=>{he()}));function wr(){let e=process.env.CLAUDE_AGENT_SDK_VERSION?`, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`:``,t=process.env.CLAUDE_AGENT_SDK_CLIENT_APP?`, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`:``,n=Nt(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.11 (external, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function Tr(){let e=[];return process.env.CLAUDE_CODE_ENTRYPOINT&&e.push(process.env.CLAUDE_CODE_ENTRYPOINT),process.env.CLAUDE_AGENT_SDK_VERSION&&e.push(`agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`),process.env.CLAUDE_AGENT_SDK_CLIENT_APP&&e.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`),`claude-code/0.0.11${e.length>0?` (${e.join(`, `)})`:``}`}function Er(){if(R()){let e=W();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":ct}}:{headers:{},error:`No OAuth token available`}}let e=ta();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function Dr(e,t){try{return await e()}catch(n){if(!f.isAxiosError(n))throw n;let r=n.response?.status;if(!(r===401||t?.also403Revoked&&r===403&&typeof n.response?.data==`string`&&n.response.data.includes(`OAuth token has been revoked`)))throw n;let i=W()?.accessToken;if(!i)throw n;return await La(i),await e()}}var Or=e((()=>{p(),O(),G(),It()}));function kr(){return{error:(e,...t)=>console.error(`[SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[SDK DEBUG]`,e,...t)}}async function Ar({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:a}){let c=process.env.CLAUDE_CODE_CONTAINER_ID,l=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,u=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,ee=Mr(),te={"x-app":`cli`,"User-Agent":wr(),"X-Claude-Code-Session-Id":be(),...ee,...c?{"x-claude-remote-container-id":c}:{},...l?{"x-claude-remote-session-id":l}:{},...u?{"x-client-app":u}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};_(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!ee.Authorization}`),s(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(te[`x-anthropic-additional-protection`]=`true`),_(`[API:auth] OAuth token check starting`),await Ba(),_(`[API:auth] OAuth token check complete`),R()||await jr(te,h());let f=Nr(i,a),p={defaultHeaders:te,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:mt({forAnthropicAPI:!0}),...f&&{fetch:f}};if(s(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-DxE_mHFI.js`),t=r===Ns()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:d(),n={...p,awsRegion:t,...s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...Fe()&&{logger:kr()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let e=await U();e&&(n.awsAccessKey=e.accessKeyId,n.awsSecretKey=e.secretAccessKey,n.awsSessionToken=e.sessionToken)}return new e(n)}if(s(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(s(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-CGx9qY3q.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...Fe()&&{logger:kr()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await ho();let[{AnthropicVertex:e},{GoogleAuth:n}]=await Promise.all([import(`./vertex-sdk-DjXcZ2J7.js`),import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1))]),i=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,a=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,c=s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||a?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...p,region:o(r),googleAuth:c,...Fe()&&{logger:kr()}})}return new ke({apiKey:R()?null:e||ta(),authToken:R()?W()?.accessToken:void 0,...p,...Fe()&&{logger:kr()}})}async function jr(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await da(t);n&&(e.Authorization=`Bearer ${n}`)}function Mr(){let e={},t=process.env.ANTHROPIC_CUSTOM_HEADERS;if(!t)return e;let n=t.split(/\n|\r\n/);for(let t of n){if(!t.trim())continue;let n=t.indexOf(`:`);if(n===-1)continue;let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();r&&(e[r]=i)}return e}function Nr(e,t){let n=e??globalThis.fetch,r=k()===`firstParty`&&Mt();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(Pr,wt());try{let n=e instanceof Request?e.url:String(e),r=a.get(Pr);_(`[API REQUEST] ${new URL(n).pathname}${r?` ${Pr}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var Pr,Fr=e((()=>{Ne(),G(),Or(),ac(),A(),gt(),m(),v(),l(),Pr=`x-client-request-id`}));function Ir(){return vt(c(),`cache`)}function Lr(){return vt(Ir(),`model-capabilities.json`)}function Rr(){return!(k()!==`firstParty`||!Mt())}function zr(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function Br(e){if(!Rr())return;let t=Wr(Lr());if(!t||t.length===0)return;let n=e.toLowerCase();return t.find(e=>e.id.toLowerCase()===n)||t.find(e=>n.includes(e.id.toLowerCase()))}async function Vr(){if(Rr()&&!$e())try{let e=await Ar({maxRetries:1}),t=R()?[ct]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=Hr().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=Lr(),i=zr(n);if(Sr(Wr(r),i)){_(`[modelCapabilities] cache unchanged, skipping write`);return}await Tt(Ir(),{recursive:!0}),await Dt(r,De({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),Wr.cache.delete(r),_(`[modelCapabilities] cached ${i.length} models`)}catch(e){_(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var Hr,Ur,Wr,Gr=e((()=>{Cr(),i(),le(),O(),Fr(),G(),v(),l(),rt(),ue(),Qe(),Re(),A(),Hr=ce(()=>se({id:ie(),max_input_tokens:ae().optional(),max_tokens:ae().optional()}).strip()),Ur=ce(()=>se({models:oe(Hr()),timestamp:ae()})),Wr=r(e=>{try{let t=xt(e,`utf-8`),n=Ur().safeParse(it(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function Kr(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function F(e){return!Kr()&&/\[1m\]/i.test(e)}function qr(e){if(Kr())return!1;let t=Q(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Jr(e,t){if(F(e))return 1e6;let n=Br(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&Kr()?$r:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&qr(e)||Yr(e)?1e6:$r}function Yr(e){return Kr()||F(e)||!Q(e).includes(`sonnet-4-6`)?!1:S().clientDataCache?.coral_reef_sonnet===`true`}function Xr(e,t){if(!e)return{used:null,remaining:null};let n=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;if(n===0)return{used:null,remaining:null};let r=Math.round(n/t*100),i=Math.min(100,Math.max(0,r));return{used:i,remaining:100-i}}function Zr(e){let t,n,r=Q(e);r.includes(`opus-4-7`)||r.includes(`opus-4-6`)?(t=64e3,n=128e3):r.includes(`sonnet-4-6`)?(t=32e3,n=128e3):r.includes(`opus-4-5`)||r.includes(`sonnet-4`)||r.includes(`haiku-4`)?(t=32e3,n=64e3):r.includes(`opus-4-1`)||r.includes(`opus-4`)?(t=32e3,n=32e3):r.includes(`claude-3-opus`)?(t=4096,n=4096):r.includes(`claude-3-sonnet`)?(t=8192,n=8192):r.includes(`claude-3-haiku`)?(t=4096,n=4096):r.includes(`3-5-sonnet`)||r.includes(`3-5-haiku`)?(t=8192,n=8192):r.includes(`3-7-sonnet`)?(t=32e3,n=64e3):(t=ti,n=ni);let i=Br(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function Qr(e){return Zr(e).upperLimit-1}var $r,ei,ti,ni,ri,ii=e((()=>{xr(),We(),l(),ac(),Gr(),$r=2e5,ei=2e4,ti=32e3,ni=64e3,ri=8e3})),ai,oi,si,ci=e((()=>{i(),A(),ai=[{modelEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],oi=[{modelEnvVar:`OPENAI_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],si=r((e,t)=>{if(k()===`firstParty`)return;let n=e.toLowerCase(),r=k()===`openai`?oi:ai;for(let e of r){let r=process.env[e.modelEnvVar],i=process.env[e.capabilitiesEnvVar];if(!(!r||i===void 0)&&n===r.toLowerCase())return i.toLowerCase().split(`,`).map(e=>e.trim()).includes(t)}},(e,t)=>`${e.toLowerCase()}:${t}`)}));function li(e){let t=[],n=[];for(let r of e)yi.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function ui(e){if(!e||e.length===0)return;if(R()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=li(e);for(let e of n)console.warn(`Warning: Beta header '${e}' is not allowed. Only the following betas are supported: ${yi.join(`, `)}`);return t.length>0?t:void 0}function di(e){let t=si(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Q(e),r=k();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function fi(e){let t=Q(e),n=k();return n===`foundry`?!0:n===`firstParty`?!t.includes(`claude-3-`):t.includes(`claude-opus-4`)||t.includes(`claude-sonnet-4`)||t.includes(`claude-haiku-4`)}function pi(e){let t=Q(e),n=k();return n!==`firstParty`&&n!==`foundry`?!1:t.includes(`claude-sonnet-4-6`)||t.includes(`claude-sonnet-4-5`)||t.includes(`claude-opus-4-1`)||t.includes(`claude-opus-4-5`)||t.includes(`claude-opus-4-6`)||t.includes(`claude-opus-4-7`)||t.includes(`claude-haiku-4-5`)}function mi(e){return!0}function hi(){return(k()===`firstParty`||k()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&Mt()}function gi(){return k()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function _i(e,t){let n=[...xi(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(sr));let r=ve();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function vi(){bi.cache?.clear?.(),xi.cache?.clear?.(),Si.cache?.clear?.()}var yi,bi,xi,Si,Ci=e((()=>{i(),m(),xr(),O(),G(),ii(),l(),ac(),ci(),A(),x(),yi=[lr],bi=r(e=>{let t=[],n=Q(e).includes(`haiku`);k();let r=hi();n||t.push(sr),R()&&t.push(ct),F(e)&&t.push(lr),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&di(e)&&t.push(cr),r&&di(e)&&!h()&&Be().showThinkingSummaries!==!0&&t.push(gr);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||fi(e),a=fi(e);return hi()&&(i||a)&&t.push(ur),r&&pi(e),r&&t.push(mr),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),xi=r(e=>{let t=bi(e);return k()===`bedrock`?t.filter(e=>!yr.has(e)):t}),Si=r(e=>bi(e).filter(e=>yr.has(e)))}));function wi(e,t){return{name:`${e.name}-with-${t.name}-fallback`,read(){return e.read()??(t.read()||{})},async readAsync(){return await e.readAsync()??(await t.readAsync()||{})},update(n){let r=e.read(),i=e.update(n);if(i.success)return r===null&&t.delete(),i;let a=t.update(n);return a.success?(r!==null&&e.delete(),{success:!0,warning:a.warning}):{success:!1}},delete(){let n=e.delete(),r=t.delete();return n||r}}}var Ti=e((()=>{}));async function Ei(){try{let e=M(Yn),{stdout:t,code:n}=await Ze(`security`,[`find-generic-password`,`-a`,qn(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return je(t.trim())}catch{}return null}function Di(){if(Ai!==void 0)return Ai;if(process.platform!==`darwin`)return Ai=!1,!1;try{Ai=Xe(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{Ai=!1}return Ai}var Oi,ki,Ai,ji=e((()=>{Ke(),v(),Ye(),Ge(),Re(),Xn(),Oi=4032,ki={name:`keychain`,read(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=M(Yn),t=qe(`security find-generic-password -a "${qn()}" -w -s "${e}"`);if(t){let e=je(t);return P.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(P.cache={data:null,cachedAt:Date.now()},null):(_(`[keychain] read failed; serving stale cache`,{level:`warn`}),P.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(P.readInFlight)return P.readInFlight;let t=P.generation,n=Ei().then(n=>{if(t===P.generation){n===null&&e.data!==null&&_(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return P.cache={data:t,cachedAt:Date.now()},P.readInFlight=null,t}return n});return P.readInFlight=n,n},update(e){N();try{let t=M(Yn),n=qn(),r=De(e),i=Buffer.from(r,`utf-8`).toString(`hex`),a=`add-generic-password -U -a "${n}" -s "${t}" -X "${i}"\n`,o;return a.length<=Oi?o=Xe(`security`,[`-i`],{input:a,stdio:[`pipe`,`pipe`,`pipe`],reject:!1}):(_(`Keychain payload (${r.length}B JSON) exceeds security -i stdin limit; using argv`,{level:`warn`}),o=Xe(`security`,[`add-generic-password`,`-U`,`-a`,n,`-s`,t,`-X`,i],{stdio:[`ignore`,`pipe`,`pipe`],reject:!1})),o.exitCode===0?(P.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){N();try{let e=M(Yn);return qe(`security delete-generic-password -a "${qn()}" -s "${e}"`),!0}catch{return!1}}}}));function Mi(){let e=c();return{storageDir:e,storagePath:vt(e,`.credentials.json`)}}var Ni,Pi=e((()=>{l(),Ae(),Pe(),Re(),Ni={name:`plaintext`,read(){let{storagePath:e}=Mi();try{return je(Le().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=Mi();try{return je(await Le().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=Mi();try{Le().mkdirSync(t)}catch(e){if(Oe(e)!==`EEXIST`)throw e}return Me(n,De(e),{encoding:`utf8`,flush:!1}),yt(n,384),{success:!0,warning:`Warning: Storing credentials in plaintext.`}}catch{return{success:!1}}},delete(){let{storagePath:e}=Mi();try{return Le().unlinkSync(e),!0}catch(e){return Oe(e)===`ENOENT`}}}}));function Fi(){return process.platform===`darwin`?wi(ki,Ni):Ni}var Ii=e((()=>{Ti(),ji(),Pi()}));function Li(e){return new Promise(t=>{kt(`security`,[`find-generic-password`,`-a`,qn(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:Hi},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function Ri(){if(process.platform!==`darwin`||Wi||u())return;let e=Li(M(Yn)),t=Li(M());Wi=Promise.all([e,t]).then(([e,t])=>{e.timedOut||Jn(e.stdout),t.timedOut||(Ui={stdout:t.stdout})})}async function zi(){Wi&&await Wi}function Bi(){return Ui}function Vi(){Ui=null}var Hi,Ui,Wi,Gi=e((()=>{l(),Xn(),Hi=1e4,Ui=null,Wi=null}));function Ki(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r();return}let a=setTimeout((e,t,n)=>{e?.removeEventListener(`abort`,t),n()},e,t,o,r);function o(){clearTimeout(a),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r()}t?.addEventListener(`abort`,o,{once:!0}),n?.unref&&a.unref()})}var qi=e((()=>{}));function Ji(){return Xi}function Yi(){Xi.clear()}var Xi,Zi=e((()=>{Xi=new Map})),Qi=n({calculateApiKeyHelperTTL:()=>la,checkAndRefreshOAuthTokenIfNeeded:()=>Ba,checkGcpCredentialsValid:()=>Ca,clearApiKeyHelperCache:()=>ha,clearAwsCredentialsCache:()=>ba,clearGcpCredentialsCache:()=>Ea,clearOAuthTokenCache:()=>Fa,getAccountInformation:()=>oo,getAnthropicApiKey:()=>ta,getAnthropicApiKeyWithSource:()=>ra,getApiKeyFromApiKeyHelper:()=>da,getApiKeyFromApiKeyHelperCached:()=>ma,getApiKeyFromConfigOrMacOSKeychain:()=>go,getApiKeyHelperElapsedMs:()=>ua,getAuthTokenSource:()=>ea,getClaudeAIOAuthTokens:()=>W,getClaudeAIOAuthTokensAsync:()=>za,getConfiguredApiKeyHelper:()=>L,getOauthAccountInfo:()=>Wa,getOtelHeadersFromHelper:()=>ro,getRateLimitTier:()=>Qa,getSubscriptionName:()=>$a,getSubscriptionType:()=>z,handleOAuth401Error:()=>La,hasAnthropicApiKeyAuth:()=>na,hasOpusAccess:()=>Ka,hasProfileScope:()=>Ha,is1PApiCustomer:()=>Ua,isAnthropicAuthEnabled:()=>I,isAwsAuthRefreshFromProjectSettings:()=>oa,isAwsCredentialExportFromProjectSettings:()=>ca,isClaudeAISubscriber:()=>R,isConsumerSubscriber:()=>ao,isCustomApiKeyApproved:()=>ja,isEnterpriseSubscriber:()=>Xa,isGcpAuthRefreshFromProjectSettings:()=>Sa,isMaxSubscriber:()=>qa,isOtelHeadersHelperFromProjectOrLocalSettings:()=>no,isOverageProvisioningAllowed:()=>Ga,isProSubscriber:()=>Za,isTeamPremiumSubscriber:()=>Ya,isTeamSubscriber:()=>Ja,isUsing3PServices:()=>eo,prefetchApiKeyFromApiKeyHelperIfSafe:()=>ga,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>Oa,prefetchGcpCredentialsIfSafe:()=>Da,refreshAndGetAwsCredentials:()=>U,refreshAwsAuth:()=>va,refreshGcpAuth:()=>Ta,refreshGcpCredentialsIfNeeded:()=>ho,removeApiKey:()=>Ma,saveApiKey:()=>Aa,saveOAuthTokensIfNeeded:()=>Pa,validateForceLoginOrg:()=>so});function $i(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function I(){if(u())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let e=b()||{},t=s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||e.modelType===`openai`||e.modelType===`gemini`||!!process.env.OPENAI_BASE_URL||!!process.env.GEMINI_BASE_URL,n=e.apiKeyHelper,r=process.env.ANTHROPIC_AUTH_TOKEN||n||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:i}=ra({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!$i()||a&&!$i())}function ea(){if(u())return L()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!$i())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(Bn())return process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR?{source:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,hasToken:!0}:{source:`CCR_OAUTH_TOKEN_FILE`,hasToken:!0};if(L()&&!$i())return{source:`apiKeyHelper`,hasToken:!0};let e=W();return wn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function ta(){let{key:e}=ra();return e}function na(){let{key:e,source:t}=ra({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function ra(e={}){if(u())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:L()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:ma(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(_e()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=Vn();if(e)return{key:e,source:`ANTHROPIC_API_KEY`};if(!t&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error(`ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required`);return t?{key:t,source:`ANTHROPIC_API_KEY`}:{key:null,source:`none`}}if(t&&S().customApiKeyResponses?.approved?.includes(Qn(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=Vn();return n?{key:n,source:`ANTHROPIC_API_KEY`}:L()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:ma(),source:`apiKeyHelper`}:go()||{key:null,source:`none`}}function L(){return u()?y(`flagSettings`)?.apiKeyHelper:(b()||{}).apiKeyHelper}function ia(){let e=L();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function aa(){return(b()||{}).awsAuthRefresh}function oa(){let e=aa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function sa(){return(b()||{}).awsCredentialExport}function ca(){let e=sa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function la(){let e=process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;if(e){let t=parseInt(e,10);if(!Number.isNaN(t)&&t>=0)return t;_(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${e}`,{level:`error`})}return co}function ua(){let e=V?.startedAt;return e?Date.now()-e:0}async function da(e){if(!L())return null;let t=la();return B?(Date.now()-B.timestamp<t||V||(V={promise:fa(e,!1,H),startedAt:null}),B.value):(V||(V={promise:fa(e,!0,H),startedAt:Date.now()}),V.promise)}async function fa(e,t,n){try{let t=await pa(e);return n===H&&t!==null&&(B={value:t,timestamp:Date.now()}),t}catch(e){if(n!==H)return` `;let r=e instanceof Error?e.message:String(e);return console.error(re.red(`apiKeyHelper failed: ${r}`)),_(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&B&&B.value!==` `?(B={...B,timestamp:Date.now()},B.value):(B={value:` `,timestamp:Date.now()},` `)}finally{n===H&&(V=null)}}async function pa(e){let t=L();if(!t)return null;if(ia()&&!C()&&!e)return Ie(`apiKeyHelper invoked before trust check`,Error(`Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_apiKeyHelper_missing_trust11`,{}),null;let n=await Je(t,{shell:!0,timeout:600*1e3,reject:!1});if(n.failed){let e=n.timedOut?`timed out`:`exited ${n.exitCode}`,t=n.stderr?.trim();throw Error(t?`${e}: ${t}`:e)}let r=n.stdout?.trim();if(!r)throw Error(`did not return a value`);return r}function ma(){return B?.value??null}function ha(){H++,B=null,V=null}function ga(e){ia()&&!C()||da(e)}async function _a(){let e=aa();if(!e)return!1;if(oa()&&!C()&&!h())return Ie(`awsAuthRefresh invoked before trust check`,Error(`Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsAuthRefresh_missing_trust`,{}),!1;try{return _(`Fetching AWS caller identity for AWS auth refresh command`),await nr(),_(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return va(e)}}function va(e){_(`Running AWS auth refresh command`);let t=ar.getInstance();return t.startAuthentication(),new Promise(n=>{let r=Ot(e,{timeout:uo});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`AWS auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running awsAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}async function ya(){let e=sa();if(!e)return null;if(ca()&&!C()&&!h())return Ie(`awsCredentialExport invoked before trust check`,Error(`Security: awsCredentialExport executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsCredentialExport_missing_trust`,{}),null;try{return _(`Fetching AWS caller identity for credential export command`),await nr(),_(`Fetched AWS caller identity, skipping AWS credential export command`),null}catch{try{_(`Running AWS credential export command`);let t=await Je(e,{shell:!0,reject:!1});if(t.exitCode!==0||!t.stdout)throw Error(`awsCredentialExport did not return a valid value`);let n=je(t.stdout.trim());if(!tr(n))throw Error(`awsCredentialExport did not return valid AWS STS output structure`);return _(`AWS credentials retrieved from awsCredentialExport`),{accessKeyId:n.Credentials.AccessKeyId,secretAccessKey:n.Credentials.SecretAccessKey,sessionToken:n.Credentials.SessionToken}}catch(e){let t=re.red(`Error getting AWS credentials from awsCredentialExport (in settings or ~/.claude.json):`);return e instanceof Error?console.error(t,e.message):console.error(t,e),null}}}function ba(){U.cache.clear()}function xa(){return(b()||{}).gcpAuthRefresh}function Sa(){let e=xa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function Ca(){try{let{GoogleAuth:e}=await import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1)),n=new e({scopes:[`https://www.googleapis.com/auth/cloud-platform`]}),r=(async()=>{await(await n.getClient()).getAccessToken()})(),i=Ki(fo).then(()=>{throw new Co(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function wa(){let e=xa();if(!e)return!1;if(Sa()&&!C()&&!h())return Ie(`gcpAuthRefresh invoked before trust check`,Error(`Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_gcpAuthRefresh_missing_trust`,{}),!1;try{if(_(`Checking GCP credentials validity for auth refresh`),await Ca())return _(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return Ta(e)}function Ta(e){_(`Running GCP auth refresh command`);let t=ar.getInstance();return t.startAuthentication(),new Promise(n=>{let r=Ot(e,{timeout:mo});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`GCP auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running gcpAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}function Ea(){ho.cache.clear()}function Da(){xa()&&(Sa()&&!C()&&!h()||ho())}function Oa(){let e=aa(),t=sa();!e&&!t||(oa()||ca())&&!C()&&!h()||(U(),j())}function ka(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function Aa(e){if(!ka(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await Na();let t=!1;if(process.platform===`darwin`)try{let n=M();await Je(`security`,[`-i`],{input:`add-generic-password -U -a "${qn()}" -s "${n}" -X "${Buffer.from(e,`utf-8`).toString(`hex`)}"\n`,reject:!1}),E(`tengu_api_key_saved_to_keychain`,{}),t=!0}catch(e){T(e),E(`tengu_api_key_keychain_error`,{error:g(e)}),E(`tengu_api_key_saved_to_config`,{})}else E(`tengu_api_key_saved_to_config`,{});let n=Qn(e);w(r=>{let i=r.customApiKeyResponses?.approved??[];return{...r,primaryApiKey:t?r.primaryApiKey:e,customApiKeyResponses:{...r.customApiKeyResponses,approved:i.includes(n)?i:[...i,n],rejected:r.customApiKeyResponses?.rejected??[]}}}),go.cache.clear?.(),Vi()}function ja(e){let t=S(),n=Qn(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function Ma(){await Na(),w(e=>({...e,primaryApiKey:void 0})),go.cache.clear?.(),Vi()}async function Na(){try{await Zn()}catch(e){T(e)}}function Pa(e){if(!wn(e.scopes))return E(`tengu_oauth_tokens_not_claude_ai`,{}),{success:!0};if(!e.refreshToken||!e.expiresAt)return E(`tengu_oauth_tokens_inference_only`,{}),{success:!0};let t=Fi(),n=t.name;try{let r=t.read()||{},i=r.claudeAiOauth;r.claudeAiOauth={accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes,subscriptionType:e.subscriptionType??i?.subscriptionType??null,rateLimitTier:e.rateLimitTier??i?.rateLimitTier??null};let a=t.update(r);return a.success?E(`tengu_oauth_tokens_saved`,{storageBackend:n}):E(`tengu_oauth_tokens_save_failed`,{storageBackend:n}),W.cache?.clear?.(),vi(),Yi(),a}catch(e){return T(e),E(`tengu_oauth_tokens_save_exception`,{storageBackend:n,error:g(e)}),{success:!1,warning:`Failed to save OAuth tokens`}}}function Fa(){W.cache?.clear?.(),N()}async function Ia(){try{let{mtimeMs:e}=await Et(vt(c(),`.credentials.json`));e!==_o&&(_o=e,Fa())}catch{W.cache?.clear?.()}}function La(e){let t=vo.get(e);if(t)return t;let n=Ra(e).finally(()=>{vo.delete(e)});return vo.set(e,n),n}async function Ra(e){Fa();let t=await za();return t?.refreshToken?t.accessToken===e?Ba(0,!0):(E(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function za(){if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||Bn())return W();try{let e=(await Fi().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}function Ba(e=0,t=!1){return e===0&&!t?yo||(yo=Va(e,t).finally(()=>{yo=null}),yo):Va(e,t)}async function Va(e,t){await Ia();let n=W();if(!t&&(!n?.refreshToken||!jn(n.expiresAt))||!n?.refreshToken||!wn(n.scopes))return!1;W.cache?.clear?.(),N();let r=await za();if(!r?.refreshToken||!jn(r.expiresAt))return!1;let i=c();await Tt(i,{recursive:!0});let a;try{E(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await He(i),E(`tengu_oauth_token_refresh_lock_acquired`,{})}catch(n){return n.code===`ELOCKED`?e<5?(E(`tengu_oauth_token_refresh_lock_retry`,{retryCount:e+1}),await Ki(1e3+Math.random()*1e3),Va(e+1,t)):(E(`tengu_oauth_token_refresh_lock_retry_limit_reached`,{maxRetries:5}),!1):(T(n),E(`tengu_oauth_token_refresh_lock_error`,{error:g(n)}),!1)}try{W.cache?.clear?.(),N();let e=await za();return!e?.refreshToken||!jn(e.expiresAt)?(E(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(E(`tengu_oauth_token_refresh_starting`,{}),Pa(await On(e.refreshToken,{scopes:wn(e.scopes)?void 0:e.scopes})),W.cache?.clear?.(),N(),!0)}catch(e){T(e),W.cache?.clear?.(),N();let t=await za();return t&&!jn(t.expiresAt)?(E(`tengu_oauth_token_refresh_race_recovered`,{}),!0):!1}finally{E(`tengu_oauth_token_refresh_lock_releasing`,{}),await a(),E(`tengu_oauth_token_refresh_lock_released`,{})}}function R(){return I()?wn(W()?.scopes):!1}function Ha(){return W()?.scopes?.includes(`user:profile`)??!1}function Ua(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||R())}function Wa(){return I()?S().oauthAccount:void 0}function Ga(){let e=Wa()?.billingType;return!(!R()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function Ka(){let e=z();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function z(){if(!I())return null;let e=W();return e?e.subscriptionType??null:null}function qa(){return z()===`max`}function Ja(){return z()===`team`}function Ya(){return z()===`team`&&Qa()===`default_claude_max_5x`}function Xa(){return z()===`enterprise`}function Za(){return z()===`pro`}function Qa(){if(!I())return null;let e=W();return e?e.rateLimitTier??null:null}function $a(){switch(z()){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`;default:return`Claude API`}}function eo(){return!!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||s(process.env.CLAUDE_CODE_USE_OPENAI)||s(process.env.CLAUDE_CODE_USE_GEMINI)||s(process.env.CLAUDE_CODE_USE_GROK))}function to(){return(b()||{}).otelHeadersHelper}function no(){let e=to();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function ro(){let e=to();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||So.toString(),10);if(bo&&Date.now()-xo<t)return bo;if(no()&&!C())return{};try{let t=qe(e,{timeout:3e4})?.toString().trim();if(!t)throw Error(`otelHeadersHelper did not return a valid value`);let n=je(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`otelHeadersHelper must return a JSON object with string key-value pairs`);for(let[e,t]of Object.entries(n))if(typeof t!=`string`)throw Error(`otelHeadersHelper returned non-string value for key "${e}": ${typeof t}`);return bo=n,xo=Date.now(),bo}catch(e){throw T(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${g(e)}`)),e}}function io(e){return e===`max`||e===`pro`}function ao(){let e=z();return R()&&e!==null&&io(e)}function oo(){if(k()!==`firstParty`)return;let{source:e}=ea(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:R()?t.subscription=$a():t.tokenSource=e;let{key:n,source:r}=ra();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=Wa()?.organizationName;e&&(t.organization=e)}let i=Wa()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function so(){if(process.env.ANTHROPIC_UNIX_SOCKET||!I())return{valid:!0};let e=y(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await Ba();let t=W();if(!t)return{valid:!0};let{source:n}=ea(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await Sn(t.accessToken);if(!i)return{valid:!1,message:`Unable to verify organization for the current authentication token.\nThis machine requires organization ${e} but the profile could not be fetched.\nThis may be a network error, or the token may lack the user:profile scope required for\nverification (tokens from 'claude setup-token' do not include this scope).\nTry again, or obtain a full-scope token.`};let a=i.organization.uuid;return a===e?{valid:!0}:r?{valid:!1,message:`The ${n===`CLAUDE_CODE_OAUTH_TOKEN`?`CLAUDE_CODE_OAUTH_TOKEN`:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`} environment variable provides a token for a\ndifferent organization than required by this machine's managed settings.\n\nRequired organization: ${e}\nToken organization: ${a}\n\nRemove the environment variable or obtain a token for the correct organization.`}:{valid:!1,message:`Your authentication token belongs to organization ${a},\nbut this machine requires organization ${e}.\n\nAuthentication token belongs to the wrong organization.`}}var co,B,V,H,lo,uo,U,fo,po,mo,ho,go,W,_o,vo,yo,bo,xo,So,Co,G=e((()=>{ne(),Ke(),i(),O(),at(),bn(),A(),m(),In(),Cn(),Kn(),$n(),ir(),or(),Ci(),We(),v(),l(),Ae(),Ye(),Ue(),et(),nt(),Ii(),Gi(),Xn(),x(),qi(),Re(),Zi(),co=300*1e3,B=null,V=null,H=0,lo=3600*1e3,uo=180*1e3,U=tt(async()=>{let e=await _a(),t=await ya();return(e||t)&&await rr(),t},lo),fo=5e3,po=3600*1e3,mo=180*1e3,ho=tt(async()=>await wa(),po),go=r(()=>{if(u())return null;if(process.platform===`darwin`){let e=Bi();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=M();try{let t=qe(`security find-generic-password -a $USER -w -s "${e}"`);if(t)return{key:t,source:`/login managed key`}}catch(e){T(e)}}}let e=S();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),W=r(()=>{if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};let e=Bn();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=Fi().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}),_o=0,vo=new Map,yo=null,bo=null,xo=0,So=1740*1e3,Co=class extends Error{}}));function K(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function wo(){return K()?Eo()===null:!1}function To(e,t){switch(e){case`free`:return t===`oauth`?`Fast mode requires a paid subscription`:`Fast mode unavailable during evaluation. Please purchase credits.`;case`preference`:return`Fast mode has been disabled by your organization`;case`extra_usage_disabled`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function Eo(){if(!K())return`Fast mode is not available`;if(ut(),h()&&_e()&&!y(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return _(`Fast mode unavailable: ${e}`),e}if(k()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return _(`Fast mode unavailable: ${e}`),e}if(J.status===`disabled`){if((J.reason===`network_error`||J.reason===`unknown`)&&s(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS))return null;let e=W()===null?`api-key`:`oauth`,t=To(J.reason,e);return _(`Fast mode unavailable: ${t}`),t}return null}function Do(){return`opus`+(Js()?`[1m]`:``)}function Oo(e){if(!K()||!wo()||!ko(e))return!1;let t=Be();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function ko(e){if(!K())return!1;let t=$(e??Us());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function Ao(){return q.status===`cooldown`&&Date.now()>=q.resetAt&&(K()&&!Uo&&(_(`Fast mode cooldown expired, re-enabling fast mode`),Uo=!0,Go.emit()),q={status:`active`}),q}function jo(e,t){if(!K())return;q={status:`cooldown`,resetAt:e,reason:t},Uo=!1;let n=e-Date.now();_(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),E(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),Wo.emit(e,t)}function Mo(){q={status:`active`}}function No(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},Ve(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1})),Xo.emit(!1))}function Po(e){switch(e){case`out_of_credits`:return`Fast mode disabled · extra usage credits exhausted`;case`org_level_disabled`:case`org_service_level_disabled`:return`Fast mode disabled · extra usage disabled by your organization`;case`org_level_disabled_until`:return`Fast mode disabled · extra usage spending cap reached`;case`member_level_disabled`:return`Fast mode disabled · extra usage disabled for your account`;case`seat_tier_level_disabled`:case`seat_tier_zero_credit_limit`:case`member_zero_credit_limit`:return`Fast mode disabled · extra usage not available for your plan`;case`overage_not_provisioned`:case`no_limits_configured`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;default:return`Fast mode disabled · extra usage not available`}}function Fo(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function Io(e){let t=Po(e);_(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),E(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),Fo(e)||(Ve(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1}))),Jo.emit(t)}function Lo(){return Ao().status===`cooldown`}function Ro(e,t){let n=K()&&wo()&&!!t&&ko(e);return n&&Lo()?`cooldown`:n?`on`:`off`}async function zo(e){let t=`${D().BASE_API_URL}/api/claude_code_penguin_mode`,n=`accessToken`in e?{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":ct}:{"x-api-key":e.apiKey};return(await f.get(t,{headers:n})).data}function Bo(){K()&&J.status===`pending`&&(J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`unknown`})}async function Vo(){if($e()||!K())return;if(es)return _(`Fast mode prefetch in progress, returning in-flight promise`),es;let e=ta();if(!(W()?.accessToken&&Ha())&&!e){J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-$o<Qo){_(`Skipping fast mode prefetch, fetched recently`);return}$o=t;let n=async()=>{let t=W(),n=t?.accessToken&&Ha()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return zo(n)};async function r(){try{let e;try{e=await n()}catch(t){if(f.isAxiosError(t)&&(t.response?.status===401||t.response?.status===403&&typeof t.response?.data==`string`&&t.response.data.includes(`OAuth token has been revoked`))){let r=W()?.accessToken;if(r)await La(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?S().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||Ve(`userSettings`,{fastMode:void 0}),w(t=>({...t,penguinModeOrgEnabled:e.enabled})),Xo.emit(e.enabled)),_(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`network_error`},_(`Failed to fetch org fast mode status, defaulting to ${J.status===`enabled`?`enabled (cached)`:`disabled (network_error)`}: ${e}`,{level:`error`}),E(`tengu_org_penguin_mode_fetch_failed`,{})}finally{es=null}}return es=r(),es}var Ho,q,Uo,Wo,Go,Ko,qo,Jo,Yo,J,Xo,Zo,Qo,$o,es,ts=e((()=>{p(),O(),m(),at(),G(),dt(),We(),v(),l(),ac(),A(),Qe(),x(),Se(),Ho=`Opus 4.7`,q={status:`active`},Uo=!1,Wo=ye(),Go=ye(),Ko=Wo.subscribe,qo=Go.subscribe,Jo=ye(),Yo=Jo.subscribe,J={status:`pending`},Xo=ye(),Zo=Xo.subscribe,Qo=3e4,$o=0,es=null}));function ns(e){return K()&&e?fs:ds}function rs(e,t){return t.input_tokens/1e6*e.inputTokens+t.output_tokens/1e6*e.outputTokens+(t.cache_read_input_tokens??0)/1e6*e.promptCacheReadTokens+(t.cache_creation_input_tokens??0)/1e6*e.promptCacheWriteTokens+(t.server_tool_use?.web_search_requests??0)*e.webSearchRequests}function is(e,t){let n=Q(e);return n===Z(on.firstParty)?ns(t.speed===`fast`):gs[n]||(as(e,n),gs[Q(Us())]??hs)}function as(e,t){E(`tengu_unknown_model_cost`,{model:e,shortName:t}),Ce()}function os(e,t){return rs(is(e,t),t)}function ss(e,t){return os(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function cs(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function ls(e){return`${cs(e.inputTokens)}/${cs(e.outputTokens)} per Mtok`}var Y,us,ds,fs,ps,ms,hs,gs,_s=e((()=>{at(),m(),ts(),dn(),ac(),Y={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},us={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},ds={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},fs={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},ps={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},ms={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},hs=ds,gs={[Z(Qt.firstParty)]:ps,[Z($t.firstParty)]:ms,[Z(Zt.firstParty)]:Y,[Z(Xt.firstParty)]:Y,[Z(en.firstParty)]:Y,[Z(tn.firstParty)]:Y,[Z(cn.firstParty)]:Y,[Z(nn.firstParty)]:us,[Z(rn.firstParty)]:us,[Z(an.firstParty)]:ds,[Z(on.firstParty)]:ds}}));function X(e){return ys.includes(e)}function vs(e){return bs.includes(e)}var ys,bs,xs=e((()=>{ys=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],bs=[`sonnet`,`opus`,`haiku`]}));function Ss(e,t){return e.includes(t)?!0:X(e)?$(e).toLowerCase().includes(t):!1}function Cs(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function ws(e,t){let n=X(e)?$(e).toLowerCase():e;return!!(Cs(n,t)||!t.startsWith(`claude-`)&&Cs(n,`claude-${t}`))}function Ts(e,t){for(let n of t){if(vs(n))continue;let t=n.indexOf(e);if(t===-1)continue;let r=t+e.length;if(r===n.length||n[r]===`-`)return!0}return!1}function Es(e){let{availableModels:t}=b()||{};if(!t)return!0;if(t.length===0)return!1;let n=hn(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!vs(n)||!Ts(n,r)))return!0;for(let e of r)if(vs(e)&&!Ts(e,r)&&Ss(n,e))return!0;if(X(n)){let e=$(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!vs(e)&&X(e)&&$(e).toLowerCase()===n)return!0;for(let e of r)if(!vs(e)&&!X(e)&&ws(n,e))return!0;return!1}var Ds=e((()=>{x(),xs(),ac(),bn()}));function Os(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var ks,As,js,Ms=e((()=>{ks=`gpt-5.5`,As=`gpt-5.4-mini`,js=[{value:`gpt-5.5`,label:`GPT-5.5`,description:`Frontier model for complex coding, research, and real-world work`},{value:`gpt-5.4`,label:`GPT-5.4`,description:`Strong model for everyday coding`},{value:`gpt-5.4-mini`,label:`GPT-5.4-Mini`,description:`Small, fast, and cost-efficient model for simpler coding tasks`},{value:`gpt-5.3-codex`,label:`GPT-5.3-Codex`,description:`Coding-optimized model`},{value:`gpt-5.3-codex-spark`,label:`GPT-5.3-Codex-Spark`,description:`Ultra-fast coding model`},{value:`gpt-5.2`,label:`GPT-5.2`,description:`Optimized for professional work and long-running agents`}]}));function Ns(){let e=k();return e===`openai`&&Os()?process.env.OPENAI_SMALL_FAST_MODEL??`gpt-5.4-mini`:e===`openai`&&process.env.OPENAI_SMALL_FAST_MODEL?process.env.OPENAI_SMALL_FAST_MODEL:e===`gemini`&&process.env.GEMINI_SMALL_FAST_MODEL?process.env.GEMINI_SMALL_FAST_MODEL:process.env.ANTHROPIC_SMALL_FAST_MODEL||Vs()}function Ps(e){return e===j().opus40||e===j().opus41||e===j().opus45||e===j().opus46||e===j().opus47}function Fs(){let e,t=me();if(t!==void 0)e=t;else{let t=b()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!Es(e)))return e}function Is(){let e=Fs();return e==null?Ws():$(e)}function Ls(){return zs()}function Rs(){let e=k();if(e===`openai`)return process.env.OPENAI_MODEL;if(e===`gemini`)return process.env.GEMINI_MODEL;if(e===`grok`)return process.env.GROK_MODEL}function zs(){let e=k();return e===`openai`&&Os()?ks:e===`openai`&&process.env.OPENAI_DEFAULT_OPUS_MODEL?process.env.OPENAI_DEFAULT_OPUS_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_OPUS_MODEL?process.env.GEMINI_DEFAULT_OPUS_MODEL:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL?process.env.ANTHROPIC_DEFAULT_OPUS_MODEL:Rs()||j().opus47}function Bs(){let e=k();return e===`openai`&&Os()?ks:e===`openai`&&process.env.OPENAI_DEFAULT_SONNET_MODEL?process.env.OPENAI_DEFAULT_SONNET_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_SONNET_MODEL?process.env.GEMINI_DEFAULT_SONNET_MODEL:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL?process.env.ANTHROPIC_DEFAULT_SONNET_MODEL:Rs()||(e===`firstParty`?j().sonnet46:j().sonnet45)}function Vs(){let e=k();return e===`openai`&&Os()?As:e===`openai`&&process.env.OPENAI_DEFAULT_HAIKU_MODEL?process.env.OPENAI_DEFAULT_HAIKU_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_HAIKU_MODEL?process.env.GEMINI_DEFAULT_HAIKU_MODEL:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL?process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL:Rs()||j().haiku45}function Hs(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return Fs()===`opusplan`&&t===`plan`&&!r?zs():Fs()===`haiku`&&t===`plan`?Bs():n}function Us(){return qa()||Ya()?zs()+(Js()?`[1m]`:``):Bs()}function Ws(){return $(Us())}function Z(e){if(e=e.toLowerCase(),e.includes(`claude-opus-4-7`))return`claude-opus-4-7`;if(e.includes(`claude-opus-4-6`))return`claude-opus-4-6`;if(e.includes(`claude-opus-4-5`))return`claude-opus-4-5`;if(e.includes(`claude-opus-4-1`))return`claude-opus-4-1`;if(e.includes(`claude-opus-4`))return`claude-opus-4`;if(e.includes(`claude-sonnet-4-6`))return`claude-sonnet-4-6`;if(e.includes(`claude-sonnet-4-5`))return`claude-sonnet-4-5`;if(e.includes(`claude-sonnet-4`))return`claude-sonnet-4`;if(e.includes(`claude-haiku-4-5`))return`claude-haiku-4-5`;if(e.includes(`claude-3-7-sonnet`))return`claude-3-7-sonnet`;if(e.includes(`claude-3-5-sonnet`))return`claude-3-5-sonnet`;if(e.includes(`claude-3-5-haiku`))return`claude-3-5-haiku`;if(e.includes(`claude-3-opus`))return`claude-3-opus`;if(e.includes(`claude-3-sonnet`))return`claude-3-sonnet`;if(e.includes(`claude-3-haiku`))return`claude-3-haiku`;let t=e.match(/(claude-(\d+-\d+-)?\w+)/);return t&&t[1]?t[1]:e}function Q(e){return Z(hn(e))}function Gs(e=!1){return qa()||Ya()?Js()?`Opus 4.7 with 1M context · Most capable for complex work${e?qs(!0):``}`:`Opus 4.7 · Most capable for complex work${e?qs(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function Ks(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:Zs($(e))}function qs(e){if(k()!==`firstParty`)return``;let t=ls(ns(e));return` ·${e?` (↯)`:``} ${t}`}function Js(){return!(Kr()||Za()||k()!==`firstParty`||!Mt()||R()&&z()===null)}function Ys(e){return e===`opusplan`?`Opus Plan`:X(e)?ft(e):Zs(e)}function Xs(e){switch(e){case j().opus47:return`Opus 4.7`;case j().opus47+`[1m]`:return`Opus 4.7 (1M context)`;case j().opus46:return`Opus 4.6`;case j().opus46+`[1m]`:return`Opus 4.6 (1M context)`;case j().opus45:return`Opus 4.5`;case j().opus41:return`Opus 4.1`;case j().opus40:return`Opus 4`;case j().sonnet46+`[1m]`:return`Sonnet 4.6 (1M context)`;case j().sonnet46:return`Sonnet 4.6`;case j().sonnet45+`[1m]`:return`Sonnet 4.5 (1M context)`;case j().sonnet45:return`Sonnet 4.5`;case j().sonnet40:return`Sonnet 4`;case j().sonnet40+`[1m]`:return`Sonnet 4 (1M context)`;case j().sonnet37:return`Sonnet 3.7`;case j().sonnet35:return`Sonnet 3.5`;case j().haiku45:return`Haiku 4.5`;case j().haiku35:return`Haiku 3.5`;default:return null}}function Zs(e){return Xs(e)||e}function $(e){let t=e.trim(),n=t.toLowerCase(),r=F(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(X(i))switch(i){case`opusplan`:return Bs()+(r?`[1m]`:``);case`sonnet`:return Bs()+(r?`[1m]`:``);case`haiku`:return Vs()+(r?`[1m]`:``);case`opus`:return zs()+(r?`[1m]`:``);case`best`:return Ls();default:}return k()===`firstParty`&&$s(i)&&ec()?zs()+(r?`[1m]`:``):r?t.replace(/\[1m\]$/i,``).trim()+`[1m]`:t}function Qs(e,t){return F(e)||!F(t)?e:qr($(e))?e+`[1m]`:e}function $s(e){return ic.includes(e)}function ec(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function tc(e){if(e===null)return R()?`Default (${Gs()})`:`Default (${Ws()})`;let t=$(e);return e===t?t:`${e} (${t})`}function nc(e){if(k()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Q(e);if(n.includes(`claude-opus-4-7`))return t?`Opus 4.7 (with 1M context)`:`Opus 4.7`;if(n.includes(`claude-opus-4-6`))return t?`Opus 4.6 (with 1M context)`:`Opus 4.6`;if(n.includes(`claude-opus-4-5`))return`Opus 4.5`;if(n.includes(`claude-opus-4-1`))return`Opus 4.1`;if(n.includes(`claude-opus-4`))return`Opus 4`;if(n.includes(`claude-sonnet-4-6`))return t?`Sonnet 4.6 (with 1M context)`:`Sonnet 4.6`;if(n.includes(`claude-sonnet-4-5`))return t?`Sonnet 4.5 (with 1M context)`:`Sonnet 4.5`;if(n.includes(`claude-sonnet-4`))return t?`Sonnet 4 (with 1M context)`:`Sonnet 4`;if(n.includes(`claude-3-7-sonnet`))return`Claude 3.7 Sonnet`;if(n.includes(`claude-3-5-sonnet`))return`Claude 3.5 Sonnet`;if(n.includes(`claude-haiku-4-5`))return`Haiku 4.5`;if(n.includes(`claude-3-5-haiku`))return`Claude 3.5 Haiku`}function rc(e){return e.replace(/\[(1|2)m\]/gi,``)}var ic,ac=e((()=>{m(),G(),ii(),l(),bn(),_s(),x(),A(),ze(),Ds(),xs(),pt(),Ms(),ic=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{No as $,Er as $n,Ht as $r,Za as $t,Ms as A,xi as An,An as Ar,L as At,ss as B,Xr as Bn,wn as Br,G as Bt,$ as C,Ii as Cn,N as Cr,da as Ct,Qs as D,ui as Dn,Ln as Dr,ea as Dt,Ys as E,vi as En,Kn as Er,ua as Et,xs as F,gi as Fn,In as Fr,z as Ft,Ho as G,F as Gn,_n as Gr,R as Gt,ls as H,Qr as Hn,xn as Hr,I as Ht,ps as I,si as In,jn as Ir,La as It,Ao as J,Gr as Jn,Gt as Jr,Xa as Jt,Mo as K,ii as Kn,j as Kr,ao as Kt,ms as L,ci as Ln,Tn as Lr,na as Lt,Ds as M,mi as Mn,kn as Mr,ro as Mt,Es as N,pi as Nn,Mn as Nr,Qa as Nt,ks as O,Si as On,Rn as Or,W as Ot,ys as P,hi as Pn,Nn as Pr,$a as Pt,Io as Q,Fr as Qn,Yt as Qr,Ga as Qt,Y as R,ri as Rn,Pn as Rr,Ka as Rt,rc as S,Fi as Sn,Qn as Sr,ra as St,Zs as T,Di as Tn,Gn as Tr,go as Tt,ns as U,Zr as Un,Sn as Ur,oa as Ut,os as V,Jr as Vn,Fn as Vr,Ua as Vt,_s as W,Yr as Wn,Cn as Wr,ca as Wt,Eo as X,Pr as Xn,Wt as Xr,qa as Xt,Ro as Y,Vr as Yn,Vt as Yr,Sa as Yt,Oo as Z,Ar as Zn,qt as Zr,no as Zt,ac as _,qi as _n,ar as _r,ba as _t,Vs as a,k as ai,Da as an,Sr as ar,qo as at,Js as b,Gi as bn,er as br,oo as bt,zs as c,Mt as ci,Ta as cn,lr as cr,Zo as ct,nc as d,Aa as dn,mr as dr,jo as dt,Rt as ei,Ya as en,Tr as er,ts as et,qs as f,Pa as fn,gr as fr,Qi as ft,Fs as g,Zi as gn,xr as gr,ha as gt,Ns as h,Ji as hn,br as hr,Ca as ht,Gs as i,Pt as ii,Oa as in,Cr as ir,ko as it,Os as j,Ci as jn,Dn as jr,Wa as jt,js as k,_i as kn,En as kr,za as kt,Bs as l,ho as ln,ur as lr,Vo as lt,Hs as m,Yi as mn,pr as mr,Ba as mt,Ls as n,Nt as ni,eo as nn,Or as nr,Lo as nt,Ws as o,jt as oi,U as on,vr as or,Ko as ot,Xs as p,so as pn,dr as pr,la as pt,Do as q,Kr as qn,bn as qr,ja as qt,Q as r,It as ri,ga as rn,Dr as rr,K as rt,Us as s,A as si,va as sn,_r as sr,Yo as st,Z as t,Lt as ti,Ja as tn,wr as tr,wo as tt,Is as u,Ma as un,hr as ur,Bo as ut,ec as v,Ki as vn,or as vr,Ea as vt,Ks as w,ji as wn,Xn as wr,ma as wt,tc as x,Ri as xn,$n as xr,ta as xt,Ps as y,zi as yn,ir as yr,Fa as yt,gs as z,ei as zn,On as zr,Ha as zt};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{CT as n,Dp as r,Ep as i,Op as a,ST as o,Sg as s,wg as c,xg as l}from"./loadAgentsDir-BL93ulMm.js";import{di as u,fi as d,ui as f}from"./src-P_wYS_NJ2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{D as m,E as h,q as g}from"./log-Dauqle-Z.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{F as y,K as b,M as x,N as S,P as C,_ as w,b as T,et as E,it as D,rt as O,s as k,tt as A,w as j}from"./model-Bgh_r4lg.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-BrKbpBK-.js";function I({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),r=s(e=>e.fastMode),i=c();function a(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${f.bold(n)}`,{display:`system`})}function o(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),i(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let a=`Set model to ${f.bold(H(n))}`,o;O()&&(b(),!D(n)&&r?(i(e=>({...e,fastMode:!1})),o=!1):D(n)&&A()&&r&&(a+=` · Fast mode ON`,o=!0)),N(n,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),e(a)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:o,onCancel:a,isStandaloneCommand:!0,showFastModeNotice:O()&&r&&D(t)&&A()})}function L({args:e,onDone:t}){let r=s(e=>e.fastMode),i=c(),a=e==="default"?null:e;return U.useEffect(()=>{async function e(){if(a&&!S(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&z(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&B(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){o(null);return}if(R(a)){o(a);return}try{let{valid:e,error:r}=await n(a);e?o(a):t(r||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function o(e){i(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let n=`Set model to ${f.bold(H(e))}`,a;O()&&(b(),!D(e)&&r?(i(e=>({...e,fastMode:!1})),a=!1):D(e)&&r&&(n+=` · Fast mode ON`,a=!0)),N(e,a===!0,T())&&(n+=` · Billed as extra usage`),a===!1&&(n+=` · Fast mode OFF`),t(n)}e()},[a,t,i]),null}function R(e){return C.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!i()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!r()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),r=H(t);return e(n?`Current model: ${f.bold(H(n))} (session override from plan mode)\nBase model: ${r}`:`Current model: ${r}`),null}function H(e){let t=j(e??k());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{u(),U=t(d(),1),M(),g(),_(),l(),F(),E(),y(),a(),w(),x(),o(),W=p(),G=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{onDone:e});if(h.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(v(`tengu_model_command_inline`,{args:n}),(0,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
@@ -1 +0,0 @@
1
- import{l as e,u as t}from"./oauth-C9VBDB0Y.js";t();export{e as getOauthConfig};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL?`-custom-oauth`:``}function n(){let e=u,t=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){let n=t.replace(/\/$/,``);if(!f.includes(n))throw Error(`CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.`);e={...e,BASE_API_URL:n,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_ORIGIN:n,TOKEN_URL:`${n}/v1/oauth/token`,API_KEY_URL:`${n}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${n}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,OAUTH_FILE_SUFFIX:`-custom-oauth`}}let n=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return n&&(e={...e,CLIENT_ID:n}),e}var r,i,a,o,s,c,l,u,d,f,p=e((()=>{r=`user:inference`,i=`user:profile`,a=`org:create_api_key`,o=`oauth-2025-04-20`,s=[a,i],c=[i,r,`user:sessions:claude_code`,`user:mcp_servers`,`user:file_upload`],l=Array.from(new Set([...s,...c])),u={BASE_API_URL:`https://api.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.claude.com/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude.com/cai/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude.ai`,TOKEN_URL:`https://platform.claude.com/v1/oauth/token`,API_KEY_URL:`https://api.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.claude.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`https://platform.claude.com/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`https://platform.claude.com/oauth/code/callback`,CLIENT_ID:`9d1c250a-e61b-44d9-88ed-5944d1962f5e`,OAUTH_FILE_SUFFIX:``,MCP_PROXY_URL:`https://mcp-proxy.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`},d=`https://claude.ai/oauth/claude-code-client-metadata`,f=[`https://beacon.claude-ai.staging.ant.dev`,`https://claude.fedstart.com`,`https://claude-staging.fedstart.com`]}));export{s as a,t as c,i,n as l,r as n,d as o,c as r,o as s,l as t,p as u};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{JE as r,YE as i,cE as a,nE as o,sE as s,tE as c}from"./loadAgentsDir-BL93ulMm.js";import{Ar as l,Ci as u,Dr as d,Er as f,Fr as p,Or as m,Pr as h,Si as g,bi as _,di as v,jr as y,kr as b,ui as x,xi as S}from"./state-BemZdQIl.js";import{$n as C,Er as w,Qn as T,Tr as E,Zn as D,er as O,nr as k,tr as A}from"./settings-D4CpDv2y.js";import{I as j,L as M}from"./config-aRiTrtCv.js";function N(e){return S(e)||v(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),x(),_(),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):g(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{u(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return T(O(e,void 0,R),e+``)}var V=e((()=>{z(),C(),D()}));function H(e,t){return t.length<2?e:f(e,s(t,0,-1))}var U=e((()=>{d(),a()}));function W(e,t){t=l(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=b(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[b(o(t))]}var G,K=e((()=>{y(),c(),U(),m(),G=Object.prototype.hasOwnProperty}));function q(e){return k(e)?void 0:e}var J=e((()=>{A()})),Y,X,Z,Q,$=e((()=>{p(),i(),K(),y(),w(),J(),V(),M(),Y=1,X=2,Z=4,Q=B(function(e,t){var n={};if(e==null)return n;var i=!1;t=h(t,function(t){return t=l(t,e),i||(i=t.length>1),t}),E(e,j(e),n),i&&(n=r(n,Y|X|Z,q));for(var a=t.length;a--;)W(n,t[a]);return n})}));export{Q as n,$ as t};
@@ -1 +0,0 @@
1
- import{i as e,r as t}from"./parser-BH4u7QiV.js";t();export{e as parseCommand};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{iE as t,rE as n}from"./loadAgentsDir-BL93ulMm.js";import{Cr as r,Sr as i,bi as a,xi as o}from"./state-BemZdQIl.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,t,r,i){return n(e,function(e,n,a){t(i,e,r(e),a)}),i}var u=e((()=>{t()}));function d(e,t){return function(n,r){var a=o(n)?s:l,c=t?t():{};return a(n,e,i(r,2),c)}}var f=e((()=>{c(),u(),r(),a()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
@@ -1,3 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{B as i,Ba as a,FT as o,G as s,GC as c,H as l,RT as u,Sg as d,V as f,W as p,ZC as ee,__ as te,ba as m,dd as ne,ed as h,fh as g,g_ as _,p_ as re,ph as ie,td as v,ud as y,wg as ae,xg as b,z as oe}from"./loadAgentsDir-BL93ulMm.js";import{I as x,P as S,Wt as se,Xn as ce,a as C,di as w,fi as T,hn as E,k as D,kt as O,n as k,o as A,ot as le,r as ue,s as de,t as j,ui as M,x as fe,y as N}from"./src-P_wYS_NJ2.js";import{t as P}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as pe,et as F}from"./state-BemZdQIl.js";import{C as I,x as me}from"./debug-BecbSVoN.js";import{H as L,V as R,g as he,ln as z,o as B,rn as V,z as H}from"./settings-D4CpDv2y.js";import{l as ge,o as _e}from"./stringUtils-C8PaYpQF.js";import{n as ve,t as ye}from"./useExitOnCtrlCDWithKeybindings-DEEJhm_W.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-ag2JTpmU.js";import{t as Se}from"./SearchBox-C9vUA4IM.js";import{n as Ce,t as we}from"./useSearchInput-gUDbkLaC.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-BzAZ57p2.js";import{n as U,t as De}from"./autoModeDenials-BxNzGJdR.js";function Oe({ruleValue:e}){switch(e.toolName){case g.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(S,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(S,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(S,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(S,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(S,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(S,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(S,{bold:!0,children:e.toolName}),` tool`]})}}var W,ke=e((()=>{T(),j(),ie(),W=P()}));function Ae(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${B(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${B(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.claude/settings.json`,value:e}}}function je({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:i,setToolPermissionContext:a}){let s=V.map(Ae),c=(0,Me.useCallback)(s=>{if(s===`cancel`){t();return}else if(V.includes(s)){let t=s,c=re(i,{type:`addRules`,rules:n,behavior:r,destination:t});te({type:`addRules`,rules:n,behavior:r,destination:t}),a(c);let l=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),u=Ee(c,{sandboxAutoAllowEnabled:o.isSandboxingEnabled()&&o.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(l,u.length>0?u:void 0)}},[e,t,n,r,i,a]);return(0,G.jsxs)(N,{title:`Add ${r} permission ${ge(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(x,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(x,{flexDirection:`column`,children:[(0,G.jsx)(S,{bold:!0,children:L(e)}),(0,G.jsx)(Oe,{ruleValue:e})]},L(e)))}),(0,G.jsxs)(x,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(S,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(h,{options:s,onChange:c})]})]})}var Me,G,Ne=e((()=>{T(),Me=t(T(),1),v(),j(),_(),H(),Te(),u(),z(),he(),_e(),ke(),G=P()}));function Pe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Fe.useState)(``),[o,s]=(0,Fe.useState)(0),c=ve();se(`confirm:no`,e,{context:`Settings`});let{columns:l}=le(),u=l-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(S,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(x,{flexDirection:`column`,children:[(0,K.jsxs)(S,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(O,{}),`e.g., `,(0,K.jsx)(S,{bold:!0,children:L({toolName:g.name})}),(0,K.jsx)(S,{bold:!1,children:` or `}),(0,K.jsx)(S,{bold:!0,children:L({toolName:g.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(x,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(y,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(R(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:u,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,K.jsx)(x,{marginLeft:3,children:c.pending?(0,K.jsxs)(S,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,K.jsx)(S,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Fe,K,Ie=e((()=>{n(),T(),Fe=t(T(),1),ne(),ye(),ee(),j(),c(),ie(),H(),K=P()}));function Le({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=C();(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(E((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)(S,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let p=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(S,{children:[(0,J.jsx)(de,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(S,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(x,{flexDirection:`column`,children:[(0,J.jsx)(S,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(x,{marginTop:1,children:(0,J.jsx)(h,{options:p,onChange:d,onFocus:f,visibleOptionCount:Math.min(10,p.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,Re=e((()=>{T(),q=t(T(),1),j(),U(),v(),J=P()}));function ze({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let a=(0,Be.useCallback)(()=>{i(re(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),o=(0,Be.useCallback)(e=>{e===`yes`?a():n()},[a,n]);return(0,Y.jsxs)(N,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(x,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(S,{bold:!0,children:e})}),(0,Y.jsx)(S,{children:`Claude Code will no longer have access to files in this directory.`}),(0,Y.jsx)(h,{onChange:o,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Be,Y,Ve=e((()=>{T(),Be=t(T(),1),v(),j(),_(),Y=P()}));function He({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=C();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=Ue.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&&t.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=Ue.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)(x,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(x,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(S,{children:`- ${F()}`}),(0,Z.jsx)(S,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(h,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var Ue,X,Z,We=e((()=>{n(),Ue=t(T(),1),X=t(T(),1),pe(),v(),j(),Z=P()}));function Ge({rule:e}){return(0,$.jsx)(S,{dimColor:!0,children:`From ${s(e.source)}`})}function Ke(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function qe({rule:e,onDelete:t,onCancel:n}){let r=ve();se(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(x,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(S,{bold:!0,children:L(e.ruleValue)}),(0,$.jsx)(Oe,{ruleValue:e.ruleValue}),(0,$.jsx)(Ge,{rule:e})]}),a=(0,$.jsx)(x,{marginLeft:3,children:r.pending?(0,$.jsxs)(S,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(S,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(S,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(S,{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)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(S,{bold:!0,color:`error`,children:[`Delete `,Ke(e.ruleBehavior),` tool?`]}),i,(0,$.jsx)(S,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(h,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),a]})}function Je(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:i,onSelect:a,onCancel:o,lastFocusedRuleKey:s,cursorOffset:c,onHeaderFocusChange:l}=e,u=A(),{headerFocused:d,focusHeader:f,blurHeader:p}=C();return(0,Q.useEffect)(()=>{r&&d&&p()},[r,d,p]),(0,Q.useEffect)(()=>{l?.(d)},[d,l]),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(x,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(D,{query:n,isFocused:r&&!d,isTerminalFocused:i,width:u,cursorOffset:c})}),(0,$.jsx)(h,{options:t,onChange:a,onCancel:o,visibleOptionCount:Math.min(10,t.length),isDisabled:r||d,defaultFocusValue:s,onUpFromFirstItem:f})]})}function Ye({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(x,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(S,{children:{allow:`Claude Code won't ask before using allowed tools.`,ask:`Claude Code will always ask for confirmation before using these tools.`,deny:`Claude Code will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Je,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Xe({onExit:e,initialTab:t,onRetryDenials:n}){let a=De().length>0,o=t??(a?`recent`:`allow`),[s,c]=(0,Q.useState)([]),u=d(e=>e.toolPermissionContext),p=ae(),ee=ce(),m=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),ne=(0,Q.useCallback)(e=>{m.current=e},[]),[h,g]=(0,Q.useState)(),[_,ie]=(0,Q.useState)(),[v,y]=(0,Q.useState)(null),[b,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,A]=(0,Q.useState)(!1),[le,de]=(0,Q.useState)(!0),j=(0,Q.useCallback)(e=>{de(e)},[]),N=(0,Q.useMemo)(()=>{let e=new Map;return i(u).forEach(t=>{e.set(I(t),t)}),e},[u]),P=(0,Q.useMemo)(()=>{let e=new Map;return l(u).forEach(t=>{e.set(I(t),t)}),e},[u]),pe=(0,Q.useMemo)(()=>{let e=new Map;return f(u).forEach(t=>{e.set(I(t),t)}),e},[u]),F=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return N;case`deny`:return P;case`ask`:return pe;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=L(r.ruleValue).toLowerCase(),t=L(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=L(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[N,P,pe]),me=ve(),R=!h&&!v&&!b&&!w&&!E,{query:he,setQuery:z,cursorOffset:B}=Ce({isActive:R&&O,onExit:()=>{A(!1)}}),V=(0,Q.useCallback)(e=>{R&&(O||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),A(!0),z(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),A(!0),z(e.key))))},[R,O,z]),H=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=F(t);if(e===`add-new-rule`){y(t);return}else{g(n.get(e));return}},[F]),ge=(0,Q.useCallback)(()=>{y(null)},[]),_e=(0,Q.useCallback)((e,t)=>{C({ruleValue:e,ruleBehavior:t}),y(null)},[]),ye=(0,Q.useCallback)((e,t)=>{C(null);for(let t of e)c(e=>[...e,`Added ${t.ruleBehavior} rule ${M.bold(L(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;c(n=>[...n,M.yellow(`${r.warning} Warning: ${L(e.rule.ruleValue)} is ${t}`),M.dim(` ${e.reason}`),M.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{C(null)},[]),Se=(0,Q.useCallback)(()=>T(!0),[]),we=(0,Q.useCallback)(e=>D(e),[]),Te=(0,Q.useCallback)(()=>{let t=m.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=>M.bold(e.display)).join(`, `)}`]:[],...s].join(`
3
- `)):e(`Permissions dialog dismissed`,{display:`system`})},[s,e,n]);se(`confirm:no`,Te,{context:`Settings`,isActive:R&&!O});let Ee=()=>{if(!h)return;let{options:e}=F(h.ruleBehavior),t=I(h),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),oe({rule:h,initialContext:u,setToolPermissionContext(e){p(t=>({...t,toolPermissionContext:e}))}}),c(e=>[...e,`Deleted ${h.ruleBehavior} rule ${M.bold(L(h.ruleValue))}`]),g(void 0)};if(h)return(0,$.jsx)(qe,{rule:h,onDelete:Ee,onCancel:()=>g(void 0)});if(v&&v!==`workspace`&&v!==`recent`)return(0,$.jsx)(Pe,{onCancel:ge,onSubmit:_e,ruleBehavior:v});if(b)return(0,$.jsx)(je,{onAddRules:ye,onCancel:be,ruleValues:[b.ruleValue],ruleBehavior:b.ruleBehavior,initialContext:u,setToolPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});if(w)return(0,$.jsx)(xe,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=re(u,n);p(e=>({...e,toolPermissionContext:r})),t&&te(n),c(n=>[...n,`Added directory ${M.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),T(!1)},onCancel:()=>T(!1),permissionContext:u});if(E)return(0,$.jsx)(ze,{directoryPath:E,onRemove:()=>{c(e=>[...e,`Removed directory ${M.bold(E)} from workspace`]),D(null)},onCancel:()=>D(null),permissionContext:u,setPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:he,isSearchMode:O,isFocused:ee,onCancel:Te,lastFocusedRuleKey:_,cursorOffset:B,getRulesOptions:F,handleToolSelect:H,onHeaderFocusChange:j};return(0,$.jsx)(x,{flexDirection:`column`,onKeyDown:V,children:(0,$.jsxs)(fe,{color:`permission`,children:[(0,$.jsxs)(ue,{title:`Permissions:`,color:`permission`,defaultTab:o,hidden:!!h||!!v||!!b||w||!!E,initialHeaderFocused:!a,navFromContent:!O,children:[(0,$.jsx)(k,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Le,{onHeaderFocusChange:j,onStateChange:ne})}),(0,$.jsx)(k,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Ye,{tab:`allow`,...U})}),(0,$.jsx)(k,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Ye,{tab:`ask`,...U})}),(0,$.jsx)(k,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Ye,{tab:`deny`,...U})}),(0,$.jsx)(k,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(S,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(He,{onExit:e,toolPermissionContext:u,onRequestAddDirectory:Se,onRequestRemoveDirectory:we,onHeaderFocusChange:j})]})})]}),(0,$.jsx)(x,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(S,{dimColor:!0,children:me.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,me.keyName,` again to exit`]}):le?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):O?(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,$,Ze=e((()=>{w(),n(),T(),Q=t(T(),1),b(),_(),v(),ye(),we(),j(),c(),U(),H(),p(),me(),Se(),Ne(),be(),ke(),Ie(),Re(),Ve(),We(),$=P()})),Qe,$e;e((()=>{Ze(),a(),Qe=P(),$e=async(e,t)=>(0,Qe.jsx)(Xe,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,m(e)])}})}))();export{$e as call};
@@ -1,17 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-BDhHQY0-.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$o as o,$x as s,AS as c,Ao as l,Bo as u,CS as d,DS as f,Do as p,ES as m,FS as h,Fg as g,Fp as _,GC as v,Go as y,IS as b,Ig as ee,Io as te,Iu as x,Jo as S,Kw as ne,MS as C,NS as w,No as T,OS as E,Oo as re,PS as D,Pp as O,Pu as k,Qo as ie,SS as A,Sg as j,Uo as M,Xw as ae,Xx as oe,Yw as se,ZC as N,Zo as ce,_o as P,aT as le,as as ue,cs as de,dT as fe,dd as pe,do as F,es as me,fo as he,gT as ge,hT as _e,jS as ve,kS as ye,lT as be,ns as xe,qo as Se,rs as Ce,ss as we,ts as I,ud as Te,vT as Ee,vo as De,wg as Oe,wo as ke,xg as Ae,yT as je,zo as Me}from"./loadAgentsDir-BL93ulMm.js";import{D as Ne,Gr as Pe,Gt as L,H as Fe,I as R,P as z,T as B,Wt as Ie,Xn as Le,fi as V,hn as Re,j as ze,k as Be,n as Ve,ot as He,r as Ue,t as We,x as Ge,y as Ke}from"./src-P_wYS_NJ2.js";import{t as qe}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Je,R as Ye,S as Xe,U as Ze,c as Qe,i as $e,x as et}from"./debug-BecbSVoN.js";import{Ln as tt,Rn as nt,c as rt,f as it,g as at,vt as ot,x as st,xt as ct}from"./settings-D4CpDv2y.js";import{b as lt,h as ut}from"./config-aRiTrtCv.js";import{o as dt,s as ft}from"./log-Dauqle-Z.js";import{n as pt,r as mt}from"./analytics-DJobLaWP.js";import{C as ht,y as gt}from"./startupProfiler-CmH_aVy2.js";import{l as H,o as _t}from"./stringUtils-C8PaYpQF.js";import{n as vt,t as yt}from"./pluginStartupCheck-CKBFaMFr.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-DnhzFbYI.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-y_O_tCEL.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-DcJ_FQuv.js";import{i as zt,n as Bt}from"./MCPConnectionManager-B9n4SXN4.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-DEEJhm_W.js";import{t as Ut}from"./SearchBox-C9vUA4IM.js";import{n as Wt,t as Gt}from"./useSearchInput-gUDbkLaC.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-DJ06N1DG.js";import{i as en,n as tn}from"./pluginAutoupdate-BBU9Jn4p.js";import*as nn from"path";import*as rn from"fs/promises";function an({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:o,setResult:s,setViewState:c,onAddComplete:l,cliMode:u=!1}){let d=(0,on.useRef)(!1),[f,p]=(0,on.useState)(!1),[m,h]=(0,on.useState)(``),g=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ot(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{p(!0),h(``);let{name:e,resolvedSource:t}=await T(n,e=>{h(e)});Se(e,{source:t}),we();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),l&&await l(),h(``),p(!1),u?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),h(``),p(!1),s(u?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!d.current&&!i&&!o&&(d.current=!0,g())},[]),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsxs)(R,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(R,{marginBottom:1,children:(0,U.jsx)(z,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(R,{flexDirection:`column`,children:[(0,U.jsx)(z,{children:`Enter marketplace source:`}),(0,U.jsx)(z,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(z,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(z,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(z,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(z,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(Te,{value:e,onChange:t,onSubmit:g,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),f&&(0,U.jsxs)(R,{marginTop:1,children:[(0,U.jsx)(k,{}),(0,U.jsx)(z,{children:m||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{color:`error`,children:i})}),o&&(0,U.jsx)(R,{marginTop:1,children:(0,U.jsx)(z,{children:o})})]}),(0,U.jsx)(R,{marginLeft:3,children:(0,U.jsx)(z,{dimColor:!0,italic:!0,children:(0,U.jsxs)(B,{children:[(0,U.jsx)(Ne,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(O,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{V(),on=t(V(),1),pt(),_(),We(),x(),pe(),Ye(),dt(),de(),Me(),At(),U=qe()}));function cn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Ie(`confirm:no`,o,{context:`Settings`}),L({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Re((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let _=g.sensitive===!0,v=g.required===!0,y=_?`*`.repeat(Pe(p)):p;return(0,dn.jsxs)(Ke,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{bold:!0,children:[g.title||h,v&&(0,dn.jsx)(z,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(z,{dimColor:!0,children:g.description}),(0,dn.jsxs)(R,{marginTop:1,children:[(0,dn.jsxs)(z,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(z,{children:y}),(0,dn.jsx)(z,{children:`█`})]})]}),(0,dn.jsxs)(R,{flexDirection:`column`,children:[(0,dn.jsxs)(z,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(z,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(V(),1),We(),v(),r(),dn=qe()}));async function pn(e){let{enabled:t,disabled:n}=await he();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=m(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>E(t),save:n=>ye(t,n,e.manifest.userConfig)});let i=A(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>C(t,r.server)??void 0,save:e=>D(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),o=hn.useRef(n);if(o.current=n,hn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function c(e){try{s.save(e)}catch(e){n(`error`,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:c,onCancel:()=>n(`skipped`)},s.key)}var hn,gn,_n=e((()=>{hn=t(V(),1),Ye(),c(),d(),F(),f(),fn(),gn=qe()}));function vn(){let e=xe();return(0,yn.jsxs)(R,{marginBottom:1,children:[(0,yn.jsxs)(z,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(z,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var yn,bn=e((()=>{i(),V(),We(),Ce(),yn=qe()}));function xn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function Sn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Cn({hasSelection:e}){return(0,wn.jsx)(R,{marginTop:1,children:(0,wn.jsx)(z,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(B,{children:[e&&(0,wn.jsx)(O,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(O,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{V(),_(),We(),wn=qe()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var Dn,On,kn=e((()=>{Dn=t(V(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:s,targetMarketplace:c,targetPlugin:l}){let[d,f]=(0,W.useState)(`marketplace-list`),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)([]),[x,S]=(0,W.useState)([]),[ne,C]=(0,W.useState)(!0),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(0),[k,ie]=(0,W.useState)(new Set),[A,j]=(0,W.useState)(new Set),M=En({totalItems:x.length,selectedIndex:E}),[ae,oe]=(0,W.useState)(0),[se,N]=(0,W.useState)(!1),[P,le]=(0,W.useState)(null),[de,fe]=(0,W.useState)(null);Ie(`confirm:no`,jn.useCallback(()=>{d===`plugin-list`?c?i({type:`manage-marketplaces`,targetMarketplace:c}):v.length===1?i({type:`menu`}):(f(`marketplace-list`),h(null),ie(new Set)):d===`plugin-details`?(f(`plugin-list`),_(null)):i({type:`menu`})},[d,c,i,v.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await u(),{marketplaces:n,failures:r}=await ue(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>re(ce(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:I(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),y(i);let a=me(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)fe(a.message+`. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!c&&!l){let e=i[0];e&&(h(e.name),f(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await te(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=ce(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:p(e)},r=t;break}}}if(n&&r){let e=n.pluginId;p(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(h(r),_(n),f(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else c&&(i.some(e=>e.name===c)?(h(c),f(`plugin-list`)):t(`Marketplace "${c}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{C(!1)}}e()},[t,c,l]),(0,W.useEffect)(()=>{if(!m)return;let e=!1;async function n(n){C(!0);try{let t=await te(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=ce(e.name,n);ee(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:p(t)})}try{let t=await Nt();if(e)return;T(t),t?r.sort((e,n)=>{let r=t.get(e.pluginId)??0,i=t.get(n.pluginId)??0;return r===i?e.entry.name.localeCompare(n.entry.name):i-r}):r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(t){if(e)return;Qe(`Failed to fetch install counts: ${Je(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}S(r),D(0),ie(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{C(!1)}}return n(m),()=>{e=!0}},[m,t]);let pe=async()=>{if(k.size===0)return;let e=x.filter(e=>k.has(e.pluginId));j(new Set(e.map(e=>e.pluginId)));let n=0,a=0,c=[];for(let t of e){let e=await De({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,c.push({name:t.entry.name,reason:e.error}))}j(new Set),ie(new Set),we(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${o(c,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${o(c,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&s&&await s(),i({type:`menu`})},F=async(e,t=`user`)=>{N(!0),le(null);let n=await De({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){N(!1),f({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),s&&await s(),i({type:`menu`})}else N(!1),le(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),L({"select:previous":()=>{E>0&&D(E-1)},"select:next":()=>{E<v.length-1&&D(E+1)},"select:accept":()=>{let e=v[E];e&&(h(e.name),f(`plugin-list`))}},{context:`Select`,isActive:d===`marketplace-list`}),L({"select:previous":()=>{E>0&&M.handleSelectionChange(E-1,D)},"select:next":()=>{E<x.length-1&&M.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===x.length&&k.size>0)pe();else if(E<x.length){let e=x[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(_(e),f(`plugin-details`),oe(0),le(null)))}}},{context:`Select`,isActive:d===`plugin-list`}),L({"plugin:toggle":()=>{if(E<x.length){let e=x[E];if(e&&!e.isInstalled){let t=new Set(k);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ie(t)}}},"plugin:install":()=>{k.size>0&&pe()}},{context:`Plugin`,isActive:d===`plugin-list`});let he=jn.useMemo(()=>{if(!g)return[];let e=g.entry.homepage;return Sn(e,xn(g))},[g]);if(L({"select:previous":()=>{ae>0&&oe(ae-1)},"select:next":()=>{ae<he.length-1&&oe(ae+1)},"select:accept":()=>{if(!g)return;let e=he[ae]?.action,t=g.entry.homepage,n=xn(g);e===`install-user`?F(g,`user`):e===`install-project`?F(g,`project`):e===`install-local`?F(g,`local`):e===`homepage`&&t?b(t):e===`github`&&n?b(`https://github.com/${n}`):e===`back`&&(f(`plugin-list`),_(null))}},{context:`Select`,isActive:d===`plugin-details`&&!!g}),typeof d==`object`&&d.type===`plugin-options`){let{plugin:e,pluginId:t}=d;function n(e){r(e),s&&s(),i({type:`menu`})}return(0,G.jsx)(mn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ne)return(0,G.jsx)(z,{children:`Loading…`});if(e)return(0,G.jsx)(z,{color:`error`,children:e});if(d===`marketplace-list`)return v.length===0?(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(z,{children:`No marketplaces configured.`}),(0,G.jsxs)(z,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Select marketplace`})}),de&&(0,G.jsx)(R,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(z,{color:`warning`,children:[a.warning,` `,de]})}),v.map((e,t)=>(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:+(t<v.length-1),children:[(0,G.jsx)(R,{children:(0,G.jsxs)(z,{color:E===t?`suggestion`:void 0,children:[E===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(R,{marginLeft:2,children:(0,G.jsxs)(z,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(d===`plugin-details`&&g){let e=g.entry.homepage,t=Sn(e,xn(g));return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:g.entry.name}),g.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[`Version: `,g.entry.version]}),g.entry.description&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{children:g.entry.description})}),g.entry.author&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof g.entry.author==`string`?g.entry.author:g.entry.author.name]})})]}),(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(z,{bold:!0,children:`Will install:`}),g.entry.commands&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(g.entry.commands)?g.entry.commands.join(`, `):Object.keys(g.entry.commands).join(`, `)]}),g.entry.agents&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(g.entry.agents)?g.entry.agents.join(`, `):Object.keys(g.entry.agents).join(`, `)]}),g.entry.hooks&&(0,G.jsxs)(z,{dimColor:!0,children:[`· Hooks: `,Object.keys(g.entry.hooks).join(`, `)]}),g.entry.mcpServers&&(0,G.jsxs)(z,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(g.entry.mcpServers)?g.entry.mcpServers.join(`, `):typeof g.entry.mcpServers==`object`?Object.keys(g.entry.mcpServers).join(`, `):`configured`]}),!g.entry.commands&&!g.entry.agents&&!g.entry.hooks&&!g.entry.mcpServers&&(0,G.jsx)(G.Fragment,{children:typeof g.entry.source==`object`&&`source`in g.entry.source&&(g.entry.source.source===`github`||g.entry.source.source===`url`||g.entry.source.source===`npm`||g.entry.source.source===`pip`)?(0,G.jsx)(z,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(z,{dimColor:!0,children:`· Components will be discovered at installation`})})]}),(0,G.jsx)(vn,{}),P&&(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsxs)(z,{color:`error`,children:[`Error: `,P]})}),(0,G.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(R,{children:[ae===t&&(0,G.jsx)(z,{children:`> `}),ae!==t&&(0,G.jsx)(z,{children:` `}),(0,G.jsx)(z,{bold:ae===t,children:se&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(R,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(z,{dimColor:!0,children:(0,G.jsxs)(B,{children:[(0,G.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(x.length===0)return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(z,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(z,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(R,{marginLeft:3,children:(0,G.jsx)(z,{dimColor:!0,italic:!0,children:(0,G.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let ge=M.getVisibleItems(x);return(0,G.jsxs)(R,{flexDirection:`column`,children:[(0,G.jsx)(R,{marginBottom:1,children:(0,G.jsx)(z,{bold:!0,children:`Install Plugins`})}),M.scrollPosition.canScrollUp&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),ge.map((t,n)=>{let r=M.toActualIndex(n),i=E===r,o=k.has(t.pluginId),s=A.has(t.pluginId);return(0,G.jsxs)(R,{flexDirection:`column`,marginBottom:n===ge.length-1&&!e?0:1,children:[(0,G.jsxs)(R,{children:[(0,G.jsxs)(z,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(z,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(z,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(z,{dimColor:!0,children:` (installed)`}),w&&m===`claude-plugins-official`&&(0,G.jsxs)(z,{dimColor:!0,children:[` · `,Mt(w.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(R,{marginLeft:4,children:[(0,G.jsx)(z,{dimColor:!0,children:ht(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(z,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),M.scrollPosition.canScrollDown&&(0,G.jsx)(R,{children:(0,G.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(R,{marginTop:1,children:(0,G.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:k.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(V(),1),W=t(V(),1),_(),We(),v(),nt(),h(),$e(),Ye(),de(),kt(),ke(),Ce(),Me(),le(),P(),g(),_t(),gt(),_n(),bn(),Tn(),kn(),G=qe()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:s,onSearchModeChange:c,targetPlugin:l}){let[d,f]=(0,K.useState)(`plugin-list`),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)([]),[v,y]=(0,K.useState)(!0),[te,x]=(0,K.useState)(null),[S,ne]=(0,K.useState)(!1),C=(0,K.useCallback)(e=>{ne(e),c?.(e)},[c]),{query:w,setQuery:T,cursorOffset:E}=Wt({isActive:d===`plugin-list`&&S&&!v,onExit:()=>{C(!1)}}),re=Le(),{columns:D}=He(),k=(0,K.useMemo)(()=>{if(!w)return g;let e=w.toLowerCase();return g.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[g,w]),[A,j]=(0,K.useState)(0),[M,ae]=(0,K.useState)(new Set),[oe,se]=(0,K.useState)(new Set),N=En({totalItems:k.length,selectedIndex:A});(0,K.useEffect)(()=>{j(0)},[w]);let[P,le]=(0,K.useState)(0),[de,fe]=(0,K.useState)(!1),[pe,F]=(0,K.useState)(null),[he,ge]=(0,K.useState)(null),[_e,ve]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await u(),{marketplaces:n,failures:r}=await ue(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=ce(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:p(t)})}let a=i.filter(e=>!e.isInstalled&&!ee(e.pluginId));try{let e=await Nt();x(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))}_(a);let o=Object.keys(e).length;if(a.length===0){let e=await ie({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ve(e)}let s=me(r,tt(n,e=>e.data!==null));if(s)if(s.type===`warning`)ge(s.message+`. Showing available plugins.`);else throw Error(s.message);if(l){let e=i.find(e=>e.entry.name===l);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(h(e),f(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{y(!1)}}e()},[t,l]);let ye=async()=>{if(M.size===0)return;let e=g.filter(e=>M.has(e.pluginId));se(new Set(e.map(e=>e.pluginId)));let n=0,a=0,c=[];for(let t of e){let e=await De({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,c.push({name:t.entry.name,reason:e.error}))}se(new Set),ae(new Set),we(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${o(c,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${o(c,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&s&&await s(),i({type:`menu`})},be=async(e,t=`user`)=>{fe(!0),F(null);let n=await De({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){fe(!1),f({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),s&&await s(),i({type:`menu`})}else fe(!1),F(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Ie(`confirm:no`,()=>{f(`plugin-list`),h(null)},{context:`Confirmation`,isActive:d===`plugin-details`}),Ie(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:d===`plugin-list`&&!S}),Re((e,t)=>{let n=!t.ctrl&&!t.meta;S||(e===`/`&&n?(C(!0),T(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(C(!0),T(e)))},{isActive:d===`plugin-list`&&!v}),L({"select:previous":()=>{A===0?C(!0):N.handleSelectionChange(A-1,j)},"select:next":()=>{A<k.length-1&&N.handleSelectionChange(A+1,j)},"select:accept":()=>{if(A===k.length&&M.size>0)ye();else if(A<k.length){let e=k[A];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(h(e),f(`plugin-details`),le(0),F(null)))}}},{context:`Select`,isActive:d===`plugin-list`&&!S}),L({"plugin:toggle":()=>{if(A<k.length){let e=k[A];if(e&&!e.isInstalled){let t=new Set(M);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ae(t)}}},"plugin:install":()=>{M.size>0&&ye()}},{context:`Plugin`,isActive:d===`plugin-list`&&!S});let xe=In.useMemo(()=>{if(!m)return[];let e=m.entry.homepage;return Sn(e,xn(m))},[m]);if(L({"select:previous":()=>{P>0&&le(P-1)},"select:next":()=>{P<xe.length-1&&le(P+1)},"select:accept":()=>{if(!m)return;let e=xe[P]?.action,t=m.entry.homepage,n=xn(m);e===`install-user`?be(m,`user`):e===`install-project`?be(m,`project`):e===`install-local`?be(m,`local`):e===`homepage`&&t?b(t):e===`github`&&n?b(`https://github.com/${n}`):e===`back`&&(f(`plugin-list`),h(null))}},{context:`Select`,isActive:d===`plugin-details`&&!!m}),typeof d==`object`&&d.type===`plugin-options`){let{plugin:e,pluginId:t}=d;function n(e){r(e),s&&s(),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(v)return(0,q.jsx)(z,{children:`Loading…`});if(e)return(0,q.jsx)(z,{color:`error`,children:e});if(d===`plugin-details`&&m){let e=m.entry.homepage,t=Sn(e,xn(m));return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(z,{bold:!0,children:m.entry.name}),(0,q.jsxs)(z,{dimColor:!0,children:[`from `,m.marketplaceName]}),m.entry.version&&(0,q.jsxs)(z,{dimColor:!0,children:[`Version: `,m.entry.version]}),m.entry.description&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{children:m.entry.description})}),m.entry.author&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`By:`,` `,typeof m.entry.author==`string`?m.entry.author:m.entry.author.name]})})]}),(0,q.jsx)(vn,{}),pe&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`error`,children:[`Error: `,pe]})}),(0,q.jsx)(R,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(R,{children:[P===t&&(0,q.jsx)(z,{children:`> `}),P!==t&&(0,q.jsx)(z,{children:` `}),(0,q.jsx)(z,{bold:P===t,children:de&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,children:(0,q.jsxs)(B,{children:[(0,q.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(g.length===0)return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(z,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:_e}),(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Se=N.getVisibleItems(k);return(0,q.jsxs)(R,{flexDirection:`column`,children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{bold:!0,children:`Discover plugins`}),N.needsPagination&&(0,q.jsxs)(z,{dimColor:!0,children:[` `,`(`,N.scrollPosition.current,`/`,N.scrollPosition.total,`)`]})]}),(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsx)(Be,{query:w,isFocused:S,isTerminalFocused:re,width:D-4,cursorOffset:E})}),he&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{color:`warning`,children:[a.warning,` `,he]})}),k.length===0&&w&&(0,q.jsx)(R,{marginBottom:1,children:(0,q.jsxs)(z,{dimColor:!0,children:[`No plugins match "`,w,`"`]})}),N.scrollPosition.canScrollUp&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Se.map((t,n)=>{let r=N.toActualIndex(n),i=A===r,o=M.has(t.pluginId),s=oe.has(t.pluginId);return(0,q.jsxs)(R,{flexDirection:`column`,marginBottom:n===Se.length-1&&!e?0:1,children:[(0,q.jsxs)(R,{children:[(0,q.jsxs)(z,{color:i&&!S?`suggestion`:void 0,children:[i&&!S?a.pointer:` `,` `]}),(0,q.jsxs)(z,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(z,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(z,{dimColor:!0,children:` [Community Managed]`}),te&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(z,{dimColor:!0,children:[` · `,Mt(te.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(R,{marginLeft:4,children:(0,q.jsx)(z,{dimColor:!0,children:ht(t.entry.description,60)})})]},`${N.startIndex}-${t.pluginId}`)}),N.scrollPosition.canScrollDown&&(0,q.jsx)(R,{children:(0,q.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(R,{marginTop:1,children:(0,q.jsxs)(z,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:M.size>0,canToggle:A<k.length&&!k[A]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(R,{marginTop:1,children:(0,q.jsx)(z,{dimColor:!0,italic:!0,children:(0,q.jsxs)(B,{children:[e&&(0,q.jsx)(O,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(z,{children:`type to search`}),t&&(0,q.jsx)(O,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(z,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(z,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(z,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(z,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(z,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(z,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(V(),1),K=t(V(),1),_(),Ut(),We(),Gt(),N(),v(),nt(),h(),$e(),Ye(),de(),kt(),ke(),Ce(),Me(),le(),P(),g(),_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,d]=(0,Bn.useState)([]),[f,p]=(0,Bn.useState)(!0),[m,h]=(0,Bn.useState)(0),[g,_]=(0,Bn.useState)(!1),[v,b]=(0,Bn.useState)(null),[ee,te]=(0,Bn.useState)(null),[x,ne]=(0,Bn.useState)(null),[C,w]=(0,Bn.useState)(`list`),[T,E]=(0,Bn.useState)(null),[re,D]=(0,Bn.useState)(0),k=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await u(),{enabled:r,disabled:i}=await he(),a=[...r,...i],{marketplaces:o,failures:l}=await ue(e),f=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));f.push({name:e,source:I(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}f.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(f);let p=me(l,tt(o,e=>e.data!==null));if(p)if(p.type===`warning`)b(p.message);else throw Error(p.message);if(s&&!k.current&&!t){k.current=!0;let e=f.findIndex(e=>e.name===s);if(e>=0){let t=f[e];if(c){h(e+1);let t=[...f];c===`update`?t[e].pendingUpdate=!0:c===`remove`&&(t[e].pendingRemove=!0),d(t),setTimeout(j,100,t)}else t&&(h(e+1),E(t),w(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),b(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{p(!1)}}e()},[s,c,t]);let ie=()=>l.some(e=>e.pendingUpdate||e.pendingRemove),A=()=>({updateCount:tt(l,e=>e.pendingUpdate),removeCount:tt(l,e=>e.pendingRemove)}),j=async t=>{let i=t||l,s=C===`details`;_(!0),b(null),te(null),ne(null);try{let t=rt(`userSettings`),n=0,c=0,l=new Set;for(let e of i){if(e.pendingRemove){if(e.installedPlugins&&e.installedPlugins.length>0){let n={...t?.enabledPlugins};for(let t of e.installedPlugins){let r=ce(t.name,e.name);n[r]=!1}st(`userSettings`,{enabledPlugins:n})}await y(e.name),c++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await M(e.name,e=>{ne(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),we(),o&&await o();let p=await u(),{enabled:m,disabled:h}=await he(),g=[...m,...h],{marketplaces:_}=await ue(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:I(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}if(v.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(v),s&&T){let e=v.find(e=>e.name===T.name);e&&E(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?te(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Je(e);b(t),n&&n(t)}finally{_(!1),ne(null)}},ae=async()=>{if(!T)return;let e=l.map(e=>e.name===T.name?{...e,pendingRemove:!0}:e);d(e),await j(e)},oe=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},se=async e=>{let t=!e.autoUpdate;try{await S(e.name,t),d(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),E(e=>e&&{...e,autoUpdate:t})}catch(e){b(e instanceof Error?e.message:`Failed to update setting`)}};if(Ie(`confirm:no`,()=>{w(`list`),D(0)},{context:`Confirmation`,isActive:!g&&(C===`details`||C===`confirm-remove`)}),Ie(`confirm:no`,()=>{d(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),h(0)},{context:`Confirmation`,isActive:!g&&C===`list`&&ie()}),Ie(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!g&&C===`list`&&!ie()}),L({"select:previous":()=>h(e=>Math.max(0,e-1)),"select:next":()=>{let e=l.length+1;h(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=m-1;if(m===0)e({type:`add-marketplace`});else if(ie())j();else{let e=l[t];e&&(E(e),w(`details`),D(0))}}},{context:`Select`,isActive:!g&&C===`list`}),Re(e=>{let t=m-1;if((e===`u`||e===`U`)&&t>=0)d(e=>e.map((e,n)=>n===t?{...e,pendingUpdate:!e.pendingUpdate,pendingRemove:e.pendingUpdate?e.pendingRemove:!1}:e));else if((e===`r`||e===`R`)&&t>=0){let e=l[t];e&&(E(e),w(`confirm-remove`))}},{isActive:!g&&C===`list`}),L({"select:previous":()=>D(e=>Math.max(0,e-1)),"select:next":()=>{let e=oe(T);D(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!T)return;let t=oe(T)[re];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:T.name});else if(t?.value===`update`){let e=l.map(e=>e.name===T.name?{...e,pendingUpdate:!0}:e);d(e),j(e)}else t?.value===`toggle-auto-update`?se(T):t?.value===`remove`&&w(`confirm-remove`)}},{context:`Select`,isActive:!g&&C===`details`}),Re(e=>{e===`y`||e===`Y`?ae():(e===`n`||e===`N`)&&(w(`list`),E(null))},{isActive:!g&&C===`confirm-remove`}),f)return(0,J.jsx)(z,{children:`Loading marketplaces…`});if(l.length===0)return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(z,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(B,{children:[(0,J.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(C===`confirm-remove`&&T){let e=T.installedPlugins?.length||0;return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsxs)(z,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(z,{italic:!0,children:T.name}),`?`]}),(0,J.jsxs)(R,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),T.installedPlugins&&T.installedPlugins.length>0&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,marginLeft:2,children:T.installedPlugins.map(e=>(0,J.jsxs)(z,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[`Press `,(0,J.jsx)(z,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(z,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(C===`details`&&T){let e=T.pendingUpdate||g,t=oe(T);return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{bold:!0,children:T.name}),(0,J.jsx)(z,{dimColor:!0,children:T.source}),(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{children:[T.pluginCount||0,` available `,H(T.pluginCount||0,`plugin`)]})}),T.installedPlugins&&T.installedPlugins.length>0&&(0,J.jsxs)(R,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(z,{bold:!0,children:[`Installed plugins (`,T.installedPlugins.length,`):`]}),(0,J.jsx)(R,{flexDirection:`column`,marginLeft:1,children:T.installedPlugins.map(e=>(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(z,{children:a.bullet}),(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{children:e.name}),(0,J.jsx)(z,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(z,{color:`claude`,children:`Updating marketplace…`}),x&&(0,J.jsx)(z,{dimColor:!0,children:x})]}),!e&&ee&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:ee})}),!e&&v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),!e&&(0,J.jsx)(R,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===re;return(0,J.jsxs)(R,{children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(z,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!lt()&&T.autoUpdate&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(R,{marginLeft:3,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(B,{children:[(0,J.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:N,removeCount:P}=A();return(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsx)(z,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:m===0?`suggestion`:void 0,children:[m===0?a.pointer:` `,` +`]}),(0,J.jsx)(z,{bold:!0,color:m===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(R,{flexDirection:`column`,children:l.map((e,t)=>{let n=t+1===m,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(z,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(R,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(z,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(z,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(z,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(z,{dimColor:!0,children:e.source}),(0,J.jsxs)(z,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),ie()&&(0,J.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(z,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(z,{dimColor:!0,children:`Enter to apply`})]}),N>0&&(0,J.jsxs)(z,{children:[`• Update `,N,` `,H(N,`marketplace`)]}),P>0&&(0,J.jsxs)(z,{color:`warning`,children:[`• Remove `,P,` `,H(P,`marketplace`)]})]}),g&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`claude`,children:`Processing changes…`})}),v&&(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{color:`error`,children:v})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:ie()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(R,{marginTop:1,children:(0,J.jsxs)(z,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(R,{marginTop:1,children:(0,J.jsx)(z,{dimColor:!0,italic:!0,children:(0,J.jsxs)(B,{children:[t&&(0,J.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(Ne,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(Ne,{shortcut:`r`,action:`remove`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),V(),Bn=t(V(),1),pt(),_(),We(),v(),nt(),ut(),Ye(),de(),Ce(),Me(),tn(),F(),ot(),at(),_t(),J=qe()}));function Hn(e){switch(e.type){case`path-not-found`:return`${e.component} path not found: ${e.path}`;case`git-auth-failed`:return`Git ${e.authType.toUpperCase()} authentication failed for ${e.gitUrl}`;case`git-timeout`:return`Git ${e.operation} timed out for ${e.gitUrl}`;case`network-error`:return`Network error accessing ${e.url}${e.details?`: ${e.details}`:``}`;case`manifest-parse-error`:return`Failed to parse manifest at ${e.manifestPath}: ${e.parseError}`;case`manifest-validation-error`:return`Invalid manifest at ${e.manifestPath}: ${e.validationErrors.join(`, `)}`;case`plugin-not-found`:return`Plugin "${e.pluginId}" not found in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return`Marketplace "${e.marketplace}" not found`;case`marketplace-load-failed`:return`Failed to load marketplace "${e.marketplace}": ${e.reason}`;case`mcp-config-invalid`:return`Invalid MCP server config for "${e.serverName}": ${e.validationError}`;case`mcp-server-suppressed-duplicate`:{let t=e.duplicateOf.startsWith(`plugin:`)?`server provided by plugin "${e.duplicateOf.split(`:`)[1]??`?`}"`:`already-configured "${e.duplicateOf}"`;return`MCP server "${e.serverName}" skipped — same command/URL as ${t}`}case`hook-load-failed`:return`Failed to load hooks from ${e.hookPath}: ${e.reason}`;case`component-load-failed`:return`Failed to load ${e.component} from ${e.path}: ${e.reason}`;case`mcpb-download-failed`:return`Failed to download MCPB from ${e.url}: ${e.reason}`;case`mcpb-extract-failed`:return`Failed to extract MCPB ${e.mcpbPath}: ${e.reason}`;case`mcpb-invalid-manifest`:return`MCPB manifest invalid at ${e.mcpbPath}: ${e.validationError}`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`Marketplace "${e.marketplace}" is blocked by enterprise policy`:`Marketplace "${e.marketplace}" is not in the allowed marketplace list`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Dependency "${e.dependency}" is disabled`:`Dependency "${e.dependency}" is not installed`;case`lsp-config-invalid`:return`Invalid LSP server config for "${e.serverName}": ${e.validationError}`;case`lsp-server-start-failed`:return`LSP server "${e.serverName}" failed to start: ${e.reason}`;case`lsp-server-crashed`:return e.signal?`LSP server "${e.serverName}" crashed with signal ${e.signal}`:`LSP server "${e.serverName}" crashed with exit code ${e.exitCode??`unknown`}`;case`lsp-request-timeout`:return`LSP server "${e.serverName}" timed out on ${e.method} after ${e.timeoutMs}ms`;case`lsp-request-failed`:return`LSP server "${e.serverName}" ${e.method} failed: ${e.error}`;case`plugin-cache-miss`:return`Plugin "${e.plugin}" not cached at ${e.installPath}`;case`generic-error`:return e.error}return Ee(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((()=>{je()}));function Gn({item:e,isSelected:t}){let[n]=Fe();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=ze(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=ze(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=ze(`success`,n)(a.tick),i=`enabled`):(r=ze(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=ze(`warning`,n)(a.warning);return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=ze(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(z,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=ze(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=ze(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=ze(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=ze(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=ze(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{dimColor:!t,children:`└ `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]}):(0,Y.jsxs)(R,{children:[(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(z,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(z,{dimColor:!t,children:[` `,(0,Y.jsx)(z,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(z,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(z,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),V(),We(),_t(),Y=qe()}));async function qn(e){try{return(await rn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>nn.basename(e.name,`.md`))}catch(t){return 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=_e(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 te(t)).plugins.find(t=>t.name===e.name);if(n){let t=[];e.commandsPath&&t.push(e.commandsPath),e.commandsPaths&&t.push(...e.commandsPaths);let i=[];for(let e of t)if(typeof e==`string`){let t=await qn(e);i.push(...t)}let a=[];e.agentsPath&&a.push(e.agentsPath),e.agentsPaths&&a.push(...e.agentsPaths);let o=[];for(let e of a)if(typeof e==`string`){let t=await qn(e);o.push(...t)}let s=[];e.skillsPath&&s.push(e.skillsPath),e.skillsPaths&&s.push(...e.skillsPaths);let c=[];for(let e of s)if(typeof e==`string`){let t=await Jn(e);c.push(...t)}let l=[];e.hooksConfig&&l.push(Object.keys(e.hooksConfig)),n.hooks&&l.push(n.hooks);let u=[];e.mcpServers&&u.push(Object.keys(e.mcpServers)),n.mcpServers&&u.push(n.mcpServers),r({commands:i.length>0?i:null,agents:o.length>0?o:null,skills:c.length>0?c:null,hooks:l.length>0?l:null,mcpServers:u.length>0?u:null})}else s(`Plugin ${e.name} not found in marketplace`)}catch(e){s(e instanceof Error?e.message:`Failed to load components`)}finally{a(!1)}}n()},[e.name,e.commandsPath,e.commandsPaths,e.agentsPath,e.agentsPaths,e.skillsPath,e.skillsPaths,e.hooksConfig,e.mcpServers,t]),i?null:o?(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Components:`}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(z,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(z,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(z,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Xn(e,t){let n=(await te(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!ee(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let c=j(e=>e.mcp.clients),u=j(e=>e.mcp.tools),d=j(e=>e.plugins.errors),f=It(),[p,m]=(0,X.useState)(!1),h=(0,X.useCallback)(e=>{m(e),r?.(e)},[r]),g=Le(),{columns:_}=He(),[v,y]=(0,X.useState)(`plugin-list`),{query:ee,setQuery:te,cursorOffset:x}=Wt({isActive:v===`plugin-list`&&p,onExit:()=>{h(!1)}}),[S,C]=(0,X.useState)(null),[T,re]=(0,X.useState)([]),[D,k]=(0,X.useState)([]),[ie,A]=(0,X.useState)(!0),[M,se]=(0,X.useState)(new Map),N=(0,X.useRef)(!1),ce=(0,X.useRef)(void 0),P=zt();Ie(`confirm:no`,$n.useCallback(()=>{if(v===`plugin-details`)y(`plugin-list`),C(null),I(null);else if(typeof v==`object`&&v.type===`failed-plugin-details`)y(`plugin-list`),I(null);else if(v===`configuring`)y(`plugin-details`),Ee(null);else if(typeof v==`object`&&(v.type===`plugin-options`||v.type===`configuring-options`))y(`plugin-list`),C(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof v==`object`&&v.type===`flagged-detail`)y(`plugin-list`),I(null);else if(typeof v==`object`&&v.type===`mcp-detail`)y(`plugin-list`),I(null);else if(typeof v==`object`&&v.type===`mcp-tools`)y({type:`mcp-detail`,client:v.client});else if(typeof v==`object`&&v.type===`mcp-tool-detail`)y({type:`mcp-tools`,client:v.client});else{if(M.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[v,e,M,t]),{context:`Confirmation`,isActive:(v!==`plugin-list`||!p)&&v!==`confirm-project-uninstall`&&!(typeof v==`object`&&v.type===`confirm-data-cleanup`)});let le=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,ue=(0,X.useMemo)(()=>{let e=it(),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:M.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of d){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=yt(),s=[];for(let[e,t]of a){if(e in f)continue;let n=fe(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:le(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],m=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;m.has(n)||m.set(n,[]),m.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;m.has(r)||m.set(r,[]),m.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:le(n),client:n,indented:!0})}}for(let e of l){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let e of s){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let[e,t]of Object.entries(f)){let n=fe(e),r=n.name||e,i=n.marketplace||`unknown`;m.has(`flagged`)||m.set(`flagged`,[]),m.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let h=[...m.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of h){let t=m.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)p.push(...e);p.push(...r)}return p},[D,c,d,M,f]),de=(0,X.useMemo)(()=>ue.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[ue]);(0,X.useEffect)(()=>{de.length>0&&Ft(de)},[de]);let pe=(0,X.useMemo)(()=>{if(!ee)return ue;let e=ee.toLowerCase();return ue.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[ue,ee]),[F,me]=(0,X.useState)(0),ge=En({totalItems:pe.length,selectedIndex:F,maxVisible:8}),[_e,be]=(0,X.useState)(0),[xe,Se]=(0,X.useState)(!1),[Ce,I]=(0,X.useState)(null),[Te,Ee]=(0,X.useState)(null),[De,Oe]=(0,X.useState)(!1),[ke,Ae]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!S){Ae(!1);return}async function e(){let e=S.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&ve(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&ve(e))),!t)try{let e=nn.join(S.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Xe(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===S.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&ve(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&ve(e))}}catch(e){Qe(`Failed to read raw marketplace.json: ${e}`)}Ae(t)}e()},[S]),(0,X.useEffect)(()=>{async function e(){A(!0);try{let{enabled:e,disabled:t}=await he(),n=it(),r=Zn([...e,...t]),i={};for(let e of r){let t=e.source.split(`@`)[1]||`local`;i[t]||(i[t]=[]),i[t].push(e)}let a=[];for(let[e,t]of Object.entries(i)){let r=tt(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),re(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})}k(o),me(0)}finally{A(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!N.current&&i&&T.length>0&&!ie){let{name:e,marketplace:n}=fe(i),r=o??n,a=r?T.filter(e=>e.name===r):T;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};C(r),y(`plugin-details`),ce.current=s,N.current=!0;return}}let c=ue.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(y({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),N.current=!0),!N.current&&s&&(N.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,T,ie,ue,s,t]);let je=async r=>{if(!S)return;let i=S.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){I(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){I(`This plugin is managed by your organization. Contact your admin to disable it.`);return}Se(!0),I(null);try{let o=`${S.plugin.name}@${S.marketplace}`,s;switch(r){case`enable`:{let e=await bt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await Ct(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!wt(i))break;if(Dt(o)){Se(!1),y(`confirm-project-uninstall`);return}let e=l().plugins[o],t=!e||e.length<=1?await ne(o):null;if(t){Se(!1),y({type:`confirm-data-cleanup`,size:t});return}let n=await xt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await St(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${S.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}we();let c=`${S.plugin.name}@${S.marketplace}`;if(it()?.enabledPlugins?.[c]!==!1){Se(!1),y({type:`plugin-options`});return}let u=r===`enable`?`Enabled`:r===`disable`?`Disabled`:r===`update`?`Updated`:`Uninstalled`,d=s&&s.length>0?` · required by ${s.join(`, `)}`:``;t(`✓ ${u} ${S.plugin.name}${d}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){Se(!1);let t=e instanceof Error?e.message:String(e);I(`Failed to ${r}: ${t}`),ft(Ze(e))}},Me=(0,X.useRef)(je);Me.current=je,(0,X.useEffect)(()=>{if(v===`plugin-details`&&S&&ce.current){let e=ce.current;ce.current=void 0,Me.current(e)}},[v,S]);let Ne=$n.useCallback(()=>{if(F>=pe.length)return;let e=pe[F];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=it(),r=M.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(M);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),we()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),we()}catch(e){ft(e)}})()),se(e)}}else e?.type===`mcp`&&P(e.client.name)},[F,pe,M,D,P]);L({"select:previous":()=>{F===0?h(!0):ge.handleSelectionChange(F-1,me)},"select:next":()=>{F<pe.length-1&&ge.handleSelectionChange(F+1,me)},"select:accept":$n.useCallback(()=>{if(F>=pe.length)return;let e=pe[F];if(e?.type===`plugin`){let t=D.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(C(t),y(`plugin-details`),be(0),I(null))}else e?.type===`flagged-plugin`?(y({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),I(null)):e?.type===`failed-plugin`?(y({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),be(0),I(null)):e?.type===`mcp`&&(y({type:`mcp-detail`,client:e.client}),I(null))},[F,pe,D])},{context:`Select`,isActive:v===`plugin-list`&&!p}),L({"plugin:toggle":Ne},{context:`Plugin`,isActive:v===`plugin-list`&&!p}),L({"select:accept":$n.useCallback(()=>{typeof v!=`object`||v.type!==`flagged-detail`||(Lt(v.plugin.id),y(`plugin-list`))},[v])},{context:`Select`,isActive:typeof v==`object`&&v.type===`flagged-detail`});let Pe=$n.useMemo(()=>{if(v!==`plugin-details`||!S)return[];let e=it(),t=`${S.plugin.name}@${S.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=S.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void je(n?`disable`:`enable`)}),r||(i.push({label:S.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(S.plugin.name,S.marketplace);if(e){I(e);return}let t=[...D],n=t.findIndex(e=>e.plugin.name===S.plugin.name&&e.marketplace===S.marketplace);n!==-1&&(t[n].pendingUpdate=!S.pendingUpdate,k(t),C({...S,pendingUpdate:!S.pendingUpdate}))}catch(e){I(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),ke&&i.push({label:`Configure`,action:async()=>{Oe(!0);try{let e=S.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&ve(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&ve(n)){t=n;break}}if(!t){I(`No MCPB file found in plugin`),Oe(!1);return}let n=`${S.plugin.name}@${S.marketplace}`,r=await w(t,S.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ee(r),y(`configuring`)):I(`Failed to load MCPB for configuration`)}catch(e){let t=Je(e);I(`Failed to load configuration: ${t}`)}finally{Oe(!1)}}}),S.plugin.manifest.userConfig&&Object.keys(S.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{y({type:`configuring-options`,schema:S.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void je(`update`)}),i.push({label:`Uninstall`,action:()=>void je(`uninstall`)})),S.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void b(S.plugin.manifest.homepage)}),S.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void b(S.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{y(`plugin-list`),C(null),I(null)}}),i},[v,S,ke,D]);if(L({"select:previous":()=>{_e>0&&be(_e-1)},"select:next":()=>{_e<Pe.length-1&&be(_e+1)},"select:accept":()=>{Pe[_e]&&Pe[_e].action()}},{context:`Select`,isActive:v===`plugin-details`&&!!S}),L({"select:accept":()=>{typeof v==`object`&&v.type===`failed-plugin-details`&&(async()=>{Se(!0),I(null);let e=v.plugin.id,t=v.plugin.scope,r=wt(t)?await xt(e,t,!1):await xt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=rt(t);n?.enabledPlugins?.[e]!==void 0&&(st(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}we()}i?(n&&await n(),Se(!1),y(`plugin-list`)):(Se(!1),I(r.message))})()}},{context:`Select`,isActive:typeof v==`object`&&v.type===`failed-plugin-details`&&v.plugin.scope!==`managed`}),L({"confirm:yes":()=>{if(!S)return;Se(!0),I(null);let r=`${S.plugin.name}@${S.marketplace}`,{error:i}=st(`localSettings`,{enabledPlugins:{...rt(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){Se(!1),I(`Failed to write settings: ${i.message}`);return}we(),t(`✓ Disabled ${S.plugin.name} in .claude/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{y(`plugin-details`),I(null)}},{context:`Confirmation`,isActive:v===`confirm-project-uninstall`&&!!S&&!xe}),Re((r,i)=>{if(!S)return;let o=`${S.plugin.name}@${S.marketplace}`,s=S.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{Se(!0),I(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);we();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){Se(!1),I(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(y(`plugin-details`),I(null))},{isActive:typeof v==`object`&&v.type===`confirm-data-cleanup`&&!!S&&!xe}),$n.useEffect(()=>{me(0)},[ee]),Re((e,t)=>{let n=!t.ctrl&&!t.meta;p||(e===`/`&&n?(h(!0),te(``),me(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(h(!0),te(e),me(0)))},{isActive:v===`plugin-list`}),ie)return(0,Z.jsx)(z,{children:`Loading installed plugins…`});if(ue.length===0)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(z,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Esc to go back`})})]});if(typeof v==`object`&&v.type===`plugin-options`&&S){let r=`${S.plugin.name}@${S.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:S.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${S.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${S.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof v==`object`&&v.type===`configuring-options`&&S){let e=`${S.plugin.name}@${S.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${S.plugin.name}`,subtitle:`Plugin options`,configSchema:v.schema,initialValues:E(e),onSave:n=>{try{ye(e,n,v.schema),we(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){I(`Failed to save configuration: ${Je(e)}`)}y(`plugin-details`)},onCancel:()=>y(`plugin-details`)})}if(v===`configuring`&&Te&&S){let e=`${S.plugin.name}@${S.marketplace}`;async function n(n){if(!(!Te||!S))try{let r=S.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&ve(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&ve(e)){i=e;break}}if(!i){I(`No MCPB file found`),y(`plugin-details`);return}await w(i,S.plugin.path,e,void 0,n),I(null),Ee(null),y(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Je(e);I(`Failed to save configuration: ${t}`),y(`plugin-details`)}}function r(){Ee(null),y(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${Te.manifest.name}`,subtitle:`Plugin: ${S.plugin.name}`,configSchema:Te.configSchema,initialValues:Te.existingConfig,onSave:n,onCancel:r})}if(typeof v==`object`&&v.type===`flagged-detail`){let e=v.plugin;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(R,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(z,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(z,{children:e.text}),(0,Z.jsxs)(z,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsxs)(z,{children:[a.pointer,` `]}),(0,Z.jsx)(z,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(v===`confirm-project-uninstall`&&S)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,color:`warning`,children:[S.plugin.name,` is enabled in .claude/settings.json (shared with your team)`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Disable it just for you in .claude/settings.local.json?`}),(0,Z.jsx)(z,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),Ce&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Ce})}),(0,Z.jsx)(R,{marginTop:1,children:xe?(0,Z.jsx)(z,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(O,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof v==`object`&&v.type===`confirm-data-cleanup`&&S)return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{bold:!0,children:[S.plugin.name,` has `,v.size.human,` of persistent data`]}),(0,Z.jsxs)(R,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(z,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(z,{dimColor:!0,children:ae(`${S.plugin.name}@${S.marketplace}`)})]}),Ce&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Ce})}),(0,Z.jsx)(R,{marginTop:1,children:xe?(0,Z.jsx)(z,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(z,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(z,{bold:!0,children:`esc`}),` to cancel`]})})]});if(v===`plugin-details`&&S){let e=it(),t=`${S.plugin.name}@${S.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===S.plugin.name||e.source===t||e.source.startsWith(`${S.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(R,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(z,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(R,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(z,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(z,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{bold:!0,children:[S.plugin.name,` @ `,S.marketplace]})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(z,{children:S.scope||`user`})]}),S.plugin.manifest.version&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(z,{children:S.plugin.manifest.version})]}),S.plugin.manifest.description&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(z,{children:S.plugin.manifest.description})}),S.plugin.manifest.author&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(z,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(z,{children:S.plugin.manifest.author.name})]}),(0,Z.jsxs)(R,{marginBottom:1,children:[(0,Z.jsx)(z,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(z,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),S.pendingUpdate&&(0,Z.jsx)(z,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:S.plugin,marketplace:S.marketplace}),i,(0,Z.jsx)(R,{marginTop:1,flexDirection:`column`,children:Pe.map((e,t)=>{let n=t===_e;return(0,Z.jsxs)(R,{children:[n&&(0,Z.jsxs)(z,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(z,{children:` `}),(0,Z.jsx)(z,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),xe&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{children:`Processing…`})}),Ce&&(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{color:`error`,children:Ce})}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(O,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof v==`object`&&v.type===`failed-plugin-details`){let e=v.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsxs)(z,{children:[(0,Z.jsx)(z,{bold:!0,children:e.name}),(0,Z.jsxs)(z,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(z,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(R,{marginTop:1,children:[(0,Z.jsxs)(z,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(z,{bold:!0,children:`Remove`})]}),xe&&(0,Z.jsx)(z,{children:`Processing…`}),Ce&&(0,Z.jsx)(z,{color:`error`,children:Ce}),(0,Z.jsx)(R,{marginTop:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[e.scope!==`managed`&&(0,Z.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof v==`object`&&v.type===`mcp-detail`){let e=v.client,n=oe(u,e.name).length,r=()=>{y({type:`mcp-tools`,client:e})},i=()=>{y(`plugin-list`)},a=e=>{e&&t(e),y(`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}):(y(`plugin-list`),null)}if(typeof v==`object`&&v.type===`mcp-tools`){let e=v.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=>{y({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>y({type:`mcp-detail`,client:e})})}if(typeof v==`object`&&v.type===`mcp-tool-detail`){let{client:e,tool:t}=v,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:()=>y({type:`mcp-tools`,client:e})})}let Fe=ge.getVisibleItems(pe);return(0,Z.jsxs)(R,{flexDirection:`column`,children:[(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsx)(Be,{query:ee,isFocused:p,isTerminalFocused:g,width:_-4,cursorOffset:x})}),pe.length===0&&ee&&(0,Z.jsx)(R,{marginBottom:1,children:(0,Z.jsxs)(z,{dimColor:!0,children:[`No items match "`,ee,`"`]})}),ge.scrollPosition.canScrollUp&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Fe.map((e,t)=>{let n=ge.toActualIndex(t)===F&&!p,r=t>0?Fe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(R,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(z,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Gn,{item:e,isSelected:n})]},e.id)}),ge.scrollPosition.canScrollDown&&(0,Z.jsx)(R,{children:(0,Z.jsxs)(z,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(R,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(B,{children:[(0,Z.jsx)(z,{children:`type to search`}),(0,Z.jsx)(O,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),M.size>0&&(0,Z.jsx)(R,{marginLeft:1,children:(0,Z.jsx)(z,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(V(),1),X=t(V(),1),_(),We(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),N(),v(),ge(),Bt(),s(),Et(),Ae(),nt(),h(),$e(),Ye(),dt(),de(),ke(),Me(),c(),se(),Rt(),be(),F(),f(),g(),vt(),at(),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)(R,{flexDirection:`column`,children:(0,ar.jsx)(z,{children:`Running validation...`})})}var ir,ar,or=e((()=>{i(),V(),ir=t(V(),1),We(),Ye(),dt(),Pt(),_t(),ar=qe()}));function sr({onComplete:e}){return(0,Q.useEffect)(()=>{async function t(){try{let t=await u(),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)(z,{children:`Loading marketplaces...`})}function cr(e){let t=[];for(let{source:n,scope:r}of[{source:`userSettings`,scope:`user`},{source:`projectSettings`,scope:`project`},{source:`localSettings`,scope:`local`}])rt(n)?.extraKnownMarketplaces?.[e]&&t.push({source:n,scope:r});return{editableSources:t,isInPolicy:!!rt(`policySettings`)?.extraKnownMarketplaces?.[e]}}function lr(e){let{editableSources:t,isInPolicy:n}=cr(e);return t.length>0?{kind:`remove-extra-marketplace`,name:e,sources:t}:n?{kind:`managed-only`,name:e}:{kind:`navigate`,tab:`marketplaces`,viewState:{type:`manage-marketplaces`,targetMarketplace:e,action:`remove`}}}function ur(e){return{kind:`navigate`,tab:`installed`,viewState:{type:`manage-plugins`,targetPlugin:e,action:`uninstall`}}}function dr(e){return yr.has(e.type)}function fr(e){if(`pluginId`in e&&e.pluginId)return e.pluginId;if(`plugin`in e&&e.plugin)return e.plugin;if(e.source.includes(`@`))return e.source.split(`@`)[0]}function pr(e,t,n,r,i,a,o){let s=[];for(let e of a){let t=`pluginId`in e?e.pluginId:`plugin`in e?e.plugin:void 0;s.push({label:t??e.source,message:Hn(e),guidance:`Restart to retry loading plugins`,action:{kind:`none`}})}let c=new Set;for(let t of e){c.add(t.name);let e=lr(t.name),n=cr(t.name),r=n.isInPolicy?`managed`:n.editableSources[0]?.scope;s.push({label:t.name,message:t.error??`Installation failed`,guidance:e.kind===`managed-only`?`Managed by your organization — contact your admin`:void 0,action:e,scope:r})}for(let e of t){let t=`marketplace`in e?e.marketplace:e.source;if(c.has(t))continue;c.add(t);let n=lr(t),r=cr(t),i=r.isInPolicy?`managed`:r.editableSources[0]?.scope;s.push({label:t,message:Hn(e),guidance:n.kind===`managed-only`?`Managed by your organization — contact your admin`:Un(e),action:n,scope:i})}for(let e of i)c.has(e.name)||(c.add(e.name),s.push({label:e.name,message:e.error,action:{kind:`remove-installed-marketplace`,name:e.name}}));let l=new Set;for(let e of n){let t=fr(e);if(t&&l.has(t))continue;t&&l.add(t);let n=`marketplace`in e?e.marketplace:void 0,r=t?o.get(e.source)??o.get(t):void 0;s.push({label:t?n?`${t} @ ${n}`:t:e.source,message:Hn(e),guidance:Un(e),action:t?ur(t):{kind:`none`},scope:r})}for(let e of r)s.push({label:e.source,message:Hn(e),guidance:Un(e),action:{kind:`none`}});return s}function mr(e,t){for(let{source:n}of t){let t=rt(n);if(!t)continue;let r={};if(t.extraKnownMarketplaces?.[e]&&(r.extraKnownMarketplaces={...t.extraKnownMarketplaces,[e]:void 0}),t.enabledPlugins){let n=`@${e}`,i=!1,a={...t.enabledPlugins};for(let e in a)e.endsWith(n)&&(a[e]=void 0,i=!0);i&&(r.enabledPlugins=a)}Object.keys(r).length>0&&st(n,r)}}function hr({setViewState:e,setActiveTab:t,markPluginsChanged:n}){let r=j(e=>e.plugins.errors),i=j(e=>e.plugins.installationStatus),o=Oe(),[s,c]=(0,Q.useState)(0),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{(async()=>{try{let{failures:e}=await ue(await u());p(e)}catch{}})()},[]);let m=i.marketplaces.filter(e=>e.status===`failed`),h=new Set(m.map(e=>e.name)),g=r.filter(dr),_=pr(m,r.filter(e=>(e.type===`marketplace-not-found`||e.type===`marketplace-load-failed`||e.type===`marketplace-blocked-by-policy`)&&!h.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,g,yt());Ie(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`}),L({"select:previous":()=>c(e=>Math.max(0,e-1)),"select:next":()=>c(e=>Math.min(_.length-1,e+1)),"select:accept":()=>{let r=_[s];if(!r)return;let{action:i}=r;switch(i.kind){case`navigate`:t(i.tab),e(i.viewState);break;case`remove-extra-marketplace`:{let e=i.sources.map(e=>e.scope).join(`, `);mr(i.name,i.sources),we(),o(e=>({...e,plugins:{...e.plugins,errors:e.plugins.errors.filter(e=>!(`marketplace`in e&&e.marketplace===i.name)),installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.filter(e=>e.name!==i.name)}}})),d(`${a.tick} Removed "${i.name}" from ${e} settings`),n();break}case`remove-installed-marketplace`:(async()=>{try{await y(i.name),we(),p(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:_.length>0});let v=Math.min(s,Math.max(0,_.length-1));v!==s&&c(v);let b=_[v]?.action,ee=b&&b.kind!==`none`&&b.kind!==`managed-only`;return _.length===0?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(R,{marginLeft:1,children:(0,$.jsx)(z,{dimColor:!0,children:`No plugin errors`})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})})]}):(0,$.jsxs)(R,{flexDirection:`column`,children:[_.map((e,t)=>{let n=t===v;return(0,$.jsxs)(R,{marginLeft:1,flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{color:n?`suggestion`:`error`,children:[n?a.pointer:a.cross,` `]}),(0,$.jsx)(z,{bold:n,children:e.label}),e.scope&&(0,$.jsxs)(z,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{color:`error`,children:e.message})}),e.guidance&&(0,$.jsx)(R,{marginLeft:3,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:e.guidance})})]},t)}),l&&(0,$.jsx)(R,{marginTop:1,marginLeft:1,children:(0,$.jsx)(z,{color:`claude`,children:l})}),(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(O,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),ee&&(0,$.jsx)(O,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`resolve`}),(0,$.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}function gr(e){switch(e.type){case`help`:return{type:`help`};case`validate`:return{type:`validate`,path:e.path};case`install`:return e.marketplace?{type:`browse-marketplace`,targetMarketplace:e.marketplace,targetPlugin:e.plugin}:e.plugin?{type:`discover-plugins`,targetPlugin:e.plugin}:{type:`discover-plugins`};case`manage`:return{type:`manage-plugins`};case`uninstall`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`uninstall`};case`enable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`enable`};case`disable`:return{type:`manage-plugins`,targetPlugin:e.plugin,action:`disable`};case`marketplace`:return e.action===`list`?{type:`marketplace-list`}:e.action===`add`?{type:`add-marketplace`,initialValue:e.target}:e.action===`remove`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`remove`}:e.action===`update`?{type:`manage-marketplaces`,targetMarketplace:e.target,action:`update`}:{type:`marketplace-menu`};default:return{type:`discover-plugins`}}}function _r(e){return e.type===`manage-plugins`?`installed`:e.type===`manage-marketplaces`?`marketplaces`:`discover`}function vr({onComplete:e,args:t}){let n=tr(t),r=gr(n),[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(_r(r)),[c,l]=(0,Q.useState)(i.type===`add-marketplace`&&i.initialValue||``),[u,d]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=Oe(),y=j(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`,ee=Vt(),te=n.type===`marketplace`&&n.action===`add`&&n.target!==void 0,x=(0,Q.useCallback)(()=>{v(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})},[v]),S=(0,Q.useCallback)(e=>{let t=e;switch(s(t),p(null),t){case`discover`:a({type:`discover-plugins`});break;case`installed`:a({type:`manage-plugins`});break;case`marketplaces`:a({type:`manage-marketplaces`});break;case`errors`:break}},[]);return(0,Q.useEffect)(()=>{i.type===`menu`&&!m&&e()},[i.type,m,e]),(0,Q.useEffect)(()=>{i.type===`browse-marketplace`&&o!==`discover`&&s(`discover`)},[i.type,o]),Ie(`confirm:no`,(0,Q.useCallback)(()=>{s(`marketplaces`),a({type:`manage-marketplaces`}),l(``),p(null)},[]),{context:`Settings`,isActive:i.type===`add-marketplace`}),(0,Q.useEffect)(()=>{m&&e(m)},[m,e]),(0,Q.useEffect)(()=>{i.type===`help`&&e()},[i.type,e]),i.type===`help`?(0,$.jsxs)(R,{flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:`Plugin Command Usage:`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Installation:`}),(0,$.jsx)(z,{children:` /plugin install - Browse and install plugins`}),(0,$.jsx)(z,{children:` /plugin install <marketplace> - Install from specific marketplace`}),(0,$.jsx)(z,{children:` /plugin install <plugin> - Install specific plugin`}),(0,$.jsx)(z,{children:` /plugin install <plugin>@<market> - Install plugin from marketplace`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Management:`}),(0,$.jsx)(z,{children:` /plugin manage - Manage installed plugins`}),(0,$.jsx)(z,{children:` /plugin enable <plugin> - Enable a plugin`}),(0,$.jsx)(z,{children:` /plugin disable <plugin> - Disable a plugin`}),(0,$.jsx)(z,{children:` /plugin uninstall <plugin> - Uninstall a plugin`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Marketplaces:`}),(0,$.jsx)(z,{children:` /plugin marketplace - Marketplace management menu`}),(0,$.jsx)(z,{children:` /plugin marketplace add - Add a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace add <path/url> - Add marketplace directly`}),(0,$.jsx)(z,{children:` /plugin marketplace update - Update marketplaces`}),(0,$.jsx)(z,{children:` /plugin marketplace update <name> - Update specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove - Remove a marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace remove <name> - Remove specific marketplace`}),(0,$.jsx)(z,{children:` /plugin marketplace list - List all marketplaces`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Validation:`}),(0,$.jsx)(z,{children:` /plugin validate <path> - Validate a manifest file or directory`}),(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{dimColor:!0,children:`Other:`}),(0,$.jsx)(z,{children:` /plugin - Main plugin menu`}),(0,$.jsx)(z,{children:` /plugin help - Show this help`}),(0,$.jsx)(z,{children:` /plugins - Alias for /plugin`})]}):i.type===`validate`?(0,$.jsx)(rr,{onComplete:e,path:i.path}):i.type===`marketplace-menu`?(a({type:`menu`}),null):i.type===`marketplace-list`?(0,$.jsx)(sr,{onComplete:e}):i.type===`add-marketplace`?(0,$.jsx)(an,{inputValue:c,setInputValue:l,cursorOffset:u,setCursorOffset:d,error:f,setError:p,result:m,setResult:h,setViewState:a,onAddComplete:x,cliMode:te}):(0,$.jsx)(Ge,{color:`suggestion`,children:(0,$.jsxs)(Ue,{title:`Plugins`,selectedTab:o,onTabChange:S,color:`suggestion`,disableNavigation:g,children:[(0,$.jsx)(Ve,{id:`discover`,title:`Discover`,children:i.type===`browse-marketplace`?(0,$.jsx)(An,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:x,targetMarketplace:i.targetMarketplace,targetPlugin:i.targetPlugin}):(0,$.jsx)(Nn,{error:f,setError:p,result:m,setResult:h,setViewState:a,onInstallComplete:x,onSearchModeChange:_,targetPlugin:i.type===`discover-plugins`?i.targetPlugin:void 0})}),(0,$.jsx)(Ve,{id:`installed`,title:`Installed`,children:(0,$.jsx)(Qn,{setViewState:a,setResult:h,onManageComplete:x,onSearchModeChange:_,targetPlugin:i.type===`manage-plugins`?i.targetPlugin:void 0,targetMarketplace:i.type===`manage-plugins`?i.targetMarketplace:void 0,action:i.type===`manage-plugins`?i.action:void 0})}),(0,$.jsx)(Ve,{id:`marketplaces`,title:`Marketplaces`,children:(0,$.jsx)(Rn,{setViewState:a,error:f,setError:p,setResult:h,exitState:ee,onManageComplete:x,targetMarketplace:i.type===`manage-marketplaces`?i.targetMarketplace:void 0,action:i.type===`manage-marketplaces`?i.action:void 0})}),(0,$.jsx)(Ve,{id:`errors`,title:b,children:(0,$.jsx)(hr,{setViewState:a,setActiveTab:s,markPluginsChanged:x})})]})})}var Q,$,yr,br=e((()=>{i(),V(),Q=t(V(),1),_(),We(),Ht(),v(),Ae(),Ye(),de(),Ce(),Me(),vt(),at(),sn(),Mn(),Ln(),Vn(),er(),Wn(),nr(),or(),$=qe(),yr=new Set([`git-auth-failed`,`git-timeout`,`network-error`])}));async function xr(e,t,n){return(0,Sr.jsx)(vr,{onComplete:e,args:n})}var Sr;e((()=>{V(),br(),Sr=qe()}))();export{xr as call};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{$d as n,Af as r,Co as i,Mf as a,So as o,dT as s,jf as c,lT as l,tf as u}from"./loadAgentsDir-BL93ulMm.js";import{P as d,R as f}from"./debug-BecbSVoN.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-Dauqle-Z.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-DnhzFbYI.js";e(),f(),u(),h(),i(),l(),p(),a(),_(),T();function E(e,n,i){g(e);let a=i?`${n} plugin "${i}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${a}: ${d(e)}`);let l=i?(()=>{let{name:e,marketplace:t}=s(i);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...r(e,t,o())}})():{};v(`tengu_plugin_command_failed`,{command:n,error_category:c(e),...l}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let i=await b(e,n);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:c}=s(i.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:a,...c&&{_PROTO_marketplace_name:c},scope:i.scope||n,install_source:`cli-explicit`,...r(a,c,o())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,i=!1){try{let a=await x(e,n,!i);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:c,marketplace:l}=s(a.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:c,...l&&{_PROTO_marketplace_name:l},scope:a.scope||n,...r(c,l,o())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let i=await y(e,n);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:c}=s(i.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:a,...c&&{_PROTO_marketplace_name:c},scope:i.scope,...r(a,c,o())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let i=await C(e,n);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:a,marketplace:c}=s(i.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:a,...c&&{_PROTO_marketplace_name:c},scope:i.scope,...r(a,c,o())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),v(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,i){try{m(`Checking for updates for plugin "${e}" at ${i} scope…\n`);let a=await S(e,i);if(!a.success)throw Error(a.message);if(m(`${t.tick} ${a.message}\n`),!a.alreadyUpToDate){let{name:t,marketplace:n}=s(a.pluginId||e);v(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:a.oldVersion||`unknown`,new_version:a.newVersion||`unknown`,...r(t,n,o())})}await n(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};