@readmagic/workmate 0.0.9 → 0.0.10

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 (427) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-Vmmm7p1c.js} +1 -1
  2. package/dist/chunks/App-C2yQjBgY.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +1 -0
  4. package/dist/chunks/{ApproveApiKey-DHAbdwkC.js → ApproveApiKey-MscC-ssL.js} +1 -1
  5. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-BuRFF1fQ.js → BypassPermissionsModeDialog-CLSACUmo.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.js → ClaudeMdExternalIncludesDialog-BqNxQOXJ.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +1 -0
  10. package/dist/chunks/{DiffDialog-BIcwpgSr.js → DiffDialog-9AYwtupw.js} +3 -3
  11. package/dist/chunks/Doctor-DmgAwce2.js +1 -0
  12. package/dist/chunks/Doctor-jEs9chPk.js +3 -0
  13. package/dist/chunks/ExitFlow-DVKxFdpX.js +2 -0
  14. package/dist/chunks/{Grove-BmirUB6V.js → Grove-B9-hhkZA.js} +1 -1
  15. package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-MxJ_W_np.js} +3 -3
  16. package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-o9DF1REI.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.js → InvalidSettingsDialog-YyQcHocx.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +1 -0
  19. package/dist/chunks/MCPToolListView-CvqB4nCw.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-CH4yyMAL.js → McpParsingWarnings-BCpfHaBK.js} +1 -1
  21. package/dist/chunks/MessageSelector-BLzw172f.js +3 -0
  22. package/dist/chunks/Messages-4K5sLmNh.js +11 -0
  23. package/dist/chunks/{Onboarding-BboWs1pp.js → Onboarding-ClwHS5rh.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-BSA9NrZc.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +1 -0
  26. package/dist/chunks/QueryEngine-DPHLSsax.js +1 -0
  27. package/dist/chunks/REPL-Bf46iQCN.js +1 -0
  28. package/dist/chunks/REPL-DIaAo9M9.js +133 -0
  29. package/dist/chunks/RemoteSessionManager-CS6mywIn.js +2 -0
  30. package/dist/chunks/ResumeConversation-Br2KsBoe.js +1 -0
  31. package/dist/chunks/{SSETransport-1KBBUikF.js → SSETransport-CoxQ8YpH.js} +1 -1
  32. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +1 -0
  33. package/dist/chunks/Settings-BMXysXIx.js +2 -0
  34. package/dist/chunks/{TeleportProgress-BmgPAZAi.js → TeleportProgress-Doucj-50.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-B5I73j7Y.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-D6kpr2c6.js} +1 -1
  37. package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-DrC8tlp0.js} +1 -1
  38. package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-Fk4m_Sy4.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-D_OUa4RT.js} +1 -1
  40. package/dist/chunks/WelcomeV2-DvfQHnZY.js +1 -0
  41. package/dist/chunks/add-dir-CZ6Clvq8.js +1 -0
  42. package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-B755vMZE.js} +1 -1
  43. package/dist/chunks/{agents-Bz1MLp4A.js → agents-CIvP8l0s.js} +1 -1
  44. package/dist/chunks/agents-DHnNg4h6.js +103 -0
  45. package/dist/chunks/allErrors-CU89tF-z.js +1 -0
  46. package/dist/chunks/api-BSeE6MwB.js +1 -0
  47. package/dist/chunks/{api-DzccRM_z.js → api-nSHc_GIQ.js} +1 -1
  48. package/dist/chunks/{auth-Cjnyy10u.js → auth-5QB6tsfB.js} +1 -1
  49. package/dist/chunks/auth-BIGJth5U.js +1 -0
  50. package/dist/chunks/auth-CDQMhIZP.js +1 -0
  51. package/dist/chunks/{autoMode-CQ5nqP9c.js → autoMode-BnUiK9Cu.js} +5 -5
  52. package/dist/chunks/{autonomy-CPUCe-YU.js → autonomy-C1aSgWPQ.js} +1 -1
  53. package/dist/chunks/autonomy-Src6sKCp.js +15 -0
  54. package/dist/chunks/{autonomyPanel-Ccr9ilei.js → autonomyPanel-DnHpuiy4.js} +1 -1
  55. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +17 -0
  56. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +1 -0
  57. package/dist/chunks/{banner-BJZNMppT.js → banner-D0P7wXdw.js} +1 -1
  58. package/dist/chunks/bg-50rllUNh.js +1 -0
  59. package/dist/chunks/{bg-w3Vlsm3Y.js → bg-DAPORXF3.js} +2 -2
  60. package/dist/chunks/{branch-CG0AKS1J.js → branch-DFWa4Oxo.js} +2 -2
  61. package/dist/chunks/{break-cache-DXV0brco.js → break-cache-Chj9i9MP.js} +2 -2
  62. package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-Bb6URf4Q.js} +1 -1
  63. package/dist/chunks/bridgeConfig-BeqChxJC.js +1 -0
  64. package/dist/chunks/bridgeMessaging-C3huGcR3.js +1 -0
  65. package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-DLYyvRKb.js} +1 -1
  66. package/dist/chunks/bridgeStatusUtil-DFMftajD.js +1 -0
  67. package/dist/chunks/{btw-DDUC_t0w.js → btw-DSK9R2C8.js} +1 -1
  68. package/dist/chunks/caches-BTQAW9zc.js +1 -0
  69. package/dist/chunks/caches-BVtSCnV1.js +1 -0
  70. package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-amzeeBz0.js} +1 -1
  71. package/dist/chunks/{ccrClient-CG6HTv_n.js → ccrClient-Bu7Tf1Z5.js} +1 -1
  72. package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-CsJfF1b-.js} +1 -1
  73. package/dist/chunks/{clear-DdWexxbM.js → clear-ClFDpWVJ.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BWcoyZDP.js} +1 -1
  75. package/dist/chunks/client-BWQ4-rN7.js +1 -0
  76. package/dist/chunks/{client-CoXtVRzi.js → client-DFlE4fYh.js} +1 -1
  77. package/dist/chunks/client-c-3-PW1F.js +1 -0
  78. package/dist/chunks/commands-Bi7k3Wg-.js +1 -0
  79. package/dist/chunks/compact-J-h0Yf4b.js +2 -0
  80. package/dist/chunks/{config-CVvUNkj2.js → config-CVHMRMwd.js} +1 -1
  81. package/dist/chunks/config-Do1870_d.js +3 -0
  82. package/dist/chunks/config-yyFe87vW.js +1 -0
  83. package/dist/chunks/context-Tb1Ca2Q-.js +1 -0
  84. package/dist/chunks/{context-noninteractive-c7jGVWHQ.js → context-noninteractive-D5iQhasu.js} +2 -2
  85. package/dist/chunks/context-noninteractive-soPYKAc9.js +1 -0
  86. package/dist/chunks/conversation-CSEtUxOY.js +1 -0
  87. package/dist/chunks/conversation-Dk1WDQuN.js +1 -0
  88. package/dist/chunks/{createSSHSession-DP7B8yvb.js → createSSHSession-CJtzNQdZ.js} +1 -1
  89. package/dist/chunks/{createSession-CPo6GBSb.js → createSession-DkT1GL8y.js} +1 -1
  90. package/dist/chunks/createSession-eE8mswkv.js +1 -0
  91. package/dist/chunks/crossProjectResume-04n3Ppy9.js +40 -0
  92. package/dist/chunks/cwd-Cfdf7z7s.js +1 -0
  93. package/dist/chunks/cwd-ClLru_7T.js +1 -0
  94. package/dist/chunks/datadog-DjeJThpV.js +1 -0
  95. package/dist/chunks/{debug-BdqxZ7rV.js → debug-RAynG_nM.js} +1 -1
  96. package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-DX0KAXNK.js} +1 -1
  97. package/dist/chunks/{detached-CkPpYMJj.js → detached-X_yjYR7x.js} +1 -1
  98. package/dist/chunks/{detectRepository-DvxoaPlk.js → detectRepository-DgpNd87p.js} +1 -1
  99. package/dist/chunks/detectRepository-ctF9KDbb.js +1 -0
  100. package/dist/chunks/{diff-DHzz9WAp.js → diff-jEJJe58I.js} +1 -1
  101. package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BbXR2bfy.js} +1 -1
  102. package/dist/chunks/doctor-B-Wag4C1.js +1 -0
  103. package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
  104. package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
  105. package/dist/chunks/entry-oIqjxIjQ.js +14 -0
  106. package/dist/chunks/esm-Cf4nSRjF.js +1 -0
  107. package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-Dwu6psHW.js} +1 -1
  108. package/dist/chunks/{execSyncWrapper-DKuxVTaf.js → execSyncWrapper-BTZJjCuv.js} +1 -1
  109. package/dist/chunks/exit-BtW7LfRX.js +1 -0
  110. package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-Mi66JwFZ.js} +1 -1
  111. package/dist/chunks/extractMemories-CUrdiNcr.js +1 -0
  112. package/dist/chunks/{fast-ClYQcEv5.js → fast-BU4iUZ8E.js} +1 -1
  113. package/dist/chunks/fast-C60p6AqJ.js +1 -0
  114. package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
  115. package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
  116. package/dist/chunks/{fileSuggestions-fNxREjpe.js → fileSuggestions-BMfQIDdW.js} +1 -1
  117. package/dist/chunks/firstPartyEventLogger-B3cXgR67.js +5 -0
  118. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +1 -0
  119. package/dist/chunks/flushGate-DgSDVGKZ.js +1 -0
  120. package/dist/chunks/gemini-BwvSxGgn.js +1 -0
  121. package/dist/chunks/{generateSessionName-nZj_VvKZ.js → generateSessionName-DlrdedOk.js} +1 -1
  122. package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-CmsUPyRz.js} +1 -1
  123. package/dist/chunks/{git-B9uvt96d.js → git-2c7WlGDL.js} +1 -1
  124. package/dist/chunks/git-XtKbtJMc.js +1 -0
  125. package/dist/chunks/{githubRepoPathMapping-Cqx3pSfc.js → githubRepoPathMapping-DbWG4hFQ.js} +1 -1
  126. package/dist/chunks/goal-ZmSRBx4q.js +3 -0
  127. package/dist/chunks/{grok-Dk3LyzMa.js → grok-BXMvezWb.js} +1 -1
  128. package/dist/chunks/{grove-BE4fQ6tG.js → grove-CeOjTaY6.js} +1 -1
  129. package/dist/chunks/help-5DNZO6_H.js +1 -0
  130. package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C637tFtd.js} +2 -2
  131. package/dist/chunks/hooks-DWg07LmS.js +1 -0
  132. package/dist/chunks/initReplBridge-D1h10vQ9.js +1 -0
  133. package/dist/chunks/{install-CVGZ55wV.js → install-C-6ItpH0.js} +1 -1
  134. package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DaiPDUst.js} +4 -4
  135. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  136. package/dist/chunks/{job-DEXxW_Zo.js → job-BeYzQUiR.js} +1 -1
  137. package/dist/chunks/{jwtUtils-C9sdGhvT.js → jwtUtils-CUPXdX3W.js} +1 -1
  138. package/dist/chunks/keybindings-DgIPdBy9.js +2 -0
  139. package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-CE4J98xO.js} +2 -2
  140. package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-BfTdC6vp.js} +1 -1
  141. package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-C7lOqvfh.js} +2194 -2329
  142. package/dist/chunks/loadAgentsDir-zikjxLvn.js +1 -0
  143. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +1 -0
  144. package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-BKrznW5x.js} +1 -1
  145. package/dist/chunks/localSearch-ZFyFy5FN.js +1 -0
  146. package/dist/chunks/log-CezCRpAN.js +1 -0
  147. package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-BkQfyQ1-.js} +1 -1
  148. package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-BpVcON9o.js} +2 -2
  149. package/dist/chunks/{main-BIiwW4mM.js → main-9r5gLzUW.js} +55 -55
  150. package/dist/chunks/{main-ClXu1ilx.js → main-CvOv59-7.js} +4 -4
  151. package/dist/chunks/managedEnv-B61yLpwp.js +1 -0
  152. package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DhWRJ5DK.js} +1 -1
  153. package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-bOab8ipV.js} +1 -1
  154. package/dist/chunks/mcp-BckPBjaM.js +6 -0
  155. package/dist/chunks/mcp-CS1DA3JL.js +1 -0
  156. package/dist/chunks/mcp-VcGPYCkW.js +2 -0
  157. package/dist/chunks/{memoize-FJv2HV1u.js → memoize-DsqYrbeR.js} +1 -1
  158. package/dist/chunks/memory-C5ohwh-T.js +1 -0
  159. package/dist/chunks/{mode-lYTs0XHs.js → mode-DlKnUM8l.js} +2 -2
  160. package/dist/chunks/model-BGu1AGq0.js +1 -0
  161. package/dist/chunks/model-BsZ4sP_H.js +1 -0
  162. package/dist/chunks/model-D19IIcll.js +1 -0
  163. package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-CxP067Qv.js} +1 -1
  164. package/dist/chunks/nativeInstaller-QB8cEJ18.js +1 -0
  165. package/dist/chunks/omit-DDUIPHnl.js +1 -0
  166. package/dist/chunks/onChangeAppState-RBl6H7ho.js +1 -0
  167. package/dist/chunks/{openai-DJLYqiRl.js → openai-B9C2XN5Q.js} +3 -3
  168. package/dist/chunks/{panel-q0_iT9cg.js → panel-KW-wmEvU.js} +1 -1
  169. package/dist/chunks/{parser-BdCj2GrE.js → parser-BwPXQomy.js} +1 -1
  170. package/dist/chunks/parser-xSBaQRLH.js +1 -0
  171. package/dist/chunks/partition-D-UhsUCx.js +1 -0
  172. package/dist/chunks/permissions-BoLXYN1j.js +3 -0
  173. package/dist/chunks/{pidLock-BR5M6RQw.js → pidLock-nJHbufJN.js} +2 -2
  174. package/dist/chunks/plan-CyU2zrCK.js +1 -0
  175. package/dist/chunks/{platform-D6IMiyqT.js → platform-BMPbglug.js} +1 -1
  176. package/dist/chunks/plugin-C6-GQke5.js +17 -0
  177. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +1 -0
  178. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +1 -0
  179. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +1 -0
  180. package/dist/chunks/{pluginFlagging-CxuRF2Vc.js → pluginFlagging-DZaYzecY.js} +1 -1
  181. package/dist/chunks/pluginOperations-D90IRawu.js +2 -0
  182. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +1 -0
  183. package/dist/chunks/{pluginStartupCheck-B6leNWq9.js → pluginStartupCheck-CB2q2dLv.js} +1 -1
  184. package/dist/chunks/plugins-B9eSjLSA.js +4 -0
  185. package/dist/chunks/poorMode-BAnubpn1.js +1 -0
  186. package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-DEwQOAJt.js} +1 -1
  187. package/dist/chunks/print-eCRv_Li-.js +26 -0
  188. package/dist/chunks/processBashCommand-B5F2Cl7K.js +1 -0
  189. package/dist/chunks/processSlashCommand-BC_D3cH5.js +5 -0
  190. package/dist/chunks/prompt-C1JPqinc.js +1 -0
  191. package/dist/chunks/prompt-DZhBz_Vu.js +1 -0
  192. package/dist/chunks/{prompt-CybUvG8G.js → prompt-M2lu8_Oa.js} +34 -34
  193. package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-DhcZY-iu.js} +2 -2
  194. package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-CkFaJKKo.js} +1 -1
  195. package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CuMaO_YV.js} +1 -1
  196. package/dist/chunks/reconciler-B4GDm_iC.js +1 -0
  197. package/dist/chunks/refresh-DBVizOzg.js +1 -0
  198. package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-CsNYRZKr.js} +1 -1
  199. package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-B7JAE3b4.js} +1 -1
  200. package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CFLJhsB6.js} +1 -1
  201. package/dist/chunks/{remoteManagedSettings-CCrq-qL-.js → remoteManagedSettings-xh_MViZH.js} +1 -1
  202. package/dist/chunks/rename-BCp2Vtqu.js +1 -0
  203. package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-Q5oCLFIC.js} +1 -1
  204. package/dist/chunks/resume-DVCSzKvv.js +2 -0
  205. package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-DvOOsDMv.js} +1 -1
  206. package/dist/chunks/ripgrep-e-iewvTf.js +1 -0
  207. package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-CS_3BDNo.js} +4 -4
  208. package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-DYUva6g-.js} +1 -1
  209. package/dist/chunks/sandbox-adapter-BFZFHplu.js +1 -0
  210. package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle--zNSKce_.js} +1 -1
  211. package/dist/chunks/searchExtraTools-ui5y2VSE.js +1 -0
  212. package/dist/chunks/{session-BbQlh2S5.js → session-CO3gEqQP.js} +2 -2
  213. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +1 -0
  214. package/dist/chunks/sessionObserver-Ba7um95p.js +1 -0
  215. package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-YkRHC-Aa.js} +1 -1
  216. package/dist/chunks/sessionState-Bifmu95-.js +11 -0
  217. package/dist/chunks/sessionStorage-CedwLLQs.js +1 -0
  218. package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-COBSgSXS.js} +2 -2
  219. package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-BrNx1k2V.js} +2 -2
  220. package/dist/chunks/settings-DkDH7WQT.js +1 -0
  221. package/dist/chunks/{settings-Xbq6AaD-.js → settings-DnptdP79.js} +5 -5
  222. package/dist/chunks/settingsSync-PmU7SmkU.js +1 -0
  223. package/dist/chunks/setup-BEsBuzsk.js +3 -0
  224. package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-DEaw-X5j.js} +1 -1
  225. package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-BYeOv3Ip.js} +1 -1
  226. package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-D0OKljee.js} +3 -3
  227. package/dist/chunks/sinks-BJHgxz6Y.js +1 -0
  228. package/dist/chunks/sinks-D5-yhcgU.js +2 -0
  229. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +1 -0
  230. package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-N_kmvXML.js} +2 -2
  231. package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-C4F5RXuh.js} +2 -2
  232. package/dist/chunks/{skillSearchPanel-mpaC62y4.js → skillSearchPanel-CftorvAM.js} +3 -3
  233. package/dist/chunks/{skills-t6krW8GZ.js → skills-C4CTRN9o.js} +1 -1
  234. package/dist/chunks/startupProfiler-D4FBdEQr.js +1 -0
  235. package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-L_UWZ03w.js} +2 -2
  236. package/dist/chunks/state-BemZdQIl.js +1 -0
  237. package/dist/chunks/state-D_lk6z-C.js +1 -0
  238. package/dist/chunks/{stats-BJBhl-Lc.js → stats-IzV0_vEc.js} +1 -1
  239. package/dist/chunks/{status-BtsnKNVY.js → status-CeVP_uDT.js} +1 -1
  240. package/dist/chunks/status-Dzuw3hBv.js +2 -0
  241. package/dist/chunks/statusNoticeHelpers-Bb9gxdSt.js +1 -0
  242. package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C84IJ91d.js} +1 -1
  243. package/dist/chunks/switcher-4KzBvuKH.js +1 -0
  244. package/dist/chunks/{switcher-77h2J5HC.js → switcher-CCs9xl1z.js} +1 -1
  245. package/dist/chunks/{syncCache-By_-buUC.js → syncCache-CBRiRU5x.js} +1 -1
  246. package/dist/chunks/{tasks-BNrdmF9p.js → tasks-DZDhgx0w.js} +1 -1
  247. package/dist/chunks/teleport-Bw0jSxe9.js +1 -0
  248. package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CrNPEKkh.js} +1 -1
  249. package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-CBqcwQll.js} +1 -1
  250. package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-D-N8YPiQ.js} +1 -1
  251. package/dist/chunks/{theme-BjpBVRf5.js → theme-Dazsirbw.js} +1 -1
  252. package/dist/chunks/{tmux-CMRiI6CD.js → tmux-DewYVEBm.js} +1 -1
  253. package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-lnHJ9fLQ.js} +1 -1
  254. package/dist/chunks/toolPool-CkXFlqsn.js +1 -0
  255. package/dist/chunks/{trustedDevice-j1u2TG5U.js → trustedDevice-CFf5yaG-.js} +1 -1
  256. package/dist/chunks/trustedDevice-CuwSv8dG.js +1 -0
  257. package/dist/chunks/{types-DWRxAH0E.js → types-3j8PS-Du.js} +1 -1
  258. package/dist/chunks/{udsClient-Cm3HqYUu.js → udsClient-e9dIkwVA.js} +1 -1
  259. package/dist/chunks/{updateCCB-BlUAU2Vp.js → updateCCB-BPe9_FW6.js} +1 -1
  260. package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-DF00RzGG.js} +1 -1
  261. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js} +1 -1
  262. package/dist/chunks/useMainLoopModel-2-eujv0n.js +1 -0
  263. package/dist/chunks/useManagePlugins-CYBIkaB1.js +1 -0
  264. package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-Dk5cPqLc.js} +1 -1
  265. package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-C7Y1I9P9.js} +1 -1
  266. package/dist/chunks/useSettingsErrors-DAEO7AyB.js +1 -0
  267. package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CIq27vUR.js} +1 -1
  268. package/dist/chunks/util-VO98TdOz.js +1 -0
  269. package/dist/chunks/validatePlugin-Kk6pxnO2.js +1 -0
  270. package/dist/chunks/{vim-3mUqsEJm.js → vim-EYQn94Kx.js} +1 -1
  271. package/dist/chunks/{which-DznMOwny.js → which-DzFN5TNM.js} +1 -1
  272. package/dist/chunks/{windowsPaths-BVztIhXM.js → windowsPaths-BU3yQWTB.js} +1 -1
  273. package/dist/chunks/windowsPaths-DgZ3YY4a.js +1 -0
  274. package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-DUqdPy44.js} +1 -1
  275. package/dist/chunks/workerRegistry-C07BcZIw.js +6 -0
  276. package/dist/chunks/worktree-dFUkhVE_.js +1 -0
  277. package/dist/cli.js +1 -1
  278. package/package.json +1 -1
  279. package/dist/chunks/App-DW4elk6E.js +0 -1
  280. package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
  281. package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +0 -2
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +0 -1
  284. package/dist/chunks/Doctor-D160J8Ad.js +0 -3
  285. package/dist/chunks/Doctor-VhJi2cmL.js +0 -1
  286. package/dist/chunks/ExitFlow-CoWHhKHJ.js +0 -2
  287. package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +0 -1
  288. package/dist/chunks/MCPToolListView-BPmE0C2o.js +0 -1
  289. package/dist/chunks/MessageSelector-kOn2GaU-.js +0 -3
  290. package/dist/chunks/Messages-4EnHFeh1.js +0 -11
  291. package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +0 -1
  292. package/dist/chunks/QueryEngine-J6ElcO16.js +0 -1
  293. package/dist/chunks/REPL-DBjbAJsm.js +0 -133
  294. package/dist/chunks/REPL-oBemMXvp.js +0 -1
  295. package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +0 -2
  296. package/dist/chunks/ResumeConversation-wBG8OD9P.js +0 -1
  297. package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +0 -1
  298. package/dist/chunks/Settings-DptKuJE7.js +0 -2
  299. package/dist/chunks/WelcomeV2-BWF-cJOu.js +0 -1
  300. package/dist/chunks/add-dir-DBVT1cEK.js +0 -1
  301. package/dist/chunks/agents-CnwTOlqO.js +0 -103
  302. package/dist/chunks/allErrors-DYw_q14e.js +0 -1
  303. package/dist/chunks/api-DXDXTFGa.js +0 -1
  304. package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
  305. package/dist/chunks/auth-CnLb6RWc.js +0 -1
  306. package/dist/chunks/auth-D-SGHS0K.js +0 -1
  307. package/dist/chunks/autonomy-dSJl0hN1.js +0 -15
  308. package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
  309. package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
  310. package/dist/chunks/bg-DWloqGwk.js +0 -1
  311. package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
  312. package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
  313. package/dist/chunks/caches-1IFb6_M_.js +0 -1
  314. package/dist/chunks/caches-CB8MHqy2.js +0 -1
  315. package/dist/chunks/client-Crrwkw7g.js +0 -1
  316. package/dist/chunks/client-D8hKghba.js +0 -1
  317. package/dist/chunks/color-Cuq0c6xy.js +0 -1
  318. package/dist/chunks/commands-D3sESsTp.js +0 -1
  319. package/dist/chunks/compact-DIpwuBDq.js +0 -2
  320. package/dist/chunks/config-D4G8_MqJ.js +0 -3
  321. package/dist/chunks/config-q9D4hFiK.js +0 -1
  322. package/dist/chunks/context-BWcfhhDj.js +0 -1
  323. package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
  324. package/dist/chunks/conversation-Bjo_8kia.js +0 -1
  325. package/dist/chunks/conversation-DrHZIQX2.js +0 -1
  326. package/dist/chunks/createSession-DnykRoia.js +0 -1
  327. package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
  328. package/dist/chunks/cwd--q1ONL7P.js +0 -1
  329. package/dist/chunks/cwd-L4wygFqJ.js +0 -1
  330. package/dist/chunks/daemon-D2vFIVOz.js +0 -2
  331. package/dist/chunks/datadog-DrmHyl3_.js +0 -1
  332. package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
  333. package/dist/chunks/doctor-PWqB46xd.js +0 -1
  334. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  335. package/dist/chunks/entry-4JtoJONR.js +0 -14
  336. package/dist/chunks/esm-DcIr7tVd.js +0 -1
  337. package/dist/chunks/exit-OW9g7b9A.js +0 -1
  338. package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
  339. package/dist/chunks/fast-CrvLdpy3.js +0 -1
  340. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  341. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  342. package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
  343. package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
  344. package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
  345. package/dist/chunks/gemini-fZ0VPU2A.js +0 -1
  346. package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
  347. package/dist/chunks/git-BfS5Hk4S.js +0 -1
  348. package/dist/chunks/goal-IasZVqKh.js +0 -3
  349. package/dist/chunks/help-D2-v9Ug9.js +0 -1
  350. package/dist/chunks/hooks-DGd02IKF.js +0 -1
  351. package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
  352. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  353. package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
  354. package/dist/chunks/language-C0cIpKE2.js +0 -1
  355. package/dist/chunks/language-CxThoWRC.js +0 -1
  356. package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
  357. package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
  358. package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
  359. package/dist/chunks/log-CTFl4qpD.js +0 -1
  360. package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
  361. package/dist/chunks/mcp-B_m1XBDt.js +0 -6
  362. package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
  363. package/dist/chunks/mcp-BjlaPUWX.js +0 -2
  364. package/dist/chunks/memory-LN8f_p2b.js +0 -1
  365. package/dist/chunks/model-C2e73CJD.js +0 -1
  366. package/dist/chunks/model-CvmS-Esk.js +0 -1
  367. package/dist/chunks/model-DJ8mFfuR.js +0 -1
  368. package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
  369. package/dist/chunks/omit-CLPZGevl.js +0 -1
  370. package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
  371. package/dist/chunks/panelCall-sum-3zvi.js +0 -1
  372. package/dist/chunks/parser-BcdhBGx0.js +0 -1
  373. package/dist/chunks/partition-CpfoVrg1.js +0 -1
  374. package/dist/chunks/permissions-DTb9wkAP.js +0 -3
  375. package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
  376. package/dist/chunks/plan-BeoIjNPv.js +0 -1
  377. package/dist/chunks/plugin-D_dHjTud.js +0 -17
  378. package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
  379. package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
  380. package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
  381. package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
  382. package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
  383. package/dist/chunks/plugins-pmipe7kE.js +0 -4
  384. package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
  385. package/dist/chunks/print-CAUvczBM.js +0 -23
  386. package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
  387. package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
  388. package/dist/chunks/prompt-RBn4JdEg.js +0 -1
  389. package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
  390. package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
  391. package/dist/chunks/refresh-D8TLHO_T.js +0 -1
  392. package/dist/chunks/rename-CKsSc7Z3.js +0 -1
  393. package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
  394. package/dist/chunks/resume-B1a5gLVR.js +0 -2
  395. package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
  396. package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
  397. package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
  398. package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
  399. package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
  400. package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
  401. package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
  402. package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
  403. package/dist/chunks/sessionState-BvECKycx.js +0 -11
  404. package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
  405. package/dist/chunks/settings-B-R9ZJNY.js +0 -1
  406. package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
  407. package/dist/chunks/setup-uZ0dSekt.js +0 -3
  408. package/dist/chunks/sinks-C7q46rvE.js +0 -2
  409. package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
  410. package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
  411. package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
  412. package/dist/chunks/state-B4HwLt8i.js +0 -1
  413. package/dist/chunks/state-Bs5xweDL.js +0 -1
  414. package/dist/chunks/status-nZQEar7T.js +0 -2
  415. package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
  416. package/dist/chunks/switcher-B2CYzCC_.js +0 -1
  417. package/dist/chunks/teleport-mdnhIZBj.js +0 -1
  418. package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
  419. package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
  420. package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
  421. package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
  422. package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
  423. package/dist/chunks/util-D-X8i5Z2.js +0 -1
  424. package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
  425. package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
  426. package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
  427. package/dist/chunks/worktree-BX1ULzrw.js +0 -1
@@ -1 +0,0 @@
1
- import{l as e,o as t,u as n}from"./envUtils-BDhHQY0-.js";import{Ar as r,Cf as i,Df as a,Ha as o,LT as s,Nc as c,Qa as l,RT as u,Wa as d,kc as f,no as p,pr as m,xf as h}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as g,mt as _,tt as v}from"./state-Bs5xweDL.js";import{F as y,a as b,l as x,nt as S,rt as ee,z as C}from"./debug-BdqxZ7rV.js";import{c as te,h as ne,y as re}from"./config-D4G8_MqJ.js";import{O as w,i as ie,k as T,m as E,u as D}from"./git-B9uvt96d.js";import{g as O,m as k}from"./log-CTFl4qpD.js";import{n as A,r as j}from"./analytics-DJobLaWP.js";import{Bt as ae,Fr as M,It as N,Ot as oe,Pr as se,_n as P,mt as F,vn as I}from"./model-C2e73CJD.js";import{a as ce,i as le,r as L,t as R}from"./sessionIdCompat-DMayYBrf.js";import{I as ue,L as de,c as fe,d as pe,h as z,m as me,n as B,p as he,u as V}from"./sessionState-BvECKycx.js";import{a as H,i as U,n as W,o as G,t as K}from"./bridgeConfig-vORehbGG.js";import{a as ge,o as q,r as _e,s as J}from"./debugUtils-CezNYZ-4.js";import{a as Y,i as ve,n as X,t as Z}from"./createSession-CPo6GBSb.js";import{n as ye,o as be}from"./mappers-xQC-Z4-h.js";import{n as xe,r as Se,t as Q}from"./sessionTitle-E1FvsKM9.js";import{i as Ce,n as we,r as Te,t as Ee}from"./flushGate-ch-Tvwjj.js";import{n as De,t as Oe}from"./pollConfig-BgpfHQPJ.js";import{n as ke,t as Ae}from"./rcDebugLog-CARUIORE.js";import{a as je,i as Me,n as $,o as Ne,r as Pe,t as Fe}from"./capacityWake-L7b1mMft.js";import{a as Ie,i as Le,n as Re,o as ze,r as Be,t as Ve}from"./bridgeMessaging-DlczTV9X.js";import{a as He,n as Ue,r as We,t as Ge}from"./workSecret-DtiFreRl.js";import{i as Ke}from"./trustedDevice-j1u2TG5U.js";import{t as qe}from"./HybridTransport-BVmSUHf0.js";import{hostname as Je}from"os";import{randomUUID as Ye}from"crypto";g(),k(),E(),ne(),M(),ae(),u(),h(),H(),pe(),l(),r(),ve(),ye(),Se(),b(),Ae(),w(),A(),S(),R(),f(),ue(),B(),t(),q(),C(),P();var Xe=2e3,Ze=6e4,Qe=900*1e3,$e=0;async function et(t){let{dir:r,machineName:i,branch:a,gitRepoUrl:o,title:s,baseUrl:l,sessionIngressUrl:u,workerType:d,getAccessToken:f,createSession:p,archiveSession:m,getCurrentTitle:h=()=>s,toSDKMessages:g=()=>{throw Error(`BridgeCoreParams.toSDKMessages not provided. Pass it if you use writeMessages() or initialMessages — daemon callers that only use writeSdkMessages() never hit this path.`)},onAuth401:_,getPollIntervalConfig:v=()=>De,initialHistoryCap:b=200,initialMessages:S,previouslyFlushedUUIDs:C,onInboundMessage:te,onPermissionResponse:ne,onInterrupt:re,onSetModel:w,onSetMaxThinkingTokens:ie,onSetPermissionMode:E,onStateChange:D,onUserMessage:O,perpetual:k,initialSSESequenceNum:A=0}=t,ae=++$e,{writeBridgePointer:M,clearBridgePointer:N,readBridgePointer:oe}=await import(`./bridgePointer-D4W9GpWw.js`),se=k?await oe(r):null,P=se?.source===`repl`?se:null;x(`[bridge:repl] initBridgeCore #${ae} starting (initialMessages=${S?.length??0}${P?` perpetual prior=env:${P.environmentId}`:``})`);let F=Pe({baseUrl:l,getAccessToken:f,runnerVersion:`0.0.9`,onDebug:x,onAuth401:_,getTrustedDeviceToken:Ke}),I={dir:r,machineName:i,branch:a,gitRepoUrl:o,maxSessions:1,spawnMode:`single-session`,verbose:!1,sandbox:!1,bridgeId:Ye(),workerType:d,environmentId:Ye(),reuseEnvironmentId:P?.environmentId,apiBaseUrl:l,sessionIngressUrl:u},L,R;try{let e=await F.registerBridgeEnvironment(I);L=e.environment_id,R=e.environment_secret}catch(e){return J(`registration_failed`,`[bridge:repl] Environment registration failed: ${y(e)}`),P&&await N(r),D?.(`failed`,y(e)),null}x(`[bridge:repl] Environment registered: ${L}`),T(`info`,`bridge_repl_env_registered`),j(`tengu_bridge_repl_env_registered`,{});async function ue(e,t){if(L!==e)return x(`[bridge:repl] Env mismatch (requested ${e}, got ${L}) — cannot reconnect in place`),!1;let n=ce(t),r=n===t?[t]:[t,n];for(let e of r)try{return await F.reconnectSession(L,e),x(`[bridge:repl] Reconnected session ${e} in place on env ${L}`),!0}catch(t){x(`[bridge:repl] reconnectSession(${e}) failed: ${y(t)}`)}return x(`[bridge:repl] reconnectSession exhausted — falling through to fresh session`),!1}let pe=P?await ue(P.environmentId,P.sessionId):!1;P&&!pe&&await N(r);let z;if(pe&&P){if(z=P.sessionId,x(`[bridge:repl] Perpetual session reused: ${z}`),S&&C)for(let e of S)C.add(e.uuid)}else{let e=await p({environmentId:L,title:s,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});if(!e)return x(`[bridge:repl] Session creation failed, deregistering environment`),j(`tengu_bridge_repl_session_failed`,{}),await F.deregisterEnvironment(L).catch(()=>{}),D?.(`failed`,`Session creation failed`),null;z=e,x(`[bridge:repl] Session created: ${z}`)}await M(r,{sessionId:z,environmentId:L,source:`repl`}),T(`info`,`bridge_repl_session_created`),j(`tengu_bridge_repl_started`,{has_initial_messages:!!(S&&S.length>0),inProtectedNamespace:n()});let me=new Set;if(S)for(let e of S)me.add(e.uuid);let B=new Ve(2e3);for(let e of me)B.add(e);let he=new Ve(2e3),V=new AbortController,H=null;fe(e=>{V.signal.aborted||H?.reportMetadata(e)},{replayCurrent:!0});let U=0,W=pe?A:0,G=null,K=null,ge=Fe(V.signal),q=ge.wake,_e=ge.signal,Y=new Ee,ve=!O,X=0,Z=null;async function ye(){if(Z)return Z;Z=be();try{return await Z}finally{Z=null}}async function be(){if(X++,ke(`doReconnect: attempt=${X}/3 envId=${L} sessionId=${z} workId=${G}`),U++,x(`[bridge:repl] Reconnecting after env lost (attempt ${X}/3)`),X>3)return x(`[bridge:repl] Environment reconnect limit reached (3), giving up`),!1;if(H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}if(q(),Y.drop(),G){let e=G;if(await F.stopWork(L,e,!1).catch(()=>{}),G!==e)return x(`[bridge:repl] Poll loop recovered during stopWork await — deferring to it`),X=0,!0;G=null,K=null}if(V.signal.aborted)return x(`[bridge:repl] Reconnect aborted by teardown`),!1;let e=L;I.reuseEnvironmentId=e;try{let e=await F.registerBridgeEnvironment(I);L=e.environment_id,R=e.environment_secret}catch(e){return I.reuseEnvironmentId=void 0,x(`[bridge:repl] Environment re-registration failed: ${y(e)}`),!1}if(I.reuseEnvironmentId=void 0,x(`[bridge:repl] Re-registered: requested=${e} got=${L}`),V.signal.aborted)return x(`[bridge:repl] Reconnect aborted after env registration, cleaning up`),await F.deregisterEnvironment(L).catch(()=>{}),!1;if(H!==null)return x(`[bridge:repl] Poll loop recovered during registerBridgeEnvironment await — deferring to it`),X=0,!0;if(await ue(e,z))return j(`tengu_bridge_repl_reconnected_in_place`,{}),X=0,!0;if(L!==e&&j(`tengu_bridge_repl_env_expired_fresh_session`,{}),await m(z),V.signal.aborted)return x(`[bridge:repl] Reconnect aborted after archive, cleaning up`),await F.deregisterEnvironment(L).catch(()=>{}),!1;let t=h(),n=await p({environmentId:L,title:t,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});return n?V.signal.aborted?(x(`[bridge:repl] Reconnect aborted after session creation, cleaning up`),await m(n),!1):(z=n,c(le(n)).catch(()=>{}),W=0,he.clear(),ve=!O,x(`[bridge:repl] Re-created session: ${z}`),await M(r,{sessionId:z,environmentId:L,source:`repl`}),C?.clear(),X=0,!0):(x(`[bridge:repl] Session creation failed during reconnection`),!1)}function xe(){return f()}function Se(){let e=Y.end();if(e.length===0)return;if(!H){x(`[bridge:repl] Cannot drain ${e.length} pending message(s): no transport`);return}for(let t of e)B.add(t.uuid);let t=g(e).map(e=>({...e,session_id:z}));x(`[bridge:repl] Drained ${e.length} pending message(s) after flush`),H.writeBatch(t)}let Q=null;function Ce(){Q?.()}function Oe(e){if(ke(`handleTransportPermanentClose: code=${e} transport=${H?`exists`:`null`} pollAborted=${V.signal.aborted}`),x(`[bridge:repl] Transport permanently closed: code=${e}`),j(`tengu_bridge_repl_ws_closed`,{code:e}),H){let e=H.getLastSequenceNum();e>W&&(W=e),H=null}q();let t=Y.drop();if(t>0&&x(`[bridge:repl] Dropping ${t} pending message(s) on transport close (code=${e})`,{level:`warn`}),e===1e3){D?.(`failed`,`session ended`),V.abort(),Ce();return}D?.(`reconnecting`,`Remote Control connection lost (code ${e})`),x(`[bridge:repl] Transport reconnect budget exhausted (code=${e}), attempting env reconnect`),ye().then(t=>{t||V.signal.aborted||(x(`[bridge:repl] reconnectEnvironmentWithSession resolved false — tearing down`),j(`tengu_bridge_repl_reconnect_failed`,{close_code:e}),D?.(`failed`,`reconnection failed`),Ce())})}tt({api:F,getCredentials:()=>({environmentId:L,environmentSecret:R}),signal:V.signal,getPollIntervalConfig:v,onStateChange:D,getWsState:()=>H?.getStateLabel()??`null`,isAtCapacity:()=>H!==null,capacitySignal:_e,onFatalError:Ce,getHeartbeatInfo:()=>!G||!K?null:{environmentId:L,workId:G,sessionToken:K},onHeartbeatFatal:e=>{if(x(`[bridge:repl] heartbeatWork fatal (status=${e.status}) — tearing down work item for fast re-dispatch`),H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}Y.drop(),G&&F.stopWork(L,G,!1).catch(e=>{x(`[bridge:repl] stopWork after heartbeat fatal: ${y(e)}`)}),G=null,K=null,q(),D?.(`reconnecting`,`Work item lease expired, fetching fresh token`)},async onEnvironmentLost(){return await ye()?{environmentId:L,environmentSecret:R}:null},onWorkReceived:(t,n,i,a)=>{if(H?.isConnectedStatus()&&x(`[bridge:repl] Work received while transport connected, replacing with fresh token (workId=${i})`),x(`[bridge:repl] Work received: workId=${i} workSessionId=${t} currentSessionId=${z} match=${He(t,z)}`),M(r,{sessionId:z,environmentId:L,source:`repl`}),!He(t,z)){x(`[bridge:repl] Rejecting foreign session: expected=${z} got=${t}`);return}G=i,K=n;let o=a||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2),s;if(!o){if(s=xe(),!s){x(`[bridge:repl] No OAuth token available for session ingress, skipping work`);return}de(s)}if(j(`tengu_bridge_repl_work_received`,{}),H){let e=H;H=null;let t=e.getLastSequenceNum();t>W&&(W=t),e.close()}Y.deactivate();let c=e=>Le(e,{transport:H,sessionId:z,onInterrupt:re,onSetModel:w,onSetMaxThinkingTokens:ie,onSetPermissionMode:E}),d=!1,f=e=>{H=e,e.setOnConnect(()=>{if(H===e){if(x(`[bridge:repl] Ingress transport connected`),j(`tengu_bridge_repl_ws_connected`,{}),!o){let e=xe();e&&de(e)}if($=!1,!d&&S&&S.length>0){d=!0;let t=b,n=S.filter(e=>Ie(e)&&!C?.has(e.uuid)),r=t>0&&n.length>t?n.slice(-t):n;r.length<n.length&&(x(`[bridge:repl] Capped initial flush: ${n.length} -> ${r.length} (cap=${t})`),j(`tengu_bridge_repl_history_capped`,{eligible_count:n.length,capped_count:r.length}));let i=g(r);if(i.length>0){x(`[bridge:repl] Flushing ${i.length} initial message(s) via transport`);let t=i.map(e=>({...e,session_id:z})),n=e.droppedBatchCount;e.writeBatch(t).then(()=>{if(e.droppedBatchCount>n){x(`[bridge:repl] Initial flush dropped ${e.droppedBatchCount-n} batch(es) — not marking ${i.length} UUID(s) as flushed`);return}if(C)for(let e of i)e.uuid&&C.add(e.uuid)}).catch(e=>x(`[bridge:repl] Initial flush failed: ${e}`)).finally(()=>{H===e&&(Se(),D?.(`connected`))})}else Se(),D?.(`connected`)}else Y.active||D?.(`connected`)}}),e.setOnData(e=>{try{let t=JSON.parse(e);ke(`ingress: type=${t.type}${t.type===`control_request`?` subtype=${t.request?.subtype} request_id=${t.request_id}`:``}${t.type===`control_response`?` subtype=${t.response?.subtype} request_id=${t.response?.request_id}`:``}${t.type===`user`?` uuid=${t.uuid}`:``}${t.type===`keep_alive`?``:` len=${e.length}`}`)}catch{ke(`ingress (non-JSON): ${String(e).slice(0,200)}`)}Be(e,B,he,te,ne,c)}),e.setOnClose(t=>{H===e&&(ke(`transport onClose: code=${t} connected=${e.isConnectedStatus()} state=${e.getStateLabel()} seq=${e.getLastSequenceNum()}`),Oe(t))}),!d&&S&&S.length>0&&Y.start(),e.connect()};if(U++,o){let e=Ge(l,t),r=U;x(`[bridge:repl] CCR v2: sessionUrl=${e} session=${t} gen=${r}`),Te({sessionUrl:e,ingressToken:n,sessionId:t,initialSequenceNum:W}).then(e=>{if(V.signal.aborted){e.close();return}if(r!==U){x(`[bridge:repl] CCR v2: discarding stale handshake gen=${r} current=${U}`),e.close();return}f(e)},e=>{x(`[bridge:repl] CCR v2: createV2ReplTransport failed: ${y(e)}`,{level:`error`}),j(`tengu_bridge_repl_ccr_v2_init_failed`,{}),r===U&&(G&&(F.stopWork(L,G,!1).catch(e=>{x(`[bridge:repl] stopWork after v2 init failure: ${y(e)}`)}),G=null,K=null),q())})}else{let e=Ue(u,t);x(`[bridge:repl] Ingress URL: ${e}`),x(`[bridge:repl] Creating HybridTransport: session=${t}`);let n=s??``;f(we(new qe(new URL(e),{Authorization:`Bearer ${n}`,"anthropic-version":`2023-06-01`},t,()=>({Authorization:`Bearer ${xe()??n}`,"anthropic-version":`2023-06-01`}),{maxConsecutiveFailures:50,isBridge:!0,onBatchDropped:()=>{D?.(`reconnecting`,`Lost sync with Remote Control — events could not be delivered`),q()}})))}}});let Ae=k?setInterval(()=>{Z||M(r,{sessionId:z,environmentId:L,source:`repl`})},60*6e4):null;Ae?.unref?.();let je=v().session_keepalive_interval_v2_ms,Me=je>0?setInterval(()=>{H&&(x(`[bridge:repl] keep_alive sent`),H.write({type:`keep_alive`}).catch(e=>{x(`[bridge:repl] keep_alive write failed: ${y(e)}`)}))},je):null;Me?.unref?.();let $=!1;Q=async()=>{if($){x(`[bridge:repl] Teardown already in progress, skipping duplicate call env=${L} session=${z}`);return}$=!0;let e=Date.now();if(x(`[bridge:repl] Teardown starting: env=${L} session=${z} workId=${G??`none`} transportState=${H?.getStateLabel()??`null`}`),Ae!==null&&clearInterval(Ae),Me!==null&&clearInterval(Me),V.abort(),x(`[bridge:repl] Teardown: poll loop aborted`),H){let e=H.getLastSequenceNum();e>W&&(W=e)}if(k){H=null,Y.drop(),await M(r,{sessionId:z,environmentId:L,source:`repl`}),x(`[bridge:repl] Teardown (perpetual): leaving env=${L} session=${z} alive on server, duration=${Date.now()-e}ms`);return}let t=H;if(H=null,Y.drop(),t){let e={...ze(z),session_id:z};t.write(e)}let n=G?F.stopWork(L,G,!0).then(()=>{x(`[bridge:repl] Teardown: stopWork completed`)}).catch(e=>{x(`[bridge:repl] Teardown stopWork failed: ${y(e)}`)}):Promise.resolve();await Promise.all([n,m(z)]),t?.close(),x(`[bridge:repl] Teardown: transport closed`),await F.deregisterEnvironment(L).catch(e=>{x(`[bridge:repl] Teardown deregister failed: ${y(e)}`)}),await N(r),x(`[bridge:repl] Teardown complete: env=${L} duration=${Date.now()-e}ms`)};let Ne=ee(()=>Q?.());return x(`[bridge:repl] Ready: env=${L} session=${z}`),D?.(`ready`),{get bridgeSessionId(){return z},get environmentId(){return L},getSSESequenceNum(){let e=H?.getLastSequenceNum()??0;return Math.max(W,e)},sessionIngressUrl:u,writeMessages(e){let t=e.filter(e=>Ie(e)&&!me.has(e.uuid)&&!B.has(e.uuid));if(t.length===0)return;if(!ve)for(let e of t){let t=Re(e);if(t!==void 0&&O?.(t,z)){ve=!0;break}}if(Y.enqueue(...t)){x(`[bridge:repl] Queued ${t.length} message(s) during initial flush`);return}if(!H){let e=t.map(e=>e.type).join(`,`);x(`[bridge:repl] Transport not configured, dropping ${t.length} message(s) [${e}] for session=${z}`,{level:`warn`});return}for(let e of t)B.add(e.uuid);x(`[bridge:repl] Sending ${t.length} message(s) via transport`);let n=g(t).map(e=>({...e,session_id:z}));H.writeBatch(n)},writeSdkMessages(e){let t=e.filter(e=>!e.uuid||!B.has(e.uuid));if(t.length===0)return;if(!H){x(`[bridge:repl] Transport not configured, dropping ${t.length} SDK message(s) for session=${z}`,{level:`warn`});return}for(let e of t)e.uuid&&B.add(e.uuid);let n=t.map(e=>({...e,session_id:z}));H.writeBatch(n)},sendControlRequest(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_request`);return}let t={...e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_request request_id=${e.request_id}`)},sendControlResponse(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_response`);return}let t={...e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_response`)},sendControlCancelRequest(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_cancel_request`);return}let t={type:`control_cancel_request`,request_id:e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_cancel_request request_id=${e}`)},sendResult(){if(!H){x(`[bridge:repl] sendResult: skipping, transport not configured session=${z}`);return}H.reportState(`idle`);let e={...ze(z),session_id:z};H.write(e),x(`[bridge:repl] Sent result for session=${z}`)},async teardown(){Ne(),await Q?.(),x(`[bridge:repl] Torn down`),j(`tengu_bridge_repl_teardown`,{})}}}async function tt({api:e,getCredentials:t,signal:n,onStateChange:r,onWorkReceived:i,onEnvironmentLost:a,getWsState:o,isAtCapacity:s,capacitySignal:c,onFatalError:l,getPollIntervalConfig:u=()=>De,getHeartbeatInfo:d,onHeartbeatFatal:f}){x(`[bridge:repl] Starting work poll loop for env=${t().environmentId}`);let p=0,m=null,h=null,g=0,_=!1;for(;!n.aborted;){let{environmentId:v,environmentSecret:b}=t(),S=u();try{let t=await e.pollForWork(v,b,n,S.reclaim_older_than_ms);if(g=0,p>0&&(x(`[bridge:repl] Poll recovered after ${p} consecutive error(s)`),p=0,m=null,h=null,r?.(`ready`)),!t){let t=_;if(_=!1,s?.()&&c&&!t){let t=S.poll_interval_ms_at_capacity;if(S.non_exclusive_heartbeat_interval_ms>0&&d){j(`tengu_bridge_heartbeat_mode_entered`,{heartbeat_interval_ms:S.non_exclusive_heartbeat_interval_ms});let r=t>0?Date.now()+t:null,i=!1,a=0;for(;!n.aborted&&s()&&(r===null||Date.now()<r);){let t=u();if(t.non_exclusive_heartbeat_interval_ms<=0)break;let n=d();if(!n)break;let r=c();try{await e.heartbeatWork(n.environmentId,n.workId,n.sessionToken)}catch(e){if(x(`[bridge:repl:heartbeat] Failed: ${y(e)}`),e instanceof $){r.cleanup(),j(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),f?(f(e),x(`[bridge:repl:heartbeat] Fatal (status=${e.status}), work state cleared — fast-polling for re-dispatch`)):i=!0;break}}a++,await I(t.non_exclusive_heartbeat_interval_ms,r.signal),r.cleanup()}let o=i?`error`:n.aborted?`shutdown`:s()?r!==null&&Date.now()>=r?`poll_due`:`config_disabled`:`capacity_changed`;if(j(`tengu_bridge_heartbeat_mode_exited`,{reason:o,heartbeat_cycles:a}),!i){o===`poll_due`&&x(`[bridge:repl] Heartbeat poll_due after ${a} cycles — falling through to pollForWork`);continue}}let r=t>0?t:S.non_exclusive_heartbeat_interval_ms;if(r>0){let e=c(),t=Date.now();await I(r,e.signal),e.cleanup();let n=Date.now()-t-r;n>6e4&&(x(`[bridge:repl] At-capacity sleep overran by ${Math.round(n/1e3)}s — process suspension detected, forcing one fast-poll cycle`),j(`tengu_bridge_repl_suspension_detected`,{overrun_ms:n}),_=!0)}}else await I(S.poll_interval_ms_not_at_capacity,n);continue}let a;try{a=We(t.secret)}catch(n){x(`[bridge:repl] Failed to decode work secret: ${y(n)}`),j(`tengu_bridge_repl_work_secret_failed`,{}),await e.stopWork(v,t.id,!1).catch(()=>{});continue}x(`[bridge:repl] Acknowledging workId=${t.id}`);try{await e.acknowledgeWork(v,t.id,a.session_ingress_token)}catch(e){x(`[bridge:repl] Acknowledge failed workId=${t.id}: ${y(e)}`)}if(t.data.type===`healthcheck`){x(`[bridge:repl] Healthcheck received`);continue}if(t.data.type===`session`){let e=t.data.id;try{Ne(e,`session_id`)}catch{x(`[bridge:repl] Invalid session_id in work: ${e}`);continue}i(e,a.session_ingress_token,t.id,a.use_code_sessions===!0),x(`[bridge:repl] Work accepted, continuing poll loop`)}}catch(i){if(n.aborted)break;if(i instanceof $&&i.status===404&&a){let e=t().environmentId;if(v!==e){x(`[bridge:repl] Stale poll error for old env=${v}, current env=${e} — skipping onEnvironmentLost`),p=0,m=null;continue}if(g++,x(`[bridge:repl] Environment deleted, attempting re-registration (attempt ${g}/3)`),j(`tengu_bridge_repl_env_lost`,{attempt:g}),g>3){x(`[bridge:repl] Environment re-registration limit reached (3), giving up`),r?.(`failed`,`Environment deleted and re-registration limit reached`),l?.();break}r?.(`reconnecting`,`environment lost, recreating session`);let i=await a();if(n.aborted)break;if(i){p=0,m=null,r?.(`ready`),x(`[bridge:repl] Re-registered environment: ${i.environmentId}`);continue}r?.(`failed`,`Environment deleted and re-registration failed`),l?.();break}if(i instanceof $){let e=Me(i.errorType),t=je(i);x(`[bridge:repl] Fatal poll error: ${i.message} (status=${i.status}, type=${i.errorType??`unknown`})${t?` (suppressed)`:``}`),j(`tengu_bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),T(e?`info`:`error`,`bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),t||r?.(`failed`,e?`session expired · /remote-control to reconnect`:i.message),l?.();break}let s=Date.now();h!==null&&s-h>6e4*2&&(x(`[bridge:repl] Detected system sleep (${Math.round((s-h)/1e3)}s gap), resetting poll error budget`),T(`info`,`bridge_repl_poll_sleep_detected`,{gapMs:s-h}),p=0,m=null),h=s,p++,m===null&&(m=s);let c=s-m,f=ge(i),_=_e(i),y=o?.()??`unknown`;if(x(`[bridge:repl] Poll error (attempt ${p}, elapsed ${Math.round(c/1e3)}s, ws=${y}): ${_}`),j(`tengu_bridge_repl_poll_error`,{status:f,consecutiveErrors:p,elapsedMs:c}),p===1&&r?.(`reconnecting`,_),c>=9e5){x(`[bridge:repl] Poll failures exceeded ${Qe/1e3}s (${p} errors), giving up`),T(`info`,`bridge_repl_poll_give_up`),j(`tengu_bridge_repl_poll_give_up`,{consecutiveErrors:p,elapsedMs:c,lastStatus:f}),r?.(`failed`,`connection to server lost`);break}let b=Math.min(Xe*2**(p-1),Ze);if(u().non_exclusive_heartbeat_interval_ms>0){let t=d?.();if(t)try{await e.heartbeatWork(t.environmentId,t.workId,t.sessionToken)}catch{}}await I(b,n)}}x(`[bridge:repl] Work poll loop ended (aborted=${n.aborted}) env=${t().environmentId}`)}b(),C(),q(),R();async function nt(e){let{onInboundMessage:t,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,initialMessages:h,getMessages:g,previouslyFlushedUUIDs:b,initialName:S,perpetual:ee,outboundOnly:C,tags:ne}=e??{};if(L(me),!await he())return J(`not_enabled`,`[bridge:repl] Skipping: bridge not enabled`),null;if(!K())return J(`no_oauth`,`[bridge:repl] Skipping: no OAuth tokens`),f?.(`failed`,`authentication required`),null;if(await a(),!i(`allow_remote_control`))return J(`policy_denied`,`[bridge:repl] Skipping: allow_remote_control policy not allowed`),f?.(`failed`,`disabled by your organization's policy`),null;if(!U()){let e=te();if(e.bridgeOauthDeadExpiresAt!=null&&(e.bridgeOauthDeadFailCount??0)>=3&&oe()?.expiresAt===e.bridgeOauthDeadExpiresAt)return x(`[bridge:repl] Skipping: cross-process backoff (dead token seen ${e.bridgeOauthDeadFailCount} times)`),null;await F();let t=oe();if(t&&t.expiresAt!==null&&t.expiresAt<=Date.now()){J(`oauth_expired_unrefreshable`,`[bridge:repl] Skipping: OAuth token expired and refresh failed (re-login required)`),f?.(`failed`,`authentication required`);let e=t.expiresAt;return re(t=>({...t,bridgeOauthDeadExpiresAt:e,bridgeOauthDeadFailCount:t.bridgeOauthDeadExpiresAt===e?(t.bridgeOauthDeadFailCount??0)+1:1})),null}}let w=W(),T=`remote-control-${s()}`,E=!1,O=!1;if(S)T=S,E=!0,O=!0;else{let e=_(),t=e?m(e):void 0;if(t)T=t,E=!0,O=!0;else if(h&&h.length>0)for(let e=h.length-1;e>=0;e--){let t=h[e];if(t.type!==`user`||t.isMeta||t.toolUseResult||t.isCompactSummary||t.origin&&t.origin.kind!==`human`||p(t))continue;let n=o(t.message.content);if(!n)continue;let r=it(n);if(r){T=r,E=!0;break}}}let k=0,A,j=0,ae=(e,t,n)=>{E=!0,T=e,x(`[bridge:repl] derived title from message ${n}: ${e}`),Y(t,e,{baseUrl:w,getAccessToken:K}).catch(()=>{})},M=(e,t)=>{let n=++j,r=k;xe(e,AbortSignal.timeout(15e3)).then(e=>{e&&n===j&&A===t&&!m(_())&&ae(e,t,r)})},P=(e,t)=>{if(O||m(_()))return!0;if(A!==void 0&&A!==t&&(k=0),A=t,k++,k===1&&!E){let n=it(e);n&&ae(n,t,k),M(e,t)}else if(k===3){let n=g?.(),r=n?Q(d(n)):e;M(r,t)}return k>=3},I=G()?`self-hosted`:await se();if(!I)return J(`no_org_uuid`,`[bridge:repl] Skipping: no org UUID`),f?.(`failed`,`/login`),null;if(z()&&!ee){let e=await Ce();if(e)return J(`version_too_old`,`[bridge:repl] Skipping: ${e}`,!0),f?.(`failed`,"run `claude update` to upgrade"),null;x(`[bridge:repl] Using env-less bridge path (tengu_bridge_repl_v2)`);let{initEnvLessBridgeCore:i}=await import(`./remoteBridgeCore-Dpg6Se9C.js`);return i({baseUrl:w,orgUUID:I,title:T,getAccessToken:K,onAuth401:N,toSDKMessages:be,initialHistoryCap:200,initialMessages:h,onInboundMessage:t,onUserMessage:P,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,outboundOnly:C,tags:ne})}let ce=V();if(ce)return J(`version_too_old`,`[bridge:repl] Skipping: ${ce}`),f?.(`failed`,"run `claude update` to upgrade"),null;let le=await ie(),R=await D(),ue=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||w;return et({dir:v(),machineName:Je(),branch:le,gitRepoUrl:R,title:T,baseUrl:w,sessionIngressUrl:ue,workerType:`claude_code`,getAccessToken:K,createSession:e=>X({...e,events:[],baseUrl:w,getAccessToken:K}),archiveSession:e=>Z(e,{baseUrl:w,getAccessToken:K,timeoutMs:1500}).catch(e=>{x(`[bridge:repl] archiveBridgeSession threw: ${y(e)}`,{level:`error`})}),getCurrentTitle:()=>m(_())??T,onUserMessage:P,toSDKMessages:be,onAuth401:N,getPollIntervalConfig:Oe,initialHistoryCap:200,initialMessages:h,previouslyFlushedUUIDs:b,onInboundMessage:t,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,perpetual:ee})}var rt=50;function it(e){let t=O(e),n=(/^(.*?[.!?])\s/.exec(t)?.[1]??t).replace(/\s+/g,` `).trim();if(n)return n.length>rt?n.slice(0,rt-1)+`…`:n}export{nt as initReplBridge};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return c||(c=new Intl.Segmenter(void 0,{granularity:`grapheme`})),c}function n(e){return e?t().segment(e)[Symbol.iterator]().next().value?.segment??``:``}function r(e){if(!e)return``;let n=``;for(let{segment:r}of t().segment(e))n=r;return n}function i(){return l||(l=new Intl.Segmenter(void 0,{granularity:`word`})),l}function a(e,t){let n=`${e}:${t}`,r=u.get(n);return r||(r=new Intl.RelativeTimeFormat(`en`,{style:e,numeric:t}),u.set(n,r)),r}function o(){return d||(d=Intl.DateTimeFormat().resolvedOptions().timeZone),d}function s(){if(f===null)try{let e=Intl.DateTimeFormat().resolvedOptions().locale;f=new Intl.Locale(e).language}catch{f=void 0}return f}var c,l,u,d,f,p=e((()=>{c=null,l=null,u=new Map,d=null,f=null}));export{o as a,r as c,s as i,t as n,i as o,a as r,p as s,n as t};
@@ -1,2 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Bw as t,Fw as n,Hw as r,Nw as i,Pw as a,Rw as o,Uw as s,Vw as c}from"./loadAgentsDir-CKSb56Gp.js";import{I as l,S as u,w as d,z as f}from"./debug-BdqxZ7rV.js";import{r as p,t as m}from"./promptEditor-0Ug93P2I.js";import{dirname as h}from"path";import{mkdir as g,writeFile as _}from"fs/promises";function v(e){let t=new Set(o.map(e=>c(e.key)));return e.map(e=>{let n={};for(let[r,i]of Object.entries(e.bindings))t.has(c(r))||(n[r]=i);return{context:e.context,bindings:n}}).filter(e=>Object.keys(e.bindings).length>0)}function y(){return d({$schema:`https://www.schemastore.org/claude-code-keybindings.json`,$docs:`https://code.claude.com/docs/en/keybindings`,bindings:v(r)},null,2)+`
2
- `}var b=e((()=>{u(),s(),t()}));async function x(){if(!n())return{type:`text`,value:`Keybinding customization is not enabled. This feature is currently in preview.`};let e=i(),t=!1;await g(h(e),{recursive:!0});try{await _(e,y(),{encoding:`utf-8`,flag:`wx`})}catch(e){if(l(e)===`EEXIST`)t=!0;else throw e}let r=await m(e);return r.error?{type:`text`,value:`${t?`Opened`:`Created`} ${e}. Could not open in editor: ${r.error}`}:{type:`text`,value:t?`Opened ${e} in your editor.`:`Created ${e} with template. Opened in your editor.`}}e((()=>{a(),b(),f(),p()}))();export{x as call};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./language-CxThoWRC.js";e();export{t as getResolvedLanguage};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,h as n}from"./config-D4G8_MqJ.js";import{i as r,s as i}from"./intl-cKc-V6Mq.js";function a(){let e=t().preferredLanguage??`auto`;return e===`en`||e===`zh`?e:r()===`zh`?`zh`:`en`}var o=e((()=>{n(),i()}));export{o as n,a as t};
@@ -1 +0,0 @@
1
- import{o as e,t}from"./loadAgentsDir-CKSb56Gp.js";e();export{t as clearAgentDefinitionsCache};
@@ -1 +0,0 @@
1
- import{gg as e,mg as t,pg as n}from"./loadAgentsDir-CKSb56Gp.js";n();export{t as loadPluginHooks,e as setupPluginHookHotReload};
@@ -1 +0,0 @@
1
- import{a as e,c as t,o as n,t as r}from"./localSearch-CPOnyi8I.js";n();export{r as clearSkillIndexCache,e as getSkillIndex,t as searchSkills};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-BDhHQY0-.js";import{Dn as ee,En as te,Kt as ne}from"./state-Bs5xweDL.js";import{S as re,U as ie,W as ae,d as a,p as oe,z as se}from"./debug-BdqxZ7rV.js";import{i as ce,t as le}from"./hash-Tu-My5Vp.js";import{join as o}from"path";import s from"node:process";import c from"node:path";import l from"node:os";import"fs/promises";var u,d,ue,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,de,P,F,I=e((()=>{u=`command-name`,d=`command-message`,ue=`command-args`,f=`bash-input`,p=`bash-stdout`,m=`bash-stderr`,h=`local-command-stdout`,g=`local-command-stderr`,_=`local-command-caveat`,v=[f,p,m,h,g,_],y=`tick`,b=`task-notification`,x=`task-id`,S=`tool-use-id`,C=`task-type`,w=`output-file`,T=`status`,E=`summary`,D=`worktree`,O=`worktreePath`,k=`worktreeBranch`,A=`remote-review`,j=`remote-review-progress`,M=`cross-session-message`,N=`fork-boilerplate`,de=`Your directive: `,P=[`help`,`-h`,`--help`],F=[`list`,`show`,`display`,`current`,`view`,`get`,`check`,`describe`,`print`,`version`,`about`,`status`,`?`]}));function fe(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`.`&&t!==`..`&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function L(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(!fe(e))throw Error(`Unsafe filename: ${JSON.stringify(e)}`)}var pe=e((()=>{Object.freeze([``,` `,`.`,`..`,` .`,`. `,` ..`,`.. `,`../`,`../foo`,`foo/../bar`,`foo/bar`,`foo\\bar`,`foo\0bar`])}));function me(e,{suffix:t=`nodejs`}={}){return L(e),t&&(e+=`-${t}`),L(e),s.platform===`darwin`?V(e):s.platform===`win32`?H(e):U(e)}var R,z,B,V,H,U,he=e((()=>{pe(),R=l.homedir(),z=l.tmpdir(),{env:B}=s,V=e=>{let t=c.join(R,`Library`);return{data:c.join(t,`Application Support`,e),config:c.join(t,`Preferences`,e),cache:c.join(t,`Caches`,e),log:c.join(t,`Logs`,e),temp:c.join(z,e)}},H=e=>{let t=B.APPDATA||c.join(R,`AppData`,`Roaming`),n=B.LOCALAPPDATA||c.join(R,`AppData`,`Local`);return{data:c.join(n,e,`Data`),config:c.join(t,e,`Config`),cache:c.join(n,e,`Cache`),log:c.join(n,e,`Log`),temp:c.join(z,e)}},U=e=>{let t=c.basename(R);return{data:c.join(B.XDG_DATA_HOME||c.join(R,`.local`,`share`),e),config:c.join(B.XDG_CONFIG_HOME||c.join(R,`.config`),e),cache:c.join(B.XDG_CACHE_HOME||c.join(R,`.cache`),e),log:c.join(B.XDG_STATE_HOME||c.join(R,`.local`,`state`),e),temp:c.join(z,t,e)}}}));function W(e){let t=e.replace(/[^a-zA-Z0-9]/g,`-`);return t.length<=q?t:`${t.slice(0,q)}-${Math.abs(le(e)).toString(36)}`}function G(e){return W(e)}var K,q,J,ge=e((()=>{he(),oe(),ce(),K=me(`claude-cli`),q=200,J={baseLogs:()=>o(K.cache,G(a().cwd())),errors:()=>o(K.cache,G(a().cwd()),`errors`),messages:()=>o(K.cache,G(a().cwd()),`messages`),mcpLogs:e=>o(K.cache,G(a().cwd()),`mcp-logs-${W(e)}`)}}));function _e(e){return e.replace(Y,``).trim()||e}function ve(e){return e.replace(Y,``).trim()}function ye(e){return e.replace(be,``).trim()}var Y,be,xe=e((()=>{Y=/<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g,be=/<(ide_opened_file|ide_selection)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g}));function Se(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`essential-traffic`:process.env.DISABLE_TELEMETRY?`no-telemetry`:`default`}function Ce(){return Se()===`essential-traffic`}function we(){return Se()!=="default"}function Te(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`:null}var Ee=e((()=>{}));function De(e,t){let n=e.firstPrompt?.startsWith(`<${y}>`),r=e.firstPrompt?ve(e.firstPrompt):``,i=r&&!n;return _e(e.agentName||e.customTitle||e.summary||(i?r:void 0)||t||(n?`Autonomous session`:void 0)||(e.sessionId?e.sessionId.slice(0,8):``)||``).trim()}function Oe(e){return e.toISOString().replace(/[:.]/g,`-`)}function ke(e){Z.length>=X&&Z.shift(),Z.push(e)}function Ae(e){if($===null&&($=e,Q.length>0)){let e=[...Q];Q.length=0;for(let t of e)switch(t.type){case`error`:$.logError(t.error);break;case`mcpError`:$.logMCPError(t.serverName,t.error);break;case`mcpDebug`:$.logMCPDebug(t.serverName,t.message);break}}}function je(e){let t=ae(e);try{if(r(process.env.CLAUDE_CODE_USE_BEDROCK)||r(process.env.CLAUDE_CODE_USE_VERTEX)||r(process.env.CLAUDE_CODE_USE_FOUNDRY)||process.env.DISABLE_ERROR_REPORTING||Ce())return;if(ke({error:ie(t),timestamp:new Date().toISOString()}),$===null){Q.push({type:`error`,error:t});return}$.logError(t)}catch{}}function Me(){return[...Z]}function Ne(e,t){try{if($===null){Q.push({type:`mcpError`,serverName:e,error:t});return}$.logMCPError(e,t)}catch{}}function Pe(e,t){try{if($===null){Q.push({type:`mcpDebug`,serverName:e,message:t});return}$.logMCPDebug(e,t)}catch{}}function Fe(e,t){if(!t||!t.startsWith(`repl_main_thread`))return;let{messages:n,...r}=e;te(r),ee(null)}var X,Z,Q,$,Ie=e((()=>{n(),ne(),I(),ge(),xe(),i(),se(),Ee(),re(),X=100,Z=[],Q=[],$=null,t(()=>process.argv.includes(`--hard-fail`))}));export{de as A,b as B,ue as C,F as D,P as E,j as F,k as G,v as H,A as I,I as J,O as K,T as L,g as M,h as N,M as O,w as P,E as R,p as S,u as T,y as U,C as V,S as W,ye as _,De as a,f as b,Pe as c,Ee as d,Ce as f,ve as g,_e as h,Me as i,_ as j,N as k,Ne as l,xe as m,Fe as n,Ie as o,we as p,D as q,Oe as r,je as s,Ae as t,Te as u,J as v,d as w,m as x,ge as y,x as z};
@@ -1 +0,0 @@
1
- import{r as e,t}from"./managedEnv-Cl7YbYzf.js";e();export{t as applyConfigEnvironmentVariables};
@@ -1,6 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{AC as t,DC as n,Fu as r,HS as i,IC as a,JS as o,KS as s,MC as c,Pu as l,SC as u,US as d,VS as f,WS as ee,_m as te,av as p,bD as ne,cC as m,ff as h,hS as g,kC as _,md as v,ov as re,pd as ie,sC as y,uf as b,vC as x,vm as ae,xD as oe,xS as se,yC as S,yS as C}from"./loadAgentsDir-CKSb56Gp.js";import{D as w,H as T,I as E,P as D,T as O,fi as k,j as A,kn as j,t as M,y as N}from"./src-P_wYS_NJ2.js";import{t as P}from"./jsx-runtime-Bb4Xn-E0.js";import{H as F,z as I}from"./debug-BdqxZ7rV.js";import{c as L,h as R,o as z,v as B}from"./config-D4G8_MqJ.js";import{n as V,o as ce}from"./process-gEbdy6uY.js";import{i as H,o as U}from"./platform-D6IMiyqT.js";import{s as W,u as G}from"./types-DWRxAH0E.js";import{n as le,r as K}from"./analytics-DJobLaWP.js";import{l as q,o as ue}from"./stringUtils-CbS6OkmE.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";ne();var X=e(k(),1);h(),V(),M(),c(),ue(),ae(),v();var Z=P();function pe({servers:e,scope:t,onDone:r}){let i=Object.keys(e),[a,o]=(0,X.useState)({});(0,X.useEffect)(()=>{n().then(({servers:e})=>o(e))},[]);let s=i.filter(e=>a[e]!==void 0);async function c(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(a[e]!==void 0){let t=1;for(;a[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await u(e,n,t),r++}}d(r)}let[l]=T(),d=(0,X.useCallback)(e=>{ce(e>0?`\n${A(`success`,l)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
- No servers were imported.`),r(),b()},[l,t,r]),f=(0,X.useCallback)(()=>{d(0)},[d]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${i.length} MCP ${q(i.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:f,hideInputGuide:!0,children:[s.length>0&&(0,Z.jsx)(D,{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)(D,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(ie,{options:i.map(e=>({label:`${e}${s.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:i.filter(e=>!s.includes(e)),onSubmit:c,onCancel:f,hideIndexes:!0})]}),(0,Z.jsx)(E,{paddingX:1,children:(0,Z.jsx)(D,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(w,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(w,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(te,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}M(),r(),le(),ee(),se(),c(),S(),re(),R(),I(),h(),W(),U();async function Q(e,t){try{let n=await g(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-uZ0dSekt.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-BjlaPUWX.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,n){let r=_(e),o=()=>{r&&(r.type===`sse`||r.type===`http`)&&(i(e,r),f(e,r))};try{if(n.scope){let t=m(n.scope);K(`tengu_mcp_delete`,{name:e,scope:t}),await a(e,t),o(),process.stdout.write(`Removed MCP server ${e} from ${t} config\n`),J(`File modified: ${y(t)}`)}let r=z(),i=L(),{servers:s}=t(`project`),c=!!s[e],l=[];if(r.mcpServers?.[e]&&l.push(`local`),c&&l.push(`project`),i.mcpServers?.[e]&&l.push(`user`),l.length===0)Y(`No MCP server found with name: "${e}"`);else if(l.length===1){let t=l[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await a(e,t),o(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${y(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),l.forEach(e=>{process.stderr.write(` - ${x(e)} (${y(e)})\n`)}),process.stderr.write(`
3
- To remove from a specific scope, use:
4
- `),l.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 n();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
- `);let t=await oe(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:C()});for(let{name:e,server:n,status:r}of t)if(n.type===`sse`)console.log(`${e}: ${n.url} (SSE) - ${r}`);else if(n.type===`http`)console.log(`${e}: ${n.url} (HTTP) - ${r}`);else if(n.type===`claudeai-proxy`)console.log(`${e}: ${n.url} - ${r}`);else if(!n.type||n.type===`stdio`){let t=n,i=Array.isArray(t.args)?t.args:[];console.log(`${e}: ${t.command} ${i.join(` `)} - ${r}`)}}await b(0)}async function $(e){K(`tengu_mcp_get`,{name:e});let t=_(e);t||Y(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${x(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`),d(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`),d(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 b(0)}async function _e(e,t,n){try{let r=m(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 s():void 0;await u(e,i,r);let c=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`&&o(e,{type:i.type,url:i.url},a),K(`tengu_mcp_add`,{scope:r,source:`json`,type:c}),J(`Added ${c} MCP server ${e} to ${r} config`)}catch(e){Y(e.message)}}async function ve(e){try{let t=m(e.scope);K(`tengu_mcp_add`,{scope:t,platform:H(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-CAmnheYx.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 j((0,Z.jsx)(p,{children:(0,Z.jsx)(l,{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.
6
- You will be prompted for approval next time you start Work Mate.`)}export{ve as mcpAddFromDesktopHandler,_e as mcpAddJsonHandler,$ as mcpGetHandler,ge as mcpListHandler,he as mcpRemoveHandler,ye as mcpResetChoicesHandler,me as mcpServeHandler};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{BS as i,Ew as a,GS as o,Vu as s,WS as c,_m as l,cv as u,dd as d,gC as f,mC as p,ov as m,sC as h,sv as g,ud as _,vm as v,yC as y,zS as b,zu as x}from"./loadAgentsDir-CKSb56Gp.js";import{D as S,Gt as ee,H as C,I as w,Lt as T,P as E,T as D,Wt as O,fi as k,j as A,t as j,y as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{a as te,o as ne}from"./debug-BdqxZ7rV.js";import{l as re,n as ie,o as P}from"./stringUtils-CbS6OkmE.js";import{F as ae,I as oe}from"./sessionState-BvECKycx.js";import{i as se,n as F,r as ce}from"./MCPConnectionManager-DPFe4hPh.js";import{n as le,t as ue}from"./McpParsingWarnings-CH4yyMAL.js";import{a as de,c as I,i as L,n as R,o as z,r as fe,s as pe,t as me}from"./MCPToolListView-BPmE0C2o.js";function he({agentServer:e,onCancel:t,onComplete:n}){let[i]=C(),[a,s]=(0,B.useState)(!1),[c,u]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),m=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>m.current?.abort(),[]),O(`confirm:no`,(0,B.useCallback)(()=>{a&&(m.current?.abort(),m.current=null,s(!1),p(null))},[a]),{context:`Confirmation`,isActive:a});let h=(0,B.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;s(!0),u(null);let t=new AbortController;m.current=t;try{let r={type:e.transport,url:e.url};await o(e.name,r,p,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof b)&&u(e.message)}finally{s(!1),m.current=null}},[e,n]),g=ie(String(e.name));if(a)return(0,V.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,V.jsxs)(E,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,V.jsxs)(w,{children:[(0,V.jsx)(x,{}),(0,V.jsx)(E,{children:` A browser window will open for authentication`})]}),f&&(0,V.jsxs)(w,{flexDirection:`column`,children:[(0,V.jsx)(E,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,V.jsx)(T,{url:f})]}),(0,V.jsx)(w,{marginLeft:3,children:(0,V.jsxs)(E,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,V.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let _=[];return e.needsAuth&&_.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),_.push({label:`Back`,value:`back`}),(0,V.jsxs)(M,{title:`${g} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,V.jsxs)(E,{children:[`Press `,e.keyName,` again to exit`]}):(0,V.jsxs)(D,{children:[(0,V.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,V.jsx)(S,{shortcut:`Enter`,action:`confirm`}),(0,V.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,V.jsxs)(w,{flexDirection:`column`,gap:0,children:[(0,V.jsxs)(w,{children:[(0,V.jsx)(E,{bold:!0,children:`Type: `}),(0,V.jsx)(E,{dimColor:!0,children:e.transport})]}),e.url&&(0,V.jsxs)(w,{children:[(0,V.jsx)(E,{bold:!0,children:`URL: `}),(0,V.jsx)(E,{dimColor:!0,children:e.url})]}),e.command&&(0,V.jsxs)(w,{children:[(0,V.jsx)(E,{bold:!0,children:`Command: `}),(0,V.jsx)(E,{dimColor:!0,children:e.command})]}),(0,V.jsxs)(w,{children:[(0,V.jsx)(E,{bold:!0,children:`Used by: `}),(0,V.jsx)(E,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,V.jsxs)(w,{marginTop:1,children:[(0,V.jsx)(E,{bold:!0,children:`Status: `}),(0,V.jsxs)(E,{children:[A(`inactive`,i)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,V.jsxs)(w,{children:[(0,V.jsx)(E,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,V.jsxs)(E,{children:[A(`success`,i)(r.tick),` authenticated`]}):(0,V.jsxs)(E,{children:[A(`warning`,i)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,V.jsx)(w,{children:(0,V.jsx)(E,{dimColor:!0,children:`This server connects only when running the agent.`})}),c&&(0,V.jsx)(w,{children:(0,V.jsxs)(E,{color:`error`,children:[`Error: `,c]})}),(0,V.jsx)(w,{children:(0,V.jsx)(d,{options:_,onChange:async e=>{switch(e){case`auth`:await h();break;case`back`:t();break}},onCancel:t})})]})}var B,V,H=e((()=>{n(),B=t(k(),1),j(),a(),c(),P(),v(),_(),s(),V=N()}));function U(e){switch(e){case`project`:return{label:`Project MCPs`,path:h(e)};case`user`:return{label:`User MCPs`,path:h(e)};case`local`:return{label:`Local MCPs`,path:h(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function ge(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 _e({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:i,onComplete:a}){let[o]=C(),[s,c]=(0,W.useState)(0),u=W.useMemo(()=>ge(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),d=W.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),f=W.useMemo(()=>(u.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[u]),p=U(`dynamic`),m=W.useMemo(()=>{let e=[];for(let t of K){let n=u.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of d)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of f)e.push({type:`server`,server:t});return e},[u,d,t,f]),h=(0,W.useCallback)(()=>{a(`MCP dialog dismissed`,{display:`system`})},[a]);ee({"confirm:previous":()=>c(e=>e===0?m.length-1:e-1),"confirm:next":()=>c(e=>e===m.length-1?0:e+1),"confirm:yes":(0,W.useCallback)(()=>{let e=m[s];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&i&&i(e.agentServer))},[m,s,n,i]),"confirm:no":h},{context:`Confirmation`});let g=e=>m.findIndex(t=>t.type===`server`&&t.server===e),_=e=>m.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),v=ne(),y=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let b=e=>{let t=g(e),n=s===t,i=``,a=``;if(e.client.type===`disabled`)i=A(`inactive`,o)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=A(`success`,o)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=A(`inactive`,o)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=A(`warning`,o)(r.triangleUpOutline),a=`needs authentication`):(i=A(`error`,o)(r.cross),a=`failed`);return(0,G.jsxs)(w,{children:[(0,G.jsx)(E,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,G.jsx)(E,{color:n?`suggestion`:void 0,children:e.name}),(0,G.jsxs)(E,{dimColor:!n,children:[` · `,i,` `]}),(0,G.jsx)(E,{dimColor:!n,children:a})]},`${e.name}-${t}`)},x=e=>{let t=_(e),n=s===t,i=e.needsAuth?A(`warning`,o)(r.triangleUpOutline):A(`inactive`,o)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,G.jsxs)(w,{children:[(0,G.jsx)(E,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,G.jsx)(E,{color:n?`suggestion`:void 0,children:e.name}),(0,G.jsxs)(E,{dimColor:!n,children:[` · `,i,` `]}),(0,G.jsx)(E,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},O=e.length+t.length;return(0,G.jsxs)(w,{flexDirection:`column`,children:[(0,G.jsx)(ue,{}),(0,G.jsx)(M,{title:`Manage MCP servers`,subtitle:`${O} ${re(O,`server`)}`,onCancel:h,hideInputGuide:!0,children:(0,G.jsxs)(w,{flexDirection:`column`,children:[K.map(e=>{let t=u.get(e);if(!t||t.length===0)return null;let n=U(e);return(0,G.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsxs)(w,{paddingLeft:2,children:[(0,G.jsx)(E,{bold:!0,children:n.label}),n.path&&(0,G.jsxs)(E,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>b(e))]},e)}),d.length>0&&(0,G.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(w,{paddingLeft:2,children:(0,G.jsx)(E,{bold:!0,children:`claude.ai`})}),d.map(e=>b(e))]}),t.length>0&&(0,G.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(w,{paddingLeft:2,children:(0,G.jsx)(E,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,G.jsxs)(w,{flexDirection:`column`,marginTop:1,children:[(0,G.jsx)(w,{paddingLeft:2,children:(0,G.jsxs)(E,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>x(e))]},e))]}),f.length>0&&(0,G.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsxs)(w,{paddingLeft:2,children:[(0,G.jsx)(E,{bold:!0,children:p.label}),p.path&&(0,G.jsxs)(E,{dimColor:!0,children:[` (`,p.path,`)`]})]}),f.map(e=>b(e))]}),(0,G.jsxs)(w,{flexDirection:`column`,children:[y&&(0,G.jsx)(E,{dimColor:!0,children:v?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,G.jsxs)(E,{dimColor:!0,children:[(0,G.jsx)(T,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,G.jsx)(w,{paddingX:1,children:(0,G.jsx)(E,{dimColor:!0,italic:!0,children:(0,G.jsxs)(D,{children:[(0,G.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,G.jsx)(S,{shortcut:`Enter`,action:`confirm`}),(0,G.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var W,G,K,q=e((()=>{n(),W=t(k(),1),j(),a(),y(),te(),P(),v(),le(),G=N(),K=[`project`,`local`,`user`,`enterprise`]}));function ve({serverName:e,onComplete:t}){let[n]=C(),i=u(),a=ce(),[o,s]=(0,J.useState)(!0),[c,l]=(0,J.useState)(null);return(0,J.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){l(`MCP server "${e}" not found`),s(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:s(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:l(`${e} requires authentication`),s(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:l(`Failed to reconnect to ${e}`),s(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);l(n),s(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),o?(0,Y.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,Y.jsxs)(E,{color:`text`,children:[`Reconnecting to `,(0,Y.jsx)(E,{bold:!0,children:e})]}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(x,{}),(0,Y.jsx)(E,{children:` Establishing connection to MCP server`})]})]}):c?(0,Y.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,Y.jsxs)(w,{children:[(0,Y.jsxs)(E,{children:[A(`error`,n)(r.cross),` `]}),(0,Y.jsxs)(E,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,Y.jsxs)(E,{dimColor:!0,children:[`Error: `,c]})]}):null}var J,Y,ye=e((()=>{n(),J=t(k(),1),j(),F(),m(),s(),Y=N()}));function be({onComplete:e}){let t=g(e=>e.mcp),n=g(e=>e.agentDefinitions),r=t.clients,[a,o]=X.useState({type:`list`}),[s,c]=X.useState([]),l=(0,X.useMemo)(()=>p(n.allAgents),[n.allAgents]),u=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(u.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,a=e.config.type===`http`,o=e.config.type===`claudeai-proxy`,s;if(r||a){let n=await new i(e.name,e.config).tokens(),r=ae()!==null&&e.type===`connected`,a=e.type===`connected`&&f(t.tools,e.name).length>0;s=!!n||r||a}let c={name:e.name,client:e,scope:n};return o?{...c,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...c,transport:`sse`,isAuthenticated:s,config:e.config}:a?{...c,transport:`http`,isAuthenticated:s,config:e.config}:{...c,transport:`stdio`,config:e.config}}));e||c(n)}return n(),()=>{e=!0}},[u,t.tools]),(0,X.useEffect)(()=>{s.length===0&&u.length>0||s.length===0&&l.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.")},[s.length,u.length,l.length,e]),a.type){case`list`:return(0,Z.jsx)(_e,{servers:s,agentServers:l,onSelectServer:e=>o({type:`server-menu`,server:e}),onSelectAgentServer:e=>o({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:a.defaultTab});case`server-menu`:{let n=f(t.tools,a.server.name),r=a.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return a.server.transport===`stdio`?(0,Z.jsx)(de,{server:a.server,serverToolsCount:n.length,onViewTools:()=>o({type:`server-tools`,server:a.server}),onCancel:()=>o({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(pe,{server:a.server,serverToolsCount:n.length,onViewTools:()=>o({type:`server-tools`,server:a.server}),onCancel:()=>o({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(me,{server:a.server,onSelectTool:(e,t)=>o({type:`server-tool-detail`,server:a.server,toolIndex:t}),onBack:()=>o({type:`server-menu`,server:a.server})});case`server-tool-detail`:{let e=f(t.tools,a.server.name)[a.toolIndex];return e?(0,Z.jsx)(fe,{tool:e,server:a.server,onBack:()=>o({type:`server-tools`,server:a.server})}):(o({type:`server-tools`,server:a.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(he,{agentServer:a.agentServer,onCancel:()=>o({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,xe=e((()=>{X=t(k(),1),c(),y(),m(),oe(),H(),q(),I(),z(),L(),R(),Z=N()})),Se=e((()=>{H(),q(),ye(),I(),xe(),z(),L(),R()}));function Ce({action:e,target:t,onComplete:n}){let r=g(e=>e.mcp.clients),i=se(),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 we(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(be,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(ve,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Ce,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return(0,$.jsx)(be,{onComplete:e})}var Q,$;e((()=>{Q=t(k(),1),Se(),ye(),F(),m(),$=N()}))();export{we as call};
@@ -1,2 +0,0 @@
1
- import{$w as e,AS as t,CT as n,DT as r,ET as i,Gl as a,Gw as o,Hx as s,Jw as c,Kw as l,Mg as u,Ng as d,Oa as f,Qa as p,Qw as m,TT as h,U as ee,Ux as te,W as ne,Wl as g,Ww as _,Xw as v,Yw as y,Zw as b,_T as x,aT as S,aa as C,bT as w,bv as T,dT as E,dc as D,dl as O,eT as k,fT as A,fc as j,fl as M,gT as N,hT as P,iT as F,kS as I,lT as L,mT as R,nT as z,oa as re,pT as B,qw as V,rT as H,sT as U,tT as W,uT as G,wT as K,xT as q,xv as J}from"./loadAgentsDir-CKSb56Gp.js";import{S as Y,w as X}from"./debug-BdqxZ7rV.js";import{o as ie,s as ae}from"./log-CTFl4qpD.js";import{_ as oe,u as se}from"./model-C2e73CJD.js";import{bn as ce,vn as Z,yn as Q}from"./prompt-CybUvG8G.js";import $ from"node:process";h(),e(),b(),n();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},H,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},U,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)}};n(),y();var ue=class extends m{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(N.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new v,this.setRequestHandler(E,e=>this._oninitialize(e)),this.setNotificationHandler(A,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(q,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=N.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=k(this._capabilities,e)}setRequestHandler(e,t){let n=K(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let a;if(i(n)){let e=n;a=e._zod?.def?.value??e.value}else{let e=n;a=e._def?.value??e.value}if(typeof a!=`string`)throw Error(`Schema method literal must be a string`);return a===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let i=r(W,e);if(!i.success){let e=i.error instanceof Error?i.error.message:String(i.error);throw new x(G.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:a}=i.data,o=await Promise.resolve(t(e,n));if(a.task){let e=r(S,o);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new x(G.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let s=r(z,o);if(!s.success){let e=s.error instanceof Error?s.error.message:String(s.error);throw new x(G.InvalidParams,`Invalid tools/call result: ${e}`)}return s.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){V(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&c(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:w.includes(t)?t:B,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`},L)}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},F,t):this.request({method:`sampling/createMessage`,params:e},H,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},U,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},U,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new x(G.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof x?e:new x(G.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},R,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};o();var de=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new _,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=l(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};n(),j(),C(),ce(),M(),t(),te(),ie(),p(),oe(),ne(),T(),Y(),a(),u();var fe=[re];async function pe(e,t,n){let r=s(100);J(e);let i=new ue({name:`claude/tengu`,version:`0.0.9`},{capabilities:{tools:{}}});i.setRequestHandler(P,async()=>{let e=Q(),t=O(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=d(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:d(n.inputSchema),outputSchema:r}}))}}),i.setRequestHandler(W,async({params:{name:e,arguments:i}})=>{let a=O(Q()),o=Z(a,e);if(!o)throw Error(`Tool ${e} not found`);let s={abortController:I(),options:{commands:fe,tools:a,mainLoopModel:se(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:n,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>D(),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,ee,f({content:[]}));return{content:[{type:`text`,text:typeof n==`string`?n:X(n.data)}]}}catch(e){return ae(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?g(e):[String(e)]).filter(Boolean).join(`
2
- `).trim()||`Error`}]}}});async function a(){let e=new de;await i.connect(e)}return await a()}export{pe as startMCPServer};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-BDhHQY0-.js";import{Af as i,Bn as a,Ew as o,Hn as s,Ix as c,Px as l,Qc as ee,Zc as u,dd as te,iw as d,jf as f,jx as p,ov as m,ow as ne,sv as h,ud as g}from"./loadAgentsDir-CKSb56Gp.js";import{I as _,Lt as v,P as y,Wt as b,_ as x,di as S,fi as C,t as w,ui as re,y as T}from"./src-P_wYS_NJ2.js";import{t as E}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as D,tt as O}from"./state-Bs5xweDL.js";import{n as k,t as A}from"./cwd-L4wygFqJ.js";import{I as j,z as M}from"./debug-BdqxZ7rV.js";import{Cn as N,bn as ie,g as P,x as F}from"./settings-Xbq6AaD-.js";import{M as I,P as L,k as ae}from"./config-D4G8_MqJ.js";import{m as R,r as z}from"./git-B9uvt96d.js";import{o as oe,s as se}from"./log-CTFl4qpD.js";import{n as ce,r as B}from"./analytics-DJobLaWP.js";import{m as le,v as V}from"./startupProfiler-jeId9f2i.js";import{n as H,t as U}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import{r as ue,t as de}from"./promptEditor-0Ug93P2I.js";import{homedir as fe}from"os";import{join as W,relative as pe}from"path";import{mkdir as G,writeFile as me}from"fs/promises";function he(e){return z(e)!==null}var ge=e((()=>{R()}));function _e({onSelect:e,onCancel:t}){let r=(0,K.use)(l()),i=W(n(),`CLAUDE.md`),o=W(O(),`CLAUDE.md`),s=r.some(e=>e.path===i),c=r.some(e=>e.path===o),u=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...s?[]:[{path:i,type:`User`,content:``,exists:!1}],...c?[]:[{path:o,type:`Project`,content:``,exists:!1}]],d=new Map,p=u.map(e=>{let t=ie(e.path),n=e.exists?``:` (new)`,r=e.parent?(d.get(e.parent)??0)+1:0;d.set(e.path,r);let a=r>0?` `.repeat(r-1):``,s;s=e.type===`User`&&!e.isNested&&e.path===i?`User memory`:e.type===`Project`&&!e.isNested&&e.path===o?`Project memory`:r>0?`${a}L ${t}${n}`:`${t}`;let c,l=he(O());return c=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===o?`${l?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:s,value:e.path,description:c}}),m=[],g=h(e=>e.agentDefinitions);if(L()){m.push({label:`Open auto-memory folder`,value:`${Y}${ae()}`,description:``});for(let e of g.activeAgents)if(e.memory){let t=a(e.agentType,e.memory);m.push({label:`Open ${re.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}p.push(...m);let v=J&&p.some(e=>e.value===J)?J:p[0]?.value||``,[S,C]=(0,K.useState)(L),[w,T]=(0,K.useState)(ee),[E]=(0,K.useState)(L),D=h(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,K.useState)(null);(0,K.useEffect)(()=>{E&&f().then(A)},[E,D]);let j=D?`running`:k===null?``:k===0?`never`:`last ran ${le(new Date(k))}`,[M,N]=(0,K.useState)(null),P=M!==null,I=+!!E;function R(){let e=!S;F(`userSettings`,{autoMemoryEnabled:e}),C(e),B(`tengu_auto_memory_toggled`,{enabled:e})}function z(){let e=!w;F(`userSettings`,{autoDreamEnabled:e}),T(e),B(`tengu_auto_dream_toggled`,{enabled:e})}return H(),b(`confirm:no`,t,{context:`Confirmation`}),b(`confirm:yes`,()=>{M===0?R():M===1&&z()},{context:`Confirmation`,isActive:P}),b(`select:next`,()=>{N(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:P}),b(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:P}),(0,q.jsxs)(_,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(_,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(x,{isFocused:M===0,children:(0,q.jsxs)(y,{children:[`Auto-memory: `,S?`on`:`off`]})}),E&&(0,q.jsx)(x,{isFocused:M===1,styled:!1,children:(0,q.jsxs)(y,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,q.jsxs)(y,{dimColor:!0,children:[` · `,j]}),!D&&w&&(0,q.jsx)(y,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(te,{defaultFocusValue:v,options:p,isDisabled:P,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>ne(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(I)})]})}var K,q,J,Y,ve=e((()=>{S(),C(),K=t(C(),1),D(),U(),w(),o(),I(),ce(),u(),i(),m(),s(),d(),c(),r(),N(),V(),ge(),P(),g(),q=E(),Y=`__open_folder__`}));function X(e){let t=fe(),n=A(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+pe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{C(),w(),k(),E()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await G(n(),{recursive:!0});try{await me(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(j(e)!==`EEXIST`)throw e}await de(t);let r=`default`,i=``;process.env.VISUAL?(r=`$VISUAL`,i=process.env.VISUAL):process.env.EDITOR&&(r=`$EDITOR`,i=process.env.EDITOR);let a=r==="default"?``:`Using ${r}="${i}".`,o=a?`> ${a} To change editor, set $EDITOR or $VISUAL environment variable.`:`> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;e(`Opened memory file at ${X(t)}\n\n${o}`,{display:`system`})}catch(t){se(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(T,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(_,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_e,{onSelect:t,onCancel:r})}),(0,Q.jsx)(_,{marginTop:1,children:(0,Q.jsxs)(y,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(v,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(C(),1),w(),ve(),ye(),c(),r(),M(),oe(),ue(),Q=E(),$=async e=>(p(),await l(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{d as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./envUtils-BDhHQY0-.js";import{n as ee,t as te}from"./defineProperty-C-QyHrDq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{di as ne,ui as re}from"./src-P_wYS_NJ2.js";import{A as ie,C as ae,p as oe,w as se}from"./external-CEp-aPkt.js";import{n as ce,r as le,t as ue}from"./lazySchema-B4D4qJVE.js";import{$t as de,Br as fe,H as pe,Kt as m,Q as me,Rn as he,Vn as ge,Y as _e,bn as ve,et as ye,fr as be,ft as xe,ln as Se,mt as Ce,pr as we,y as Te,z as h,zr as Ee}from"./state-Bs5xweDL.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-BdqxZ7rV.js";import{Ut as Be,c as y,f as b,g as x,n as Ve,x as He}from"./settings-Xbq6AaD-.js";import{C as Ue,S as We,c as S,h as Ge,n as C,y as w}from"./config-D4G8_MqJ.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-5SylUnAI.js";import{d as $e,f as et,o as tt,s as T}from"./log-CTFl4qpD.js";import{r as nt,t as rt}from"./memoize-FJv2HV1u.js";import{s as it,u as at}from"./types-DWRxAH0E.js";import{n as ot,r as E}from"./analytics-DJobLaWP.js";import{l as D,n as st,r as ct,s as lt,t as ut,u as O}from"./oauth-C9VBDB0Y.js";import{n as dt,t as ft}from"./bundledMode--fG1S62b.js";import{n as pt,o as mt}from"./stringUtils-CbS6OkmE.js";import{a as ht,i as gt,l as _t}from"./proxy-Blq4W6Ox.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{return new URL(e).host===`api.anthropic.com`}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(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 zt=e((()=>{}));function Bt(e,t){return e.find(e=>e.includes(t))??null}async function Vt(){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 U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Ht(){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 U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function Ut(e){return e.startsWith(`anthropic.`)}function Wt(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Gt(e){let t=Wt(e);for(let e of Yt)if(t.startsWith(`${e}.anthropic.`))return e}function Kt(e,t){let n=Gt(e);return n?e.replace(`${n}.`,`${t}.`):Ut(e)?`${t}.${e}`:e}var qt,Jt,Yt,Xt=e((()=>{i(),G(),l(),tt(),_t(),qt=r(async function(){let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([Vt(),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}}),Jt=r(async function(e){try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([Vt(),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}}),Yt=[`us`,`eu`,`apac`,`global`]})),Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn=e((()=>{Zt={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`},Qt={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`},$t={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`},en={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`},tn={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`},nn={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`},rn={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`},an={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`},on={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`},sn={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`},cn={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`},ln={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`},un={haiku35:$t,haiku45:en,sonnet35:Qt,sonnet37:Zt,sonnet40:tn,sonnet45:nn,sonnet46:ln,opus40:rn,opus41:an,opus45:on,opus46:sn,opus47:cn},Object.values(un).map(e=>e.firstParty),dn=Object.fromEntries(Object.entries(un).map(([e,t])=>[t.firstParty,e]))}));function pn(e){let t={};for(let n of yn)t[n]=un[n][e];return t}async function mn(){let e=pn(`bedrock`),t;try{t=await qt()}catch(t){return T(t),e}if(!t?.length)return e;let n={};for(let r of yn){let i=un[r].firstParty;n[r]=Bt(t,i)||e[r]}return n}function hn(e){let t=Ve().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=dn[e];t&&r&&(n[t]=r)}return n}function gn(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 _n(){if(me()===null){if(k()!==`bedrock`){he(pn(k()));return}bn()}}function j(){let e=me();return e===null?(_n(),hn(pn(k()))):hn(e)}async function vn(){if(me()===null){if(k()!==`bedrock`){he(pn(k()));return}await bn()}}var yn,bn,xn=e((()=>{m(),tt(),zt(),x(),Xt(),fn(),A(),yn=Object.keys(un),bn=Rt(async()=>{if(me()===null)try{he(await mn())}catch(e){T(e)}})}));async function Sn(){let e=S().oauthAccount?.accountUuid,t=na();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 Cn(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 wn=e((()=>{p(),O(),G(),Ge(),tt()}));function Tn(e){return!!e?.includes(st)}function En(e){return e?.split(` `).filter(Boolean)??[]}function Dn({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 On(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 kn(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=En(r.scope);E(`tengu_oauth_token_refresh_success`,{});let l=S(),u=W(),d=l.oauthAccount?.billingType!==void 0&&l.oauthAccount?.accountCreatedAt!==void 0&&l.oauthAccount?.subscriptionCreatedAt!==void 0&&u?.subscriptionType!=null&&u?.rateLimitTier!=null?null:await Nn(i);if(d&&l.oauthAccount){let e={};d.displayName!==void 0&&(e.displayName=d.displayName),typeof d.hasExtraUsageEnabled==`boolean`&&(e.hasExtraUsageEnabled=d.hasExtraUsageEnabled),d.billingType!==null&&(e.billingType=d.billingType),d.accountCreatedAt!==void 0&&(e.accountCreatedAt=d.accountCreatedAt),d.subscriptionCreatedAt!==void 0&&(e.subscriptionCreatedAt=d.subscriptionCreatedAt),Object.keys(e).length>0&&w(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:i,refreshToken:a,expiresAt:s,scopes:c,subscriptionType:d?.subscriptionType??u?.subscriptionType??null,rateLimitTier:d?.rateLimitTier??u?.rateLimitTier??null,profile:d?.rawProfile,tokenAccount:r.account?{uuid:r.account.uuid,emailAddress:r.account.email_address,organizationUuid:r.organization?.uuid}:void 0}}catch(e){let t=f.isAxiosError(e)&&e.response?.data?JSON.stringify(e.response.data):void 0;throw E(`tengu_oauth_token_refresh_failure`,{error:e.message,...t&&{responseBody:t}}),e}}async function An(e){let t=await f.get(D().ROLES_URL,{headers:{Authorization:`Bearer ${e}`}});if(t.status!==200)throw Error(`Failed to fetch user roles: ${t.statusText}`);let n=t.data;if(!S().oauthAccount)throw Error(`OAuth account information not found in config`);w(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),E(`tengu_oauth_roles_stored`,{org_role:n.organization_role})}async function jn(e){try{let t=await f.post(D().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await ja(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 Mn(e){return e!==null&&Date.now()+300*1e3>=e}async function Nn(e){let t=await Cn(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 Pn(){let e=S().oauthAccount?.organizationUuid;if(e)return e;let t=W()?.accessToken;return t===void 0||!Ua()?null:(await Cn(t))?.organization?.uuid||null}async function Fn(){let e=process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CLAUDE_CODE_USER_EMAIL,n=process.env.CLAUDE_CODE_ORGANIZATION_UUID,r=!!(e&&t&&n);e&&t&&n&&(S().oauthAccount||In({accountUuid:e,emailAddress:t,organizationUuid:n})),await Va();let i=S();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!R()||!Ua())return!1;let a=W();if(a?.accessToken){let e=await Cn(a.accessToken);if(e)return r&&v(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),In({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 In({accountUuid:e,emailAddress:t,organizationUuid:n,displayName:r,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s}){let c={accountUuid:e,emailAddress:t,organizationUuid:n,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s};r&&(c.displayName=r),w(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}var Ln=e((()=>{p(),ot(),O(),G(),Ge(),_(),wn()}));function Rn(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{xt(Un,{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 zn(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 Bn({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=zn(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),Rn(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=zn(t,n);return i(r),r}}function Vn(){return Bn({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:Wn,label:`OAuth token`,getCached:ye,setCached:ge})}function Hn(){return Bn({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:Gn,label:`API key`,getCached:Te,setCached:Se})}var Un,Wn,Gn,Kn,qn=e((()=>{m(),_(),l(),ze(),Ie(),Un=`/home/claude/.claude/remote`,Wn=`${Un}/.oauth_token`,Gn=`${Un}/.api_key`,Kn=`${Un}/.session_ingress_token`}));function M(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 Jn(){try{return process.env.USER||vt().username}catch{return`claude-code-user`}}function N(){P.cache={data:null,cachedAt:0},P.generation++,P.readInFlight=null}function Yn(e){if(P.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}P.cache={data:t,cachedAt:Date.now()}}var Xn,P,Zn=e((()=>{O(),l(),Xn=`-credentials`,P={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function Qn(){if(process.platform===`darwin`&&(await Ye(`security delete-generic-password -a $USER -s "${M()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function $n(e){return e.slice(-20)}var er=e((()=>{qe(),Zn()}));function tr(e){return e?.name===`CredentialsProviderError`}function nr(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 rr(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function ir(){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((()=>{_()})),or,sr=e((()=>{we(),ee(),or=class e{constructor(){te(this,`status`,{isAuthenticating:!1,output:[]}),te(this,`changed`,be()),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(or,`instance`,null)})),cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr=e((()=>{cr=`claude-code-20250219`,lr=`interleaved-thinking-2025-05-14`,ur=`context-1m-2025-08-07`,dr=`context-management-2025-06-27`,fr=`structured-outputs-2025-12-15`,pr=`tool-search-tool-2025-10-19`,mr=`task-budgets-2026-03-13`,hr=`prompt-caching-scope-2026-01-05`,gr=`fast-mode-2026-02-01`,_r=`redact-thinking-2026-02-12`,vr=`afk-mode-2026-01-31`,yr=`advisor-tool-2026-03-01`,br=new Set([lr,ur,pr]),xr=new Set([cr,lr,dr])}));function Cr(e,t){return Ee(e,t)}var wr=e((()=>{fe()}));function Tr(){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.9 (external, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function Er(){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.9${e.length>0?` (${e.join(`, `)})`:``}`}function Dr(){if(R()){let e=W();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":lt}}:{headers:{},error:`No OAuth token available`}}let e=na();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function Or(e,t){try{return await e()}catch(n){if(!f.isAxiosError(n))throw n;let r=n.response?.status;if(!(r===401||t?.also403Revoked&&r===403&&typeof n.response?.data==`string`&&n.response.data.includes(`OAuth token has been revoked`)))throw n;let i=W()?.accessToken;if(!i)throw n;return await Ra(i),await e()}}var kr=e((()=>{p(),O(),G(),Lt()}));function Ar(){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 jr({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=Nr(),te={"x-app":`cli`,"User-Agent":Tr(),"X-Claude-Code-Session-Id":Ce(),...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 Va(),v(`[API:auth] OAuth token check complete`),R()||await Mr(te,h());let f=Pr(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===Ps()&&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:Ar()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let e=await U();e&&(n.awsAccessKey=e.accessKeyId,n.awsSecretKey=e.secretAccessKey,n.awsSessionToken=e.sessionToken)}return new e(n)}if(s(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(s(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-CGx9qY3q.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...Le()&&{logger:Ar()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await go();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:Ar()}})}return new je({apiKey:R()?null:e||na(),authToken:R()?W()?.accessToken:void 0,...p,...Le()&&{logger:Ar()}})}async function Mr(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await fa(t);n&&(e.Authorization=`Bearer ${n}`)}function Nr(){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 Pr(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(Fr,Tt());try{let n=e instanceof Request?e.url:String(e),r=a.get(Fr);v(`[API REQUEST] ${new URL(n).pathname}${r?` ${Fr}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var Fr,Ir=e((()=>{ke(),G(),kr(),oc(),A(),_t(),m(),_(),l(),Fr=`x-client-request-id`}));function Lr(){return yt(c(),`cache`)}function Rr(){return yt(Lr(),`model-capabilities.json`)}function zr(){return!(k()!==`firstParty`||!Nt())}function Br(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function Vr(e){if(!zr())return;let t=Gr(Rr());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 Hr(){if(zr()&&!et())try{let e=await jr({maxRetries:1}),t=R()?[lt]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=Ur().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=Rr(),i=Br(n);if(Cr(Gr(r),i)){v(`[modelCapabilities] cache unchanged, skipping write`);return}await Et(Lr(),{recursive:!0}),await Ot(r,Re({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),Gr.cache.delete(r),v(`[modelCapabilities] cached ${i.length} models`)}catch(e){v(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var Ur,Wr,Gr,Kr=e((()=>{wr(),i(),le(),O(),Ir(),G(),_(),l(),it(),ue(),$e(),Me(),A(),Ur=ce(()=>se({id:ie(),max_input_tokens:ae().optional(),max_tokens:ae().optional()}).strip()),Wr=ce(()=>se({models:oe(Ur()),timestamp:ae()})),Gr=r(e=>{try{let t=St(e,`utf-8`),n=Wr().safeParse(at(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function qr(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function F(e){return!qr()&&/\[1m\]/i.test(e)}function Jr(e){if(qr())return!1;let t=Q(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Yr(e,t){if(F(e))return 1e6;let n=Vr(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&qr()?ei:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&Jr(e)||Xr(e)?1e6:ei}function Xr(e){return qr()||F(e)||!Q(e).includes(`sonnet-4-6`)?!1:S().clientDataCache?.coral_reef_sonnet===`true`}function Zr(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 Qr(e){let t,n,r=Q(e);r.includes(`opus-4-7`)||r.includes(`opus-4-6`)?(t=64e3,n=128e3):r.includes(`sonnet-4-6`)?(t=32e3,n=128e3):r.includes(`opus-4-5`)||r.includes(`sonnet-4`)||r.includes(`haiku-4`)?(t=32e3,n=64e3):r.includes(`opus-4-1`)||r.includes(`opus-4`)?(t=32e3,n=32e3):r.includes(`claude-3-opus`)?(t=4096,n=4096):r.includes(`claude-3-sonnet`)?(t=8192,n=8192):r.includes(`claude-3-haiku`)?(t=4096,n=4096):r.includes(`3-5-sonnet`)||r.includes(`3-5-haiku`)?(t=8192,n=8192):r.includes(`3-7-sonnet`)?(t=32e3,n=64e3):(t=ni,n=ri);let i=Vr(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function $r(e){return Qr(e).upperLimit-1}var ei,ti,ni,ri,ii,ai=e((()=>{Sr(),Ge(),l(),oc(),Kr(),ei=2e5,ti=2e4,ni=32e3,ri=64e3,ii=8e3})),oi,si,ci,li=e((()=>{i(),A(),oi=[{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`}],si=[{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`}],ci=r((e,t)=>{if(k()===`firstParty`)return;let n=e.toLowerCase(),r=k()===`openai`?si:oi;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 ui(e){let t=[],n=[];for(let r of e)bi.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function di(e){if(!e||e.length===0)return;if(R()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=ui(e);for(let e of n)console.warn(`Warning: Beta header '${e}' is not allowed. Only the following betas are supported: ${bi.join(`, `)}`);return t.length>0?t:void 0}function fi(e){let t=ci(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Q(e),r=k();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function pi(e){let t=Q(e),n=k();return n===`foundry`?!0:n===`firstParty`?!t.includes(`claude-3-`):t.includes(`claude-opus-4`)||t.includes(`claude-sonnet-4`)||t.includes(`claude-haiku-4`)}function mi(e){let t=Q(e),n=k();return n!==`firstParty`&&n!==`foundry`?!1:t.includes(`claude-sonnet-4-6`)||t.includes(`claude-sonnet-4-5`)||t.includes(`claude-opus-4-1`)||t.includes(`claude-opus-4-5`)||t.includes(`claude-opus-4-6`)||t.includes(`claude-opus-4-7`)||t.includes(`claude-haiku-4-5`)}function hi(e){return!0}function gi(){return(k()===`firstParty`||k()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&Nt()}function _i(){return k()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function vi(e,t){let n=[...Si(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(cr));let r=xe();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function yi(){xi.cache?.clear?.(),Si.cache?.clear?.(),Ci.cache?.clear?.()}var bi,xi,Si,Ci,wi=e((()=>{i(),m(),Sr(),O(),G(),ai(),l(),oc(),li(),A(),x(),bi=[ur],xi=r(e=>{let t=[],n=Q(e).includes(`haiku`);k();let r=gi();n||t.push(cr),R()&&t.push(lt),F(e)&&t.push(ur),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&fi(e)&&t.push(lr),r&&fi(e)&&!h()&&Ve().showThinkingSummaries!==!0&&t.push(_r);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||pi(e),a=pi(e);return gi()&&(i||a)&&t.push(dr),r&&mi(e),r&&t.push(hr),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),Si=r(e=>{let t=xi(e);return k()===`bedrock`?t.filter(e=>!br.has(e)):t}),Ci=r(e=>xi(e).filter(e=>br.has(e)))}));function Ti(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 Ei=e((()=>{}));async function Di(){try{let e=M(Xn),{stdout:t,code:n}=await Qe(`security`,[`find-generic-password`,`-a`,Jn(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return De(t.trim())}catch{}return null}function Oi(){if(ji!==void 0)return ji;if(process.platform!==`darwin`)return ji=!1,!1;try{ji=Ze(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{ji=!1}return ji}var ki,Ai,ji,Mi=e((()=>{qe(),_(),Xe(),Ke(),Me(),Zn(),ki=4032,Ai={name:`keychain`,read(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=M(Xn),t=Je(`security find-generic-password -a "${Jn()}" -w -s "${e}"`);if(t){let e=De(t);return P.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(P.cache={data:null,cachedAt:Date.now()},null):(v(`[keychain] read failed; serving stale cache`,{level:`warn`}),P.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(P.readInFlight)return P.readInFlight;let t=P.generation,n=Di().then(n=>{if(t===P.generation){n===null&&e.data!==null&&v(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return P.cache={data:t,cachedAt:Date.now()},P.readInFlight=null,t}return n});return P.readInFlight=n,n},update(e){N();try{let t=M(Xn),n=Jn(),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<=ki?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?(P.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){N();try{let e=M(Xn);return Je(`security delete-generic-password -a "${Jn()}" -s "${e}"`),!0}catch{return!1}}}}));function Ni(){let e=c();return{storageDir:e,storagePath:yt(e,`.credentials.json`)}}var Pi,Fi=e((()=>{l(),ze(),Ie(),Me(),Pi={name:`plaintext`,read(){let{storagePath:e}=Ni();try{return De(Fe().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=Ni();try{return De(await Fe().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=Ni();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}=Ni();try{return Fe().unlinkSync(e),!0}catch(e){return Ae(e)===`ENOENT`}}}}));function Ii(){return process.platform===`darwin`?Ti(Ai,Pi):Pi}var Li=e((()=>{Ei(),Mi(),Fi()}));function Ri(e){return new Promise(t=>{At(`security`,[`find-generic-password`,`-a`,Jn(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:Ui},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function zi(){if(process.platform!==`darwin`||Gi||u())return;let e=Ri(M(Xn)),t=Ri(M());Gi=Promise.all([e,t]).then(([e,t])=>{e.timedOut||Yn(e.stdout),t.timedOut||(Wi={stdout:t.stdout})})}async function Bi(){Gi&&await Gi}function Vi(){return Wi}function Hi(){Wi=null}var Ui,Wi,Gi,Ki=e((()=>{l(),Zn(),Ui=1e4,Wi=null,Gi=null}));function qi(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 Ji=e((()=>{}));function Yi(){return Zi}function Xi(){Zi.clear()}var Zi,Qi=e((()=>{Zi=new Map})),$i=n({calculateApiKeyHelperTTL:()=>ua,checkAndRefreshOAuthTokenIfNeeded:()=>Va,checkGcpCredentialsValid:()=>wa,clearApiKeyHelperCache:()=>ga,clearAwsCredentialsCache:()=>xa,clearGcpCredentialsCache:()=>Da,clearOAuthTokenCache:()=>Ia,getAccountInformation:()=>so,getAnthropicApiKey:()=>na,getAnthropicApiKeyWithSource:()=>ia,getApiKeyFromApiKeyHelper:()=>fa,getApiKeyFromApiKeyHelperCached:()=>ha,getApiKeyFromConfigOrMacOSKeychain:()=>_o,getApiKeyHelperElapsedMs:()=>da,getAuthTokenSource:()=>ta,getClaudeAIOAuthTokens:()=>W,getClaudeAIOAuthTokensAsync:()=>Ba,getConfiguredApiKeyHelper:()=>L,getOauthAccountInfo:()=>Ga,getOtelHeadersFromHelper:()=>io,getRateLimitTier:()=>$a,getSubscriptionName:()=>eo,getSubscriptionType:()=>z,handleOAuth401Error:()=>Ra,hasAnthropicApiKeyAuth:()=>ra,hasOpusAccess:()=>qa,hasProfileScope:()=>Ua,is1PApiCustomer:()=>Wa,isAnthropicAuthEnabled:()=>I,isAwsAuthRefreshFromProjectSettings:()=>sa,isAwsCredentialExportFromProjectSettings:()=>la,isClaudeAISubscriber:()=>R,isConsumerSubscriber:()=>oo,isCustomApiKeyApproved:()=>Ma,isEnterpriseSubscriber:()=>Za,isGcpAuthRefreshFromProjectSettings:()=>Ca,isMaxSubscriber:()=>Ja,isOtelHeadersHelperFromProjectOrLocalSettings:()=>ro,isOverageProvisioningAllowed:()=>Ka,isProSubscriber:()=>Qa,isTeamPremiumSubscriber:()=>Xa,isTeamSubscriber:()=>Ya,isUsing3PServices:()=>to,prefetchApiKeyFromApiKeyHelperIfSafe:()=>_a,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>ka,prefetchGcpCredentialsIfSafe:()=>Oa,refreshAndGetAwsCredentials:()=>U,refreshAwsAuth:()=>ya,refreshGcpAuth:()=>Ea,refreshGcpCredentialsIfNeeded:()=>go,removeApiKey:()=>Na,saveApiKey:()=>ja,saveOAuthTokensIfNeeded:()=>Fa,validateForceLoginOrg:()=>co});function ea(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function I(){if(u())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let e=b()||{},t=s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||e.modelType===`openai`||e.modelType===`gemini`||!!process.env.OPENAI_BASE_URL||!!process.env.GEMINI_BASE_URL,n=e.apiKeyHelper,r=process.env.ANTHROPIC_AUTH_TOKEN||n||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:i}=ia({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!ea()||a&&!ea())}function ta(){if(u())return L()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!ea())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(Vn())return process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR?{source:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,hasToken:!0}:{source:`CCR_OAUTH_TOKEN_FILE`,hasToken:!0};if(L()&&!ea())return{source:`apiKeyHelper`,hasToken:!0};let e=W();return Tn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function na(){let{key:e}=ia();return e}function ra(){let{key:e,source:t}=ia({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function ia(e={}){if(u())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:L()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:ha(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(de()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=Hn();if(e)return{key:e,source:`ANTHROPIC_API_KEY`};if(!t&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error(`ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required`);return t?{key:t,source:`ANTHROPIC_API_KEY`}:{key:null,source:`none`}}if(t&&S().customApiKeyResponses?.approved?.includes($n(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=Hn();return n?{key:n,source:`ANTHROPIC_API_KEY`}:L()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:ha(),source:`apiKeyHelper`}:_o()||{key:null,source:`none`}}function L(){return u()?y(`flagSettings`)?.apiKeyHelper:(b()||{}).apiKeyHelper}function aa(){let e=L();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function oa(){return(b()||{}).awsAuthRefresh}function sa(){let e=oa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function ca(){return(b()||{}).awsCredentialExport}function la(){let e=ca();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function ua(){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 lo}function da(){let e=V?.startedAt;return e?Date.now()-e:0}async function fa(e){if(!L())return null;let t=ua();return B?(Date.now()-B.timestamp<t||V||(V={promise:pa(e,!1,H),startedAt:null}),B.value):(V||(V={promise:pa(e,!0,H),startedAt:Date.now()}),V.promise)}async function pa(e,t,n){try{let t=await ma(e);return n===H&&t!==null&&(B={value:t,timestamp:Date.now()}),t}catch(e){if(n!==H)return` `;let r=e instanceof Error?e.message:String(e);return console.error(re.red(`apiKeyHelper failed: ${r}`)),v(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&B&&B.value!==` `?(B={...B,timestamp:Date.now()},B.value):(B={value:` `,timestamp:Date.now()},` `)}finally{n===H&&(V=null)}}async function ma(e){let t=L();if(!t)return null;if(aa()&&!C()&&!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 ha(){return B?.value??null}function ga(){H++,B=null,V=null}function _a(e){aa()&&!C()||fa(e)}async function va(){let e=oa();if(!e)return!1;if(sa()&&!C()&&!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 rr(),v(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return ya(e)}}function ya(e){v(`Running AWS auth refresh command`);let t=or.getInstance();return t.startAuthentication(),new Promise(n=>{let r=kt(e,{timeout:fo});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 ba(){let e=ca();if(!e)return null;if(la()&&!C()&&!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 rr(),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(!nr(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(){U.cache.clear()}function Sa(){return(b()||{}).gcpAuthRefresh}function Ca(){let e=Sa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function wa(){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=qi(po).then(()=>{throw new wo(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function Ta(){let e=Sa();if(!e)return!1;if(Ca()&&!C()&&!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 wa())return v(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return Ea(e)}function Ea(e){v(`Running GCP auth refresh command`);let t=or.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(`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 Da(){go.cache.clear()}function Oa(){Sa()&&(Ca()&&!C()&&!h()||go())}function ka(){let e=oa(),t=ca();!e&&!t||(sa()||la())&&!C()&&!h()||(U(),j())}function Aa(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function ja(e){if(!Aa(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await Pa();let t=!1;if(process.platform===`darwin`)try{let n=M();await Ye(`security`,[`-i`],{input:`add-generic-password -U -a "${Jn()}" -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=$n(e);w(r=>{let i=r.customApiKeyResponses?.approved??[];return{...r,primaryApiKey:t?r.primaryApiKey:e,customApiKeyResponses:{...r.customApiKeyResponses,approved:i.includes(n)?i:[...i,n],rejected:r.customApiKeyResponses?.rejected??[]}}}),_o.cache.clear?.(),Hi()}function Ma(e){let t=S(),n=$n(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function Na(){await Pa(),w(e=>({...e,primaryApiKey:void 0})),_o.cache.clear?.(),Hi()}async function Pa(){try{await Qn()}catch(e){T(e)}}function Fa(e){if(!Tn(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=Ii(),n=t.name;try{let r=t.read()||{},i=r.claudeAiOauth;r.claudeAiOauth={accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes,subscriptionType:e.subscriptionType??i?.subscriptionType??null,rateLimitTier:e.rateLimitTier??i?.rateLimitTier??null};let a=t.update(r);return a.success?E(`tengu_oauth_tokens_saved`,{storageBackend:n}):E(`tengu_oauth_tokens_save_failed`,{storageBackend:n}),W.cache?.clear?.(),yi(),Xi(),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 Ia(){W.cache?.clear?.(),N()}async function La(){try{let{mtimeMs:e}=await Dt(yt(c(),`.credentials.json`));e!==vo&&(vo=e,Ia())}catch{W.cache?.clear?.()}}function Ra(e){let t=yo.get(e);if(t)return t;let n=za(e).finally(()=>{yo.delete(e)});return yo.set(e,n),n}async function za(e){Ia();let t=await Ba();return t?.refreshToken?t.accessToken===e?Va(0,!0):(E(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function Ba(){if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||Vn())return W();try{let e=(await Ii().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}function Va(e=0,t=!1){return e===0&&!t?bo||(bo=Ha(e,t).finally(()=>{bo=null}),bo):Ha(e,t)}async function Ha(e,t){await La();let n=W();if(!t&&(!n?.refreshToken||!Mn(n.expiresAt))||!n?.refreshToken||!Tn(n.scopes))return!1;W.cache?.clear?.(),N();let r=await Ba();if(!r?.refreshToken||!Mn(r.expiresAt))return!1;let i=c();await Et(i,{recursive:!0});let a;try{E(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await Ue(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 qi(1e3+Math.random()*1e3),Ha(e+1,t)):(E(`tengu_oauth_token_refresh_lock_retry_limit_reached`,{maxRetries:5}),!1):(T(n),E(`tengu_oauth_token_refresh_lock_error`,{error:g(n)}),!1)}try{W.cache?.clear?.(),N();let e=await Ba();return!e?.refreshToken||!Mn(e.expiresAt)?(E(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(E(`tengu_oauth_token_refresh_starting`,{}),Fa(await kn(e.refreshToken,{scopes:Tn(e.scopes)?void 0:e.scopes})),W.cache?.clear?.(),N(),!0)}catch(e){T(e),W.cache?.clear?.(),N();let t=await Ba();return t&&!Mn(t.expiresAt)?(E(`tengu_oauth_token_refresh_race_recovered`,{}),!0):!1}finally{E(`tengu_oauth_token_refresh_lock_releasing`,{}),await a(),E(`tengu_oauth_token_refresh_lock_released`,{})}}function R(){return I()?Tn(W()?.scopes):!1}function Ua(){return W()?.scopes?.includes(`user:profile`)??!1}function Wa(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||R())}function Ga(){return I()?S().oauthAccount:void 0}function Ka(){let e=Ga()?.billingType;return!(!R()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function qa(){let e=z();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function z(){if(!I())return null;let e=W();return e?e.subscriptionType??null:null}function Ja(){return z()===`max`}function Ya(){return z()===`team`}function Xa(){return z()===`team`&&$a()===`default_claude_max_5x`}function Za(){return z()===`enterprise`}function Qa(){return z()===`pro`}function $a(){if(!I())return null;let e=W();return e?e.rateLimitTier??null:null}function eo(){switch(z()){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`;default:return`Claude API`}}function to(){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 no(){return(b()||{}).otelHeadersHelper}function ro(){let e=no();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function io(){let e=no();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||Co.toString(),10);if(xo&&Date.now()-So<t)return xo;if(ro()&&!C())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 xo=n,So=Date.now(),xo}catch(e){throw T(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${g(e)}`)),e}}function ao(e){return e===`max`||e===`pro`}function oo(){let e=z();return R()&&e!==null&&ao(e)}function so(){if(k()!==`firstParty`)return;let{source:e}=ta(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:R()?t.subscription=eo():t.tokenSource=e;let{key:n,source:r}=ia();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=Ga()?.organizationName;e&&(t.organization=e)}let i=Ga()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function co(){if(process.env.ANTHROPIC_UNIX_SOCKET||!I())return{valid:!0};let e=y(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await Va();let t=W();if(!t)return{valid:!0};let{source:n}=ta(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await Cn(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 lo,B,V,H,uo,fo,U,po,mo,ho,go,_o,W,vo,yo,bo,xo,So,Co,wo,G=e((()=>{ne(),qe(),i(),O(),ot(),xn(),A(),m(),Ln(),wn(),qn(),er(),ar(),sr(),wi(),Ge(),_(),l(),ze(),Xe(),We(),tt(),rt(),Li(),Ki(),Zn(),x(),Ji(),Me(),Qi(),lo=300*1e3,B=null,V=null,H=0,uo=3600*1e3,fo=180*1e3,U=nt(async()=>{let e=await va(),t=await ba();return(e||t)&&await ir(),t},uo),po=5e3,mo=3600*1e3,ho=180*1e3,go=nt(async()=>await Ta(),mo),_o=r(()=>{if(u())return null;if(process.platform===`darwin`){let e=Vi();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=M();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=S();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),W=r(()=>{if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};let e=Vn();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=Ii().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}),vo=0,yo=new Map,bo=null,xo=null,So=0,Co=1740*1e3,wo=class extends Error{}}));function K(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function To(){return K()?Do()===null:!1}function Eo(e,t){switch(e){case`free`:return t===`oauth`?`Fast mode requires a paid subscription`:`Fast mode unavailable during evaluation. Please purchase credits.`;case`preference`:return`Fast mode has been disabled by your organization`;case`extra_usage_disabled`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function Do(){if(!K())return`Fast mode is not available`;if(dt(),h()&&de()&&!pe()&&!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=W()===null?`api-key`:`oauth`,t=Eo(J.reason,e);return v(`Fast mode unavailable: ${t}`),t}return null}function Oo(){return`opus`+(Ys()?`[1m]`:``)}function ko(e){if(!K()||!To()||!Ao(e))return!1;let t=Ve();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function Ao(e){if(!K())return!1;let t=$(e??Ws());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function jo(){return q.status===`cooldown`&&Date.now()>=q.resetAt&&(K()&&!Wo&&(v(`Fast mode cooldown expired, re-enabling fast mode`),Wo=!0,Ko.emit()),q={status:`active`}),q}function Mo(e,t){if(!K())return;q={status:`cooldown`,resetAt:e,reason:t},Wo=!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}),Go.emit(e,t)}function No(){q={status:`active`}}function Po(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},He(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1})),Zo.emit(!1))}function Fo(e){switch(e){case`out_of_credits`:return`Fast mode disabled · extra usage credits exhausted`;case`org_level_disabled`:case`org_service_level_disabled`:return`Fast mode disabled · extra usage disabled by your organization`;case`org_level_disabled_until`:return`Fast mode disabled · extra usage spending cap reached`;case`member_level_disabled`:return`Fast mode disabled · extra usage disabled for your account`;case`seat_tier_level_disabled`:case`seat_tier_zero_credit_limit`:case`member_zero_credit_limit`:return`Fast mode disabled · extra usage not available for your plan`;case`overage_not_provisioned`:case`no_limits_configured`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;default:return`Fast mode disabled · extra usage not available`}}function Io(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function Lo(e){let t=Fo(e);v(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),E(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),Io(e)||(He(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1}))),Yo.emit(t)}function Ro(){return jo().status===`cooldown`}function zo(e,t){let n=K()&&To()&&!!t&&Ao(e);return n&&Ro()?`cooldown`:n?`on`:`off`}async function Bo(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 Vo(){K()&&J.status===`pending`&&(J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`unknown`})}async function Ho(){if(et()||!K())return;if(ts)return v(`Fast mode prefetch in progress, returning in-flight promise`),ts;let e=na();if(!(W()?.accessToken&&Ua())&&!e){J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-es<$o){v(`Skipping fast mode prefetch, fetched recently`);return}es=t;let n=async()=>{let t=W(),n=t?.accessToken&&Ua()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return Bo(n)};async function r(){try{let e;try{e=await n()}catch(t){if(f.isAxiosError(t)&&(t.response?.status===401||t.response?.status===403&&typeof t.response?.data==`string`&&t.response.data.includes(`OAuth token has been revoked`))){let r=W()?.accessToken;if(r)await Ra(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?S().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||He(`userSettings`,{fastMode:void 0}),w(t=>({...t,penguinModeOrgEnabled:e.enabled})),Zo.emit(e.enabled)),v(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){J=S().penguinModeOrgEnabled===!0?{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{ts=null}}return ts=r(),ts}var Uo,q,Wo,Go,Ko,qo,Jo,Yo,Xo,J,Zo,Qo,$o,es,ts,ns=e((()=>{p(),O(),m(),ot(),G(),ft(),Ge(),_(),l(),oc(),A(),$e(),x(),we(),Uo=`Opus 4.7`,q={status:`active`},Wo=!1,Go=be(),Ko=be(),qo=Go.subscribe,Jo=Ko.subscribe,Yo=be(),Xo=Yo.subscribe,J={status:`pending`},Zo=be(),Qo=Zo.subscribe,$o=3e4,es=0,ts=null}));function rs(e){return K()&&e?ps:fs}function is(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 as(e,t){let n=Q(e);return n===Z(sn.firstParty)?rs(t.speed===`fast`):_s[n]||(os(e,n),_s[Q(Ws())]??gs)}function os(e,t){E(`tengu_unknown_model_cost`,{model:e,shortName:t}),ve()}function ss(e,t){return is(as(e,t),t)}function cs(e,t){return ss(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function ls(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function us(e){return`${ls(e.inputTokens)}/${ls(e.outputTokens)} per Mtok`}var Y,ds,fs,ps,ms,hs,gs,_s,vs=e((()=>{ot(),m(),ns(),fn(),oc(),Y={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},ds={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},fs={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},ps={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},ms={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},hs={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},gs=fs,_s={[Z($t.firstParty)]:ms,[Z(en.firstParty)]:hs,[Z(Qt.firstParty)]:Y,[Z(Zt.firstParty)]:Y,[Z(tn.firstParty)]:Y,[Z(nn.firstParty)]:Y,[Z(ln.firstParty)]:Y,[Z(rn.firstParty)]:ds,[Z(an.firstParty)]:ds,[Z(on.firstParty)]:fs,[Z(sn.firstParty)]:fs}}));function X(e){return bs.includes(e)}function ys(e){return xs.includes(e)}var bs,xs,Ss=e((()=>{bs=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],xs=[`sonnet`,`opus`,`haiku`]}));function Cs(e,t){return e.includes(t)?!0:X(e)?$(e).toLowerCase().includes(t):!1}function ws(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function Ts(e,t){let n=X(e)?$(e).toLowerCase():e;return!!(ws(n,t)||!t.startsWith(`claude-`)&&ws(n,`claude-${t}`))}function Es(e,t){for(let n of t){if(ys(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 Ds(e){let{availableModels:t}=b()||{};if(!t)return!0;if(t.length===0)return!1;let n=gn(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!ys(n)||!Es(n,r)))return!0;for(let e of r)if(ys(e)&&!Es(e,r)&&Cs(n,e))return!0;if(X(n)){let e=$(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!ys(e)&&X(e)&&$(e).toLowerCase()===n)return!0;for(let e of r)if(!ys(e)&&!X(e)&&Ts(n,e))return!0;return!1}var Os=e((()=>{x(),Ss(),oc(),xn()}));function ks(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var As,js,Ms,Ns=e((()=>{As=`gpt-5.5`,js=`gpt-5.4-mini`,Ms=[{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 Ps(){let e=k();return e===`openai`&&ks()?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||Hs()}function Fs(e){return e===j().opus40||e===j().opus41||e===j().opus45||e===j().opus46||e===j().opus47}function Is(){let e,t=_e();if(t!==void 0)e=t;else{let t=b()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!Ds(e)))return e}function Ls(){let e=Is();return e==null?Gs():$(e)}function Rs(){return Bs()}function zs(){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 Bs(){let e=k();return e===`openai`&&ks()?As: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:zs()||j().opus47}function Vs(){let e=k();return e===`openai`&&ks()?As: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:zs()||(e===`firstParty`?j().sonnet46:j().sonnet45)}function Hs(){let e=k();return e===`openai`&&ks()?js: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:zs()||j().haiku45}function Us(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return Is()===`opusplan`&&t===`plan`&&!r?Bs():Is()===`haiku`&&t===`plan`?Vs():n}function Ws(){return Ja()||Xa()?Bs()+(Ys()?`[1m]`:``):Vs()}function Gs(){return $(Ws())}function Z(e){if(e=e.toLowerCase(),e.includes(`claude-opus-4-7`))return`claude-opus-4-7`;if(e.includes(`claude-opus-4-6`))return`claude-opus-4-6`;if(e.includes(`claude-opus-4-5`))return`claude-opus-4-5`;if(e.includes(`claude-opus-4-1`))return`claude-opus-4-1`;if(e.includes(`claude-opus-4`))return`claude-opus-4`;if(e.includes(`claude-sonnet-4-6`))return`claude-sonnet-4-6`;if(e.includes(`claude-sonnet-4-5`))return`claude-sonnet-4-5`;if(e.includes(`claude-sonnet-4`))return`claude-sonnet-4`;if(e.includes(`claude-haiku-4-5`))return`claude-haiku-4-5`;if(e.includes(`claude-3-7-sonnet`))return`claude-3-7-sonnet`;if(e.includes(`claude-3-5-sonnet`))return`claude-3-5-sonnet`;if(e.includes(`claude-3-5-haiku`))return`claude-3-5-haiku`;if(e.includes(`claude-3-opus`))return`claude-3-opus`;if(e.includes(`claude-3-sonnet`))return`claude-3-sonnet`;if(e.includes(`claude-3-haiku`))return`claude-3-haiku`;let t=e.match(/(claude-(\d+-\d+-)?\w+)/);return t&&t[1]?t[1]:e}function Q(e){return Z(gn(e))}function Ks(e=!1){return Ja()||Xa()?Ys()?`Opus 4.7 with 1M context · Most capable for complex work${e?Js(!0):``}`:`Opus 4.7 · Most capable for complex work${e?Js(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function qs(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:Qs($(e))}function Js(e){if(k()!==`firstParty`)return``;let t=us(rs(e));return` ·${e?` (↯)`:``} ${t}`}function Ys(){return!(qr()||Qa()||k()!==`firstParty`||!Nt()||R()&&z()===null)}function Xs(e){return e===`opusplan`?`Opus Plan`:X(e)?pt(e):Qs(e)}function Zs(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 Qs(e){return Zs(e)||e}function $(e){let t=e.trim(),n=t.toLowerCase(),r=F(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(X(i))switch(i){case`opusplan`:return Vs()+(r?`[1m]`:``);case`sonnet`:return Vs()+(r?`[1m]`:``);case`haiku`:return Hs()+(r?`[1m]`:``);case`opus`:return Bs()+(r?`[1m]`:``);case`best`:return Rs();default:}return k()===`firstParty`&&ec(i)&&tc()?Bs()+(r?`[1m]`:``):r?t.replace(/\[1m\]$/i,``).trim()+`[1m]`:t}function $s(e,t){return F(e)||!F(t)?e:Jr($(e))?e+`[1m]`:e}function ec(e){return ac.includes(e)}function tc(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function nc(e){if(e===null)return R()?`Default (${Ks()})`:`Default (${Gs()})`;let t=$(e);return e===t?t:`${e} (${t})`}function rc(e){if(k()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Q(e);if(n.includes(`claude-opus-4-7`))return t?`Opus 4.7 (with 1M context)`:`Opus 4.7`;if(n.includes(`claude-opus-4-6`))return t?`Opus 4.6 (with 1M context)`:`Opus 4.6`;if(n.includes(`claude-opus-4-5`))return`Opus 4.5`;if(n.includes(`claude-opus-4-1`))return`Opus 4.1`;if(n.includes(`claude-opus-4`))return`Opus 4`;if(n.includes(`claude-sonnet-4-6`))return t?`Sonnet 4.6 (with 1M context)`:`Sonnet 4.6`;if(n.includes(`claude-sonnet-4-5`))return t?`Sonnet 4.5 (with 1M context)`:`Sonnet 4.5`;if(n.includes(`claude-sonnet-4`))return t?`Sonnet 4 (with 1M context)`:`Sonnet 4`;if(n.includes(`claude-3-7-sonnet`))return`Claude 3.7 Sonnet`;if(n.includes(`claude-3-5-sonnet`))return`Claude 3.5 Sonnet`;if(n.includes(`claude-haiku-4-5`))return`Haiku 4.5`;if(n.includes(`claude-3-5-haiku`))return`Claude 3.5 Haiku`}function ic(e){return e.replace(/\[(1|2)m\]/gi,``)}var ac,oc=e((()=>{m(),G(),ai(),l(),xn(),vs(),x(),A(),Be(),Os(),Ss(),mt(),Ns(),ac=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{Po as $,Dr as $n,Ut as $r,Qa as $t,Ns as A,Si as An,jn as Ar,L as At,cs as B,Zr as Bn,Tn as Br,G as Bt,$ as C,Li as Cn,N as Cr,fa as Ct,$s as D,di as Dn,Rn as Dr,ta as Dt,Xs as E,yi as En,qn as Er,da as Et,Ss as F,_i as Fn,Ln as Fr,z as Ft,Uo as G,F as Gn,vn as Gr,R as Gt,us as H,$r as Hn,Sn as Hr,I as Ht,ms as I,ci as In,Mn as Ir,Ra as It,jo as J,Kr as Jn,Kt as Jr,Za as Jt,No as K,ai as Kn,j as Kr,oo as Kt,hs as L,li as Ln,En as Lr,ra as Lt,Os as M,hi as Mn,An as Mr,io as Mt,Ds as N,mi as Nn,Nn as Nr,$a as Nt,As as O,Ci as On,zn as Or,W as Ot,bs as P,gi as Pn,Pn as Pr,eo as Pt,Lo as Q,Ir as Qn,Xt as Qr,Ka as Qt,Y as R,ii as Rn,Fn as Rr,qa as Rt,ic as S,Ii as Sn,$n as Sr,ia as St,Qs as T,Oi as Tn,Kn as Tr,_o as Tt,rs as U,Qr as Un,Cn as Ur,sa as Ut,ss as V,Yr as Vn,In as Vr,Wa as Vt,vs as W,Xr as Wn,wn as Wr,la as Wt,Do as X,Fr as Xn,Gt as Xr,Ja as Xt,zo as Y,Hr as Yn,Ht as Yr,Ca as Yt,ko as Z,jr as Zn,Jt as Zr,ro as Zt,oc as _,Ji as _n,or as _r,xa as _t,Hs as a,k as ai,Oa as an,Cr as ar,Jo as at,Ys as b,Ki as bn,tr as br,so as bt,Bs as c,Nt as ci,Ea as cn,ur as cr,Qo as ct,rc as d,ja as dn,hr as dr,Mo as dt,zt as ei,Xa as en,Er as er,ns as et,Js as f,Fa as fn,_r as fr,$i as ft,Is as g,Qi as gn,Sr as gr,ga as gt,Ps as h,Yi as hn,xr as hr,wa as ht,Ks as i,Ft as ii,ka as in,wr as ir,Ao as it,ks as j,wi as jn,On as jr,Ga as jt,Ms as k,vi as kn,Dn as kr,Ba as kt,Vs as l,go as ln,dr as lr,Ho as lt,Us as m,Xi as mn,mr,Va as mt,Rs as n,Pt as ni,to as nn,kr as nr,Ro as nt,Gs as o,Mt as oi,U as on,yr as or,qo as ot,Zs as p,co as pn,fr as pr,ua as pt,Oo as q,qr as qn,xn as qr,Ma as qt,Q as r,Lt as ri,_a as rn,Or as rr,K as rt,Ws as s,A as si,ya as sn,vr as sr,Xo as st,Z as t,Rt as ti,Ya as tn,Tr as tr,To as tt,Ls as u,Na as un,gr as ur,Vo as ut,tc as v,qi as vn,sr as vr,Da as vt,qs as w,Mi as wn,Zn as wr,ha as wt,nc as x,zi as xn,er as xr,na as xt,Fs as y,Bi as yn,ar as yr,Ia as yt,_s as z,ti as zn,kn as zr,Ua as zt};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{dm as n,ia as r,lm as i,lv as a,ov as o,ra as s,sv as c,um as l}from"./loadAgentsDir-CKSb56Gp.js";import{di as u,fi as d,ui as f}from"./src-P_wYS_NJ2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{D as m,E as h,J as g}from"./log-CTFl4qpD.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{F as y,K as b,M as x,N as S,P as C,_ as w,b as T,et as E,it as D,rt as O,s as k,tt as A,w as j}from"./model-C2e73CJD.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-Dt5mw35U.js";function I({onDone:e}){let t=c(e=>e.mainLoopModel),n=c(e=>e.mainLoopModelForSession),r=c(e=>e.fastMode),i=a();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${f.bold(n)}`,{display:`system`})}function s(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),i(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let a=`Set model to ${f.bold(H(n))}`,o;O()&&(b(),!D(n)&&r?(i(e=>({...e,fastMode:!1})),o=!1):D(n)&&A()&&r&&(a+=` · Fast mode ON`,o=!0)),N(n,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),e(a)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:s,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:O()&&r&&D(t)&&A()})}function L({args:e,onDone:t}){let n=c(e=>e.fastMode),i=a(),o=e==="default"?null:e;return U.useEffect(()=>{async function e(){if(o&&!S(o)){t(`Model '${o}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(o&&z(o)){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(o&&B(o)){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(!o){a(null);return}if(R(o)){a(o);return}try{let{valid:e,error:n}=await r(o);e?a(o):t(n||`Model '${o}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function a(e){i(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let r=`Set model to ${f.bold(H(e))}`,a;O()&&(b(),!D(e)&&n?(i(e=>({...e,fastMode:!1})),a=!1):D(e)&&n&&(r+=` · Fast mode ON`,a=!0)),N(e,a===!0,T())&&(r+=` · Billed as extra usage`),a===!1&&(r+=` · Fast mode OFF`),t(r)}e()},[o,t,i]),null}function R(e){return C.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!i()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!l()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=c(e=>e.mainLoopModel),n=c(e=>e.mainLoopModelForSession),r=H(t);return e(n?`Current model: ${f.bold(H(n))} (session override from plan mode)\nBase model: ${r}`:`Current model: ${r}`),null}function H(e){let t=j(e??k());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{u(),U=t(d(),1),M(),g(),_(),o(),F(),E(),y(),n(),w(),x(),s(),W=p(),G=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{onDone:e});if(h.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(v(`tengu_model_command_inline`,{args:n}),(0,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
@@ -1 +0,0 @@
1
- import{_ as e,u as t}from"./model-C2e73CJD.js";e();export{t as getMainLoopModel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-BDhHQY0-.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{F as a,I as o,S as s,V as c,W as l,a as u,d,l as f,nt as p,p as ee,rt as te,z as ne}from"./debug-BdqxZ7rV.js";import{Gt as re,Jt as ie}from"./settings-Xbq6AaD-.js";import{C as m,S as ae,c as oe,h as se,x as ce,y as le}from"./config-D4G8_MqJ.js";import{n as h,r as g}from"./execFileNoThrow-5SylUnAI.js";import{o as ue,s as _}from"./log-CTFl4qpD.js";import{n as de,r as v}from"./analytics-DJobLaWP.js";import{_n as y,vn as b}from"./model-C2e73CJD.js";import{B as fe,R as pe,z as me}from"./sessionState-BvECKycx.js";import{ft as he,ut as ge}from"./esm-DcIr7tVd.js";import{C as _e,S as ve,_ as ye,a as x,b as be,c as xe,d as Se,g as Ce,h as we,i as Te,l as Ee,n as De,o as S,p as Oe,s as ke,t as Ae,v as je,x as Me,y as Ne}from"./pidLock-BR5M6RQw.js";import{a as Pe,i as Fe,n as Ie,r as Le,t as Re}from"./xdg-DcF9ejUM.js";import{homedir as ze}from"os";import{basename as Be,delimiter as Ve,dirname as C,join as w,resolve as T}from"path";import{constants as He}from"fs";import{createHash as Ue}from"crypto";import{access as E,chmod as D,copyFile as O,mkdir as k,readdir as A,readlink as j,rename as M,rm as N,rmdir as We,stat as P,symlink as Ge,unlink as F,writeFile as I}from"fs/promises";async function Ke(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return v(`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),v(`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 _(c),c}}async function qe(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 Ke(t,L)}function Je(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||R}async function Ye(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,u=()=>{c&&(clearTimeout(c),c=void 0)},d=()=>{u(),c=setTimeout(e=>e.abort(),Je(),s)};try{d();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{d()},...i});u();let o=Ue(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await I(n,Buffer.from(a.data)),await D(n,493);return}catch(e){u();let t=r.isCancel(e);if(a=t?new z:l(e),t&&o<3){f(`Download stalled on attempt ${o}/3, retrying...`),await b(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Xe(e,t,n,i){let a=d();await a.rm(t,{recursive:!0,force:!0});let o=B(),s=Date.now();v(`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),v(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),_(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw v(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,f=V(o),p=`${n}/${e}/${o}/${f}`;await a.mkdir(t);let ee=w(t,f);try{await Ye(p,u,ee,i||{}),v(`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),v(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),_(Error(`Failed to download binary from ${p}: ${n}`)),e}}async function Ze(e,t){return await Xe(e,t,L),`binary`}var L,R,z,Qe=e((()=>{i(),de(),u(),ne(),g(),ee(),ue(),y(),s(),$(),L=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,R=6e4,z=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function B(){let e=re.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw f(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&ge.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function V(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function H(){let e=V(B());return{versions:w(Le(),`claude`,`versions`),staging:w(Ie(),`claude`,`staging`),locks:w(Fe(),`claude`,`locks`),executable:w(Re(),e)}}async function U(e){try{let t=await P(e);return!t.isFile()||t.size===0?!1:(await E(e,He.X_OK),!0)}catch{return!1}}async function W(e){let t=H(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>k(e,{recursive:!0}))),await k(C(t.executable),{recursive:!0});let r=w(t.versions,e);try{await P(r)}catch{await I(r,``,{encoding:`utf8`})}return{stagingPath:w(t.staging,e),installPath:r}}async function G(e,t,n=0){let r=H(),i=Y(r,e);if(await k(r.locks,{recursive:!0}),S()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await xe(e,i,async()=>{try{await t()}catch(e){throw _(e),e}}))return v(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await b(Math.min(o*2**(r-1),s))}return v(`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 m(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{f(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return v(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),v(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw _(e),e}}finally{a&&await a()}}async function K(e,t){await k(C(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await O(e,n),await D(n,493),await M(n,t),f(`Atomically installed binary to ${t}`)}catch(e){try{await F(n)}catch{}throw e}}async function $e(e,t){try{let n=w(e,`node_modules`,`@anthropic-ai`),r=(await A(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw v(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=w(n,r,`cli`);try{await P(i)}catch{throw v(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await K(i,t),await N(e,{recursive:!0,force:!0}),v(`tengu_native_install_package_success`,{})}catch(e){let t=a(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&v(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),_(l(e)),e}}async function et(e,t){try{let n=w(e,V(B()));try{await P(n)}catch{throw v(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await K(n,t),await N(e,{recursive:!0,force:!0}),v(`tengu_native_install_binary_success`,{})}catch(e){throw a(e).includes(`Staged binary not found`)||v(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),_(l(e)),e}}async function tt(e,t,n){n===`npm`?await $e(e,t):await et(e,t)}async function q(e,n){let{stagingPath:r,installPath:i}=await W(e),{executable:a}=H(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await J(e)||n;if(s?(f(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await tt(o,i,await Ze(e,o))):f(`Version ${e} already installed, updating symlink`),await rt(a),await it(a,i),!await U(a)){let e=!1;try{await P(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 J(e){let{installPath:t}=await W(e);return U(t)}async function nt(e,n=!1){let r=Date.now(),i=await qe(e),{executable:a}=H();if(f(`Checking for native installer update to version ${i}`),!n){let e=await Oe();if(e&&pe(i,e)){if(f(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),me(`0.0.9`,e))return f(`Native installer: current version 0.0.9 is already at or above maxVersion ${e}, skipping update`),v(`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.9`&&await J(i)&&await U(a))return f(`Found ${i} at ${a}, skipping install`),v(`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&&Ce(i))return v(`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 q(i,n),s=Date.now()-r;else{let{installPath:e}=await W(i);n&&await ut(e);let t=await G(e,async()=>{o=await q(i,n)},3);if(s=Date.now()-r,!t){let t=H(),n;if(S()){let r=Y(t,e);x(r)&&(n=ke(r)?.pid)}return v(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return v(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),f(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function rt(e){try{await We(e),f(`Removed empty directory at ${e}`)}catch(t){let n=o(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&f(`Could not remove directory at ${e}: ${t}`)}}async function it(e,t){if(B().startsWith(`win32`))try{await k(C(e),{recursive:!0});let n;try{n=await P(e)}catch{}if(n){try{let e=await P(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await M(e,r);try{await O(t,e);try{await F(r)}catch{}}catch(t){try{await M(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw _(n),n}throw t}}else try{await O(t,e)}catch(e){throw c(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return _(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=C(e);try{await k(n,{recursive:!0}),f(`Created directory ${n} for symlink`)}catch(e){return _(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await P(e),n=!0}catch{}if(n){try{let n=await j(e);if(T(C(e),n)===T(t))return!1}catch{}await F(e)}}catch(e){_(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Ge(t,r),await M(r,e),f(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await F(r)}catch{}return _(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function at(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Ee();if(n===`development`||!(e||n===`native`))return[];let r=H(),i=[],a=C(r.executable),o=T(a),s=B().startsWith(`win32`);try{await E(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await U(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 j(r.executable);await U(T(C(r.executable),e))||i.push({message:`Claude symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){c(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await U(r.executable)||i.push({message:`${r.executable} exists but is not a valid Claude binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Ve).some(e=>{try{let t=T(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=ve(),t=je()[e],n=t?t.replace(ze(),`~`):`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 ot(e,t=!1){if(t)return st(e,t);if(Q)return f(`installLatest: joining in-flight call`),Q;let n=st(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function st(e,t=!1){let n=await nt(e,t);return n.success?(oe().installMethod!==`native`&&(le(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),f(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),dt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function ct(e){try{let t=await j(e),n=T(C(e),t);if(await U(n))return n}catch{}return null}function Y(e,t){let n=Be(t);return w(e.locks,`${n}.lock`)}async function lt(){let e=H();if(!process.execPath.includes(e.versions))return;let t=T(process.execPath);try{let n=Y(e,t);if(await k(e.locks,{recursive:!0}),S()){if(!await Ae(t,n)){v(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}v(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),f(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await m(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{f(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),v(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),f(`Acquired mtime-based lock on running version: ${t}`),te(async()=>{try{await e?.()}catch{}})}catch(e){if(c(e)){f(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}v(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(c(e)){f(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}f(`NON-FATAL: Failed to lock current version during execution ${a(e)}`,{level:`info`})}}function X(e,t){_(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ut(e){let t=Y(H(),e);try{await F(t),f(`Force-removed lock file at ${t}`)}catch(e){f(`Failed to force-remove lock file: ${a(e)}`)}}async function dt(){await Promise.resolve();let e=H(),t=Date.now()-36e5;if(B().startsWith(`win32`)){let t=C(e.executable);try{let e=await A(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await F(w(t,r)),n++}catch{}n>0&&f(`Cleaned up ${n} old Windows executables on startup`)}catch(e){c(e)||f(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await A(e.staging),r=0;for(let i of n){let n=w(e.staging,i);try{(await P(n)).mtime.getTime()<t&&(await N(n,{recursive:!0,force:!0}),r++,f(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(f(`Cleaned up ${r} orphaned staging directories`),v(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){c(e)||f(`Failed to clean up staging directories: ${e}`)}if(S()){let t=De(e.locks);t>0&&(f(`Cleaned up ${t} stale version locks`),v(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await A(e.versions)}catch(e){c(e)||f(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=w(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await P(n)).mtime.getTime()<t&&(await F(n),i++,f(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await P(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:T(n),mtime:e.mtime})}catch{}}if(i>0&&(f(`Cleaned up ${i} orphaned temp install files`),v(`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(T(t));let i=await ct(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(S())i=x(r);else try{i=await ce(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),f(`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){v(`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 G(e.path,async()=>{await F(e.path)})?o++:(s++,f(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,_(Error(`Failed to delete version ${e.name}: ${t}`))}})),v(`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){c(e)||_(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=je();for(let[n,r]of Object.entries(t))try{let t=await be(r);if(!t)continue;let{filtered:i,hadAlias:a}=ye(t);a&&(await Me(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),f(`Cleaned up claude alias from ${n} config`))}catch(t){_(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await h(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await F(e),f(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(B().startsWith(`win32`)){let e=w(n,`claude.cmd`),t=w(n,`claude.ps1`),a=w(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(w(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(f(`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: ${B().startsWith(`win32`)?w(n,`node_modules`,e):w(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return f(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await h(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return f(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){f(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),f(`Attempting manual removal due to ENOTEMPTY error`);let t=await pt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return f(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function ht(){let e=[],t=[],n=0,r=await mt(`@anthropic-ai/claude-code`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=w(ze(),`.claude`,`local`);try{await N(i,{recursive:!0}),n++,f(`Removed local installation at ${i}`)}catch(t){c(t)||(e.push(`Failed to remove ${i}: ${t}`),f(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{de(),we(),p(),se(),u(),Se(),ie(),he(),n(),ne(),g(),_e(),ae(),ue(),fe(),Ne(),y(),Pe(),Qe(),Te(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,lt as c,dt as i,at as n,$ as o,ht as r,ot as s,gt as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{ME as r,aD as i,iD as a,jE as o,vD as s,yD as c}from"./loadAgentsDir-CKSb56Gp.js";import{Ar as l,Ci as u,Ei as d,Lr as f,Mr as p,Nr as m,Pr as h,Rr as g,Ti as _,jr as v,kr as y,mi as b,pi as x,wi as S}from"./state-Bs5xweDL.js";import{$n as C,Qn as w,Tr as T,Xn as E,Zn as D,er as O,tr as k,wr as A}from"./settings-Xbq6AaD-.js";import{I as j,L as M}from"./config-D4G8_MqJ.js";function N(e){return S(e)||b(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),x(),u(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):_(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{d(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return D(C(e,void 0,R),e+``)}var V=e((()=>{z(),w(),E()}));function H(e,t){return t.length<2?e:y(e,o(t,0,-1))}var U=e((()=>{l(),r()}));function W(e,t){t=m(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var a=p(t[n]);if(a===`__proto__`&&!G.call(e,`__proto__`)||(a===`constructor`||a===`prototype`)&&n<r-1)return!1}var o=H(e,t);return o==null||delete o[p(i(t))]}var G,K=e((()=>{h(),a(),U(),v(),G=Object.prototype.hasOwnProperty}));function q(e){return k(e)?void 0:e}var J=e((()=>{O()})),Y,X,Z,Q,$=e((()=>{g(),c(),K(),h(),T(),J(),V(),M(),Y=1,X=2,Z=4,Q=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=f(t,function(t){return t=m(t,e),r||(r=t.length>1),t}),A(e,j(e),n),r&&(n=s(n,Y|X|Z,q));for(var i=t.length;i--;)W(n,t[i]);return n})}));export{Q as n,$ as t};
@@ -1 +0,0 @@
1
- import{Kt as e,Pn as t}from"./state-Bs5xweDL.js";import{W as n,z as r}from"./debug-BdqxZ7rV.js";import{Pt as i,Rt as a,jt as o}from"./settings-Xbq6AaD-.js";import{c as s,h as c,y as l}from"./config-D4G8_MqJ.js";import{o as u,s as d}from"./log-CTFl4qpD.js";import{Bt as f,_t as p,gt as m,vt as h}from"./model-C2e73CJD.js";import{a as g,i as _,n as v}from"./sessionState-BvECKycx.js";import{r as y,t as b}from"./managedEnv-Cl7YbYzf.js";e(),f(),c(),r(),u(),y(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:i(e.permission_mode)}}:{}})}function S({newState:e,oldState:r}){let i=r.toolPermissionContext.mode,o=e.toolPermissionContext.mode;if(i!==o){let e=a(i),t=a(o);e!==t&&g({permission_mode:t}),_(o)}if(e.mainLoopModel!==r.mainLoopModel&&t(e.mainLoopModel),e.expandedView!==r.expandedView){let t=e.expandedView===`tasks`;s().showExpandedTodos!==t&&l(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==r.verbose&&s().verbose!==e.verbose){let t=e.verbose;l(e=>({...e,verbose:t}))}if(e.settings!==r.settings)try{m(),p(),h(),e.settings.env!==r.settings.env&&b()}catch(e){d(n(e))}}export{S as n,x as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{gl as n,hl as r}from"./loadAgentsDir-CKSb56Gp.js";import{I as i,P as a,fi as o,hn as s,mt as c,t as l,y as u}from"./src-P_wYS_NJ2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";function f(e){return e.status===`running`?{mark:`●`,color:`warning`}:e.resultKind===`dead`?{mark:`✗`,color:`error`}:{mark:`✓`,color:`success`}}function p(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function m(e){let t=[];return e.model&&t.push(e.model),t.push(`${p(e.tokenCount)} tok`),t.push(`${e.toolCount??0} tool`),t.join(` · `)}var h,g,_,v,y,b=e((()=>{h={running:`●`,completed:`✓`,failed:`✗`,killed:`■`},g={running:`warning`,completed:`success`,failed:`error`,killed:`subtle`},_={running:`running`,completed:`done`,failed:`failed`,killed:`killed`},v={running:`●`,done:`✓`,pending:`○`},y={running:`warning`,done:`success`,pending:`subtle`}}));function x(e,t){if(e.length<=t)return e;let n=e.match(/#\d+$/);if(!n)return e.slice(0,t);let r=n[0],i=e.slice(0,e.length-r.length),a=t-r.length-1;return`${i.slice(0,a)}…${r}`}function S({agents:e,selectedIndex:t,focused:n}){let[r,o]=c(T),s=w[Math.floor(o/T)%w.length];return e.length===0?(0,C.jsx)(a,{color:`subtle`,children:`(no agents in this phase)`}):(0,C.jsx)(i,{ref:r,flexDirection:`column`,children:e.map((e,r)=>{let o=f(e),c=r===t&&n,l=e.status===`running`?s:o.mark,u=x(e.label??`agent-${e.id}`,E);return(0,C.jsxs)(i,{backgroundColor:c?`selectionBg`:void 0,justifyContent:`space-between`,children:[(0,C.jsxs)(i,{children:[(0,C.jsx)(a,{color:o.color,children:l}),(0,C.jsxs)(a,{children:[` `,u]})]}),(0,C.jsx)(a,{color:`subtle`,children:m(e)})]},e.id)})})}var C,w,T,E,D=e((()=>{o(),l(),b(),C=d(),w=[`·`,`✢`,`✱`,`✶`,`✻`,`✽`],T=120,E=18}));function O(e,t){return e?.status===`done`?`done`:t.length>0?t.every(e=>e.status===`done`)?`done`:`running`:e?.status===`running`?`running`:`pending`}function k(e){let t=new Map(e.phases.map(e=>[e.title,e])),n=new Set,r=[],i=i=>{if(n.has(i))return;n.add(i);let a=t.get(i),o=e.agents.filter(e=>e.phase===i);r.push({title:i,status:O(a,o),done:o.filter(e=>e.status===`done`).length,total:o.length})};for(let t of e.declaredPhases)i(t);for(let t of e.phases)i(t.title);for(let t of e.agents)t.phase&&i(t.phase);return r}function ee(e,t){return t===void 0||t===`All`?e:e.filter(e=>e.phase===t)}function A(e){return e.filter(e=>e.status===`running`)}function j(e,t){let n=Math.max(0,Math.trunc(t)),r=e.slice(0,n);return{runs:r,overflow:Math.max(0,e.length-r.length)}}function M(e,t){return`${e}#${t.slice(-4)}`}function N(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m${String(r).padStart(2,`0`)}s`:`${Math.floor(n/60)}h${String(n%60).padStart(2,`0`)}m`}var P=e((()=>{}));function te({phases:e,agents:t,selectedIndex:n,focused:r}){let[o,s]=c(L),l=I[Math.floor(s/L)%I.length],u=t.length;return(0,F.jsx)(i,{ref:o,flexDirection:`column`,children:[{title:`All`,done:t.filter(e=>e.status===`done`).length,total:u},...e].map((e,t)=>{let o=t===n,s=o&&r,c=e.status===`running`?l:e.status?v[e.status]:` `,u=e.status?y[e.status]:`subtle`;return(0,F.jsxs)(i,{backgroundColor:s?`selectionBg`:void 0,justifyContent:`space-between`,children:[(0,F.jsxs)(i,{children:[(0,F.jsx)(a,{color:o?`claude`:void 0,children:s?`>`:` `}),(0,F.jsx)(a,{children:` `}),(0,F.jsx)(a,{color:u,children:c}),(0,F.jsxs)(a,{children:[` `,e.title]})]}),(0,F.jsxs)(a,{color:`subtle`,children:[e.done,`/`,e.total]})]},e.title)})})}var F,I,L,R=e((()=>{o(),l(),b(),P(),F=d(),I=[`·`,`✢`,`✱`,`✶`,`✻`,`✽`],L=120}));function z({runs:e,activeRunId:t}){if(e.length===0)return(0,B.jsx)(a,{color:`subtle`,children:`(no runs)`});let{runs:n,overflow:r}=j(e,H);return(0,B.jsxs)(i,{children:[n.map(e=>{let n=e.runId===t,r=x(M(e.workflowName,e.runId),V),o=`═`.repeat(r.length+2);return(0,B.jsxs)(i,{flexDirection:`column`,marginRight:2,children:[(0,B.jsxs)(i,{children:[(0,B.jsx)(a,{color:g[e.status],children:h[e.status]}),(0,B.jsx)(a,{children:` `}),(0,B.jsx)(a,{color:n?`claude`:void 0,bold:n,children:r})]}),(0,B.jsx)(a,{color:n?`claude`:void 0,children:n?o:``})]},e.runId)}),r>0?(0,B.jsxs)(i,{flexDirection:`column`,marginRight:2,children:[(0,B.jsxs)(a,{color:`subtle`,children:[`+`,r]}),(0,B.jsx)(a,{children:` `})]}):null]})}var B,V,H,U=e((()=>{o(),l(),b(),P(),D(),B=d(),V=18,H=6}));function W(e,t,n=`normal`){return n===`confirm`?e===`y`||e===`Y`||t.return?`confirmYes`:e===`n`||e===`N`||t.escape||e===`q`?`confirmNo`:null:t.tab||e===` `?t.shift?`prevTab`:`nextTab`:t.escape||e===`q`?`quit`:e===`K`?`killWorkflow`:e===`x`?`killAgent`:e===`r`?`resume`:e===`n`?`newRun`:t.leftArrow?`focusLeft`:t.rightArrow?`focusRight`:t.upArrow?`moveUp`:t.downArrow?`moveDown`:null}function G(e,t=`normal`){s((n,r)=>{let i=W(n,r,t);if(i!==null)switch(i){case`nextTab`:e.nextTab();break;case`prevTab`:e.prevTab();break;case`focusLeft`:e.focusLeft();break;case`focusRight`:e.focusRight();break;case`moveUp`:e.moveUp();break;case`moveDown`:e.moveDown();break;case`killAgent`:e.killAgent();break;case`killWorkflow`:e.killWorkflow();break;case`resume`:e.resumeFocused();break;case`newRun`:e.newRun();break;case`quit`:e.quit();break;case`confirmYes`:e.confirmYes();break;case`confirmNo`:e.confirmNo();break}})}var K=e((()=>{l()}));function q(e,t){if(t===0)return 0;let n=Math.trunc(e);return Number.isNaN(n)||n<0?0:Math.min(n,t-1)}function J(e,t){return!e||!t||e.runId!==t.runId||e.status!==`running`?!1:t.status===`completed`||t.status===`failed`||t.status===`killed`}function Y({onDone:e,context:t}){let n=r(),o=(0,X.useSyncExternalStore)(n.subscribe,()=>n.listRuns(),()=>[]),s=A(o),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(`phases`),[m,h]=(0,X.useState)(0),[v,y]=(0,X.useState)(0),[b,x]=(0,X.useState)(null);(0,X.useEffect)(()=>{n.loadPersistedRuns()},[n]),(0,X.useEffect)(()=>{if(s.length===0){l!==null&&d(null);return}s.some(e=>e.runId===l)||d(s[0].runId)},[s,l]);let C=s.find(e=>e.runId===l),w=C?k(C):[],T=w.length+1,E=q(m,T),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{let t=C?{runId:C.runId,status:C.status}:null,n=D.current;if(D.current=t,!J(n,t))return;let r=setTimeout(()=>e(),800);return()=>{clearTimeout(r)}},[C?.runId,C?.status,e]);let O=E===0?void 0:w[E-1]?.title,j=C?ee(C.agents,O):[],M=q(v,j.length),P=e=>{d(e),p(`phases`),h(0),y(0)};G({nextTab:()=>{if(s.length===0)return;let e=s.findIndex(e=>e.runId===l),t=s[(e+1)%s.length];P(t.runId)},prevTab:()=>{if(s.length===0)return;let e=s.findIndex(e=>e.runId===l),t=s[(e-1+s.length)%s.length];P(t.runId)},focusLeft:()=>p(`phases`),focusRight:()=>p(`agents`),moveUp:()=>{f===`phases`?h(e=>q(e-1,T)):y(e=>q(e-1,j.length))},moveDown:()=>{f===`phases`?h(e=>q(e+1,T)):y(e=>q(e+1,j.length))},killAgent:()=>{f!==`agents`||!C||j[M]&&x(`agent`)},killWorkflow:()=>{C&&x(`workflow`)},resumeFocused:()=>{if(!C)return;let r=t.canUseTool;if(!r){e(`resume needs canUseTool context; run /<name> resume from the main session.`);return}n.launch({resumeFromRunId:C.runId,name:C.workflowName},t,r).catch(t=>e(`resume failed: ${t.message}`))},newRun:()=>e(`Tip: start a named workflow with /<name>, or pass name via the Workflow tool.`),quit:()=>{if(b!==null){x(null);return}e()},confirmYes:()=>{if(b===`workflow`&&C){n.kill(C.runId),x(null),e();return}else if(b===`agent`&&C){let e=j[M];e&&n.killAgent(C.runId,e.id)}x(null)},confirmNo:()=>x(null)},b===null?`normal`:`confirm`);let F=o.filter(e=>e.status===`running`).length,I=o.length-F,L=O??`All`,R=C?C.agents.filter(e=>e.status===`done`).length:0,[B]=c(1e3),V=C?Date.now()-C.startedAt:0;return(0,Z.jsxs)(i,{ref:B,flexDirection:`column`,borderStyle:`round`,borderColor:`claude`,paddingX:1,children:[(0,Z.jsxs)(i,{justifyContent:`space-between`,children:[(0,Z.jsx)(a,{bold:!0,children:C?.workflowName??`Workflows`}),C?(0,Z.jsxs)(a,{color:`subtle`,children:[R,`/`,C.agentCount,` agents · `,N(V),` ·`,` `,(0,Z.jsx)(a,{color:g[C.status],children:_[C.status]})]}):(0,Z.jsxs)(a,{color:`subtle`,children:[F,` running · `,I,` done`]})]}),C?.description?(0,Z.jsx)(a,{color:`subtle`,children:C.description}):null,s.length>1?(0,Z.jsx)(i,{marginTop:1,children:(0,Z.jsx)(z,{runs:s,activeRunId:l})}):null,(0,Z.jsxs)(i,{flexDirection:`row`,marginTop:1,children:[(0,Z.jsxs)(i,{width:`25%`,flexDirection:`column`,children:[(0,Z.jsx)(a,{color:f===`phases`?`claude`:`subtle`,bold:!0,children:`Phases`}),(0,Z.jsx)(te,{phases:w,agents:C?.agents??[],selectedIndex:E,focused:f===`phases`})]}),(0,Z.jsx)(a,{color:`subtle`,children:`│`}),(0,Z.jsxs)(i,{flexGrow:1,flexDirection:`column`,children:[(0,Z.jsxs)(a,{color:f===`agents`?`claude`:`subtle`,bold:!0,children:[L,` · `,j.length,` agents`]}),(0,Z.jsx)(S,{agents:j,selectedIndex:M,focused:f===`agents`})]})]}),(0,Z.jsx)(i,{marginTop:1,children:(0,Z.jsx)(a,{color:`subtle`,children:b===null?`Tab switch run · ←/→ focus · ↑/↓ move · x kill agent · K kill workflow · r resume · q quit`:`Confirm: y kill · n/Esc cancel`})}),b===null?null:(0,Z.jsx)(u,{title:b===`workflow`?`Kill workflow "${C?.workflowName??``}"?`:`Kill agent "${j[M]?.label??``}"?`,subtitle:b===`workflow`?`All in-flight agents will be aborted. Resume will replay from journal.`:`Only this agent aborts; other agents in the workflow keep running.`,onCancel:()=>x(null),color:`warning`,children:(0,Z.jsx)(a,{color:`subtle`,children:`Press y to confirm, or n/Esc to cancel.`})})]})}var X,Z,ne=e((()=>{X=t(o(),1),l(),n(),D(),R(),U(),b(),K(),P(),Z=d()})),Q,$;e((()=>{ne(),Q=d(),$=async(e,t,n)=>(0,Q.jsx)(Y,{onDone:e,context:t})}))();export{$ as call};
@@ -1 +0,0 @@
1
- import{i as e,r as t}from"./parser-BdCj2GrE.js";t();export{e as parseCommand};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{DE as t,OE as n}from"./loadAgentsDir-CKSb56Gp.js";import{Ci as r,Er as i,Tr as a,wi as o}from"./state-Bs5xweDL.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,n,r,i){return t(e,function(e,t,a){n(i,e,r(e),a)}),i}var u=e((()=>{n()}));function d(e,t){return function(n,r){var i=o(n)?s:l,c=t?t():{};return i(n,e,a(r,2),c)}}var f=e((()=>{c(),u(),i(),r()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
@@ -1,3 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{B as i,Ew as a,G as o,H as s,Qa as c,Sd as l,T_ as u,V as d,W as f,aE as p,cE as ee,dd as m,fd as h,ja as g,lv as te,n_ as _,ov as ne,pw as re,r_ as v,sv as ie,w_ as y,x_ as ae,xd as b,z as oe}from"./loadAgentsDir-CKSb56Gp.js";import{I as x,P as S,Wt as se,Xn as ce,a as C,di as w,fi as T,hn as E,k as D,kt as O,n as k,o as A,ot as le,r as ue,s as de,t as j,ui as M,x as fe,y as N}from"./src-P_wYS_NJ2.js";import{t as P}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as pe,tt as F}from"./state-Bs5xweDL.js";import{S as me,w as I}from"./debug-BdqxZ7rV.js";import{H as L,V as R,cn as he,g as z,nn as B,o as ge,z as V}from"./settings-Xbq6AaD-.js";import{l as _e,o as ve}from"./stringUtils-CbS6OkmE.js";import{n as ye,t as be}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import{n as xe,t as Se}from"./AddWorkspaceDirectory-qFZy3FOD.js";import{t as Ce}from"./SearchBox-C9vUA4IM.js";import{n as we,t as Te}from"./useSearchInput-C6d6nt9S.js";import{n as Ee,t as De}from"./shadowedRuleDetection-B9iSx6mB.js";import{n as H,t as Oe}from"./autoModeDenials-BxNzGJdR.js";function ke({ruleValue:e}){switch(e.toolName){case _.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,U.jsxs)(S,{dimColor:!0,children:[`Any Bash command starting with `,(0,U.jsx)(S,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,U.jsxs)(S,{dimColor:!0,children:[`The Bash command `,(0,U.jsx)(S,{bold:!0,children:e.ruleContent})]}):(0,U.jsx)(S,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,U.jsxs)(S,{dimColor:!0,children:[`Any use of the `,(0,U.jsx)(S,{bold:!0,children:e.toolName}),` tool`]})}}var U,Ae=e((()=>{T(),j(),v(),U=P()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${ge(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${ge(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.claude/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:i,setToolPermissionContext:a}){let o=B.map(je),s=(0,Ne.useCallback)(o=>{if(o===`cancel`){t();return}else if(B.includes(o)){let t=o,s=ae(i,{type:`addRules`,rules:n,behavior:r,destination:t});u({type:`addRules`,rules:n,behavior:r,destination:t}),a(s);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=De(s,{sandboxAutoAllowEnabled:p.isSandboxingEnabled()&&p.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(c,l.length>0?l:void 0)}},[e,t,n,r,i,a]);return(0,W.jsxs)(N,{title:`Add ${r} permission ${_e(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,W.jsx)(x,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,W.jsxs)(x,{flexDirection:`column`,children:[(0,W.jsx)(S,{bold:!0,children:L(e)}),(0,W.jsx)(ke,{ruleValue:e})]},L(e)))}),(0,W.jsxs)(x,{flexDirection:`column`,marginY:1,children:[(0,W.jsx)(S,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,W.jsx)(m,{options:o,onChange:s})]})]})}var Ne,W,Pe=e((()=>{T(),Ne=t(T(),1),h(),j(),y(),V(),Ee(),ee(),he(),z(),ve(),Ae(),W=P()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Ie.useState)(``),[o,s]=(0,Ie.useState)(0),c=ye();se(`confirm:no`,e,{context:`Settings`});let{columns:l}=le(),u=l-6;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,G.jsxs)(S,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,G.jsxs)(x,{flexDirection:`column`,children:[(0,G.jsxs)(S,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,G.jsx)(O,{}),`e.g., `,(0,G.jsx)(S,{bold:!0,children:L({toolName:_.name})}),(0,G.jsx)(S,{bold:!1,children:` or `}),(0,G.jsx)(S,{bold:!0,children:L({toolName:_.name,ruleContent:`ls:*`})})]}),(0,G.jsx)(x,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,G.jsx)(b,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(R(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:u,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,G.jsx)(x,{marginLeft:3,children:c.pending?(0,G.jsxs)(S,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,G.jsx)(S,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,G,Le=e((()=>{n(),T(),Ie=t(T(),1),l(),be(),re(),j(),a(),v(),V(),G=P()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=C();(0,K.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,K.useState)(()=>Oe()),[a,o]=(0,K.useState)(()=>new Set),[s,c]=(0,K.useState)(()=>new Set),[l,u]=(0,K.useState)(0);(0,K.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,K.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),f=(0,K.useCallback)(e=>{u(Number(e))},[]);if(E((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,q.jsx)(S,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let p=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,q.jsxs)(S,{children:[(0,q.jsx)(de,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,q.jsx)(S,{dimColor:!0,children:r})]}),value:String(t)}});return(0,q.jsxs)(x,{flexDirection:`column`,children:[(0,q.jsx)(S,{children:`Commands recently denied by the auto mode classifier.`}),(0,q.jsx)(x,{marginTop:1,children:(0,q.jsx)(m,{options:p,onChange:d,onFocus:f,visibleOptionCount:Math.min(10,p.length),isDisabled:n,onUpFromFirstItem:r})})]})}var K,q,ze=e((()=>{T(),K=t(T(),1),j(),H(),h(),q=P()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let a=(0,Ve.useCallback)(()=>{i(ae(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),o=(0,Ve.useCallback)(e=>{e===`yes`?a():n()},[a,n]);return(0,J.jsxs)(N,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,J.jsx)(x,{marginX:2,flexDirection:`column`,children:(0,J.jsx)(S,{bold:!0,children:e})}),(0,J.jsx)(S,{children:`Claude Code will no longer have access to files in this directory.`}),(0,J.jsx)(m,{onChange:o,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,J,He=e((()=>{T(),Ve=t(T(),1),h(),j(),y(),J=P()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=C();(0,Y.useEffect)(()=>{a?.(o)},[o,a]);let c=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,Y.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t&&t.isDeletable&&i(t.path)},[c,n,i]),u=(0,Y.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=We.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,X.jsxs)(x,{flexDirection:`column`,marginBottom:1,children:[(0,X.jsxs)(x,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,X.jsx)(S,{children:`- ${F()}`}),(0,X.jsx)(S,{dimColor:!0,children:`(Original working directory)`})]}),(0,X.jsx)(m,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var We,Y,X,Ge=e((()=>{n(),We=t(T(),1),Y=t(T(),1),pe(),h(),j(),X=P()}));function Ke({rule:e}){return(0,$.jsx)(S,{dimColor:!0,children:`From ${o(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=ye();se(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(x,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(S,{bold:!0,children:L(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),a=(0,$.jsx)(x,{marginLeft:3,children:r.pending?(0,$.jsxs)(S,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(S,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(S,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(S,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
- `,`Contact your system administrator for more information.`]})]}),a]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(S,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),i,(0,$.jsx)(S,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(m,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),a]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:i,onSelect:a,onCancel:o,lastFocusedRuleKey:s,cursorOffset:c,onHeaderFocusChange:l}=e,u=A(),{headerFocused:d,focusHeader:f,blurHeader:p}=C();return(0,Q.useEffect)(()=>{r&&d&&p()},[r,d,p]),(0,Q.useEffect)(()=>{l?.(d)},[d,l]),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(x,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(D,{query:n,isFocused:r&&!d,isTerminalFocused:i,width:u,cursorOffset:c})}),(0,$.jsx)(m,{options:t,onChange:a,onCancel:o,visibleOptionCount:Math.min(10,t.length),isDisabled:r||d,defaultFocusValue:s,onUpFromFirstItem:f})]})}function Z({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(x,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(S,{children:{allow:`Claude Code won't ask before using allowed tools.`,ask:`Claude Code will always ask for confirmation before using these tools.`,deny:`Claude Code will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Ye,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Xe({onExit:e,initialTab:t,onRetryDenials:n}){let a=Oe().length>0,o=t??(a?`recent`:`allow`),[c,l]=(0,Q.useState)([]),f=ie(e=>e.toolPermissionContext),p=te(),ee=ce(),m=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),h=(0,Q.useCallback)(e=>{m.current=e},[]),[g,_]=(0,Q.useState)(),[ne,re]=(0,Q.useState)(),[v,y]=(0,Q.useState)(null),[b,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,A]=(0,Q.useState)(!1),[le,de]=(0,Q.useState)(!0),j=(0,Q.useCallback)(e=>{de(e)},[]),N=(0,Q.useMemo)(()=>{let e=new Map;return i(f).forEach(t=>{e.set(I(t),t)}),e},[f]),P=(0,Q.useMemo)(()=>{let e=new Map;return s(f).forEach(t=>{e.set(I(t),t)}),e},[f]),pe=(0,Q.useMemo)(()=>{let e=new Map;return d(f).forEach(t=>{e.set(I(t),t)}),e},[f]),F=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return N;case`deny`:return P;case`ask`:return pe;case`workspace`:case`recent`:return new Map}})(),i=[];e!==`workspace`&&e!==`recent`&&!t&&i.push({label:`Add a new rule${r.ellipsis}`,value:`add-new-rule`});let a=Array.from(n.keys()).sort((e,t)=>{let r=n.get(e),i=n.get(t);if(r&&i){let e=L(r.ruleValue).toLowerCase(),t=L(i.ruleValue).toLowerCase();return e.localeCompare(t)}return 0}),o=t.toLowerCase();for(let e of a){let r=n.get(e);if(r){let n=L(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[N,P,pe]),me=ye(),R=!g&&!v&&!b&&!w&&!E,{query:he,setQuery:z,cursorOffset:B}=we({isActive:R&&O,onExit:()=>{A(!1)}}),ge=(0,Q.useCallback)(e=>{R&&(O||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),A(!0),z(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),A(!0),z(e.key))))},[R,O,z]),V=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=F(t);if(e===`add-new-rule`){y(t);return}else{_(n.get(e));return}},[F]),_e=(0,Q.useCallback)(()=>{y(null)},[]),ve=(0,Q.useCallback)((e,t)=>{C({ruleValue:e,ruleBehavior:t}),y(null)},[]),be=(0,Q.useCallback)((e,t)=>{C(null);for(let t of e)l(e=>[...e,`Added ${t.ruleBehavior} rule ${M.bold(L(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;l(n=>[...n,M.yellow(`${r.warning} Warning: ${L(e.rule.ruleValue)} is ${t}`),M.dim(` ${e.reason}`),M.dim(` Fix: ${e.fix}`)])}},[]),xe=(0,Q.useCallback)(()=>{C(null)},[]),Ce=(0,Q.useCallback)(()=>T(!0),[]),Te=(0,Q.useCallback)(e=>D(e),[]),Ee=(0,Q.useCallback)(()=>{let t=m.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let a=r(t.approved);a.length>0||c.length>0?e([...a.length>0?[`Approved ${a.map(e=>M.bold(e.display)).join(`, `)}`]:[],...c].join(`
3
- `)):e(`Permissions dialog dismissed`,{display:`system`})},[c,e,n]);se(`confirm:no`,Ee,{context:`Settings`,isActive:R&&!O});let De=()=>{if(!g)return;let{options:e}=F(g.ruleBehavior),t=I(g),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),re(i),oe({rule:g,initialContext:f,setToolPermissionContext(e){p(t=>({...t,toolPermissionContext:e}))}}),l(e=>[...e,`Deleted ${g.ruleBehavior} rule ${M.bold(L(g.ruleValue))}`]),_(void 0)};if(g)return(0,$.jsx)(Je,{rule:g,onDelete:De,onCancel:()=>_(void 0)});if(v&&v!==`workspace`&&v!==`recent`)return(0,$.jsx)(Fe,{onCancel:_e,onSubmit:ve,ruleBehavior:v});if(b)return(0,$.jsx)(Me,{onAddRules:be,onCancel:xe,ruleValues:[b.ruleValue],ruleBehavior:b.ruleBehavior,initialContext:f,setToolPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});if(w)return(0,$.jsx)(Se,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=ae(f,n);p(e=>({...e,toolPermissionContext:r})),t&&u(n),l(n=>[...n,`Added directory ${M.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),T(!1)},onCancel:()=>T(!1),permissionContext:f});if(E)return(0,$.jsx)(Be,{directoryPath:E,onRemove:()=>{l(e=>[...e,`Removed directory ${M.bold(E)} from workspace`]),D(null)},onCancel:()=>D(null),permissionContext:f,setPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});let H={searchQuery:he,isSearchMode:O,isFocused:ee,onCancel:Ee,lastFocusedRuleKey:ne,cursorOffset:B,getRulesOptions:F,handleToolSelect:V,onHeaderFocusChange:j};return(0,$.jsx)(x,{flexDirection:`column`,onKeyDown:ge,children:(0,$.jsxs)(fe,{color:`permission`,children:[(0,$.jsxs)(ue,{title:`Permissions:`,color:`permission`,defaultTab:o,hidden:!!g||!!v||!!b||w||!!E,initialHeaderFocused:!a,navFromContent:!O,children:[(0,$.jsx)(k,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:j,onStateChange:h})}),(0,$.jsx)(k,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Z,{tab:`allow`,...H})}),(0,$.jsx)(k,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Z,{tab:`ask`,...H})}),(0,$.jsx)(k,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Z,{tab:`deny`,...H})}),(0,$.jsx)(k,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(S,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:f,onRequestAddDirectory:Ce,onRequestRemoveDirectory:Te,onHeaderFocusChange:j})]})})]}),(0,$.jsx)(x,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(S,{dimColor:!0,children:me.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,me.keyName,` again to exit`]}):le?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):O?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):a&&o===`recent`?(0,$.jsx)($.Fragment,{children:`Enter approve · r retry · ↑↓ navigate · ←/→ switch · Esc cancel`}):(0,$.jsx)($.Fragment,{children:`↑↓ navigate · Enter select · Type to search · ←/→ switch · Esc cancel`})})})]})})}var Q,$,Ze=e((()=>{w(),n(),T(),Q=t(T(),1),ne(),y(),h(),be(),Te(),j(),a(),H(),V(),f(),me(),Ce(),Pe(),xe(),Ae(),Le(),ze(),He(),Ge(),$=P()})),Qe,$e;e((()=>{Ze(),c(),Qe=P(),$e=async(e,t)=>(0,Qe.jsx)(Xe,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,g(e)])}})}))();export{$e as call};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{o as r}from"./log-CTFl4qpD.js";import{join as i}from"path";import"fs/promises";import"net";import"events";function a(){return i(t(),`pipes`)}function o(e){return e?.pipeIpc??s}var s,c=e((()=>{n(),r(),s={role:`main`,subIndex:null,displayRole:`main`,serverName:null,attachedBy:null,localIp:null,hostname:null,machineId:null,mac:null,statusVisible:!1,selectorOpen:!1,selectedPipes:[],routeMode:`selected`,slaves:{},discoveredPipes:[]}}));export{a as n,c as r,o as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$x as t,A as n,C as r,FT as i,MT as a,jT as o,sS as s,w_ as c,x_ as l}from"./loadAgentsDir-CKSb56Gp.js";import{I as u,P as d,fi as f,t as p}from"./src-P_wYS_NJ2.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as h,Vt as g}from"./state-Bs5xweDL.js";import{a as _,i as v,r as y,t as b}from"./promptEditor-0Ug93P2I.js";import{r as x,t as S}from"./staticRender-DrU6eWoq.js";function C({planContent:e,planPath:t,editorName:n}){return(0,T.jsxs)(u,{flexDirection:`column`,children:[(0,T.jsx)(d,{bold:!0,children:`Current Plan`}),(0,T.jsx)(d,{dimColor:!0,children:t}),(0,T.jsx)(u,{marginTop:1,children:(0,T.jsx)(d,{children:e})}),n&&(0,T.jsxs)(u,{marginTop:1,children:[(0,T.jsx)(d,{dimColor:!0,children:`"/plan open"`}),(0,T.jsx)(d,{dimColor:!0,children:` to edit this plan in `}),(0,T.jsx)(d,{bold:!0,dimColor:!0,children:n})]})]})}async function w(e,t,r){let{getAppState:i,setAppState:c}=t,u=i().toolPermissionContext.mode;if(u!==`plan`){g(u,`plan`),c(e=>({...e,toolPermissionContext:l(n(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=r.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let d=o(),f=a();if(!d)return e(`Already in plan mode. No plan written yet.`),null;if(r.trim().split(/\s+/)[0]===`open`){let t=await b(f);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${f}`),null}let p=v();return e(await x((0,T.jsx)(C,{planContent:d,planPath:f,editorName:p?s(p):void 0}))),null}var T;e((()=>{f(),h(),p(),_(),t(),c(),r(),i(),y(),S(),T=m()}))();export{w as call};