@readmagic/workmate 0.0.5 → 0.0.6

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 (346) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-DJRkEz7o.js → AddWorkspaceDirectory-ClHi-Dr6.js} +1 -1
  2. package/dist/chunks/{App-iJu5qyiF.js → App-BP06lHmf.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-CRejTHUw.js → ApproveApiKey-Bsy8kr2a.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-CBLQ1v-J.js → AssistantSessionChooser-CcocKoTJ.js} +1 -1
  6. package/dist/chunks/{BackgroundTasksDialog-CyoLEYWH.js → BackgroundTasksDialog-DNeBhGCf.js} +1 -1
  7. package/dist/chunks/{BypassPermissionsModeDialog-D1FCKVOi.js → BypassPermissionsModeDialog-BKj_3Idm.js} +1 -1
  8. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CI0yF6sZ.js → ClaudeMdExternalIncludesDialog-BD-7yAZh.js} +1 -1
  9. package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +1 -0
  10. package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-D1rrMxeP.js → DesktopHandoff-BmPmCfT3.js} +1 -1
  12. package/dist/chunks/{DiffDialog-BKcfKx7O.js → DiffDialog-C4XSSjvV.js} +1 -1
  13. package/dist/chunks/Doctor-BhD-ZzZm.js +1 -0
  14. package/dist/chunks/{Doctor-Yco1McrL.js → Doctor-DEQe2q16.js} +1 -1
  15. package/dist/chunks/{ExitFlow-D3csukbB.js → ExitFlow-BttnAv-O.js} +1 -1
  16. package/dist/chunks/{Feedback-bEUtrHia.js → Feedback-BaYA8-SU.js} +1 -1
  17. package/dist/chunks/Grove-BJziCbZH.js +11 -0
  18. package/dist/chunks/Grove-sWm-oLBf.js +1 -0
  19. package/dist/chunks/{HybridTransport-9fTBC2Pv.js → HybridTransport-B8V6O6rM.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-9M-1nfZ6.js → InvalidConfigDialog-CHzBSJDf.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-B2F6pryH.js → InvalidSettingsDialog-BKenH3bD.js} +1 -1
  22. package/dist/chunks/{MCPConnectionManager-MWpKjeZT.js → MCPConnectionManager-CNh9dNlk.js} +1 -1
  23. package/dist/chunks/{McpParsingWarnings-BPBb7Npe.js → McpParsingWarnings-Bj2-YL8o.js} +1 -1
  24. package/dist/chunks/{MessageSelector-DsQmqFt2.js → MessageSelector-DdR6wJhh.js} +1 -1
  25. package/dist/chunks/{Messages-B3sGRx5A.js → Messages-Ch6cboMV.js} +2 -2
  26. package/dist/chunks/{Onboarding-cHcnsBGp.js → Onboarding-BrAJp0aL.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-CWCD_RpM.js → OverageCreditUpsell-Ds1cB7RC.js} +1 -1
  28. package/dist/chunks/PluginSettings-CGqEzejq.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-D5sAO6y-.js → PromptInputFooterSuggestions-egs9VvUs.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-n6hAdsto.js → PromptInputHelpMenu-SieM5NoY.js} +1 -1
  31. package/dist/chunks/{QueryEngine-cwdsr4dr.js → QueryEngine-CZZMl3PB.js} +1 -1
  32. package/dist/chunks/{REPL-CJzScgbZ.js → REPL-CG2N7E4Q.js} +6 -6
  33. package/dist/chunks/REPL-DvA910N_.js +1 -0
  34. package/dist/chunks/{RemoteCallout-CiA4rCEs.js → RemoteCallout-Cs-ro8_i.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-zdHfmvfj.js → RemoteSessionManager-B740Dp6m.js} +1 -1
  36. package/dist/chunks/{ResumeConversation-Rxwd6HAJ.js → ResumeConversation-DzV2zmuX.js} +1 -1
  37. package/dist/chunks/{SSETransport-BPbhCa2f.js → SSETransport-DtpMDekF.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +1 -0
  39. package/dist/chunks/{Settings-CxI_KHUj.js → Settings-XKw6FI_m.js} +2 -2
  40. package/dist/chunks/{TeleportProgress-DrulEQ7z.js → TeleportProgress-rYaHIEfe.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-D3FOLr0P.js → TeleportRepoMismatchDialog-DY97YZMB.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-DI5iRFND.js → TeleportResumeWrapper-jaQzyTCh.js} +1 -1
  43. package/dist/chunks/{ThemePicker-CQ7dfFtv.js → ThemePicker-BViWzLp3.js} +1 -1
  44. package/dist/chunks/{TrustDialog-CnVKrdxQ.js → TrustDialog-DGJ_BisZ.js} +1 -1
  45. package/dist/chunks/{ValidationErrorsList-CPYeuppg.js → ValidationErrorsList-B8pRiGuy.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-C-UXdIng.js → WelcomeV2-DqnbSdIu.js} +1 -1
  47. package/dist/chunks/{add-dir-xTz4COgn.js → add-dir-C2Hu3oE4.js} +1 -1
  48. package/dist/chunks/{agentDisplay-BuSReYxu.js → agentDisplay-XoDJhr03.js} +1 -1
  49. package/dist/chunks/{agents-Du9KYHqN.js → agents-BIHTGDYh.js} +1 -1
  50. package/dist/chunks/{agents-CiLlKN2I.js → agents-C4QXeHIJ.js} +1 -1
  51. package/dist/chunks/{allErrors-P3utlEeA.js → allErrors-1896uQA1.js} +1 -1
  52. package/dist/chunks/{ant-CBIfqmAb.js → ant-B6k6cBts.js} +1 -1
  53. package/dist/chunks/api-BsFW57_Q.js +1 -0
  54. package/dist/chunks/{api-B-5jqiMg.js → api-gqTA-D7n.js} +1 -1
  55. package/dist/chunks/{assistant-XOnU01yl.js → assistant-DJ9hd4uC.js} +1 -1
  56. package/dist/chunks/auth-8Vd3_U8t.js +1 -0
  57. package/dist/chunks/{auth-DT2yxy94.js → auth-BnSrKyJe.js} +1 -1
  58. package/dist/chunks/auth-DRTjfnGy.js +1 -0
  59. package/dist/chunks/{autoMode-CEMflt3g.js → autoMode-BNukrVAB.js} +1 -1
  60. package/dist/chunks/{autonomy-_N8aDaA8.js → autonomy-BEmI7WVW.js} +1 -1
  61. package/dist/chunks/{autonomy-Cg5zweUa.js → autonomy-DGcy5Rml.js} +1 -1
  62. package/dist/chunks/{autonomyPanel-I4yCy3Fr.js → autonomyPanel-fhge09AG.js} +1 -1
  63. package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +1 -0
  64. package/dist/chunks/{backgroundHousekeeping-DhF2lrQ9.js → backgroundHousekeeping-BVMf_Tjn.js} +2 -2
  65. package/dist/chunks/{branch-BIX-pyHp.js → branch-Bpe-gocq.js} +1 -1
  66. package/dist/chunks/{break-cache-BQfgkNAo.js → break-cache-C_p7Kmx2.js} +3 -3
  67. package/dist/chunks/{bridge-CYskzVt8.js → bridge-D12Shbkj.js} +2 -2
  68. package/dist/chunks/{bridgeConfig-5p_w4s5r.js → bridgeConfig-BhxRF2vm.js} +1 -1
  69. package/dist/chunks/bridgeConfig-CqIQ_rvD.js +1 -0
  70. package/dist/chunks/bridgeEnabled-D0XC5kNh.js +1 -0
  71. package/dist/chunks/{bridgeEnabled-DhFrLTbG.js → bridgeEnabled-SbB-6zdY.js} +1 -1
  72. package/dist/chunks/{bridgeMain-BX2AkLPs.js → bridgeMain-DHUpZFgL.js} +6 -6
  73. package/dist/chunks/bridgeMain-DUbQjgCp.js +1 -0
  74. package/dist/chunks/{bridgeMessaging-B5Lbzr8e.js → bridgeMessaging-DHc5dOhB.js} +1 -1
  75. package/dist/chunks/{btw-CWWFO7u8.js → btw-D9hMM5d2.js} +1 -1
  76. package/dist/chunks/caches-CWzT7e6Y.js +1 -0
  77. package/dist/chunks/{caches-DPqPIogk.js → caches-UeVVM3T0.js} +2 -2
  78. package/dist/chunks/{ccrClient-CTLnU9Y1.js → ccrClient-Iza0L8Zw.js} +1 -1
  79. package/dist/chunks/{clear-DCAgZwc4.js → clear-B4d38ssF.js} +1 -1
  80. package/dist/chunks/client-BzKQTXzF.js +1 -0
  81. package/dist/chunks/{color-CmJGInHL.js → color-D8VOyoYl.js} +1 -1
  82. package/dist/chunks/commands-DDamMmo4.js +1 -0
  83. package/dist/chunks/commitAttribution-CgohL8vD.js +1 -0
  84. package/dist/chunks/{commitAttribution-CGZr7XNO.js → commitAttribution-ChAgixdj.js} +1 -1
  85. package/dist/chunks/{compact-C6-lMHgn.js → compact-IFHwxjZ9.js} +1 -1
  86. package/dist/chunks/config-DY5-_kk_.js +1 -0
  87. package/dist/chunks/{config-3m_9zSrj.js → config-DmomySWC.js} +1 -1
  88. package/dist/chunks/config-WxgxrQoP.js +1 -0
  89. package/dist/chunks/{context-C9V4GF0n.js → context-Cl6BJ2vm.js} +1 -1
  90. package/dist/chunks/{context-noninteractive-BmC4o5xo.js → context-noninteractive-9hELVC29.js} +1 -1
  91. package/dist/chunks/context-noninteractive-Beij5MfU.js +1 -0
  92. package/dist/chunks/conversation-BBB91hEw.js +1 -0
  93. package/dist/chunks/{conversation-CYqqk0o7.js → conversation-BWVTM40Y.js} +1 -1
  94. package/dist/chunks/{createSSHSession-BL6j0AU5.js → createSSHSession-BM-5pbv6.js} +1 -1
  95. package/dist/chunks/createSession-CoQtL5Rj.js +1 -0
  96. package/dist/chunks/{createSession-D_sgO1Xy.js → createSession-Cvl1Q50F.js} +1 -1
  97. package/dist/chunks/{crossProjectResume-D5hTOfnE.js → crossProjectResume-BasMLl2n.js} +1 -1
  98. package/dist/chunks/{datadog-UkGdjL8-.js → datadog-CpqEQbHa.js} +1 -1
  99. package/dist/chunks/{desktop-HbYKh-VK.js → desktop-B_L6T6jI.js} +1 -1
  100. package/dist/chunks/{diff-nTV17iWX.js → diff-CVzOodeg.js} +1 -1
  101. package/dist/chunks/doctor-1L0TFuGw.js +1 -0
  102. package/dist/chunks/{entry-CCFI6-gM.js → entry-DHVYCR26.js} +1 -1
  103. package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +1 -0
  104. package/dist/chunks/{envLessBridgeConfig-DXd10GXD.js → envLessBridgeConfig-Ck2-KMq0.js} +1 -1
  105. package/dist/chunks/{esm-CGoYrggU.js → esm-D5q6s4l8.js} +1 -1
  106. package/dist/chunks/{exit-ropaQiOr.js → exit-Bm1S_f3i.js} +1 -1
  107. package/dist/chunks/extra-usage-UHAWtypK.js +1 -0
  108. package/dist/chunks/{extra-usage-core-DLYHAInT.js → extra-usage-core-BFOolqoi.js} +1 -1
  109. package/dist/chunks/{extra-usage-noninteractive-D8iszH3c.js → extra-usage-noninteractive-cUGZy0en.js} +1 -1
  110. package/dist/chunks/{extra-usage-g2Pw4zt_.js → extra-usage-zDHVtWKZ.js} +1 -1
  111. package/dist/chunks/{extraUsage-C2Ylufhj.js → extraUsage-Dq66zzqR.js} +1 -1
  112. package/dist/chunks/extractMemories-BcaklA33.js +1 -0
  113. package/dist/chunks/fast-DALAHO3d.js +1 -0
  114. package/dist/chunks/{fast-Dx2fTmWr.js → fast-MS7WZpD8.js} +1 -1
  115. package/dist/chunks/{feedback-DCQ4pJ3v.js → feedback-Fw4m28ZC.js} +1 -1
  116. package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +1 -0
  117. package/dist/chunks/{firstPartyEventLogger-BNGPPBNP.js → firstPartyEventLogger-CoSUd0a1.js} +2 -2
  118. package/dist/chunks/{flushGate-XaheIZZT.js → flushGate-De-yppeo.js} +1 -1
  119. package/dist/chunks/{gemini-BCCLHK3K.js → gemini-BPziscyN.js} +1 -1
  120. package/dist/chunks/{generateRecap-BhvbixY2.js → generateRecap-jGDLI_wU.js} +1 -1
  121. package/dist/chunks/{generateSessionName-CN1oh7Fa.js → generateSessionName-hDJ6HBJ1.js} +1 -1
  122. package/dist/chunks/{githubRepoPathMapping-B4AM8luI.js → githubRepoPathMapping-qAoiyj6P.js} +1 -1
  123. package/dist/chunks/{goal-Bp6fyGqo.js → goal-CFx4eRkf.js} +1 -1
  124. package/dist/chunks/{grok-ax26ju8y.js → grok-Byblph7F.js} +1 -1
  125. package/dist/chunks/{grove-DrBVaZSN.js → grove-CpqjcGCb.js} +1 -1
  126. package/dist/chunks/{heapdump-JseysNDr.js → heapdump-C4kPlqGt.js} +1 -1
  127. package/dist/chunks/{help-DR9hKneR.js → help-B1h-faJ3.js} +1 -1
  128. package/dist/chunks/hooks-DPLIIpAD.js +1 -0
  129. package/dist/chunks/{hooks-C5n23H1E.js → hooks-X6J03MnA.js} +1 -1
  130. package/dist/chunks/hostGuard-BHI6Q8Mt.js +1 -0
  131. package/dist/chunks/inboundAttachments-BekVc0W-.js +1 -0
  132. package/dist/chunks/{inboundAttachments-Cp8XvLMZ.js → inboundAttachments-CUJE3KaU.js} +1 -1
  133. package/dist/chunks/{initReplBridge-DJs28ZkI.js → initReplBridge-JQ-afRx9.js} +1 -1
  134. package/dist/chunks/{install-C7qTB0V5.js → install-D5YORIJL.js} +1 -1
  135. package/dist/chunks/{instrumentation-CLZttr_u.js → instrumentation-Bw3CxPQf.js} +3 -3
  136. package/dist/chunks/{job-BhiazwPH.js → job-DOWtcltx.js} +1 -1
  137. package/dist/chunks/{keybindings-CkL8BzUt.js → keybindings-BLw5J-Zj.js} +1 -1
  138. package/dist/chunks/{language-DIw2871r.js → language-C6Fq-XOZ.js} +1 -1
  139. package/dist/chunks/language-Cqw5gYJR.js +1 -0
  140. package/dist/chunks/{launchAgentsPlatform-j-mWpwW1.js → launchAgentsPlatform-jWWf-Lk9.js} +1 -1
  141. package/dist/chunks/{launchLocalMemory-DmoXp0Xo.js → launchLocalMemory-kHeD0I0y.js} +1 -1
  142. package/dist/chunks/{launchLocalVault-1uKe0HjA.js → launchLocalVault-DLqkOjmb.js} +1 -1
  143. package/dist/chunks/{launchMemoryStores-SxDKjHJ3.js → launchMemoryStores-Ct7AVXrO.js} +1 -1
  144. package/dist/chunks/{launchOnboarding-CTtpnXcs.js → launchOnboarding-Cc6WwPX9.js} +1 -1
  145. package/dist/chunks/{launchSchedule-BDVnGhaL.js → launchSchedule-ZyvuvjgU.js} +1 -1
  146. package/dist/chunks/{launchSkillStore-SmMLxp4K.js → launchSkillStore-BejQnLog.js} +1 -1
  147. package/dist/chunks/{launchTeleport-B472ZSGz.js → launchTeleport-8CuYUfIR.js} +1 -1
  148. package/dist/chunks/{launchVault-CsyBgxle.js → launchVault-DIvIOuPh.js} +1 -1
  149. package/dist/chunks/{loadAgentsDir-Clu7Uk6a.js → loadAgentsDir-D206qwP3.js} +47 -47
  150. package/dist/chunks/loadAgentsDir-TZjwTqdr.js +1 -0
  151. package/dist/chunks/{loadPluginHooks-Cvd5VdjQ.js → loadPluginHooks-Ddhsyn0_.js} +1 -1
  152. package/dist/chunks/{localSearch-iA6JTk19.js → localSearch-CzrbOklu.js} +1 -1
  153. package/dist/chunks/localSearch-DrOAL6f4.js +1 -0
  154. package/dist/chunks/{logoV2Utils-YHBJLIrC.js → logoV2Utils-8M56V7oN.js} +1 -1
  155. package/dist/chunks/{magicDocs-Bf1fqnHN.js → magicDocs-DWjL2k7P.js} +1 -1
  156. package/dist/chunks/{main-gtV_TqXP.js → main-BohPzJFF.js} +16 -16
  157. package/dist/chunks/{mappers-C8lYERPX.js → mappers-BDMZFgKx.js} +1 -1
  158. package/dist/chunks/{mcp-Ci0OPVrR.js → mcp-Bt1ITh-Z.js} +1 -1
  159. package/dist/chunks/{mcp-CNuhEGP6.js → mcp-CwJ-AIpt.js} +2 -2
  160. package/dist/chunks/{mcp-CwIYauZl.js → mcp-W0LFoyFR.js} +1 -1
  161. package/dist/chunks/{memory-DCGqfQ1U.js → memory-3wV7m7UU.js} +1 -1
  162. package/dist/chunks/{mode-DO6g7nkX.js → mode-CUkHFkju.js} +1 -1
  163. package/dist/chunks/{model-DLXL0CNu.js → model-BY3auM2c.js} +1 -1
  164. package/dist/chunks/model-CKkOnnnx.js +1 -0
  165. package/dist/chunks/model-DRXcJyU9.js +1 -0
  166. package/dist/chunks/{nativeInstaller-OPuO2sm_.js → nativeInstaller-CA5d6_G7.js} +1 -1
  167. package/dist/chunks/{onChangeAppState-CHhRDkM7.js → onChangeAppState-DBmy2Ow_.js} +1 -1
  168. package/dist/chunks/{openai-HOebt-8k.js → openai-Cbomn0Ws.js} +1 -1
  169. package/dist/chunks/{overageCreditGrant-Bi1CTBAx.js → overageCreditGrant-DsUrmeBh.js} +1 -1
  170. package/dist/chunks/{panel-CrTPqXCv.js → panel-BSZGX6jN.js} +1 -1
  171. package/dist/chunks/{panelCall-D0eURklm.js → panelCall-BsVoL1uF.js} +1 -1
  172. package/dist/chunks/{partition-C8RSL3SQ.js → partition-BAakXjvj.js} +1 -1
  173. package/dist/chunks/{passes-BJci5SM_.js → passes-CLRt7Cvm.js} +1 -1
  174. package/dist/chunks/{permissions-JU9CGHgI.js → permissions-BVSFuwNP.js} +1 -1
  175. package/dist/chunks/{pidLock-Bd2e6xuT.js → pidLock-D5rUnDB-.js} +2 -2
  176. package/dist/chunks/{plan-D4gMsK7i.js → plan-SYZ4DXR8.js} +1 -1
  177. package/dist/chunks/{plugin-CwCo5Kik.js → plugin-Bfjzhmrk.js} +1 -1
  178. package/dist/chunks/{pluginAutoupdate-CO-n9bqe.js → pluginAutoupdate-reO2PgtQ.js} +1 -1
  179. package/dist/chunks/{pluginBlocklist-5qbaTRbV.js → pluginBlocklist-C3H2afWG.js} +1 -1
  180. package/dist/chunks/{pluginCliCommands-I-lsw_us.js → pluginCliCommands-lqdxdkQp.js} +1 -1
  181. package/dist/chunks/{pluginFlagging-DNPBbJZo.js → pluginFlagging-D9HKAGBC.js} +1 -1
  182. package/dist/chunks/{pluginOperations-Cz6eQ0Vu.js → pluginOperations-EN3EKLux.js} +1 -1
  183. package/dist/chunks/{pluginStartupCheck-DJ9fslCK.js → pluginStartupCheck-BY73BMT2.js} +1 -1
  184. package/dist/chunks/pluginStartupCheck-CwWOlveD.js +1 -0
  185. package/dist/chunks/{plugins-CzJIuPfb.js → plugins-Dn6ceWrT.js} +1 -1
  186. package/dist/chunks/policyLimits-CkTI5KEt.js +1 -0
  187. package/dist/chunks/{poor-Dha9p9RF.js → poor-j-y-bv8o.js} +1 -1
  188. package/dist/chunks/{poorMode-1NLYiS3Y.js → poorMode-DhzFKpPl.js} +1 -1
  189. package/dist/chunks/poorMode-V11s-3cf.js +1 -0
  190. package/dist/chunks/{print-BL4EUT5Z.js → print-Db_VXmfO.js} +4 -4
  191. package/dist/chunks/{privacy-settings-6ZWxR4Qt.js → privacy-settings-DHMJREbb.js} +1 -1
  192. package/dist/chunks/{processBashCommand-BZs9wggV.js → processBashCommand-BcM_fhV9.js} +1 -1
  193. package/dist/chunks/{processSlashCommand-D8lKLNzM.js → processSlashCommand-DEVo3GPX.js} +1 -1
  194. package/dist/chunks/{prompt-Bg_1U0gO.js → prompt-BNHtszmZ.js} +1 -1
  195. package/dist/chunks/prompt-CrX31AGm.js +1 -0
  196. package/dist/chunks/prompt-IAvMxKDl.js +1 -0
  197. package/dist/chunks/{promptEditor-BhYDmwdS.js → promptEditor-DeMrXUir.js} +1 -1
  198. package/dist/chunks/{protocolHandler-Dnb7lITm.js → protocolHandler-BHxBy84Z.js} +1 -1
  199. package/dist/chunks/{rate-limit-options-DVzT3eWH.js → rate-limit-options-DIudL9fb.js} +1 -1
  200. package/dist/chunks/{rcDebugLog-VKwMl0yg.js → rcDebugLog-CUy1_F23.js} +1 -1
  201. package/dist/chunks/{reconciler-BdRXZTJf.js → reconciler-BXpPyfSY.js} +1 -1
  202. package/dist/chunks/{referral-BlrMpBAV.js → referral-CUaIo_vT.js} +1 -1
  203. package/dist/chunks/{refresh-jwqnoK2h.js → refresh-CuaVBIQ0.js} +1 -1
  204. package/dist/chunks/{registerProtocol-CuKZAiCc.js → registerProtocol-B7Fzdofu.js} +1 -1
  205. package/dist/chunks/{release-notes-BgP8u7NE.js → release-notes-fbfv2DC0.js} +1 -1
  206. package/dist/chunks/{releaseNotes-CunqVlbU.js → releaseNotes-CxAHFLPl.js} +2 -2
  207. package/dist/chunks/{reload-plugins-CD9TzvFm.js → reload-plugins-B9IT9CFA.js} +1 -1
  208. package/dist/chunks/{remote-env-QaP_W_sv.js → remote-env-BOklGlll.js} +1 -1
  209. package/dist/chunks/{remoteBridgeCore-9-HVMo63.js → remoteBridgeCore-j0bG1zjv.js} +1 -1
  210. package/dist/chunks/{remoteManagedSettings-jZ6u8ZBT.js → remoteManagedSettings-Cq994lyc.js} +1 -1
  211. package/dist/chunks/{rename-29qxHf8W.js → rename-Iev7wQsI.js} +1 -1
  212. package/dist/chunks/{resume-D-SpOy_1.js → resume-y7MCTZHJ.js} +1 -1
  213. package/dist/chunks/{runtimeObserver-DOEcrylu.js → runtimeObserver-BZcJ1FbH.js} +1 -1
  214. package/dist/chunks/{runtimeObserver-Dm3LIUMp.js → runtimeObserver-CyzLASla.js} +2 -2
  215. package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +1 -0
  216. package/dist/chunks/{sandbox-toggle-B61AeBor.js → sandbox-toggle-CWpBO228.js} +1 -1
  217. package/dist/chunks/searchExtraTools-BUOUds7p.js +1 -0
  218. package/dist/chunks/{session-RwJCIIcs.js → session-DL4cA_8l.js} +1 -1
  219. package/dist/chunks/{sessionDiscovery-dkFeWcA3.js → sessionDiscovery-DAfNKqp1.js} +1 -1
  220. package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +1 -0
  221. package/dist/chunks/{sessionMemory-btARBn8H.js → sessionMemory-BS8_TbKj.js} +1 -1
  222. package/dist/chunks/sessionMemory-D5fSHXvZ.js +1 -0
  223. package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +1 -0
  224. package/dist/chunks/sessionObserver-ChfQtK2m.js +1 -0
  225. package/dist/chunks/{sessionObserver-CSOYgsvH.js → sessionObserver-ShbCwJ8x.js} +1 -1
  226. package/dist/chunks/sessionStorage-Cf5wmnyB.js +1 -0
  227. package/dist/chunks/{sessionTitle-CLOlPZ_M.js → sessionTitle-coed9IuJ.js} +1 -1
  228. package/dist/chunks/{sessionTracing-D8wr9j4X.js → sessionTracing-D9rUyiq0.js} +1 -1
  229. package/dist/chunks/{settings-Dlp5JTa_.js → settings-BovzmwMP.js} +2 -2
  230. package/dist/chunks/{settingsSync-QWA0VZSu.js → settingsSync-PqU9XGJq.js} +1 -1
  231. package/dist/chunks/{setup-UI9uv2-K.js → setup-B_FOvNpp.js} +2 -2
  232. package/dist/chunks/{shadowedRuleDetection-CXsmUY2o.js → shadowedRuleDetection-D1wsAdpp.js} +1 -1
  233. package/dist/chunks/{sideQuestion-CHpOVzY5.js → sideQuestion-wSi38p81.js} +1 -1
  234. package/dist/chunks/sinks-BpcRrN_T.js +1 -0
  235. package/dist/chunks/{sinks-1hFrW9HK.js → sinks-C_Dl1p4K.js} +2 -2
  236. package/dist/chunks/{skill-learning-Ck17rwH8.js → skill-learning-B5tmc7EX.js} +1 -1
  237. package/dist/chunks/{skillChangeDetector-s0F9Yf9a.js → skillChangeDetector-DNqohXxz.js} +1 -1
  238. package/dist/chunks/{skillGapStore-BJ1h2LVr.js → skillGapStore-D-kQKVDZ.js} +1 -1
  239. package/dist/chunks/{skillGapStore-DyqNKuNy.js → skillGapStore-Df5BWAk5.js} +2 -2
  240. package/dist/chunks/{skillGenerator-BT8NGzXT.js → skillGenerator-DbcdpAkw.js} +2 -2
  241. package/dist/chunks/skillLearning-C5cXZE6_.js +1 -0
  242. package/dist/chunks/{skillLearning-Cn9Uw0Kd.js → skillLearning-ClRiDcJH.js} +1 -1
  243. package/dist/chunks/{skillPanel-N0GoWjIi.js → skillPanel-LBd4E-MM.js} +3 -3
  244. package/dist/chunks/{skillSearchPanel-CTwtgTzy.js → skillSearchPanel-CErRnUwo.js} +2 -2
  245. package/dist/chunks/{skills-Bv3lH-aA.js → skills-CBKhfg_a.js} +1 -1
  246. package/dist/chunks/{stats-C1Ff6w4i.js → stats-BY4dskVg.js} +1 -1
  247. package/dist/chunks/{status-DyXiBa0m.js → status-BnJIXtKl.js} +2 -2
  248. package/dist/chunks/{status-FD7HVYS7.js → status-DU-B4SMW.js} +1 -1
  249. package/dist/chunks/{statusNoticeHelpers-kTp9Rdk6.js → statusNoticeHelpers-CzTuGNuC.js} +1 -1
  250. package/dist/chunks/{tag-RzOSA5T0.js → tag-B-wVW9Aj.js} +1 -1
  251. package/dist/chunks/{tasks-eJrOcdhB.js → tasks-CBVL005y.js} +1 -1
  252. package/dist/chunks/{teleport-ABA-hdmP.js → teleport-dtqQXM4x.js} +1 -1
  253. package/dist/chunks/{templateJobs-BnOBSFtq.js → templateJobs-D6998LcG.js} +1 -1
  254. package/dist/chunks/{terminalSetup-BfvmoJaK.js → terminalSetup-0SBdyKF5.js} +1 -1
  255. package/dist/chunks/{terminalSetup-D_P5iZmq.js → terminalSetup-CuV-qU6v.js} +1 -1
  256. package/dist/chunks/{theme-S0kVMVt4.js → theme-p0AooruD.js} +1 -1
  257. package/dist/chunks/thinkback-Catprqs_.js +1 -0
  258. package/dist/chunks/{thinkback-HyW_R_88.js → thinkback-DI2NpvG-.js} +1 -1
  259. package/dist/chunks/{thinkback-play-H6md4czq.js → thinkback-play-CqrIRx2o.js} +1 -1
  260. package/dist/chunks/{toolEventObserver-BAFzvePj.js → toolEventObserver-DTccwC3c.js} +1 -1
  261. package/dist/chunks/{toolEventObserver--Z6jENks.js → toolEventObserver-DlH73w-S.js} +1 -1
  262. package/dist/chunks/{toolPool-CR61XXm3.js → toolPool-B64V-jmK.js} +1 -1
  263. package/dist/chunks/{trustedDevice-Dn4rXbxT.js → trustedDevice-BTYoQCkC.js} +1 -1
  264. package/dist/chunks/trustedDevice-CiwjT_Y6.js +1 -0
  265. package/dist/chunks/{ultrareviewCommand-mYDTBCFD.js → ultrareviewCommand-BDFUS3hf.js} +1 -1
  266. package/dist/chunks/undercover-XYapZ_SS.js +1 -0
  267. package/dist/chunks/{undercover-CdapzvNH.js → undercover-vuTpCnQJ.js} +2 -2
  268. package/dist/chunks/{updateCCB-DPShheOr.js → updateCCB-DFL5Wt_I.js} +1 -1
  269. package/dist/chunks/{upgrade-BOeakAP6.js → upgrade-D5qwcaWQ.js} +1 -1
  270. package/dist/chunks/upgrade-DIg3j929.js +1 -0
  271. package/dist/chunks/{upload-BXQsDtLW.js → upload-B_yADHX9.js} +1 -1
  272. package/dist/chunks/{usage-iNQzY960.js → usage-C0SnnC-i.js} +1 -1
  273. package/dist/chunks/usage-CYJKE8N6.js +1 -0
  274. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CntByfTQ.js → useExitOnCtrlCDWithKeybindings-DKIqRraH.js} +1 -1
  275. package/dist/chunks/useMainLoopModel-XetDUXd-.js +1 -0
  276. package/dist/chunks/{useManagePlugins-B8HD0RUh.js → useManagePlugins-B2KhKiu5.js} +1 -1
  277. package/dist/chunks/{useMergedTools-DfchLQZC.js → useMergedTools-CKvwz_Zt.js} +1 -1
  278. package/dist/chunks/{useSearchInput-H-8hJeFD.js → useSearchInput-D1Vr2Js1.js} +1 -1
  279. package/dist/chunks/{useSettingsErrors-BF5i5Xju.js → useSettingsErrors-B7BXHchG.js} +1 -1
  280. package/dist/chunks/{util-CoicMvOv.js → util-BaDs-wL5.js} +1 -1
  281. package/dist/chunks/{validatePlugin-z2fcngf8.js → validatePlugin-DtiYlXby.js} +1 -1
  282. package/dist/chunks/{vim-DdvQlLDm.js → vim-C-icQDz1.js} +1 -1
  283. package/dist/chunks/{workerRegistry-CzqQwCHC.js → workerRegistry-ChqPPIaO.js} +1 -1
  284. package/dist/chunks/worktree-DAn8ooa1.js +1 -0
  285. package/dist/cli.js +1 -1
  286. package/package.json +1 -1
  287. package/dist/chunks/ApproveApiKey-CKfn7U1R.js +0 -1
  288. package/dist/chunks/ClaudeMdExternalIncludesDialog-TypH-X8e.js +0 -1
  289. package/dist/chunks/ConsoleOAuthFlow-wGQuFt41.js +0 -1
  290. package/dist/chunks/Doctor-CcJUwSQn.js +0 -1
  291. package/dist/chunks/Grove-DPkIjqg8.js +0 -1
  292. package/dist/chunks/Grove-Dsd7F39b.js +0 -11
  293. package/dist/chunks/PluginSettings-B0jbwB2M.js +0 -17
  294. package/dist/chunks/REPL-DlBJIPCw.js +0 -1
  295. package/dist/chunks/SearchExtraToolsTool-VP87ErGx.js +0 -1
  296. package/dist/chunks/api-BiwZmmsh.js +0 -1
  297. package/dist/chunks/auth-BQa4kzQo.js +0 -1
  298. package/dist/chunks/auth-UAJhZNmZ.js +0 -1
  299. package/dist/chunks/backgroundHousekeeping-BUUZ7Csq.js +0 -1
  300. package/dist/chunks/bridgeConfig-DWEqKbXk.js +0 -1
  301. package/dist/chunks/bridgeEnabled-CjVCMwnq.js +0 -1
  302. package/dist/chunks/bridgeMain-6lollTtZ.js +0 -1
  303. package/dist/chunks/caches-C46fa77L.js +0 -1
  304. package/dist/chunks/client-Bup0Sgcn.js +0 -1
  305. package/dist/chunks/commands-BdB1eFvP.js +0 -1
  306. package/dist/chunks/commitAttribution-D6J3NuhB.js +0 -1
  307. package/dist/chunks/config-Bxt1UH1T.js +0 -1
  308. package/dist/chunks/config-CjjXZfNi.js +0 -1
  309. package/dist/chunks/context-noninteractive-DvGo1l7b.js +0 -1
  310. package/dist/chunks/conversation-CH9ouFai.js +0 -1
  311. package/dist/chunks/createSession-DUfOAeyE.js +0 -1
  312. package/dist/chunks/doctor-7fgVhEKL.js +0 -1
  313. package/dist/chunks/envLessBridgeConfig-B2HYnEKo.js +0 -1
  314. package/dist/chunks/extra-usage-CLhv1Z4g.js +0 -1
  315. package/dist/chunks/extractMemories-B2IAvbXM.js +0 -1
  316. package/dist/chunks/fast-_G6zcFye.js +0 -1
  317. package/dist/chunks/firstPartyEventLogger-C9LzVy6y.js +0 -1
  318. package/dist/chunks/hooks-BUJLxdFJ.js +0 -1
  319. package/dist/chunks/hostGuard-C5xydXZI.js +0 -1
  320. package/dist/chunks/inboundAttachments-C0nMTtCi.js +0 -1
  321. package/dist/chunks/language-DfOAuDFc.js +0 -1
  322. package/dist/chunks/loadAgentsDir-DTbJJff-.js +0 -1
  323. package/dist/chunks/localSearch-DKv8PRLD.js +0 -1
  324. package/dist/chunks/model-BQF64tZx.js +0 -1
  325. package/dist/chunks/model-DvrvG6BB.js +0 -1
  326. package/dist/chunks/pluginStartupCheck-CoW7073W.js +0 -1
  327. package/dist/chunks/policyLimits-BkjgMQD0.js +0 -1
  328. package/dist/chunks/poorMode-qlxqU8Hm.js +0 -1
  329. package/dist/chunks/prompt-CN7gBNKS.js +0 -1
  330. package/dist/chunks/prompt-D-zHhqp8.js +0 -1
  331. package/dist/chunks/sandbox-adapter-LzTcKwBp.js +0 -1
  332. package/dist/chunks/searchExtraTools-CbJJQqzH.js +0 -1
  333. package/dist/chunks/sessionFileAccessHooks-B_nNW0zE.js +0 -1
  334. package/dist/chunks/sessionMemory-C4JAUZ6V.js +0 -1
  335. package/dist/chunks/sessionMemoryUtils-BlqAy8oR.js +0 -1
  336. package/dist/chunks/sessionObserver-DMvWci8-.js +0 -1
  337. package/dist/chunks/sessionStorage-Diyuvt20.js +0 -1
  338. package/dist/chunks/sinks-CXq8-7Qn.js +0 -1
  339. package/dist/chunks/skillLearning-1ZfYIzfL.js +0 -1
  340. package/dist/chunks/thinkback-C6gV2LpU.js +0 -1
  341. package/dist/chunks/trustedDevice-DUrFWupL.js +0 -1
  342. package/dist/chunks/undercover-k3JoOKAb.js +0 -1
  343. package/dist/chunks/upgrade-D7iGU0PQ.js +0 -1
  344. package/dist/chunks/usage-DbRdMJog.js +0 -1
  345. package/dist/chunks/useMainLoopModel-DHkRIgNs.js +0 -1
  346. package/dist/chunks/worktree-DMhP5T0p.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Kr as t,qr as n}from"./src-CDCSSo0U2.js";import{en as r,ht as i}from"./state-ix0xIunV.js";import{cb as a,fb as o,po as s,zo as c}from"./loadAgentsDir-Clu7Uk6a.js";import{Y as l}from"./log-BMCygSzM.js";import{Ut as u}from"./prompt-Bg_1U0gO.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:i(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:i(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:i(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=s({content:n(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:i(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=a();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{r(),l(),u(),t(),c(),o()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Kr as t,qr as n}from"./src-CDCSSo0U2.js";import{en as r,ht as i}from"./state-ix0xIunV.js";import{cb as a,fb as o,po as s,zo as c}from"./loadAgentsDir-D206qwP3.js";import{Y as l}from"./log-BMCygSzM.js";import{Ut as u}from"./prompt-BNHtszmZ.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:i(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:i(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:i(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=s({content:n(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:i(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=a();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{r(),l(),u(),t(),c(),o()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{D as i,Gt as a,H as o,I as s,Lt as c,P as l,T as u,Wt as d,fi as f,j as p,t as m,y as ee}from"./src-CDCSSo0U2.js";import{t as h}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as g,C_ as _,Fb as v,GS as y,Jg as b,Nb as x,O_ as S,Sx as C,T_ as w,US as T,WS as E,Yg as D,e_ as te,fx as O,g_ as k,px as ne,xx as A}from"./loadAgentsDir-Clu7Uk6a.js";import{a as re,o as ie}from"./debug-BrXObCdR.js";import{l as ae,n as oe,o as j}from"./stringUtils-DGLPkqJ4.js";import{D as se,O as ce}from"./rcDebugLog-VKwMl0yg.js";import{u as M}from"./referral-BlrMpBAV.js";import{i as le,n as N,r as ue}from"./MCPConnectionManager-MWpKjeZT.js";import{n as de,t as fe}from"./McpParsingWarnings-BPBb7Npe.js";import{a as pe,c as P,i as F,l as me,n as he,o as I,r as ge,s as _e,t as ve,u as L}from"./PluginSettings-B0jbwB2M.js";function ye({agentServer:e,onCancel:t,onComplete:n}){let[a]=o(),[f,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)(null),y=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>y.current?.abort(),[]),d(`confirm:no`,(0,R.useCallback)(()=>{f&&(y.current?.abort(),y.current=null,m(!1),v(null))},[f]),{context:`Confirmation`,isActive:f});let S=(0,R.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;m(!0),g(null);let t=new AbortController;y.current=t;try{let r={type:e.transport,url:e.url};await te(e.name,r,v,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof b)&&g(e.message)}finally{m(!1),y.current=null}},[e,n]),C=oe(String(e.name));if(f)return(0,z.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,z.jsxs)(l,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(x,{}),(0,z.jsx)(l,{children:` A browser window will open for authentication`})]}),_&&(0,z.jsxs)(s,{flexDirection:`column`,children:[(0,z.jsx)(l,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,z.jsx)(c,{url:_})]}),(0,z.jsx)(s,{marginLeft:3,children:(0,z.jsxs)(l,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,z.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let w=[];return e.needsAuth&&w.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),w.push({label:`Back`,value:`back`}),(0,z.jsxs)(ee,{title:`${C} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,z.jsxs)(l,{children:[`Press `,e.keyName,` again to exit`]}):(0,z.jsxs)(u,{children:[(0,z.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,z.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,z.jsxs)(s,{flexDirection:`column`,gap:0,children:[(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Type: `}),(0,z.jsx)(l,{dimColor:!0,children:e.transport})]}),e.url&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`URL: `}),(0,z.jsx)(l,{dimColor:!0,children:e.url})]}),e.command&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Command: `}),(0,z.jsx)(l,{dimColor:!0,children:e.command})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Used by: `}),(0,z.jsx)(l,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,z.jsxs)(s,{marginTop:1,children:[(0,z.jsx)(l,{bold:!0,children:`Status: `}),(0,z.jsxs)(l,{children:[p(`inactive`,a)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,z.jsxs)(l,{children:[p(`success`,a)(r.tick),` authenticated`]}):(0,z.jsxs)(l,{children:[p(`warning`,a)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,z.jsx)(s,{children:(0,z.jsx)(l,{dimColor:!0,children:`This server connects only when running the agent.`})}),h&&(0,z.jsx)(s,{children:(0,z.jsxs)(l,{color:`error`,children:[`Error: `,h]})}),(0,z.jsx)(s,{children:(0,z.jsx)(ne,{options:w,onChange:async e=>{switch(e){case`auth`:await S();break;case`back`:t();break}},onCancel:t})})]})}var R,z,B=e((()=>{n(),R=t(f(),1),m(),M(),g(),j(),C(),O(),v(),z=h()}));function V(e){switch(e){case`project`:return{label:`Project MCPs`,path:k(e)};case`user`:return{label:`User MCPs`,path:k(e)};case`local`:return{label:`Local MCPs`,path:k(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function be(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function xe({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:d,onComplete:f}){let[m]=o(),[h,g]=(0,H.useState)(0),_=H.useMemo(()=>be(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),v=H.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),y=H.useMemo(()=>(_.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[_]),b=V(`dynamic`),x=H.useMemo(()=>{let e=[];for(let t of W){let n=_.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of v)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of y)e.push({type:`server`,server:t});return e},[_,v,t,y]),S=(0,H.useCallback)(()=>{f(`MCP dialog dismissed`,{display:`system`})},[f]);a({"confirm:previous":()=>g(e=>e===0?x.length-1:e-1),"confirm:next":()=>g(e=>e===x.length-1?0:e+1),"confirm:yes":(0,H.useCallback)(()=>{let e=x[h];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&d&&d(e.agentServer))},[x,h,n,d]),"confirm:no":S},{context:`Confirmation`});let C=e=>x.findIndex(t=>t.type===`server`&&t.server===e),w=e=>x.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),T=ie(),E=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let D=e=>{let t=C(e),n=h===t,i=``,a=``;if(e.client.type===`disabled`)i=p(`inactive`,m)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=p(`success`,m)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=p(`inactive`,m)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=p(`warning`,m)(r.triangleUpOutline),a=`needs authentication`):(i=p(`error`,m)(r.cross),a=`failed`);return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`${e.name}-${t}`)},te=e=>{let t=w(e),n=h===t,i=e.needsAuth?p(`warning`,m)(r.triangleUpOutline):p(`inactive`,m)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},O=e.length+t.length;return(0,U.jsxs)(s,{flexDirection:`column`,children:[(0,U.jsx)(fe,{}),(0,U.jsx)(ee,{title:`Manage MCP servers`,subtitle:`${O} ${ae(O,`server`)}`,onCancel:S,hideInputGuide:!0,children:(0,U.jsxs)(s,{flexDirection:`column`,children:[W.map(e=>{let t=_.get(e);if(!t||t.length===0)return null;let n=V(e);return(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:n.label}),n.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>D(e))]},e)}),v.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`claude.ai`})}),v.map(e=>D(e))]}),t.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,U.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsxs)(l,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>te(e))]},e))]}),y.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:b.label}),b.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,b.path,`)`]})]}),y.map(e=>D(e))]}),(0,U.jsxs)(s,{flexDirection:`column`,children:[E&&(0,U.jsx)(l,{dimColor:!0,children:T?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,U.jsxs)(l,{dimColor:!0,children:[(0,U.jsx)(c,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,U.jsx)(s,{paddingX:1,children:(0,U.jsx)(l,{dimColor:!0,italic:!0,children:(0,U.jsxs)(u,{children:[(0,U.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,U.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var H,U,W,G=e((()=>{n(),H=t(f(),1),m(),M(),S(),re(),j(),C(),de(),U=h(),W=[`project`,`local`,`user`,`enterprise`]}));function Se({serverName:e,onComplete:t}){let[n]=o(),i=y(),a=ue(),[c,u]=(0,K.useState)(!0),[d,f]=(0,K.useState)(null);return(0,K.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){f(`MCP server "${e}" not found`),u(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:u(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:f(`${e} requires authentication`),u(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:f(`Failed to reconnect to ${e}`),u(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);f(n),u(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(l,{color:`text`,children:[`Reconnecting to `,(0,q.jsx)(l,{bold:!0,children:e})]}),(0,q.jsxs)(s,{children:[(0,q.jsx)(x,{}),(0,q.jsx)(l,{children:` Establishing connection to MCP server`})]})]}):d?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(s,{children:[(0,q.jsxs)(l,{children:[p(`error`,n)(r.cross),` `]}),(0,q.jsxs)(l,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,q.jsxs)(l,{dimColor:!0,children:[`Error: `,d]})]}):null}var K,q,J=e((()=>{n(),K=t(f(),1),m(),N(),T(),v(),q=h()}));function Y({onComplete:e}){let t=E(e=>e.mcp),n=E(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[o,s]=X.useState([]),c=(0,X.useMemo)(()=>_(n.allAgents),[n.allAgents]),l=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;if(r||i){let n=await new D(e.name,e.config).tokens(),r=se()!==null&&e.type===`connected`,i=e.type===`connected`&&w(t.tools,e.name).length>0;o=!!n||r||i}let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,X.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,Z.jsx)(xe,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=w(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return i.server.transport===`stdio`?(0,Z.jsx)(_e,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(me,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(ge,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=w(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(pe,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(ye,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,Ce=e((()=>{X=t(f(),1),g(),S(),T(),ce(),B(),G(),L(),P(),I(),F(),Z=h()})),we=e((()=>{B(),G(),J(),L(),Ce(),P(),I(),F()}));function Te({action:e,target:t,onComplete:n}){let r=E(e=>e.mcp.clients),i=le(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function Ee(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(Y,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(Se,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Te,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return process.env.USER_TYPE===`ant`?(0,$.jsx)(ve,{onComplete:e,args:`manage`,showMcpRedirectMessage:!0}):(0,$.jsx)(Y,{onComplete:e})}var Q,$;e((()=>{Q=t(f(),1),we(),J(),N(),T(),he(),$=h()}))();export{Ee as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{D as i,Gt as a,H as o,I as s,Lt as c,P as l,T as u,Wt as d,fi as f,j as p,t as m,y as ee}from"./src-CDCSSo0U2.js";import{t as h}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as g,C_ as _,Fb as v,GS as y,Jg as b,Nb as x,O_ as S,Sx as C,T_ as w,US as T,WS as E,Yg as D,e_ as te,fx as O,g_ as k,px as ne,xx as A}from"./loadAgentsDir-D206qwP3.js";import{a as re,o as ie}from"./debug-BrXObCdR.js";import{l as ae,n as oe,o as j}from"./stringUtils-DGLPkqJ4.js";import{D as se,O as ce}from"./rcDebugLog-CUy1_F23.js";import{u as M}from"./referral-CUaIo_vT.js";import{i as le,n as N,r as ue}from"./MCPConnectionManager-CNh9dNlk.js";import{n as de,t as fe}from"./McpParsingWarnings-Bj2-YL8o.js";import{a as pe,c as P,i as F,l as me,n as he,o as I,r as ge,s as _e,t as ve,u as L}from"./PluginSettings-CGqEzejq.js";function ye({agentServer:e,onCancel:t,onComplete:n}){let[a]=o(),[f,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)(null),y=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>y.current?.abort(),[]),d(`confirm:no`,(0,R.useCallback)(()=>{f&&(y.current?.abort(),y.current=null,m(!1),v(null))},[f]),{context:`Confirmation`,isActive:f});let S=(0,R.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;m(!0),g(null);let t=new AbortController;y.current=t;try{let r={type:e.transport,url:e.url};await te(e.name,r,v,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof b)&&g(e.message)}finally{m(!1),y.current=null}},[e,n]),C=oe(String(e.name));if(f)return(0,z.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,z.jsxs)(l,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(x,{}),(0,z.jsx)(l,{children:` A browser window will open for authentication`})]}),_&&(0,z.jsxs)(s,{flexDirection:`column`,children:[(0,z.jsx)(l,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,z.jsx)(c,{url:_})]}),(0,z.jsx)(s,{marginLeft:3,children:(0,z.jsxs)(l,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,z.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let w=[];return e.needsAuth&&w.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),w.push({label:`Back`,value:`back`}),(0,z.jsxs)(ee,{title:`${C} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,z.jsxs)(l,{children:[`Press `,e.keyName,` again to exit`]}):(0,z.jsxs)(u,{children:[(0,z.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,z.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,z.jsxs)(s,{flexDirection:`column`,gap:0,children:[(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Type: `}),(0,z.jsx)(l,{dimColor:!0,children:e.transport})]}),e.url&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`URL: `}),(0,z.jsx)(l,{dimColor:!0,children:e.url})]}),e.command&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Command: `}),(0,z.jsx)(l,{dimColor:!0,children:e.command})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Used by: `}),(0,z.jsx)(l,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,z.jsxs)(s,{marginTop:1,children:[(0,z.jsx)(l,{bold:!0,children:`Status: `}),(0,z.jsxs)(l,{children:[p(`inactive`,a)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,z.jsxs)(l,{children:[p(`success`,a)(r.tick),` authenticated`]}):(0,z.jsxs)(l,{children:[p(`warning`,a)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,z.jsx)(s,{children:(0,z.jsx)(l,{dimColor:!0,children:`This server connects only when running the agent.`})}),h&&(0,z.jsx)(s,{children:(0,z.jsxs)(l,{color:`error`,children:[`Error: `,h]})}),(0,z.jsx)(s,{children:(0,z.jsx)(ne,{options:w,onChange:async e=>{switch(e){case`auth`:await S();break;case`back`:t();break}},onCancel:t})})]})}var R,z,B=e((()=>{n(),R=t(f(),1),m(),M(),g(),j(),C(),O(),v(),z=h()}));function V(e){switch(e){case`project`:return{label:`Project MCPs`,path:k(e)};case`user`:return{label:`User MCPs`,path:k(e)};case`local`:return{label:`Local MCPs`,path:k(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function be(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function xe({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:d,onComplete:f}){let[m]=o(),[h,g]=(0,H.useState)(0),_=H.useMemo(()=>be(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),v=H.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),y=H.useMemo(()=>(_.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[_]),b=V(`dynamic`),x=H.useMemo(()=>{let e=[];for(let t of W){let n=_.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of v)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of y)e.push({type:`server`,server:t});return e},[_,v,t,y]),S=(0,H.useCallback)(()=>{f(`MCP dialog dismissed`,{display:`system`})},[f]);a({"confirm:previous":()=>g(e=>e===0?x.length-1:e-1),"confirm:next":()=>g(e=>e===x.length-1?0:e+1),"confirm:yes":(0,H.useCallback)(()=>{let e=x[h];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&d&&d(e.agentServer))},[x,h,n,d]),"confirm:no":S},{context:`Confirmation`});let C=e=>x.findIndex(t=>t.type===`server`&&t.server===e),w=e=>x.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),T=ie(),E=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let D=e=>{let t=C(e),n=h===t,i=``,a=``;if(e.client.type===`disabled`)i=p(`inactive`,m)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=p(`success`,m)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=p(`inactive`,m)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=p(`warning`,m)(r.triangleUpOutline),a=`needs authentication`):(i=p(`error`,m)(r.cross),a=`failed`);return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`${e.name}-${t}`)},te=e=>{let t=w(e),n=h===t,i=e.needsAuth?p(`warning`,m)(r.triangleUpOutline):p(`inactive`,m)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},O=e.length+t.length;return(0,U.jsxs)(s,{flexDirection:`column`,children:[(0,U.jsx)(fe,{}),(0,U.jsx)(ee,{title:`Manage MCP servers`,subtitle:`${O} ${ae(O,`server`)}`,onCancel:S,hideInputGuide:!0,children:(0,U.jsxs)(s,{flexDirection:`column`,children:[W.map(e=>{let t=_.get(e);if(!t||t.length===0)return null;let n=V(e);return(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:n.label}),n.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>D(e))]},e)}),v.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`claude.ai`})}),v.map(e=>D(e))]}),t.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,U.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsxs)(l,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>te(e))]},e))]}),y.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:b.label}),b.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,b.path,`)`]})]}),y.map(e=>D(e))]}),(0,U.jsxs)(s,{flexDirection:`column`,children:[E&&(0,U.jsx)(l,{dimColor:!0,children:T?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,U.jsxs)(l,{dimColor:!0,children:[(0,U.jsx)(c,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,U.jsx)(s,{paddingX:1,children:(0,U.jsx)(l,{dimColor:!0,italic:!0,children:(0,U.jsxs)(u,{children:[(0,U.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,U.jsx)(A,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var H,U,W,G=e((()=>{n(),H=t(f(),1),m(),M(),S(),re(),j(),C(),de(),U=h(),W=[`project`,`local`,`user`,`enterprise`]}));function Se({serverName:e,onComplete:t}){let[n]=o(),i=y(),a=ue(),[c,u]=(0,K.useState)(!0),[d,f]=(0,K.useState)(null);return(0,K.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){f(`MCP server "${e}" not found`),u(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:u(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:f(`${e} requires authentication`),u(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:f(`Failed to reconnect to ${e}`),u(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);f(n),u(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(l,{color:`text`,children:[`Reconnecting to `,(0,q.jsx)(l,{bold:!0,children:e})]}),(0,q.jsxs)(s,{children:[(0,q.jsx)(x,{}),(0,q.jsx)(l,{children:` Establishing connection to MCP server`})]})]}):d?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(s,{children:[(0,q.jsxs)(l,{children:[p(`error`,n)(r.cross),` `]}),(0,q.jsxs)(l,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,q.jsxs)(l,{dimColor:!0,children:[`Error: `,d]})]}):null}var K,q,J=e((()=>{n(),K=t(f(),1),m(),N(),T(),v(),q=h()}));function Y({onComplete:e}){let t=E(e=>e.mcp),n=E(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[o,s]=X.useState([]),c=(0,X.useMemo)(()=>_(n.allAgents),[n.allAgents]),l=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;if(r||i){let n=await new D(e.name,e.config).tokens(),r=se()!==null&&e.type===`connected`,i=e.type===`connected`&&w(t.tools,e.name).length>0;o=!!n||r||i}let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,X.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,Z.jsx)(xe,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=w(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return i.server.transport===`stdio`?(0,Z.jsx)(_e,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(me,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(ge,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=w(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(pe,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(ye,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,Ce=e((()=>{X=t(f(),1),g(),S(),T(),ce(),B(),G(),L(),P(),I(),F(),Z=h()})),we=e((()=>{B(),G(),J(),L(),Ce(),P(),I(),F()}));function Te({action:e,target:t,onComplete:n}){let r=E(e=>e.mcp.clients),i=le(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function Ee(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(Y,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(Se,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Te,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return process.env.USER_TYPE===`ant`?(0,$.jsx)(ve,{onComplete:e,args:`manage`,showMcpRedirectMessage:!0}):(0,$.jsx)(Y,{onComplete:e})}var Q,$;e((()=>{Q=t(f(),1),we(),J(),N(),T(),he(),$=h()}))();export{Ee as call};
@@ -1,5 +1,5 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./p-map-HKDr3iDo.js";import{D as r,H as i,I as a,P as o,T as s,fi as c,j as ee,kn as l,t as u,y as te}from"./src-CDCSSo0U2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as f,D_ as p,G_ as m,HS as h,I_ as g,O_ as ne,Ob as re,Qg as _,R_ as v,Sx as y,US as b,V_ as x,Xg as ie,Zg as ae,__ as S,ag as oe,cC as C,dg as se,g_ as w,gx as T,hx as E,j_ as D,kb as O,lg as k,oC as A,r_ as j,t_ as M,xx as N,z_ as P}from"./loadAgentsDir-Clu7Uk6a.js";import{H as F,z as I}from"./debug-BrXObCdR.js";import{c as L,g as R,o as z,y as B}from"./config-3m_9zSrj.js";import{n as V,o as H}from"./process-gEbdy6uY.js";import{i as U,o as W}from"./platform-BrYefG_2.js";import{s as ce,u as G}from"./types-C-MRCL8J.js";import{n as le,r as K}from"./analytics-BotDBGh0.js";import{l as q,o as ue}from"./stringUtils-DGLPkqJ4.js";import{n as J,t as Y}from"./exit-BOhGfSlm.js";import{stat as de}from"fs/promises";import{cwd as fe}from"process";n();var X=e(c(),1);C(),V(),u(),x(),ue(),y(),T();var Z=d();function pe({servers:e,scope:t,onDone:n}){let c=Object.keys(e),[l,u]=(0,X.useState)({});(0,X.useEffect)(()=>{g().then(({servers:e})=>u(e))},[]);let d=c.filter(e=>l[e]!==void 0);async function f(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(l[e]!==void 0){let t=1;for(;l[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await D(e,n,t),r++}}m(r)}let[p]=i(),m=(0,X.useCallback)(e=>{H(e>0?`\n${ee(`success`,p)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
- No servers were imported.`),n(),A()},[p,t,n]),h=(0,X.useCallback)(()=>{m(0)},[m]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(te,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${c.length} MCP ${q(c.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:h,hideInputGuide:!0,children:[d.length>0&&(0,Z.jsx)(o,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Z.jsx)(o,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(E,{options:c.map(e=>({label:`${e}${d.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:c.filter(e=>!d.includes(e)),onSubmit:f,onCancel:h,hideIndexes:!0})]}),(0,Z.jsx)(a,{paddingX:1,children:(0,Z.jsx)(o,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(r,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(r,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}u(),O(),le(),f(),se(),x(),ne(),b(),R(),I(),C(),ce(),W();async function Q(e,t){try{let n=await oe(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function me({debug:e,verbose:t}){let n=fe();K(`tengu_mcp_start`,{});try{await de(n)}catch(e){throw F(e)&&Y(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-UI9uv2-K.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-CwIYauZl.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,t){let n=v(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(ae(e,n),ie(e,n))};try{if(t.scope){let n=S(t.scope);K(`tengu_mcp_delete`,{name:e,scope:n}),await m(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),J(`File modified: ${w(n)}`)}let n=z(),i=L(),{servers:a}=P(`project`),o=!!a[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),i.mcpServers?.[e]&&s.push(`user`),s.length===0)Y(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await m(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${w(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${p(e)} (${w(e)})\n`)}),process.stderr.write(`
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./p-map-HKDr3iDo.js";import{D as r,H as i,I as a,P as o,T as s,fi as c,j as ee,kn as l,t as u,y as te}from"./src-CDCSSo0U2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as f,D_ as p,G_ as m,HS as h,I_ as g,O_ as ne,Ob as re,Qg as _,R_ as v,Sx as y,US as b,V_ as x,Xg as ie,Zg as ae,__ as S,ag as oe,cC as C,dg as se,g_ as w,gx as T,hx as E,j_ as D,kb as O,lg as k,oC as A,r_ as j,t_ as M,xx as N,z_ as P}from"./loadAgentsDir-D206qwP3.js";import{H as F,z as I}from"./debug-BrXObCdR.js";import{c as L,g as R,o as z,y as B}from"./config-DmomySWC.js";import{n as V,o as H}from"./process-gEbdy6uY.js";import{i as U,o as W}from"./platform-BrYefG_2.js";import{s as ce,u as G}from"./types-C-MRCL8J.js";import{n as le,r as K}from"./analytics-BotDBGh0.js";import{l as q,o as ue}from"./stringUtils-DGLPkqJ4.js";import{n as J,t as Y}from"./exit-BOhGfSlm.js";import{stat as de}from"fs/promises";import{cwd as fe}from"process";n();var X=e(c(),1);C(),V(),u(),x(),ue(),y(),T();var Z=d();function pe({servers:e,scope:t,onDone:n}){let c=Object.keys(e),[l,u]=(0,X.useState)({});(0,X.useEffect)(()=>{g().then(({servers:e})=>u(e))},[]);let d=c.filter(e=>l[e]!==void 0);async function f(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(l[e]!==void 0){let t=1;for(;l[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await D(e,n,t),r++}}m(r)}let[p]=i(),m=(0,X.useCallback)(e=>{H(e>0?`\n${ee(`success`,p)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
+ No servers were imported.`),n(),A()},[p,t,n]),h=(0,X.useCallback)(()=>{m(0)},[m]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(te,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${c.length} MCP ${q(c.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:h,hideInputGuide:!0,children:[d.length>0&&(0,Z.jsx)(o,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Z.jsx)(o,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(E,{options:c.map(e=>({label:`${e}${d.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:c.filter(e=>!d.includes(e)),onSubmit:f,onCancel:h,hideIndexes:!0})]}),(0,Z.jsx)(a,{paddingX:1,children:(0,Z.jsx)(o,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(r,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(r,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}u(),O(),le(),f(),se(),x(),ne(),b(),R(),I(),C(),ce(),W();async function Q(e,t){try{let n=await oe(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function me({debug:e,verbose:t}){let n=fe();K(`tengu_mcp_start`,{});try{await de(n)}catch(e){throw F(e)&&Y(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-B_FOvNpp.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-W0LFoyFR.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,t){let n=v(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(ae(e,n),ie(e,n))};try{if(t.scope){let n=S(t.scope);K(`tengu_mcp_delete`,{name:e,scope:n}),await m(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),J(`File modified: ${w(n)}`)}let n=z(),i=L(),{servers:a}=P(`project`),o=!!a[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),i.mcpServers?.[e]&&s.push(`user`),s.length===0)Y(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await m(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${w(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${p(e)} (${w(e)})\n`)}),process.stderr.write(`
3
3
  To remove from a specific scope, use:
4
4
  `),s.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),Y()}catch(e){Y(e.message)}}async function ge(){K(`tengu_mcp_list`,{});let{servers:e}=await g();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
5
  `);let n=await t(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:k()});for(let{name:e,server:t,status:r}of n)if(t.type===`sse`)console.log(`${e}: ${t.url} (SSE) - ${r}`);else if(t.type===`http`)console.log(`${e}: ${t.url} (HTTP) - ${r}`);else if(t.type===`claudeai-proxy`)console.log(`${e}: ${t.url} - ${r}`);else if(!t.type||t.type===`stdio`){let n=t,i=Array.isArray(n.args)?n.args:[];console.log(`${e}: ${n.command} ${i.join(` `)} - ${r}`)}}await A(0)}async function $(e){K(`tengu_mcp_get`,{name:e});let t=v(e);t||Y(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${p(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),_(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),_(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await A(0)}async function _e(e,t,n){try{let r=S(n.scope),i=G(t),a=n.clientSecret&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&`oauth`in i&&i.oauth&&typeof i.oauth==`object`&&`clientId`in i.oauth?await M():void 0;await D(e,i,r);let o=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;a&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&j(e,{type:i.type,url:i.url},a),K(`tengu_mcp_add`,{scope:r,source:`json`,type:o}),J(`Added ${o} MCP server ${e} to ${r} config`)}catch(e){Y(e.message)}}async function ve(e){try{let t=S(e.scope);K(`tengu_mcp_add`,{scope:t,platform:U(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-Cx31Ugjp.js`),r=await n();Object.keys(r).length===0&&J(`No MCP servers found in Claude Desktop configuration or configuration file does not exist.`);let{unmount:i}=await l((0,Z.jsx)(h,{children:(0,Z.jsx)(re,{children:(0,Z.jsx)(pe,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){Y(e.message)}}async function ye(){K(`tengu_mcp_reset_mcpjson_choices`,{}),B(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),J(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
@@ -1,2 +1,2 @@
1
- import{$v as e,Av as t,Cv as n,Dv as r,Ev as i,Fv as a,G as o,Gp as s,Gv as ee,Gw as c,Hv as l,Ia as u,Iv as d,Jv as f,Kv as p,La as m,Lv as h,Mv as te,Nv as g,Ov as ne,Pv as _,Qv as v,Rd as y,Sv as b,Tv as x,Uv as S,Vv as C,W as w,Wp as T,Wv as E,Ww as D,Xu as O,Yu as k,Yv as A,aw as j,ay as M,iw as N,iy as P,jv as F,kv as I,nl as L,ny as R,po as z,qv as B,ry as re,tl as V,ty as H,wv as U,zd as W,zo as G,zv as K}from"./loadAgentsDir-Clu7Uk6a.js";import{S as q,w as J}from"./debug-BrXObCdR.js";import{o as Y,s as X}from"./log-BMCygSzM.js";import{_ as ie,u as ae}from"./model-BQF64tZx.js";import{Cn as oe,Tn as se,wn as Z}from"./prompt-Bg_1U0gO.js";import{a as Q,o as ce}from"./fileStateCache-DDW5toIs.js";import $ from"node:process";re(),F(),I(),H();var le=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},a,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},K,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)}};H(),r();var ue=class extends t{constructor(t,n){super(n),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(f.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=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new ne,this.setRequestHandler(S,e=>this._oninitialize(e)),this.setNotificationHandler(E,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(e,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=f.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new le(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=te(this._capabilities,e)}setRequestHandler(e,t){let n=R(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(P(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=M(g,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new A(l.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=M(h,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new A(l.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=M(_,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new A(l.InvalidParams,`Invalid tools/call result: ${e}`)}return o.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){x(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&i(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:v.includes(t)?t:ee,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`},C)}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},d,t):this.request({method:`sampling/createMessage`,params:e},a,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},K,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},K,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new A(l.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof A?e:new A(l.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},p,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`})}};n();var de=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new b,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=U(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};H(),j(),u(),se(),O(),c(),ce(),Y(),G(),ie(),o(),T(),q(),W(),V();var fe=[m];async function pe(e,t,n){let r=Q(100);s(e);let i=new ue({name:`claude/tengu`,version:`0.0.5`},{capabilities:{tools:{}}});i.setRequestHandler(B,async()=>{let e=Z(),t=k(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=L(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:L(n.inputSchema),outputSchema:r}}))}}),i.setRequestHandler(g,async({params:{name:e,arguments:i}})=>{let a=k(Z()),o=oe(a,e);if(!o)throw Error(`Tool ${e} not found`);let s={abortController:D(),options:{commands:fe,tools:a,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:n,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>N(),setAppState:()=>{},messages:[],readFileState:r,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!o.isEnabled())throw Error(`Tool ${e} is not enabled`);let t=await o.validateInput?.(i??{},s);if(t&&!t.result)throw Error(`Tool ${e} input is invalid: ${`message`in t?t.message:String(t)}`);let n=await o.call(i??{},s,w,z({content:[]}));return{content:[{type:`text`,text:typeof n==`string`?n:J(n.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?y(e):[String(e)]).filter(Boolean).join(`
1
+ import{$v as e,Av as t,Cv as n,Dv as r,Ev as i,Fv as a,G as o,Gp as s,Gv as ee,Gw as c,Hv as l,Ia as u,Iv as d,Jv as f,Kv as p,La as m,Lv as h,Mv as te,Nv as g,Ov as ne,Pv as _,Qv as v,Rd as y,Sv as b,Tv as x,Uv as S,Vv as C,W as w,Wp as T,Wv as E,Ww as D,Xu as O,Yu as k,Yv as A,aw as j,ay as M,iw as N,iy as P,jv as F,kv as I,nl as L,ny as R,po as z,qv as B,ry as re,tl as V,ty as H,wv as U,zd as W,zo as G,zv as K}from"./loadAgentsDir-D206qwP3.js";import{S as q,w as J}from"./debug-BrXObCdR.js";import{o as Y,s as X}from"./log-BMCygSzM.js";import{_ as ie,u as ae}from"./model-CKkOnnnx.js";import{Cn as oe,Tn as se,wn as Z}from"./prompt-BNHtszmZ.js";import{a as Q,o as ce}from"./fileStateCache-DDW5toIs.js";import $ from"node:process";re(),F(),I(),H();var le=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},a,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},K,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)}};H(),r();var ue=class extends t{constructor(t,n){super(n),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(f.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=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new ne,this.setRequestHandler(S,e=>this._oninitialize(e)),this.setNotificationHandler(E,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(e,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=f.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new le(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=te(this._capabilities,e)}setRequestHandler(e,t){let n=R(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(P(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=M(g,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new A(l.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=M(h,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new A(l.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=M(_,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new A(l.InvalidParams,`Invalid tools/call result: ${e}`)}return o.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){x(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&i(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:v.includes(t)?t:ee,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`},C)}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},d,t):this.request({method:`sampling/createMessage`,params:e},a,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},K,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},K,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new A(l.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof A?e:new A(l.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},p,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`})}};n();var de=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new b,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=U(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};H(),j(),u(),se(),O(),c(),ce(),Y(),G(),ie(),o(),T(),q(),W(),V();var fe=[m];async function pe(e,t,n){let r=Q(100);s(e);let i=new ue({name:`claude/tengu`,version:`0.0.6`},{capabilities:{tools:{}}});i.setRequestHandler(B,async()=>{let e=Z(),t=k(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=L(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:L(n.inputSchema),outputSchema:r}}))}}),i.setRequestHandler(g,async({params:{name:e,arguments:i}})=>{let a=k(Z()),o=oe(a,e);if(!o)throw Error(`Tool ${e} not found`);let s={abortController:D(),options:{commands:fe,tools:a,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:n,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>N(),setAppState:()=>{},messages:[],readFileState:r,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!o.isEnabled())throw Error(`Tool ${e} is not enabled`);let t=await o.validateInput?.(i??{},s);if(t&&!t.result)throw Error(`Tool ${e} input is invalid: ${`message`in t?t.message:String(t)}`);let n=await o.call(i??{},s,w,z({content:[]}));return{content:[{type:`text`,text:typeof n==`string`?n:J(n.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?y(e):[String(e)]).filter(Boolean).join(`
2
2
  `).trim()||`Error`}]}}});async function a(){let e=new de;await i.connect(e)}return await a()}export{pe as startMCPServer};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,di as l,fi as u,t as d,ui as ee,y as f}from"./src-CDCSSo0U2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{en as m,nt as h}from"./state-ix0xIunV.js";import{IE as g,US as _,Un as v,VE as y,Vn as te,WS as b,au as x,fx as S,hf as ne,mf as C,ou as re,px as ie,zE as w}from"./loadAgentsDir-Clu7Uk6a.js";import{n as T,t as E}from"./cwd-CYmmnQVS.js";import{I as D,z as O}from"./debug-BrXObCdR.js";import{g as k,y as A}from"./settings-Dlp5JTa_.js";import{I as j,P as M,j as ae}from"./config-3m_9zSrj.js";import{_ as N,r as P}from"./git-Do0wJvux.js";import{o as F,s as I}from"./log-BMCygSzM.js";import{f as L,l as oe}from"./file-DcZWPH2V.js";import{n as se,r as R}from"./analytics-BotDBGh0.js";import{b as ce,h as z}from"./startupProfiler-xa3NmN7Z.js";import{u as B}from"./referral-BlrMpBAV.js";import{r as V,t as H}from"./browser-BmZuQom6.js";import{n as U,t as W}from"./useExitOnCtrlCDWithKeybindings-CntByfTQ.js";import{r as le,t as ue}from"./promptEditor-BhYDmwdS.js";import{homedir as de}from"os";import{join as G,relative as fe}from"path";import{mkdir as K,writeFile as pe}from"fs/promises";function me(e){return P(e)!==null}var he=e((()=>{N()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(w()),a=G(n(),`CLAUDE.md`),l=G(h(),`CLAUDE.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=oe(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),g=[],_=b(e=>e.agentDefinitions);if(j()){g.push({label:`Open auto-memory folder`,value:`${X}${ae()}`,description:``});for(let e of _.activeAgents)if(e.memory){let t=te(e.agentType,e.memory);g.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(...g);let v=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[y,x]=(0,q.useState)(j),[S,C]=(0,q.useState)(re),[T]=(0,q.useState)(j),E=b(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[D,O]=(0,q.useState)(null);(0,q.useEffect)(()=>{T&&ne().then(O)},[T,E]);let k=E?`running`:D===null?``:D===0?`never`:`last ran ${z(new Date(D))}`,[M,N]=(0,q.useState)(null),P=M!==null,F=+!!T;function I(){let e=!y;A(`userSettings`,{autoMemoryEnabled:e}),x(e),R(`tengu_auto_memory_toggled`,{enabled:e})}function L(){let e=!S;A(`userSettings`,{autoDreamEnabled:e}),C(e),R(`tengu_auto_dream_toggled`,{enabled:e})}return U(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{M===0?I():M===1&&L()},{context:`Confirmation`,isActive:P}),s(`select:next`,()=>{N(e=>e!==null&&e<F?e+1:null)},{context:`Select`,isActive:P}),s(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:P}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:M===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,y?`on`:`off`]})}),T&&(0,J.jsx)(c,{isFocused:M===1,styled:!1,children:(0,J.jsxs)(o,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,S?`on`:`off`,k&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,k]}),!E&&S&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(ie,{defaultFocusValue:v,options:m,isDisabled:P,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>V(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(F)})]})}var q,J,Y,X,_e=e((()=>{l(),u(),q=t(u(),1),m(),W(),d(),B(),M(),se(),x(),C(),_(),v(),H(),y(),r(),L(),ce(),he(),k(),S(),J=p(),X=`__open_folder__`}));function ve(e){let t=de(),n=E(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+fe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{u(),d(),T(),p()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(D(e)!==`EEXIST`)throw e}await ue(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 ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){I(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(u(),1),d(),_e(),ye(),y(),r(),O(),F(),le(),Q=p(),$=async e=>(g(),await w(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,di as l,fi as u,t as d,ui as ee,y as f}from"./src-CDCSSo0U2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{en as m,nt as h}from"./state-ix0xIunV.js";import{IE as g,US as _,Un as v,VE as y,Vn as te,WS as b,au as x,fx as S,hf as ne,mf as C,ou as re,px as ie,zE as w}from"./loadAgentsDir-D206qwP3.js";import{n as T,t as E}from"./cwd-CYmmnQVS.js";import{I as D,z as O}from"./debug-BrXObCdR.js";import{g as k,y as A}from"./settings-BovzmwMP.js";import{I as j,P as M,j as ae}from"./config-DmomySWC.js";import{_ as N,r as P}from"./git-Do0wJvux.js";import{o as F,s as I}from"./log-BMCygSzM.js";import{f as L,l as oe}from"./file-DcZWPH2V.js";import{n as se,r as R}from"./analytics-BotDBGh0.js";import{b as ce,h as z}from"./startupProfiler-xa3NmN7Z.js";import{u as B}from"./referral-CUaIo_vT.js";import{r as V,t as H}from"./browser-BmZuQom6.js";import{n as U,t as W}from"./useExitOnCtrlCDWithKeybindings-DKIqRraH.js";import{r as le,t as ue}from"./promptEditor-DeMrXUir.js";import{homedir as de}from"os";import{join as G,relative as fe}from"path";import{mkdir as K,writeFile as pe}from"fs/promises";function me(e){return P(e)!==null}var he=e((()=>{N()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(w()),a=G(n(),`CLAUDE.md`),l=G(h(),`CLAUDE.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=oe(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),g=[],_=b(e=>e.agentDefinitions);if(j()){g.push({label:`Open auto-memory folder`,value:`${X}${ae()}`,description:``});for(let e of _.activeAgents)if(e.memory){let t=te(e.agentType,e.memory);g.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(...g);let v=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[y,x]=(0,q.useState)(j),[S,C]=(0,q.useState)(re),[T]=(0,q.useState)(j),E=b(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[D,O]=(0,q.useState)(null);(0,q.useEffect)(()=>{T&&ne().then(O)},[T,E]);let k=E?`running`:D===null?``:D===0?`never`:`last ran ${z(new Date(D))}`,[M,N]=(0,q.useState)(null),P=M!==null,F=+!!T;function I(){let e=!y;A(`userSettings`,{autoMemoryEnabled:e}),x(e),R(`tengu_auto_memory_toggled`,{enabled:e})}function L(){let e=!S;A(`userSettings`,{autoDreamEnabled:e}),C(e),R(`tengu_auto_dream_toggled`,{enabled:e})}return U(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{M===0?I():M===1&&L()},{context:`Confirmation`,isActive:P}),s(`select:next`,()=>{N(e=>e!==null&&e<F?e+1:null)},{context:`Select`,isActive:P}),s(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:P}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:M===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,y?`on`:`off`]})}),T&&(0,J.jsx)(c,{isFocused:M===1,styled:!1,children:(0,J.jsxs)(o,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,S?`on`:`off`,k&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,k]}),!E&&S&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(ie,{defaultFocusValue:v,options:m,isDisabled:P,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>V(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(F)})]})}var q,J,Y,X,_e=e((()=>{l(),u(),q=t(u(),1),m(),W(),d(),B(),M(),se(),x(),C(),_(),v(),H(),y(),r(),L(),ce(),he(),k(),S(),J=p(),X=`__open_folder__`}));function ve(e){let t=de(),n=E(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+fe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{u(),d(),T(),p()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(D(e)!==`EEXIST`)throw e}await ue(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 ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){I(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(u(),1),d(),_e(),ye(),y(),r(),O(),F(),le(),Q=p(),$=async e=>(g(),await w(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -1,2 +1,2 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{dt as s,ft as c,mt as l,mx as u,pt as d,px as f}from"./loadAgentsDir-Clu7Uk6a.js";function p({onDone:e}){let t=d(),i=s(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){l(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function c(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:i,options:a,onChange:o,onCancel:c,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),u(),c(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=d(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{dt as s,ft as c,mt as l,mx as u,pt as d,px as f}from"./loadAgentsDir-D206qwP3.js";function p({onDone:e}){let t=d(),i=s(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){l(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function c(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:i,options:a,onChange:o,onCancel:c,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),u(),c(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=d(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
2
  `)}`,{display:`system`});return}l(r),e(`${n.icon} Mode switched to: ${n.name} (${n.slug}) — ${n.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{di as n,fi as r,ui as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Ad as o,KS as s,US as c,WS as l,gh as u,hh as d,kd as f,mh as p}from"./loadAgentsDir-Clu7Uk6a.js";import{D as m,E as h,Y as g}from"./log-BMCygSzM.js";import{n as _,r as v}from"./analytics-BotDBGh0.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-BQF64tZx.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-C2Ylufhj.js";function I({onDone:e}){let t=l(e=>e.mainLoopModel),n=l(e=>e.mainLoopModelForSession),r=l(e=>e.fastMode),a=s();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${i.bold(n)}`,{display:`system`})}function c(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let o=`Set model to ${i.bold(H(n))}`,s;O()&&(b(),!D(n)&&r?(a(e=>({...e,fastMode:!1})),s=!1):D(n)&&A()&&r&&(o+=` · Fast mode ON`,s=!0)),N(n,s===!0,T())&&(o+=` · Billed as extra usage`),s===!1&&(o+=` · Fast mode OFF`),e(o)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:c,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:O()&&r&&D(t)&&A()})}function L({args:e,onDone:t}){let n=l(e=>e.fastMode),r=s(),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){s(null);return}if(R(a)){s(a);return}try{let{valid:e,error:n}=await o(a);e?s(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function s(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${i.bold(H(e))}`,o;O()&&(b(),!D(e)&&n?(r(e=>({...e,fastMode:!1})),o=!1):D(e)&&n&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,r]),null}function R(e){return C.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!p()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!d()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=l(e=>e.mainLoopModel),n=l(e=>e.mainLoopModelForSession),r=H(t);return e(n?`Current model: ${i.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((()=>{n(),U=t(r(),1),M(),g(),_(),c(),F(),E(),y(),u(),w(),x(),f(),W=a(),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
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{di as n,fi as r,ui as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Ad as o,KS as s,US as c,WS as l,gh as u,hh as d,kd as f,mh as p}from"./loadAgentsDir-D206qwP3.js";import{D as m,E as h,Y as g}from"./log-BMCygSzM.js";import{n as _,r as v}from"./analytics-BotDBGh0.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-CKkOnnnx.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-Dq66zzqR.js";function I({onDone:e}){let t=l(e=>e.mainLoopModel),n=l(e=>e.mainLoopModelForSession),r=l(e=>e.fastMode),a=s();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${i.bold(n)}`,{display:`system`})}function c(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let o=`Set model to ${i.bold(H(n))}`,s;O()&&(b(),!D(n)&&r?(a(e=>({...e,fastMode:!1})),s=!1):D(n)&&A()&&r&&(o+=` · Fast mode ON`,s=!0)),N(n,s===!0,T())&&(o+=` · Billed as extra usage`),s===!1&&(o+=` · Fast mode OFF`),e(o)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:c,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:O()&&r&&D(t)&&A()})}function L({args:e,onDone:t}){let n=l(e=>e.fastMode),r=s(),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){s(null);return}if(R(a)){s(a);return}try{let{valid:e,error:n}=await o(a);e?s(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function s(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${i.bold(H(e))}`,o;O()&&(b(),!D(e)&&n?(r(e=>({...e,fastMode:!1})),o=!1):D(e)&&n&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,r]),null}function R(e){return C.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!p()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!d()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=l(e=>e.mainLoopModel),n=l(e=>e.mainLoopModelForSession),r=H(t);return e(n?`Current model: ${i.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((()=>{n(),U=t(r(),1),M(),g(),_(),c(),F(),E(),y(),u(),w(),x(),f(),W=a(),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};
@@ -0,0 +1 @@
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-DSxRz_kt.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-CDCSSo0U2.js";import{E as ie,M as ae,T as oe,h as se,n as ce,r as le,t as ue}from"./lazySchema-DcIJE_0i.js";import{$ as de,H as fe,Jr as pe,On as me,Sr as he,X as ge,Xn as _e,Yr as ve,_n as ye,en as m,ht as be,pt as xe,qn as Se,sn as Ce,tt as we,xr as Te,y as Ee,z as h}from"./state-ix0xIunV.js";import{C as De,E as Oe,F as g,G as ke,I as Ae,K as je,S as Me,V as Ne,a as _,c as Pe,d as Fe,l as v,p as Ie,s as Le,w as Re,z as ze}from"./debug-BrXObCdR.js";import{Kt as Be,c as y,f as b,g as x,n as Ve,y as He}from"./settings-BovzmwMP.js";import{C as Ue,b as S,c as C,g as We,n as w,w as Ge}from"./config-DmomySWC.js";import{a as Ke,c as qe,i as Je,o as Ye,r as Xe,s as Ze,t as Qe}from"./execFileNoThrow-D244NytW.js";import{d as $e,f as et,o as tt,s as T}from"./log-BMCygSzM.js";import{r as nt,t as rt}from"./memoize-B0zhbT8Z.js";import{s as it,u as at}from"./types-C-MRCL8J.js";import{n as ot,r as E}from"./analytics-BotDBGh0.js";import{l as D,n as st,r as ct,s as lt,t as ut,u as O}from"./oauth-BqJqV-2M.js";import{n as dt,t as ft}from"./bundledMode--fG1S62b.js";import{n as pt,o as mt}from"./stringUtils-DGLPkqJ4.js";import{a as ht,i as gt,l as _t}from"./proxy-CRN7jYIi.js";import{userInfo as vt}from"os";import{join as yt}from"path";import{chmodSync as bt,mkdirSync as xt,readFileSync as St,writeFileSync as Ct}from"fs";import{createHash as wt,randomUUID as Tt}from"crypto";import{mkdir as Et,stat as Dt,writeFile as Ot}from"fs/promises";import{exec as kt,execFile as At}from"child_process";import{AsyncLocalStorage as jt}from"async_hooks";function k(e=Ve()){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 Mt(){return k()}function Nt(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{let t=new URL(e).host,n=[`api.anthropic.com`];return process.env.USER_TYPE===`ant`&&n.push(`api-staging.anthropic.com`),n.includes(t)}catch{return!1}}var A=e((()=>{x(),l()}));function Pt(){return It.getStore()?.workload}function Ft(e,t){return It.run({workload:e},t)}var It,Lt=e((()=>{It=new jt}));function Rt(){return process.env.USER_TYPE,null}function zt(){return process.env.USER_TYPE===`ant`?Rt()?.antModels??[]:[]}function Bt(e){if(process.env.USER_TYPE!==`ant`||e===void 0)return;let t=e.toLowerCase();return zt().find(n=>n.alias===e||t.includes(n.model.toLowerCase()))}var Vt=e((()=>{}));function Ht(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 Ut=e((()=>{}));function Wt(e,t){return e.find(e=>e.includes(t))??null}async function Gt(){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 gt(),...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 W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Kt(){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 gt(),...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 W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function qt(e){return e.startsWith(`anthropic.`)}function Jt(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Yt(e){let t=Jt(e);for(let e of $t)if(t.startsWith(`${e}.anthropic.`))return e}function Xt(e,t){let n=Yt(e);return n?e.replace(`${n}.`,`${t}.`):qt(e)?`${t}.${e}`:e}var Zt,Qt,$t,en=e((()=>{i(),K(),l(),tt(),_t(),Zt=r(async function(){let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([Gt(),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([Gt(),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}}),$t=[`us`,`eu`,`apac`,`global`]})),tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn=e((()=>{tn={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`},nn={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`},rn={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`},an={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`},on={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`},sn={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`},cn={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`},ln={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`},un={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`},dn={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`},fn={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`},pn={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`},mn={haiku35:rn,haiku45:an,sonnet35:nn,sonnet37:tn,sonnet40:on,sonnet45:sn,sonnet46:pn,opus40:cn,opus41:ln,opus45:un,opus46:dn,opus47:fn},Object.values(mn).map(e=>e.firstParty),hn=Object.fromEntries(Object.entries(mn).map(([e,t])=>[t.firstParty,e]))}));function _n(e){let t={};for(let n of Cn)t[n]=mn[n][e];return t}async function vn(){let e=_n(`bedrock`),t;try{t=await Zt()}catch(t){return T(t),e}if(!t?.length)return e;let n={};for(let r of Cn){let i=mn[r].firstParty;n[r]=Wt(t,i)||e[r]}return n}function yn(e){let t=Ve().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=hn[e];t&&r&&(n[t]=r)}return n}function bn(e){let t;try{t=Ve().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function xn(){if(de()===null){if(k()!==`bedrock`){Se(_n(k()));return}wn()}}function j(){let e=de();return e===null?(xn(),yn(_n(k()))):yn(e)}async function Sn(){if(de()===null){if(k()!==`bedrock`){Se(_n(k()));return}await wn()}}var Cn,wn,Tn=e((()=>{m(),tt(),Ut(),x(),en(),gn(),A(),Cn=Object.keys(mn),wn=Ht(async()=>{if(de()===null)try{Se(await vn())}catch(e){T(e)}})}));function En(){if(s(process.env.DISABLE_COST_WARNINGS)||B())return!1;let e=ja(),t=R()!==null;if(!e.hasToken&&!t)return!1;let n=C(),r=n.oauthAccount?.organizationRole,i=n.oauthAccount?.workspaceRole;return!r||!i?!1:[`admin`,`billing`].includes(r)||[`workspace_admin`,`workspace_billing`].includes(i)}function Dn(e){kn=e}function On(){if(kn!==null)return kn;if(!B())return!1;let e=V();if(e===`max`||e===`pro`)return!0;let t=C().oauthAccount?.organizationRole;return!!t&&[`admin`,`billing`,`owner`,`primary_owner`].includes(t)}var kn,An=e((()=>{K(),We(),l(),kn=null}));function jn(){return process.env.USER_TYPE===`ant`?process.env.CLAUDE_MOCK_HEADERLESS_429?process.env.CLAUDE_MOCK_HEADERLESS_429:M?Vn:null:null}function Mn(){return!M||process.env.USER_TYPE!==`ant`||Object.keys(Bn).length===0?null:Bn}function Nn(){Bn={},Gn=[],Hn=null,Un=null,N=null,Vn=null,Dn(null),M=!1}function Pn(e){let t=Mn();if(!t)return e;let n=new globalThis.Headers(e);return Object.entries(t).forEach(([e,t])=>{t!==void 0&&n.set(e,t)}),n}function Fn(){return process.env.USER_TYPE===`ant`?M||!!process.env.CLAUDE_MOCK_HEADERLESS_429:!1}function In(){return!M||process.env.USER_TYPE!==`ant`?null:Hn||Wn}function Ln(){return M&&Hn!==null&&process.env.USER_TYPE===`ant`}function Rn(){return Un!==null}function zn(e){if(Un===null||!e)return null;if(N!==null&&Date.now()>=N)return Nn(),null;N===null&&(N=Date.now()+Un);let t=N-Date.now(),n={...Bn};return n[`retry-after`]=String(Math.max(1,Math.ceil(t/1e3))),n}var Bn,M,Vn,Hn,Un,N,Wn,Gn,Kn=e((()=>{An(),Bn={},M=!1,Vn=null,Hn=null,Un=null,N=null,Wn=`max`}));async function qn(){let e=C().oauthAccount?.accountUuid,t=R();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":lt},params:{account_uuid:e},timeout:1e4})).data}catch(e){T(e)}}async function Jn(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 Yn=e((()=>{p(),O(),K(),We(),tt()}));function Xn(e){return!!e?.includes(st)}function Zn(e){return e?.split(` `).filter(Boolean)??[]}function Qn({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?[st]:ut;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 $n(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 er(e,{scopes:t}={}){let n={grant_type:`refresh_token`,refresh_token:e,client_id:D().CLIENT_ID,scope:(t?.length?t:ct).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=Zn(r.scope);E(`tengu_oauth_token_refresh_success`,{});let l=C(),u=G(),d=l.oauthAccount?.billingType!==void 0&&l.oauthAccount?.accountCreatedAt!==void 0&&l.oauthAccount?.subscriptionCreatedAt!==void 0&&u?.subscriptionType!=null&&u?.rateLimitTier!=null?null:await ir(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&&S(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 tr(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(!C().oauthAccount)throw Error(`OAuth account information not found in config`);S(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 nr(e){try{let t=await f.post(D().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await oo(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 rr(e){return e!==null&&Date.now()+300*1e3>=e}async function ir(e){let t=await Jn(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 ar(){let e=C().oauthAccount?.organizationUuid;if(e)return e;let t=G()?.accessToken;return t===void 0||!yo()?null:(await Jn(t))?.organization?.uuid||null}async function or(){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&&(C().oauthAccount||sr({accountUuid:e,emailAddress:t,organizationUuid:n})),await _o();let i=C();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!B()||!yo())return!1;let a=G();if(a?.accessToken){let e=await Jn(a.accessToken);if(e)return r&&v(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),sr({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 sr({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),S(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 cr=e((()=>{p(),ot(),O(),K(),We(),_(),Yn()}));function lr(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{xt(mr,{recursive:!0,mode:448}),Ct(e,t,{encoding:`utf8`,mode:384}),v(`Persisted ${n} to ${e} for subprocess access`)}catch(e){v(`Failed to persist ${n} to disk (non-fatal): ${g(e)}`,{level:`error`})}}function ur(e,t){try{let n=Fe().readFileSync(e,{encoding:`utf8`}).trim();return n?(v(`Read ${t} from well-known file ${e}`),n):null}catch(n){return Ne(n)||v(`Failed to read ${t} from ${e}: ${g(n)}`,{level:`debug`}),null}}function dr({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=ur(t,n);return i(e),e}let s=parseInt(o,10);if(Number.isNaN(s))return v(`${e} must be a valid file descriptor number, got: ${o}`,{level:`error`}),i(null),null;try{let e=Fe(),r=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${s}`:`/proc/self/fd/${s}`,a=e.readFileSync(r,{encoding:`utf8`}).trim();return a?(v(`Successfully read ${n} from file descriptor ${s}`),i(a),lr(t,a,n),a):(v(`File descriptor contained empty ${n}`,{level:`error`}),i(null),null)}catch(e){v(`Failed to read ${n} from file descriptor ${s}: ${g(e)}`,{level:`error`});let r=ur(t,n);return i(r),r}}function fr(){return dr({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:hr,label:`OAuth token`,getCached:we,setCached:_e})}function pr(){return dr({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:gr,label:`API key`,getCached:Ee,setCached:ye})}var mr,hr,gr,_r,vr=e((()=>{m(),_(),l(),ze(),Ie(),mr=`/home/claude/.claude/remote`,hr=`${mr}/.oauth_token`,gr=`${mr}/.api_key`,_r=`${mr}/.session_ingress_token`}));function P(e=``){let t=c(),n=process.env.CLAUDE_CONFIG_DIR?`-${wt(`sha256`).update(t).digest(`hex`).substring(0,8)}`:``;return`Claude Code${D().OAUTH_FILE_SUFFIX}${e}${n}`}function yr(){try{return process.env.USER||vt().username}catch{return`claude-code-user`}}function F(){I.cache={data:null,cachedAt:0},I.generation++,I.readInFlight=null}function br(e){if(I.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}I.cache={data:t,cachedAt:Date.now()}}var xr,I,Sr=e((()=>{O(),l(),xr=`-credentials`,I={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function Cr(){if(process.platform===`darwin`&&(await Ye(`security delete-generic-password -a $USER -s "${P()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function wr(e){return e.slice(-20)}var Tr=e((()=>{qe(),Sr()}));function Er(e){return e?.name===`CredentialsProviderError`}function Dr(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 Or(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function kr(){try{v(`Clearing AWS credential provider cache`);let{fromIni:e}=await import(`./dist-es-CIULjvtA2.js`);await e({ignoreCache:!0})(),v(`AWS credential provider cache refreshed`)}catch{v(`Failed to clear AWS credential cache (this is expected if no credentials are configured)`)}}var Ar=e((()=>{_()})),jr,Mr=e((()=>{he(),ee(),jr=class e{constructor(){te(this,`status`,{isAuthenticating:!1,output:[]}),te(this,`changed`,Te()),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(jr,`instance`,null)})),Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr=e((()=>{Nr=`claude-code-20250219`,Pr=`interleaved-thinking-2025-05-14`,Fr=`context-1m-2025-08-07`,Ir=`context-management-2025-06-27`,Lr=`structured-outputs-2025-12-15`,Rr=`tool-search-tool-2025-10-19`,zr=`task-budgets-2026-03-13`,Br=`prompt-caching-scope-2026-01-05`,Vr=`fast-mode-2026-02-01`,Hr=`redact-thinking-2026-02-12`,Ur=`afk-mode-2026-01-31`,Wr=process.env.USER_TYPE===`ant`?`cli-internal-2026-02-09`:``,Gr=`advisor-tool-2026-03-01`,Kr=new Set([Pr,Fr,Rr]),qr=new Set([Nr,Pr,Ir])}));function Yr(e,t){return pe(e,t)}var Xr=e((()=>{ve()}));function Zr(){return`claude-code/0.0.6`}var Qr=e((()=>{}));function $r(){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=Pt(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.6 (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function ei(){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.6${e.length>0?` (${e.join(`, `)})`:``}`}function ti(){return`Claude-User (${Zr()}; +https://support.anthropic.com/)`}function ni(){if(B()){let e=G();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":lt}}:{headers:{},error:`No OAuth token available`}}let e=R();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function ri(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=G()?.accessToken;if(!i)throw n;return await mo(i),await e()}}var ii=e((()=>{p(),O(),K(),Qr(),Lt()}));function ai(){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 oi({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=ci(),te={"x-app":`cli`,"User-Agent":$r(),"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}:{}};v(`[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`),v(`[API:auth] OAuth token check starting`),await _o(),v(`[API:auth] OAuth token check complete`),B()||await si(te,h());let f=li(i,a),p={defaultHeaders:te,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:ht({forAnthropicAPI:!0}),...f&&{fetch:f}};if(s(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-DxE_mHFI.js`),t=r===fc()&&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},...Le()&&{logger:ai()}};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 W();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},...Le()&&{logger:ai()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await Ko();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,...Le()&&{logger:ai()}})}return new je({apiKey:B()?null:e||R(),authToken:B()?G()?.accessToken:void 0,...process.env.USER_TYPE===`ant`&&s(process.env.USE_STAGING_OAUTH)?{baseURL:D().BASE_API_URL}:{},...p,...Le()&&{logger:ai()}})}async function si(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await Va(t);n&&(e.Authorization=`Bearer ${n}`)}function ci(){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 li(e,t){let n=e??globalThis.fetch,r=k()===`firstParty`&&Nt();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(ui,Tt());try{let n=e instanceof Request?e.url:String(e),r=a.get(ui);v(`[API REQUEST] ${new URL(n).pathname}${r?` ${ui}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var ui,di=e((()=>{ke(),K(),ii(),$(),A(),_t(),m(),O(),_(),l(),ui=`x-client-request-id`}));function fi(){return yt(c(),`cache`)}function pi(){return yt(fi(),`model-capabilities.json`)}function mi(){return!(k()!==`firstParty`||!Nt())}function hi(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function gi(e){if(!mi())return;let t=bi(pi());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 _i(){if(mi()&&!et())try{let e=await oi({maxRetries:1}),t=B()?[lt]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=vi().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=pi(),i=hi(n);if(Yr(bi(r),i)){v(`[modelCapabilities] cache unchanged, skipping write`);return}await Et(fi(),{recursive:!0}),await Ot(r,Re({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),bi.cache.delete(r),v(`[modelCapabilities] cached ${i.length} models`)}catch(e){v(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var vi,yi,bi,xi=e((()=>{Xr(),i(),le(),O(),di(),K(),_(),l(),it(),ue(),$e(),Me(),A(),vi=ce(()=>ie({id:ae(),max_input_tokens:oe().optional(),max_tokens:oe().optional()}).strip()),yi=ce(()=>ie({models:se(vi()),timestamp:oe()})),bi=r(e=>{try{let t=St(e,`utf-8`),n=yi().safeParse(at(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function Si(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function L(e){return!Si()&&/\[1m\]/i.test(e)}function Ci(e){if(Si())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function wi(e,t){if(process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS){let e=parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS,10);if(!isNaN(e)&&e>0)return e}if(L(e))return 1e6;let n=gi(e);if(n?.max_input_tokens&&n.max_input_tokens>=1e5)return n.max_input_tokens>2e5&&Si()?ki:n.max_input_tokens;if(t?.includes(`context-1m-2025-08-07`)&&Ci(e)||Ti(e))return 1e6;if(process.env.USER_TYPE===`ant`){let t=Bt(e);if(t?.contextWindow)return t.contextWindow}return ki}function Ti(e){return Si()||L(e)||!Z(e).includes(`sonnet-4-6`)?!1:C().clientDataCache?.coral_reef_sonnet===`true`}function Ei(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 Di(e){let t,n;if(process.env.USER_TYPE===`ant`){let r=Bt(e.toLowerCase());if(r)return t=r.defaultMaxTokens??ji,n=r.upperMaxTokensLimit??Mi,{default:t,upperLimit:n}}let r=Z(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=ji,n=Mi);let i=gi(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function Oi(e){return Di(e).upperLimit-1}var ki,Ai,ji,Mi,Ni,Pi=e((()=>{Jr(),We(),l(),$(),Vt(),xi(),ki=2e5,Ai=2e4,ji=32e3,Mi=64e3,Ni=8e3})),Fi,Ii,Li,Ri=e((()=>{i(),A(),Fi=[{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`}],Ii=[{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`}],Li=r((e,t)=>{if(k()===`firstParty`)return;let n=e.toLowerCase(),r=k()===`openai`?Ii:Fi;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 zi(e){let t=[],n=[];for(let r of e)Yi.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function Bi(e){if(!e||e.length===0)return;if(B()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=zi(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 Vi(e){let t=Li(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Z(e),r=k();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function Hi(e){let t=Z(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 Ui(e){let t=Z(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 Wi(e){return!0}function Gi(){return(k()===`firstParty`||k()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&Nt()}function Ki(){return k()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function qi(e,t){let n=[...Zi(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(Nr),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Wr&&!n.includes(Wr)&&n.push(Wr));let r=xe();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function Ji(){Xi.cache?.clear?.(),Zi.cache?.clear?.(),Qi.cache?.clear?.()}var Yi,Xi,Zi,Qi,$i=e((()=>{i(),m(),Jr(),O(),K(),Pi(),l(),$(),Ri(),A(),x(),Yi=[Fr],Xi=r(e=>{let t=[],n=Z(e).includes(`haiku`);k();let r=Gi();n||(t.push(Nr),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Wr&&t.push(Wr)),B()&&t.push(lt),L(e)&&t.push(Fr),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&Vi(e)&&t.push(Pr),r&&Vi(e)&&!h()&&Ve().showThinkingSummaries!==!0&&t.push(Hr);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||Hi(e),a=Hi(e);return Gi()&&(i||a)&&t.push(Ir),r&&Ui(e),process.env.USER_TYPE,r&&t.push(Br),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),Zi=r(e=>{let t=Xi(e);return k()===`bedrock`?t.filter(e=>!Kr.has(e)):t}),Qi=r(e=>Xi(e).filter(e=>Kr.has(e)))}));function ea(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 ta=e((()=>{}));async function na(){try{let e=P(xr),{stdout:t,code:n}=await Qe(`security`,[`find-generic-password`,`-a`,yr(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return De(t.trim())}catch{}return null}function ra(){if(oa!==void 0)return oa;if(process.platform!==`darwin`)return oa=!1,!1;try{oa=Ze(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{oa=!1}return oa}var ia,aa,oa,sa=e((()=>{qe(),_(),Xe(),Ke(),Me(),Sr(),ia=4032,aa={name:`keychain`,read(){let e=I.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=P(xr),t=Je(`security find-generic-password -a "${yr()}" -w -s "${e}"`);if(t){let e=De(t);return I.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(I.cache={data:null,cachedAt:Date.now()},null):(v(`[keychain] read failed; serving stale cache`,{level:`warn`}),I.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=I.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(I.readInFlight)return I.readInFlight;let t=I.generation,n=na().then(n=>{if(t===I.generation){n===null&&e.data!==null&&v(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return I.cache={data:t,cachedAt:Date.now()},I.readInFlight=null,t}return n});return I.readInFlight=n,n},update(e){F();try{let t=P(xr),n=yr(),r=Re(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<=ia?o=Ze(`security`,[`-i`],{input:a,stdio:[`pipe`,`pipe`,`pipe`],reject:!1}):(v(`Keychain payload (${r.length}B JSON) exceeds security -i stdin limit; using argv`,{level:`warn`}),o=Ze(`security`,[`add-generic-password`,`-U`,`-a`,n,`-s`,t,`-X`,i],{stdio:[`ignore`,`pipe`,`pipe`],reject:!1})),o.exitCode===0?(I.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){F();try{let e=P(xr);return Je(`security delete-generic-password -a "${yr()}" -s "${e}"`),!0}catch{return!1}}}}));function ca(){let e=c();return{storageDir:e,storagePath:yt(e,`.credentials.json`)}}var la,ua=e((()=>{l(),ze(),Ie(),Me(),la={name:`plaintext`,read(){let{storagePath:e}=ca();try{return De(Fe().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=ca();try{return De(await Fe().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=ca();try{Fe().mkdirSync(t)}catch(e){if(Ae(e)!==`EEXIST`)throw e}return Oe(n,Re(e),{encoding:`utf8`,flush:!1}),bt(n,384),{success:!0,warning:`Warning: Storing credentials in plaintext.`}}catch{return{success:!1}}},delete(){let{storagePath:e}=ca();try{return Fe().unlinkSync(e),!0}catch(e){return Ae(e)===`ENOENT`}}}}));function da(){return process.platform===`darwin`?ea(aa,la):la}var fa=e((()=>{ta(),sa(),ua()}));function pa(e){return new Promise(t=>{At(`security`,[`find-generic-password`,`-a`,yr(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:va},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function ma(){if(process.platform!==`darwin`||ba||u())return;let e=pa(P(xr)),t=pa(P());ba=Promise.all([e,t]).then(([e,t])=>{e.timedOut||br(e.stdout),t.timedOut||(ya={stdout:t.stdout})})}async function ha(){ba&&await ba}function ga(){return ya}function _a(){ya=null}var va,ya,ba,xa=e((()=>{l(),Sr(),va=1e4,ya=null,ba=null}));function Sa(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 Ca=e((()=>{}));function wa(){return Ea}function Ta(){Ea.clear()}var Ea,Da=e((()=>{Ea=new Map})),Oa=n({calculateApiKeyHelperTTL:()=>za,checkAndRefreshOAuthTokenIfNeeded:()=>_o,checkGcpCredentialsValid:()=>$a,clearApiKeyHelperCache:()=>Ga,clearAwsCredentialsCache:()=>Xa,clearGcpCredentialsCache:()=>no,clearOAuthTokenCache:()=>fo,getAccountInformation:()=>Lo,getAnthropicApiKey:()=>R,getAnthropicApiKeyWithSource:()=>Na,getApiKeyFromApiKeyHelper:()=>Va,getApiKeyFromApiKeyHelperCached:()=>Wa,getApiKeyFromConfigOrMacOSKeychain:()=>qo,getApiKeyHelperElapsedMs:()=>Ba,getAuthTokenSource:()=>ja,getClaudeAIOAuthTokens:()=>G,getClaudeAIOAuthTokensAsync:()=>go,getConfiguredApiKeyHelper:()=>z,getOauthAccountInfo:()=>xo,getOtelHeadersFromHelper:()=>Po,getRateLimitTier:()=>ko,getSubscriptionName:()=>Ao,getSubscriptionType:()=>V,handleOAuth401Error:()=>mo,hasAnthropicApiKeyAuth:()=>Ma,hasOpusAccess:()=>Co,hasProfileScope:()=>yo,is1PApiCustomer:()=>bo,isAnthropicAuthEnabled:()=>Aa,isAwsAuthRefreshFromProjectSettings:()=>Ia,isAwsCredentialExportFromProjectSettings:()=>Ra,isClaudeAISubscriber:()=>B,isConsumerSubscriber:()=>Io,isCustomApiKeyApproved:()=>so,isEnterpriseSubscriber:()=>Do,isGcpAuthRefreshFromProjectSettings:()=>Qa,isMaxSubscriber:()=>wo,isOtelHeadersHelperFromProjectOrLocalSettings:()=>No,isOverageProvisioningAllowed:()=>So,isProSubscriber:()=>Oo,isTeamPremiumSubscriber:()=>Eo,isTeamSubscriber:()=>To,isUsing3PServices:()=>jo,prefetchApiKeyFromApiKeyHelperIfSafe:()=>Ka,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>io,prefetchGcpCredentialsIfSafe:()=>ro,refreshAndGetAwsCredentials:()=>W,refreshAwsAuth:()=>Ja,refreshGcpAuth:()=>to,refreshGcpCredentialsIfNeeded:()=>Ko,removeApiKey:()=>co,saveApiKey:()=>oo,saveOAuthTokensIfNeeded:()=>uo,validateForceLoginOrg:()=>Ro});function ka(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function Aa(){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}=Na({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!ka()||a&&!ka())}function ja(){if(u())return z()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!ka())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(fr())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(z()&&!ka())return{source:`apiKeyHelper`,hasToken:!0};let e=G();return Xn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function R(){let{key:e}=Na();return e}function Ma(){let{key:e,source:t}=Na({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function Na(e={}){if(u())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:z()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:Wa(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(Ce()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=pr();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&&C().customApiKeyResponses?.approved?.includes(wr(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=pr();return n?{key:n,source:`ANTHROPIC_API_KEY`}:z()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:Wa(),source:`apiKeyHelper`}:qo()||{key:null,source:`none`}}function z(){return u()?y(`flagSettings`)?.apiKeyHelper:(b()||{}).apiKeyHelper}function Pa(){let e=z();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function Fa(){return(b()||{}).awsAuthRefresh}function Ia(){let e=Fa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function La(){return(b()||{}).awsCredentialExport}function Ra(){let e=La();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function za(){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;v(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${e}`,{level:`error`})}return zo}function Ba(){let e=U?.startedAt;return e?Date.now()-e:0}async function Va(e){if(!z())return null;let t=za();return H?(Date.now()-H.timestamp<t||U||(U={promise:Ha(e,!1,Bo),startedAt:null}),H.value):(U||(U={promise:Ha(e,!0,Bo),startedAt:Date.now()}),U.promise)}async function Ha(e,t,n){try{let t=await Ua(e);return n===Bo&&t!==null&&(H={value:t,timestamp:Date.now()}),t}catch(e){if(n!==Bo)return` `;let r=e instanceof Error?e.message:String(e);return console.error(re.red(`apiKeyHelper failed: ${r}`)),v(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&H&&H.value!==` `?(H={...H,timestamp:Date.now()},H.value):(H={value:` `,timestamp:Date.now()},` `)}finally{n===Bo&&(U=null)}}async function Ua(e){let t=z();if(!t)return null;if(Pa()&&!w()&&!e)return Pe(`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 Ye(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 Wa(){return H?.value??null}function Ga(){Bo++,H=null,U=null}function Ka(e){Pa()&&!w()||Va(e)}async function qa(){let e=Fa();if(!e)return!1;if(Ia()&&!w()&&!h())return Pe(`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 v(`Fetching AWS caller identity for AWS auth refresh command`),await Or(),v(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return Ja(e)}}function Ja(e){v(`Running AWS auth refresh command`);let t=jr.getInstance();return t.startAuthentication(),new Promise(n=>{let r=kt(e,{timeout:Ho});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),v(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),v(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)v(`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=La();if(!e)return null;if(Ra()&&!w()&&!h())return Pe(`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 v(`Fetching AWS caller identity for credential export command`),await Or(),v(`Fetched AWS caller identity, skipping AWS credential export command`),null}catch{try{v(`Running AWS credential export command`);let t=await Ye(e,{shell:!0,reject:!1});if(t.exitCode!==0||!t.stdout)throw Error(`awsCredentialExport did not return a valid value`);let n=De(t.stdout.trim());if(!Dr(n))throw Error(`awsCredentialExport did not return valid AWS STS output structure`);return v(`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 Xa(){W.cache.clear()}function Za(){return(b()||{}).gcpAuthRefresh}function Qa(){let e=Za();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function $a(){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=Sa(Uo).then(()=>{throw new es(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function eo(){let e=Za();if(!e)return!1;if(Qa()&&!w()&&!h())return Pe(`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(v(`Checking GCP credentials validity for auth refresh`),await $a())return v(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return to(e)}function to(e){v(`Running GCP auth refresh command`);let t=jr.getInstance();return t.startAuthentication(),new Promise(n=>{let r=kt(e,{timeout:Go});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),v(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),v(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)v(`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 no(){Ko.cache.clear()}function ro(){Za()&&(Qa()&&!w()&&!h()||Ko())}function io(){let e=Fa(),t=La();!e&&!t||(Ia()||Ra())&&!w()&&!h()||(W(),j())}function ao(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function oo(e){if(!ao(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await lo();let t=!1;if(process.platform===`darwin`)try{let n=P();await Ye(`security`,[`-i`],{input:`add-generic-password -U -a "${yr()}" -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=wr(e);S(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??[]}}}),qo.cache.clear?.(),_a()}function so(e){let t=C(),n=wr(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function co(){await lo(),S(e=>({...e,primaryApiKey:void 0})),qo.cache.clear?.(),_a()}async function lo(){try{await Cr()}catch(e){T(e)}}function uo(e){if(!Xn(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=da(),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}),G.cache?.clear?.(),Ji(),Ta(),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 fo(){G.cache?.clear?.(),F()}async function po(){try{let{mtimeMs:e}=await Dt(yt(c(),`.credentials.json`));e!==Jo&&(Jo=e,fo())}catch{G.cache?.clear?.()}}function mo(e){let t=Yo.get(e);if(t)return t;let n=ho(e).finally(()=>{Yo.delete(e)});return Yo.set(e,n),n}async function ho(e){fo();let t=await go();return t?.refreshToken?t.accessToken===e?_o(0,!0):(E(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function go(){if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||fr())return G();try{let e=(await da().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}function _o(e=0,t=!1){return e===0&&!t?Xo||(Xo=vo(e,t).finally(()=>{Xo=null}),Xo):vo(e,t)}async function vo(e,t){await po();let n=G();if(!t&&(!n?.refreshToken||!rr(n.expiresAt))||!n?.refreshToken||!Xn(n.scopes))return!1;G.cache?.clear?.(),F();let r=await go();if(!r?.refreshToken||!rr(r.expiresAt))return!1;let i=c();await Et(i,{recursive:!0});let a;try{E(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await Ge(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 Sa(1e3+Math.random()*1e3),vo(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{G.cache?.clear?.(),F();let e=await go();return!e?.refreshToken||!rr(e.expiresAt)?(E(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(E(`tengu_oauth_token_refresh_starting`,{}),uo(await er(e.refreshToken,{scopes:Xn(e.scopes)?void 0:e.scopes})),G.cache?.clear?.(),F(),!0)}catch(e){T(e),G.cache?.clear?.(),F();let t=await go();return t&&!rr(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 B(){return Aa()?Xn(G()?.scopes):!1}function yo(){return G()?.scopes?.includes(`user:profile`)??!1}function bo(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||B())}function xo(){return Aa()?C().oauthAccount:void 0}function So(){let e=xo()?.billingType;return!(!B()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function Co(){let e=V();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function V(){if(Ln())return In();if(!Aa())return null;let e=G();return e?e.subscriptionType??null:null}function wo(){return V()===`max`}function To(){return V()===`team`}function Eo(){return V()===`team`&&ko()===`default_claude_max_5x`}function Do(){return V()===`enterprise`}function Oo(){return V()===`pro`}function ko(){if(!Aa())return null;let e=G();return e?e.rateLimitTier??null:null}function Ao(){switch(V()){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 jo(){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 Mo(){return(b()||{}).otelHeadersHelper}function No(){let e=Mo();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function Po(){let e=Mo();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||$o.toString(),10);if(Zo&&Date.now()-Qo<t)return Zo;if(No()&&!w())return{};try{let t=Je(e,{timeout:3e4})?.toString().trim();if(!t)throw Error(`otelHeadersHelper did not return a valid value`);let n=De(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 Zo=n,Qo=Date.now(),Zo}catch(e){throw T(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${g(e)}`)),e}}function Fo(e){return e===`max`||e===`pro`}function Io(){let e=V();return B()&&e!==null&&Fo(e)}function Lo(){if(k()!==`firstParty`)return;let{source:e}=ja(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:B()?t.subscription=Ao():t.tokenSource=e;let{key:n,source:r}=Na();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=xo()?.organizationName;e&&(t.organization=e)}let i=xo()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function Ro(){if(process.env.ANTHROPIC_UNIX_SOCKET||!Aa())return{valid:!0};let e=y(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await _o();let t=G();if(!t)return{valid:!0};let{source:n}=ja(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await Jn(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 zo,H,U,Bo,Vo,Ho,W,Uo,Wo,Go,Ko,qo,G,Jo,Yo,Xo,Zo,Qo,$o,es,K=e((()=>{ne(),qe(),i(),O(),ot(),Tn(),A(),m(),Kn(),cr(),Yn(),vr(),Tr(),Ar(),Mr(),$i(),We(),_(),l(),ze(),Xe(),Ue(),tt(),rt(),fa(),xa(),Sr(),x(),Ca(),Me(),Da(),zo=300*1e3,H=null,U=null,Bo=0,Vo=3600*1e3,Ho=180*1e3,W=nt(async()=>{let e=await qa(),t=await Ya();return(e||t)&&await kr(),t},Vo),Uo=5e3,Wo=3600*1e3,Go=180*1e3,Ko=nt(async()=>await eo(),Wo),qo=r(()=>{if(u())return null;if(process.platform===`darwin`){let e=ga();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=P();try{let t=Je(`security find-generic-password -a $USER -w -s "${e}"`);if(t)return{key:t,source:`/login managed key`}}catch(e){T(e)}}}let e=C();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),G=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=fr();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=da().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}),Jo=0,Yo=new Map,Xo=null,Zo=null,Qo=0,$o=1740*1e3,es=class extends Error{}}));function q(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function ts(){return q()?rs()===null:!1}function ns(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 · /extra-usage to enable`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function rs(){if(!q())return`Fast mode is not available`;if(dt(),h()&&Ce()&&!fe()&&!y(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return v(`Fast mode unavailable: ${e}`),e}if(k()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return v(`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=G()===null?`api-key`:`oauth`,t=ns(J.reason,e);return v(`Fast mode unavailable: ${t}`),t}return null}function is(){return`opus`+(Dc()?`[1m]`:``)}function as(e){if(!q()||!ts()||!os(e))return!1;let t=Ve();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function os(e){if(!q())return!1;let t=Q(e??Sc());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function ss(){return bs.status===`cooldown`&&Date.now()>=bs.resetAt&&(q()&&!xs&&(v(`Fast mode cooldown expired, re-enabling fast mode`),xs=!0,Cs.emit()),bs={status:`active`}),bs}function cs(e,t){if(!q())return;bs={status:`cooldown`,resetAt:e,reason:t},xs=!1;let n=e-Date.now();v(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),E(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),Ss.emit(e,t)}function ls(){bs={status:`active`}}function us(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},He(`userSettings`,{fastMode:void 0}),S(e=>({...e,penguinModeOrgEnabled:!1})),Os.emit(!1))}function ds(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 · /extra-usage to enable`;default:return`Fast mode disabled · extra usage not available`}}function fs(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function ps(e){let t=ds(e);v(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),E(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),fs(e)||(He(`userSettings`,{fastMode:void 0}),S(e=>({...e,penguinModeOrgEnabled:!1}))),Es.emit(t)}function ms(){return ss().status===`cooldown`}function hs(e,t){let n=q()&&ts()&&!!t&&os(e);return n&&ms()?`cooldown`:n?`on`:`off`}async function gs(e){let t=`${D().BASE_API_URL}/api/claude_code_penguin_mode`,n=`accessToken`in e?{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":lt}:{"x-api-key":e.apiKey};return(await f.get(t,{headers:n})).data}function _s(){if(!q()||J.status!==`pending`)return;let e=process.env.USER_TYPE===`ant`,t=C().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`unknown`}}async function vs(){if(et()||!q())return;if(Ms)return v(`Fast mode prefetch in progress, returning in-flight promise`),Ms;let e=R();if(!(G()?.accessToken&&yo())&&!e){let e=process.env.USER_TYPE===`ant`,t=C().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-js<As){v(`Skipping fast mode prefetch, fetched recently`);return}js=t;let n=async()=>{let t=G(),n=t?.accessToken&&yo()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return gs(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=G()?.accessToken;if(r)await mo(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?C().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||He(`userSettings`,{fastMode:void 0}),S(t=>({...t,penguinModeOrgEnabled:e.enabled})),Os.emit(e.enabled)),v(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){let t=process.env.USER_TYPE===`ant`,n=C().penguinModeOrgEnabled===!0;J=t||n?{status:`enabled`}:{status:`disabled`,reason:`network_error`},v(`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{Ms=null}}return Ms=r(),Ms}var ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,J,Os,ks,As,js,Ms,Ns=e((()=>{p(),O(),m(),ot(),K(),ft(),We(),_(),l(),$(),A(),$e(),x(),he(),ys=`Opus 4.7`,bs={status:`active`},xs=!1,Ss=Te(),Cs=Te(),ws=Ss.subscribe,Ts=Cs.subscribe,Es=Te(),Ds=Es.subscribe,J={status:`pending`},Os=Te(),ks=Os.subscribe,As=3e4,js=0,Ms=null}));function Ps(e){return q()&&e?Gs:Ws}function Fs(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=Z(e);return n===X(dn.firstParty)?Ps(t.speed===`fast`):Ys[n]||(Ls(e,n),Ys[Z(Sc())]??Js)}function Ls(e,t){E(`tengu_unknown_model_cost`,{model:e,shortName:t}),me()}function Rs(e,t){return Fs(Is(e,t),t)}function zs(e,t){return Rs(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function Bs(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function Vs(e){return`${Bs(e.inputTokens)}/${Bs(e.outputTokens)} per Mtok`}var Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs=e((()=>{ot(),m(),Ns(),gn(),$(),Hs={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},Us={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},Ws={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},Gs={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},Ks={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},qs={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},Js=Ws,Ys={[X(rn.firstParty)]:Ks,[X(an.firstParty)]:qs,[X(nn.firstParty)]:Hs,[X(tn.firstParty)]:Hs,[X(on.firstParty)]:Hs,[X(sn.firstParty)]:Hs,[X(pn.firstParty)]:Hs,[X(cn.firstParty)]:Us,[X(ln.firstParty)]:Us,[X(un.firstParty)]:Ws,[X(dn.firstParty)]:Ws}}));function Y(e){return Qs.includes(e)}function Zs(e){return $s.includes(e)}var Qs,$s,ec=e((()=>{Qs=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],$s=[`sonnet`,`opus`,`haiku`]}));function tc(e,t){return e.includes(t)?!0:Y(e)?Q(e).toLowerCase().includes(t):!1}function nc(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function rc(e,t){let n=Y(e)?Q(e).toLowerCase():e;return!!(nc(n,t)||!t.startsWith(`claude-`)&&nc(n,`claude-${t}`))}function ic(e,t){for(let n of t){if(Zs(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 ac(e){let{availableModels:t}=b()||{};if(!t)return!0;if(t.length===0)return!1;let n=bn(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!Zs(n)||!ic(n,r)))return!0;for(let e of r)if(Zs(e)&&!ic(e,r)&&tc(n,e))return!0;if(Y(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!Zs(e)&&Y(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!Zs(e)&&!Y(e)&&rc(n,e))return!0;return!1}var oc=e((()=>{x(),ec(),$(),Tn()}));function sc(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var cc,lc,uc,dc=e((()=>{cc=`gpt-5.5`,lc=`gpt-5.4-mini`,uc=[{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 fc(){let e=k();return e===`openai`&&sc()?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||bc()}function pc(e){return e===j().opus40||e===j().opus41||e===j().opus45||e===j().opus46||e===j().opus47}function mc(){let e,t=ge();if(t!==void 0)e=t;else{let t=b()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!ac(e)))return e}function hc(){let e=mc();return e==null?Cc():Q(e)}function gc(){return vc()}function _c(){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 vc(){let e=k();return e===`openai`&&sc()?cc: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:_c()||j().opus47}function yc(){let e=k();return e===`openai`&&sc()?cc: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:_c()||(e===`firstParty`?j().sonnet46:j().sonnet45)}function bc(){let e=k();return e===`openai`&&sc()?lc: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:_c()||j().haiku45}function xc(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return mc()===`opusplan`&&t===`plan`&&!r?vc():mc()===`haiku`&&t===`plan`?yc():n}function Sc(){return process.env.USER_TYPE===`ant`?Rt()?.defaultModel??vc()+`[1m]`:wo()||Eo()?vc()+(Dc()?`[1m]`:``):yc()}function Cc(){return Q(Sc())}function X(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 Z(e){return X(bn(e))}function wc(e=!1){return wo()||Eo()?Dc()?`Opus 4.7 with 1M context · Most capable for complex work${e?Ec(!0):``}`:`Opus 4.7 · Most capable for complex work${e?Ec(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function Tc(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:jc(Q(e))}function Ec(e){if(k()!==`firstParty`)return``;let t=Vs(Ps(e));return` ·${e?` (↯)`:``} ${t}`}function Dc(){return!(Si()||Oo()||k()!==`firstParty`||!Nt()||B()&&V()===null)}function Oc(e){return e===`opusplan`?`Opus Plan`:Y(e)?pt(e):jc(e)}function kc(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 Ac(e){let[t=``,...n]=e.split(`-`);return[t.slice(0,3)+`*`.repeat(Math.max(0,t.length-3)),...n].join(`-`)}function jc(e){let t=kc(e);if(t)return t;if(process.env.USER_TYPE===`ant`){let t=Q(e),n=Bt(e);return n?Ac(n.model.replace(/\[1m\]$/i,``))+(L(t)?`[1m]`:``):t===e?t:`${e} (${t})`}return e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=L(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(Y(i))switch(i){case`opusplan`:return yc()+(r?`[1m]`:``);case`sonnet`:return yc()+(r?`[1m]`:``);case`haiku`:return bc()+(r?`[1m]`:``);case`opus`:return vc()+(r?`[1m]`:``);case`best`:return gc();default:}if(k()===`firstParty`&&Nc(i)&&Pc())return vc()+(r?`[1m]`:``);if(process.env.USER_TYPE===`ant`){let e=L(n),t=Bt(n.replace(/\[1m]$/i,``).trim());if(t){let n=e?`[1m]`:``;return t.model+n}}return r?t.replace(/\[1m\]$/i,``).trim()+`[1m]`:t}function Mc(e,t){return L(e)||!L(t)?e:Ci(Q(e))?e+`[1m]`:e}function Nc(e){return Rc.includes(e)}function Pc(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function Fc(e){if(e===null)return process.env.USER_TYPE===`ant`?`Default for Ants (${Tc(Sc())})`:B()?`Default (${wc()})`:`Default (${Cc()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function Ic(e){if(k()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Z(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 Lc(e){return e.replace(/\[(1|2)m\]/gi,``)}var Rc,$=e((()=>{m(),Vt(),K(),Pi(),l(),Tn(),Xs(),x(),A(),Be(),oc(),ec(),mt(),dc(),Rc=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{us as $,ni as $n,Rn as $r,Oo as $t,dc as A,Zi as An,lr as Ar,z as At,zs as B,Ei as Bn,Zn as Br,K as Bt,Q as C,Mt as Ci,fa as Cn,Er as Cr,Va as Ct,Mc as D,Bi as Dn,Sr as Dr,ja as Dt,Oc as E,Ji as En,F as Er,Ba as Et,ec as F,Ki as Fn,tr as Fr,V as Ft,ys as G,L as Gn,qn as Gr,B as Gt,Vs as H,Oi as Hn,er as Hr,Aa as Ht,Ks as I,Li as In,ir as Ir,mo as It,ss as J,xi as Jn,Pn as Jr,Do as Jt,ls as K,Pi as Kn,Jn as Kr,Io as Kt,qs as L,Ri as Ln,ar as Lr,Ma as Lt,oc as M,Wi as Mn,Qn as Mr,Po as Mt,ac as N,Ui as Nn,nr as Nr,ko as Nt,cc as O,Qi as On,_r as Or,G as Ot,Qs as P,Gi as Pn,$n as Pr,Ao as Pt,ps as Q,di as Qn,Kn as Qr,So as Qt,Hs as R,Ni as Rn,cr as Rr,Co as Rt,Lc as S,k as Si,da as Sn,Ar as Sr,Na as St,jc as T,Nt as Ti,ra as Tn,wr as Tr,qo as Tt,Ps as U,Di as Un,Xn as Ur,Ia as Ut,Rs as V,wi as Vn,or as Vr,bo as Vt,Xs as W,Ti as Wn,sr as Wr,Ra as Wt,rs as X,ui as Xn,jn as Xr,wo as Xt,hs as Y,_i as Yn,zn as Yr,Qa as Yt,as as Z,oi as Zn,Mn as Zr,No as Zt,$ as _,Vt as _i,Ca as _n,zr as _r,Xa as _t,bc as a,j as ai,ro as an,Zr as ar,Ts as at,Dc as b,Lt as bi,xa as bn,jr as br,Lo as bt,vc as c,Kt as ci,to as cn,Yr as cr,ks as ct,Ic as d,en as di,oo as dn,Fr as dr,cs as dt,Fn as ei,Eo as en,ei as er,Ns as et,Ec as f,qt as fi,uo as fn,Ir as fr,Oa as ft,mc as g,zt as gi,Da as gn,Lr as gr,Ga as gt,fc as h,Rt as hi,wa as hn,Hr as hr,$a as ht,wc as i,Sn as ii,io as in,ri as ir,os as it,sc as j,$i as jn,ur as jr,xo as jt,uc as k,qi as kn,vr as kr,go as kt,yc as l,Yt as li,Ko as ln,Gr as lr,vs as lt,xc as m,Ht as mi,Ta as mn,Br as mr,_o as mt,gc as n,En as ni,jo as nn,ti as nr,ms as nt,Cc as o,Tn as oi,W as on,Qr as or,ws as ot,kc as p,Ut as pi,Ro as pn,Vr as pr,za as pt,is as q,Si as qn,Yn as qr,so as qt,Z as r,An as ri,Ka as rn,ii as rr,q as rt,Sc as s,Xt as si,Ja as sn,Xr as sr,Ds as st,X as t,On as ti,To as tn,$r as tr,ts as tt,hc as u,Qt as ui,co as un,Ur as ur,_s as ut,Pc as v,Bt as vi,Sa as vn,qr as vr,no as vt,Tc as w,A as wi,sa as wn,Tr as wr,Wa as wt,Fc as x,Ft as xi,ma as xn,Mr as xr,R as xt,pc as y,Pt as yi,ha as yn,Jr as yr,fo as yt,Ys as z,Ai as zn,rr as zr,yo as zt};
@@ -0,0 +1 @@
1
+ import{_ as e,u as t}from"./model-CKkOnnnx.js";e();export{t as getMainLoopModel};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{E as a,F as o,I as s,S as c,V as l,W as u,a as d,d as f,l as p,nt as m,p as ee,rt as te,w as h,z as g}from"./debug-BrXObCdR.js";import{Jt as ne,Zt as re}from"./settings-Dlp5JTa_.js";import{C as ie,S as ae,b as oe,c as se,g as ce,w as _}from"./config-3m_9zSrj.js";import{n as v,r as y}from"./execFileNoThrow-D244NytW.js";import{o as b,s as x}from"./log-BMCygSzM.js";import{n as S,r as C}from"./analytics-BotDBGh0.js";import{_n as le,vn as ue}from"./model-BQF64tZx.js";import{ft as de,ut as fe}from"./esm-CGoYrggU.js";import{n as pe,r as me,t as he}from"./semver-BMRJYn3q.js";import{C as ge,S as _e,_ as ve,a as w,b as ye,c as be,d as xe,g as Se,h as Ce,i as we,l as Te,n as Ee,o as T,p as De,s as Oe,t as ke,v as E,x as Ae,y as je}from"./pidLock-Bd2e6xuT.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./xdg-DcF9ejUM.js";import{homedir as D}from"os";import{basename as Le,delimiter as Re,dirname as O,join as k,resolve as A}from"path";import{constants as ze}from"fs";import{createHash as Be}from"crypto";import{access as j,chmod as M,copyFile as N,mkdir as P,readdir as F,readlink as I,rename as L,rm as R,rmdir as Ve,stat as z,symlink as He,unlink as B,writeFile as V}from"fs/promises";async function Ue(e=`latest`){let t=Date.now(),{stdout:n,code:r,stderr:i}=await v(`npm`,[`view`,`@${e}`,`version`,`--prefer-online`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0}),a=Date.now()-t;if(r!==0){C(`tengu_version_check_failure`,{latency_ms:a,source_npm:!0,exit_code:r});let e=Error(`npm view failed with code ${r}: ${i}`);throw x(e),e}return C(`tengu_version_check_success`,{latency_ms:a,source_npm:!0}),p(`npm view @${e} version: ${n}`),n.trim()}async function We(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return C(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),C(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw x(c),c}}async function Ge(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return process.env.USER_TYPE===`ant`?Ue(t===`stable`?`stable`:`latest`):We(t,H)}async function Ke(e,t){let n=f();await n.rm(t,{recursive:!0,force:!0});let r=W(),i=`-${r}`;p(`Fetching integrity hash for ${i}@${e}`);let{stdout:o,code:s,stderr:c}=await v(`npm`,[`view`,`${i}@${e}`,`dist.integrity`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0});if(s!==0)throw Error(`npm view integrity failed with code ${s}: ${c}`);let l=o.trim();if(!l)throw Error(`Failed to fetch integrity hash for ${i}@${e}`);p(`Got integrity hash for ${r}: ${l}`),await n.mkdir(t);let u={name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},d={name:`claude-native-installer`,version:`0.0.1`,lockfileVersion:3,requires:!0,packages:{"":{name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},"node_modules/":{version:e,optionalDependencies:{[i]:e}},[`node_modules/${i}`]:{version:e,integrity:l}}};a(k(t,`package.json`),h(u,null,2),{encoding:`utf8`,flush:!0}),a(k(t,`package-lock.json`),h(d,null,2),{encoding:`utf8`,flush:!0});let m=await v(`npm`,[`ci`,`--prefer-online`,`--registry`,U],{timeout:6e4,preserveOutputOnError:!0,cwd:t});if(m.code!==0)throw Error(`npm ci failed with code ${m.code}: ${m.stderr}`);p(`Successfully downloaded and verified @${e}`)}function qe(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||Ze}async function Je(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},d=()=>{l(),c=setTimeout(e=>e.abort(),qe(),s)};try{d();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{d()},...i});l();let o=Be(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await V(n,Buffer.from(a.data)),await M(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new Qe:u(e),t&&o<3){p(`Download stalled on attempt ${o}/3, retrying...`),await ue(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ye(e,t,n,i){let a=f();await a.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();C(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),C(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),x(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw C(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=G(o),p=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let m=k(t,d);try{await Je(p,u,m,i||{}),C(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),C(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),x(Error(`Failed to download binary from ${p}: ${n}`)),e}}async function Xe(e,t){return process.env.USER_TYPE===`ant`?(await Ke(e,t),`npm`):(await Ye(e,t,H),`binary`)}var H,U,Ze,Qe,$e=e((()=>{i(),S(),d(),g(),y(),ee(),b(),le(),c(),$(),H=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,U=`https://artifactory.infra.ant.dev/artifactory/api/npm/npm-all/`,Ze=6e4,Qe=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ne.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw p(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&fe.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:k(Fe(),`claude`,`versions`),staging:k(Pe(),`claude`,`staging`),locks:k(Ne(),`claude`,`locks`),executable:k(Ie(),e)}}async function q(e){try{let t=await z(e);return!t.isFile()||t.size===0?!1:(await j(e,ze.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>P(e,{recursive:!0}))),await P(O(t.executable),{recursive:!0});let r=k(t.versions,e);try{await z(r)}catch{await V(r,``,{encoding:`utf8`})}return{stagingPath:k(t.staging,e),installPath:r}}async function et(e,t,n=0){let r=K(),i=Y(r,e);if(await P(r.locks,{recursive:!0}),T()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw x(e),e}}))return C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await ue(Math.min(o*2**(r-1),s))}return C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),X(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await _(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{p(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw x(e),e}}finally{a&&await a()}}async function tt(e,t){await P(O(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await N(e,n),await M(n,493),await L(n,t),p(`Atomically installed binary to ${t}`)}catch(e){try{await B(n)}catch{}throw e}}async function nt(e,t){try{let n=k(e,`node_modules`,`@anthropic-ai`),r=(await F(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw C(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=k(n,r,`cli`);try{await z(i)}catch{throw C(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await tt(i,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_package_success`,{})}catch(e){let t=o(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&C(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),x(u(e)),e}}async function rt(e,t){try{let n=k(e,G(W()));try{await z(n)}catch{throw C(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await tt(n,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_binary_success`,{})}catch(e){throw o(e).includes(`Staged binary not found`)||C(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),x(u(e)),e}}async function it(e,t,n){n===`npm`?await nt(e,t):await rt(e,t)}async function at(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await ot(e)||n;if(s?(p(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await it(o,i,await Xe(e,o))):p(`Version ${e} already installed, updating symlink`),await ct(a),await lt(a,i),!await q(a)){let e=!1;try{await z(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function ot(e){let{installPath:t}=await J(e);return q(t)}async function st(e,n=!1){let r=Date.now(),i=await Ge(e),{executable:a}=K();if(p(`Checking for native installer update to version ${i}`),!n){let e=await De();if(e&&he(i,e)){if(p(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),pe(`0.0.5`,e))return p(`Native installer: current version 0.0.5 is already at or above maxVersion ${e}, skipping update`),C(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.5`&&await ot(i)&&await q(a))return p(`Found ${i} at ${a}, skipping install`),C(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&Se(i))return C(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await at(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ht(e);let t=await et(e,async()=>{o=await at(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(T()){let r=Y(t,e);w(r)&&(n=Oe(r)?.pid)}return C(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return C(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),p(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function ct(e){try{await Ve(e),p(`Removed empty directory at ${e}`)}catch(t){let n=s(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&p(`Could not remove directory at ${e}: ${t}`)}}async function lt(e,t){if(W().startsWith(`win32`))try{await P(O(e),{recursive:!0});let n;try{n=await z(e)}catch{}if(n){try{let e=await z(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await L(e,r);try{await N(t,e);try{await B(r)}catch{}}catch(t){try{await L(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw x(n),n}throw t}}else try{await N(t,e)}catch(e){throw l(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return x(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=O(e);try{await P(n,{recursive:!0}),p(`Created directory ${n} for symlink`)}catch(e){return x(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await z(e),n=!0}catch{}if(n){try{let n=await I(e);if(A(O(e),n)===A(t))return!1}catch{}await B(e)}}catch(e){x(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await L(r,e),p(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await B(r)}catch{}return x(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ut(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Te();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=O(r.executable),o=A(a),s=W().startsWith(`win32`);try{await j(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await I(r.executable);await q(A(O(r.executable),e))||i.push({message:`Claude symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){l(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(r.executable)||i.push({message:`${r.executable} exists but is not a valid Claude binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).some(e=>{try{let t=A(e);return s?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(s){let e=a.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=_e(),t=E()[e],n=t?t.replace(D(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function dt(e,t=!1){if(t)return ft(e,t);if(Q)return p(`installLatest: joining in-flight call`),Q;let n=ft(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ft(e,t=!1){let n=await st(e,t);return n.success?(se().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),p(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),gt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function pt(e){try{let t=await I(e),n=A(O(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Le(t);return k(e.locks,`${n}.lock`)}async function mt(){let e=K();if(!process.execPath.includes(e.versions))return;let t=A(process.execPath);try{let n=Y(e,t);if(await P(e.locks,{recursive:!0}),T()){if(!await ke(t,n)){C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),p(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await _(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{p(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),p(`Acquired mtime-based lock on running version: ${t}`),te(async()=>{try{await e?.()}catch{}})}catch(e){if(l(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(l(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}p(`NON-FATAL: Failed to lock current version during execution ${o(e)}`,{level:`info`})}}function X(e,t){x(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ht(e){let t=Y(K(),e);try{await B(t),p(`Force-removed lock file at ${t}`)}catch(e){p(`Failed to force-remove lock file: ${o(e)}`)}}async function gt(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=O(e.executable);try{let e=await F(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await B(k(t,r)),n++}catch{}n>0&&p(`Cleaned up ${n} old Windows executables on startup`)}catch(e){l(e)||p(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await F(e.staging),r=0;for(let i of n){let n=k(e.staging,i);try{(await z(n)).mtime.getTime()<t&&(await R(n,{recursive:!0,force:!0}),r++,p(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(p(`Cleaned up ${r} orphaned staging directories`),C(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){l(e)||p(`Failed to clean up staging directories: ${e}`)}if(T()){let t=Ee(e.locks);t>0&&(p(`Cleaned up ${t} stale version locks`),C(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await F(e.versions)}catch(e){l(e)||p(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=k(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await z(n)).mtime.getTime()<t&&(await B(n),i++,p(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await z(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:A(n),mtime:e.mtime})}catch{}}if(i>0&&(p(`Cleaned up ${i} orphaned temp install files`),C(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t&&t.includes(e.versions)&&n.add(A(t));let i=await pt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(T())i=w(r);else try{i=await ae(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),p(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){C(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await et(e.path,async()=>{await B(e.path)})?o++:(s++,p(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,x(Error(`Failed to delete version ${e.name}: ${t}`))}})),C(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){l(e)||x(Error(`Version cleanup failed: ${e}`))}}async function _t(){let e=[],t=E();for(let[n,r]of Object.entries(t))try{let t=await ye(r);if(!t)continue;let{filtered:i,hadAlias:a}=ve(t);a&&(await Ae(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),p(`Cleaned up claude alias from ${n} config`))}catch(t){x(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function vt(e){try{let t=await v(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await B(e),p(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=k(n,`claude.cmd`),t=k(n,`claude.ps1`),a=k(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(k(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(p(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?k(n,`node_modules`,e):k(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return p(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function yt(e){let{code:t,stderr:n}=await v(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return p(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),p(`Attempting manual removal due to ENOTEMPTY error`);let t=await vt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function bt(){let e=[],t=[],n=0,r=await yt(`@anthropic-ai/claude-code`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=k(D(),`.claude`,`local`);try{await R(i,{recursive:!0}),n++,p(`Removed local installation at ${i}`)}catch(t){l(t)||(e.push(`Failed to remove ${i}: ${t}`),p(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{S(),Ce(),m(),ce(),d(),xe(),re(),de(),n(),g(),y(),ge(),ie(),b(),me(),je(),le(),Me(),$e(),we(),Z=10080*60*1e3,Q=null})),xt=e((()=>{$()}));export{_t as a,mt as c,gt as i,ut as n,$ as o,bt as r,dt as s,xt as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{E as a,F as o,I as s,S as c,V as l,W as u,a as d,d as f,l as p,nt as m,p as ee,rt as te,w as h,z as g}from"./debug-BrXObCdR.js";import{Jt as ne,Zt as re}from"./settings-BovzmwMP.js";import{C as ie,S as ae,b as oe,c as se,g as ce,w as _}from"./config-DmomySWC.js";import{n as v,r as y}from"./execFileNoThrow-D244NytW.js";import{o as b,s as x}from"./log-BMCygSzM.js";import{n as S,r as C}from"./analytics-BotDBGh0.js";import{_n as le,vn as ue}from"./model-CKkOnnnx.js";import{ft as de,ut as fe}from"./esm-D5q6s4l8.js";import{n as pe,r as me,t as he}from"./semver-BMRJYn3q.js";import{C as ge,S as _e,_ as ve,a as w,b as ye,c as be,d as xe,g as Se,h as Ce,i as we,l as Te,n as Ee,o as T,p as De,s as Oe,t as ke,v as E,x as Ae,y as je}from"./pidLock-D5rUnDB-.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./xdg-DcF9ejUM.js";import{homedir as D}from"os";import{basename as Le,delimiter as Re,dirname as O,join as k,resolve as A}from"path";import{constants as ze}from"fs";import{createHash as Be}from"crypto";import{access as j,chmod as M,copyFile as N,mkdir as P,readdir as F,readlink as I,rename as L,rm as R,rmdir as Ve,stat as z,symlink as He,unlink as B,writeFile as V}from"fs/promises";async function Ue(e=`latest`){let t=Date.now(),{stdout:n,code:r,stderr:i}=await v(`npm`,[`view`,`@${e}`,`version`,`--prefer-online`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0}),a=Date.now()-t;if(r!==0){C(`tengu_version_check_failure`,{latency_ms:a,source_npm:!0,exit_code:r});let e=Error(`npm view failed with code ${r}: ${i}`);throw x(e),e}return C(`tengu_version_check_success`,{latency_ms:a,source_npm:!0}),p(`npm view @${e} version: ${n}`),n.trim()}async function We(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return C(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),C(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw x(c),c}}async function Ge(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return process.env.USER_TYPE===`ant`?Ue(t===`stable`?`stable`:`latest`):We(t,H)}async function Ke(e,t){let n=f();await n.rm(t,{recursive:!0,force:!0});let r=W(),i=`-${r}`;p(`Fetching integrity hash for ${i}@${e}`);let{stdout:o,code:s,stderr:c}=await v(`npm`,[`view`,`${i}@${e}`,`dist.integrity`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0});if(s!==0)throw Error(`npm view integrity failed with code ${s}: ${c}`);let l=o.trim();if(!l)throw Error(`Failed to fetch integrity hash for ${i}@${e}`);p(`Got integrity hash for ${r}: ${l}`),await n.mkdir(t);let u={name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},d={name:`claude-native-installer`,version:`0.0.1`,lockfileVersion:3,requires:!0,packages:{"":{name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},"node_modules/":{version:e,optionalDependencies:{[i]:e}},[`node_modules/${i}`]:{version:e,integrity:l}}};a(k(t,`package.json`),h(u,null,2),{encoding:`utf8`,flush:!0}),a(k(t,`package-lock.json`),h(d,null,2),{encoding:`utf8`,flush:!0});let m=await v(`npm`,[`ci`,`--prefer-online`,`--registry`,U],{timeout:6e4,preserveOutputOnError:!0,cwd:t});if(m.code!==0)throw Error(`npm ci failed with code ${m.code}: ${m.stderr}`);p(`Successfully downloaded and verified @${e}`)}function qe(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||Ze}async function Je(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},d=()=>{l(),c=setTimeout(e=>e.abort(),qe(),s)};try{d();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{d()},...i});l();let o=Be(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await V(n,Buffer.from(a.data)),await M(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new Qe:u(e),t&&o<3){p(`Download stalled on attempt ${o}/3, retrying...`),await ue(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ye(e,t,n,i){let a=f();await a.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();C(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),C(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),x(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw C(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=G(o),p=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let m=k(t,d);try{await Je(p,u,m,i||{}),C(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),C(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),x(Error(`Failed to download binary from ${p}: ${n}`)),e}}async function Xe(e,t){return process.env.USER_TYPE===`ant`?(await Ke(e,t),`npm`):(await Ye(e,t,H),`binary`)}var H,U,Ze,Qe,$e=e((()=>{i(),S(),d(),g(),y(),ee(),b(),le(),c(),$(),H=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,U=`https://artifactory.infra.ant.dev/artifactory/api/npm/npm-all/`,Ze=6e4,Qe=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ne.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw p(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&fe.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:k(Fe(),`claude`,`versions`),staging:k(Pe(),`claude`,`staging`),locks:k(Ne(),`claude`,`locks`),executable:k(Ie(),e)}}async function q(e){try{let t=await z(e);return!t.isFile()||t.size===0?!1:(await j(e,ze.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>P(e,{recursive:!0}))),await P(O(t.executable),{recursive:!0});let r=k(t.versions,e);try{await z(r)}catch{await V(r,``,{encoding:`utf8`})}return{stagingPath:k(t.staging,e),installPath:r}}async function et(e,t,n=0){let r=K(),i=Y(r,e);if(await P(r.locks,{recursive:!0}),T()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw x(e),e}}))return C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await ue(Math.min(o*2**(r-1),s))}return C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),X(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await _(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{p(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw x(e),e}}finally{a&&await a()}}async function tt(e,t){await P(O(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await N(e,n),await M(n,493),await L(n,t),p(`Atomically installed binary to ${t}`)}catch(e){try{await B(n)}catch{}throw e}}async function nt(e,t){try{let n=k(e,`node_modules`,`@anthropic-ai`),r=(await F(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw C(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=k(n,r,`cli`);try{await z(i)}catch{throw C(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await tt(i,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_package_success`,{})}catch(e){let t=o(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&C(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),x(u(e)),e}}async function rt(e,t){try{let n=k(e,G(W()));try{await z(n)}catch{throw C(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await tt(n,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_binary_success`,{})}catch(e){throw o(e).includes(`Staged binary not found`)||C(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),x(u(e)),e}}async function it(e,t,n){n===`npm`?await nt(e,t):await rt(e,t)}async function at(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await ot(e)||n;if(s?(p(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await it(o,i,await Xe(e,o))):p(`Version ${e} already installed, updating symlink`),await ct(a),await lt(a,i),!await q(a)){let e=!1;try{await z(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function ot(e){let{installPath:t}=await J(e);return q(t)}async function st(e,n=!1){let r=Date.now(),i=await Ge(e),{executable:a}=K();if(p(`Checking for native installer update to version ${i}`),!n){let e=await De();if(e&&he(i,e)){if(p(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),pe(`0.0.6`,e))return p(`Native installer: current version 0.0.6 is already at or above maxVersion ${e}, skipping update`),C(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.6`&&await ot(i)&&await q(a))return p(`Found ${i} at ${a}, skipping install`),C(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&Se(i))return C(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await at(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ht(e);let t=await et(e,async()=>{o=await at(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(T()){let r=Y(t,e);w(r)&&(n=Oe(r)?.pid)}return C(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return C(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),p(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function ct(e){try{await Ve(e),p(`Removed empty directory at ${e}`)}catch(t){let n=s(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&p(`Could not remove directory at ${e}: ${t}`)}}async function lt(e,t){if(W().startsWith(`win32`))try{await P(O(e),{recursive:!0});let n;try{n=await z(e)}catch{}if(n){try{let e=await z(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await L(e,r);try{await N(t,e);try{await B(r)}catch{}}catch(t){try{await L(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw x(n),n}throw t}}else try{await N(t,e)}catch(e){throw l(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return x(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=O(e);try{await P(n,{recursive:!0}),p(`Created directory ${n} for symlink`)}catch(e){return x(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await z(e),n=!0}catch{}if(n){try{let n=await I(e);if(A(O(e),n)===A(t))return!1}catch{}await B(e)}}catch(e){x(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await L(r,e),p(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await B(r)}catch{}return x(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ut(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Te();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=O(r.executable),o=A(a),s=W().startsWith(`win32`);try{await j(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await I(r.executable);await q(A(O(r.executable),e))||i.push({message:`Claude symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){l(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(r.executable)||i.push({message:`${r.executable} exists but is not a valid Claude binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).some(e=>{try{let t=A(e);return s?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(s){let e=a.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=_e(),t=E()[e],n=t?t.replace(D(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function dt(e,t=!1){if(t)return ft(e,t);if(Q)return p(`installLatest: joining in-flight call`),Q;let n=ft(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ft(e,t=!1){let n=await st(e,t);return n.success?(se().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),p(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),gt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function pt(e){try{let t=await I(e),n=A(O(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Le(t);return k(e.locks,`${n}.lock`)}async function mt(){let e=K();if(!process.execPath.includes(e.versions))return;let t=A(process.execPath);try{let n=Y(e,t);if(await P(e.locks,{recursive:!0}),T()){if(!await ke(t,n)){C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),p(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await _(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{p(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),p(`Acquired mtime-based lock on running version: ${t}`),te(async()=>{try{await e?.()}catch{}})}catch(e){if(l(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(l(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}p(`NON-FATAL: Failed to lock current version during execution ${o(e)}`,{level:`info`})}}function X(e,t){x(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ht(e){let t=Y(K(),e);try{await B(t),p(`Force-removed lock file at ${t}`)}catch(e){p(`Failed to force-remove lock file: ${o(e)}`)}}async function gt(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=O(e.executable);try{let e=await F(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await B(k(t,r)),n++}catch{}n>0&&p(`Cleaned up ${n} old Windows executables on startup`)}catch(e){l(e)||p(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await F(e.staging),r=0;for(let i of n){let n=k(e.staging,i);try{(await z(n)).mtime.getTime()<t&&(await R(n,{recursive:!0,force:!0}),r++,p(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(p(`Cleaned up ${r} orphaned staging directories`),C(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){l(e)||p(`Failed to clean up staging directories: ${e}`)}if(T()){let t=Ee(e.locks);t>0&&(p(`Cleaned up ${t} stale version locks`),C(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await F(e.versions)}catch(e){l(e)||p(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=k(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await z(n)).mtime.getTime()<t&&(await B(n),i++,p(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await z(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:A(n),mtime:e.mtime})}catch{}}if(i>0&&(p(`Cleaned up ${i} orphaned temp install files`),C(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t&&t.includes(e.versions)&&n.add(A(t));let i=await pt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(T())i=w(r);else try{i=await ae(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),p(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){C(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await et(e.path,async()=>{await B(e.path)})?o++:(s++,p(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,x(Error(`Failed to delete version ${e.name}: ${t}`))}})),C(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){l(e)||x(Error(`Version cleanup failed: ${e}`))}}async function _t(){let e=[],t=E();for(let[n,r]of Object.entries(t))try{let t=await ye(r);if(!t)continue;let{filtered:i,hadAlias:a}=ve(t);a&&(await Ae(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),p(`Cleaned up claude alias from ${n} config`))}catch(t){x(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function vt(e){try{let t=await v(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await B(e),p(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=k(n,`claude.cmd`),t=k(n,`claude.ps1`),a=k(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(k(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(p(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?k(n,`node_modules`,e):k(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return p(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function yt(e){let{code:t,stderr:n}=await v(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return p(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),p(`Attempting manual removal due to ENOTEMPTY error`);let t=await vt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function bt(){let e=[],t=[],n=0,r=await yt(`@anthropic-ai/claude-code`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=k(D(),`.claude`,`local`);try{await R(i,{recursive:!0}),n++,p(`Removed local installation at ${i}`)}catch(t){l(t)||(e.push(`Failed to remove ${i}: ${t}`),p(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{S(),Ce(),m(),ce(),d(),xe(),re(),de(),n(),g(),y(),ge(),ie(),b(),me(),je(),le(),Me(),$e(),we(),Z=10080*60*1e3,Q=null})),xt=e((()=>{$()}));export{_t as a,mt as c,gt as i,ut as n,$ as o,bt as r,dt as s,xt as t};
@@ -1 +1 @@
1
- import{Un as e,en as t}from"./state-ix0xIunV.js";import{_a as n,ya as r}from"./loadAgentsDir-Clu7Uk6a.js";import{W as i,z as a}from"./debug-BrXObCdR.js";import{Ft as o,Ht as s,Rt as c}from"./settings-Dlp5JTa_.js";import{b as l,c as u,g as d}from"./config-3m_9zSrj.js";import{o as f,s as p}from"./log-BMCygSzM.js";import{Bt as m,_t as h,gt as g,vt as _}from"./model-BQF64tZx.js";import{d as v,m as y,p as b}from"./rcDebugLog-VKwMl0yg.js";t(),m(),d(),a(),f(),r(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:t,oldState:r}){let a=r.toolPermissionContext.mode,o=t.toolPermissionContext.mode;if(a!==o){let e=s(a),n=s(o);e!==n&&y({permission_mode:n,is_ultraplan_mode:n===`plan`&&t.isUltraplanMode&&!r.isUltraplanMode?!0:null}),b(o)}if(t.mainLoopModel!==r.mainLoopModel&&e(t.mainLoopModel),t.expandedView!==r.expandedView){let e=t.expandedView===`tasks`;u().showExpandedTodos!==e&&l(t=>({...t,showExpandedTodos:e}))}if(t.verbose!==r.verbose&&u().verbose!==t.verbose){let e=t.verbose;l(t=>({...t,verbose:e}))}if(process.env.USER_TYPE===`ant`&&t.tungstenPanelVisible!==r.tungstenPanelVisible&&t.tungstenPanelVisible!==void 0&&u().tungstenPanelVisible!==t.tungstenPanelVisible){let e=t.tungstenPanelVisible;l(t=>({...t,tungstenPanelVisible:e}))}if(t.settings!==r.settings)try{g(),h(),_(),t.settings.env!==r.settings.env&&n()}catch(e){p(i(e))}}export{S as n,x as t};
1
+ import{Un as e,en as t}from"./state-ix0xIunV.js";import{_a as n,ya as r}from"./loadAgentsDir-D206qwP3.js";import{W as i,z as a}from"./debug-BrXObCdR.js";import{Ft as o,Ht as s,Rt as c}from"./settings-BovzmwMP.js";import{b as l,c as u,g as d}from"./config-DmomySWC.js";import{o as f,s as p}from"./log-BMCygSzM.js";import{Bt as m,_t as h,gt as g,vt as _}from"./model-CKkOnnnx.js";import{d as v,m as y,p as b}from"./rcDebugLog-CUy1_F23.js";t(),m(),d(),a(),f(),r(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:t,oldState:r}){let a=r.toolPermissionContext.mode,o=t.toolPermissionContext.mode;if(a!==o){let e=s(a),n=s(o);e!==n&&y({permission_mode:n,is_ultraplan_mode:n===`plan`&&t.isUltraplanMode&&!r.isUltraplanMode?!0:null}),b(o)}if(t.mainLoopModel!==r.mainLoopModel&&e(t.mainLoopModel),t.expandedView!==r.expandedView){let e=t.expandedView===`tasks`;u().showExpandedTodos!==e&&l(t=>({...t,showExpandedTodos:e}))}if(t.verbose!==r.verbose&&u().verbose!==t.verbose){let e=t.verbose;l(t=>({...t,verbose:e}))}if(process.env.USER_TYPE===`ant`&&t.tungstenPanelVisible!==r.tungstenPanelVisible&&t.tungstenPanelVisible!==void 0&&u().tungstenPanelVisible!==t.tungstenPanelVisible){let e=t.tungstenPanelVisible;l(t=>({...t,tungstenPanelVisible:e}))}if(t.settings!==r.settings)try{g(),h(),_(),t.settings.env!==r.settings.env&&n()}catch(e){p(i(e))}}export{S as n,x as t};