@readmagic/workmate 0.0.8 → 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 (512) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-Vmmm7p1c.js +1 -0
  2. package/dist/chunks/App-C2yQjBgY.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +1 -0
  4. package/dist/chunks/ApproveApiKey-MscC-ssL.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +2 -0
  6. package/dist/chunks/BypassPermissionsModeDialog-CLSACUmo.js +1 -0
  7. package/dist/chunks/ClaudeMdExternalIncludesDialog-BqNxQOXJ.js +1 -0
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +1 -0
  10. package/dist/chunks/DiffDialog-9AYwtupw.js +6 -0
  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-B9-hhkZA.js +11 -0
  15. package/dist/chunks/{HybridTransport-BJPOG2wl.js → HybridTransport-MxJ_W_np.js} +3 -3
  16. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +1 -0
  17. package/dist/chunks/InvalidSettingsDialog-YyQcHocx.js +1 -0
  18. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +1 -0
  19. package/dist/chunks/MCPToolListView-CvqB4nCw.js +1 -0
  20. package/dist/chunks/McpParsingWarnings-BCpfHaBK.js +1 -0
  21. package/dist/chunks/MessageSelector-BLzw172f.js +3 -0
  22. package/dist/chunks/Messages-4K5sLmNh.js +11 -0
  23. package/dist/chunks/Onboarding-ClwHS5rh.js +1 -0
  24. package/dist/chunks/{PermissionDialog-0ya1CU5k.js → PermissionDialog-Cb3z8OUP.js} +1 -1
  25. package/dist/chunks/{PressEnterToContinue-Dl9Hg9Mf.js → PressEnterToContinue-Dq0Imo9c.js} +1 -1
  26. package/dist/chunks/PromptInputFooterSuggestions-BSA9NrZc.js +1 -0
  27. package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +1 -0
  28. package/dist/chunks/QueryEngine-DPHLSsax.js +1 -0
  29. package/dist/chunks/REPL-Bf46iQCN.js +1 -0
  30. package/dist/chunks/REPL-DIaAo9M9.js +133 -0
  31. package/dist/chunks/RemoteSessionManager-CS6mywIn.js +2 -0
  32. package/dist/chunks/ResumeConversation-Br2KsBoe.js +1 -0
  33. package/dist/chunks/{SSETransport-CrwbKuVt.js → SSETransport-CoxQ8YpH.js} +1 -1
  34. package/dist/chunks/{SearchBox-vfLXEPed.js → SearchBox-C9vUA4IM.js} +1 -1
  35. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +1 -0
  36. package/dist/chunks/Settings-BMXysXIx.js +2 -0
  37. package/dist/chunks/TeleportProgress-Doucj-50.js +1 -0
  38. package/dist/chunks/TeleportRepoMismatchDialog-B5I73j7Y.js +1 -0
  39. package/dist/chunks/TeleportResumeWrapper-D6kpr2c6.js +1 -0
  40. package/dist/chunks/ThemePicker-DrC8tlp0.js +1 -0
  41. package/dist/chunks/{TrustDialog-BukWGvHZ.js → TrustDialog-Fk4m_Sy4.js} +1 -1
  42. package/dist/chunks/{ValidationErrorsList-DokTJQwi.js → ValidationErrorsList-D_OUa4RT.js} +1 -1
  43. package/dist/chunks/WelcomeV2-DvfQHnZY.js +1 -0
  44. package/dist/chunks/add-dir-CZ6Clvq8.js +1 -0
  45. package/dist/chunks/{agentDisplay-DBQYOaOh.js → agentDisplay-B755vMZE.js} +1 -1
  46. package/dist/chunks/{agents-HlKk68Qc.js → agents-CIvP8l0s.js} +1 -1
  47. package/dist/chunks/agents-DHnNg4h6.js +103 -0
  48. package/dist/chunks/allErrors-CU89tF-z.js +1 -0
  49. package/dist/chunks/analytics-DJobLaWP.js +1 -0
  50. package/dist/chunks/api-BSeE6MwB.js +1 -0
  51. package/dist/chunks/{api-CF5IVtj0.js → api-nSHc_GIQ.js} +1 -1
  52. package/dist/chunks/auth-5QB6tsfB.js +15 -0
  53. package/dist/chunks/auth-BIGJth5U.js +1 -0
  54. package/dist/chunks/auth-CDQMhIZP.js +1 -0
  55. package/dist/chunks/{autoMode-Cr0AhS1G.js → autoMode-BnUiK9Cu.js} +4 -4
  56. package/dist/chunks/{autonomy-ARUQt-Lu.js → autonomy-C1aSgWPQ.js} +1 -1
  57. package/dist/chunks/autonomy-Src6sKCp.js +15 -0
  58. package/dist/chunks/{autonomyPanel-BQK9MoeB.js → autonomyPanel-DnHpuiy4.js} +1 -1
  59. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +17 -0
  60. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +1 -0
  61. package/dist/chunks/{banner-Ca7rki2V.js → banner-D0P7wXdw.js} +1 -1
  62. package/dist/chunks/bg-50rllUNh.js +1 -0
  63. package/dist/chunks/{bg-DxRHF1yn.js → bg-DAPORXF3.js} +2 -2
  64. package/dist/chunks/branch-DFWa4Oxo.js +3 -0
  65. package/dist/chunks/{break-cache-BKvoMOZx.js → break-cache-Chj9i9MP.js} +2 -2
  66. package/dist/chunks/{bridgeConfig-jDEva6Eh.js → bridgeConfig-Bb6URf4Q.js} +1 -1
  67. package/dist/chunks/bridgeConfig-BeqChxJC.js +1 -0
  68. package/dist/chunks/bridgeMessaging-C3huGcR3.js +1 -0
  69. package/dist/chunks/{bridgePointer-DIM0sj0x.js → bridgePointer-DLYyvRKb.js} +1 -1
  70. package/dist/chunks/bridgeStatusUtil-DFMftajD.js +1 -0
  71. package/dist/chunks/btw-DSK9R2C8.js +1 -0
  72. package/dist/chunks/caches-BTQAW9zc.js +1 -0
  73. package/dist/chunks/caches-BVtSCnV1.js +1 -0
  74. package/dist/chunks/{capacityWake-CKOiRELo.js → capacityWake-amzeeBz0.js} +1 -1
  75. package/dist/chunks/{ccrClient-BC2q3k44.js → ccrClient-Bu7Tf1Z5.js} +1 -1
  76. package/dist/chunks/{claudeDesktop-DQXL5bGm.js → claudeDesktop-CsJfF1b-.js} +1 -1
  77. package/dist/chunks/{clear-1etSJhdg.js → clear-ClFDpWVJ.js} +1 -1
  78. package/dist/chunks/{cliLaunch-CQjLYRzM.js → cliLaunch-BWcoyZDP.js} +1 -1
  79. package/dist/chunks/client-BWQ4-rN7.js +1 -0
  80. package/dist/chunks/{client-DQwf_b9o.js → client-DFlE4fYh.js} +1 -1
  81. package/dist/chunks/client-c-3-PW1F.js +1 -0
  82. package/dist/chunks/commands-Bi7k3Wg-.js +1 -0
  83. package/dist/chunks/compact-J-h0Yf4b.js +2 -0
  84. package/dist/chunks/config-CVHMRMwd.js +1 -0
  85. package/dist/chunks/config-Do1870_d.js +3 -0
  86. package/dist/chunks/config-yyFe87vW.js +1 -0
  87. package/dist/chunks/context-Tb1Ca2Q-.js +1 -0
  88. package/dist/chunks/{context-noninteractive-Ct_ttQfP.js → context-noninteractive-D5iQhasu.js} +2 -2
  89. package/dist/chunks/context-noninteractive-soPYKAc9.js +1 -0
  90. package/dist/chunks/conversation-CSEtUxOY.js +1 -0
  91. package/dist/chunks/conversation-Dk1WDQuN.js +1 -0
  92. package/dist/chunks/{createSSHSession-BmHXA2me.js → createSSHSession-CJtzNQdZ.js} +1 -1
  93. package/dist/chunks/{createSession-C4rukWkv.js → createSession-DkT1GL8y.js} +1 -1
  94. package/dist/chunks/createSession-eE8mswkv.js +1 -0
  95. package/dist/chunks/crossProjectResume-04n3Ppy9.js +40 -0
  96. package/dist/chunks/cwd-Cfdf7z7s.js +1 -0
  97. package/dist/chunks/cwd-ClLru_7T.js +1 -0
  98. package/dist/chunks/datadog-DjeJThpV.js +1 -0
  99. package/dist/chunks/{debug-RZ4NuXyS.js → debug-RAynG_nM.js} +4 -4
  100. package/dist/chunks/{debugUtils-D30M1cbN.js → debugUtils-DX0KAXNK.js} +1 -1
  101. package/dist/chunks/{detached-jrVP11oU.js → detached-X_yjYR7x.js} +1 -1
  102. package/dist/chunks/{detectRepository-CFiHe6Rv.js → detectRepository-DgpNd87p.js} +1 -1
  103. package/dist/chunks/detectRepository-ctF9KDbb.js +1 -0
  104. package/dist/chunks/{diff-BKiK3xHv.js → diff-jEJJe58I.js} +1 -1
  105. package/dist/chunks/directoryCompletion-BbXR2bfy.js +1 -0
  106. package/dist/chunks/doctor-B-Wag4C1.js +1 -0
  107. package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
  108. package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
  109. package/dist/chunks/entry-oIqjxIjQ.js +14 -0
  110. package/dist/chunks/envUtils-BDhHQY0-.js +1 -0
  111. package/dist/chunks/esm-Cf4nSRjF.js +1 -0
  112. package/dist/chunks/{execFileNoThrow-CCX-JY8h.js → execFileNoThrow-Dwu6psHW.js} +1 -1
  113. package/dist/chunks/{execSyncWrapper-dhRSYGFW.js → execSyncWrapper-BTZJjCuv.js} +1 -1
  114. package/dist/chunks/exit-BtW7LfRX.js +1 -0
  115. package/dist/chunks/extraUsage-Mi66JwFZ.js +1 -0
  116. package/dist/chunks/extractMemories-CUrdiNcr.js +1 -0
  117. package/dist/chunks/fast-BU4iUZ8E.js +1 -0
  118. package/dist/chunks/fast-C60p6AqJ.js +1 -0
  119. package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
  120. package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
  121. package/dist/chunks/fileSuggestions-BMfQIDdW.js +3 -0
  122. package/dist/chunks/firstPartyEventLogger-B3cXgR67.js +5 -0
  123. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +1 -0
  124. package/dist/chunks/flushGate-DgSDVGKZ.js +1 -0
  125. package/dist/chunks/{fpsMetrics-Cf_hdtiJ.js → fpsMetrics-DffAomdg.js} +1 -1
  126. package/dist/chunks/gemini-BwvSxGgn.js +1 -0
  127. package/dist/chunks/generateSessionName-DlrdedOk.js +1 -0
  128. package/dist/chunks/{genericProcessUtils-DVfMHhfy.js → genericProcessUtils-CmsUPyRz.js} +1 -1
  129. package/dist/chunks/{git-BerW9bId.js → git-2c7WlGDL.js} +1 -1
  130. package/dist/chunks/git-XtKbtJMc.js +1 -0
  131. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +1 -0
  132. package/dist/chunks/goal-ZmSRBx4q.js +3 -0
  133. package/dist/chunks/grok-BXMvezWb.js +1 -0
  134. package/dist/chunks/grove-CeOjTaY6.js +7 -0
  135. package/dist/chunks/help-5DNZO6_H.js +1 -0
  136. package/dist/chunks/{hooks-BZJTWD07.js → hooks-C637tFtd.js} +2 -2
  137. package/dist/chunks/hooks-DWg07LmS.js +1 -0
  138. package/dist/chunks/initReplBridge-D1h10vQ9.js +1 -0
  139. package/dist/chunks/{install-BI---dv0.js → install-C-6ItpH0.js} +1 -1
  140. package/dist/chunks/{instrumentation-CcWzhGfE.js → instrumentation-DaiPDUst.js} +4 -4
  141. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  142. package/dist/chunks/{job-B0ftcqPF.js → job-BeYzQUiR.js} +1 -1
  143. package/dist/chunks/{jwtUtils-C0cE-1Ey.js → jwtUtils-CUPXdX3W.js} +1 -1
  144. package/dist/chunks/keybindings-DgIPdBy9.js +2 -0
  145. package/dist/chunks/launchLocalMemory-CE4J98xO.js +3 -0
  146. package/dist/chunks/launchOnboarding-BfTdC6vp.js +8 -0
  147. package/dist/chunks/{loadAgentsDir-ByO8eJqU.js → loadAgentsDir-C7lOqvfh.js} +2233 -2454
  148. package/dist/chunks/loadAgentsDir-zikjxLvn.js +1 -0
  149. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +1 -0
  150. package/dist/chunks/{localSearch-CHHCH16D.js → localSearch-BKrznW5x.js} +1 -1
  151. package/dist/chunks/localSearch-ZFyFy5FN.js +1 -0
  152. package/dist/chunks/log-CezCRpAN.js +1 -0
  153. package/dist/chunks/logoV2Utils-BkQfyQ1-.js +1 -0
  154. package/dist/chunks/{magicDocs-C5i5ruuU.js → magicDocs-BpVcON9o.js} +3 -3
  155. package/dist/chunks/main-9r5gLzUW.js +605 -0
  156. package/dist/chunks/{main-BLD4QAQg.js → main-CvOv59-7.js} +4 -4
  157. package/dist/chunks/managedEnv-B61yLpwp.js +1 -0
  158. package/dist/chunks/{managedEnv-C-9XSN14.js → managedEnv-DhWRJ5DK.js} +1 -1
  159. package/dist/chunks/{mappers-CHRFic5q.js → mappers-bOab8ipV.js} +1 -1
  160. package/dist/chunks/mcp-BckPBjaM.js +6 -0
  161. package/dist/chunks/mcp-CS1DA3JL.js +1 -0
  162. package/dist/chunks/mcp-VcGPYCkW.js +2 -0
  163. package/dist/chunks/{memoize-B8hfb1JN.js → memoize-DsqYrbeR.js} +1 -1
  164. package/dist/chunks/memory-C5ohwh-T.js +1 -0
  165. package/dist/chunks/{modalContext-DFjKLCB6.js → modalContext-CUThy6Ph.js} +1 -1
  166. package/dist/chunks/mode-DlKnUM8l.js +2 -0
  167. package/dist/chunks/model-BGu1AGq0.js +1 -0
  168. package/dist/chunks/model-BsZ4sP_H.js +1 -0
  169. package/dist/chunks/model-D19IIcll.js +1 -0
  170. package/dist/chunks/modelOptions-CxP067Qv.js +1 -0
  171. package/dist/chunks/nativeInstaller-QB8cEJ18.js +1 -0
  172. package/dist/chunks/oauth-BN2I0_jl.js +1 -0
  173. package/dist/chunks/oauth-C9VBDB0Y.js +1 -0
  174. package/dist/chunks/omit-DDUIPHnl.js +1 -0
  175. package/dist/chunks/onChangeAppState-RBl6H7ho.js +1 -0
  176. package/dist/chunks/{openai-DPH6rXOZ.js → openai-B9C2XN5Q.js} +3 -3
  177. package/dist/chunks/{panel-mD094ALT.js → panel-KW-wmEvU.js} +1 -1
  178. package/dist/chunks/{parser-dbHRgXb8.js → parser-BwPXQomy.js} +1 -1
  179. package/dist/chunks/parser-xSBaQRLH.js +1 -0
  180. package/dist/chunks/partition-D-UhsUCx.js +1 -0
  181. package/dist/chunks/permissions-BoLXYN1j.js +3 -0
  182. package/dist/chunks/pidLock-nJHbufJN.js +3 -0
  183. package/dist/chunks/plan-CyU2zrCK.js +1 -0
  184. package/dist/chunks/{platform-DCXXznJg.js → platform-BMPbglug.js} +1 -1
  185. package/dist/chunks/plugin-C6-GQke5.js +17 -0
  186. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +1 -0
  187. package/dist/chunks/{pluginBlocklist-PwHHD3nj.js → pluginBlocklist-n6Imlh3y.js} +1 -1
  188. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +1 -0
  189. package/dist/chunks/{pluginFlagging-pBxSselw.js → pluginFlagging-DZaYzecY.js} +1 -1
  190. package/dist/chunks/pluginOperations-D90IRawu.js +2 -0
  191. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +1 -0
  192. package/dist/chunks/{pluginStartupCheck-Di4LjHXf.js → pluginStartupCheck-CB2q2dLv.js} +1 -1
  193. package/dist/chunks/plugins-B9eSjLSA.js +4 -0
  194. package/dist/chunks/poorMode-BAnubpn1.js +1 -0
  195. package/dist/chunks/{poorMode-CYXmr_mU.js → poorMode-DEwQOAJt.js} +1 -1
  196. package/dist/chunks/print-eCRv_Li-.js +26 -0
  197. package/dist/chunks/processBashCommand-B5F2Cl7K.js +1 -0
  198. package/dist/chunks/processSlashCommand-BC_D3cH5.js +5 -0
  199. package/dist/chunks/{projectContext-D9MDwJUF.js → projectContext-CIxul6vA.js} +1 -1
  200. package/dist/chunks/{projectContext-BaDZBAoK.js → projectContext-RUMJB798.js} +1 -1
  201. package/dist/chunks/prompt-C1JPqinc.js +1 -0
  202. package/dist/chunks/prompt-DZhBz_Vu.js +1 -0
  203. package/dist/chunks/prompt-M2lu8_Oa.js +139 -0
  204. package/dist/chunks/promptEditor-DhcZY-iu.js +4 -0
  205. package/dist/chunks/{protocolHandler-RNKkhq91.js → protocolHandler-CkFaJKKo.js} +1 -1
  206. package/dist/chunks/{proxy-BmtEnJ02.js → proxy-CuMaO_YV.js} +1 -1
  207. package/dist/chunks/reconciler-B4GDm_iC.js +1 -0
  208. package/dist/chunks/refresh-DBVizOzg.js +1 -0
  209. package/dist/chunks/{registerProtocol-DoKqmqu2.js → registerProtocol-CsNYRZKr.js} +1 -1
  210. package/dist/chunks/reload-plugins-B7JAE3b4.js +1 -0
  211. package/dist/chunks/{remoteBridgeCore-Cddqv2WW.js → remoteBridgeCore-CFLJhsB6.js} +1 -1
  212. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +1 -0
  213. package/dist/chunks/rename-BCp2Vtqu.js +1 -0
  214. package/dist/chunks/{renderOptions-ChLwxtVu.js → renderOptions-Q5oCLFIC.js} +1 -1
  215. package/dist/chunks/resume-DVCSzKvv.js +2 -0
  216. package/dist/chunks/{ripgrep-gaT9Njwi.js → ripgrep-DvOOsDMv.js} +1 -1
  217. package/dist/chunks/ripgrep-e-iewvTf.js +1 -0
  218. package/dist/chunks/{runtimeObserver-Dbxxw4ls.js → runtimeObserver-CS_3BDNo.js} +4 -4
  219. package/dist/chunks/{runtimeObserver-CsIwinzh.js → runtimeObserver-DYUva6g-.js} +1 -1
  220. package/dist/chunks/sandbox-adapter-BFZFHplu.js +1 -0
  221. package/dist/chunks/sandbox-toggle--zNSKce_.js +1 -0
  222. package/dist/chunks/searchExtraTools-ui5y2VSE.js +1 -0
  223. package/dist/chunks/session-CO3gEqQP.js +2 -0
  224. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +1 -0
  225. package/dist/chunks/sessionObserver-Ba7um95p.js +1 -0
  226. package/dist/chunks/{sessionObserver-DoYc0ZOP.js → sessionObserver-YkRHC-Aa.js} +2 -2
  227. package/dist/chunks/sessionState-Bifmu95-.js +11 -0
  228. package/dist/chunks/sessionStorage-CedwLLQs.js +1 -0
  229. package/dist/chunks/{sessionStoragePortable-Cx6JQ5Ye.js → sessionStoragePortable-JZnGwqUM.js} +1 -1
  230. package/dist/chunks/sessionTitle-COBSgSXS.js +14 -0
  231. package/dist/chunks/sessionTracing-BrNx1k2V.js +11 -0
  232. package/dist/chunks/settings-DkDH7WQT.js +1 -0
  233. package/dist/chunks/settings-DnptdP79.js +20 -0
  234. package/dist/chunks/settingsSync-PmU7SmkU.js +1 -0
  235. package/dist/chunks/setup-BEsBuzsk.js +3 -0
  236. package/dist/chunks/shadowedRuleDetection-DEaw-X5j.js +1 -0
  237. package/dist/chunks/{shellQuote-BUVKMu_P.js → shellQuote-BYeOv3Ip.js} +1 -1
  238. package/dist/chunks/{sideQuestion-C780iYwd.js → sideQuestion-D0OKljee.js} +3 -3
  239. package/dist/chunks/sinks-BJHgxz6Y.js +1 -0
  240. package/dist/chunks/sinks-D5-yhcgU.js +2 -0
  241. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +1 -0
  242. package/dist/chunks/{skillGapStore-Dc1arohs.js → skillGapStore-N_kmvXML.js} +2 -2
  243. package/dist/chunks/{skillLifecycle-DP6mY1Kp.js → skillLifecycle-C4F5RXuh.js} +2 -2
  244. package/dist/chunks/{skillSearchPanel-CpLTImaL.js → skillSearchPanel-CftorvAM.js} +4 -4
  245. package/dist/chunks/skills-C4CTRN9o.js +1 -0
  246. package/dist/chunks/{src-CDCSSo0U2.js → src-P_wYS_NJ2.js} +1 -1
  247. package/dist/chunks/{src-CST_jFnT.js → src-r6ZFgWPx2.js} +1 -1
  248. package/dist/chunks/startupProfiler-D4FBdEQr.js +1 -0
  249. package/dist/chunks/{startupProfiler-DCn_NxMH.js → startupProfiler-L_UWZ03w.js} +3 -3
  250. package/dist/chunks/{state-Cn_m2NOf.js → state-BAGmpVBn.js} +1 -1
  251. package/dist/chunks/state-BemZdQIl.js +1 -0
  252. package/dist/chunks/state-D_lk6z-C.js +1 -0
  253. package/dist/chunks/{staticRender-BIxpgNUq.js → staticRender-DrU6eWoq.js} +1 -1
  254. package/dist/chunks/{stats-Duk7_xjQ.js → stats-IzV0_vEc.js} +1 -1
  255. package/dist/chunks/{status-peiVB_2j.js → status-CeVP_uDT.js} +1 -1
  256. package/dist/chunks/status-Dzuw3hBv.js +2 -0
  257. package/dist/chunks/statusNoticeHelpers-Bb9gxdSt.js +1 -0
  258. package/dist/chunks/{stringUtils-B6FudhoZ.js → stringUtils-C84IJ91d.js} +1 -1
  259. package/dist/chunks/subprocessEnv-CZkA9Cdp.js +1 -0
  260. package/dist/chunks/{subprocessEnv-vrwzMgKn.js → subprocessEnv-Ci8VV_bi.js} +1 -1
  261. package/dist/chunks/switcher-4KzBvuKH.js +1 -0
  262. package/dist/chunks/{switcher-BAMqSX7Z.js → switcher-CCs9xl1z.js} +1 -1
  263. package/dist/chunks/{syncCache-Zl9kZRRl.js → syncCache-CBRiRU5x.js} +1 -1
  264. package/dist/chunks/tasks-DZDhgx0w.js +1 -0
  265. package/dist/chunks/teleport-Bw0jSxe9.js +1 -0
  266. package/dist/chunks/{templateJobs-DR5fKFiO.js → templateJobs-CrNPEKkh.js} +1 -1
  267. package/dist/chunks/{terminalSetup-DgRBt-JJ.js → terminalSetup-CBqcwQll.js} +1 -1
  268. package/dist/chunks/terminalSetup-D-N8YPiQ.js +33 -0
  269. package/dist/chunks/{theme-Bz6esfST.js → theme-Dazsirbw.js} +1 -1
  270. package/dist/chunks/{tmux-DSU9tYIo.js → tmux-DewYVEBm.js} +1 -1
  271. package/dist/chunks/{toolEventObserver-BSekCkM2.js → toolEventObserver-lnHJ9fLQ.js} +1 -1
  272. package/dist/chunks/toolPool-CkXFlqsn.js +1 -0
  273. package/dist/chunks/{trustedDevice-B0x9X0fb.js → trustedDevice-CFf5yaG-.js} +1 -1
  274. package/dist/chunks/trustedDevice-CuwSv8dG.js +1 -0
  275. package/dist/chunks/{types-D7_37tP2.js → types-3j8PS-Du.js} +1 -1
  276. package/dist/chunks/{udsClient-CHoMMH28.js → udsClient-e9dIkwVA.js} +1 -1
  277. package/dist/chunks/updateCCB-BPe9_FW6.js +11 -0
  278. package/dist/chunks/{upstreamproxy-Hmq-n8fw.js → upstreamproxy-DF00RzGG.js} +1 -1
  279. package/dist/chunks/useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js +1 -0
  280. package/dist/chunks/useMainLoopModel-2-eujv0n.js +1 -0
  281. package/dist/chunks/useManagePlugins-CYBIkaB1.js +1 -0
  282. package/dist/chunks/useMergedTools-Dk5cPqLc.js +1 -0
  283. package/dist/chunks/useSearchInput-C7Y1I9P9.js +1 -0
  284. package/dist/chunks/useSettingsErrors-DAEO7AyB.js +1 -0
  285. package/dist/chunks/{userAgent-BxTG7IMk.js → userAgent-CIq27vUR.js} +1 -1
  286. package/dist/chunks/util-VO98TdOz.js +1 -0
  287. package/dist/chunks/{validatePlugin-AHl-g4ct.js → validatePlugin-Kk6pxnO2.js} +1 -1
  288. package/dist/chunks/vim-EYQn94Kx.js +1 -0
  289. package/dist/chunks/{which-CHLNJmtJ.js → which-DzFN5TNM.js} +1 -1
  290. package/dist/chunks/{windowsPaths-o62uq6LF.js → windowsPaths-BU3yQWTB.js} +1 -1
  291. package/dist/chunks/windowsPaths-DgZ3YY4a.js +1 -0
  292. package/dist/chunks/{workSecret-DG9shvG0.js → workSecret-DUqdPy44.js} +1 -1
  293. package/dist/chunks/workerRegistry-C07BcZIw.js +6 -0
  294. package/dist/chunks/worktree-dFUkhVE_.js +1 -0
  295. package/dist/cli.js +1 -1
  296. package/package.json +1 -1
  297. package/dist/chunks/AddWorkspaceDirectory-CwLtQld4.js +0 -1
  298. package/dist/chunks/App-Ba52HvYC.js +0 -1
  299. package/dist/chunks/ApproveApiKey-CEIfuUh0.js +0 -1
  300. package/dist/chunks/ApproveApiKey-D2MLQu2P.js +0 -1
  301. package/dist/chunks/BackgroundTasksDialog-IGDrkbWl.js +0 -2
  302. package/dist/chunks/BypassPermissionsModeDialog-GYhq--JR.js +0 -1
  303. package/dist/chunks/ClaudeMdExternalIncludesDialog-C-CTa-95.js +0 -1
  304. package/dist/chunks/ClaudeMdExternalIncludesDialog-Catv6BCJ.js +0 -1
  305. package/dist/chunks/ConsoleOAuthFlow-BeQXqUtX.js +0 -1
  306. package/dist/chunks/DiffDialog-AC5DSJrq.js +0 -6
  307. package/dist/chunks/Doctor-B9Rxsoy0.js +0 -1
  308. package/dist/chunks/Doctor-lhUBhEy5.js +0 -3
  309. package/dist/chunks/ExitFlow-Cu8SoQHs.js +0 -2
  310. package/dist/chunks/Grove-Bc4CofEj.js +0 -11
  311. package/dist/chunks/InvalidConfigDialog-BI13il58.js +0 -1
  312. package/dist/chunks/InvalidSettingsDialog-CtOheV1K.js +0 -1
  313. package/dist/chunks/MCPConnectionManager-ao-P3xSA.js +0 -1
  314. package/dist/chunks/MCPToolListView-dkofcJs4.js +0 -1
  315. package/dist/chunks/McpParsingWarnings-BS4JoR5l.js +0 -1
  316. package/dist/chunks/MessageSelector-B88b2ypw.js +0 -3
  317. package/dist/chunks/Messages-BPeI7lLV.js +0 -11
  318. package/dist/chunks/Onboarding-c2fQ8Io_.js +0 -1
  319. package/dist/chunks/PromptInputFooterSuggestions-D1cH9sDX.js +0 -1
  320. package/dist/chunks/PromptInputHelpMenu-DDD5WuK0.js +0 -1
  321. package/dist/chunks/QueryEngine-Cv_meCam.js +0 -1
  322. package/dist/chunks/REPL-BXhAQOXb.js +0 -139
  323. package/dist/chunks/REPL-YqjLnr3A.js +0 -1
  324. package/dist/chunks/RemoteSessionManager-CT7T8BaR.js +0 -2
  325. package/dist/chunks/ResumeConversation-CIZCjms9.js +0 -1
  326. package/dist/chunks/SearchExtraToolsTool-Dx6093yw.js +0 -1
  327. package/dist/chunks/Settings-CyUm0AtU.js +0 -2
  328. package/dist/chunks/TeleportProgress-C3qyp5zy.js +0 -1
  329. package/dist/chunks/TeleportRepoMismatchDialog-BV--nyYn.js +0 -1
  330. package/dist/chunks/TeleportResumeWrapper-Blo2cZg-.js +0 -1
  331. package/dist/chunks/ThemePicker-EQ6hPUeI.js +0 -1
  332. package/dist/chunks/WelcomeV2-Ci9VwPYh.js +0 -1
  333. package/dist/chunks/add-dir-DPQV0qml.js +0 -1
  334. package/dist/chunks/agents-DmybpgDN.js +0 -103
  335. package/dist/chunks/allErrors-BPn_2TrB.js +0 -1
  336. package/dist/chunks/analytics-CkYUHW_U.js +0 -1
  337. package/dist/chunks/ant-DjdvlLOo.js +0 -1
  338. package/dist/chunks/api-AMgj1zf_.js +0 -1
  339. package/dist/chunks/asciicast-BJNYO5sh.js +0 -4
  340. package/dist/chunks/asciicast-CH6hdK0a.js +0 -1
  341. package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
  342. package/dist/chunks/auth-CNjDn1VY.js +0 -15
  343. package/dist/chunks/auth-CZzP483s.js +0 -1
  344. package/dist/chunks/auth-DDSBm_Yj.js +0 -1
  345. package/dist/chunks/autonomy-D4xZLOdJ.js +0 -15
  346. package/dist/chunks/backgroundHousekeeping--eBgphcg.js +0 -17
  347. package/dist/chunks/backgroundHousekeeping-VV1V_Y2Z.js +0 -1
  348. package/dist/chunks/bg-BK_9J6F6.js +0 -1
  349. package/dist/chunks/branch-BYq0zpzT.js +0 -3
  350. package/dist/chunks/bridgeConfig-C82un7rJ.js +0 -1
  351. package/dist/chunks/bridgeMessaging-YqYdl6ej.js +0 -1
  352. package/dist/chunks/btw-CUV3nRrE.js +0 -1
  353. package/dist/chunks/caches-BZ59_En6.js +0 -1
  354. package/dist/chunks/caches-Cg-HtWKG.js +0 -1
  355. package/dist/chunks/client-DQXvVKND.js +0 -1
  356. package/dist/chunks/client-DkgC-mFB.js +0 -1
  357. package/dist/chunks/color-CBsNbt1s.js +0 -1
  358. package/dist/chunks/commands-qM5z_Uld.js +0 -1
  359. package/dist/chunks/compact-BclJiRJe.js +0 -2
  360. package/dist/chunks/completionCache-BMHAktkM.js +0 -1
  361. package/dist/chunks/config-CE058cvr.js +0 -3
  362. package/dist/chunks/config-D81avYye.js +0 -1
  363. package/dist/chunks/config-DpOOllGk.js +0 -1
  364. package/dist/chunks/context-noninteractive-DJb8H_hN.js +0 -1
  365. package/dist/chunks/context-sR9fJmXE.js +0 -1
  366. package/dist/chunks/conversation-D48Kt3ar.js +0 -1
  367. package/dist/chunks/conversation-fOFTa7k5.js +0 -1
  368. package/dist/chunks/createSession-CSwlW2T2.js +0 -1
  369. package/dist/chunks/crossProjectResume-lDFB2ZcY.js +0 -40
  370. package/dist/chunks/cwd-5Xr-Qka6.js +0 -1
  371. package/dist/chunks/cwd-C5ce-7WB.js +0 -1
  372. package/dist/chunks/daemon-ZtpTZWgQ.js +0 -2
  373. package/dist/chunks/datadog-BJn5ECIu.js +0 -1
  374. package/dist/chunks/detectRepository-DqQvyj_a.js +0 -1
  375. package/dist/chunks/directoryCompletion-BagQcynj.js +0 -1
  376. package/dist/chunks/doctor-BEHYm34V.js +0 -1
  377. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  378. package/dist/chunks/entry-BzL1MFQG.js +0 -14
  379. package/dist/chunks/envUtils-DSxRz_kt.js +0 -1
  380. package/dist/chunks/esm-BLPbfHQd.js +0 -1
  381. package/dist/chunks/eventLoopStallDetector-Cg_RXU1q.js +0 -1
  382. package/dist/chunks/exit-DE2YiAhQ.js +0 -1
  383. package/dist/chunks/extraUsage-Dw7AXiH7.js +0 -1
  384. package/dist/chunks/extractMemories-DxTUMiv3.js +0 -1
  385. package/dist/chunks/fast-CHmMkIpE.js +0 -1
  386. package/dist/chunks/fast-uQASHWqR.js +0 -1
  387. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  388. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  389. package/dist/chunks/fileSuggestions-Dyu2kQtE.js +0 -3
  390. package/dist/chunks/firstPartyEventLogger-D5ohKbIe.js +0 -5
  391. package/dist/chunks/firstPartyEventLogger-LsNY6yOt.js +0 -1
  392. package/dist/chunks/flushGate-Cnsu4HET.js +0 -1
  393. package/dist/chunks/gemini-Cudre91e.js +0 -1
  394. package/dist/chunks/generateRecap-CiFxXlmH.js +0 -1
  395. package/dist/chunks/generateSessionName-DitoBxJT.js +0 -1
  396. package/dist/chunks/git-D6dOU2mT.js +0 -1
  397. package/dist/chunks/githubRepoPathMapping-DGr0kJ8D.js +0 -1
  398. package/dist/chunks/goal-DuUayfDg.js +0 -3
  399. package/dist/chunks/grok-tRbmZzEh.js +0 -1
  400. package/dist/chunks/grove-Cv19v6Sv.js +0 -7
  401. package/dist/chunks/help-DkqxbFDM.js +0 -1
  402. package/dist/chunks/hooks-CsP42iOp.js +0 -1
  403. package/dist/chunks/initReplBridge-DdsSWVqN.js +0 -1
  404. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  405. package/dist/chunks/keybindings-DZU3vwo3.js +0 -2
  406. package/dist/chunks/language-DHhXLb_Y.js +0 -1
  407. package/dist/chunks/language-s-dLbdVz.js +0 -1
  408. package/dist/chunks/launchLocalMemory-twLxpPvg.js +0 -3
  409. package/dist/chunks/launchOnboarding-BWz2XSb9.js +0 -8
  410. package/dist/chunks/lib-rQZENxQg.js +0 -8
  411. package/dist/chunks/loadAgentsDir-CMNFLt7R.js +0 -1
  412. package/dist/chunks/loadPluginHooks-BPnxcgrL.js +0 -1
  413. package/dist/chunks/localSearch-DzQODFap.js +0 -1
  414. package/dist/chunks/log-CZ0zYP_c.js +0 -1
  415. package/dist/chunks/logoV2Utils-CGUJ-5gY.js +0 -1
  416. package/dist/chunks/main-D4Uk-WUs.js +0 -862
  417. package/dist/chunks/managedEnv-DLVRBaA9.js +0 -1
  418. package/dist/chunks/mcp-BMVdGknC.js +0 -1
  419. package/dist/chunks/mcp-COS5RJFS.js +0 -6
  420. package/dist/chunks/mcp-tGsOW1GN.js +0 -2
  421. package/dist/chunks/memory-DR6poqeH.js +0 -1
  422. package/dist/chunks/mode-QV-NW1Wd.js +0 -2
  423. package/dist/chunks/model-BF_4ebyl.js +0 -1
  424. package/dist/chunks/model-BNU_ulDJ.js +0 -1
  425. package/dist/chunks/model-CwO-g1RW.js +0 -1
  426. package/dist/chunks/nativeInstaller-B-lNJjM-.js +0 -1
  427. package/dist/chunks/oauth-BqJqV-2M.js +0 -1
  428. package/dist/chunks/oauth-C8X_p8Gc.js +0 -1
  429. package/dist/chunks/omit-DZCEXri5.js +0 -1
  430. package/dist/chunks/onChangeAppState-BmfM5g-D.js +0 -1
  431. package/dist/chunks/p-map-B1EeBuI8.js +0 -1
  432. package/dist/chunks/p-map-HKDr3iDo.js +0 -1
  433. package/dist/chunks/panelCall-SbffM7G4.js +0 -1
  434. package/dist/chunks/parser-DrBC8nWp.js +0 -1
  435. package/dist/chunks/partition-DKuAFJkc.js +0 -1
  436. package/dist/chunks/path-Cv9QMBAX.js +0 -1
  437. package/dist/chunks/permissions-ey-bfanE.js +0 -3
  438. package/dist/chunks/pidLock-DJnS_38v.js +0 -3
  439. package/dist/chunks/pipeTransport-DVOKR4c_.js +0 -1
  440. package/dist/chunks/plan-Brg9XnRr.js +0 -1
  441. package/dist/chunks/plugin-CRwa39Y1.js +0 -17
  442. package/dist/chunks/pluginAutoupdate-D0LIP7cy.js +0 -1
  443. package/dist/chunks/pluginCliCommands-BJM5Bdpf.js +0 -1
  444. package/dist/chunks/pluginOperations-C7p_Qr2r.js +0 -2
  445. package/dist/chunks/pluginStartupCheck-C0HqhG6D.js +0 -1
  446. package/dist/chunks/plugins-DUKNjLq6.js +0 -4
  447. package/dist/chunks/poorMode-CejPNCp-.js +0 -1
  448. package/dist/chunks/print-gyTOCJzk.js +0 -23
  449. package/dist/chunks/processBashCommand-Cze9vCm6.js +0 -1
  450. package/dist/chunks/processSlashCommand-BRajh1v7.js +0 -5
  451. package/dist/chunks/prompt-B7joRiqj.js +0 -139
  452. package/dist/chunks/prompt-DqSMh2x9.js +0 -1
  453. package/dist/chunks/prompt-Eysh8Et_.js +0 -1
  454. package/dist/chunks/promptEditor-R_acDAgI.js +0 -4
  455. package/dist/chunks/reconciler-BfkO6X2X.js +0 -4
  456. package/dist/chunks/refresh-C1X3sptR.js +0 -1
  457. package/dist/chunks/reload-plugins-C0osFcNh.js +0 -1
  458. package/dist/chunks/remoteManagedSettings-B1mnRDmA.js +0 -1
  459. package/dist/chunks/rename-B3tf-YiD.js +0 -1
  460. package/dist/chunks/replBridgeHandle-CNwNIijW.js +0 -1
  461. package/dist/chunks/resume-Be1G_GBL.js +0 -2
  462. package/dist/chunks/ripgrep-C2PhTJDh.js +0 -1
  463. package/dist/chunks/rollback-BPWRKlIZ.js +0 -11
  464. package/dist/chunks/sandbox-adapter-C6GBuJPB.js +0 -1
  465. package/dist/chunks/sandbox-toggle-jEySONTW.js +0 -1
  466. package/dist/chunks/sdkHeapDumpMonitor-WdXUV7DV.js +0 -1
  467. package/dist/chunks/searchExtraTools-C_UTryh_.js +0 -1
  468. package/dist/chunks/session-DDI1Eb2x.js +0 -2
  469. package/dist/chunks/sessionDataUploader-CaCjwsA2.js +0 -1
  470. package/dist/chunks/sessionFileAccessHooks-DfJ7Htfl.js +0 -1
  471. package/dist/chunks/sessionMemory-CQBxPkTQ.js +0 -1
  472. package/dist/chunks/sessionMemory-s0ALUHvc.js +0 -1
  473. package/dist/chunks/sessionMemoryUtils-xt7dTHGC.js +0 -1
  474. package/dist/chunks/sessionObserver-C2sYqWL3.js +0 -1
  475. package/dist/chunks/sessionState-CjNY991n.js +0 -11
  476. package/dist/chunks/sessionStorage-DqsY-7pi.js +0 -1
  477. package/dist/chunks/sessionTitle-B0OYf5nM.js +0 -14
  478. package/dist/chunks/sessionTracing-CwsXt_uA.js +0 -11
  479. package/dist/chunks/settings-BWtOA9A7.js +0 -1
  480. package/dist/chunks/settings-hQDLwPVj.js +0 -20
  481. package/dist/chunks/settingsSync-DdFagwHV.js +0 -1
  482. package/dist/chunks/setup-DzC22EkN.js +0 -3
  483. package/dist/chunks/shadowedRuleDetection-C86PTj1m.js +0 -1
  484. package/dist/chunks/sinks-5G_xhc1Q.js +0 -1
  485. package/dist/chunks/sinks-Cftq7Es0.js +0 -2
  486. package/dist/chunks/skillChangeDetector-plLveEbf.js +0 -1
  487. package/dist/chunks/skills-zGYaYfFV.js +0 -1
  488. package/dist/chunks/startupProfiler-JbpAkfNE.js +0 -1
  489. package/dist/chunks/state-C2OSZkV1.js +0 -1
  490. package/dist/chunks/state-DU9lRJ9x.js +0 -1
  491. package/dist/chunks/status-CFw-FpZM.js +0 -2
  492. package/dist/chunks/statusNoticeHelpers-B5U5c9PE.js +0 -1
  493. package/dist/chunks/subprocessEnv-BSQSomcK.js +0 -1
  494. package/dist/chunks/switcher-hgBgVzLb.js +0 -1
  495. package/dist/chunks/tasks-BxpyRhmD.js +0 -1
  496. package/dist/chunks/teleport-CwxeD5vL.js +0 -1
  497. package/dist/chunks/terminalSetup-DlaFWI81.js +0 -33
  498. package/dist/chunks/toolPool-B7SIoDw5.js +0 -1
  499. package/dist/chunks/trustedDevice-CjHQtVkO.js +0 -1
  500. package/dist/chunks/up-B8wBSpLg.js +0 -12
  501. package/dist/chunks/updateCCB-D_kGQKPT.js +0 -11
  502. package/dist/chunks/useExitOnCtrlCDWithKeybindings-Cce612uS.js +0 -1
  503. package/dist/chunks/useMainLoopModel-BICP6_Fi.js +0 -1
  504. package/dist/chunks/useManagePlugins-DtbY_vPL.js +0 -1
  505. package/dist/chunks/useMergedTools-Ckx2IEhF.js +0 -1
  506. package/dist/chunks/useSearchInput-BAgljZUl.js +0 -1
  507. package/dist/chunks/useSettingsErrors-CAJR_wpd.js +0 -1
  508. package/dist/chunks/util-DDtmyq_r.js +0 -1
  509. package/dist/chunks/vim-kg-mRVbu.js +0 -1
  510. package/dist/chunks/windowsPaths-Pmx8LDR6.js +0 -1
  511. package/dist/chunks/workerRegistry-C7H_lsQX.js +0 -6
  512. package/dist/chunks/worktree-O2p-mJdF.js +0 -1
@@ -1,139 +0,0 @@
1
- import{a as e,n as t,o as n,r}from"./rolldown-runtime-DaDcL9Zw.js";import{c as i,l as a,n as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{n as u,t as d}from"./figures-5ThXQEtq.js";import{t as f}from"./semver-DQo45qGo.js";import{n as p,t as m}from"./axios-DaWTGg7G.js";import{C as h,D as g,Ft as _,Gr as v,Gt as y,H as b,I as x,Kr as S,Kt as C,Lt as w,P as T,Pn as E,Rn as D,T as O,Tt as k,Vn as ee,Wt as A,Xn as j,Xt as M,Y as N,Yt as te,Z as P,Zn as F,_n as ne,bn as re,ct as I,di as L,dr as ie,et as R,fi as z,ft as ae,hn as oe,ir as se,j as ce,lr as le,lt as ue,ot as de,p as fe,q as pe,qr as me,t as B,tr as he,ui as ge,vn as V,x as _e,y as ve,yn as ye,yt as be}from"./src-CDCSSo0U2.js";import{t as xe}from"./jsx-runtime-Bb4Xn-E0.js";import{A as Se,C as Ce,S as we,a as Te,b as Ee,l as De,r as Oe,w as ke}from"./external-CEp-aPkt.js";import{n as Ae,r as je,t as Me}from"./lazySchema-B4D4qJVE.js";import{$t as Ne,At as Pe,B as Fe,Bn as Ie,Bt as Le,D as Re,En as ze,G as Be,Ht as Ve,Jt as He,Kn as Ue,Lt as We,Mt as Ge,Nt as Ke,Ot as qe,Rt as Je,Ut as Ye,V as Xe,Vt as Ze,X as Qe,Xt as $e,_r as et,at as tt,b as nt,br as rt,dn as it,en as at,fn as ot,ft as st,gr as ct,hr as lt,jt as ut,kt as dt,ln as ft,mt as pt,qn as mt,tt as ht,un as gt,vt as _t,wt as vt,yn as yt,yr as bt,z as xt,zt as St}from"./state-C2OSZkV1.js";import{$_ as Ct,$b as wt,$i as Tt,$l as Et,$o as Dt,$p as Ot,$s as kt,$x as At,A_ as jt,Aa as Mt,Ab as Nt,Ac as Pt,Ad as Ft,Ah as It,Am as Lt,Ap as Rt,Au as zt,Av as Bt,Ay as Vt,BT as Ht,B_ as Ut,Ba as Wt,Bb as Gt,Bc as Kt,Bm as qt,Bn as Jt,Bo as Yt,Bp as Xt,Bs as Zt,Bu as Qt,By as $t,C as en,Cb as tn,Ci as nn,Cl as rn,Co as an,Cp as on,Cr as sn,Ct as cn,Cx as ln,Cy as un,D_ as dn,Da as fn,Db as pn,Dd as mn,Dh as hn,Dm as gn,Do as _n,Dp as vn,Dw as yn,Dy as bn,E as xn,ED as Sn,E_ as Cn,Ea as wn,Eb as Tn,Ef as H,Eh as En,El as Dn,Em as On,Ep as kn,Er as An,Et as jn,Eu as Mn,Ey as Nn,F_ as Pn,Fa as Fn,Fb as In,Fc as Ln,Fd as Rn,Fh as zn,Fp as Bn,Ft as Vn,Fv as Hn,Fw as Un,Fx as Wn,Fy as Gn,G as Kn,GS as qn,Ga as Jn,Gb as Yn,Gm as Xn,Gp as Zn,Gs as Qn,Gt as $n,Gu as er,HS as tr,H_ as nr,Hc as rr,Hi as ir,Hm as ar,Hs as or,Hu as sr,Hw as cr,Hx as lr,Hy as ur,I as dr,IE as fr,Ib as pr,Id as mr,Ii as hr,Im as gr,Ip as _r,Ir as vr,Iw as yr,Ix as br,Iy as xr,J as Sr,JC as Cr,J_ as wr,Jb as Tr,Jd as U,Jg as Er,Jh as Dr,Ji as Or,Jl as W,Jm as kr,Jn as Ar,Jp as jr,Jr as Mr,Ju as Nr,Jv as Pr,KS as Fr,K_ as Ir,Kb as Lr,Kh as Rr,Kl as zr,Km as Br,Kp as Vr,Ks as Hr,Ku as Ur,LE as Wr,LS as Gr,LT as Kr,L_ as qr,La as Jr,Lb as Yr,Lc as Xr,Lf as Zr,Lm as Qr,Ln as $r,Lp as ei,Lv as ti,Lw as ni,Lx as ri,M as ii,M_ as ai,Mc as oi,Md as si,Mm as ci,Mp as li,Mr as ui,My as di,N as fi,N_ as pi,Nc as mi,Nm as hi,No as gi,Np as _i,Nw as vi,OE as yi,O_ as bi,Ob as xi,Od as Si,Oh as Ci,Om as wi,Op as Ti,Ov as Ei,P as Di,P_ as Oi,Pa as ki,Pb as Ai,Pn as ji,Po as Mi,Pr as Ni,Pw as Pi,Px as Fi,Py as Ii,Q as Li,QE as Ri,QT as zi,Q_ as Bi,Qb as Vi,Qd as Hi,Qn as Ui,Qo as Wi,Qp as Gi,Qx as Ki,RS as qi,RT as Ji,R_ as Yi,Rb as Xi,Rc as Zi,Rf as Qi,Rm as $i,Rp as ea,Rw as ta,SE as na,Sl as ra,Sx as ia,Sy as aa,TD as oa,TE as sa,T_ as ca,Tb as la,Tf as ua,Tl as da,Tm as fa,Tp as pa,Tu as ma,Tv as ha,Tw as ga,Ty as _a,US as va,UT as ya,U_ as ba,Ua as xa,Ub as Sa,Uc as Ca,Ud as wa,Ui as Ta,Um as Ea,Up as Da,Us as Oa,Ut as ka,Uu as Aa,Uy as ja,VT as Ma,V_ as Na,Va as Pa,Vb as Fa,Vc as Ia,Vm as La,Vp as Ra,W as za,WT as Ba,W_ as Va,Wa as Ha,Wb as Ua,Wc as Wa,Wd as Ga,Wi as Ka,Wm as qa,Wo as Ja,Wp as Ya,Wu as Xa,Ww as Za,Wx as Qa,Wy as $a,X as eo,XE as to,XT as no,X_ as ro,Xa as io,Xb as ao,Xd as oo,Xh as so,Xl as co,Xo as lo,Xv as uo,Xx as fo,YC as po,Y_ as mo,Yb as ho,Yg as go,Yh as _o,Yi as vo,Yl as yo,Yo as bo,Yp as xo,Yv as So,Z as Co,ZE as wo,Z_ as To,Za as Eo,Zd as Do,Zi as Oo,Zo as ko,Zt as Ao,Zv as jo,Zx as Mo,_S as No,_b as Po,_c as Fo,_d as Io,_g as Lo,_l as Ro,_m as zo,_p as Bo,_v as G,_w as Vo,_x as Ho,_y as Uo,aE as Wo,a_ as Go,ac as Ko,ad as qo,ag as Jo,ah as Yo,al as Xo,am as Zo,au as Qo,ax as $o,ay as es,b_ as ts,ba as ns,bf as rs,bs as is,bv as as,bx as os,cS as ss,c_ as cs,cc as ls,cd as us,cl as ds,cm as fs,co as ps,cs as ms,cv as hs,cx as gs,cy as _s,dS as vs,d_ as ys,dh as bs,dl as xs,dm as Ss,dn as Cs,ds as ws,dv as Ts,dx as Es,dy as Ds,eE as Os,eS as ks,ea as As,ec as js,ei as Ms,en as Ns,eo as Ps,es as Fs,et as Is,eu as Ls,ev as Rs,ex as zs,ey as Bs,fS as Vs,f_ as Hs,fh as Us,fi as Ws,fm as Gs,fp as Ks,fs as qs,fv as Js,fw as Ys,fy as Xs,gS as Zs,gc as Qs,gd as $s,gl as ec,gm as tc,gp as nc,gv as rc,gy as ic,hS as ac,hb as oc,hd as sc,hf as cc,hi as lc,hl as uc,hm as dc,ho as fc,hp as pc,hv as mc,iD as hc,iE as gc,i_ as _c,ic as vc,id as yc,ig as bc,im as xc,it as Sc,iu as Cc,ix as wc,iy as Tc,jd as Ec,jm as Dc,jo as Oc,jp as kc,jr as Ac,jv as jc,jy as Mc,k_ as Nc,ka as Pc,kb as Fc,kc as Ic,kd as Lc,kh as Rc,km as zc,kp as Bc,ku as Vc,kv as Hc,kw as Uc,l_ as Wc,la as Gc,ld as Kc,li as qc,lm as Jc,lo as Yc,lr as Xc,lt as Zc,lv as Qc,lx as $c,ly as el,ma as tl,md as nl,mf as rl,mg as il,ml as al,mm as ol,mp as sl,mr as cl,mv as ll,nD as ul,nS as dl,n_ as fl,nc as pl,nd as ml,ng as hl,np as gl,nr as _l,ns as vl,nv as yl,nx as bl,ny as xl,oS as Sl,o_ as Cl,oc as wl,od as Tl,og as El,ol as Dl,om as Ol,op as kl,or as Al,os as jl,ou as Ml,ox as Nl,oy as Pl,p_ as Fl,pb as Il,pd as Ll,pg as Rl,ph as zl,pi as Bl,po as Vl,pp as Hl,pv as Ul,pw as Wl,px as Gl,py as Kl,q as ql,q_ as Jl,qb as Yl,qg as Xl,qh as Zl,ql as Ql,qm as $l,qp as eu,qu as tu,rD as nu,rE as ru,rS as iu,rc as au,rd as ou,rg as su,rh as cu,rm as lu,ru as uu,rv as du,rx as fu,sS as pu,s_ as mu,sc as hu,sd as gu,si as _u,sl as vu,sm as yu,sp as bu,sv as xu,sy as Su,tE as Cu,ta as wu,tb as Tu,tc as Eu,td as Du,tg as Ou,to as ku,tp as Au,ts as ju,tt as Mu,tv as Nu,tx as Pu,uS as Fu,u_ as Iu,ua as Lu,uc as Ru,uh as zu,um as Bu,up as Vu,ur as Hu,ut as Uu,uv as Wu,ux as Gu,uy as Ku,vS as qu,v_ as Ju,va as Yu,vb as Xu,vd as Zu,vg as Qu,vi as $u,vv as K,vw as ed,vy as td,wi as nd,wm as rd,wp as id,wv as ad,ww as od,wy as sd,xS as cd,xa as ld,xl as ud,xo as dd,xw as fd,xx as pd,xy as md,yS as hd,y_ as gd,ya as _d,yc as vd,yd,yf as bd,yn as xd,ys as Sd,yv as Cd,yx as wd,zT as Td,zb as Ed,zc as Dd,zi as Od,zm as kd,zn as Ad,zp as jd,zw as Md}from"./loadAgentsDir-ByO8eJqU.js";import{n as Nd,t as Pd}from"./cwd-C5ce-7WB.js";import{C as Fd,D as Id,F as Ld,G as Rd,Q as zd,S as Bd,V as Vd,W as Hd,_ as Ud,a as q,d as Wd,l as J,nt as Gd,p as Kd,rt as qd,w as Jd,z as Yd}from"./debug-RZ4NuXyS.js";import{At as Xd,Cn as Zd,Gt as Qd,H as $d,Ht as ef,In as tf,It as nf,Jn as rf,Jt as af,Kn as of,Ln as sf,Lt as cf,Mt as lf,On as uf,Rn as df,Rt as ff,Ut as pf,Vt as mf,an as hf,bn as gf,c as _f,cn as vf,ct as yf,f as bf,g as xf,jt as Sf,n as Cf,qn as wf,qt as Tf,vt as Ef,x as Df,z as Of}from"./settings-hQDLwPVj.js";import{P as kf,b as Af,c as jf,g as Mf,l as Nf,n as Pf}from"./config-CE058cvr.js";import{O as Ff,a as If,i as Lf,k as Rf,l as zf,m as Bf}from"./git-BerW9bId.js";import{r as Vf,t as Hf}from"./execFileNoThrow-CCX-JY8h.js";import{B as Uf,J as Wf,L as Gf,N as Kf,R as qf,U as Jf,k as Yf,o as Xf,s as Y}from"./log-CZ0zYP_c.js";import{n as Zf,t as Qf}from"./memoize-B8hfb1JN.js";import{n as $f,t as ep}from"./which-CHLNJmtJ.js";import{i as tp,o as np}from"./platform-DCXXznJg.js";import{i as rp,n as ip,r as ap}from"./path-Cv9QMBAX.js";import{s as op,u as sp}from"./types-D7_37tP2.js";import{n as X,r as Z}from"./analytics-CkYUHW_U.js";import{c as cp,n as lp,s as up,t as dp}from"./intl-cKc-V6Mq.js";import{d as fp,f as pp,u as mp,v as hp,w as gp,y as _p}from"./startupProfiler-DCn_NxMH.js";import{n as vp,t as yp}from"./bundledMode--fG1S62b.js";import{a as bp,d as xp,l as Sp,o as Cp,r as wp,s as Tp}from"./stringUtils-B6FudhoZ.js";import{$n as Ep,$r as Dp,At as Op,Bn as kp,Bt as Ap,Ct as jp,D as Mp,Et as Np,Ft as Pp,Gt as Fp,Hr as Ip,Ht as Lp,Kn as Rp,Qr as zp,St as Bp,T as Vp,Vn as Hp,Wr as Up,X as Wp,_ as Gp,_i as Kp,_r as qp,at as Jp,b as Yp,ct as Xp,ei as Zp,et as Qp,gi as $p,h as em,it as tm,m as nm,mt as rm,nr as im,nt as am,ot as om,rt as sm,st as cm,tr as lm,tt as um,u as dm,vr as fm,x as pm}from"./model-CwO-g1RW.js";import{At as mm,Mt as hm,Nt as gm,cn as _m,dn as vm,gn as ym,hn as bm,jt as xm,rt as Sm,sn as Cm,tn as wm,un as Tm,vt as Em,xn as Dm,yn as Om,yt as km}from"./prompt-B7joRiqj.js";import{B as Am,C as jm,D as Mm,E as Nm,N as Pm,O as Fm,T as Im,d as Lm,gt as Rm,j as zm,k as Bm,n as Vm,r as Hm,w as Um,z as Wm}from"./sessionState-CjNY991n.js";import{et as Gm,rt as Km}from"./esm-BLPbfHQd.js";import{a as qm,i as Jm,r as Ym}from"./shellQuote-BUVKMu_P.js";import{a as Xm}from"./ripgrep-gaT9Njwi.js";import{i as Zm,n as Qm,r as $m}from"./parser-dbHRgXb8.js";import{T as eh,c as th,r as nh,w as rh}from"./sessionTracing-CwsXt_uA.js";import{n as ih,t as ah}from"./poorMode-CYXmr_mU.js";import{o as oh,u as sh}from"./api-CF5IVtj0.js";import{f as ch,m as lh,n as uh}from"./firstPartyEventLogger-D5ohKbIe.js";import{i as dh,m as fh,n as ph,p as mh}from"./terminalSetup-DlaFWI81.js";import{c as hh}from"./switcher-BAMqSX7Z.js";import{n as gh,t as _h}from"./mappers-CHRFic5q.js";import{n as vh,r as yh}from"./sessionTitle-B0OYf5nM.js";import{t as bh}from"./bridgeMessaging-YqYdl6ej.js";import{C as xh,S as Sh,d as Ch,l as wh}from"./pidLock-DJnS_38v.js";import{n as Th,t as Eh}from"./nativeInstaller-B-lNJjM-.js";import{r as Dh,t as Oh}from"./pipeTransport-DVOKR4c_.js";import{t as kh}from"./useManagePlugins-DtbY_vPL.js";import{n as Ah,t as jh}from"./MCPConnectionManager-ao-P3xSA.js";import{n as Mh,t as Nh}from"./reconciler-BfkO6X2X.js";import{n as Ph,t as Fh}from"./toolPool-B7SIoDw5.js";import{a as Ih,c as Lh,i as Rh,r as zh,t as Bh}from"./MessageSelector-B88b2ypw.js";import{n as Vh,t as Hh}from"./useExitOnCtrlCDWithKeybindings-Cce612uS.js";import{n as Uh,t as Wh}from"./sideQuestion-C780iYwd.js";import{a as Gh,n as Kh,o as qh,r as Jh,s as Yh,t as Xh}from"./skillChangeDetector-plLveEbf.js";import{n as Zh,t as Qh}from"./refresh-C1X3sptR.js";import{i as $h,n as eg,r as tg,t as ng}from"./directoryCompletion-BagQcynj.js";import{r as rg,t as ig}from"./PromptInputFooterSuggestions-D1cH9sDX.js";import{n as ag,t as og}from"./useMergedTools-Ckx2IEhF.js";import{a as sg,i as cg,n as lg,o as ug,r as dg,t as fg}from"./promptEditor-R_acDAgI.js";import{n as pg,t as mg}from"./useMainLoopModel-BICP6_Fi.js";import{a as hg,i as gg,o as _g,r as vg,s as yg,t as bg}from"./fileSuggestions-Dyu2kQtE.js";import{n as xg}from"./replBridgeHandle-CNwNIijW.js";import{i as Sg,n as Cg,r as wg,t as Tg}from"./extraUsage-Dw7AXiH7.js";import{n as Eg,t as Dg}from"./useSearchInput-BAgljZUl.js";import{n as Og,t as kg}from"./staticRender-BIxpgNUq.js";import{n as Ag,t as jg}from"./useSettingsErrors-CAJR_wpd.js";import{n as Mg,t as Ng}from"./shadowedRuleDetection-C86PTj1m.js";import{n as Pg,t as Fg}from"./ExitFlow-Cu8SoQHs.js";import{a as Ig,i as Lg,r as Rg,t as zg}from"./fast-CHmMkIpE.js";import{i as Bg,n as Vg,r as Hg,t as Ug}from"./PermissionDialog-0ya1CU5k.js";import{a as Wg,i as Gg,n as Kg,r as qg,t as Jg}from"./PromptInputHelpMenu-DDD5WuK0.js";import{n as Yg,r as Xg}from"./autoModeDenials-BxNzGJdR.js";import{n as Zg,r as Qg}from"./pluginAutoupdate-D0LIP7cy.js";import{n as $g,t as e_}from"./generateSessionName-DitoBxJT.js";import{a as t_,c as n_,d as r_,i as i_,l as a_,n as o_,o as s_,r as c_,s as l_,t as u_,u as d_}from"./Messages-BPeI7lLV.js";import{t as f_}from"./lib-BlVGipXx.js";import{a as p_,i as m_,n as h_,o as g_,r as __,t as v_}from"./BackgroundTasksDialog-IGDrkbWl.js";import{n as y_}from"./fpsMetrics-Cf_hdtiJ.js";import{t as b_}from"./earlyInput-BTC_Wucv.js";import{a as x_,i as S_,o as C_,r as w_,s as T_,t as E_}from"./RemoteSessionManager-CT7T8BaR.js";import{n as D_,t as O_}from"./backgroundHousekeeping--eBgphcg.js";import{n as k_}from"./language-s-dLbdVz.js";import{homedir as A_,tmpdir as j_}from"os";import*as M_ from"path";import{basename as N_,dirname as P_,extname as F_,join as I_,relative as L_,sep as R_}from"path";import{dirname as z_,join as B_}from"node:path";import{watch as V_}from"fs";import{createHash as H_}from"node:crypto";import{randomUUID as U_}from"crypto";import{readFile as W_,readdir as G_,stat as K_,writeFile as q_}from"fs/promises";import{spawn as J_,spawnSync as Y_}from"child_process";import{mkdir as X_,readFile as Z_,rename as Q_,writeFile as $_}from"node:fs/promises";s(),c();var ev=f();L(),V(),u(),B(),je(),rt(),Ne(),Nd(),Gd(),Rd(),Yd(),Bd(),Kd(),q(),Ff(),Wf(),Xf(),Vf(),Qf(),ep(),Bf(),np(),rp(),wf(),sf(),X(),Zd(),op(),up(),_p(),vf(),Me(),yp(),af(),pf(),Sf(),Ef(),Of(),Cp(),xf(),kf(),$p(),Dm(),Mf(),ym(),vm(),Zp(),Up(),fm(),im(),Rp(),Ap(),Qp(),Gp(),wm(),Gm(),hc(),wo(),fr(),Xm(),sa(),Wo(),gm(),Cu(),xm(),ya(),Am(),Pi(),fd(),Vo(),po(),va(),qi(),hd(),pu(),Mo(),Qa(),ri(),Fi(),ia(),Es(),Nl(),bl(),Ua(),Pm(),pn(),tn(),Po(),Tu(),km(),Sm(),$a(),$t(),xr(),Ym(),bn(),_a(),md(),td(),$m(),Ds(),_s(),So(),Hn(),jc(),Ei(),ad(),ba(),Pn(),Nc(),bi(),gd(),Fl(),go(),jm(),Lo(),Rl(),Jo(),rh(),Ou(),_o(),Zl(),zn(),Rc(),ch(),uh(),kr(),ol(),Xt(),id(),Ec(),yd(),$s(),nl(),Kc(),gu(),yc(),ou(),Du(),Ur(),zt(),Mn(),Cc(),Ls(),yo(),Ql(),ra(),uc(),th(),Xo(),Ca(),oi(),Ic(),Fo(),Ru(),wl(),kt(),Qn(),Oa(),Sd(),qs(),ju(),Yt(),gi(),_n(),dd(),Ps(),Lu(),wu(),vo(),Ac(),$r(),xd(),Is(),Co(),ql(),Kn(),en(),Dg(),Bg(),Vg();var Q=n(z(),1);S(),o_(),ni(),cr(),G(),kg();var $=xe();function tv({children:e}){let{bindings:t}=Za(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(C,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function nv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function rv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>Og((0,$.jsx)(rc,{children:(0,$.jsx)(tv,{children:(0,$.jsx)(u_,{messages:e,tools:t,commands:[],verbose:i,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:`export`,screen:`prompt`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:n})})}),r),c=a;for(let t of e)c+=nv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(me(t).trim()===``)break;await n(t),o?.(e+a)}}async function iv(e,t=[],n){let r=[];return await rv(e,t,e=>void r.push(me(e)),{columns:n}),r.join(``)}Un(),Uc(),ll(),Wu(),Qc(),Hi(),oo(),sg(),ea();function av({onDone:e}){return(0,$.jsxs)(ve,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(T,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(w,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(jd,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),ea();function ov({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ve,{title:`You've been away ${sv(e)} and this conversation is ${hp(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(x,{flexDirection:`column`,children:(0,$.jsx)(T,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(jd,{options:[{value:`continue`,label:`Continue this conversation`},{value:`clear`,label:`Send message as a new conversation`},{value:`never`,label:`Don't ask me again`}],onChange:e=>n(e)})]})}function sv(e){if(e<1)return`< 1m`;if(e<60)return`${Math.floor(e)}m`;let t=Math.floor(e/60),n=Math.floor(e%60);return n===0?`${t}h`:`${t}h ${n}m`}qa();async function cv(e,t){let n=jf().preferredNotifChannel;await ka(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await uv(n,e,t),term:Qd.terminal})}var lv=`Work Mate`;async function uv(e,t,n){let r=t.title||lv;try{switch(e){case`auto`:return dv(t,n);case`iterm2`:return n.notifyITerm2(t),`iterm2`;case`iterm2_with_bell`:return n.notifyITerm2(t),n.notifyBell(),`iterm2_with_bell`;case`kitty`:return n.notifyKitty({...t,title:r,id:fv()}),`kitty`;case`ghostty`:return n.notifyGhostty({...t,title:r}),`ghostty`;case`terminal_bell`:return n.notifyBell(),`terminal_bell`;case`notifications_disabled`:return`disabled`;default:return`none`}}catch{return`error`}}async function dv(e,t){let n=e.title||lv;switch(Qd.terminal){case`Apple_Terminal`:return await pv()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:fv()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function fv(){return Math.floor(Math.random()*1e4)}async function pv(){try{if(Qd.terminal!==`Apple_Terminal`)return!1;let e=(await Hf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Hf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return Y(e),!1}}var mv=300,hv=240*1e3,gv=null,_v=null,vv=0,yv=!1;function bv(){vv++,vv===1&&(Tv(),Cv())}function xv(){vv>0&&vv--,vv===0&&(wv(),Ev())}function Sv(){vv=0,wv(),Ev()}function Cv(){process.platform===`darwin`&&_v===null&&(_v=setInterval(()=>{vv>0&&(J(`Restarting caffeinate to maintain sleep prevention`),Ev(),Tv())},hv),_v.unref())}function wv(){_v!==null&&(clearInterval(_v),_v=null)}function Tv(){if(process.platform===`darwin`&&gv===null){yv||(yv=!0,qd(async()=>{Sv()}));try{gv=J_(`caffeinate`,[`-i`,`-t`,String(mv)],{stdio:`ignore`}),gv.unref();let e=gv;gv.on(`error`,t=>{J(`caffeinate spawn error: ${t.message}`),gv===e&&(gv=null)}),gv.on(`exit`,()=>{gv===e&&(gv=null)}),J(`Started caffeinate to prevent sleep`)}catch{gv=null}}}function Ev(){if(gv!==null){let e=gv;gv=null;try{e.kill(`SIGKILL`),J(`Stopped caffeinate, allowing sleep`)}catch{}}}var Dv=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,bt()),l(this,`subscribe`,this._changed.subscribe),l(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function Ov(e,t=!1){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(void 0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let o=e[0]?.uuid,s=n.current,c=i.current===void 0,l=o!==void 0&&!c&&o===i.current&&s<=e.length,u=o!==void 0&&!c&&o===i.current&&s>e.length,d=l?s:0;if(d===e.length)return;let f=d===0?e:e.slice(d),p=l?r.current:void 0,m=++a.current;if(_u(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=Ui(f,e).findLast(ui);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}ei(),xg(),B(),G(),q();function kv(e,t,n,r,i){(0,Q.useRef)(null),(0,Q.useRef)(void 0),(0,Q.useRef)(0),(0,Q.useRef)(!1),(0,Q.useRef)(!1),(0,Q.useRef)(new Set),(0,Q.useRef)(void 0),(0,Q.useRef)(0);let a=as(),o=(0,Q.useRef)(r);o.current=r;let s=(0,Q.useRef)(i);s.current=i;let c=(0,Q.useRef)(e);c.current=e,Cd();let{addNotification:l}=Xn();return K(e=>e.replBridgeEnabled),K(e=>e.replBridgeConnected),K(e=>e.replBridgeSessionActive),K(e=>e.replBridgeOutboundOnly),K(e=>e.replBridgeInitialName),(0,Q.useEffect)(()=>{},[!1,!1,a,t,l]),(0,Q.useEffect)(()=>{},[e,!1]),(0,Q.useEffect)(()=>{},[!1,!1]),{sendBridgeResult:(0,Q.useCallback)(()=>{},[!1])}}kc(),Bc(),pa(),sl(),Hl(),Hh(),zh(),X();var Av=Ae(()=>ke({method:Ee(`log_event`),params:ke({eventName:Se(),eventData:ke({}).passthrough()})}));function jv(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=dl(e);t&&t.client.setNotificationHandler(Av(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}Ne(),B();var Mv=6e3;function Nv(){return Date.now()-Be()}function Pv(e){return Nv()<e}function Fv(e){return!Pv(e)}function Iv(e,t){let n=E();(0,Q.useEffect)(()=>{et(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Fv(6e3)&&!r&&(r=!0,clearInterval(i),cv({message:e,notificationType:t},n))},Mv);return()=>clearInterval(i)},[e,t,n])}Md(),To(),Iu(),mu(),_c(),Ea(),qt(),$i(),mh(),dh(),Lt(),Ss(),Jc(),Ol(),xc(),Gi(),dg(),B(),od();var Lv={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Rv(e){return mc().syntaxHighlightingDisabled?(0,$.jsx)(Bv,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Bv,{...e,highlight:null}),children:(0,$.jsx)(zv,{...e})})}function zv(e){let t=(0,Q.use)(xu());return(0,$.jsx)(Bv,{...e,highlight:t})}function Bv({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=de(),[s]=b(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Do(e,s,a),[e,s,a]).split(`
2
- `),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>v(e))),g=Math.min(h+4,c),y=g-4,S=`${Lv.topLeft}${Lv.horizontal.repeat(g-2)}${Lv.topRight}`,C=`${Lv.bottomLeft}${Lv.horizontal.repeat(g-2)}${Lv.bottomRight}`,w=d?(()=>{let e=u.length-l,t=`${Lv.horizontal.repeat(3)} \u2702 ${Lv.horizontal.repeat(3)} ${e} lines hidden `,n=v(t),r=Math.max(0,g-2-n);return`${Lv.teeLeft}${t}${Lv.horizontal.repeat(r)}${Lv.teeRight}`})():null;return(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:S}),m.map((e,t)=>{let n=v(e)>y?ga(e,0,y):e,r=` `.repeat(Math.max(0,y-v(n)));return(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[Lv.vertical,` `]}),(0,$.jsx)(_,{children:n}),(0,$.jsxs)(T,{dimColor:!0,children:[r,` `,Lv.vertical]})]},t)}),w&&(0,$.jsx)(T,{color:`warning`,children:w}),(0,$.jsx)(T,{dimColor:!0,children:C})]})}fd(),B(),_p();function Vv({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${d.tick} Submit `,a=v(`← `)+v(` →`)+v(n),o=i-a;if(o<=0)return e.map((e,n)=>{let r=e?.header||`Q${n+1}`;return n===t?r.slice(0,3):``});let s=e.map((e,t)=>e?.header||`Q${t+1}`);if(s.map(e=>4+v(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+v(s[t]||``),l=Math.min(c,o/2),u=o-l,f=e.length-1,p=Math.max(6,Math.floor(u/Math.max(f,1)));return s.map((e,n)=>n===t?gp(e,l-2-2):gp(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(x,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(T,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?d.checkboxOn:d.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(x,{children:i?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(T,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(x,{children:t===e.length?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,d.tick,` Submit`,` `]}):(0,$.jsxs)(T,{children:[` `,d.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(T,{color:t===e.length?`inactive`:void 0,children:` →`})]})}u(),fd(),B(),G(),pu();function Hv({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:u,onCancel:f,onTabPrev:p,onTabNext:m,onRespondToClaude:g,onFinishPlanInterview:_}){let v=K(e=>e.toolPermissionContext.mode)===`plan`,[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(0),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),ee=cg(),j=ee?ac(ee):null,M=e.question,N=i[M],te=e.options,[P,F]=(0,Q.useState)(0),ne=(0,Q.useRef)(M);if(ne.current!==M){ne.current=M;let e=N?.selectedValue,t=e?te.findIndex(t=>t.label===e):-1;F(t>=0?t:0)}let re=te[P],I=N?.selectedValue,L=N?.textInputValue||``,ie=(0,Q.useCallback)(e=>{let t=te[e];t&&(F(e),c(M,{selectedValue:t.label},!1),l(M,t.label))},[te,M,c,l]),R=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?P>0?P-1:P:P<te.length-1?P+1:P,t>=0&&t<te.length&&F(t)},[P,te.length,E]);A(`chat:externalEditor`,async()=>{let e=N?.textInputValue||``,t=await lg(e);t.content!==null&&t.content!==e&&c(M,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!ee}),y({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!E&&!b});let z=(0,Q.useCallback)(()=>{D(!1),u(!1),I&&l(M,I)},[I,M,l,u]),ae=(0,Q.useCallback)(()=>{S(!0)},[]),oe=(0,Q.useCallback)(()=>{S(!1)},[]),se=(0,Q.useCallback)(e=>{if(b){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),C===0?oe():w(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),v&&C===0&&w(1);return}if(e.key===`return`){e.preventDefault(),C===0?g():_();return}e.key===`escape`&&(e.preventDefault(),f());return}if(E){e.key===`escape`&&(e.preventDefault(),z());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),P>0&&R(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),P===te.length-1?ae():R(`down`);else if(e.key===`return`)e.preventDefault(),ie(P);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),D(!0),u(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<te.length&&R(t)}},[b,C,v,E,P,te.length,oe,ae,R,ie,z,g,_,f,u]),ce=re?.preview||null,{columns:le}=de(),ue=le-30-4,fe=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:se,children:[(0,$.jsx)(h,{color:`inactive`}),(0,$.jsxs)(x,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Vv,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Hg,{title:e.question,color:`text`}),(0,$.jsxs)(x,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(x,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(x,{flexDirection:`column`,width:30,children:te.map((e,t)=>{let n=P===t,r=I===e.label;return(0,$.jsxs)(x,{flexDirection:`row`,children:[n?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(T,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(T,{color:`success`,children:[` `,d.tick]})]},e.label)})}),(0,$.jsxs)(x,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(Rv,{content:ce||`No preview available`,maxLines:fe,minWidth:s,maxWidth:ue}),(0,$.jsxs)(x,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:`Notes:`}),E?(0,$.jsx)(lu,{value:L,placeholder:`Add notes on this design…`,onChange:e=>{c(M,{textInputValue:e},!1)},onSubmit:z,onExit:z,focus:!0,showCursor:!0,columns:60,cursorOffset:O,onChangeCursorOffset:k}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:L||`press n to add notes`})]})]})]}),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(h,{color:`inactive`}),(0,$.jsxs)(x,{flexDirection:`row`,gap:1,children:[b&&C===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:b&&C===0?`suggestion`:void 0,children:`Chat about this`})]}),v&&(0,$.jsxs)(x,{flexDirection:`row`,gap:1,children:[b&&C===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:b&&C===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,d.arrowUp,`/`,d.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),E&&j&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,j]}),` · Esc to cancel`]})})]})]})]})}u(),B(),G(),sg(),pu(),dg(),ea(),Bg();function Uv({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onSubmit:m,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y,onImagePaste:b,pastedContents:S,onRemoveImage:C}){let w=K(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[ee,A]=(0,Q.useState)(!1),j=cg(),M=j?ac(j):null,N=(0,Q.useCallback)(e=>{let t=e===`__other__`;A(t),f(t)},[f]),te=(0,Q.useCallback)(()=>{D(!0)},[]),P=(0,Q.useCallback)(()=>{D(!1)},[]),F=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?P():k(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),w&&O===0&&k(1);return}if(e.key===`return`){e.preventDefault(),O===0?v():y();return}e.key===`escape`&&(e.preventDefault(),p())}},[E,O,w,P,v,y,p]),ne=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),re=e.question,I=i[re],L=(0,Q.useCallback)(async(t,n)=>{let r=await lg(t);r.content!==null&&r.content!==t&&(n(r.content),l(re,{textInputValue:r.content},e.multiSelect??!1))},[re,l,e.multiSelect]),ie={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:I?.textInputValue??``,onChange:t=>{l(re,{textInputValue:t},e.multiSelect??!1)}},R=[...ne,ie];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Hv,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y}):(0,$.jsxs)(x,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:F,children:[w&&o&&(0,$.jsxs)(x,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(h,{color:`inactive`}),(0,$.jsxs)(T,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(ro,{filePath:o})]})]}),(0,$.jsx)(x,{marginTop:-1,children:(0,$.jsx)(h,{color:`inactive`})}),(0,$.jsxs)(x,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Vv,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Hg,{title:e.question,color:`text`}),(0,$.jsxs)(x,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(x,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Ra,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[re]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(re,n,void 0,!1)},onFocus:N,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:te,isDisabled:E,onOpenEditor:L,onImagePaste:b,pastedContents:S,onRemoveImage:C},e.question):(0,$.jsx)(jd,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!1);let t=e===`__other__`?i[re]?.textInputValue:void 0;u(re,e,t)},onFocus:N,onCancel:p,onDownFromLastItem:te,isDisabled:E,layout:`compact-vertical`,onOpenEditor:L,onImagePaste:b,pastedContents:S,onRemoveImage:C},e.question)}),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(h,{color:`inactive`}),(0,$.jsxs)(x,{flexDirection:`row`,gap:1,children:[E&&O===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===0?`suggestion`:void 0,children:[R.length+1,`. Chat about this`]})]}),w&&(0,$.jsxs)(x,{flexDirection:`row`,gap:1,children:[E&&O===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===1?`suggestion`:void 0,children:[R.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[d.arrowUp,`/`,d.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,ee&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}function Wv(e,t){if(!e)return null;if(e.type===`classifier`)return e.classifier===`auto-mode`?{reasonString:`Auto mode classifier requires confirmation for this ${t}.\n${e.reason}`,configString:void 0,themeColor:`error`}:{reasonString:`Classifier ${ge.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${ge.bold($d(e.rule.ruleValue))} requires confirmation for this ${t}.`,configString:e.rule.source===`policySettings`?void 0:`/permissions to update rules`};case`hook`:{let n=e.reason?`:\n${e.reason}`:`.`,r=e.hookSource?` ${ge.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${ge.bold(e.hookName)} requires confirmation for this ${t}${n}${r}`,configString:`/hooks to update`}}case`safetyCheck`:case`other`:return{reasonString:e.reason,configString:void 0};case`workingDir`:return{reasonString:e.reason,configString:`/permissions to update rules`};default:return null}}function Gv({permissionResult:e,toolType:t}){let n=K(e=>e.toolPermissionContext.mode),r=Wv(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,Kv.jsxs)(x,{marginBottom:1,flexDirection:`column`,children:[i?(0,Kv.jsx)(T,{color:i,children:r.reasonString}):(0,Kv.jsx)(T,{children:(0,Kv.jsx)(_,{children:r.reasonString})}),r.configString&&(0,Kv.jsx)(T,{dimColor:!0,children:r.configString})]})}var Kv,qv=t((()=>{z(),B(),G(),Kv=xe()}));u(),B(),ea(),Bg(),qv();function Jv({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(h,{color:`inactive`}),(0,$.jsxs)(x,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Vv,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Hg,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(x,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(x,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(T,{children:[d.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(x,{marginLeft:2,children:(0,$.jsxs)(T,{color:`success`,children:[d.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(Gv,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(T,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(jd,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Yv(e,t){switch(t.type){case`next-question`:return{...e,currentQuestionIndex:e.currentQuestionIndex+1,isInTextInput:!1};case`prev-question`:return{...e,currentQuestionIndex:Math.max(0,e.currentQuestionIndex-1),isInTextInput:!1};case`update-question-state`:{let n=e.questionStates[t.questionText],r={selectedValue:t.updates.selectedValue??n?.selectedValue??(t.isMultiSelect?[]:void 0),textInputValue:t.updates.textInputValue??n?.textInputValue??``};return{...e,questionStates:{...e.questionStates,[t.questionText]:r}}}case`set-answer`:{let n={...e,answers:{...e.answers,[t.questionText]:t.answer}};return t.shouldAdvance?{...n,currentQuestionIndex:n.currentQuestionIndex+1,isInTextInput:!1}:n}case`set-text-input-mode`:return{...e,isInTextInput:t.isInInput}}}var Xv={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Zv(){let[e,t]=(0,Q.useReducer)(Yv,Xv),n=(0,Q.useCallback)(()=>{t({type:`next-question`})},[]),r=(0,Q.useCallback)(()=>{t({type:`prev-question`})},[]),i=(0,Q.useCallback)((e,n,r)=>{t({type:`update-question-state`,questionText:e,updates:n,isMultiSelect:r})},[]),a=(0,Q.useCallback)((e,n,r=!0)=>{t({type:`set-answer`,questionText:e,answer:n,shouldAdvance:r})},[]),o=(0,Q.useCallback)(e=>{t({type:`set-text-input-mode`,isInInput:e})},[]);return{currentQuestionIndex:e.currentQuestionIndex,answers:e.answers,questionStates:e.questionStates,isInTextInput:e.isInTextInput,nextQuestion:n,prevQuestion:r,updateQuestionState:i,setAnswer:a,setTextInputMode:o}}ll(),fd(),B(),Pi(),X(),G(),Qc(),Xf(),Hi();var Qv=12,$v=40,ey=15;function ty(e){return mc().syntaxHighlightingDisabled?(0,$.jsx)(ry,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ry,{...e,highlight:null}),children:(0,$.jsx)(ny,{...e})})}function ny(e){let t=(0,Q.use)(xu());return(0,$.jsx)(ry,{...e,highlight:t})}function ry({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Et.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=de(),[s]=b(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Qv,o-ey);for(let i of a)if(i.options.some(e=>e.preview)){let a=Math.max(1,n-11),o=0;for(let e of i.options)if(e.preview){let n=Do(e.preview,s,r).split(`
3
- `),i=n.length>a,c=i?a:n.length;o=Math.max(o,c+ +!!i+2);for(let e of n)t=Math.max(t,v(e))}let c=o+2,l=i.options.length+2;e=Math.max(e,Math.max(l,c)+7)}else e=Math.max(e,i.options.length+3+7);return{globalContentHeight:Math.min(Math.max(e,Qv),n),globalContentWidth:Math.max(t,$v)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function m(e,t,n,r,i,a){let o=p.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};xo(s),Ot(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let h=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),g=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),_=K(e=>e.toolPermissionContext.mode)===`plan`,x=_?Ht():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:ee}=Zv(),A=S<(a?.length||0)?a?.[S]:null,j=S===(a?.length||0),M=a?.every(e=>e?.question&&!!C[e.question])??!1,N=a.length===1&&!a[0]?.multiSelect,te=(0,Q.useCallback)(()=>{u&&Z(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&co()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),P=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
- This means they may have additional information, context or questions for you.
5
- Take their response into account and then reformulate the questions if appropriate.
6
- Start by asking them what they would like to clarify.
7
-
8
- Questions asked:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
- `)}`;u&&Z(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&co()});let r=await iy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,_,g]),F=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
10
- Stop asking clarifying questions and proceed to finish the plan with the information you have.
11
-
12
- Questions asked and answers provided:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
- `)}`;u&&Z(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&co()});let r=await iy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,_,g]),ne=(0,Q.useCallback)(async n=>{u&&Z(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&co()});let r={};for(let e of a){let t=n[e.question],i=w[e.question]?.textInputValue,a=(t?e.options.find(e=>e.label===t):void 0)?.preview;(a||i?.trim())&&(r[e.question]={...a&&{preview:a},...i?.trim()&&{notes:i.trim()}})}let i={...e.input,answers:n,...Object.keys(r).length>0&&{annotations:r}},o=await iy(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,w,_,g]),re=(0,Q.useCallback)((e,t,n,r=!0)=>{let i,o=Array.isArray(t);i=o?t.join(`, `):n?Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`${n} (Image attached)`:n:t===`__other__`&&Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`(Image attached)`:t;let s=a.length===1;if(!o&&s&&r){let t={...C,[e]:i};ne(t).catch(Y);return}k(e,i,r)},[k,a.length,C,ne,d]);function I(e){if(e===`cancel`){te();return}e===`submit`&&ne(C).catch(Y)}let L=N?(a?.length||1)-1:a?.length||0,ie=(0,Q.useCallback)(()=>{S>0&&D()},[S,D]),R=(0,Q.useCallback)(()=>{S<L&&E()},[S,L,E]);return y({"tabs:previous":ie,"tabs:next":R},{context:`Tabs`,isActive:!(T&&!j)}),A?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Uv,{question:A,questions:a,currentQuestionIndex:S,answers:C,questionStates:w,hideSubmitTab:N,minContentHeight:c,minContentWidth:l,planFilePath:x,onUpdateQuestionState:O,onAnswer:re,onTextInputFocus:ee,onCancel:te,onSubmit:E,onTabPrev:ie,onTabNext:R,onRespondToClaude:P,onFinishPlanInterview:F,onImagePaste:(e,t,n,r,i)=>m(A.question,e,t,n,r,i),pastedContents:d[A.question]??{},onRemoveImage:e=>h(A.question,e)})}):j?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Jv,{questions:a,currentQuestionIndex:S,answers:C,allQuestionsAnswered:M,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:I})}):null}async function iy(e){if(e.length!==0)return Promise.all(e.map(async e=>(await ed({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var ay=[`http://`,`https://`,`ftp://`],oy={rg:2,"pre-commit":2,gcloud:4,"gcloud compute":6,"gcloud beta":6,aws:4,az:4,kubectl:3,docker:3,dotnet:3,"git push":2},sy=e=>Array.isArray(e)?e:[e];function cy(e,t){if(!t?.subcommands?.length)return!1;let n=e.toLowerCase();return t.subcommands.some(e=>Array.isArray(e.name)?e.name.some(e=>e.toLowerCase()===n):e.name.toLowerCase()===n)}function ly(e,t,n){if(n?.options){let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t)return!!t.args}return n?.subcommands?.length&&t&&!t.startsWith(`-`)?!cy(t,n):!1}function uy(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){ly(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||cy(r,t))return r}}}async function dy(e,t,n){let r=await fy(e,t,n),i=[e],a=!!n?.subcommands?.length,o=!1;for(let s=0;s<t.length;s++){let c=t[s];if(!c||i.length>=r)break;if(c.startsWith(`-`)){if(c===`-c`&&[`python`,`python3`].includes(e.toLowerCase()))break;if(n?.options){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(c):e.name===c);if(e?.args&&sy(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){ly(c,t[s+1],n)&&s++;continue}break}if(await py(c,t.slice(0,s),n))break;a&&!o&&(o=cy(c,n)),i.push(c)}return i.join(` `)}async function fy(e,t,n){let r=uy(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(oy[a])return oy[a];if(oy[i])return oy[i];if(!n)return 2;if(n.options&&t.some(e=>e?.startsWith(`-`)))for(let e of t){if(!e?.startsWith(`-`))continue;let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t?.args&&sy(t.args).some(e=>e?.isCommand||e?.isModule))return 3}if(r&&n.subcommands?.length){let e=r.toLowerCase(),t=n.subcommands.find(t=>Array.isArray(t.name)?t.name.some(t=>t.toLowerCase()===e):t.name.toLowerCase()===e);if(t){if(t.args){let e=sy(t.args);if(e.some(e=>e?.isCommand))return 3;if(e.some(e=>e?.isVariadic))return 2}return t.subcommands?.length?4:t.args?3:2}}if(n.args){let e=sy(n.args);if(e.some(e=>e?.isCommand))return!Array.isArray(n.args)&&n.args.isCommand?2:Math.min(2+e.findIndex(e=>e?.isCommand),3);if(!n.subcommands?.length){if(e.some(e=>e?.isVariadic))return 1;if(e[0]&&!e[0].isOptional)return 2}}return n.args&&sy(n.args).some(e=>e?.isDangerous)?3:2}async function py(e,t,n){if(e.startsWith(`-`))return!0;let r=e.lastIndexOf(`.`),i=r>0&&r<e.length-1&&!e.substring(r+1).includes(`:`),a=e.includes(`/`)||i,o=ay.some(t=>e.startsWith(t));if(!a&&!o)return!1;if(n?.options&&t.length>0&&t[t.length-1]===`-m`){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(`-m`):e.name===`-m`);if(e?.args&&sy(e.args).some(e=>e?.isModule))return!1}return!0}var my=[{name:`pyright`,description:`Type checker for Python`,options:[{name:[`--help`,`-h`],description:`Show help message`},{name:`--version`,description:`Print pyright version and exit`},{name:[`--watch`,`-w`],description:`Continue to run and watch for changes`},{name:[`--project`,`-p`],description:`Use the configuration file at this location`,args:{name:`FILE OR DIRECTORY`}},{name:`-`,description:`Read file or directory list from stdin`},{name:`--createstub`,description:`Create type stub file(s) for import`,args:{name:`IMPORT`}},{name:[`--typeshedpath`,`-t`],description:`Use typeshed type stubs at this location`,args:{name:`DIRECTORY`}},{name:`--verifytypes`,description:`Verify completeness of types in py.typed package`,args:{name:`IMPORT`}},{name:`--ignoreexternal`,description:`Ignore external imports for --verifytypes`},{name:`--pythonpath`,description:`Path to the Python interpreter`,args:{name:`FILE`}},{name:`--pythonplatform`,description:`Analyze for platform`,args:{name:`PLATFORM`}},{name:`--pythonversion`,description:`Analyze for Python version`,args:{name:`VERSION`}},{name:[`--venvpath`,`-v`],description:`Directory that contains virtual environments`,args:{name:`DIRECTORY`}},{name:`--outputjson`,description:`Output results in JSON format`},{name:`--verbose`,description:`Emit verbose diagnostics`},{name:`--stats`,description:`Print detailed performance stats`},{name:`--dependencies`,description:`Emit import dependency information`},{name:`--level`,description:`Minimum diagnostic level`,args:{name:`LEVEL`}},{name:`--skipunannotated`,description:`Skip type analysis of unannotated functions`},{name:`--warnings`,description:`Use exit code of 1 if warnings are reported`},{name:`--threads`,description:`Use up to N threads to parallelize type checking`,args:{name:`N`,isOptional:!0}}],args:{name:`files`,description:`Specify files or directories to analyze (overrides config file)`,isVariadic:!0,isOptional:!0}},{name:`timeout`,description:`Run a command with a time limit`,args:[{name:`duration`,description:`Duration to wait before timing out (e.g., 10, 5s, 2m)`,isOptional:!1},{name:`command`,description:`Command to run`,isCommand:!0}]},{name:`sleep`,description:`Delay for a specified amount of time`,args:{name:`duration`,description:`Duration to sleep (seconds or with suffix like 5s, 2m, 1h)`,isOptional:!1}},{name:`alias`,description:`Create or list command aliases`,args:{name:`definition`,description:`Alias definition in the form name=value`,isOptional:!0,isVariadic:!0}},{name:`nohup`,description:`Run a command immune to hangups`,args:{name:`command`,description:`Command to run with nohup`,isCommand:!0}},{name:`time`,description:`Time a command`,args:{name:`command`,description:`Command to time`,isCommand:!0}},{name:`srun`,description:`Run a command on SLURM cluster nodes`,options:[{name:[`-n`,`--ntasks`],description:`Number of tasks`,args:{name:`count`,description:`Number of tasks to run`}},{name:[`-N`,`--nodes`],description:`Number of nodes`,args:{name:`count`,description:`Number of nodes to allocate`}}],args:{name:`command`,description:`Command to run on the cluster`,isCommand:!0}}];async function hy(e){if(!e||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||e.startsWith(`-`)&&e!==`-`)return null;try{let t=await import(`@withfig/autocomplete/build/${e}.js`);return t.default||t}catch{return null}}var gy=Zf(async e=>my.find(t=>t.name===e)||await hy(e)||null,e=>e),_y=/^\d+$/,vy=/^[A-Za-z_][A-Za-z0-9_]*=/,yy=new Set([`nice`]),by=e=>Array.isArray(e)?e:[e];function xy(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Sy(e,t=0,n=0){if(n>2||t>10)return null;let r=await Zm(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Qm(a);if(!o)return{commandPrefix:null};let c=await gy(o),l=yy.has(o)||c?.args&&by(c.args).some(e=>e?.isCommand);l&&s[0]&&xy(s[0],c)&&(l=!1);let u=l?await Cy(o,s,t,n):await dy(o,s,c);if(u===null&&t===0&&l)return null;let d=i.length?`${i.join(` `)} `:``;return{commandPrefix:u?d+u:null}}async function Cy(e,t,n,r){let i=await gy(e);if(i?.args){let a=by(i.args).findIndex(e=>e?.isCommand);if(a!==-1){let i=[e];for(let e=0;e<t.length&&e<=a;e++)if(e===a){let a=await Sy(t.slice(e).join(` `),n+1,r+1);if(a?.commandPrefix)return i.push(...a.commandPrefix.split(` `)),i.join(` `);break}else t[e]&&!t[e].startsWith(`-`)&&!vy.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!_y.test(e)&&!vy.test(e));if(!a)return e;let o=await Sy(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function wy(e,t){let n=Li(e);if(n.length<=1){let t=await Sy(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Sy(n);i?.commandPrefix&&r.push(i.commandPrefix)}if(r.length===0)return[];let i=new Map;for(let e of r){let t=e.split(` `)[0],n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[];for(let[,e]of i)a.push(Ty(e));return a}function Ty(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&t[a]===i[a];)a++;n=a}return t.slice(0,Math.max(1,n)).join(` `)}async function Ey(e){Z(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}var Dy=t((()=>{X()}));fs(),nc(),X(),Co(),Of(),G(),af(),Dy();function Oy(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=pi(e.suggestions),n=t.length>0?t.map(e=>$d(e)).join(`, `):`none`;return`ask: ${e.message},
14
- suggestions: ${n}
15
- reason: ${ky(e.decisionReason)}`}case`deny`:return`deny: ${e.message},
16
- reason: ${ky(e.decisionReason)}`;case`passthrough`:{let t=pi(e.suggestions),n=t.length>0?t.map(e=>$d(e)).join(`, `):`none`;return`passthrough: ${e.message},
17
- suggestions: ${n}
18
- reason: ${ky(e.decisionReason)}`}}}function ky(e){if(!e)return`No decision reason`;if(e.type===`classifier`)return`Classifier: ${e.classifier}, Reason: ${e.reason}`;switch(e.type){case`rule`:return`Rule: ${$d(e.rule.ruleValue)}`;case`mode`:return`Mode: ${e.mode}`;case`subcommandResults`:return`Subcommand Results: ${Array.from(e.reasons.entries()).map(([e,t])=>`${e}: ${Oy(t)}`).join(`,
19
- `)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${Jd(e.toolResult)}`;case`hook`:return`Hook: ${e.hookName}${e.reason?`, Reason: ${e.reason}`:``}`;case`workingDir`:return`Working Directory: ${e.reason}`;case`safetyCheck`:return`Safety check: ${e.reason}`;case`other`:return`Other: ${e.reason}`;default:return Jd(e,null,2)}}function Ay(e,t){let n=as(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(r.current!==e.toolUseID){if(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),Z(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:na.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===Hs.name&&t.behavior===`ask`&&!Oi(t.suggestions)&&Z(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:na.isSandboxingEnabled(),decisionReasonDetails:ky(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=Hs.inputSchema.safeParse(e.input);if(e.tool.name===Hs.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=Li(t.data.command)}catch{}Z(`tengu_internal_bash_tool_use_permission_request`,{parts:Jd(n),input:Jd(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:ky(e.permissionResult.decisionReason)})}}Ey({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Qd.platform}})}},[e,t,n])}L(),u(),B(),G(),Pn(),Of(),Mg(),sa();function jy(e){if(e.type===`classifier`)return`${ge.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${ge.bold($d(e.rule.ruleValue))} rule from ${hf(e.rule.source)}`;case`mode`:return`${cf(e.mode)} mode`;case`sandboxOverride`:return`Requires permission to bypass sandbox`;case`workingDir`:return e.reason;case`safetyCheck`:case`other`:return e.reason;case`permissionPromptTool`:return`${ge.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${ge.bold(e.hookName)} hook: ${e.reason}`:`${ge.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function My({title:e,decisionReason:t}){let[n]=b();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(x,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[t.behavior===`allow`?ce(`success`,n)(d.tick):ce(`error`,n)(d.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(_,{children:jy(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Ny,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(T,{children:(0,$.jsx)(_,{children:jy(t)})})}}return(0,$.jsxs)(x,{flexDirection:`column`,children:[e&&(0,$.jsx)(T,{children:e}),r()]})}function Ny({suggestions:e}){let t=pi(e);return t.length===0?null:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(_,{children:t.map(e=>ge.bold($d(e))).join(`, `)})]})}function Py(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Fy(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Iy({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:`None`})]});let n=pi(e),r=Py(e),i=Fy(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(T,{children:`None`})]}):(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:` `})]}),n.length>0&&(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(x,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,$d(e)]},t))})]}),r.length>0&&(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(x,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(T,{children:cf(i)})]})]})}function Ly({permissionResult:e,toolName:t}){let n=K(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=na.isSandboxingEnabled()&&na.isAutoAllowBashIfSandboxedEnabled(),r=Ng(n,{sandboxAutoAllowEnabled:e}),a=pi(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(T,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Message `})}),(0,$.jsx)(T,{children:e.message})]}),(0,$.jsxs)(x,{flexDirection:`row`,children:[(0,$.jsx)(x,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(T,{children:`undefined`}):(0,$.jsx)(My,{decisionReason:r})]}),(0,$.jsx)(Iy,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(x,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(T,{color:`warning`,children:$d(e.rule.ruleValue)}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}je(),X(),Gm(),Mf(),q(),Yd(),Me(),Xf(),ah(),bd(),Bd();var Ry={LOW:1,MEDIUM:2,HIGH:3},zy=1,By=2,Vy=3,Hy=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Uy={name:`explain_command`,description:`Provide an explanation of a shell command`,input_schema:{type:`object`,properties:{explanation:{type:`string`,description:`What this command does (1-2 sentences)`},reasoning:{type:`string`,description:`Why YOU are running this command. Start with "I" - e.g. "I need to check the file contents"`},risk:{type:`string`,description:`What could go wrong, under 15 words`},riskLevel:{type:`string`,enum:[`LOW`,`MEDIUM`,`HIGH`],description:`LOW (safe dev workflows), MEDIUM (recoverable changes), HIGH (dangerous/irreversible)`}},required:[`explanation`,`reasoning`,`risk`,`riskLevel`]}},Wy=Ae(()=>ke({riskLevel:De([`LOW`,`MEDIUM`,`HIGH`]),explanation:Se(),reasoning:Se(),risk:Se()}));function Gy(e){if(typeof e==`string`)return e;try{return Jd(e,null,2)}catch{return String(e)}}function Ky(e,t=1e3){let n=e.filter(e=>e.type===`assistant`).slice(-3),r=[],i=0;for(let e of n.reverse()){let n=(Array.isArray(e.message.content)?e.message.content:[]).filter(e=>e.type===`text`).map(e=>`text`in e?e.text:``).join(` `);if(n&&i<t){let e=t-i,a=n.length>e?n.slice(0,e)+`...`:n;r.unshift(a),i+=a.length}}return r.join(`
20
-
21
- `)}function qy(){return jf().permissionExplainerEnabled!==!1}async function Jy({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!qy())return null;let a=Date.now();try{let o=Gy(t),s=r?.length?Ky(r):``,c=`Tool: ${e}
22
- ${n?`Description: ${n}\n`:``}
23
- Input:
24
- ${o}
25
- ${s?`\nRecent conversation context:\n${s}`:``}
26
-
27
- Explain this command in context.`,l=await rs({model:ih()?em():dm(),system:Hy,messages:[{role:`user`,content:c}],tools:[Uy],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;J(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){J(`Permission explainer: tool input: ${Jd(d.input).slice(0,500)}`);let t=Wy().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return Z(`tengu_permission_explainer_generated`,{tool_name:Km(e),risk_level:Ry[n.riskLevel],latency_ms:u}),J(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Z(`tengu_permission_explainer_error`,{tool_name:Km(e),error_type:zy,latency_ms:u}),J(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(J(`Permission explainer: request aborted for ${e}`),null):(J(`Permission explainer error: ${Ld(t)}`),Y(t),Z(`tengu_permission_explainer_error`,{tool_name:Km(e),error_type:t instanceof Error&&t.name===`AbortError`?By:Vy,latency_ms:n}),null)}}B(),Pi(),X();var Yy=`Loading explanation…`;function Xy(){let[e,t]=Bo(`responding`,Yy,!1);return(0,$.jsx)(x,{ref:e,children:(0,$.jsx)(T,{children:Yy.split(``).map((e,n)=>(0,$.jsx)(yu,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Zy(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Qy(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function $y(e){return Jy({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function eb(e){let t=qy(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return A(`confirm:toggleExplanation`,()=>{n||(Z(`tengu_permission_explainer_shortcut_used`,{}),i||a($y(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function tb({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(T,{children:t.explanation}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{children:t.reasoning})}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:Zy(t.riskLevel),children:[Qy(t.riskLevel),`:`]}),(0,$.jsxs)(T,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Explanation unavailable`})})}function nb({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(Xy,{})}),children:(0,$.jsx)(tb,{promise:t})})}fd(),B(),Xf(),Ir(),Ct();function rb(e){let[t]=(0,Q.useState)(()=>ob(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ab,{placeholder:!0}),children:(0,$.jsx)(ib,{promise:t,file_path:e.file_path})})}function ib({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=de();return(0,$.jsx)(ab,{children:(0,$.jsx)(Bi,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function ab({children:e,placeholder:t}){return(0,$.jsx)(x,{flexDirection:`column`,children:(0,$.jsx)(x,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(T,{dimColor:!0,children:`…`}):e})})}async function ob(e,t){let n=t.filter(e=>e.old_string!=null&&e.new_string!=null),r=n.length===1?n[0]:void 0;if(r&&r.old_string.length>=8192)return sb(e,[r]);try{let t=await Jl(e);if(t===null)return sb(e,n);try{if(!r||r.old_string===``){let r=await wr(t);return r===null?sb(e,n):{patch:wc({filePath:e,fileContents:r,edits:n.map(e=>cb(r,e))}),firstLine:bp(r),fileContent:r}}let i=await mo(t,r.old_string,3);if(i.truncated||i.content===``)return sb(e,[r]);let a=cb(i.content,r);return{patch:fu(wc({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?bp(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Y(t),sb(e,n)}}function sb(e,t){return{patch:t.flatMap(t=>wc({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function cb(e,t){let n=wt(e,t.old_string)||t.old_string;return{...t,old_string:n}}Nu(),X(),bl(),Mf(),Nl(),Yd(),pu(),Xf();function lb({onChange:e,toolUseContext:t,filePath:n,edits:r,editMode:i}){let a=(0,Q.useRef)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useMemo)(()=>U_().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${N_(n)} (${c}) ⧉`,[n,c]),u=Sl(t.options.mcpClients)&&jf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=iu(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Z(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await db(n,r,t,l);if(a.current)return;Z(`tengu_ext_diff_accepted`,{});let c=ub(n,o,s,i);if(c.length===0){Z(`tengu_ext_diff_rejected`,{});let i=dl(t.options.mcpClients);i&&await fb(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Y(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=dl(t.options.mcpClients);return e?fb(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function ub(e,t,n,r){let i=r===`single`,a=$o({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Y(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),zs(a))}async function db(e,t,n,r){let i=!1,a=ip(e),o=``;try{o=rf(a)}catch(e){if(!Vd(e))throw e}async function s(){if(!i){i=!0;try{await fb(r,c)}catch(e){Y(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=dl(n.options.mcpClients);try{let{updatedFile:e}=Pu({filePath:a,fileContents:o,edits:t});if(!c||c.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;tp()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new qu(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await cd(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(hb(u))return s(),{oldContent:o,newContent:u[1].text};if(pb(u))return s(),{oldContent:o,newContent:e};if(mb(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Y(e),s(),e}}async function fb(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await cd(`close_tab`,{tab_name:e},t)}catch(e){Y(e)}}function pb(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`TAB_CLOSED`}function mb(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`DIFF_REJECTED`}function hb(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}B(),Nd(),pu(),ea();function gb({onChange:e,options:t,input:n,filePath:r,ideName:i,symlinkTarget:a,rejectFeedback:o,acceptFeedback:s,setFocusedOption:c,onInputModeToggle:l,focusedOption:u,yesInputMode:d,noInputMode:f}){return(0,$.jsx)(_e,{color:`permission`,children:(0,$.jsxs)(x,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(T,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(T,{color:`warning`,children:L_(Pd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Vs()&&(0,$.jsx)(T,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:N_(r)}),`?`]}),(0,$.jsx)(jd,{options:t,inlineDescriptions:!0,onChange:r=>{let i=t.find(e=>e.value===r);if(i){if(i.option.type===`reject`){let t=o.trim();e(i.option,n,t||void 0);return}if(i.option.type===`accept-once`){let t=s.trim();e(i.option,n,t||void 0);return}e(i.option,n)}},onCancel:()=>e({type:`reject`},n),onFocus:e=>c(e),onInputModeToggle:l})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Ne(),B(),rp();function _b(e){let t=ip(e),n=ip(`${ht()}/.claude`),r=Ad(t),i=Ad(n);return r.startsWith(i+R_.toLowerCase())||r.startsWith(i+`/`)}function vb(e){let t=ip(e),n=I_(A_(),`.claude`),r=Ad(t),i=Ad(n);return r.startsWith(i+R_.toLowerCase())||r.startsWith(i+`/`)}function yb({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=ta(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=Jt(e,t),u=_b(e),d=vb(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .claude/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(T,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]});else{let r=N_(ap(e))||`this directory`;t=n===`read`?(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(T,{children:[`Yes, allow all edits in `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}X(),Gm(),af(),$r(),Dy();function bb(e,t,n,r,i){Ey({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Qd.platform,hasFeedback:i??!1}})}function xb(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;bb(`accept`,a,o,n),Z(`tengu_accept_submitted`,{toolName:Km(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function Sb(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(bb(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:_m,ruleContent:t.scope===`global-claude-folder`?Tm:Cm}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?ji(r,l,a):[];o(),i.onAllow(i.input,u)}function Cb(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;bb(`reject`,o,s,n,t?.hasFeedback),Z(`tengu_reject_submitted`,{toolName:Km(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var wb={"accept-once":xb,"accept-session":Sb,reject:Cb};G(),Pi(),X(),Gm();function Tb({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=K(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>yb({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),T=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=wb[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?b:S,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,b,S]);return y({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=w.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);T(e.option,t)}},[w,o,r.input,T])},{context:`Confirmation`}),{options:w,onChange:T,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&v(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:Km(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),Z(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),x(!0),Z(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(v(!1),Z(`tengu_reject_feedback_mode_collapsed`,t)):(v(!0),C(!0),Z(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}B(),Qc(),Nd(),rp(),ea();function Eb({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?hs(l):`none`),[p,l]);Ay(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=ip(l),{resolvedPath:t,isSymlink:n}=Ud(Wd(),e);return n?t:null},[l,d]),g=Tb({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:b,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E}=g,D=u(e.input),O=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:k,showingDiffInIDE:ee,ideName:A}=lb(O?{onChange:(e,t)=>{let n=f.applyChanges(D,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:O.filePath,edits:(O.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:O.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),j=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(ee&&O&&l)return(0,$.jsx)(gb,{onChange:(e,t,n)=>j(e,n),options:_,filePath:l,input:D,ideName:A,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:b,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E});let M=h!=null&&L_(Pd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ug,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(x,{paddingX:1,marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,children:M?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(x,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(T,{children:o}):o,(0,$.jsx)(jd,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();j(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();j(t.option,e||void 0);return}j(t.option)}},onCancel:()=>j({type:`reject`}),onFocus:e=>b(e),onInputModeToggle:S})]})]}),(0,$.jsx)(x,{paddingX:1,marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!E)&&` · Tab to add feedback`]})})]})}Nd(),Yd(),wf(),Kd(),B(),Fl();function Db({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ob,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=of(n);return{oldContent:(await Wd().readFile(n,{encoding:e})).replaceAll(`\r
28
- `,`
29
- `),fileExists:!0}})().catch(e=>{if(!Vd(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Ob({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Ju(i,e),[i,e]),s=(0,Q.useMemo)(()=>i===o?[]:[{old_string:i,new_string:o,replace_all:!1}],[i,o]),c=(0,Q.useMemo)(()=>a?`Pattern did not match any content`:`File does not exist`,[a]);return(0,$.jsx)(Eb,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:L_(Pd(),r),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:N_(r)}),`?`]}),content:s.length>0?(0,$.jsx)(rb,{file_path:r,edits:s}):(0,$.jsx)(T,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Hs.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}af(),Dy();function kb(e,{assistantMessage:{message:{id:t}}},n,r){Ey({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Tf(),hasFeedback:r??!1}})}X(),Gm(),G();function Ab({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=as(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);function y(t){e.onUserInteraction();let n={toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),Z(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),Z(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),Z(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),Z(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(Z(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),kb(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function x(t){t!==p&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),m(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:h,noFeedbackModeEntered:_,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:p,handleInputModeToggle:y,handleReject:b,handleFocus:x}}Ne(),B();function jb(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(T,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(T,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(T,{bold:!0,children:e.slice(-1)[0]})]})}}function Mb(e){return e.join(`, `).length>50?`similar`:jb(e)}function Nb(e){if(e.length===0)return``;let t=e.map(e=>N_(e)||e);return t.length===1?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),R_]}):t.length===2?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),R_,` and `,(0,$.jsx)(T,{bold:!0,children:t[1]}),R_]}):(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),R_,`, `,(0,$.jsx)(T,{bold:!0,children:t[1]}),R_,` and `,e.length-2,` more`]})}function Pb(e,t,n){let r=e.filter(e=>e.type===`addRules`).flatMap(e=>e.rules||[]),i=r.filter(e=>e.toolName===`Read`),a=r.filter(e=>e.toolName===t),o=e.filter(e=>e.type===`addDirectories`).flatMap(e=>e.directories||[]),s=i.map(e=>e.ruleContent?.replace(`/**`,``)||``).filter(e=>e),c=[...new Set(a.flatMap(e=>{if(!e.ruleContent)return[];let t=jt(e.ruleContent)??e.ruleContent;return n?n(t):t}))],l=o.length>0,u=s.length>0,d=c.length>0;if(u&&!l&&!d){if(s.length===1){let e=s[0];return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsx)(T,{bold:!0,children:N_(e)||e}),R_,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,Nb(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,(0,$.jsx)(T,{bold:!0,children:N_(e)||e}),R_,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Nb(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,Mb(c),` commands in `,(0,$.jsx)(T,{bold:!0,children:ht()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Nb(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(T,{children:[`Yes, and allow access to `,Nb(e),` and `,Mb(c),` commands`]}):(0,$.jsxs)(T,{children:[`Yes, and allow `,Nb(e),` access and `,Mb(c),` commands`]})}return null}Co();function Fb(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function Ib(e){let{commandWithoutRedirections:t,redirections:n}=eo(e);return n.length>0?t:e}function Lb({suggestions:e=[],decisionReason:t,onRejectFeedbackChange:n,onAcceptFeedbackChange:r,onClassifierDescriptionChange:i,classifierDescription:a,initialClassifierDescriptionEmpty:o=!1,existingAllowDescriptions:s=[],yesInputMode:c=!1,noInputMode:l=!1,editablePrefix:u,onEditablePrefixChange:d}){let f=[];if(c?f.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:r,allowEmptySubmitToCancel:!0}):f.push({label:`Yes`,value:`yes`}),ha()){let n=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!n&&e.length>0)f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., npm run:*)`,initialValue:u,onChange:d,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else if(e.length>0){let t=Pb(e,bm,Ib);t&&f.push({label:t,value:`yes-apply-suggestions`})}let r=f.some(e=>e.value===`yes-prefix-edited`);process.env.USER_TYPE===`ant`&&!r&&Va()&&i&&!o&&!Fb(a??``,s)&&t?.type!==`classifier`&&f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-classifier-reviewed`,placeholder:`describe what to allow...`,initialValue:a??``,onChange:i,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0})}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}B(),Pi(),X(),Gm(),G(),Fl(),gd(),ba(),Pn(),sa(),fs(),nc(),Vg(),qv();function Rb(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Hs.inputSchema.parse(t.input),c=ts(o);return c?(0,$.jsx)(Db,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(zb,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function zb({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=b(),c=K(e=>e.toolPermissionContext),l=eb({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:S,handleFocus:C}=Ab({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(o||``),[k,ee]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Va())return;let e=new AbortController;return Na(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(O(t),ee(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let j=e.permissionResult.decisionReason?.type===`subcommandResults`,[M,N]=(0,Q.useState)(()=>{if(j){let t=pi(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Hs.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=dn(a);if(t)return`${t}:*`;let n=Cn(a);return n?`${n}:*`:a}),te=(0,Q.useRef)(!1),P=(0,Q.useCallback)(e=>{te.current=!0,N(e)},[]);(0,Q.useEffect)(()=>{if(j)return;let e=!1;return wy(a,e=>Hs.isReadOnly({command:e})).then(t=>{e||te.current||t.length>0&&N(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,j]);let[F]=(0,Q.useState)(!1),{destructiveWarning:ne,sandboxingEnabled:re,isSandboxed:I}=(0,Q.useMemo)(()=>{let t=na.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Sr(e.input)}},[a,e.input]);Ay(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let L=(0,Q.useMemo)(()=>nr(c),[c]),ie=(0,Q.useMemo)(()=>Lb({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:O,classifierDescription:D,initialClassifierDescriptionEmpty:k,existingAllowDescriptions:L,yesInputMode:u,noInputMode:d,editablePrefix:M,onEditablePrefixChange:P}),[e,D,k,L,u,d,M,P]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{E(e=>!e)},[]),{context:`Confirmation`}),A(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function R(t){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=Km(e.tool.name);if(t===`yes-prefix-edited`){let t=(M??``).trim();if(kb(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Hs.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();kb(`tool_use_single`,e,`accept`),Z(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{kb(`tool_use_single`,e,`accept`);let t=`suggestions`in e.permissionResult&&e.permissionResult.suggestions||[];e.onAllow(e.input,t),n();break}case`no`:{let t=h.trim();Z(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),S(t||void 0);break}}}return(0,$.jsxs)(Ug,{title:re&&!I?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:l.visible,children:Hs.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(T,{dimColor:!0,children:e.description}),(0,$.jsx)(nb,{visible:l.visible,promise:l.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ly,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(x,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(Gv,{permissionResult:e.permissionResult,toolType:`command`}),ne&&(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,dimColor:!1,children:ne})}),(0,$.jsx)(T,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(jd,{options:ie,isDisabled:!1,inlineDescriptions:!0,onChange:R,onCancel:()=>S(),onFocus:C,onInputModeToggle:y})]}),(0,$.jsxs)(x,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ne(),B(),X(),G(),yo(),ea(),Vg();function Bb({toolUseConfirm:e,onDone:t,onReject:n}){let r=K(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(Z(`tengu_plan_enter`,{interviewPhaseEnabled:co(),entryMethod:`tool`}),He(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Ug,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(T,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(x,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(T,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(T,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(T,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(T,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(jd,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),qa(),X(),G(),Ne(),$g(),B(),sg(),pu(),Xf(),Ps(),Gp(),ba(),Sf(),en(),yo(),ya(),dg(),Ac(),ea(),Vg(),qv(),Vo(),Gi();var Vb=(Ml(),e(Qo));function Hb(e,t){let n=[{type:`setMode`,mode:ff(e),destination:`session`}];return Va()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Ut(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Ub(e,t,n){at()||bf()?.cleanupPeriodDays===0||!n&&cl(pt())||e_([Jr({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||cl(pt()))return;let n=pt(),r=An();await $u(n,e,r,`auto`),await lc(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Y)}function Wb({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=K(e=>e.toolPermissionContext),a=as();Cd();let{addNotification:o}=Xn(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=K(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_}=i,v=(0,Q.useMemo)(()=>Gb({showClearContext:p,usedPercent:p?Kb(m,h):null,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_,onFeedbackChange:c}),[p,m,h,g,_]);function y(e,t,n,r,i){let a=f.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};xo(o),Ot(o),u(e=>({...e,[a]:o}))}let b=(0,Q.useCallback)(e=>{u(t=>{let n={...t};return delete n[e],n})},[]),S=Object.values(l).filter(e=>e.type===`image`),C=S.length>0,w=e.tool.name===mm,E=w?void 0:e.input.plan,D=w?Ht():void 0,O=e.input.allowedPrompts,k=E??Td(),ee=!k||k.trim()===``,[A]=(0,Q.useState)(()=>W()??void 0),[j,M]=(0,Q.useState)(()=>E||(Td()??`No plan found. Please write your plan to the plan file first.`)),[N,te]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(N){let e=setTimeout(te,5e3,!1);return()=>clearTimeout(e)}},[N]);let ne=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Z(`tengu_plan_external_editor_used`,{}),(async()=>{if(w&&D){let e=await fg(D);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==j&&F(!0),M(e.content),te(!0))}else{let e=await lg(j);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==j&&(M(e.content),te(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),re(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function re(r){let o=s.trim(),c=o||void 0,l=w&&!P?{}:{plan:j};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&xn(),t=Vb?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Vb?.setAutoModeActive(!1),Ue(!0),a(e=>({...e,toolPermissionContext:{...ii(e.toolPermissionContext),prePlanMode:void 0}})))}let u=r===`yes-accept-edits-keep-context`||r===`yes-default-keep-context`||r===`yes-resume-auto-mode`;if(r!==`no`&&Ub(j,a,!u),r!==`no`&&!u){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&xn()&&(i=`auto`,Vb?.setAutoModeActive(!0)),Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:r,clearContext:!0,interviewPhaseEnabled:co(),planStructureVariant:A,hasFeedback:!!c});let o=`\n\nIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ${An()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...Jr({content:`Implement the following plan:\n\n${j}${o}${s}`}),planContent:j},clearContext:!0,mode:i,allowedPrompts:O}})),ze(!0),mt(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&xn()){Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:r,clearContext:!1,interviewPhaseEnabled:co(),planStructureVariant:A,hasFeedback:!!c}),ze(!0),mt(!0),Vb?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:fi({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(l,[],c);return}let d={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(d){Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:r,clearContext:!1,interviewPhaseEnabled:co(),planStructureVariant:A,hasFeedback:!!c}),ze(!0),mt(!0),t(),e.onAllow(l,Hb(d,O),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:r,interviewPhaseEnabled:co(),planStructureVariant:A,hasFeedback:!!c}),ze(!0),mt(!0),t(),e.onAllow(l,Hb(f,O),c);return}if(r===`no`){if(!o&&!C)return;Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:`no`,interviewPhaseEnabled:co(),planStructureVariant:A});let r;C&&(r=await Promise.all(S.map(async e=>(await ed({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(C?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let I=cg(),L=I?ac(I):null,ie=(0,Q.useRef)(re);ie.current=re;let R=(0,Q.useRef)(void 0);R.current=()=>{Z(`tengu_plan_exit`,{planLengthChars:j.length,outcome:`no`,interviewPhaseEnabled:co(),planStructureVariant:A}),t(),n(),e.onReject()};let z=!ee&&!!r;if((0,Q.useLayoutEffect)(()=>{if(z)return r((0,$.jsxs)(x,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(jd,{options:v,onChange:e=>void ie.current(e),onCancel:()=>R.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})}),L&&(0,$.jsxs)(x,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:L}),w&&D&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,gf(D)]}),N&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[z,r,v,l,L,w,D,N]),ee){function r(r){r===`yes`?(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:co(),planStructureVariant:A}),(Vb?.isAutoModeActive()??!1)&&(Vb?.setAutoModeActive(!1),Ue(!0),a(e=>({...e,toolPermissionContext:{...ii(e.toolPermissionContext),prePlanMode:void 0}}))),ze(!0),mt(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:co(),planStructureVariant:A}),t(),n(),e.onReject())}return(0,$.jsx)(Ug,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(T,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(jd,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:co(),planStructureVariant:A}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(x,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ne,children:[(0,$.jsx)(Ug,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(x,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:`Here is Claude's plan:`})}),(0,$.jsx)(x,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(U,{children:j})}),(0,$.jsxs)(x,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(Gv,{permissionResult:e.permissionResult,toolType:`tool`}),Va()&&O&&O.length>0&&(0,$.jsxs)(x,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{bold:!0,children:`Requested permissions:`}),O.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!z&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(jd,{options:v,onChange:re,onCancel:()=>R.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})})]})]})]})}),!z&&L&&(0,$.jsxs)(x,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:L}),w&&D&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,gf(D)]})]}),N&&(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function Gb({showClearContext:e,usedPercent:t,isAutoModeAvailable:n,isBypassPermissionsModeAvailable:r,onFeedbackChange:i}){let a=[],o=t===null?``:` (${t}% used)`;return e&&(n?a.push({label:`Yes, clear context${o} and use auto mode`,value:`yes-auto-clear-context`}):r?a.push({label:`Yes, clear context${o} and bypass permissions`,value:`yes-bypass-permissions`}):a.push({label:`Yes, clear context${o} and auto-accept edits`,value:`yes-accept-edits`})),n?a.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):r?a.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):a.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),a.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),a.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Claude what to change`,description:`shift+tab to approve with this feedback`,onChange:i}),a}function Kb(e,t){if(!e)return null;let n=Hp(nm({permissionMode:t,mainLoopModel:dm(),exceeds200kTokens:!1}),st()),{used:r}=kp({input_tokens:e.input_tokens,cache_creation_input_tokens:e.cache_creation_input_tokens??0,cache_read_input_tokens:e.cache_read_input_tokens??0},n);return r}function qb({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=as(),[o,s]=(0,Jb.useState)(``),[c,l]=(0,Jb.useState)(``),[u,d]=(0,Jb.useState)(!1),[f,p]=(0,Jb.useState)(!1),[m,h]=(0,Jb.useState)(null),[g,_]=(0,Jb.useState)(!1),[v,b]=(0,Jb.useState)(!1),S=e.find(e=>e.value===m)?.feedbackConfig?.type,C=S===`accept`&&!u||S===`reject`&&!f,w=(0,Jb.useMemo)(()=>e.map(e=>{let{value:t,label:n,feedbackConfig:r}=e;if(!r)return{label:n,value:t};let{type:i,placeholder:a}=r,o=i===`accept`?u:f,c=i===`accept`?s:l,d=Xb[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),E=(0,Jb.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),Z(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),Z(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),Z(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),b(!0),Z(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),D=(0,Jb.useCallback)(n=>{let r=e.find(e=>e.value===n);if(!r)return;let a;if(r.feedbackConfig){let e=(r.feedbackConfig.type===`accept`?o:c).trim();e&&(a=e);let t={toolName:i?.toolName,isMcp:i?.isMcp??!1,has_instructions:!!e,instructions_length:e?.length??0,entered_feedback_mode:r.feedbackConfig.type===`accept`?g:v};r.feedbackConfig.type===`accept`?Z(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&Z(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);y((0,Jb.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>D(n.value));return t},[e,D]),{context:`Confirmation`});let O=(0,Jb.useCallback)(()=>{Z(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,Yb.jsxs)(x,{flexDirection:`column`,children:[typeof r==`string`?(0,Yb.jsx)(T,{children:r}):r,(0,Yb.jsx)(jd,{options:w,inlineDescriptions:!0,onChange:D,onCancel:O,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:E}),(0,Yb.jsx)(x,{marginTop:1,children:(0,Yb.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,C&&` · Tab to amend`]})})]})}var Jb,Yb,Xb,Zb=t((()=>{Jb=n(z(),1),B(),Pi(),X(),G(),Xt(),Yb=xe(),Xb={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));yh(),Ne(),B(),Gm(),af(),ad(),Cp(),Dy(),Vg(),Zb(),qv();function Qb({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=b(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Ay(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Qd.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Qd.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Qd.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Qd.platform}}),e.onReject(),n(),t()},[e,t,n]),l=ht(),u=ha(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:l})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[o,l,u]),f=(0,Q.useMemo)(()=>({toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Ug,{title:`Tool use`,children:[(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(T,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(T,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(T,{dimColor:!0,children:xp(e.description,3)})]}),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(Gv,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(qb,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function $b(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}Nd(),B();var ex={getConfig:e=>$b(e.file_path,e.old_string,e.new_string,e.replace_all),applyChanges:(e,t)=>{let n=t[0];return n?{...e,old_string:n.old_string,new_string:n.new_string,replace_all:n.replace_all}:e}};function tx(e){let t=e=>sc.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Eb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:L_(Pd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:N_(n)}),`?`]}),content:(0,$.jsx)(rb,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:ex})}B();function nx(e){let t=e.tool;if(`getPath`in t&&typeof t.getPath==`function`)try{return t.getPath(e.input)}catch{return null}return null}function rx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=b(),o=nx(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Eb,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(T,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:r}),`)`]})}),path:o,parseInput:e=>e,operationType:c?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(Qb,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}fd(),B(),Nl(),du();function ix({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>n?wc({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
30
- `)[0]??null;return(0,$.jsx)(x,{flexDirection:`column`,children:(0,$.jsx)(x,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?df(a.map(t=>(0,$.jsx)(Rs,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(yl,{code:t||`(No content)`,filePath:e})})})}B(),Nd(),Yd(),wf();var ax={getConfig:e=>{let t;try{t=rf(e.file_path)}catch(e){if(!Vd(e))throw e;t=``}return $b(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function ox(e){let t=e=>Ll.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:rf(n)}}catch(e){if(!Vd(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Eb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:L_(Pd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to `,o,` `,(0,$.jsx)(T,{bold:!0,children:N_(n)}),`?`]}),content:(0,$.jsx)(ix,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:ax})}B(),sf(),Nd(),Nl(),Kd(),du(),Nu();function sx(e){let t=(0,Q.useMemo)(()=>Wd().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>sp(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(cx,{...e,promise:t})})}function cx({notebook_path:e,cell_id:t,new_source:n,cell_type:r,edit_mode:i=`replace`,verbose:a,width:o,promise:s}){let c=(0,Q.use)(s),l=(0,Q.useMemo)(()=>{if(!c||!t)return``;let e=qo(t);if(e!==void 0){if(c.cells[e]){let t=c.cells[e].source;return Array.isArray(t)?t.join(``):t}return``}let n=c.cells.find(e=>e.id===t);return n?Array.isArray(n.source)?n.source.join(``):n.source:``},[c,t]),u=(0,Q.useMemo)(()=>!c||i===`insert`||i===`delete`?null:wc({filePath:e,fileContents:l,edits:[{old_string:l,new_string:n,replace_all:!1}],ignoreWhitespace:!1}),[c,e,l,n,i]),d;switch(i){case`insert`:d=`Insert new cell`;break;case`delete`:d=`Delete cell`;break;default:d=`Replace cell contents`}return(0,$.jsx)(x,{flexDirection:`column`,children:(0,$.jsxs)(x,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(x,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{bold:!0,children:a?e:L_(Pd(),e)}),(0,$.jsxs)(T,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(x,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(yl,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(x,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(yl,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?df(u.map(t=>(0,$.jsx)(Rs,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
31
- `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(yl,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}B(),Xf();function lx(e){let t=e=>{let t=ml.inputSchema.safeParse(e);return t.success?t.data:(Y(Error(`Failed to parse notebook edit input: ${t.error.message}`)),{notebook_path:``,new_source:``,cell_id:``})},n=t(e.toolUseConfirm.input),{notebook_path:r,edit_mode:i,cell_type:a}=n,o=a===`markdown`?`markdown`:`python`,s=i===`insert`?`insert this cell into`:i===`delete`?`delete this cell from`:`make this edit to`;return(0,$.jsx)(Eb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(T,{children:[`Do you want to `,s,` `,(0,$.jsx)(T,{bold:!0,children:N_(r)}),`?`]}),content:(0,$.jsx)(sx,{notebook_path:n.notebook_path,cell_id:n.cell_id,new_source:n.new_source,cell_type:n.cell_type,edit_mode:n.edit_mode,verbose:e.verbose,width:e.verbose?120:80}),path:r,completionType:`tool_use_single`,languageName:o,parseInput:t})}Cp(),Cl();async function ux(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||Go.has(t.toLowerCase()))return null;if(e.nameType===`cmdlet`)return t;if(e.elementTypes?.[0]!==`StringConstant`)return null;for(let t=0;t<e.args.length;t++){let n=e.elementTypes[t+1];if(n!==`StringConstant`&&n!==`Parameter`)return null}let n=t.toLowerCase(),r=await gy(n),i=await dy(t,e.args,r),a=0;for(let t of i.split(` `).slice(1)){if(t.includes(`\\`))return null;for(;a<e.args.length;){let n=e.args[a];if(n===t)break;if(n.startsWith(`-`)){if(a++,r?.options&&a<e.args.length&&e.args[a]!==t&&!e.args[a].startsWith(`-`)){let e=n.toLowerCase();r.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e)?.args&&a++}continue}return null}if(a>=e.args.length)return null;a++}return!i.includes(` `)&&(r?.subcommands?.length||oy[n])?null:i}async function dx(e,t){let n=await ys(e);if(!n.valid)return[];let r=Wc(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await ux(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await ux(e);n&&i.push(n)}if(i.length===0)return[];let a=new Map;for(let e of i){let t=e.split(` `)[0].toLowerCase(),n=a.get(t);n?n.push(e):a.set(t,[e])}let o=[];for(let[e,t]of a){let n=fx(t);(n===``?0:wp(n,` `)+1)<=1&&((await gy(e))?.subcommands?.length||oy[e])||o.push(n)}return o}function fx(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&i[a].toLowerCase()===t[a].toLowerCase();)a++;if(n=a,n===0)break}return t.slice(0,n).join(` `)}ad();function px({suggestions:e=[],onRejectFeedbackChange:t,onAcceptFeedbackChange:n,yesInputMode:r=!1,noInputMode:i=!1,editablePrefix:a,onEditablePrefixChange:o}){let s=[];if(r?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:n,allowEmptySubmitToCancel:!0}):s.push({label:`Yes`,value:`yes`}),ha()&&e.length>0){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`PowerShell`));if(a!==void 0&&o&&!t)s.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., Get-Process:*)`,initialValue:a,onChange:o,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else{let t=Pb(e,Em);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}B(),Pi(),X(),Gm(),Xt(),Vg(),qv();function mx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=fl.inputSchema.parse(t.input),[s]=b(),c=eb({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:h,setRejectFeedback:g,focusedOption:_,handleInputModeToggle:v,handleReject:y,handleFocus:S}=Ab({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[C,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(a.includes(`
32
- `)?void 0:a),O=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return dx(a,e=>cs(e,e.text)).then(t=>{e||O.current||t.length>0&&D(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let k=(0,Q.useCallback)(e=>{O.current=!0,D(e)},[]);Ay(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ee=(0,Q.useMemo)(()=>px({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:E,onEditablePrefixChange:k}),[t,l,u,E,k]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`});function j(e){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=Km(t.tool.name);if(e===`yes-prefix-edited`){let e=(E??``).trim();if(kb(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:fl.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();kb(`tool_use_single`,t,`accept`),Z(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{kb(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();Z(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),y(e||void 0);break}}}return(0,$.jsxs)(Ug,{title:`PowerShell command`,children:[(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:c.visible,children:fl.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(T,{dimColor:!0,children:t.description}),(0,$.jsx)(nb,{visible:c.visible,promise:c.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ly,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(x,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(Gv,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(T,{children:`Do you want to proceed?`}),(0,$.jsx)(jd,{options:ee,inlineDescriptions:!0,onChange:j,onCancel:()=>y(),onFocus:S,onInputModeToggle:v})]}),(0,$.jsxs)(x,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(_===`yes`&&!l||_===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Xf(),Ne(),B(),Gm(),af(),ad(),Dy(),Vg(),Zb(),qv();function hx(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=ma.inputSchema.safeParse(e);return t.success?t.data.skill:(Y(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),o=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;Ay(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=ht(),c=ha(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:a}),` in `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-exact`});let e=a.indexOf(` `);if(e>0){let n=a.substring(0,e);t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[a,s,c]),u=(0,Q.useMemo)(()=>({toolName:Km(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Qd.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Qd.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:hm,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Qd.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:hm,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Qd.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Qd.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Ug,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(T,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(T,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(Gv,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(qb,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}var gx=r({WorkflowPermissionRequest:()=>_x});function _x({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=b(),i=on(r),a=e.input,o=(0,vx.useMemo)(()=>ha(),[]),s=(0,vx.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,yx.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,yx.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,vx.useCallback)((r,i)=>{switch(r){case`yes`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,vx.useCallback)(()=>{Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,yx.jsx)(Ug,{title:`Workflow`,children:(0,yx.jsxs)(x,{flexDirection:`column`,gap:1,children:[(0,yx.jsxs)(x,{flexDirection:`column`,children:[(0,yx.jsxs)(T,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,yx.jsxs)(T,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,yx.jsx)(Gv,{permissionResult:e.permissionResult,toolType:`command`}),(0,yx.jsx)(qb,{options:s,onSelect:c,onCancel:l})]})})}var vx,yx,bx=t((()=>{vx=n(z(),1),B(),af(),ad(),Dy(),Vg(),Zb(),qv(),yx=xe()})),xx=r({MonitorPermissionRequest:()=>Sx});function Sx({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=b(),i=on(r),a=e.input,o=(0,Cx.useMemo)(()=>ha(),[]),s=(0,Cx.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,wx.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,wx.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,Cx.useCallback)((r,i)=>{switch(r){case`yes`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Ey({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Cx.useCallback)(()=>{Ey({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Qd.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,wx.jsx)(Ug,{title:`Monitor`,children:(0,wx.jsxs)(x,{flexDirection:`column`,gap:1,children:[(0,wx.jsxs)(x,{flexDirection:`column`,children:[(0,wx.jsx)(T,{bold:!0,color:i.permission,children:a.description}),(0,wx.jsx)(T,{dimColor:!0,children:xp(a.command,5)})]}),(0,wx.jsx)(Gv,{permissionResult:e.permissionResult,toolType:`command`}),(0,wx.jsx)(qb,{options:s,onSelect:c,onCancel:l})]})})}var Cx,wx,Tx=t((()=>{Cx=n(z(),1),B(),id(),af(),ad(),Cp(),Dy(),Vg(),Zb(),qv(),wx=xe()}));Pi(),Ls(),Fl(),$s(),nl(),ou(),_c(),Mn();var Ex=(ec(),e(Ro)).createWorkflowToolCore(),Dx=(bx(),e(gx)).WorkflowPermissionRequest,Ox=(Dn(),e(da)).MonitorTool,kx=(Tx(),e(xx)).MonitorPermissionRequest;function Ax(e){switch(e){case sc:return tx;case Ll:return ox;case Hs:return Rb;case fl:return mx;case ml:return lx;case uu:return Wb;case zr:return Bb;case ma:return hx;case Et:return ty;case Ex:return Dx??Qb;case Ox:return kx??Qb;case Tl:case us:case Gc:return rx;default:return Qb}}function jx(e){let t=e.tool.userFacingName(e.input);return e.tool===uu?`Claude Code needs your approval for the plan`:e.tool===zr?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function Mx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return A(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Iv(jx(e),`permission_prompt`),(0,$.jsx)(Ax(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Ys(),Da(),Xf(),Ps();async function Nx(e,t,n){let r=new Date,i=r.toISOString(),a=-r.getTimezoneOffset(),o=Math.floor(Math.abs(a)/60),s=Math.abs(a)%60,c=`${a>=0?`+`:`-`}${String(o).padStart(2,`0`)}:${String(s).padStart(2,`0`)}`,l=r.toLocaleDateString(`en-US`,{weekday:`long`}),u=Rm([`You are a date/time parser that converts natural language into ISO 8601 format.`,`You MUST respond with ONLY the ISO 8601 formatted string, with no explanation or additional text.`,`If the input is ambiguous, prefer future dates over past dates.`,`For times without dates, use today's date.`,`For dates without times, do not include a time component.`,`If the input is incomplete or you cannot confidently parse it into a valid date, respond with exactly "INVALID" (nothing else).`,`Examples of INVALID input: partial dates like "2025-01-", lone numbers like "13", gibberish.`,`Examples of valid natural language: "tomorrow", "next Monday", "jan 1st 2025", "in 2 hours", "yesterday".`]),d=`Current context:
33
- - Current date and time: ${i} (UTC)
34
- - Local timezone: ${c}
35
- - Day of week: ${l}
36
-
37
- User input: "${e}"
38
-
39
- Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
40
-
41
- Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await Mu({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Wt(Array.isArray(e.message.content)?e.message.content:[]).trim();return!t||t===`INVALID`||!/^\d{4}/.test(t)?{success:!1,error:`Unable to parse date/time from input`}:{success:!0,value:t}}catch(e){return Y(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function Px(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}je(),Bd(),Cp();var Fx=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function Ix(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function Lx(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function Rx(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function zx(e,t){let n=Lx(e).indexOf(t);return n>=0?Rx(e)[n]??t:t}function Bx(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function Vx(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function Hx(e,t){let n=Bx(e).indexOf(t);return n>=0?Vx(e)[n]??t:t}function Ux(e){if(Fx(e)){let[t,...n]=Bx(e);return t?De([t,...n]):we()}if(e.type===`string`){let t=Se();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Sp(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Sp(e.maxLength,`character`)}`})),e.format){case`email`:t=t.email({message:`Must be a valid email address, e.g. user@example.com`});break;case`uri`:t=t.url({message:`Must be a valid URI, e.g. https://example.com`});break;case`date`:t=t.date(`Must be a valid date, e.g. 2024-03-15, today, next Monday`);break;case`date-time`:t=t.datetime({offset:!0,message:`Must be a valid date-time, e.g. 2024-03-15T14:30:00Z, tomorrow at 3pm`});break;default:break}return t}if(e.type===`number`||e.type===`integer`){let t=e.type===`integer`?`an integer`:`a number`,n=e.type===`integer`,r=e=>Number.isInteger(e)&&!n?`${e}.0`:String(e),i=e.minimum!==void 0&&e.maximum!==void 0?`Must be ${t} between ${r(e.minimum)} and ${r(e.maximum)}`:e.minimum===void 0?e.maximum===void 0?`Must be ${t}`:`Must be ${t} <= ${r(e.maximum)}`:`Must be ${t} >= ${r(e.minimum)}`,a=Te({error:i});return e.type===`integer`&&(a=a.int({message:i})),e.minimum!==void 0&&(a=a.min(e.minimum,{message:i})),e.maximum!==void 0&&(a=a.max(e.maximum,{message:i})),a}if(e.type===`boolean`)return Oe();throw Error(`Unsupported schema: ${Jd(e)}`)}function Wx(e,t){let n=Ux(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function Gx(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function Kx(e,t,n){let r=Wx(e,t);if(r.isValid)return r;if(Gx(t)&&!Px(e)){let r=await Nx(e,t.format,n);if(r.success){let e=Wx(r.value,t);if(e.isValid)return e}}return r}u(),fd(),B(),Pi(),Cp(),jr(),xc();var qx=e=>[`string`,`number`,`integer`].includes(e.type),Jx=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,Yx=e=>(e+1)%10;function Xx(e){e.buffer=``,e.timer=void 0}function Zx(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,Yx);return()=>clearInterval(e)},[]),(0,$.jsx)(T,{color:`warning`,children:Jx[e]})}function Qx(e,t){try{let n=new Date(e);if(Number.isNaN(n.getTime()))return e;if((`format`in t?t.format:void 0)===`date-time`)return n.toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`});let r=e.split(`-`);return r.length===3?new Date(Number(r[0]),Number(r[1])-1,Number(r[2])).toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}):e}catch{return e}}function $x({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(tS,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(eS,{event:e,onResponse:t})}function eS({event:e,onResponse:t}){let{serverName:n,signal:r}=e,{message:i,requestedSchema:a}=e.params,o=Object.keys(a.properties).length>0,[s,c]=(0,Q.useState)(o?null:`accept`),[l,u]=(0,Q.useState)(()=>{let e={};if(a.properties)for(let[t,n]of Object.entries(a.properties))typeof n==`object`&&n&&n.default!==void 0&&(e[t]=n.default);return e}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(qx(n)&&n?.default!==void 0){let r=Wx(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,_]=(0,Q.useState)(o?0:void 0),[v,y]=(0,Q.useState)(()=>{let e=m[0];if(e&&qx(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[b,S]=(0,Q.useState)(v.length),[C,w]=(0,Q.useState)(()=>new Set),[E,D]=(0,Q.useState)(),[k,ee]=(0,Q.useState)(0),j=(0,Q.useRef)(void 0),M=(0,Q.useRef)(new Map),N=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{j.current!==void 0&&clearTimeout(j.current);let e=N.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of M.current.values())e.abort();M.current.clear()},[]);let{columns:te,rows:P}=de(),F=h===void 0?void 0:m[h],ne=F!==void 0&&qx(F.schema)&&!Fx(F.schema)&&!s;Vr(`elicitation`),Iv(`Claude Code needs your input`,`elicitation_dialog`);let re=(0,Q.useCallback)(e=>{if(e===void 0){y(``),S(0);return}let t=m[e];if(t&&qx(t.schema)&&!Fx(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);y(n),S(n.length)}},[m,l]);function I(e,t){if(!Ix(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?R(e,`Select at least ${i} ${Sp(i,`item`)}`):a!==void 0&&n.length>a?R(e,`Select at most ${a} ${Sp(a,`item`)}`):R(e)}function L(e){F&&Ix(F.schema)?(I(F.name,F.schema),D(void 0)):F&&Fx(F.schema)&&D(void 0),ne&&F&&(ae(F.name,F.schema,v),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),Gx(F.schema)&&v.trim()!==``&&f[F.name]&&se(F.name,F.schema,v));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(_(r),c(null),re(r)):(_(void 0),c(r===m.length?`accept`:`decline`),y(``))}function ie(e,t){u(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&R(e)}function R(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function z(e){e&&(ie(e,void 0),R(e),y(``),S(0))}function ae(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){z(e);return}if(r===``){l[e]!==void 0&&ie(e,``);return}let i=Wx(n,t);ie(e,i.isValid?i.value:n),R(e,i.isValid?void 0:i.error)}function se(e,t,n){if(!r)return;let i=M.current.get(e);i&&i.abort();let a=new AbortController;M.current.set(e,a),w(t=>new Set(t).add(e)),Kx(n,t,a.signal).then(t=>{if(M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){ie(e,t.value),R(e);let r=String(t.value);y(e=>e===n?(S(r.length),r):e)}else R(e,t.error)},()=>{M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n})})}function ce(e){if(y(e),F&&(ae(F.name,F.schema,e),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),Gx(F.schema)&&e.trim()!==``&&f[F.name])){let t=F.name,n=F.schema;j.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,j,se,t,n,e)}}function le(){L(`down`)}function ue(e,t,n){let r=N.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(Xx,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}A(`confirm:no`,()=>{if(ne&&F){let e=l[F.name];y(e===void 0?``:String(e)),S(0)}t(`cancel`)},{context:`Settings`,isActive:!!F&&!s&&!E}),oe((e,n)=>{if(ne&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(E&&F&&Ix(F.schema)){let t=F.schema,r=Lx(t),i=l[F.name]??[];if(n.leftArrow||n.escape){D(void 0),I(F.name,t);return}if(n.upArrow){k===0?(D(void 0),I(F.name,t)):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;ie(F.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||F.isRequired)?R(F.name,`Select at least ${a} ${Sp(a,`item`)}`):o!==void 0&&n.length>o?R(F.name,`Select at most ${o} ${Sp(o,`item`)}`):R(F.name)}return}if(n.return){let e=r[k];e!==void 0&&!i.includes(e)&&ie(F.name,[...i,e]),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>zx(t,e).toLowerCase()),ee);return}return}if(E&&F&&Fx(F.schema)){let t=F.schema,r=Bx(t);if(n.leftArrow||n.escape){D(void 0);return}if(n.upArrow){k===0?D(void 0):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0);return}if(n.return){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>Hx(t,e).toLowerCase()),ee);return}return}if(n.return&&s===`accept`){if(fe()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&R(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(_(t),c(null),re(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=N.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),L(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!F)return;let{schema:r,name:i}=F,o=l[i];if(r.type===`boolean`){if(e===` `){ie(i,o===void 0||!o);return}if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}if(e&&!n.return){ue(e,[`yes`,`no`],e=>ie(i,e===0));return}return}if(Fx(r)||Ix(r)){if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}let t,a=0;if(Fx(r)){let e=Bx(r);t=e.map(e=>Hx(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=Lx(r).map(e=>zx(r,e).toLowerCase());if(n.rightArrow){D(i),ee(a);return}if(e&&!n.leftArrow){ue(e,t,e=>{D(i),ee(e)});return}return}if(n.backspace&&ne&&v===``){z(i);return}},{isActive:!0});function fe(){let e=a.required||[];for(let t of e){let e=l[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let pe=Math.max(2,Math.floor((P-14)/3)),me=(0,Q.useMemo)(()=>{let e=m.length;if(e<=pe)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(pe/2)),r=Math.min(n+pe,e);return n=Math.max(0,r-pe),{start:n,end:r}},[m.length,pe,h]),B=me.start>0,he=me.end<m.length;function ge(){return m.length?(0,$.jsxs)(x,{flexDirection:`column`,children:[B&&(0,$.jsx)(x,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowUp,` `,me.start,` more above`]})}),m.slice(me.start,me.end).map((e,t)=>{let n=me.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=C.has(r)?(0,$.jsx)(Zx,{}):p?(0,$.jsx)(T,{color:`error`,children:d.warning}):u?(0,$.jsx)(T,{color:`success`,dimColor:!o,children:d.tick}):a?(0,$.jsx)(T,{color:`error`,children:`*`}):(0,$.jsx)(T,{children:` `}),g=p?`error`:u?`success`:a?`error`:`suggestion`,_=o?g:void 0,y=(0,$.jsx)(T,{color:_,bold:o,children:i.title||r}),w,D=null;if(Ix(i)){let e=Lx(i),t=c??[];if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(x,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=zx(i,e),a=t.includes(e),o=n===k;return(0,$.jsxs)(x,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:o?d.pointer:` `}),(0,$.jsx)(T,{color:a?`success`:void 0,children:a?d.checkboxOn:d.checkboxOff}),(0,$.jsx)(T,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:t.map(e=>zx(i,e)).join(`, `)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(Fx(i)){let e=Bx(i);if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(x,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=Hx(i,e),r=c===e,a=t===k;return(0,$.jsxs)(x,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:a?d.pointer:` `}),(0,$.jsx)(T,{color:r?`success`:void 0,children:r?d.radioOn:d.radioOff}),(0,$.jsx)(T,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:Hx(i,c)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(T,{color:_,bold:!0,children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,children:d.checkboxOff}):u?(0,$.jsx)(T,{children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});else if(qx(i))if(o)w=(0,$.jsx)(lu,{value:v,onChange:ce,onSubmit:le,placeholder:`Type something…`,columns:Math.min(te-20,60),cursorOffset:b,onChangeCursorOffset:S,focus:!0,showCursor:!0});else{let e=u&&Gx(i)?Qx(String(c),i):String(c);w=u?(0,$.jsx)(T,{children:e}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(T,{children:String(c)}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(x,{gap:1,children:[(0,$.jsx)(T,{color:g,children:o?d.pointer:` `}),m,(0,$.jsxs)(x,{children:[y,(0,$.jsx)(T,{color:_,children:`: `}),w]})]}),D,i.description&&(0,$.jsx)(x,{marginLeft:6,children:(0,$.jsx)(T,{dimColor:!0,children:i.description})}),(0,$.jsx)(x,{marginLeft:6,height:1,children:p?(0,$.jsx)(T,{color:`error`,italic:!0,children:p}):(0,$.jsx)(T,{children:` `})})]},r)}),he&&(0,$.jsx)(x,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowDown,` `,m.length-me.end,` more below`]})})]}):null}return(0,$.jsx)(ve,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!F||!!s)&&!E,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(eu,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(g,{shortcut:`↑↓`,action:`navigate`}),F&&(0,$.jsx)(g,{shortcut:`Backspace`,action:`unset`}),F&&F.schema.type===`boolean`&&(0,$.jsx)(g,{shortcut:`Space`,action:`toggle`}),F&&Fx(F.schema)&&(E?(0,$.jsx)(g,{shortcut:`Space`,action:`select`}):(0,$.jsx)(g,{shortcut:`→`,action:`expand`})),F&&Ix(F.schema)&&(E?(0,$.jsx)(g,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(g,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(x,{flexDirection:`column`,children:[ge(),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{color:`success`,children:s===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:s===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function tS({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,l]=(0,Q.useState)(`prompt`),u=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Iv(`Claude Code needs your input`,`elicitation_url_dialog`),Vr(`elicitation-url`),u.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let _=``,v=``,y=``;try{_=new URL(s).hostname;let e=s.indexOf(_);v=s.slice(0,e),y=s.slice(e+_.length)}catch{_=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let b=(0,Q.useCallback)(()=>{Wl(s),t(`accept`),l(`waiting`),u.current=`waiting`,p(`open`)},[t,s]);if(oe((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?b():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?Wl(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ve,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(eu,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(g,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(x,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{color:`success`,children:f===`open`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(T,{color:`success`,children:f===`action`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:`error`,children:f===`cancel`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ve,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(eu,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(g,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(x,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{color:`success`,children:f===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:f===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}B(),Pi(),Xt(),Vg();function nS({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){A(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Ug,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(T,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(x,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(jd,{options:a,onChange:e=>{r(e)}})})})}Ua();function rS(){return(0,Q.useSyncExternalStore)(ao,Fa)}Xf(),je(),pu(),Me();var iS=`at_mentioned`,aS=Ae(()=>ke({method:Ee(iS),params:ke({filePath:Se(),lineStart:Ce().optional(),lineEnd:Ce().optional()})}));function oS(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=dl(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(aS(),e=>{if(n.current===r)try{let n=e.params,r=n.lineStart===void 0?void 0:n.lineStart+1,i=n.lineEnd===void 0?void 0:n.lineEnd+1;t({filePath:n.filePath,lineStart:r,lineEnd:i})}catch(e){Y(e)}})},[e,t])}Ig(),Rg(),l_();function sS(e){return(0,Q.useMemo)(()=>{let t=e?.find(e=>e.name===`ide`);if(!t)return{status:null,ideName:null};let n=t.config,r=n.type===`sse-ide`||n.type===`ws-ide`?n.ideName:null;return t.type===`connected`?{status:`connected`,ideName:r}:t.type===`pending`?{status:`pending`,ideName:r}:{status:`disconnected`,ideName:r}},[e])}mg();function cS(){let[e,t]=(0,Q.useState)({...la});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return xi.add(e),()=>{xi.delete(e)}},[]),e}B();function lS({ideSelection:e,mcpClients:t}){let{status:n}=sS(t),r=n===`connected`&&(e?.filePath||e?.text&&e.lineCount>0);if(n===null||!r||!e)return null;if(e.text&&e.lineCount>0)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,N_(e.filePath)]},`selection-indicator`)}function uS(){return(0,Q.useSyncExternalStore)(ja.subscribe,ja.getState)}B(),Ga();function dS({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Rr(e,t),a=uS();if(!r||a)return null;let o=Dr(),s=wa(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(x,{flexDirection:`row`,children:o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(T,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}B(),sa();function fS(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=yr(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!na.isSandboxingEnabled())return;let e=na.getSandboxViolationStore(),r=e.getTotalCount(),i=e.subscribe(()=>{let i=e.getTotalCount(),a=i-r;a>0&&(t(a),r=i,n.current&&clearTimeout(n.current),n.current=setTimeout(t,5e3,0))});return()=>{i(),n.current&&clearTimeout(n.current)}},[]),!na.isSandboxingEnabled()||e===0?null:(0,$.jsx)(x,{paddingX:0,paddingY:0,children:(0,$.jsxs)(T,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}qa(),X(),G(),B(),Zl(),sg(),_p(),pu(),Ps(),jr();var pS=5e3;function mS({apiKeyStatus:e,autoUpdaterResult:t,debug:n,isAutoUpdating:r,verbose:i,messages:a,onAutoUpdaterResult:o,onChangeIsUpdating:s,ideSelection:c,mcpClients:l,isInputWrapped:u=!1,isNarrow:d=!1}){let f=(0,Q.useMemo)(()=>Xu(Jn(a)),[a]),p=pg(),m=Rr(f,p).isAboveWarningThreshold,{status:h}=sS(l),g=K(e=>e.notifications),{addNotification:_,removeNotification:v}=Xn(),y=cS();(0,Q.useEffect)(()=>(ti((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>ti(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,S=Pp(),C=S===`team`||S===`enterprise`,w=cg(),E=u&&!m&&e!==`invalid`&&e!==`missing`&&w!==void 0;return(0,Q.useEffect)(()=>{E&&w?(Z(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(eu,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${ac(w)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[E,w,_,v]),(0,$.jsx)(x,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(hS,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:C,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function hS({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:o,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(!Op())return;let e=setInterval(e=>{let t=Np(),n=t>=1e4?mp(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]),K(e=>e.isBriefOnly),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(lS,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(T,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(T,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(x,{children:(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(x,{children:[(0,$.jsxs)(T,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(x,{children:(0,$.jsx)(T,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(x,{children:(0,$.jsx)(T,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(x,{children:(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),(0,$.jsx)(dS,{tokenUsage:l,model:u}),(0,$.jsx)(fS,{})]})}qa(),jr(),B();var gS=10,_S=null,vS=0,yS;async function bS(e,t){let n=Math.ceil(e/gS)*gS;if(_S&&vS>=n&&yS===t)return _S;_S&&await _S,vS=n,yS=t,_S=(async()=>{let e=[],n=0;for await(let r of wi())if(!(t&&gr(r.display)!==t)&&(e.push(r),n++,n>=vS))break;return e})();try{return await _S}finally{_S=null,vS=0,yS=void 0}}function xS(e,t,n,r,i){let[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(void 0),l=(0,Q.useRef)(!1),{addNotification:u,removeNotification:d}=Xn(),f=(0,Q.useRef)([]),p=(0,Q.useRef)(void 0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(void 0),g=(0,Q.useRef)(t),_=(0,Q.useRef)(n),v=(0,Q.useRef)(i);g.current=t,_.current=n,v.current=i;let y=(0,Q.useCallback)((t,n,i,a=!1)=>{e(t,n,i),r?.(a?0:t.length)},[e,r]),b=(0,Q.useCallback)((e,t=!1)=>{if(!e||!e.display)return;let n=gr(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(eu,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:pS})},[u]);return{historyIndex:a,setHistoryIndex:o,onHistoryUp:(0,Q.useCallback)(()=>{let e=m.current;m.current++;let t=g.current,n=_.current,r=v.current;if(e===0){h.current=r===`bash`?r:void 0;let e=t.trim()!==``;c(e?{display:t,pastedContents:n,mode:r}:void 0)}let i=h.current;(async()=>{let t=e+1;if(p.current!==i&&(f.current=[],p.current=i,m.current=0),f.current.length<t){let e=await bS(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),b(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,x())})()},[b,x]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),b(f.current[e-2]);else if(e===1)if(m.current=0,o(0),s){let e=s.mode;e?y(s.display,e,s.pastedContents??{}):b(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,b,y]),resetHistory:(0,Q.useCallback)(()=>{c(void 0),o(0),m.current=0,h.current=void 0,d(`search-history-hint`),f.current=[],p.current=void 0},[d]),dismissSearchHint:(0,Q.useCallback)(()=>{d(`search-history-hint`)},[d])}}G();function SS(){let e=K(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(js).filter(e=>e.agentType!==`main-session`).filter(e=>e.isBackgrounded!==!1).filter(e=>e.evictAfter===void 0||e.evictAfter>t).sort((e,t)=>e.startTime-t.startTime)},[e])}$i(),Lt(),B(),Pi();function CS(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(`prompt`),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(void 0),E=(0,Q.useRef)(void 0),D=(0,Q.useRef)(new Set),O=(0,Q.useRef)(null),k=(0,Q.useCallback)(()=>{E.current&&(E.current.return(void 0),E.current=void 0)},[]),j=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),v(0),x(`prompt`),C({}),T(void 0),k(),D.current.clear()},[c,k]),M=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){k(),D.current.clear(),T(void 0),m(!1),n(h),r(_),a(b),l(S);return}if(e||(k(),E.current=Dc(),D.current.clear()),E.current)for(;;){if(t?.aborted)return;let e=await E.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!D.current.has(i)){D.current.add(i),T(e.value),m(!1),a(gr(i)),n(i),l(e.value.pastedContents);let t=Qr(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,k,n,r,a,l,h,_,b,S]),N=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),x(o),C(u),E.current=Dc(),D.current.clear()},[c,t,i,o,u]),te=(0,Q.useCallback)(()=>{M(!0)},[M]),P=(0,Q.useCallback)(()=>{if(w){let e=gr(w.display);n(Qr(w.display)),a(e),l(w.pastedContents)}else l(S);j()},[w,n,a,l,S,j]),F=(0,Q.useCallback)(()=>{n(h),r(_),l(S),j()},[n,r,l,h,_,S,j]),ne=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:S});else if(w){let t=gr(w.display),n=Qr(w.display);a(t),e({display:n,pastedContents:w.pastedContents})}j()},[d,w,e,a,h,S,j]);A(`history:search`,N,{context:`Global`,isActive:!s}),y((0,Q.useMemo)(()=>({"historySearch:next":te,"historySearch:accept":P,"historySearch:cancel":F,"historySearch:execute":ne}),[te,P,F,ne]),{context:`HistorySearch`,isActive:s});let re=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),F())};oe((e,t,n)=>{re(new ee(n.keypress))},{isActive:s});let I=(0,Q.useRef)(M);return I.current=M,(0,Q.useEffect)(()=>{O.current?.abort();let e=new AbortController;return O.current=e,I.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:w,historyFailedMatch:p,handleKeyDown:re}}function wS({maxBufferSize:e,debounceMs:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(-1),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null),c=(0,Q.useCallback)((l,u,d={})=>{let f=Date.now();if(s.current&&(clearTimeout(s.current),s.current=null),f-o.current<t){s.current=setTimeout(c,t,l,u,d);return}o.current=f,r(t=>{let n=i>=0?t.slice(0,i+1):t,r=n[n.length-1];if(r&&r.text===l)return n;let a=[...n,{text:l,cursorOffset:u,pastedContents:d,timestamp:f}];return a.length>e?a.slice(-e):a}),a(t=>{let r=t>=0?t+1:n.length;return Math.min(r,e-1)})},[t,e,i,n.length]),l=(0,Q.useCallback)(()=>{if(i<0||n.length===0)return;let e=Math.max(0,i-1),t=n[e];if(t)return a(e),t},[n,i]),u=(0,Q.useCallback)(()=>{r([]),a(-1),o.current=0,s.current&&(clearTimeout(s.current),s.current=null)},[o,s]);return{pushToBuffer:c,undo:l,canUndo:i>0&&n.length>1,clearBuffer:u}}B(),X(),G();function TS({inputValue:e,isAssistantResponding:t}){let n=K(e=>e.promptSuggestion),r=as(),i=j(),{text:a,promptId:o,shownAt:s,acceptedAt:c,generationRequestId:l}=n,u=t||e.length>0?null:a,d=a&&s>0,f=(0,Q.useRef)(0),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(0);s>0&&s!==m.current?(m.current=s,p.current=i,f.current=0):s===0&&(m.current=0),e.length>0&&f.current===0&&d&&(f.current=Date.now());let h=(0,Q.useCallback)(()=>{vc(r),r(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[r]);return{suggestion:u,markAccepted:(0,Q.useCallback)(()=>{d&&r(e=>({...e,promptSuggestion:{...e.promptSuggestion,acceptedAt:Date.now()}}))},[d,r]),markShown:(0,Q.useCallback)(()=>{r(e=>e.promptSuggestion.shownAt!==0||!e.promptSuggestion.text?e:{...e,promptSuggestion:{...e.promptSuggestion,shownAt:Date.now()}})},[r]),logOutcomeAtSubmission:(0,Q.useCallback)((e,t)=>{if(!d)return;let n=c>s,r=n||e===a,i=r&&c||Date.now();Z(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100,...process.env.USER_TYPE===`ant`&&{suggestion:a,userInput:e}}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}Mc(),q(),xh();var ES=15,DS=1e3,OS=[`|`,`||`,`&&`,`;`];function kS(e){return typeof e==`object`&&!!e&&`op`in e&&OS.includes(e.op)}function AS(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function jS(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function MS(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&kS(n)}function NS(e,t){let n=e.slice(0,t),r=n.match(/\$[a-zA-Z_][a-zA-Z0-9_]*$/);if(r)return{prefix:r[0],completionType:`variable`};let i=qm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:AS(t)}}let a=jS(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&kS(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=AS(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=MS(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function PS(e,t){return t===`variable`?`compgen -v ${Jm([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${Jm([e])} 2>/dev/null | head -${ES} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${Jm([e])} 2>/dev/null`}function FS(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${Jm([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${Jm([e])}*(N[1,${ES}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${Jm([e])}*]} 2>/dev/null`}async function IS(e,t,n,r){let i;if(e===`bash`)i=PS(t,n);else if(e===`zsh`)i=FS(t,n);else return[];return(await(await Bt(i,r,`bash`,{timeout:DS})).result).stdout.split(`
42
- `).filter(e=>e.trim()).slice(0,ES).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function LS(e,t,n){let r=Sh();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=NS(e,t);return i?(await IS(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return J(`Shell completion failed: ${e}`),[]}}r_(),vo();var RS=/[:_-]/g,zS=null;function BS(e){if(zS?.commands===e)return zS.fuse;let t=new d_(e.filter(e=>!e.isHidden).map(e=>{let t=Oo(e),n=t.split(RS).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>QS(e)).filter(Boolean),partKey:n.length>1?n:void 0,commandName:t,command:e,aliasKey:e.aliases}}),{includeScore:!0,threshold:.3,location:0,distance:100,keys:[{name:`commandName`,weight:3},{name:`partKey`,weight:2},{name:`aliasKey`,weight:2},{name:`descriptionKey`,weight:.5}]});return zS={commands:e,fuse:t},t}function VS(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function HS(e,t){if(e.startsWith(`/`))return null;let n=e.slice(0,t).match(/\s\/([a-zA-Z0-9_:-]*)$/);if(!n||n.index===void 0)return null;let r=n.index+1,i=e.slice(r+1).match(/^[a-zA-Z0-9_:-]*/),a=i?i[0]:``;return t>r+1+a.length?null:{token:`/`+a,startPos:r,partialCommand:a}}function US(e,t){if(!e)return null;let n=XS(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!VS(t.metadata))continue;let n=Oo(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function WS(e){return e.startsWith(`/`)}function GS(e){return!(!WS(e)||!e.includes(` `)||e.endsWith(` `))}function KS(e){return`/${e} `}function qS(e){let t=Oo(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function JS(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function YS(e,t){let n=Oo(e),r=t?` (${t})`:``,i=e.type===`prompt`&&e.kind===`workflow`,a=e.type===`prompt`&&!i&&(e.source===`projectSettings`||e.source===`localSettings`)?`local`:void 0,o=(i?e.description:ir(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:qS(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function XS(e,t){if(!WS(e)||GS(e))return[];let n=e.slice(1).toLowerCase().trim();if(n===``){let e=t.filter(e=>!e.isHidden),n=[],r=e.filter(e=>e.type===`prompt`).map(e=>({cmd:e,score:Vc(Oo(e))})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score);for(let e of r.slice(0,5))n.push(e.cmd);let i=new Set(n.map(e=>qS(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(qS(e))||(e.type===`local`||e.type===`local-jsx`?a.push(e):e.type===`prompt`&&(e.source===`userSettings`||e.source===`localSettings`)?o.push(e):e.type===`prompt`&&e.source===`projectSettings`?s.push(e):e.type===`prompt`&&e.source===`policySettings`?c.push(e):l.push(e))});let u=(e,t)=>Oo(e).localeCompare(Oo(t));return a.sort(u),o.sort(u),s.sort(u),c.sort(u),l.sort(u),[...n,...a,...o,...s,...c,...l].map(e=>YS(e))}let r=t.find(e=>e.isHidden&&Oo(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&Oo(e).toLowerCase()===n)&&(r=void 0);let i=BS(t).search(n).map(e=>({r:e,name:e.item.commandName.toLowerCase(),aliases:e.item.aliasKey?.map(e=>e.toLowerCase())??[],usage:e.item.command.type===`prompt`?Vc(Oo(e.item.command)):0})).sort((e,t)=>{let r=e.name,i=t.name,a=e.aliases,o=t.aliases,s=r===n,c=i===n;if(s&&!c)return-1;if(c&&!s)return 1;let l=a.some(e=>e===n),u=o.some(e=>e===n);if(l&&!u)return-1;if(u&&!l)return 1;let d=r.startsWith(n),f=i.startsWith(n);if(d&&!f)return-1;if(f&&!d)return 1;if(d&&f&&r.length!==i.length)return r.length-i.length;let p=a.find(e=>e.startsWith(n)),m=o.find(e=>e.startsWith(n));if(p&&!m)return-1;if(m&&!p)return 1;if(p&&m&&p.length!==m.length)return p.length-m.length;let h=(e.r.score??0)-(t.r.score??0);return Math.abs(h)>.1?h:t.usage-e.usage}).map(e=>{let t=e.r.item.command;return YS(t,JS(n,t.aliases))});if(r){let e=qS(r);if(!i.some(t=>t.id===e))return[YS(r),...i]}return i}function ZS(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Ta(o,n):void 0;else{if(!VS(e.metadata))return;o=Oo(e.metadata),s=e.metadata}let c=KS(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function QS(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function $S(e){let t=[],n=/(^|[\s])(\/[a-zA-Z][a-zA-Z0-9:\-_]*)/g,r=null;for(;(r=n.exec(e))!==null;){let e=r[1]??``,n=r[2]??``,i=r.index+e.length;t.push({start:i,end:i+n.length})}return t}tg(),Lt(),q();var eC=null,tC=0,nC=6e4;async function rC(){let e=Date.now();if(eC&&e-tC<nC)return eC;let t=[],n=new Set;try{for await(let e of wi()){if(e.display&&e.display.startsWith(`!`)){let r=e.display.slice(1).trim();r&&!n.has(r)&&(n.add(r),t.push(r))}if(t.length>=50)break}}catch(e){J(`Failed to read shell history: ${e}`)}return eC=t,tC=e,t}function iC(e){if(!eC)return;let t=eC.indexOf(e);t!==-1&&eC.splice(t,1),eC.unshift(e)}async function aC(e){if(!e||e.length<2||!e.trim())return null;let t=await rC();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}hh(),q(),Me(),rt(),Bd();var oC=`slack_search_channels`,sC=new Map,cC=new Set,lC=0,uC=bt(),dC=uC.subscribe,fC=null,pC=null;function mC(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function hC(e,t){let n=mC(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:oC,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?vC(_C(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
43
- `))):[]}catch(e){return J(`Failed to fetch Slack channels: ${e}`),[]}}var gC=Ae(()=>ke({results:Se()}));function _C(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=gC().safeParse(Fd(t));if(e.success)return e.data.results}catch{}return e}function vC(e){let t=[],n=new Set;for(let r of e.split(`
44
- `)){let e=r.match(/^Name:\s*#?([a-z0-9][a-z0-9_-]{0,79})\s*$/);e&&!n.has(e[1])&&(n.add(e[1]),t.push(e[1]))}return t}function yC(e){return mC(e)!==void 0}function bC(){return lC}function xC(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!cC.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function SC(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function CC(e,t){let n,r=0;for(let[i,a]of sC)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function wC(e,t){if(!t)return[];let n=SC(t),r=t.toLowerCase(),i=sC.get(n)??CC(n,r);if(!i)if(fC===n&&pC)i=await pC;else{fC=n,pC=hC(e,n),i=await pC,sC.set(n,i);let t=cC.size;for(let e of i)cC.add(e);cC.size!==t&&(lC++,uC.emit()),sC.size>50&&sC.delete(sC.keys().next().value),fC===n&&(fC=null,pC=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}r_(),hg(),H(),_p(),Xf();function TC(e){switch(e.type){case`file`:return{id:`file-${e.path}`,displayText:e.displayText,description:e.description};case`mcp_resource`:return{id:`mcp-resource-${e.server}__${e.uri}`,displayText:e.displayText,description:e.description};case`agent`:return{id:`agent-${e.agentType}`,displayText:e.displayText,description:e.description,color:e.color}}}var EC=15,DC=60;function OC(e){return gp(e,DC)}function kC(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:OC(e.whenToUse),agentType:e.agentType,color:ua(e.agentType)}));if(!t)return n;let r=t.toLowerCase();return n.filter(e=>e.agentType.toLowerCase().includes(r)||e.displayText.toLowerCase().includes(r))}catch(e){return Y(e),[]}}async function AC(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([gg(e,r),Promise.resolve(kC(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:N_(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:OC(e.description||e.name||e.uri),server:e.server,uri:e.uri,name:e.name||e.uri}));if(!e)return[...o,...s,...a].slice(0,EC).map(TC);let c=[...s,...a],l=[];for(let e of o)l.push({source:e,score:e.score??.5});if(c.length>0){let t=new d_(c,{includeScore:!0,threshold:.6,keys:[{name:`displayText`,weight:2},{name:`name`,weight:3},{name:`server`,weight:1},{name:`description`,weight:1},{name:`agentType`,weight:3}]}).search(e,{limit:EC});for(let e of t)l.push({source:e.item,score:e.score??.5})}return l.sort((e,t)=>e.score-t.score),l.slice(0,EC).map(e=>e.source).map(TC)}qa(),B(),X(),vo(),$i(),Da(),ni(),Pi(),Un(),G(),_p(),Ac(),hg();var jC=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,MC=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,NC=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,PC=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,FC=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,IC=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function LC(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function RC(e,t,n){if(n.length===0)return-1;if(t<0)return 0;let r=e[t];if(!r)return 0;let i=n.findIndex(e=>e.id===r.id);return i>=0?i:0}function zC(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function BC(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function VC(e){let{displayText:t,mode:n,hasAtPrefix:r,needsQuotes:i,isQuoted:a,isComplete:o}=e,s=o?` `:``;return a||i?n===`bash`?`"${t}"${s}`:`@"${t}"${s}`:r?n===`bash`?`${t}${s}`:`@${t}${s}`:t}function HC(e,t,n,r,i,a){let o=t.slice(0,n).lastIndexOf(` `)+1,s;s=a===`variable`?`$`+e.displayText+` `:a===`command`?e.displayText+` `:e.displayText,r(t.slice(0,o)+s+t.slice(n)),i(o+s.length)}var UC=/(^|\s)@[\w-]*$/;function WC(e,t,n,r,i,a){let o=t.slice(0,n).match(r);if(!o||o.index===void 0)return;let s=o.index+(o[1]?.length??0),c=t.slice(0,s);i(c+e.displayText+` `+t.slice(n)),a(c.length+e.displayText.length+1)}var GC=null;async function KC(e,t){try{return GC&&GC.abort(),GC=new AbortController,await LS(e,t,GC.signal)}catch{return Z(`tengu_shell_completion_failed`,{}),[]}}function qC(e,t,n,r,i){let a=i?`/`:` `,o=e.slice(0,n),s=e.slice(n+r),c=`@`+t+a;return{newInput:o+c+s,cursorPos:o.length+c.length}}function JC(e,t,n=!1){if(!e)return null;let r=e.substring(0,t);if(n){let n=r.match(/@"([^"]*)"?$/);if(n&&n.index!==void 0){let r=e.substring(t).match(/^[^"]*"?/),i=r?r[0]:``;return{token:n[0]+i,startPos:n.index,isQuoted:!0}}}if(n){let n=r.lastIndexOf(`@`);if(n>=0&&(n===0||/\s/.test(r[n-1]))){let i=r.substring(n),a=i.match(jC);if(a&&a[0].length===i.length){let r=e.substring(t).match(MC),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?NC:PC,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(MC),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function YC(e){if(WS(e)){let t=e.indexOf(` `);return t===-1?{commandName:e.slice(1),args:``}:{commandName:e.slice(1,t),args:e.slice(t+1)}}return null}function XC(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function ZC({commands:e,onInputChange:t,onSubmit:n,setCursorOffset:r,input:i,cursorOffset:a,mode:o,agents:s,setSuggestionsState:c,suggestionsState:{suggestions:l,selectedSuggestion:u,commandArgumentHint:d},suppressSuggestions:f=!1,markAccepted:p,onModeChange:m}){let{addNotification:h}=Xn(),g=yr(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,v]=(0,Q.useState)(`none`),b=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=Oo(e);return t?t.length:0}))+6},[e]),[x,S]=(0,Q.useState)(void 0),C=K(e=>e.mcp.resources),w=Cd(),E=K(e=>e.promptSuggestion),D=K(e=>!!e.viewingAgentTaskId),O=te(),[k,A]=(0,Q.useState)(void 0),j=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=HS(i,a);if(!t)return;let n=US(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),N=f?void 0:o===`prompt`?j:k,P=(0,Q.useRef)(a);P.current=a;let F=(0,Q.useRef)(null),ne=(0,Q.useRef)(``),re=(0,Q.useRef)(``),I=(0,Q.useRef)(``),L=(0,Q.useRef)(``),ie=(0,Q.useRef)(l);ie.current=l;let R=(0,Q.useRef)(null),z=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),S(void 0),A(void 0)},[c]),ae=(0,Q.useCallback)(async(e,t=!1)=>{F.current=e;let n=await AC(e,C,s,t);if(F.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),S(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),S(void 0)}},[C,c,v,S,s]);(0,Q.useEffect)(()=>(yg(),_g(()=>{let e=F.current;e!==null&&(F.current=null,ae(e,e===``))})),[ae]);let se=ye(ae,50),ce=ye((0,Q.useCallback)(async e=>{L.current=e;let t=await wC(w.getState().mcp.clients,e);L.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),S(void 0))},[c]),150),le=(0,Q.useCallback)(async(t,n)=>{let r=n??P.current;if(f){se.cancel(),z();return}if(o===`prompt`){let n=HS(t,r);if(n&&US(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),S(void 0);return}}if(o===`bash`&&t.trim()){I.current=t;let e=await aC(t);if(I.current!==t)return;if(e){A({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),S(void 0);return}else A(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=w.getState(),n=[],r=new Set;for(let[i,a]of t.agentNameRegistry){if(r.has(i)||!i.toLowerCase().startsWith(e))continue;let o=t.tasks[a]?.status;n.push({id:`dm-${i}`,displayText:`@${i}`,description:o?`send message · ${o}`:`send message`})}if(n.length>0){se.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),S(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(IC);if(e&&yC(w.getState().mcp.clients)){ce(e[2]);return}else _===`slack-channel`&&(ce.cancel(),z())}let a=t.substring(0,r).match(FC),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&WS(t)&&r>0){let e=YC(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){se.cancel(),z();return}let n=await ng(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}se.cancel(),z();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await nd(t,{limit:10})).map(e=>{let t=sn(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:pp(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}z();return}}let l=t.substring(0,r);if(o===`prompt`&&WS(l)&&r>0&&!XC(s,l)){let t;if(l.length>1){let n=l.indexOf(` `),r=n===-1?l.slice(1):l.slice(1,n),i=n!==-1&&l.slice(n+1).trim().length>0,a=n!==-1&&l.length===n+1;if(n!==-1){let o=e.find(e=>{let t=Oo(e);return t&&t===r});if(o||i){if(o?.argumentHint&&a)t=o.argumentHint;else if(o?.type===`prompt`&&o.argNames?.length&&l.endsWith(` `)){let e=di(l.slice(n+1));t=Vt(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),S(void 0);return}}}let n=XS(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),v(n.length>0?`command`:`none`),n.length>0&&S(b);return}if(_===`command`?(se.cancel(),z()):WS(l)&&XC(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&z(),_===`agent`&&ie.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||z()),a&&o!==`bash`){let e=JC(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=BC(e);if($h(t)){re.current=t;let e=await eg(t,{maxResults:10});if(re.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:RC(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(F.current===t)return;se(t,!0);return}}if(_===`file`){let e=JC(t,r,!0);if(e){let t=BC(e);if(F.current===t)return;se(t,!1)}else se.cancel(),z()}if(_===`shell`){let e=ie.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(se.cancel(),z())}},[_,e,c,z,se,ce,o,f,b]);(0,Q.useEffect)(()=>{R.current!==i&&(ne.current!==i&&(ne.current=i,F.current=null),R.current=null,le(i))},[i,le]);let ue=(0,Q.useCallback)(async()=>{if(N){if(o===`bash`){t(N.fullCommand),r(N.fullCommand.length),A(void 0);return}let e=HS(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=n+`/`+N.fullCommand+` `+a,s=e.startPos+1+N.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){se.cancel(),ce.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${Oo(e)} `;t(n+i.slice(a)),r(n.length)}z()}}else if(_===`custom-title`&&l.length>0){if(n){let e=zC(n);t(e),r(e.length),z()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=WS(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=LC(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),LC(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),le(o,o.length)):z()}else{let e=JC(i,a,!0)??JC(i,a,!1);if(e){let a=LC(n.metadata)&&n.metadata.type===`directory`,s=qC(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),le(o,s.cursorPos)):z()}else z()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;HC(n,i,a,t,r,e?.completionType),z()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(WC(n,i,a,UC,t,r),z())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(WC(n,i,a,IC,t,r),z())}else if(_===`file`&&l.length>0){let n=JC(i,a,!0);if(!n){z();return}let s=vg(l),c=n.token.startsWith(`@`),u;if(u=n.isQuoted?n.token.slice(2).replace(/"$/,``).length:c?n.token.length-1:n.token.length,s.length>u){let e=VC({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});bg(e,i,n.token,n.startPos,t,r),le(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);bg(VC({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),z()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await KC(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;HC(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=JC(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await AC(e?t.token.substring(1):t.token,C,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:RC(e.suggestions,e.selectedSuggestion,n)})),v(e),S(void 0))}},[l,u,i,_,e,o,t,r,n,z,a,le,C,c,s,se,ce,N]),de=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(ZS(s,!0,e,t,r,n),se.cancel(),z());else if(_===`custom-title`&&u<l.length){if(s){let e=zC(s);t(e),r(e.length),n(e,!0),se.cancel(),z()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;HC(e,i,a,t,r,n?.completionType),se.cancel(),z()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))WC(s,i,a,UC,t,r),se.cancel(),z();else if(_===`slack-channel`&&u<l.length)s&&(WC(s,i,a,IC,t,r),ce.cancel(),z());else if(_===`file`&&u<l.length){let e=JC(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);bg(VC({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),se.cancel(),z()}}else if(_===`directory`&&u<l.length&&s){if(WS(i)){se.cancel(),z();return}let e=JC(i,a,!0)??JC(i,a,!1);if(e){let n=LC(s.metadata)&&s.metadata.type===`directory`,a=qC(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}se.cancel(),z()}},[l,u,_,e,i,a,o,t,r,n,z,se,ce]),fe=(0,Q.useCallback)(()=>{ue()},[ue]),pe=(0,Q.useCallback)(()=>{se.cancel(),ce.cancel(),z(),R.current=i},[se,ce,z,i]),me=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),B=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),he=(0,Q.useMemo)(()=>({"autocomplete:accept":fe,"autocomplete:dismiss":pe,"autocomplete:previous":me,"autocomplete:next":B}),[fe,pe,me,B]),ge=l.length>0||!!N,V=Ya();Vr(`autocomplete`,ge),M(`Autocomplete`,ge),y(he,{context:`Autocomplete`,isActive:ge&&!V});function _e(e){let n=gr(e);if(n!==`prompt`&&m){m(n);let i=Qr(e);t(i),r(i.length)}else t(e),r(e.length)}let ve=e=>{if(e.key===`right`&&!D){let t=E.text,n=E.shownAt;if(t&&n>0&&i===``){p(),_e(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||N)return;let t=E.text,n=E.shownAt;if(t&&n>0&&i===``&&!D){e.preventDefault(),p(),_e(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=O?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),B();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),me();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),de())};return oe((e,t,n)=>{let r=new ee(n.keypress);ve(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:x,commandArgumentHint:d,inlineGhostText:N,handleKeyDown:ve}}Tg();var QC={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function $C(e){return e in QC}en();function ew(e){switch(e.mode){case`default`:return`acceptEdits`;case`acceptEdits`:return`plan`;case`plan`:return`auto`;case`auto`:return e.isBypassPermissionsModeAvailable?`bypassPermissions`:`default`;case`bypassPermissions`:return`default`;case`dontAsk`:return`default`;default:return`default`}}function tw(e){let t=ew(e);return{nextMode:t,context:Di(e.mode,t,e)}}Uh();var nw=f_();Ne(),ei(),Da(),B(),Pi(),G(),Mf();function rw({onDone:e}){Vr(`bridge-dialog`);let t=K(e=>e.replBridgeConnected),n=K(e=>e.replBridgeSessionActive),r=K(e=>e.replBridgeReconnecting),i=K(e=>e.replBridgeConnectUrl),a=K(e=>e.replBridgeSessionUrl),o=K(e=>e.replBridgeError),s=K(e=>e.replBridgeExplicit),c=K(e=>e.replBridgeEnvironmentId),l=K(e=>e.replBridgeSessionId),u=K(e=>e.verbose),d=as(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=N_(ht());(0,Q.useEffect)(()=>{Lf().then(_).catch(()=>{})},[]);let b=n?a:i;(0,Q.useEffect)(()=>{if(!f||!b){h(``);return}(0,nw.toString)(b,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,b]),y({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),oe(t=>{t===`d`&&(s&&Af(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:S,color:C}=_r({error:o,connected:t,sessionActive:n,reconnecting:r}),w=o?`×`:ef,E=m?m.split(`
45
- `).filter(e=>e.length>0):[],D=[];v&&D.push(v),g&&D.push(g);let O=D.length>0?` · `+D.join(` · `):``,k=o?li:b?n?_i(b):Bn(b):void 0;return(0,$.jsx)(ve,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(x,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:C,children:[w,` `,S]}),(0,$.jsx)(T,{dimColor:!0,children:O})]}),o&&(0,$.jsx)(T,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(T,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(T,{dimColor:!0,children:[`Session: `,l]})]}),f&&E.length>0&&(0,$.jsx)(x,{flexDirection:`column`,children:E.map((e,t)=>(0,$.jsx)(T,{children:e},t))}),k&&(0,$.jsx)(T,{dimColor:!0,children:k}),(0,$.jsx)(T,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}B(),Da(),fd(),B(),Nd(),sg(),_p(),$r(),Da(),Lt(),fd(),B(),_p(),Sg(),Da(),hg(),fd(),B(),Nd(),sg(),_p(),Wo(),B(),Pi(),jr(),ea();function iw({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=Vh(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Claude will think before responding`},{value:`false`,label:`Disabled`,description:`Claude will respond without extended thinking`}];A(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),A(`confirm:yes`,()=>{a!==null&&t(a)},{context:`Confirmation`,isActive:a!==null});function c(n){let i=n===`true`;r&&i!==e?o(i):t(i)}return(0,$.jsxs)(_e,{color:`permission`,children:[(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsxs)(x,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(T,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(x,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(jd,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(x,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(T,{color:`warning`,children:`Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results, set this at the start of a session.`}),(0,$.jsx)(T,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(T,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(O,{children:[(0,$.jsx)(g,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(eu,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(g,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(eu,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}oh(),Zr(),__(),h_();function aw(e,t,n){let r=t;for(let t=0;t<n;t++){let t=ow(e,r);if(t.equals(r))break;r=t}return r}function ow(e,t){switch(e){case`h`:return t.left();case`l`:return t.right();case`j`:return t.downLogicalLine();case`k`:return t.upLogicalLine();case`gj`:return t.down();case`gk`:return t.up();case`w`:return t.nextVimWord();case`b`:return t.prevVimWord();case`e`:return t.endOfVimWord();case`W`:return t.nextWORD();case`B`:return t.prevWORD();case`E`:return t.endOfWORD();case`0`:return t.startOfLogicalLine();case`^`:return t.firstNonBlankInLogicalLine();case`$`:return t.endOfLogicalLine();case`G`:return t.startOfLastLine();default:return t}}function sw(e){return`eE$`.includes(e)}function cw(e){return`jkG`.includes(e)||e===`gg`}var lw={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function uw(e,t,n,r){if(n===`w`)return dw(e,t,r,zo);if(n===`W`)return dw(e,t,r,e=>!tc(e));let i=lw[n];if(i){let[n,a]=i;return n===a?fw(e,t,n,r):pw(e,t,n,a,r)}return null}function dw(e,t,n,r){let i=[];for(let{segment:t,index:n}of lp().segment(e))i.push({segment:t,index:n});let a=i.length-1;for(let n=0;n<i.length;n++){let r=i[n],o=n+1<i.length?i[n+1].index:e.length;if(t>=r.index&&t<o){a=n;break}}let o=e=>i[e]?.segment??``,s=t=>t<i.length?i[t].index:e.length,c=e=>tc(o(e)),l=e=>r(o(e)),u=e=>dc(o(e)),d=a,f=a;if(l(a)){for(;d>0&&l(d-1);)d--;for(;f<i.length&&l(f);)f++}else if(c(a)){for(;d>0&&c(d-1);)d--;for(;f<i.length&&c(f);)f++;return{start:s(d),end:s(f)}}else if(u(a)){for(;d>0&&u(d-1);)d--;for(;f<i.length&&u(f);)f++}if(!n){if(f<i.length&&c(f))for(;f<i.length&&c(f);)f++;else if(d>0&&c(d-1))for(;d>0&&c(d-1);)d--}return{start:s(d),end:s(f)}}function fw(e,t,n,r){let i=e.lastIndexOf(`
46
- `,t-1)+1,a=e.indexOf(`
47
- `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function pw(e,t,n,r,i){let a=0,o=-1;for(let i=t;i>=0;i--)if(e[i]===r&&i!==t)a++;else if(e[i]===n){if(a===0){o=i;break}a--}if(o===-1)return null;a=0;let s=-1;for(let t=o+1;t<e.length;t++)if(e[t]===n)a++;else if(e[t]===r){if(a===0){s=t;break}a--}return s===-1?null:i?{start:o+1,end:s}:{start:o,end:s+1}}ol(),up(),Cp();function mw(e,t,n,r){let i=aw(t,r.cursor,n);if(i.equals(r.cursor))return;let a=Ew(r.cursor,i,t,e,n);Ow(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function hw(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new Gs(i.cursor.measuredText,a),s=Dw(i.cursor,o,t);Ow(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function gw(e,t,n,r,i){let a=uw(i.text,i.cursor.offset,n,t===`inner`);a&&(Ow(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function _w(e,t,n){let r=n.text,i=r.split(`
48
- `),a=wp(r.slice(0,n.cursor.offset),`
49
- `),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
50
- `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
51
- `)||(l+=`
52
- `),n.setRegister(l,!0),e===`yank`)n.setOffset(s);else if(e===`delete`){let e=s,t=c;t===r.length&&e>0&&r[e-1]===`
53
- `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(cp(i).length||1));n.setOffset(Math.min(e,a))}else if(e===`change`)if(i.length===1)n.setText(``),n.enterInsert(0);else{let e=i.slice(0,a),t=i.slice(a+o),r=[...e,``,...t].join(`
54
- `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function vw(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.cursor;for(let t=0;t<e&&!r.isAtEnd();t++)r=r.right();let i=r.offset,a=t.text.slice(n,i),o=t.text.slice(0,n)+t.text.slice(i);t.setRegister(a,!1),t.setText(o);let s=Math.max(0,o.length-(cp(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function yw(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=dp(i.slice(r)).length||1;i=i.slice(0,r)+e+i.slice(r+t),r+=e.length}n.setText(i),n.setOffset(Math.max(0,r-e.length)),n.recordChange({type:`replace`,char:e,count:t})}function bw(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.text,i=n,a=0;for(;i<r.length&&a<e;){let e=dp(r.slice(i)),t=e.length,n=e===e.toUpperCase()?e.toLowerCase():e.toUpperCase();r=r.slice(0,i)+n+r.slice(i+t),i+=n.length,a++}t.setText(r),t.setOffset(i),t.recordChange({type:`toggleCase`,count:e})}function xw(e,t){let n=t.text.split(`
55
- `),{line:r}=t.cursor.getPosition();if(r>=n.length-1)return;let i=Math.min(e,n.length-r-1),a=n[r],o=a.length;for(let e=1;e<=i;e++){let t=(n[r+e]??``).trimStart();t.length>0&&(!a.endsWith(` `)&&a.length>0&&(a+=` `),a+=t)}let s=[...n.slice(0,r),a,...n.slice(r+i+1)],c=s.join(`
56
- `);t.setText(c),t.setOffset(Tw(s,r)+o),t.recordChange({type:`join`,count:e})}function Sw(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
57
- `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
58
- `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
59
- `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
60
- `);n.setText(u),n.setOffset(Tw(l,o))}else{let r=a.repeat(t),i=e&&n.cursor.offset<n.text.length?n.cursor.measuredText.nextOffset(n.cursor.offset):n.cursor.offset,o=n.text.slice(0,i)+r+n.text.slice(i),s=cp(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function Cw(e,t,n){let r=n.text.split(`
61
- `),{line:i}=n.cursor.getPosition(),a=Math.min(t,r.length-i);for(let t=0;t<a;t++){let n=i+t,a=r[n]??``;if(e===`>`)r[n]=` `+a;else if(a.startsWith(` `))r[n]=a.slice(2);else if(a.startsWith(` `))r[n]=a.slice(1);else{let e=0,t=0;for(;t<a.length&&e<2&&/\s/.test(a[t]);)e++,t++;r[n]=a.slice(t)}}let o=r.join(`
62
- `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(Tw(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function ww(e,t){let n=t.text.split(`
63
- `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
64
- `);t.setText(o),t.enterInsert(Tw(a,i)),t.recordChange({type:`openLine`,direction:e})}function Tw(e,t){return e.slice(0,t).join(`
65
- `).length+ +(t>0)}function Ew(e,t,n,r,i){let a=Math.min(e.offset,t.offset),o=Math.max(e.offset,t.offset),s=!1;if(r===`change`&&(n===`w`||n===`W`)){let t=e;for(let e=0;e<i-1;e++)t=n===`w`?t.nextVimWord():t.nextWORD();let r=n===`w`?t.endOfVimWord():t.endOfWORD();o=e.measuredText.nextOffset(r.offset)}else if(cw(n)){s=!0;let t=e.text,n=t.indexOf(`
66
- `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
67
- `&&--a):o=n+1}else sw(n)&&e.offset<=t.offset&&(o=e.measuredText.nextOffset(o));return a=e.snapOutOfImageRef(a,`start`),o=e.snapOutOfImageRef(o,`end`),{from:a,to:o,linewise:s}}function Dw(e,t,n){let r=Math.min(e.offset,t.offset),i=Math.max(e.offset,t.offset);return{from:r,to:e.measuredText.nextOffset(i)}}function Ow(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
68
- `)&&(a+=`
69
- `),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(cp(e).length||1));r.setOffset(Math.min(t,i))}else if(e===`change`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e),r.enterInsert(t)}}function kw(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Ew(n.cursor,r,`G`,e,t);Ow(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function Aw(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Ew(n.cursor,r,`gg`,e,t);Ow(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var jw={d:`delete`,c:`change`,y:`yank`};function Mw(e){return e in jw}var Nw=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),Pw=new Set([`f`,`F`,`t`,`T`]),Fw={i:`inner`,a:`around`};function Iw(e){return e in Fw}var Lw=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),Rw=1e4;function zw(){return{mode:`INSERT`,insertedText:``}}function Bw(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function Vw(e,t,n){switch(e.type){case`idle`:return Ww(t,n);case`count`:return Gw(e,t,n);case`operator`:return Kw(e,t,n);case`operatorCount`:return qw(e,t,n);case`operatorFind`:return Jw(e,t,n);case`operatorTextObj`:return Yw(e,t,n);case`find`:return Xw(e,t,n);case`g`:return Zw(e,t,n);case`operatorG`:return Qw(e,t,n);case`replace`:return $w(e,t,n);case`indent`:return eT(e,t,n)}}function Hw(e,t,n){return Mw(e)?{next:{type:`operator`,op:jw[e],count:t}}:Nw.has(e)?{execute:()=>{let r=aw(e,n.cursor,t);n.setOffset(r.offset)}}:Pw.has(e)?{next:{type:`find`,find:e,count:t}}:e===`g`?{next:{type:`g`,count:t}}:e===`r`?{next:{type:`replace`,count:t}}:e===`>`||e===`<`?{next:{type:`indent`,dir:e,count:t}}:e===`~`?{execute:()=>bw(t,n)}:e===`x`?{execute:()=>vw(t,n)}:e===`J`?{execute:()=>xw(t,n)}:e===`p`||e===`P`?{execute:()=>Sw(e===`p`,t,n)}:e===`D`?{execute:()=>mw(`delete`,`$`,1,n)}:e===`C`?{execute:()=>mw(`change`,`$`,1,n)}:e===`Y`?{execute:()=>_w(`yank`,t,n)}:e===`G`?{execute:()=>{t===1?n.setOffset(n.cursor.startOfLastLine().offset):n.setOffset(n.cursor.goToLine(t).offset)}}:e===`.`?{execute:()=>n.onDotRepeat?.()}:e===`;`||e===`,`?{execute:()=>tT(e===`,`,t,n)}:e===`u`?{execute:()=>n.onUndo?.()}:e===`i`?{execute:()=>n.enterInsert(n.cursor.offset)}:e===`I`?{execute:()=>n.enterInsert(n.cursor.firstNonBlankInLogicalLine().offset)}:e===`a`?{execute:()=>{let e=n.cursor.isAtEnd()?n.cursor.offset:n.cursor.right().offset;n.enterInsert(e)}}:e===`A`?{execute:()=>n.enterInsert(n.cursor.endOfLogicalLine().offset)}:e===`o`?{execute:()=>ww(`below`,n)}:e===`O`?{execute:()=>ww(`above`,n)}:null}function Uw(e,t,n,r){return Iw(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:Fw[n]}}:Pw.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:Nw.has(n)?{execute:()=>mw(e,n,t,r)}:n===`G`?{execute:()=>kw(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function Ww(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:Hw(e,1,t)||{}}function Gw(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),Rw))}}}return Hw(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function Kw(e,t,n){return t===e.op[0]?{execute:()=>_w(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:Uw(e.op,e.count,t,n)||{next:{type:`idle`}}}function qw(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),Rw);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return Uw(e.op,i,t,n)||{next:{type:`idle`}}}function Jw(e,t,n){return{execute:()=>hw(e.op,e.find,t,e.count,n)}}function Yw(e,t,n){return Lw.has(t)?{execute:()=>gw(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function Xw(e,t,n){return{execute:()=>{let r=n.cursor.findCharacter(t,e.find,e.count);r!==null&&(n.setOffset(r),n.setLastFind(e.find,t))}}}function Zw(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=aw(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
70
- `),r=Math.min(e.count-1,t.length-1),i=0;for(let e=0;e<r;e++)i+=(t[e]?.length??0)+1;n.setOffset(i)}}:{execute:()=>n.setOffset(n.cursor.startOfFirstLine().offset)}:{next:{type:`idle`}}}function Qw(e,t,n){return t===`j`||t===`k`?{execute:()=>mw(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>Aw(e.op,e.count,n)}:{next:{type:`idle`}}}function $w(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>yw(t,e.count,n)}}function eT(e,t,n){return t===e.dir?{execute:()=>Cw(e.dir,e.count,n)}:{next:{type:`idle`}}}function tT(e,t,n){let r=n.getLastFind();if(!r)return;let i=r.type;e&&(i={f:`F`,F:`f`,t:`T`,T:`t`}[i]);let a=n.cursor.findCharacter(r.char,i,t);a!==null&&n.setOffset(a)}ol(),up();function nT(e){let t=Q.useRef(zw()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(Bw()),a=Bu({...e,inputFilter:void 0}),{onModeChange:o,inputFilter:s}=e,c=(0,Q.useCallback)(e=>{e!==void 0&&a.setOffset(e),t.current={mode:`INSERT`,insertedText:``},r(`INSERT`),o?.(`INSERT`)},[a,o]),l=(0,Q.useCallback)(()=>{let n=t.current;n.mode===`INSERT`&&n.insertedText&&(i.current.lastChange={type:`insert`,text:n.insertedText});let s=a.offset;s>0&&e.value[s-1]!==`
71
- `&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=Gs.fromText(e.value,e.columns,a.offset),r=u(n,!0);switch(t.type){case`insert`:if(t.text){let r=n.insert(t.text);e.onChange(r.text),a.setOffset(r.offset)}break;case`x`:vw(t.count,r);break;case`replace`:yw(t.char,t.count,r);break;case`toggleCase`:bw(t.count,r);break;case`indent`:Cw(t.dir,t.count,r);break;case`join`:xw(t.count,r);break;case`openLine`:ww(t.direction,r);break;case`operator`:mw(t.op,t.motion,t.count,r);break;case`operatorFind`:hw(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:gw(t.op,t.scope,t.objType,t.count,r);break}}function f(n,r){let i=t.current,o=s?s(n,r):n,c=i.mode===`INSERT`?o:n,f=Gs.fromText(e.value,e.columns,a.offset);if(r.ctrl){a.onInput(c,r);return}if(r.escape&&i.mode===`INSERT`){l();return}if(r.escape&&i.mode===`NORMAL`){t.current={mode:`NORMAL`,command:{type:`idle`}};return}if(r.return){a.onInput(c,r);return}if(i.mode===`INSERT`){r.backspace||r.delete?i.insertedText.length>0&&(t.current={mode:`INSERT`,insertedText:i.insertedText.slice(0,-(cp(i.insertedText).length||1))}):t.current={mode:`INSERT`,insertedText:i.insertedText+c},a.onInput(c,r);return}if(i.mode!==`NORMAL`)return;if(i.command.type===`idle`&&(r.upArrow||r.downArrow||r.leftArrow||r.rightArrow)){a.onInput(c,r);return}let p={...u(f,!1),onUndo:e.onUndo,onDotRepeat:d},m=i.command.type===`idle`||i.command.type===`count`||i.command.type===`operator`||i.command.type===`operatorCount`,h=c;r.leftArrow?h=`h`:r.rightArrow?h=`l`:r.upArrow?h=`k`:r.downArrow?h=`j`:m&&r.backspace?h=`h`:m&&i.command.type!==`count`&&r.delete&&(h=`x`);let g=Vw(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}L(),B();function rT(e){let[t]=b(),n=j();La(n,!!e.onImagePaste);let r=nT({value:e.value,onChange:e.onChange,onSubmit:e.onSubmit,onExit:e.onExit,onExitMessage:e.onExitMessage,onHistoryReset:e.onHistoryReset,onHistoryUp:e.onHistoryUp,onHistoryDown:e.onHistoryDown,onClearInput:e.onClearInput,focus:e.focus,mask:e.mask,multiline:e.multiline,cursorChar:e.showCursor?` `:``,highlightPastedText:e.highlightPastedText,invert:n?ge.inverse:e=>e,themeText:ce(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(x,{flexDirection:`column`,children:(0,$.jsx)(Zo,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Lm(),jn(),Dh(),qg(),s();function iT(e){if(!e)return null;let t=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;return t===0?null:Math.round(e.cache_read_input_tokens/t*100)}function aT(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function oT(e){let t=H_(`sha256`).update(e).digest(`hex`).slice(0,16);return B_(o(),`cache-stats`,`${t}.json`)}var sT={version:1,signature:null,lastResetAt:null,lastHitRate:null};function cT(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&(t.signature===null||typeof t.signature==`string`)&&(t.lastResetAt===null||typeof t.lastResetAt==`number`)&&(t.lastHitRate===null||typeof t.lastHitRate==`number`)}async function lT(e){try{let t=await Z_(e,`utf8`),n=JSON.parse(t);return cT(n)?n:{...sT}}catch{return{...sT}}}async function uT(e,t){await X_(z_(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await $_(n,JSON.stringify(t),`utf8`),await Q_(n,e)}catch{}}var dT={signature:null,lastResetAt:null,lastHitRate:null},fT=null;async function pT(e){fT=e;let t=await lT(oT(e));dT={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function mT(e){let t=aT(e),n=iT(e);return t!==dT.signature&&(dT={signature:t,lastResetAt:Date.now(),lastHitRate:n},fT!==null&&uT(oT(fT),{version:1,signature:t,lastResetAt:dT.lastResetAt,lastHitRate:n})),{...dT}}function hT(){return{...dT}}B(),_p(),fd();function gT(e){let t=e-Date.now()/1e3;if(t<=0)return`now`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>=1?`${n}d${r}h`:r>=1?`${r}h${i}m`:`${i}m`}function _T(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function vT({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=de(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${hp(n)}/${hp(r)}`;return(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(_T,{}),(0,$.jsx)(T,{dimColor:!0,children:`Context `}),(0,$.jsxs)(T,{children:[t,`%`]}),!d&&(0,$.jsxs)(T,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_T,{}),(0,$.jsx)(T,{dimColor:!0,children:`Session `}),(0,$.jsxs)(T,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,gT(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_T,{}),(0,$.jsx)(T,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(T,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,gT(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_T,{}),(0,$.jsx)(T,{children:gs(i)})]})]})}var yT=Q.memo(vT);X(),G(),Ne(),qa(),Es(),mg(),ll(),B(),pn(),Mf(),Rp(),Nd(),q(),xd(),Ps(),Gp(),Ac(),Po(),_p();var bT=3600*1e3;function xT(e){return String(Math.floor(e)).padStart(2,`0`)}function ST(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${xT(t)}:${xT(n)}`}function CT({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=oc(e),o=(0,Q.useRef)(null);if(a!==null){let e=aT(a);e!==o.current&&(o.current=e,mT(a))}let{lastResetAt:s,lastHitRate:c}=hT(),l=s===null?null:t-s,u=l===null?null:bT-l,d=l===null?null:l/6e4,f=u!==null&&u<=0;(0,Q.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=d!==null&&d>=55&&!f;(0,Q.useEffect)(()=>{if(!p){i(!0);return}let e=setInterval(()=>i(e=>!e),500);return()=>clearInterval(e)},[p]);let m=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{m.current||(m.current=!0,pT(pt()))},[]);let h=a===null?c:iT(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:ST(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:` Cache `}),(0,$.jsx)(T,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(T,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function wT(){let{getGoal:t,formatGoalStatusLabel:n}=(ia(),e(os)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?hp(r.tokensUsed):`${hp(r.tokensUsed)}/${hp(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(T,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(T,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(T,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(T,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(T,{children:o})}return(0,$.jsxs)(T,{children:[s,(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{dimColor:!0,children:i}),(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{children:a})]})}function TT(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function ET(e,t,n,r,i,a,o){let s=Qe(),c=cn(),l=nm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=oc(r),f=Hp(l,st()),p=kp(d,f),m=cl(pt()),h=Tn(),g={...h.five_hour&&{five_hour:{used_percentage:h.five_hour.utilization*100,resets_at:h.five_hour.resets_at}},...h.seven_day&&{seven_day:{used_percentage:h.seven_day.utilization*100,resets_at:h.seven_day.resets_at}}};return{...Vn(),...m&&{session_name:m},model:{id:l,display_name:Vp(l)},workspace:{current_dir:Pd(),project_dir:ht(),added_dirs:i},version:`0.0.8`,output_style:{name:u},cost:{total_cost_usd:qe(),total_duration_ms:dt(),total_api_duration_ms:vt(),total_lines_added:ut(),total_lines_removed:Ge()},context_window:{total_input_tokens:Pe(),total_output_tokens:Ke(),context_window_size:f,current_usage:d,used_percentage:p.used,remaining_percentage:p.remaining},exceeds_200k_tokens:t,...(g.five_hour||g.seven_day)&&{rate_limits:g},...Wg()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...Fe()&&{remote:{session_id:pt()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function DT(e){return Ha(e)?.uuid??null}function OT({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=K(e=>e.toolPermissionContext.mode),a=K(e=>e.toolPermissionContext.additionalWorkingDirectories),o=K(e=>e.statusLineText),s=as(),c=mc(),{addNotification:l}=Xn(),u=pg(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let g=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),v=(0,Q.useRef)(void 0),y=(0,Q.useRef)(!0),b=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=y.current;if(y.current=!1,d.current?.statusLine?.command)try{let e=g.current.exceeds200kTokens,r=DT(n);r!==g.current.messageId&&(e=Il(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Ns(ET(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),S=(0,Q.useCallback)(()=>{v.current!==void 0&&clearTimeout(v.current),v.current=setTimeout((e,t)=>{e.current=void 0,t()},300,v,b)},[b]);(0,Q.useEffect)(()=>{(t!==g.current.messageId||i!==g.current.permissionMode||n!==g.current.vimMode||u!==g.current.mainLoopModel)&&(g.current.permissionMode=i,g.current.vimMode=n,g.current.mainLoopModel=u,S())},[t,i,n,u,S]);let C=c?.statusLine?.command,w=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(w.current){w.current=!1;return}y.current=!0,b()},[C,b]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(Z(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&J(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Pf()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),J(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(b(),()=>{r.current?.abort(),v.current!==void 0&&clearTimeout(v.current)}),[]);let E=c?.statusLine?.padding??0,D=nm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),O=Hp(D,st()),k=oc(e.current),ee=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,A=k?Math.round(kp(k,O).used??0):0,j=Tn(),M={...j.five_hour&&{five_hour:{utilization:j.five_hour.utilization,resets_at:j.five_hour.resets_at}},...j.seven_day&&{seven_day:{utilization:j.seven_day.utilization,resets_at:j.seven_day.resets_at}}},N=c?.statusLineEnabled===!0,te=!!c?.statusLine?.command;return(0,$.jsxs)(x,{flexDirection:`column`,paddingX:E,children:[N&&(0,$.jsxs)(x,{gap:2,children:[(0,$.jsx)(yT,{modelName:Vp(D),contextUsedPct:A,usedTokens:ee,contextWindowSize:O,totalCostUsd:qe(),rateLimits:M}),(0,$.jsx)(wT,{}),(0,$.jsx)(CT,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(_,{children:o})}):te&&Ts()?(0,$.jsx)(T,{children:` `}):null]})}var kT=(0,Q.memo)(OT);u(),G(),kt(),Xa(),B();function AT({tasksSelected:e,onOpenDialog:t}){let n=K(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>pc(e)&&!(process.env.USER_TYPE===`ant`&&Eu(e))),[n]);return m_(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jT,{selected:e,onClick:t,children:Aa(r)}),er(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function jT({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(T,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(x,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}B(),xc();function MT({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(x,{gap:1,children:[(0,$.jsx)(T,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(lu,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:v(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Vf(),Bf(),Bd();var NT=5e3;function PT(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function FT(){if(!await zf())return null;let[e,t]=await Promise.all([Lf(),If()]);if(e===t)return null;let{stdout:n,code:r}=await Hf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:NT,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Fd(n);return e.headRefName===t||e.headRefName===`main`||e.headRefName===`master`||e.state===`MERGED`||e.state===`CLOSED`?null:{number:e.number,url:e.url,reviewState:PT(e.isDraft,e.reviewDecision)}}catch{return null}}Ne();var IT=6e4,LT=4e3,RT=60*6e4,zT={number:null,url:null,reviewState:null,lastUpdated:0};function BT(e,t=!0){let[n,r]=(0,Q.useState)(zT),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(0);return(0,Q.useEffect)(()=>{if(!t||a.current)return;let e=!1,n=-1,s=Date.now();async function c(){if(e)return;let t=Be();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=RT)return;let l=Date.now(),u=await FT();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>LT){a.current=!0;return}e||(i.current=setTimeout(c,IT))}}let l=Date.now()-o.current;return l>=IT?c():i.current=setTimeout(c,IT-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),qg(),Un(),Sf(),sl(),kt(),sf(),__(),G(),Ne(),fd(),_p(),Wu(),Mf(),np(),Nr();var VT=(jm(),e(Mm)),HT=e=>()=>{},UT=()=>null,WT=5e3,GT=1e3;function KT(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{function e(){let e=process.memoryUsage().rss/(1024*1024),n=e>=1024?`error`:e>=512?`warning`:`normal`,r=fp(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,WT);return()=>clearInterval(n)},[]),e}function qT(){let e=(0,Q.useSyncExternalStore)(VT?.subscribeToProactiveChanges??HT,VT?.getNextTickAt??UT,UT),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(T,{dimColor:!0,children:[`waiting `,mp(t*1e3,{mostSignificantOnly:!0})]})}function JT(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),GT);return()=>clearInterval(e)},[]);let r=(ia(),e(os)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(T,{color:d,children:[`goal (`,u,`)`]})}function YT({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(T,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=Wg()&&t===`INSERT`&&!l;return(0,$.jsxs)(x,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(MT,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(XT,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function XT({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=yr(`chat:cycleMode`,`Chat`,`shift+tab`),u=K(e=>e.tasks),f=Cd(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=BT(i,QT()),h=K(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(VT?.subscribeToProactiveChanges??HT,VT?.getNextTickAt??UT,UT),v=I(),y=ue().getState,b=_!==null,S=(0,Q.useMemo)(()=>tf(Object.values(u),e=>pc(e)&&!(process.env.USER_TYPE===`ant`&&Eu(e))),[u]),C=kn(),E=C!==void 0&&C.length>0,D=yr(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=yr(`app:toggleTodos`,`Global`,`ctrl+t`),ee=yr(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),A=K(e=>e.notifications.current?.key===`kill-agents-confirm`),j=KT();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let M=n?.mode,N=!lf(M),te=S>0,P=+!!N+ +!!te,F=QT()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&P<2&&(P===0||c>=80),ne=P<2,re=M&&N&&!Fe()?(0,$.jsxs)(T,{color:Xd(M),children:[nf(M),` `,cf(M).toLowerCase(),` on`,ne&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(g,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,L=[...p?[(0,$.jsx)(w,{url:p,children:(0,$.jsxs)(T,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&h?[(0,$.jsx)(TungstenPill,{selected:o},`tmux`)]:[],...F?[(0,$.jsx)(tu,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...j?[(0,$.jsxs)(T,{dimColor:j.level===`normal`,color:j.level===`error`?`error`:j.level===`warning`?`warning`:void 0,children:[j.text,` · pid:`,process.pid]},`rss`)]:[],...(ia(),e(os)).getGoal()?[(0,$.jsx)(JT,{},`goal-elapsed`)]:[]],ie=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),R=r?ZT(i,D,k,ee,E,ie,A):[];b?L.push((0,$.jsx)(qT,{},`proactive`)):r&&L.push(...R);let z=te&&!m_(u,!1)?(0,$.jsx)(AT,{tasksSelected:a,onOpenDialog:s}):null;L.length===0&&!z&&!re&&r&&L.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=jf().copyOnSelect??!0,oe=v&&(!ae||se());if(Ts()&&oe){let e=tp()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);L.push((0,$.jsx)(T,{dimColor:!0,children:(0,$.jsxs)(O,{children:[!ae&&(0,$.jsx)(g,{shortcut:`ctrl+c`,action:`copy`}),se()&&(t?(0,$.jsx)(T,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(g,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return z&&r&&L.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(g,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(g,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),L.length===0&&!z&&!re?Ts()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(x,{height:1,overflow:`hidden`,children:[re&&(0,$.jsxs)(x,{flexShrink:0,children:[re,(z||L.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(x,{flexShrink:0,children:[z,L.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),L.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:L})})]})}function ZT(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(g,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(g,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(g,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function QT(){return jf().prStatusFooterEnabled??!0}ei(),ll(),fd(),B(),Da(),G(),Wu(),rg(),Kg();function $T({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:b,mcpClients:S,isPasting:C=!1,isInputWrapped:w=!1,messages:T,isSearching:E,historyQuery:D,setHistoryQuery:O,historyFailedMatch:k,onOpenTasksDialog:ee}){let A=mc(),{columns:j,rows:M}=de(),N=(0,Q.useRef)(T);N.current=T;let te=(0,Q.useMemo)(()=>DT(T),[T]),P=j<80,F=Ts(),ne=F&&M<24,re=_,I=h||TT(A)||E;return n_((0,Q.useMemo)(()=>F&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[F,u,d,f])),u.length&&!F?(0,$.jsx)(x,{paddingX:2,paddingY:0,children:(0,$.jsx)(ig,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Jg,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(x,{flexDirection:P?`column`:`row`,justifyContent:P?`flex-start`:`space-between`,paddingX:2,gap:+!P,children:[(0,$.jsxs)(x,{flexDirection:`column`,flexShrink:+!P,children:[i===`prompt`&&!ne&&!n.show&&!C&&TT(A)&&(0,$.jsx)(kT,{messagesRef:N,lastAssistantMessageId:te,vimMode:r}),(0,$.jsx)(nE,{}),(0,$.jsx)(YT,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:I,isLoading:g,tasksSelected:re,tmuxSelected:y,isPasting:C,isSearching:E,historyQuery:D,setHistoryQuery:O,historyFailedMatch:k,onOpenTasksDialog:ee})]}),(0,$.jsxs)(x,{flexShrink:1,gap:1,children:[F?null:(0,$.jsx)(mS,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:T,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:b,mcpClients:S,isInputWrapped:w,isNarrow:P}),(0,$.jsx)(tE,{bridgeSelected:v})]})]})})}var eE=(0,Q.memo)($T);function tE({bridgeSelected:e}){return null}function nE(){return null}u(),B();function rE({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function iE({mode:e,isLoading:t}){return(0,$.jsx)(x,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(T,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(rE,{isLoading:t})})}B(),G(),mr(),Ua(),Ps(),Bd(),sr();var aE=new Set;function oE(e){try{return Fd(e)?.type===`idle_notification`}catch{return!1}}var sE=3;function cE(e){return`<${Uf}>
72
- <${qf}>+${e} more tasks completed</${qf}>
73
- <${Gf}>completed</${Gf}>
74
- </${Uf}>`}function lE(e){let t=e.filter(e=>typeof e.value!=`string`||!oE(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=sE)return[...r,...n];let i=n.slice(0,sE-1),a={value:cE(n.length-(sE-1)),mode:`task-notification`};return[...r,...i,a]}function uE(){let e=rS(),t=K(e=>!!e.viewingAgentTaskId);K(e=>e.isBriefOnly);let n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(Lr);return t.length===0?null:ps(lE(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Jr({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(x,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(Rn,{isFirst:t===0,useBriefLayout:!1,children:(0,$.jsx)(Qt,{message:e,lookups:tl,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:aE,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var dE=Q.memo(uE);Si(),u(),B();function fE({hasStash:e}){return e?(0,$.jsx)(x,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Lt();var pE=1e4,mE=1e3;function hE(e,t){if(e.length<=pE)return{truncatedText:e,placeholderContent:``};let n=Math.floor(mE/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+gE(t,zc(a))+i,placeholderContent:a}}function gE(e,t){return`[...Truncated text #${e} +${t} lines...]`}function _E(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=hE(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function vE({input:e,pastedContents:t,onInputChange:n,setCursorOffset:r,setPastedContents:i}){let[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(a||e.length<=1e4)return;let{newInput:s,newPastedContents:c}=_E(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}G(),Mf(),Ua();var yE=(jm(),e(Mm)),bE=3;function xE({input:e,submitCount:t}){let n=rS(),r=K(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Yn)&&(jf().queuedCommandUpHintCount||0)<bE)return`Press up to edit queued messages`;if(t<1&&r&&!yE?.isProactiveActive())return T_()}},[e,n,t,r])}var SE=5e3,CE=!1;function wE(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(CE||!e)return;CE=!0,n(!0);let t=setTimeout(n,SE,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}L(),qa(),X(),G(),Nd(),Ua(),S(),vo(),Da(),l_(),Lt(),mg(),fd(),B(),ni(),Md(),Pi(),wl(),sf(),ol(),Mf(),q(),af(),Yd(),Wu(),Gi(),Xf(),Gp(),np(),dg(),jr(),xc(),__(),$i(),qg();var TE=5,EE=3;function DE({debug:e,ideSelection:t,toolPermissionContext:n,setToolPermissionContext:r,apiKeyStatus:i,commands:a,agents:o,isLoading:s,verbose:c,messages:l,onAutoUpdaterResult:u,autoUpdaterResult:d,input:f,onInputChange:p,mode:m,onModeChange:h,stashedPrompt:g,setStashedPrompt:_,submitCount:v,onShowMessageSelector:b,onMessageActionsEnter:S,mcpClients:C,pastedContents:w,setPastedContents:E,vimMode:D,setVimMode:O,showBashesDialog:k,setShowBashesDialog:ee,onExit:j,getToolUseContext:M,onSubmit:N,isSearchingHistory:P,setIsSearchingHistory:F,onDismissSideQuestion:ne,isSideQuestionVisible:re,helpOpen:I,setHelpOpen:L,hasSuppressedDialogs:ie,isLocalJSXCommandActive:z=!1,insertTextRef:ae}){let se=pg(),ce=Ya()||z,[le,ue]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)({show:!1}),[B,he]=(0,Q.useState)(f.length),ge=Q.useRef(f);f!==ge.current&&(he(f.length),ge.current=f);let V=Q.useCallback(e=>{ge.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:B,insert:e=>{let t=B===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,B)+t+f.slice(B);ge.current=n,p(n),he(B+t.length)},setInputWithCursor:(e,t)=>{ge.current=e,p(e),he(t)}});let _e=Cd(),ve=as(),ye=K(e=>e.tasks),be=K(e=>e.replBridgeConnected),xe=K(e=>e.replBridgeExplicit),Se=K(e=>e.replBridgeReconnecting),Ce=be&&(xe||Se),we=K(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Te=process.env.USER_TYPE===`ant`&&we,Ee=K(e=>!1),De=rS(),Oe=K(e=>e.promptSuggestion),ke=K(e=>e.speculation),Ae=K(e=>e.speculationSessionTimeSavedMs);K(e=>e.isBriefOnly);let je=K(e=>e.mainLoopModel),Me=K(e=>e.mainLoopModelForSession),Ne=K(e=>e.thinkingEnabled),Pe=K(e=>sm()?e.fastMode:!1),Fe=K(e=>e.viewingAgentTaskId);K(e=>e.viewSelectionMode);let{historyQuery:Ie,setHistoryQuery:Le,historyMatch:Re,historyFailedMatch:ze}=CS(e=>{E(e.pastedContents),an(e.display)},f,V,he,B,h,m,P,F,E,w),Be=(0,Q.useRef)(-1);Be.current===-1&&(Be.current=OE(l));let Ve=(0,Q.useRef)(!1),[He,Ue]=(0,Q.useState)(!1),We=K(e=>e.selectedBgAgentIndex),Ge=(0,Q.useCallback)(e=>ve(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[ve]),[Ke,qe]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(!1),[Xe,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(!1),[nt,rt]=(0,Q.useState)(!1),[it,at]=(0,Q.useState)(!1),[ot,st]=(0,Q.useState)(!1),ct=(0,Q.useMemo)(()=>{let e=f.indexOf(`
75
- `);return e===-1||B<=e},[f,B]),lt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
76
- `);return e===-1||B>e},[f,B]),ut=(0,Q.useMemo)(()=>tf(Object.values(ye),e=>e.status===`running`),[ye])>0&&!m_(ye,!1),dt=SS(),ft=dt.length>0,pt=(0,Q.useMemo)(()=>[ft&&`bg_agent`,ut&&`tasks`,Te&&`tmux`,Ee&&`bagel`,Ce&&`bridge`].filter(Boolean),[ft,ut,Te,Ee,Ce]),mt=K(e=>e.footerSelection),ht=mt&&pt.includes(mt)?mt:null;(0,Q.useEffect)(()=>{mt&&!ht&&ve(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[mt,ht,ve]);let gt=ht===`tasks`,_t=ht===`tmux`,vt=ht===`bridge`,yt=ht===`bg_agent`;function bt(e){ve(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Ge(-1)}function xt(e,t=!1){let n=ht?pt.indexOf(ht):-1,r=pt[n+e];return r?(bt(r),!0):e<0&&t?(bt(null),!0):!1}let{suggestion:St,markAccepted:Ct,logOutcomeAtSubmission:wt,markShown:Tt}=TS({inputValue:f,isAssistantResponding:s}),Et=(0,Q.useMemo)(()=>P&&Re?Qr(typeof Re==`string`?Re:Re.display):f,[P,Re,f]),Dt=(0,Q.useMemo)(()=>Lc(Et),[Et]),kt=(0,Q.useMemo)(()=>Wh(Et),[Et]),At=(0,Q.useMemo)(()=>$S(Et).filter(e=>Or(Et.slice(e.start+1,e.end),a)),[Et,a]),jt=(0,Q.useMemo)(()=>rr(Et),[Et]),Mt=(0,Q.useMemo)(()=>yC(_e.getState().mcp.clients)?xC(Et):[],[Et,(0,Q.useSyncExternalStore)(dC,bC)]),Nt=(0,Q.useMemo)(()=>ci(Et).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[Et]),Pt=Nt.some(e=>e.start===B);(0,Q.useEffect)(()=>{let e=Nt.find(e=>B>e.start&&B<e.end);if(e){let t=(e.start+e.end)/2;he(B<t?e.start:e.end)}},[B,Nt,he]);let It=(0,Q.useMemo)(()=>{let e=[];for(let t of Nt)B===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});P&&Re&&!ze&&e.push({start:B,end:B+Ie.length,color:`warning`,priority:20});for(let t of kt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of At)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of jt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Mt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(si())for(let t of Dt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Ft(n-t.start),shimmerColor:Ft(n-t.start,!0),priority:10});return e},[P,Ie,Re,ze,B,kt,Nt,At,jt,Mt,Et,Dt]),{addNotification:Lt,removeNotification:Rt}=Xn();(0,Q.useEffect)(()=>{Dt.length&&si()?Lt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):Rt(`ultrathink-active`)},[Lt,Rt,Dt.length]);let zt=(0,Q.useRef)(f.length),Bt=(0,Q.useRef)(f.length),Vt=(0,Q.useCallback)(()=>{Rt(`stash-hint`)},[Rt]);(0,Q.useEffect)(()=>{let e=zt.current,t=Bt.current,n=f.length;if(zt.current=n,n>t){Bt.current=n;return}if(n===0){Bt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(jf().hasUsedStash||Lt({key:`stash-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(eu,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:pS}),Bt.current=n)},[f.length,Lt]);let{pushToBuffer:Ht,undo:Ut,canUndo:Wt,clearBuffer:Gt}=wS({maxBufferSize:50,debounceMs:1e3});vE({input:f,pastedContents:w,onInputChange:V,setCursorOffset:he,setPastedContents:E});let Kt=xE({input:f,submitCount:v}),qt=(0,Q.useCallback)(e=>{if(e===`?`){Z(`tengu_help_toggled`,{}),L(e=>!e);return}L(!1),Vt(),Qs(),vc(ve);let t=e.length===f.length+1,n=B===0,r=gr(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Qr(e).replaceAll(` `,` `);Ht(f,B,w),V(t),he(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Ht(f,B,w),ve(e=>e.footerSelection===null?e:{...e,footerSelection:null}),V(i)},[V,h,f,B,Ht,w,Vt,ve]),{resetHistory:Jt,onHistoryUp:Yt,onHistoryDown:Xt,dismissSearchHint:Zt,historyIndex:Qt}=xS((e,t,n)=>{qt(e),h(t),E(n)},f,w,he,m);(0,Q.useEffect)(()=>{P&&Zt()},[P,Zt]);function $t(){if(!(on.length>1)&&ct){if(De.some(Yn)){vn();return}Yt()}}function en(){if(!(on.length>1)&&lt&&Xt()&&pt.length>0){let e=pt[0];bt(e),e===`tasks`&&!jf().hasSeenTasksHint&&Af(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[tn,nn]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),rn=(0,Q.useCallback)(e=>{nn(t=>typeof e==`function`?e(t):e)},[]),an=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=_e.getState();if(n.footerSelection&&pt.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(w).some(e=>e.type===`image`),i=Oe.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(ke.status===`active`){Ct(),wt(i,{skipReset:!0}),N(i,{setCursorOffset:he,clearBuffer:Gt,resetHistory:Jt},{state:ke,speculationSessionTimeSavedMs:Ae,setAppState:ve});return}Oe.shownAt>0&&(Ct(),e=i)}if(e.trim()===``&&!r)return;let a=tn.suggestions.length>0&&tn.suggestions.every(e=>e.description===`directory`);if(tn.suggestions.length>0&&!t&&!a){J(`[onSubmit] early return: suggestions showing (count=${tn.suggestions.length})`);return}Oe.text&&Oe.shownAt>0&&wt(e),Rt(`stash-hint`),await N(e,{setCursorOffset:he,clearBuffer:Gt,resetHistory:Jt})},[Oe,ke,Ae,_e,pt,tn.suggestions,N,Gt,Jt,wt,ve,Ct,w,Rt]),{suggestions:on,selectedSuggestion:sn,commandArgumentHint:cn,inlineGhostText:ln,maxColumnWidth:un}=ZC({commands:a,onInputChange:V,onSubmit:an,setCursorOffset:he,input:f,cursorOffset:B,mode:m,agents:o,setSuggestionsState:rn,suggestionsState:tn,suppressSuggestions:P||Qt>0,markAccepted:Ct,onModeChange:h}),dn=m===`prompt`&&on.length===0&&St&&!Fe;dn&&Tt(),Oe.text&&!St&&Oe.shownAt===0&&!Fe&&(vd(`timing`,Oe.text),ve(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function fn(e,t,n,r,i){Z(`tengu_paste_image`,{}),h(`prompt`);let a=Be.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};xo(o),Ot(o),E(e=>({...e,[a]:o})),hn((Ve.current?` `:``)+On(a)),Ve.current=!0}(0,Q.useEffect)(()=>{let e=new Set(ci(f).map(e=>e.id));E(t=>{let n=Object.values(t).filter(t=>t.type===`image`&&!e.has(t.id));if(n.length===0)return t;let r={...t};for(let e of n)delete r[e.id];return r})},[f,E]);function pn(e){Ve.current=!1;let t=me(e).replace(/\r/g,`
77
- `).replaceAll(` `,` `);if(f.length===0){let e=gr(t);e!==`prompt`&&(h(e),t=Qr(t))}let n=zc(t),r=Math.min(Nn-10,2);if(t.length>800||n>r){let e=Be.current++,r={id:e,type:`text`,content:t};E(t=>({...t,[e]:r})),hn(gn(e,n))}else hn(t)}let mn=(0,Q.useCallback)((e,t)=>Ve.current?(Ve.current=!1,Gg(e,t)?` `+e:e):e,[]);function hn(e){Ht(f,B,w);let t=f.slice(0,B)+e+f.slice(B);V(t),he(B+e.length)}let _n=R(()=>{},()=>b()),vn=(0,Q.useCallback)(()=>{let e=Tr(f,B);return e?(V(e.text),h(`prompt`),he(e.cursorOffset),e.images.length>0&&E(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[V,h,f,B,E]);oS(C,function(e){Z(`tengu_ext_at_mentioned`,{});let t,n=M_.relative(Pd(),e.filePath);t=e.lineStart&&e.lineEnd?e.lineStart===e.lineEnd?`@${n}#L${e.lineStart} `:`@${n}#L${e.lineStart}-${e.lineEnd} `:`@${n} `;let r=f[B-1]??` `;/\s/.test(r)||(t=` ${t}`),hn(t)});let yn=(0,Q.useCallback)(()=>{if(Wt){let e=Ut();e&&(V(e.text),he(e.cursorOffset),E(e.pastedContents))}},[Wt,Ut,V,E]),bn=(0,Q.useCallback)(()=>{Ht(f,B,w);let e=f.slice(0,B)+`
78
- `+f.slice(B);V(e),he(B+1)},[f,B,V,he,Ht,w]),xn=(0,Q.useCallback)(async()=>{Z(`tengu_external_editor_used`,{}),Ye(!0);try{let e=await lg(f,w);e.error&&Lt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Ht(f,B,w),V(e.content),he(e.content.length))}catch(e){e instanceof Error&&Y(e),Lt({key:`external-editor-error`,text:`External editor failed: ${Ld(e)}`,color:`warning`,priority:`high`})}finally{Ye(!1)}},[f,B,w,Ht,V,Lt]),Sn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(V(g.text),he(g.cursorOffset),E(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:B,pastedContents:w}),V(``),he(0),E({}),Af(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,B,g,V,_,w,E]),Cn=(0,Q.useCallback)(()=>{Ze(e=>!e),I&&L(!1)},[I]),wn=(0,Q.useCallback)(()=>{at(e=>!e),I&&L(!1)},[I]),Tn=(0,Q.useCallback)(()=>{st(e=>!e),I&&L(!1)},[I]),H=(0,Q.useCallback)(()=>{J(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=ew(n),{context:t}=tw(n);Z(`tengu_mode_cycle`,{to:e}),e===`plan`&&Af(e=>({...e,lastPlanModeUse:Date.now()})),ve(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),I&&L(!1)},[n,ve,r,I]),En=(0,Q.useCallback)(()=>{ar().then(e=>{if(e)fn(e.base64,e.mediaType);else{let e=ta(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Qd.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;Lt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[Lt,fn]),Dn=te();(0,Q.useEffect)(()=>{if(!(!Dn||ce))return Dn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{an(f)}})},[Dn,ce,an,f]),y((0,Q.useMemo)(()=>({"chat:undo":yn,"chat:newline":bn,"chat:externalEditor":xn,"chat:stash":Sn,"chat:modelPicker":Cn,"chat:thinkingToggle":Tn,"chat:cycleMode":H,"chat:imagePaste":En}),[yn,bn,xn,Sn,Cn,Tn,H,En]),{context:`Chat`,isActive:!ce}),A(`chat:messageActions`,()=>S?.(),{context:`Chat`,isActive:!ce&&!P}),A(`chat:fastMode`,wn,{context:`Chat`,isActive:!ce&&sm()&&um()}),A(`help:dismiss`,()=>{L(!1)},{context:`Help`,isActive:I}),A(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),A(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),A(`history:search`,()=>{},{context:`Global`,isActive:!1}),A(`app:interrupt`,()=>{vc(ve)},{context:`Global`,isActive:!s&&ke.status===`active`}),y({"footer:up":()=>{if(yt){We>-1?Ge(e=>e-1):bt(null);return}xt(-1,!0)},"footer:down":()=>{if(yt){We<dt.length-1&&Ge(e=>e+1);return}if(gt){ee(!0),bt(null);return}xt(1)},"footer:next":()=>{xt(1)},"footer:previous":()=>{xt(-1)},"footer:openSelected":()=>{switch(ht){case`tasks`:ee(!0),bt(null);break;case`tmux`:process.env.USER_TYPE===`ant`&&ve(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`bridge`:Ue(!0),bt(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{bt(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!ht&&!ce}),oe((e,t)=>{if(!(Qe||et||nt)){if(tp()===`macos`&&$C(e)){let t=QC[e],n=ph();Lt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(T,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(ht&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){qt(f.slice(0,B)+e+f.slice(B)),he(B+e.length);return}if(B===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),L(!1)),I&&f===``&&(t.backspace||t.delete)&&L(!1),t.escape){if(ke.status===`active`){vc(ve);return}if(re&&ne){ne();return}if(I){L(!1);return}if(ht)return;if(De.some(Yn)){vn();return}l.length>0&&!f&&!s&&_n()}t.return&&I&&L(!1)}});let kn=sm()?am():!1,An=sm()?Pe&&(um()||kn):!1,jn=wE(An??!1),{columns:Mn,rows:Nn}=de(),Pn=Mn-3,Fn=Ts()?Math.max(EE,Math.floor(Nn/2)-TE):void 0,In=(0,Q.useCallback)(e=>{if(!f||P)return;let t=Gs.fromText(f,Pn,B),n=t.getViewportStartLine(Fn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});he(r)},[f,Pn,P,B,Fn]),Ln=(0,Q.useCallback)(e=>ee(e??!0),[ee]),Rn=dn&&St?St:Kt,zn=(0,Q.useMemo)(()=>f.includes(`
79
- `),[f]),Bn=(0,Q.useCallback)(e=>{let t=!1;ve(n=>(t=sm()&&!tm(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Ze(!1);let n=(Pe??!1)&&!t,r=`Model set to ${pm(e)}`;Cg(e,n,Yp())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),Lt({key:`model-switched`,jsx:(0,$.jsx)(T,{children:r}),priority:`immediate`,timeoutMs:3e3}),Z(`tengu_model_picker_hotkey`,{model:e})},[ve,Lt,Pe]),Vn=(0,Q.useCallback)(()=>{Ze(!1)},[]),Hn=(0,Q.useMemo)(()=>Xe?(0,$.jsx)(x,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(wg,{initial:je,sessionModel:Me,onSelect:Bn,onCancel:Vn,isStandaloneCommand:!0,showFastModeNotice:sm()&&Pe&&tm(je)&&um()})}):null,[Xe,je,Me,Bn,Vn]),Un=(0,Q.useCallback)(e=>{at(!1),e&&Lt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(T,{children:e}),priority:`immediate`,timeoutMs:3e3})},[Lt]),Wn=(0,Q.useMemo)(()=>it?(0,$.jsx)(x,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(zg,{onDone:Un,unavailableReason:Wp()})}):null,[it,Un]),Gn=(0,Q.useCallback)(e=>{ve(t=>({...t,thinkingEnabled:e})),st(!1),Z(`tengu_thinking_toggled_hotkey`,{enabled:e}),Lt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(T,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[ve,Lt]),Kn=(0,Q.useCallback)(()=>{st(!1)},[]),qn=(0,Q.useMemo)(()=>ot?(0,$.jsx)(x,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(iw,{currentValue:Ne??!0,onSelect:Gn,onCancel:Kn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[ot,Ne,Gn,Kn,l.length]);if(a_(null),k)return(0,$.jsx)(v_,{onDone:()=>ee(!1),toolUseContext:M(l,[],new AbortController,se),initialDetailTaskId:typeof k==`string`?k:void 0});if(Hn)return Hn;if(Wn)return Wn;if(qn)return qn;if(He)return(0,$.jsx)(rw,{onDone:()=>{Ue(!1),bt(null)}});let Jn={multiline:!0,onSubmit:an,onChange:qt,value:Re?Qr(typeof Re==`string`?Re:Re.display):f,onHistoryUp:$t,onHistoryDown:en,onHistoryReset:Jt,placeholder:Rn,onExit:j,onExitMessage:(e,t)=>pe({show:e,key:t}),onImagePaste:fn,columns:Pn,maxVisibleLines:Fn,disableCursorMovementForUpDownKeys:on.length>0||!!ht,disableEscapeDoublePress:on.length>0,cursorOffset:B,onChangeCursorOffset:he,onPaste:pn,onIsPastingChange:qe,focus:!P&&!ce&&!ht,showCursor:!ht&&!P&&!Pt,argumentHint:cn,onUndo:Wt?()=>{let e=Ut();e&&(V(e.text),he(e.cursorOffset),E(e.pastedContents))}:void 0,highlights:It,inlineGhostText:ln,inputFilter:mn},Zn=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Je)return(0,$.jsx)(x,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Zn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Qn=Wg()?(0,$.jsx)(rT,{...Jn,initialMode:D,onModeChange:O}):(0,$.jsx)(lu,{...Jn});return(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[!Ts()&&(0,$.jsx)(dE,{}),ie&&(0,$.jsx)(x,{marginTop:1,marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(fE,{hasStash:g!==void 0}),(0,$.jsxs)(x,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Zn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:kE(An??!1,jn,kn),children:[(0,$.jsx)(iE,{mode:m,isLoading:s}),(0,$.jsx)(x,{flexGrow:1,flexShrink:1,onClick:In,children:Qn})]}),(0,$.jsx)(eE,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:Wg()?D:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:le,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:ue,suggestions:on,selectedSuggestion:sn,maxColumnWidth:un,toolPermissionContext:n,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:gt,bridgeSelected:vt,tmuxSelected:_t,ideSelection:t,mcpClients:C,isPasting:Ke,isInputWrapped:zn,messages:l,isSearching:P,historyQuery:Ie,setHistoryQuery:Le,historyFailedMatch:ze,onOpenTasksDialog:Ts()?Ln:void 0}),Ts()?(0,$.jsx)(x,{position:`absolute`,marginTop:-1,height:+(on.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(mS,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:le,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:ue,ideSelection:t,mcpClients:C,isInputWrapped:zn})}):null]})}function OE(e){let t=0;for(let n of e)if(n.type===`user`){if(n.imagePasteIds)for(let e of n.imagePasteIds)e>t&&(t=e);if(Array.isArray(n.message.content)){for(let e of n.message.content)if(e.type===`text`){let n=ci(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function kE(e,t,n){if(e)return{content:` ${t?`${Lg(!0,n)} ${ge.dim(`/fast`)}`:Lg(!0,n)} `,position:`top`,align:`end`,offset:0}}var AE=Q.memo(DE);Bd();function jE(e,t){return{type:`assistant`,uuid:U_(),message:{id:`remote-${t}`,type:`message`,role:`assistant`,content:[{type:`tool_use`,id:e.tool_use_id,name:e.tool_name,input:e.input}],model:``,stop_reason:null,stop_sequence:null,container:null,context_management:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},requestId:void 0,timestamp:new Date().toISOString()}}function ME(e){return{name:e,inputSchema:{},isEnabled:()=>!0,userFacingName:()=>e,renderToolUseMessage:e=>{let t=Object.entries(e);return t.length===0?``:t.slice(0,3).map(([e,t])=>`${e}: ${typeof t==`string`?t:Jd(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}q(),gh(),Ps();function NE(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function PE(e){return{type:`stream_event`,event:e.event}}function FE(e){let t=e.subtype!==`success`;return{type:`system`,subtype:`informational`,content:t?e.errors?.join(`, `)||`Unknown error`:`Session completed successfully`,level:t?`warning`:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function IE(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function LE(e){return e.status?{type:`system`,subtype:`informational`,content:e.status===`compacting`?`Compacting conversation…`:`Status: ${e.status}`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}:null}function RE(e){return{type:`system`,subtype:`informational`,content:`Tool ${e.tool_name} running for ${e.elapsed_time_seconds}s…`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),toolUseID:e.tool_use_id}}function zE(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:_h(e.compact_metadata)}}function BE(e,t){switch(e.type){case`assistant`:return{type:`message`,message:NE(e)};case`user`:{let n=e,r=n.message?.content,i=Array.isArray(r)&&r.some(e=>e.type===`tool_result`);return t?.convertToolResults&&i||t?.convertUserTextMessages&&!i&&(typeof r==`string`||Array.isArray(r))?{type:`message`,message:Jr({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:PE(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:FE(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:IE(t)};if(t.subtype===`status`){let t=LE(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:zE(e)}:(J(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:RE(e)};case`auth_status`:return J(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return J(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return J(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return J(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return J(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function VE(e){return e.type===`result`}G(),q(),_p(),Ps();var HE=6e4,UE=18e4;function WE({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=as(),d=(0,Q.useCallback)(e=>u(t=>t.remoteConnectionStatus===e?t:{...t,remoteConnectionStatus:e}),[u]),f=(0,Q.useRef)(new Set),p=(0,Q.useCallback)(()=>{let e=f.current.size;u(t=>t.remoteBackgroundTaskCount===e?t:{...t,remoteBackgroundTaskCount:e})},[u]),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(new bh(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;J(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new E_(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(J(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){J(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;J(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(VE(i)&&(h.current=!1,n(!1)),c&&i.type===`user`){let e=i.message?.content;if(Array.isArray(e)){let t=[];for(let n of e)n.type===`tool_result`&&t.push(n.tool_use_id);t.length>0&&c(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n.size===e.size?e:n})}}let l=BE(i,e.viewerOnly?{convertToolResults:!0,convertUserTextMessages:!0}:void 0);if(l.type===`message`){if(o?.(e=>e.length>0?[]:e),c&&l.message.type===`assistant`){let e=(Array.isArray(l.message.message?.content)?l.message.message.content:[]).filter(e=>e.type===`tool_use`).map(e=>e.id);e.length>0&&c(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}t(e=>[...e,l.message])}else l.type===`stream_event`&&(o&&s?Eo(l.event,e=>t(t=>[...t,e]),()=>{},s,o):J(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{J(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=Om(y.current,e.tool_name)??ME(e.tool_name),o=jE(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{J(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{J(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{J(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{J(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{J(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{J(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let b=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return J(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:Wt(r,` `);n&&vh(n,new AbortController().signal).then(e=>{sh(t,e??gp(n,75))})}if(!e?.viewerOnly){let e=h.current?UE:HE;m.current=setTimeout((e,t)=>{J(`[useRemoteSession] Response timeout - attempting reconnect`);let n=ki(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),x=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:b,cancelRequest:x,disconnect:S}),[l,b,x,S])}q(),Bd(),c();function GE(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var KE=class{constructor(e,t){l(this,`ws`,null),l(this,`config`,void 0),l(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
80
- `).filter(e=>e.trim());for(let e of t){let t;try{t=Fd(e)}catch{continue}if(!GE(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(J(`[DirectConnect] Unsupported control request subtype: ${n.request.subtype}`),this.sendErrorResponse(n.request_id,`Unsupported control request subtype: ${n.request.subtype}`));continue}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.callbacks.onMessage(n)}}),this.ws.addEventListener(`close`,()=>{this.callbacks.onDisconnected?.()}),this.ws.addEventListener(`error`,()=>{this.callbacks.onError?.(Error(`WebSocket connection error`))})}sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;let t=Jd({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.ws.send(t),!0}respondToPermissionRequest(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=Jd({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.ws.send(n)}sendInterrupt(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let e=Jd({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.ws.send(e)}sendErrorResponse(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=Jd({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.ws.send(n)}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}isConnected(){return this.ws?.readyState===WebSocket.OPEN}};Dm(),q();function qE({config:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new KE(e,{onMessage:e=>{if(VE(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=BE(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=Om(l.current,e.tool_name)??ME(e.tool_name),o=jE(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a,o,s){let c={behavior:`allow`,updatedInput:a};i.respondToPermissionRequest(t,c),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let a={behavior:`deny`,message:n??`User denied permission`};i.respondToPermissionRequest(t,a),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{J(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
81
- Server disconnected.
82
- `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,Br(1),n(!1)},onError:e=>{J(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}Dm(),q(),kr();function JE({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(VE(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=BE(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useSSHSession] permission request: ${e.tool_name}`);let a=Om(l.current,e.tool_name)??ME(e.tool_name),o=jE(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{J(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:U_(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{J(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal `+e.proc.signalCode}):\n${t}`),Br(1,`other`,{finalMessage:a})},onError:e=>{J(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}Cp();var YE=400;function XE({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=YE}){let s=(0,Q.useRef)(e),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)({setInputValue:t,isValidDigit:n,onDigit:r});u.current={setInputValue:t,isValidDigit:n,onDigit:r},(0,Q.useEffect)(()=>{if(!(!i||a&&c.current)){if(l.current!==null&&(clearTimeout(l.current),l.current=null),e!==s.current){let t=Tp(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}B();var ZE=[`0`,`1`,`2`,`3`],QE={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},$E=e=>ZE.includes(e),eD=`How is Claude doing this session? (optional)`;function tD({onSelect:e,inputValue:t,setInputValue:n,message:r=eD}){return XE({inputValue:t,setInputValue:n,isValidDigit:$E,onDigit:t=>e(QE[t])}),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(T,{bold:!0,children:r})]}),(0,$.jsxs)(x,{marginLeft:2,children:[(0,$.jsx)(x,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(x,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(x,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(x,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}pf(),B(),Cp();function nD({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!$E(i)?null:(0,$.jsx)(aD,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var rD=[`0`,`1`];function iD(e){return rD.includes(e)}function aD({skillName:e,updates:t,onSelect:n,inputValue:r,setInputValue:i}){let a=(0,Q.useRef)(r);return(0,Q.useEffect)(()=>{if(r!==a.current){let e=Tp(r.slice(-1));iD(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(x,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[mf,` `]}),(0,$.jsxs)(T,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(x,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(x,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(x,{width:12,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(x,{width:14,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}X(),G(),Ps();function oD(e){let t=K(e=>e.skillImprovement.suggestion),n=as(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,Z(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;Z(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&D_(r.skillName,r.updates).then(()=>{e(e=>[...e,ki(`Skill "${r.skillName}" updated with improvements.`,`suggestion`)])}),i(!1),o.current=!1,n(e=>e.skillImprovement.suggestion?{...e,skillImprovement:{suggestion:null}}:e)},[n,e]);return{isOpen:r,suggestion:a.current,handleSelect:s}}function sD(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Vi(),Er(),Uu(),Es();function cD(e){(0,Q.useEffect)(()=>{let t=()=>{Dp()&&process.stdout.write(`
83
- `+$c()+`
84
- `),Gl(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function lD(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function uD(e,t){let n=(0,Q.useRef)(e??null),r=(0,Q.useRef)(!e);return(0,Q.useEffect)(()=>{let e=n.current;if(!e)return;let i=!1;return e.then(e=>{i||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))}),()=>{i=!0}},[t]),(0,Q.useCallback)(async()=>{if(r.current||!n.current)return;let e=await n.current;r.current||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))},[t])}Ne(),Is(),Ap();function dD(){let[e,t]=(0,Q.useState)(()=>{if(!Lp()||Fp())return`valid`;let{key:e,source:t}=Bp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Lp()||Fp()){t(`valid`);return}await jp(xt());let{key:e,source:n}=Bp();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await Sc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}Ne(),B(),Nd(),q(),B(),Pi(),X(),G();function fD({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=K(e=>e.expandedView),u=as(),d=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:l===`tasks`}),u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=K(e=>e.isBriefOnly),p=(0,Q.useCallback)(()=>{let s=e!==`transcript`;Z(`tengu_toggle_transcript`,{is_entering:s,show_all:n,message_count:i}),t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),s&&a&&a(),!s&&o&&o()},[e,t,f,n,r,i,u,a,o]),m=(0,Q.useCallback)(()=>{Z(`tengu_transcript_toggle_show_all`,{is_expanding:!n,message_count:i}),r(e=>!e)},[n,r,i]),h=(0,Q.useCallback)(()=>{Z(`tengu_transcript_exit`,{show_all:n,message_count:i}),t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]),g=(0,Q.useCallback)(()=>{},[f,u]);A(`app:toggleTodos`,d,{context:`Global`}),A(`app:toggleTranscript`,p,{context:`Global`}),A(`app:toggleBrief`,g,{context:`Global`,isActive:!1}),A(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),A(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let _=e===`transcript`;return A(`transcript:toggleShowAll`,m,{context:`Transcript`,isActive:_&&!s}),A(`transcript:exit`,h,{context:`Transcript`,isActive:_&&!c}),null}Da(),ni(),Pi();var pD={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function mD({onSubmit:e,isActive:t=!0}){let n=te(),r=Ya(),i=(0,Q.useMemo)(()=>{if(!n)return new Set;let e=new Set;for(let t of n.bindings)t.action?.startsWith(`command:`)&&e.add(t.action);return e},[n]);return y((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,pD,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}bu(),X(),G(),qg(),qa(),Da(),Md(),Pi(),kt(),Ua();var hD=3e3;function gD(e){let{setToolUseConfirmQueue:t,onCancel:n,onAgentsKilled:r,isMessageSelectorVisible:i,screen:a,abortSignal:o,popCommandFromQueue:s,vimMode:c,isLocalJSXCommand:l,isSearchingHistory:u,isHelpOpen:d,inputMode:f,inputValue:p,streamMode:m}=e,h=Cd(),g=as(),_=rS().length,{addNotification:v,removeNotification:y}=Xn(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){Z(`tengu_cancel`,e),t(()=>[]),n();return}if(Sa()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Zn(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(Wg()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);A(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;pl(e,g);let n=[];for(let[e,r]of t)au(e,g),n.push(r.description),zm(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Xi({value:n.length===1?`Background agent "${n[0]}" was stopped by the user.`:`${n.length} background agents were stopped by the user: ${n.map(e=>`"${e}"`).join(`, `)}.`,mode:`task-notification`}),r(),!0},[h,g,r]);return A(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),A(`chat:killAgents`,(0,Q.useCallback)(()=>{let e=h.getState().tasks;if(!Object.values(e).some(e=>e.type===`local_agent`&&e.status===`running`)){v({key:`kill-agents-none`,text:`No background agents running`,priority:`immediate`,timeoutMs:2e3});return}let t=Date.now();if(t-b.current<=hD){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),Ai(),k();return}b.current=t;let n=ta(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:hD})},[h,v,y,k]),{context:`Chat`}),null}B(),G(),sl();function _D(e){let t=K(e=>e.tasks),n=K(e=>e.pipeIpc),r=Object.values(t).some(pc),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return oe((e,t,n)=>{i(new ee(n.keypress))}),{handleKeyDown:i}}Yg(),Xf();async function vD(e){let{ctx:t,updatedInput:n,suggestions:r,permissionMode:i}=e;try{let e=await t.runHooks(i,r,n);if(e)return e}catch(e){e instanceof Error?Y(e):Y(Error(`Automated permission check failed: ${String(e)}`))}return null}var yD=new Map,bD=null;function xD(){return bD??null}function SD(e,t){let n=xD();if(!n)return null;let r=U_(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return yD.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function CD(e){e&&yD.delete(e)}function wD(e,t){if(!e)return;let n=xD();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}X(),Gm(),bi(),q(),xd(),Ps(),Pn(),Us();function TD(e){let t=!1,n=!1;return{resolve(r){n||(n=!0,t=!0,e(r))},isResolved(){return t},claim(){return t?!1:(t=!0,!0)}}}function ED(e,t,n,r,i,a,o){let s=r.message.id;return Object.freeze({tool:e,input:t,toolUseContext:n,assistantMessage:r,messageId:s,toolUseID:i,logDecision(r,a){zl({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:Km(e.name)})},async persistPermissions(e){return e.length===0?!1:(qr(e),a(ai(n.getAppState().toolPermissionContext,e)),e.some(e=>Yi(e.destination)))},resolveIfAborted(e){return n.abortController.signal.aborted?(this.logCancelled(),e(this.cancelAndAbort(void 0,!0)),!0):!1},cancelAndAbort(t,r,i){let a=!!n.agentId,o=t?`${a?ld:_d}${t}`:a?ns:Yu,s=a?o:fc(o);return(r||!t&&!i?.length&&!a)&&(J(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of $n(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(J(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function DD(e){return{push(t){e(e=>[...e,t])},remove(t){e(e=>e.filter(e=>e.toolUseID!==t))},update(t,n){e(e=>e.map(e=>e.toolUseID===t?{...e,...n}:e))}}}q(),B(),bi(),Jo(),Yd();function OD(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=TD(t),u,d,f=o?U_():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){wD(h,e),CD(h),h=null}function _(){CD(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||bc(n.toolUseID)},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await za(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=SD(v,e=>{l()&&(_(),bc(n.toolUseID),n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),bc(n.toolUseID),n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}X(),Gm(),B(),bi(),Jo(),q(),Yd(),Xf(),Kn(),Bd(),Us();function kD(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=ED(n,r,i,a,o,t,DD(e));if(!l.resolveIfAborted(c))return(s===void 0?za(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:Km(n.name),behavior:e.behavior,input:Jd(r),messageID:l.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&El(o,e.decisionReason.reason),l.logDecision({decision:`accept`,source:`config`}),c(l.buildAllow(e.updatedInput??r,{decisionReason:e.decisionReason}));return}let t=i.getAppState(),a=await n.description(r,{isNonInteractiveSession:i.options.isNonInteractiveSession,toolPermissionContext:t.toolPermissionContext,tools:i.options.tools});if(!l.resolveIfAborted(c))switch(e.behavior){case`deny`:zl({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Xg({toolName:n.name,display:a,reason:e.decisionReason.reason??``,timestamp:Date.now()}),i.addNotification?.({key:`auto-mode-denied`,priority:`immediate`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await vD({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;OD({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:void 0},c);return}}).catch(e=>{e instanceof Id||e instanceof zd?(J(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Y(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{bc(o)})}),[e,t])}Vm(),X(),vo(),Lt(),Nd(),q(),kr(),Yd(),Xf(),Ua(),Gp();function AD(){$l(0)}async function jD(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,ideSelection:d,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,canUseTool:_,queuedCommands:v,uuid:y,skipSlashCommands:b,bridgeOrigin:x}=e,{setCursorOffset:S,clearBuffer:C,resetHistory:w}=t;if(v?.length){ds(),await MD({queuedCommands:v,messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a});return}let T=e.input??``,E=e.mode??`prompt`,D=e.pastedContents??{},O=new Set(ci(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),ee=Object.values(k).some(Wn);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?jD({...e,input:`/exit`}):AD();return}let A=fa(T,k),j=ci(T).filter(e=>k[e.id]?.type===`text`),M=j.length;if(Z(`tengu_paste_text`,{pastedTextCount:M,pastedTextBytes:j.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&A.trim().startsWith(`/`)){let t=A.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Tt(e)&&(e.name===f||e.aliases?.includes(f)||Oo(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Z(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Gr(),u),n=!1,r=await(await m.load()).call((t,r)=>{n=!0,s({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),t&&r?.display!==`skip`&&e.addNotification&&e.addNotification({key:`immediate-${m.name}`,text:t,priority:`immediate`}),r?.nextInput&&(r.submitNextInput?Yr({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(J(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Z(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),Yr({value:A.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:ee?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}ds(),await MD({queuedCommands:[{value:A,preExpansionValue:T,mode:E,pastedContents:ee?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function MD(e){let{messages:t,mainLoopModel:n,ideSelection:r,querySource:i,queryGuard:a,setToolJSX:o,getToolUseContext:s,setUserInputOnProcessing:c,setAbortController:l,onQuery:u,setAppState:d,onBeforeQuery:f,resetHistory:p,canUseTool:m,queuedCommands:h}=e,g=Gr();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),vu(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await hn(C);C=w.attachmentCommands;let T=w.claimedCommands;if(C.length===0){l(null);return}let E=C[0]?.workload,D=E!==void 0&&C.every(e=>e.workload===E)?E:void 0,O=new Set,k;try{await Kp(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await Lh({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&O.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.nextInput,S=u.submitNextInput)}if(vu(`query_process_user_input_end`),xl()&&(vu(`query_file_history_snapshot_start`),s.filter(Ih).forEach(e=>{es(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),vu(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=C[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?Mp(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?Yr({value:x,mode:`prompt`}):e.onInputChange(x))})}catch(e){k=e}if(T.length){let e=T.filter(e=>{let t=e.autonomy?.runId;return!t||!O.has(t)});if(k)try{await Ci({commands:e,outcome:{type:`failed`,error:k},currentDir:Pd(),priority:`later`,workload:D})}catch(e){Y(Hd(e))}else try{let t=await Ci({commands:e,outcome:{type:`completed`},currentDir:Pd(),priority:`later`,workload:D});for(let e of t)Yr(e)}catch(e){Y(Hd(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}Ua();function ND(e){if(typeof e.value==`string`)return e.value.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);for(let t of e.value)if(t.type===`text`)return t.text.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);return!1}function PD({executeInput:e}){let t=e=>e.agentId===void 0,n=Yl(t);if(!n)return{processed:!1};if(ND(n)||n.mode===`bash`)return e([In(t)]),{processed:!0};let r=n.mode,i=pr(e=>t(e)&&!ND(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Ua();function FD({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(ao,Fa);(0,Q.useEffect)(()=>{r||t||i.length!==0&&PD({executeInput:e})},[i,r,e,t,n])}function ID({isLoading:e,onSubmitMessage:t}){let n=Hc();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function LD(e,t){return e&&t&&t.length>0?Wr([...e,...t],`name`):e||[]}function RD(e,t){return(0,Q.useMemo)(()=>LD(e,t),[e,t])}bs(),Fh(),og(),fr();function zD(e,t){return(0,Q.useMemo)(()=>t.length>0?Wr([...e,...t],`name`):e,[e,t])}vo(),Xf();function BD(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Od(),t(await Ka(e))}catch(e){e instanceof Error&&Y(e)}},[e,t]);(0,Q.useEffect)(()=>Xh.subscribe(n),[n])}Xf(),je(),pu(),Me();var VD=Ae(()=>ke({method:Ee(`selection_changed`),params:ke({selection:ke({start:ke({line:Ce(),character:Ce()}),end:ke({line:Ce(),character:Ce()})}).nullable().optional(),text:Se().optional(),filePath:Se().optional()})}));function HD(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=dl(e);if(r.current!==(i??null)&&(n.current=!1,r.current=i||null,t({lineCount:0,lineStart:void 0,text:void 0,filePath:void 0})),n.current||!i)return;let a=e=>{if(e.selection?.start&&e.selection?.end){let{start:n,end:r}=e.selection,i=r.line-n.line+1;r.character===0&&i--,t({lineCount:i,lineStart:n.line,text:e.text,filePath:e.filePath})}};i.client.setNotificationHandler(VD(),e=>{if(r.current===i)try{let t=e.params;t.selection&&t.selection.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){Y(e)}}),n.current=!0},[e,t])}Sn(),gl(),rl(),B(),p_(),G(),_p();function UD({task:e,selected:t}){let n=g_(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(x,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(x,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(T,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(T,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(T,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(x,{flexShrink:0,children:(0,$.jsxs)(T,{dimColor:!0,children:[n,` · ↓ `,hp(r),` tokens`]})})]})}function WD(e,t){return e?`↑/↓ to select · Enter to view`:t?t.status===`running`?`shift+↓ to manage · x to stop`:`shift+↓ to manage · x to clear`:`shift+↓ to manage background agents`}function GD(){let e=SS(),t=K(e=>e.viewingAgentTaskId),n=K(e=>e.footerSelection),r=K(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(x,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(x,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(T,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(T,{dimColor:!0,children:WD(i,s)})]}),e.map(e=>(0,$.jsx)(UD,{task:e,selected:e.agentId===a},e.agentId))]})}q(),Cu();var KD=1e3;function qD({taskListId:e,isLoading:t,onSubmitTask:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)(n);o.current=n;let s=e!==void 0,c=e??`tasklist`,l=(0,Q.useRef)(async()=>{});l.current=async()=>{if(!s||a.current)return;let t=await ru(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)J(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=JD(t);if(!n)return;J(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await no(e,n.id,c);if(!i.success){J(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=YD(n);J(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(J(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await gc(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;zi(e);let t=Os(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),KD,l)};u.current=r;try{n=V_(t,r),n.unref(),J(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){J(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function JD(e){let t=new Set(e.filter(e=>e.status!==`completed`).map(e=>e.id));return e.find(e=>e.status!==`pending`||e.owner?!1:e.blockedBy.every(e=>!t.has(e)))}function YD(e){let t=`Complete all open tasks. Start with task #${e.id}: \n\n ${e.subject}`;return e.description&&(t+=`\n\n${e.description}`),t}Mf(),s(),pu();function XD({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(jf().autoConnectIde||e||vs()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!i(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:r.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:r.url,ideName:r.name,authToken:r.authToken,ideRunningInWindows:r.ideRunningInWindows,scope:`dynamic`}})}ss(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}Pg(),Ss(),B(),Pi(),Un(),G(),Mf(),af(),s();function ZD({onBackgroundSession:e,isLoading:t}){let n=as(),r=Cd(),[i,o]=(0,Q.useState)(!1),s=R(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Uo(r.getState())?(ic(()=>r.getState(),n),jf().hasUsedBackgroundTask||Af(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=K(Uo),u=a(`false`);A(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=yr(`task:background`,`Task`,`ctrl+b`),f=Qd.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(x,{paddingLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(g,{shortcut:f,action:`background`})})})}G();function QD({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=K(e=>e.foregroundedTaskId),o=K(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=as(),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(()=>{if(a){s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),e([]),n(),r(null);return}i()},[a,s,e,n,r,i]);return(0,Q.useEffect)(()=>{if(!a){c.current=0;return}if(!o||o.type!==`local_agent`){s(e=>({...e,foregroundedTaskId:void 0})),n(),c.current=0;return}let i=o.messages??[];if(i.length!==c.current&&(c.current=i.length,e([...i])),o.status===`running`){let e=o.abortController;if(e?.signal.aborted){s(e=>{if(!e.foregroundedTaskId)return e;let t=e.tasks[e.foregroundedTaskId];return t?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[e.foregroundedTaskId]:{...t,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0;return}t(!0),e&&r(e)}else s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0},[a,o,s,e,t,n,r]),{handleBackgroundSession:l}}No(),Lm(),B(),Ap(),Mf(),Xt(),Vg();function $D({onDone:e}){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useCallback)(()=>{t.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{Af(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);let r=(0,Q.useCallback)(e=>{t.current(e)},[]);return(0,$.jsx)(Ug,{title:`Remote Control`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(x,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{children:`Remote Control lets you access this CLI session from the web (claude.ai/code) or the Claude app, so you can pick up where you left off on any device.`}),(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{children:`You can disconnect remote access anytime by running /remote-control again.`})]}),(0,$.jsx)(x,{children:(0,$.jsx)(jd,{options:[{label:`Enable Remote Control for this session`,description:`Opens a secure connection to claude.ai.`,value:`enable`},{label:`Never mind`,description:`You can always enable it later with /remote-control.`,value:`dismiss`}],onChange:r,onCancel:n})})]})})}Ah();function eO(e,t){return t}cu(),Ne(),Ps(),fd(),B(),Pi(),Is(),Ap(),Ys(),q(),af(),Bf(),Xf(),Ac(),Bd(),go(),jr(),xc(),process.env.USER_TYPE;function tO(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,`"[REDACTED_API_KEY]"`),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,`[REDACTED_API_KEY]`),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,`AWS key: "[REDACTED_AWS_KEY]"`),t=t.replace(/(AKIA[A-Z0-9]{16})/g,`[REDACTED_AWS_KEY]`),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,`[REDACTED_GCP_KEY]`),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,`[REDACTED_GCP_SERVICE_ACCOUNT]`),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,`$1[REDACTED_API_KEY]`),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,`$1[REDACTED_TOKEN]`),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_AWS_VALUE]`),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_GCP_VALUE]`),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED]`),t}m(),Ap(),q(),Yd(),im(),Ps(),Ac(),Bd();async function nO(e,t,n){try{J(`Collecting transcript for sharing`,{level:`info`});let r=Yc(e),i=await Mr(Al(e)),a;try{let e=An(),{size:t}=await K_(e);t<=52428800?a=await W_(e,`utf-8`):J(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=tO(Jd({trigger:t,version:`0.0.8`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await rm();let s=Ep();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":lm(),...s.headers},l=await p.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return J(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return J(Ld(e),{level:`error`}),{success:!1}}}function rO({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(U_()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=U_(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}X(),Mf(),s(),Ps(),Gp(),xf();var iO={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},aO={probability:0};function oO(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=Ha(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=eO(`tengu_feedback_survey_config`,iO),u=eO(`tengu_bad_survey_transcript_ask_config`,aO),d=eO(`tengu_good_survey_transcript_ask_config`,aO),f=Cf().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),jf().feedbackSurveyState?.lastShownTime!==e&&Af(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),eh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),eh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||jf().transcriptShareDismissed||!Yo(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Z(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),eh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(Z(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&Af(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await nO(g.current,i,e);return Z(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=rO({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),ee=dm(),A=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(ee),[l.onForModels,ee]),j=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!A||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||lh()||!Yo(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=jf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,A,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{j&&D()},[j,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}ch(),X(),cu(),Mf(),s(),Ps(),rh();var sO=3e3,cO=`tengu_memory_survey_event`,lO=`memory_survey`;function uO(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=rO({hideThanksAfterMs:sO,onOpen:(0,Q.useCallback)(e=>{Z(cO,{event_type:`appeared`,appearance_id:e}),eh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(cO,{event_type:`responded`,appearance_id:e,response:t}),eh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!(process.env.USER_TYPE!==`ant`||e!==`bad`&&e!==`good`||jf().transcriptShareDismissed||!Yo(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(cO,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:lO}),eh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(cO,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:lO}),t===`dont_ask_again`&&Af(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await nO(o.current,lO,e);return Z(cO,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:lO}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>Ha(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}ch(),X(),s(),Ps(),rh();var dO=3e3,fO=.2;function pO(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function mO(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=rO({hideThanksAfterMs:dO,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:so()}),eh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:so()}),eh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>ku(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||lh()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&pO(e,c.current)){c.current=null,Math.random()<fO&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}pf(),B();var hO=[`1`,`2`,`3`],gO={1:`yes`,2:`no`,3:`dont_ask_again`},_O=e=>hO.includes(e);function vO({onSelect:e,inputValue:t,setInputValue:n}){return XE({inputValue:t,setInputValue:n,isValidDigit:_O,onDigit:t=>e(gO[t])}),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(x,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[mf,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can we look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(x,{marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(x,{marginLeft:2,children:[(0,$.jsx)(x,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(x,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(x,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}X(),B();function yO({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(xO,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(x,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(vO,{onSelect:r,inputValue:i,setInputValue:a}):i&&!$E(i)?null:(0,$.jsx)(tD,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var bO=e=>e===`1`;function xO({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return XE({inputValue:t,setInputValue:n,isValidDigit:bO,enabled:!!i,once:!0,onDigit:()=>{Z(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(x,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(T,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(T,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(T,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}Ch(),Eh(),Ne(),qa(),Xf();function SO(e){let{addNotification:t}=Xn(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{Fe()||n.current||(n.current=!0,Promise.resolve().then(()=>r.current()).then(e=>{if(e)for(let n of Array.isArray(e)?e:[e])t(n)}).catch(Y))},[t])}function CO(){SO(async()=>(await Th()).map((e,t)=>{let n=`low`;return e.type===`error`||e.userActionRequired?n=`high`:(e.type===`path`||e.type===`alias`)&&(n=`medium`),{key:`install-message-${t}-${e.type}`,text:e.message,priority:n,color:e.type===`error`?`error`:`warning`}}))}Rd(),q(),Ps(),Gp(),go(),k_(),Is(),B(),Ps();function wO(e,t,n){(0,Q.useRef)(null),(0,Q.useRef)(null);let r=(0,Q.useRef)(e),i=(0,Q.useRef)(n),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(null);r.current=e,i.current=n,(0,Q.useEffect)(()=>{},[!1,t]),(0,Q.useEffect)(()=>{if(n||!a.current)return;let e=F();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{F()},[n,!1])}X(),Mf(),q(),s(),Yd(),Xf();function TO(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var EO={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function DO(e){let t=EO.INITIAL_DELAY_MS*EO.BACKOFF_MULTIPLIER**e;return Math.min(t,EO.MAX_DELAY_MS)}function OO(e){if(!e.officialMarketplaceAutoInstallAttempted)return!0;if(e.officialMarketplaceAutoInstalled)return!1;let t=e.officialMarketplaceAutoInstallFailReason,n=e.officialMarketplaceAutoInstallRetryCount||0,r=e.officialMarketplaceAutoInstallNextRetryTime,i=Date.now();return n>=EO.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function kO(){let e=jf();if(!OO(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return J(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(TO())return J(`Official marketplace auto-install disabled via env var, skipping`),Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await vl())[`claude-plugins-official`])return J(`Official marketplace '${ul}' already installed, skipping`),Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!is(nu))return J(`Official marketplace blocked by enterprise policy, skipping`),Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=Dt(),n=I_(t,ul);if(await ws(n,t)!==null){let e=await vl();return e[ul]={source:nu,installLocation:n,lastUpdated:new Date().toISOString()},await ms(e),Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await to()){J(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+DO(t),i=!1;try{Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Y(Hd(e)),J(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}J(`Attempting to auto-install official marketplace`),await bo(nu),J(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return Ri(),J(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};J(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Y(Hd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+DO(r),o=!1;try{Af(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Y(Hd(e)),J(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}B(),q();function AO(){SO(async()=>{let e=await kO(),t=[];return e.configSaveFailed&&(J(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(T,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(J(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(T,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(J(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(T,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}xf(),X();function jO(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:S_(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function MO(e){if(bf().spinnerTipsEnabled===!1)return;let t=await w_(e);if(t.length!==0)return jO(t)}function NO(e){x_(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}Yd(),Xf(),Ne(),G(),en();var PO=!1;async function FO(e,t,n){{if(PO)return;PO=!0;let{updateContext:r,notification:i}=await dr(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function IO(){PO=!1}function LO(){let e=K(e=>e.mainLoopModel),t=K(e=>e.mainLoopModelForSession),n=K(e=>e.fastMode),r=as(),i=Cd(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{Fe()||(a.current?a.current=!1:IO(),FO(i.getState().toolPermissionContext,r,n).catch(e=>{Y(Error(`Auto mode gate check failed`,{cause:Hd(e)}))}))},[e,t,n])}_s();function RO(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!xl()||r.current||(r.current=!0,e&&Pl(e,n))},[t,e,n])}B(),sa(),X(),Xt(),Vg();function zO({hostPattern:{host:e},onUserResponse:t}){function n(n){switch(process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:n}),n){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...yi()?[]:[{label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(T,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(T,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Ug,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(x,{children:(0,$.jsx)(jd,{options:r,onChange:n,onCancel:()=>{process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:`cancel`}),t({allow:!1,persistToSettings:!1})}})})]})})}B(),sa(),np();function BO(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function VO(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=na.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!na.isSandboxingEnabled()||tp()===`linux`||n===0?null:(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(x,{marginLeft:0,children:(0,$.jsxs)(T,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(x,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[BO(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(x,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}jg(),qa(),Ne(),B();var HO=[];function UO({mcpClients:e=HO}){let{addNotification:t}=Xn();(0,Q.useEffect)(()=>{if(Fe())return;let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`&&e.config.type!==`claudeai-proxy`),r=e.filter(e=>e.type===`failed`&&e.config.type===`claudeai-proxy`&&Cr(e.name)),i=e.filter(e=>e.type===`needs-auth`&&e.config.type!==`claudeai-proxy`),a=e.filter(e=>e.type===`needs-auth`&&e.config.type===`claudeai-proxy`&&Cr(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}B(),xf(),ea();var WO=`Auto mode lets Claude handle permission prompts automatically — Claude checks each tool call for risky actions and prompt injection before executing. Actions Claude identifies as safe are executed, while actions Claude identifies as risky are blocked and Claude may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Claude can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;V(),Ne(),qa(),B(),G(),q(),s();var GO=5e3;function KO(){let{addNotification:e}=Xn(),t=as(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),J(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Fe()||Xe())return;let e=Io();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=Zu();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);re(s,n?GO:null),Q.useEffect(()=>{Fe()||!n||s()},[s,n])}q();var qO=new Map;async function JO(e){if(!e||!e.trim())return J(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=qO.get(t);if(n!==void 0)return J(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await $f(t).catch(()=>null)&&(r=!0),qO.set(t,r),J(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Mf(),q(),ju();var YO=5;function XO(e){return yf.has(e.toLowerCase())}function ZO(e){if(!e)return null;if(typeof e==`string`)return J(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=$O(t);if(e)return e}return null}return $O(e)}function QO(e){return typeof e==`object`&&!!e}function $O(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!QO(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(QO(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function ek(){let e=new Map;try{let t=await vl();for(let n of Object.keys(t))try{let t=await Wi(n),r=XO(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=ZO(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){J(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){J(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function tk(e){if(ik())return J(`[lspRecommendation] Recommendations are disabled`),[];let t=F_(e).toLowerCase();if(!t)return J(`[lspRecommendation] No file extension found`),[];J(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await ek(),r=jf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){J(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Ja(e)){J(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await JO(e.command)?(a.push({info:e,pluginId:t}),J(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):J(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function nk(e){Af(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),J(`[lspRecommendation] Added ${e} to never suggest`)}function rk(){Af(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),J(`[lspRecommendation] Incremented ignored count`)}function ik(){let e=jf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=YO}u(),Ne(),B(),Xf(),ju();function ak(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{Fe()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Y).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function ok(e,t,n,r,i){try{let a=await Fs(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(T,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Y(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(T,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ne(),qa(),G(),Mf(),q(),Xf(),xf();var sk=28e3;function ck(){let e=K(e=>e.fileHistory.trackedFiles),{addNotification:t}=Xn(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=ak();return Q.useEffect(()=>{a(async()=>{if($e())return null;let t=[];for(let r of e)n.current.has(r)||(n.current.add(r),t.push(r));for(let e of t)try{let t=(await tk(e))[0];if(t)return J(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ie(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:F_(e),shownAt:Date.now()}}catch(e){Y(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(J(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:ok(n,a,`lsp-plugin`,t,async e=>{J(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?I_(e.marketplaceInstallLocation,e.entry.source):void 0;await Oc(n,e.entry,`user`,void 0,t),Df(`userSettings`,{enabledPlugins:{..._f(`userSettings`)?.enabledPlugins,[n]:!0}}),J(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=sk&&(J(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),rk());break}case`never`:nk(n);break;case`disable`:Af(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),Xt(),Vg();var lk=3e4;function uk({pluginName:e,pluginDescription:t,fileExtension:n,onResponse:r}){let i=Q.useRef(r);i.current=r,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),lk,i);return()=>clearTimeout(e)},[]);function a(e){switch(e){case`yes`:r(`yes`);break;case`no`:r(`no`);break;case`never`:r(`never`);break;case`disable`:r(`disable`);break}}return(0,$.jsx)(Ug,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),t&&(0,$.jsx)(x,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(T,{children:[` `,n,` files`]})]}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(x,{children:(0,$.jsx)(jd,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(T,{children:[`Never for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}qa(),X(),q(),gi();function dk(){let e=Q.useSyncExternalStore(Kl,Ku),{addNotification:t}=Xn(),{recommendation:n,clearRecommendation:r,tryResolve:i}=ak();return Q.useEffect(()=>{e&&i(async()=>{let t=await jo(e);return t&&(J(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Xs()),Ku()===e&&el(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(uo(n.pluginId),Z(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;ok(e,r,`hint-plugin`,t,async t=>{let n=await Mi({pluginId:e,entry:t.entry,marketplaceName:i,scope:`user`,trigger:`hint`});if(!n.success)throw Error(n.success?`Unknown error`:n.error)});break}case`disable`:Pr();break;case`no`:break}r()}},[n,t,r])}}B(),Xt(),Vg();var fk=3e4;function pk({pluginName:e,pluginDescription:t,marketplaceName:n,sourceCommand:r,onResponse:i}){let a=Q.useRef(i);a.current=i,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),fk,a);return()=>clearTimeout(e)},[]);function o(e){switch(e){case`yes`:i(`yes`);break;case`disable`:i(`disable`);break;default:i(`no`)}}return(0,$.jsx)(Ug,{title:`Plugin Recommendation`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`The `,(0,$.jsx)(T,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsxs)(x,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(T,{children:[` `,n]})]}),t&&(0,$.jsx)(x,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install it?`})}),(0,$.jsx)(x,{children:(0,$.jsx)(jd,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}Xt(),Vg();var mk=3e4;function hk({tools:e,onSelect:t,onDismiss:n}){let r=Q.useRef(t),i=Q.useRef(n);r.current=t,i.current=n,Q.useEffect(()=>{let e=setTimeout(e=>e.current(),mk,i);return()=>clearTimeout(e)},[]);let a=e.map(e=>({label:`${e.name} — ${e.description.slice(0,60)} (score: ${e.score.toFixed(2)})`,value:e.name}));return a.push({label:`Dismiss`,value:`__dismiss__`}),(0,$.jsx)(Ug,{title:`Tool Recommendation`,children:(0,$.jsx)(jd,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}Kt();var gk=.15,_k=3;function vk(){let e=Q.useSyncExternalStore(Ia,Dd),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,_k).map(e=>({name:e.name,description:e.description.slice(0,60),score:e.score})),[e]);return{tools:t,visible:t.length>0&&(t[0]?.score??0)>=gk,handleSelect:Q.useCallback(e=>{Zi()},[]),handleDismiss:Q.useCallback(()=>{Zi()},[])}}Ne(),Nd(),q(),Vf(),Zd();var yk=`1.1.2396`;function bk(){let e=[process.argv[1]||``,process.execPath||``],t=[`/build-ant/`,`/build-ant-native/`,`/build-external/`,`/build-external-native/`];return e.some(e=>t.some(t=>e.includes(t)))}function xk(e){let t=bk()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,Pd()),n.toString()}async function Sk(){if(bk())return!0;let e=process.platform;if(e===`darwin`)return uf(`/Applications/Claude.app`);if(e===`linux`){let{code:e,stdout:t}=await Hf(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await Hf(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function Ck(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await Hf(`defaults`,[`read`,`/Applications/Claude.app/Contents/Info.plist`,`CFBundleShortVersionString`]);if(e!==0)return null;let n=t.trim();return n.length>0?n:null}else if(e===`win32`){let e=process.env.LOCALAPPDATA;if(!e)return null;let t=I_(e,`AnthropicClaude`);try{let e=(await G_(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,ev.coerce)(e)!==null).sort((e,t)=>{let n=(0,ev.coerce)(e),r=(0,ev.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function wk(){if(!await Sk())return{status:`not-installed`};let e;try{e=await Ck()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,ev.coerce)(e);return!t||!Wm(t.version,yk)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function Tk(e){let t=process.platform;if(J(`Opening deep link: ${e}`),t===`darwin`){if(bk()){let{code:t}=await Hf(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await Hf(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await Hf(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await Hf(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function Ek(){let e=pt();if(!await Sk())return{success:!1,error:`Claude Desktop is not installed. Install it from https://claude.ai/download`};let t=xk(e);return await Tk(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Claude Desktop. Please try opening it manually.`,deepLinkUrl:t}}B(),Ys(),Yd(),kr(),Ac();var Dk=`https://clau.de/desktop`;function Ok(){switch(process.platform){case`win32`:return`https://claude.ai/api/desktop/win32/x64/exe/latest/redirect`;default:return`https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect`}}function kk({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return oe(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?(Wl(Ok()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${Dk}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${Dk}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await wk();if(t.status===`not-installed`){o(`Claude Desktop is not installed.`),n(`prompt-download`);return}if(t.status===`version-too-old`){o(`Claude Desktop needs to be updated (found v${t.version}, need v1.1.2396+).`),n(`prompt-download`);return}n(`flushing`),await Xc(),n(`opening`);let r=await Ek();if(!r.success){i(r.error??`Failed to open Claude Desktop`),n(`error`);return}n(`success`),setTimeout(async e=>{e(`Session transferred to Claude Desktop`,{display:`system`}),await Br(0,`other`)},500,e)}t().catch(e=>{i(Ld(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(T,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(T,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(T,{children:a}),(0,$.jsx)(T,{children:`Download now? (y/n)`})]}):(0,$.jsx)(fe,{message:{checking:`Checking for Claude Desktop…`,flushing:`Saving session…`,opening:`Opening Claude Desktop…`,success:`Opening in Claude Desktop…`}[t]})}B(),X(),Mf(),Xt(),Vg();var Ak={enable_shortcut_tip:!1,enable_startup_dialog:!1};function jk(){return Ak}function Mk(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function Nk(){if(!Mk()||!jk().enable_startup_dialog)return!1;let e=jf();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function Pk({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(jf().desktopUpsellSeenCount??0)+1;Af(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),Z(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(kk,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:Af(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(Ug,{title:`Try Claude Code Desktop`,children:(0,$.jsxs)(x,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(x,{marginBottom:1,children:(0,$.jsx)(T,{children:`Same Claude Code with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(jd,{options:[{label:`Open in Claude Code Desktop`,value:`try`},{label:`Not now`,value:`not-now`},{label:`Don't ask again`,value:`never`}],onChange:r,onCancel:()=>r(`not-now`)})]})})}Ne(),qa(),B(),G(),q(),Cp();function Fk(){let{addNotification:e}=Xn(),t=K(e=>e.plugins.installationStatus),{totalFailed:n,failedMarketplacesCount:r,failedPluginsCount:i}=(0,Q.useMemo)(()=>{if(!t)return{totalFailed:0,failedMarketplacesCount:0,failedPluginsCount:0};let e=t.marketplaces.filter(e=>e.status===`failed`),n=t.plugins.filter(e=>e.status===`failed`);return{totalFailed:e.length+n.length,failedMarketplacesCount:e.length,failedPluginsCount:n.length}},[t]);(0,Q.useEffect)(()=>{if(!Fe()){if(!t){J(`No installation status to monitor`);return}n!==0&&(J(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(J(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n,` `,Sp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}Ne(),qa(),B(),q(),Zg();function Ik(){let{addNotification:e}=Xn(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!Fe())return Qg(e=>{J(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(Fe()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(T,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),J(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}q(),Xf(),ju(),Qh(),X();function Lk(e,t,n,r){e(e=>({...e,plugins:{...e.plugins,installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.map(e=>e.name===t?{...e,status:n,error:r}:e)}}}))}async function Rk(e){J(`performBackgroundPluginInstallations called`);try{let t=Nh(ko(),await vl().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;J(`Installing ${n.length} marketplace(s) in background`);let r=await Mh({onProgress:t=>{switch(t.type){case`installing`:Lk(e,t.name,`installing`);break;case`installed`:Lk(e,t.name,`installed`);break;case`failed`:Lk(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(Z(`tengu_marketplace_background_install`,i),Rf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){lo(),J(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Zh(e)}catch(t){Y(t),J(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),an(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(lo(),an(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Y(e)}}Mf(),q(),ju(),_n();async function zk(e){if(J(`performStartupChecks called`),!Pf()){J(`Trust not accepted for current directory - skipping plugin installations`);return}try{J(`Starting background plugin installations`),await jl()&&(lo(),an(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await Rk(e)}catch(e){J(`Error initiating background plugin installations: ${e}`)}}B();var Bk=/https?:\/\/\S+/;function Vk(){let[e,t]=(0,Q.useState)(qp.getInstance().getStatus());return(0,Q.useEffect)(()=>qp.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(x,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(T,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(x,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(Bk);if(!n)return(0,$.jsx)(T,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(T,{dimColor:!0,children:[a,(0,$.jsx)(w,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(x,{marginTop:1,children:(0,$.jsx)(T,{color:`error`,children:e.error})})]})}qa(),B(),pn(),Ap(),Zp(),Ne();function Hk(e){let{addNotification:t}=Xn(),n=cS(),r=(0,Q.useMemo)(()=>Fc(n,e),[n,e]),i=(0,Q.useMemo)(()=>Nt(n),[n]),a=(0,Q.useRef)(null),o=Pp(),s=zp(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{Fe()||(n.isUsingOverage&&!l&&(!c||s)?(t({key:`limit-reached`,text:i,priority:`immediate`}),u(!0)):!n.isUsingOverage&&l&&u(!1))},[n.isUsingOverage,i,l,t,s,c]),(0,Q.useEffect)(()=>{Fe()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(T,{children:(0,$.jsx)(T,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}qa(),Ne();function Uk(e){let{addNotification:t}=Xn(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(Fe())return;let r=C_(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var Wk=``;function Gk(){SO(async()=>vp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await wh()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:Wk,color:`warning`,priority:`high`})}qa(),B(),Mf(),pu(),Ne();var Kk=5;function qk({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Xn(),{status:a,ideName:o}=sS(t),s=(0,Q.useRef)(!1),c=n?Fu(n?.ideType):!1,l=n?.error||c,u=a===`connected`&&(e?.filePath||e?.text&&e.lineCount>0),d=a===`connected`&&!u,f=l&&!c&&!d&&!u,p=l&&c&&!d&&!u;(0,Q.useEffect)(()=>{if(Fe())return;if(vs()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(jf().ideHintShownCount??0)>=Kk)return;let e=setTimeout((e,t)=>{ks(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Af(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(T,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!Fe()){if(f||p||a!==`disconnected`||!o){i(`ide-status-disconnected`);return}r({key:`ide-status-disconnected`,text:`${o} disconnected`,color:`error`,priority:`medium`})}},[r,i,a,o,f,p]),(0,Q.useEffect)(()=>{if(!Fe()){if(!p){i(`ide-status-jetbrains-disconnected`);return}r({key:`ide-status-jetbrains-disconnected`,text:`IDE plugin not connected · /status for info`,priority:`medium`})}},[r,i,p]),(0,Q.useEffect)(()=>{if(!Fe()){if(!f){i(`ide-status-install-error`);return}r({key:`ide-status-install-error`,text:`IDE extension install failed (see /status for info)`,color:`error`,priority:`medium`})}},[r,i,f])}Mf();var Jk=[e=>{if(Xk(e.sonnet45To46MigrationTimestamp))return{key:`sonnet-46-update`,text:`Model updated to Sonnet 4.6`,color:`suggestion`,priority:`high`,timeoutMs:3e3}},e=>{let t=!!e.legacyOpusMigrationTimestamp;if(Xk(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function Yk(){SO(()=>{let e=jf(),t=[];for(let n of Jk){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function Xk(e){return e!==void 0&&Date.now()-e<3e3}Ap(),B(),X(),Mf();var Zk=3;function Qk(){SO(async()=>{if((jf().subscriptionNoticeCount??0)>=Zk)return null;let e=await $k();return e===null?null:(Af(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Z(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(T,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`]}),priority:`low`})})}async function $k(){if(Fp())return null;let e=await Ip();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}qa(),G(),Qp(),_p(),Ne();var eA=`fast-mode-cooldown-started`,tA=`fast-mode-cooldown-expired`,nA=`fast-mode-org-changed`,rA=`fast-mode-overage-rejected`;function iA(){let{addNotification:e}=Xn(),t=K(e=>e.fastMode),n=as();(0,Q.useEffect)(()=>{if(!Fe()&&sm())return Xp(r=>{r?e({key:nA,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:nA,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!Fe()&&sm())return cm(t=>{n(e=>({...e,fastMode:!1})),e({key:rA,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(Fe()||!t)return;let n=om((t,n)=>{let r=aA(n,mp(t-Date.now(),{hideTrailingZeros:!0}));e({key:eA,invalidates:[tA],text:r,color:`warning`,priority:`immediate`})}),r=Jp(()=>{e({key:tA,invalidates:[eA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function aA(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}B(),Pi();function oA({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return A(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(x,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(x,{children:(0,$.jsx)(T,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(x,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,(0,$.jsx)(g,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(x,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Reason: `,n]})})]})}function sA(e){if(process.env.USER_TYPE!==`ant`)return!1;switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function cA(e){return`/issue`}function lA(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}var uA=()=>null;pf(),B();function dA(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(x,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(x,{minWidth:2,children:(0,$.jsx)(T,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(T,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(T,{dimColor:!0,children:` /issue to report it`})]})]}):null}ym(),Ps();var fA=[/\bcurl\b/,/\bwget\b/,/\bssh\b/,/\bkubectl\b/,/\bsrun\b/,/\bdocker\b/,/\bbq\b/,/\bgsutil\b/,/\bgcloud\b/,/\baws\b/,/\bgit\s+push\b/,/\bgit\s+pull\b/,/\bgit\s+fetch\b/,/\bgh\s+(pr|issue)\b/,/\bnc\b/,/\bncat\b/,/\btelnet\b/,/\bftp\b/],pA=[/^no[,!]\s/i,/\bthat'?s (wrong|incorrect|not (what|right|correct))\b/i,/\bnot what I (asked|wanted|meant|said)\b/i,/\bI (said|asked|wanted|told you|already said)\b/i,/\bwhy did you\b/i,/\byou should(n'?t| not)? have\b/i,/\byou were supposed to\b/i,/\btry again\b/i,/\b(undo|revert) (that|this|it|what you)\b/i];function mA(e){for(let t of e){if(t.type!==`assistant`)continue;let e=t.message.content;if(Array.isArray(e))for(let t of e){if(t.type!==`tool_use`||!(`name`in t))continue;let e=t.name;if(e.startsWith(`mcp__`))return!1;if(e===`Bash`){let e=t.input?.command||``;if(fA.some(t=>t.test(e)))return!1}}}return!0}function hA(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=io(n);if(r)return pA.some(e=>e.test(r))}return!1}var gA=3,_A=1800*1e3;function vA(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>mA(e)&&hA(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<_A||t<gA||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}Ne(),B();function yA(){return process.env.USER_TYPE===`ant`}function bA(){let[e,t]=(0,Q.useState)(_t);return ae(()=>{t(_t())},yA()?500:null),!yA()||e.length===0?null:(0,$.jsxs)(T,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}t_(),B(),Mf(),id();function xA(e,t,n){let r=(0,Q.useRef)(!1),i=(0,Q.useRef)(n);i.current=n,(0,Q.useEffect)(()=>{if(t)return e.subscribe(()=>{let t=e.getState(),n=e.hasSelection();if(t?.isDragging){r.current=!1;return}if(!n){r.current=!1;return}if(r.current||!(jf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function SA(e){let[t]=b();(0,Q.useEffect)(()=>{e.setSelectionBgColor(on(t).selectionBg)},[e,t])}qa(),B(),Pi(),q();var CA=40,wA=.3,TA=6,EA=200,DA=15,OA=15,kA=3,AA=1500,jA=150,MA=5,NA=5,PA=80,FA=3,IA=6,LA=500;function RA(e){return!(e.wheelUp||e.wheelDown||(e.leftArrow||e.rightArrow||e.upArrow||e.downArrow||e.home||e.end||e.pageUp||e.pageDown)&&(e.shift||e.meta||e.super))}function zA(e){return!e.shift||e.meta?null:e.leftArrow?`left`:e.rightArrow?`right`:e.upArrow?`up`:e.downArrow?`down`:e.home?`lineStart`:e.end?`lineEnd`:null}function BA(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>AA&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>EA)return e.dir=t,e.time=n,e.mult=e.base,Math.floor(e.mult);e.wheelMode=!0}let r=n-e.time;if(t!==e.dir&&e.dir!==0)return e.pendingFlip=!0,e.time=n,0;if(e.dir=t,e.time=n,e.wheelMode)if(r<NA)if(++e.burstCount>=5)e.wheelMode=!1,e.burstCount=0,e.mult=e.base;else return 1;else e.burstCount=0;if(e.wheelMode){let t=.5**(r/jA),n=Math.max(OA,e.base*2),i=1+(e.mult-1)*t+DA*t;return e.mult=Math.min(n,i,e.mult+kA),Math.floor(e.mult)}if(r>CA)e.mult=e.base;else{let t=Math.max(TA,e.base*2);e.mult=Math.min(t,e.mult+wA)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<NA)return 1;if(!i||r>LA)e.mult=2,e.frac=0;else{let t=.5**(r/jA);e.mult=Math.min(r>=PA?FA:IA,1+(e.mult-1)*t+MA*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function VA(){let e=process.env.CLAUDE_CODE_SCROLL_SPEED;if(!e)return 1;let t=parseFloat(e);return Number.isNaN(t)||t<=0?1:Math.min(t,20)}function HA(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function UA(){let e=se(),t=VA();return J(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),HA(e,t)}var WA=2,GA=50,KA=200;function qA({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ue(),{addNotification:a}=Xn(),o=(0,Q.useRef)(null);function s(e){let t=le(),n=e.length,r;switch(t){case`native`:r=`copied ${n} chars to clipboard`;break;case`tmux-buffer`:r=`copied ${n} chars to tmux buffer · paste with prefix + ]`;break;case`osc52`:r=`sent ${n} chars via OSC 52 · check terminal clipboard settings if paste fails`;break}a({key:`selection-copied`,text:r,color:`suggestion`,priority:`immediate`,timeoutMs:t===`native`?2e3:4e3})}function c(){let e=i.copySelection();e&&s(e)}function l(e,t){let n=i.getState();if(!n?.anchor||!n.focus)return;let r=e.getViewportTop(),a=r+e.getViewportHeight()-1;if(n.anchor.row<r||n.anchor.row>a||n.focus.row<r||n.focus.row>a)return;let o=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),s=e.getScrollTop()+e.getPendingDelta(),c=Math.max(0,Math.min(o,s+t))-s;if(c!==0)if(c>0)i.captureScrolledRows(r,r+c-1,`above`),i.shiftSelection(-c,r,a);else{let e=-c;i.captureScrolledRows(a-e+1,a,`below`),i.shiftSelection(e,r,a)}}return y({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=XA(t,r);n?.(i,t)},"scroll:pageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=XA(t,r);n?.(i,t)},"scroll:lineUp":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=UA()),QA(t,BA(o.current,-1,performance.now())),n?.(!1,t)},"scroll:lineDown":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=UA());let r=ZA(t,BA(o.current,1,performance.now()));n?.(r,t)},"scroll:top":()=>{let t=e.current;t&&(l(t,-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(0),n?.(!1,t))},"scroll:bottom":()=>{let t=e.current;if(!t)return;let r=Math.max(0,t.getScrollHeight()-t.getViewportHeight());l(t,r-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(r),t.scrollToBottom(),n?.(!0,t)},"selection:copy":c},{context:`Scroll`,isActive:t}),y({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=XA(t,r);n?.(i,t)},"scroll:halfPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=XA(t,r);n?.(i,t)},"scroll:fullPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,t.getViewportHeight());l(t,r);let i=XA(t,r);n?.(i,t)},"scroll:fullPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,t.getViewportHeight());l(t,r);let i=XA(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),oe((t,r,i)=>{let a=e.current;if(!a)return;let o=ej(a,$A(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),oe((e,t,n)=>{if(!i.hasSelection())return;if(t.escape){i.clearSelection(),n.stopImmediatePropagation();return}if(t.ctrl&&!t.shift&&!t.meta&&e===`c`){c(),n.stopImmediatePropagation();return}let r=zA(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}RA(t)&&i.clearSelection()},{isActive:t}),JA(e,i,t,n),xA(i,t,s),SA(i),null}function JA(e,t,n,r){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o=(0,Q.useRef)(0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(r);c.current=r,(0,Q.useEffect)(()=>{if(!n)return;function r(){a.current=0,i.current&&(clearInterval(i.current),i.current=null)}function l(){let n=t.getState(),i=e.current,o=a.current;if(!n?.isDragging||!n.focus||!i||o===0||++s.current>KA){r();return}if(i.getPendingDelta()!==0)return;let l=i.getViewportTop(),u=l+i.getViewportHeight()-1;if(o<0){if(i.getScrollTop()<=0){r();return}let e=Math.min(WA,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-2)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(WA,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(WA)}c.current?.(!1,i)}function u(e){o.current=e,a.current!==e&&(r(),a.current=e,s.current=0,l(),a.current===e&&(i.current=setInterval(l,GA)))}function d(){let n=e.current;if(!n){r();return}let i=n.getViewportTop(),a=i+n.getViewportHeight()-1,s=t.getState();(!s?.isDragging||s.scrolledOffAbove.length===0&&s.scrolledOffBelow.length===0)&&(o.current=0);let c=YA(s,i,a,o.current);if(c===0){if(o.current!==0&&s?.focus){let e=s.focus.row<i?-1:+(s.focus.row>a);e!==0&&e!==o.current&&(s.scrolledOffAbove=[],s.scrolledOffBelow=[],s.scrolledOffAboveSW=[],s.scrolledOffBelowSW=[],o.current=0)}r()}else u(c)}let f=t.subscribe(d);return()=>{f(),r(),o.current=0}},[n,e,t])}function YA(e,t,n,r=0){if(!e?.isDragging||!e.anchor||!e.focus)return 0;let i=e.focus.row,a=i<t?-1:+(i>n);return r===0?e.anchor.row<t||e.anchor.row>n?0:a:a===r?a:0}function XA(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),r=e.getScrollTop()+e.getPendingDelta()+t;return r>=n?(e.scrollTo(n),e.scrollToBottom(),!0):(e.scrollTo(Math.max(0,r)),!1)}function ZA(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return e.getScrollTop()+e.getPendingDelta()+t>=n?(e.scrollToBottom(),!0):(e.scrollBy(t),!1)}function QA(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function $A(e,t){if(t.meta)return null;if(!t.ctrl&&!t.shift){if(t.upArrow)return`lineUp`;if(t.downArrow)return`lineDown`;if(t.home)return`top`;if(t.end)return`bottom`}if(t.ctrl){if(t.shift)return null;switch(e){case`u`:return`halfPageUp`;case`d`:return`halfPageDown`;case`b`:return`fullPageUp`;case`f`:return`fullPageDown`;case`n`:return`lineDown`;case`p`:return`lineUp`;default:return null}}let n=e[0];if(!n||e!==n.repeat(e.length))return null;if(n===`G`||n===`g`&&t.shift)return`bottom`;if(t.shift)return null;switch(n){case`g`:return`top`;case`j`:return`lineDown`;case`k`:return`lineUp`;case` `:return`fullPageDown`;case`b`:return`fullPageUp`;default:return null}}function ej(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),XA(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),XA(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),XA(e,i)}case`top`:return n(-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(0),!1;case`bottom`:{let t=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return n(t-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(t),e.scrollToBottom(),!0}}}var tj=r({useProactive:()=>nj});function nj(e){let t=(0,rj.useRef)(e);t.current=e,(0,rj.useEffect)(()=>{if(!Im())return;let e=null,n=!1,r=!1;function i(){Fm(Date.now()+ij),e=setTimeout(()=>{if(e=null,!Bm()){i();return}let{isLoading:a,queuedCommandsLength:o,hasActiveLocalJsxUI:s,isInPlanMode:c}=t.current;if(a||c||s||o>0||r){i();return}r=!0,(async()=>{let e=await It({basePrompt:`<${Jf}>${new Date().toLocaleTimeString()}</${Jf}>`,currentDir:Pd(),shouldCreate:()=>!n});if(n){await En({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await En({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>J(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},ij)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),Fm(null)}},[Im(),Nm(),Um()])}var rj,ij,aj=t((()=>{rj=n(z(),1),Wf(),Nd(),Rc(),q(),ij=3e4}));function oj(e){if(e.tokenBudget!==null){let t=Math.max(0,e.tokenBudget-e.tokensUsed);return`Tokens used: ${e.tokensUsed} / ${e.tokenBudget} (${t} remaining)`}return`Tokens used: ${e.tokensUsed}`}function sj(e){let t=Ho(e),n=oj(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
85
- You have an active goal to work on. Continue making progress.
86
-
87
- ## Active Goal
88
- ${e.objective}
89
-
90
- ## Status
91
- - Elapsed active time: ${t}
92
- - ${n}
93
- - ${r}
94
-
95
- ## Instructions
96
-
97
- Continue working towards the goal. Do NOT narrow the scope of the goal — even if you cannot complete everything in one turn, maintain the full objective and make as much progress as possible.
98
-
99
- When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
100
-
101
- ### Completion Audit
102
- 1. Derive concrete requirements from the objective and any referenced files.
103
- 2. Preserve the original scope — do not redefine success around what is already done.
104
- 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
105
- 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
106
- 5. Treat uncertain or indirect evidence as "not achieved".
107
- 6. The audit must PROVE completion, not merely fail to find remaining work.
108
-
109
- ### Blocked Audit
110
- If you encounter an obstacle you genuinely cannot overcome:
111
- - Do NOT mark blocked on the first encounter.
112
- - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
113
- - "Difficult", "slow", or "partially incomplete" is NOT blocked.
114
- - If blocked, use the GoalTool with status "blocked" and a clear reason.
115
-
116
- Resume working now.
117
- </goal-steering>`}function cj(e){return`<goal-steering type="budget_limit">
118
- ## Token Budget Reached
119
-
120
- Your token budget for this goal has been exhausted.
121
-
122
- - Goal: ${e.objective}
123
- - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
124
- - Active time: ${Ho(e)}
125
-
126
- **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
127
-
128
- Instead, provide a brief summary:
129
- 1. What has been accomplished so far.
130
- 2. What remains to be done.
131
- 3. Any blockers or issues encountered.
132
-
133
- Then use the GoalTool to mark the goal as complete (if truly done) or leave it in its current state for the user to decide.
134
- </goal-steering>`}var lj=t((()=>{})),uj=r({useGoalContinuation:()=>fj});function dj(e){J(`[goal] hook: ${e}`)}function fj(e){let t=(0,pj.useRef)(e);t.current=e;let n=(0,pj.useRef)(!1),r=(0,pj.useRef)(!1);(0,pj.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){dj(`skip: queryActiveNow=true`);return}if(e.wasAborted){dj(`skip: wasAborted=true`);return}if(n.current)return;if(Fa().length>0){dj(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){dj(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){dj(`skip: planMode`);return}let t=wd();if(!t){r.current=!1;return}if(t.status===`active`&&(r.current=!1),t.status===`budget_limited`&&!r.current){r.current=!0,n.current=!0;let e=cj(t);J(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Yr({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){dj(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){ln()&&(rn(),e.onMaxTurnsReached?.()),J(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=pd();rn();let a=sj(t);J(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Yr({value:a,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-continuation`,skipSlashCommands:!0}),e.onContinuationEnqueued?.({turn:i,objective:t.objective})},[e.isLoading,e.wasAborted,e.queuedCommandsLength,e.hasActiveLocalJsxUI,e.isInPlanMode])}var pj,mj=t((()=>{pj=n(z(),1),q(),ia(),lj(),Ua()})),hj=r({AntModelSwitchCallout:()=>gj,shouldShowModelSwitchCallout:()=>_j});function gj(e){return null}function _j(){return!1}t((()=>{})),Ne(),Ca(),sf(),u(),B(),fd(),sg(),qa(),q(),s(),_p(),Rc(),kt(),vo(),zh(),Es(),Lt(),$i(),Un(),Md(),Yd(),Xf(),Nd(),Pn(),en(),bi(),Mf(),Zp(),X(),Ps(),yh(),Wf(),kr(),Xo(),o_(),Dh(),pa(),xd(),mg(),G(),ya(),Ac(),_s(),pu(),jn(),Ua(),wl(),qi(),sa(),Wu();var vj=(jm(),e(Mm)),yj=e=>()=>{},bj=()=>!1,xj=()=>null,Sj=(e,t)=>!1,Cj=(aj(),e(tj)).useProactive,wj=(mj(),e(uj)).useGoalContinuation,Tj=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),Ej=()=>({routeToSelectedPipes:()=>!1}),Dj=process.env.USER_TYPE===`ant`?e(hj).AntModelSwitchCallout:null,Oj=process.env.USER_TYPE===`ant`?e(hj).shouldShowModelSwitchCallout:()=>!1,kj=[],Aj=3e3;function jj(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?Math.round((t[n-1]+t[n])/2):t[n]}function Mj({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=yr(`app:toggleTranscript`,`Global`,`ctrl+o`),o=yr(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(x,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${d.arrowUp}${d.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{flexGrow:1}),(0,$.jsxs)(T,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{flexGrow:1}),(0,$.jsxs)(T,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function Nj({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Eg({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(x,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(T,{children:`/`}),(0,$.jsx)(T,{children:s.slice(0,f)}),(0,$.jsx)(T,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(T,{children:s.slice(f+1)}),(0,$.jsx)(x,{flexGrow:1}),l===`building`?(0,$.jsx)(T,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(T,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(T,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(T,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var Pj=[`⠂`,`⠐`],Fj=`✳`,Ij=960;function Lj({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=j(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%Pj.length),Ij,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?Pj[a]??Fj:Fj;return N(n?null:r?t:`${s} ${t}`),null}var Rj=`<${Yf}>`;function zj(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(Rj)}function Bj({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:y=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:w,remoteSessionConfig:D,directConnectConfig:O,sshSession:k,thinkingConfig:ee}){let A=!!D,M=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),N=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),te=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(J(`[REPL:mount] REPL mounted, disabled=${y}`),()=>J(`[REPL:unmount] REPL unmounting`)),[y]);let[F,re]=(0,Q.useState)(S),I=K(e=>e.toolPermissionContext),L=K(e=>e.verbose),R=K(e=>e.mcp),z=K(e=>e.plugins),ae=K(e=>e.agentDefinitions),se=K(e=>e.fileHistory),ce=K(e=>e.initialMessage),le=rS(),ue=K(e=>e.spinnerTip),fe=K(e=>e.expandedView)===`tasks`,me=K(e=>e.tasks),B=K(e=>e.elicitation),ge=K(e=>e.viewingAgentTaskId),V=as(),_e=ge?me[ge]:void 0,ve=js(_e)&&_e.retain&&!_e.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ve)return;let e=ge;Hu(un(e)).then(t=>{V(n=>{let r=n.tasks[e];if(!js(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[ge,ve,V]);let ye=Cd(),xe=E(),Se=pg(),[Ce,we]=(0,Q.useState)(t);BD(A?void 0:tt(),we);let Te=Q.useSyncExternalStore(vj?.subscribeToProactiveChanges??yj,vj?.isProactiveActive??bj),Ee=Q.useSyncExternalStore(vj?.subscribeToProactiveChanges??yj,vj?.getNextTickAt??xj),De=K(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>al(I),[I,Te,De]);LO();let[ke,Ae]=(0,Q.useState)(f),je=(0,Q.useCallback)(e=>{Ae(e)},[Ae]),[Me,Ne]=(0,Q.useState)(`prompt`),[Fe,Ie]=(0,Q.useState)(!1),[ze,He]=(0,Q.useState)(!1),[Ue,Ge]=(0,Q.useState)(``),Ke=(0,Q.useRef)(0),Xe=(0,Q.useRef)(void 0),Qe=(0,Q.useRef)(!1),{addNotification:$e,removeNotification:rt}=Xn(),at=Sj,st=RD(d,R.clients),[ut,dt]=(0,Q.useState)(void 0),[mt,_t]=(0,Q.useState)(null),[vt,bt]=(0,Q.useState)(null),[xt,Ct]=(0,Q.useState)(!1),[wt,Et]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&Oj()),Dt=K(e=>e.showRemoteCallout),[Ot,kt]=(0,Q.useState)(()=>Nk());Yk(),Qk(),qk({ideSelection:ut,mcpClients:st,ideInstallationStatus:vt}),UO({mcpClients:st}),Fk(),Ik(),Ag(),Hk(Se),iA(),Uk(Se),Gk(),CO(),AO(),KO();let{recommendation:jt,handleResponse:Nt}=ck(),{recommendation:Ft,handleResponse:It}=dk(),Lt=vk(),zt=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);kh({enabled:!A});let Bt=vn();(0,Q.useEffect)(()=>{A||zk(V)},[V,A]);let Vt=ag(zt,R.tools,I),{tools:Ht,allowedAgentTypes:Ut}=(0,Q.useMemo)(()=>{if(!F)return{tools:Vt,allowedAgentTypes:void 0};let e=cc(F,Vt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[F,Vt]),Wt=zD(zD(Ce,z.commands),R.commands),Kt=(0,Q.useMemo)(()=>C?[]:Wt,[C,Wt]);jv(A?kj:R.clients),HD(A?kj:R.clients,dt);let[qt,Jt]=(0,Q.useState)(`responding`),Yt=(0,Q.useRef)(qt);Yt.current=qt;let[Xt,Qt]=(0,Q.useState)([]),[$t,en]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if($t&&!$t.isStreaming&&$t.streamingEndedAt){let e=3e4-(Date.now()-$t.streamingEndedAt);if(e>0){let t=setTimeout(en,e,null);return()=>clearTimeout(t)}else en(null)}},[$t]);let[tn,rn]=(0,Q.useState)(null),an=(0,Q.useRef)(null);an.current=tn;let on=(0,Q.useRef)(0),[sn,ln]=(0,Q.useState)(!1),dn=(0,Q.useRef)(()=>{}),pn=(0,Q.useRef)(()=>{}),gn=(0,Q.useRef)(null),_n=(0,Q.useRef)(null),bn=(0,Q.useRef)(0),xn=Q.useRef(new Dv).current,Sn=Q.useSyncExternalStore(xn.subscribe,xn.getSnapshot),[Cn,Tn]=Q.useState(D?.hasInitialPrompt??!1),H=Sn||Cn,[En,Dn]=Q.useState(void 0),On=Q.useRef(0),kn=Q.useRef(!1),An=Q.useRef(0),jn=Q.useRef(0),Mn=Q.useRef(null),Pn=Q.useCallback(()=>{An.current=Date.now(),jn.current=0,Mn.current=null},[]),In=Q.useRef(!1);Sn&&!In.current&&Pn(),In.current=Sn;let Rn=Q.useCallback(e=>{Tn(e),e&&Pn()},[Pn]),zn=Q.useRef(void 0),[Bn,Vn]=Q.useState(!1),[Hn,Un]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Hn?.notifications&&Hn.notifications.forEach(e=>{$e({key:`auto-updater-notification`,text:e,priority:`low`})})},[Hn,$e]),(0,Q.useEffect)(()=>{Ts()&&Ul().then(e=>{e&&$e({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Wn,Kn]=(0,Q.useState)(null),Yn=(0,Q.useRef)(null),Zn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Yn.current={...n,isLocalJSXCommand:!0},Kn(n);return}if(Yn.current){if(e?.clearLocalJSX){Yn.current=null,Kn(null),on.current=Date.now();return}return}if(e?.clearLocalJSX){Kn(null);return}Kn(e)},[]),[Qn,$n]=(0,Q.useState)([]),[er,nr]=(0,Q.useState)(null),[rr,ir]=(0,Q.useState)([]),[ar,sr]=(0,Q.useState)([]),cr=(0,Q.useRef)(new Map),dr=K(e=>e.settings.terminalTitleFromRename)===!1?void 0:cl(pt()),[fr,pr]=(0,Q.useState)(),mr=(0,Q.useRef)((i?.length??0)>0),gr=F?.agentType,_r=dr??gr??fr??`Work Mate`,yr=Qn.length>0||ar.length>0,xr=Wn?.isLocalJSXCommand===!0&&Wn?.jsx!=null,Sr=H&&!yr&&!xr;(0,Q.useEffect)(()=>{if(H&&!yr&&!xr)return bv(),()=>xv()},[H,yr,xr]);let Cr=yr||xr?`waiting`:H?`busy`:`idle`,wr=Cr===`waiting`?Qn.length>0?`approve ${Qn[0].tool.name}`:xr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Ln({status:Cr,waitingFor:wr})},[Cr,wr]),P(null);let[U,Er]=(0,Q.useState)(i??[]),Dr=(0,Q.useRef)(U),Or=(0,Q.useRef)(!1),W=(0,Q.useCallback)(e=>{let t=Dr.current,n=typeof e==`function`?e(Dr.current):e;if(Dr.current=n,n.length<On.current)On.current=0;else if(n.length>t.length&&kn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(Hr)?kn.current=!1:On.current=n.length}Er(n)},[]),kr=(0,Q.useCallback)(e=>{e===void 0?kn.current=!1:(On.current=Dr.current.length,kn.current=!0),Dn(e)},[]),{dividerIndex:jr,dividerYRef:Mr,onScrollAway:Nr,onRepin:Pr,jumpToNew:Ir,shiftDivider:Lr}=s_(U.length);wO(U,W,H);let[Rr,zr]=(0,Q.useState)(null),Br=(0,Q.useRef)(null),Vr=(0,Q.useMemo)(()=>i_(U,jr),[jr,U.length]),Ur=(0,Q.useCallback)(()=>{gn.current?.scrollToBottom(),Pr(),zr(null)},[Pr,zr]),Wr=U.at(-1),qr=Wr!=null&&Hr(Wr);(0,Q.useEffect)(()=>{qr&&Ur()},[qr,Wr,Ur]);let Zr=(0,Q.useCallback)((e,t)=>{bn.current=Date.now(),e?Pr():Nr(t)},[Pr,Nr,V]),Qr=uD(o,W),$r=(0,Q.useDeferredValue)(Q.useMemo(()=>U.length>500?U.slice(-500):U,[U])),ei=U.length-$r.length;ei>0&&J(`[useDeferredValue] Messages deferred by ${ei} (${$r.length}→${U.length})`);let[ti,ni]=(0,Q.useState)(null),[ri,ii]=(0,Q.useState)(()=>b_()),oi=(0,Q.useRef)(ri);oi.current=ri;let si=(0,Q.useRef)(null),li=(0,Q.useCallback)(e=>{at(oi.current,e)||(oi.current===``&&e!==``&&Date.now()-bn.current>=Aj&&Ur(),oi.current=e,ii(e),Vn(e.trim().length>0))},[Vn,Ur,at]);(0,Q.useEffect)(()=>{if(ri.trim().length===0)return;let e=setTimeout(Vn,1500,!1);return()=>clearTimeout(e)},[ri]);let[ui,di]=(0,Q.useState)(`prompt`),[pi,gi]=(0,Q.useState)(),_i=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||hr.has(e)))},[we]),[yi,bi]=(0,Q.useState)(new Set),xi=(0,Q.useRef)(!1),Si=WE({config:D,setMessages:W,setIsLoading:Rn,onInit:_i,setToolUseConfirmQueue:$n,tools:zt,setStreamingToolUses:Qt,setStreamMode:Jt,setInProgressToolUseIDs:bi}),wi=qE({config:O,setMessages:W,setIsLoading:Rn,setToolUseConfirmQueue:$n,tools:zt}),Ei=JE({session:k,setMessages:W,setIsLoading:Rn,setToolUseConfirmQueue:$n,tools:zt}),Di=Ei.isRemoteMode?Ei:wi.isRemoteMode?wi:Si,[Oi,Ai]=(0,Q.useState)({}),[ji,Mi]=(0,Q.useState)(0),Pi=(0,Q.useRef)(0),Fi=(0,Q.useRef)([]),Li=(0,Q.useCallback)(e=>{let t=Pi.current;if(Pi.current=e(t),Pi.current>t){let e=Fi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Pi.current}}},[]),[Ri,zi]=(0,Q.useState)(null),Bi=!(K(e=>e.settings.prefersReducedMotion)??!1)&&!he(),Vi=(0,Q.useCallback)(e=>{Bi&&zi(e)},[Bi]),Hi=Ri&&Bi&&Ri.substring(0,Ri.lastIndexOf(`
135
- `)+1)||null,[Ui,Wi]=(0,Q.useState)(0),[Gi,qi]=(0,Q.useState)(null),[Yi,Xi]=(0,Q.useState)(null),[Zi,$i]=(0,Q.useState)(null),[ea,sa]=(0,Q.useState)(!1),[la,ua]=(0,Q.useState)(void 0),[da,pa]=(0,Q.useState)(!1),[ma,ha]=(0,Q.useState)(U_()),[ga,_a]=(0,Q.useState)(null),va=(0,Q.useRef)(!1),ya=(0,Q.useRef)(Ui);ya.current=Ui;let[ba]=(0,Q.useState)(()=>({current:qn(i,c)}));hl(()=>{ba.current=tr()});let[Sa,Ca]=(0,Q.useState)(jf().hasAcknowledgedCostThreshold),[wa,Ta]=(0,Q.useState)(`INSERT`),[Ea,Da]=(0,Q.useState)(!1),[Oa,ka]=(0,Q.useState)(!1),[Aa,ja]=(0,Q.useState)(!1),Na=j(),Fa=(0,Q.useRef)(Na);Fa.current=Na;let[Ia]=b(),La=Q.useRef(!1),Ra=(0,Q.useCallback)(()=>{if(La.current)return;La.current=!0;let e=Dr.current.slice(oo.current);for(let t of hu(e))ao.current.add(t);oo.current=Dr.current.length,MO({theme:Ia,readFileState:io.current,bashTools:ao.current}).then(async e=>{if(e){let t=await e.content({theme:Ia});V(e=>({...e,spinnerTip:t})),NO(e)}else V(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[V,Ia]),za=(0,Q.useCallback)(()=>{Rn(!1),kr(void 0),Pi.current=0,Fi.current=[],zi(null),Qt([]),qi(null),Xi(null),$i(null),Ra(),nh(),ca()},[Ra]),Va=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(I.mode!==`auto`){Va.current=!1;return}if(Va.current||(jf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Af(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,ki(WO,`warning`)])},800,Va,W);return()=>clearTimeout(e)}},[I.mode,W]);let Ha=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ha.current)return;let e=cn();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ha.current=!0;let t=Math.round(e.creationDurationMs/1e3);W(e=>[...e,ki(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[W]);let Ua=(0,Q.useMemo)(()=>{let e=U.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&yi.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[U,yi]),{onBeforeQuery:Ga,onTurnComplete:Ka,render:qa}=sD({enabled:N,setMessages:W,inputValue:ri,setInputValue:li,setToolJSX:Zn}),Ja=(!Wn||Wn.showSpinner===!0)&&Qn.length===0&&ar.length===0&&(H||En||Gt()>0)&&!Ua&&(!Hi||De),Ya=Qn.length>0||ar.length>0||rr.length>0||B.queue.length>0,Xa=oO(U,H,ji,`session`,Ya),Za=oD(W),Qa=vA(U,ji),$a=(0,Q.useMemo)(()=>({...Xa,handleSelect:e=>{_o.current=!1;let t=Xa.handleSelect(e);e===`bad`&&!t&&sA(`feedback_survey_bad`)&&(go(`feedback_survey_bad`),_o.current=!0)}}),[Xa]),eo=mO(U,H,Ya,{enabled:!A}),to=uO(U,H,Ya,{enabled:!A});XD({autoConnectIdeFlag:p,ideToInstallExtension:mt,setDynamicMcpConfig:Ae,setShowIdeOnboarding:Ct,setIDEInstallationState:bt}),RO(s,se,e=>V(t=>({...t,fileHistory:e})));let no=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Au(n.messages),o=Cs();await Ao(`resume`,{getAppState:()=>ye.getState(),setAppState:V,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await Qu(`resume`,{sessionId:t,agentType:F?.agentType,model:Se});a.push(...s),r===`fork`?Kr(n,sd(t)):Ji(n,sd(t)),qh(n,V),n.fileHistorySnapshots&&Bs(n);let{agentDefinition:c}=Gh(n.agentSetting,S,ae);re(c),V(e=>({...e,agent:c?.agentType})),V(e=>({...e,standaloneAgentContext:Kh(n.agentName,n.agentColor)})),Xr(n.agentName),lo(a,n.projectPath??ht()),za(),rn(null),ha(t);let l=Gu(t);Gl(),ft(),ct(sd(t),n.fullPath?P_(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-CH6hdK0a.js`);if(await u(),await Ws(),_l(),Bl(n),n.goal){let{hydrateGoalFromTranscript:r}=(ra(),e(ud)),i=new Map;i.set(t,n.goal),r(i,t)}if(mr.current=!0,pr(void 0),r!==`fork`)Jh(),Yh(n.worktreeSession),Ar(),Qi({abortController:new AbortController,getAppState:()=>ye.getState(),setAppState:V});else{let e=cn();e&&nn(e)}l&&yt(l),ba.current&&r!==`fork`&&(ba.current=Fr(a,n.contentReplacements??[])),W(()=>a),Zn(null),li(``),Z(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Z(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[za,V]),[ro]=(0,Q.useState)(()=>fo(100)),io=(0,Q.useRef)(ro),ao=(0,Q.useRef)(new Set),oo=(0,Q.useRef)(0),so=(0,Q.useRef)(new Set),co=(0,Q.useRef)(new Set),lo=(0,Q.useCallback)((e,t)=>{let n=ls(e,t,100);io.current=Ki(io.current,n);for(let t of hu(e))ao.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(lo(i,ht()),Qi({abortController:new AbortController,getAppState:()=>ye.getState(),setAppState:V}))},[]);let{status:uo,reverify:po}=dD(),[mo,go]=(0,Q.useState)(null),_o=(0,Q.useRef)(!1),[vo,yo]=(0,Q.useState)(null),[bo,xo]=(0,Q.useState)(!1),So=!H&&da;function Co(){if(bo||vo)return;if(ea)return`message-selector`;if(Bn)return;if(rr[0])return`sandbox-permission`;let e=!Wn||Wn.shouldContinueAnimation;if(e&&Qn[0])return`tool-permission`;if(e&&ar[0])return`prompt`;if(e&&B.queue[0])return`elicitation`;if(e&&So)return`cost`;if(e&&ga)return`idle-return`;if(e&&xt)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&wt)return`model-switch`;if(e&&Dt)return`remote-callout`;if(e&&jt)return`lsp-recommendation`;if(e&&Ft)return`plugin-hint`;if(e&&Lt.visible)return`search-extra-tools-hint`;if(e&&Ot)return`desktop-upsell`}let wo=Co(),To=Bn&&(rr[0]||Qn[0]||ar[0]||B.queue[0]||So);zn.current=wo,(0,Q.useEffect)(()=>{if(!H)return;let e=wo===`tool-permission`,t=Date.now();e&&Mn.current===null?Mn.current=t:!e&&Mn.current!==null&&(jn.current+=t-Mn.current,Mn.current=null)},[wo,H]);let Do=(0,Q.useRef)(wo);(0,Q.useLayoutEffect)(()=>{Do.current===`tool-permission`!=(wo===`tool-permission`)&&Ur(),Do.current=wo},[wo,Ur]);function ko(){if(wo!==`elicitation`){if(on.current!==0&&Date.now()-on.current<500){on.current=0,J(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(on.current=0,J(`[onCancel] focusedInputDialog=${wo} streamMode=${qt}`),vj?.pauseProactive(),xn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ia(),e(os)),{persistCurrentGoal:r}=(ra(),e(ud));t()?.status===`active`&&(n(),r())}if(ln(!0),xn.forceEnd(),va.current=!1,Ri?.trim()&&W(e=>[...e,Pc({content:Ri})]),za(),lt(null),wo===`tool-permission`)Qn[0]?.onAbort(),$n([]);else if(wo===`prompt`){for(let e of ar)e.reject(Error(`Prompt cancelled by user`));sr([]),tn?.abort(`user-cancel`)}else Di.isRemoteMode?Di.cancelRequest():tn?.abort(`user-cancel`);rn(null),Ka(Dr.current,!0)}}let jo=(0,Q.useCallback)(()=>{let e=Tr(ri,0);e&&(li(e.text),di(`prompt`),e.images.length>0&&Ai(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[li,di,ri,Ai]),Mo={setToolUseConfirmQueue:$n,onCancel:ko,onAgentsKilled:()=>W(e=>[...e,wn()]),isMessageSelectorVisible:ea||!!Ea,screen:Me,abortSignal:tn?.signal,popCommandFromQueue:jo,vimMode:wa,isLocalJSXCommand:Wn?.isLocalJSXCommand,isSearchingHistory:Oa,isHelpOpen:Aa,inputMode:ui,inputValue:ri,streamMode:qt};(0,Q.useEffect)(()=>{qe()>=5&&!da&&!Sa&&(Z(`tengu_cost_threshold_reached`,{}),Ca(!0),Dp()&&pa(!0))},[U,da,Sa]);let No=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}ir(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[V,ye]);(0,Q.useEffect)(()=>{let e=na.getSandboxUnavailableReason();if(e){if(na.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),$l(1,`other`);return}J(`sandbox disabled: ${e}`,{level:`warn`}),$e({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(T,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[$e]),na.isSandboxingEnabled()&&na.initialize(No).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Ld(e)}\n`),$l(1,`other`)});let Po=(0,Q.useCallback)((e,t)=>{V(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},$n)},[V,$n]),Fo=kD($n,Po),Io=(0,Q.useCallback)((e,t,r,i)=>{let a=ye.getState(),o=()=>{let e=ye.getState(),t=xs(e.toolPermissionContext,e.mcp.tools),n=Ph(zt,t,e.toolPermissionContext.mode);return F?cc(F,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Kt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:ee,mcpClients:LD(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:vt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:Ia,agentDefinitions:Ut?{...a.agentDefinitions,allowedAgentTypes:Ut}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>ye.getState(),setAppState:V,messages:e,setMessages:W,updateFileHistoryState(e){V(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){V(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{y||sa(!0)},onChangeAPIKey:po,readFileState:io.current,setToolJSX:Zn,addNotification:$e,appendSystemMessage:e=>W(t=>[...t,e]),sendOSNotification:e=>{cv(e,xe)},onChangeDynamicMcpConfig:je,onInstallIDEExtension:_t,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:co.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:so.current,setResponseLength:Li,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Pi.current;Fi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Jt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Xi(`claudeBlue_FOR_SYSTEM_SPINNER`),$i(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),qi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:qi(`Compacting conversation`);break;case`compact_end`:qi(null),Xi(null),$i(null);break}},setInProgressToolUseIDs:bi,setHasInterruptibleToolInProgress:e=>{xi.current=e},resume:no,setConversationId:ha,requestPrompt:void 0,contentReplacementState:ba.current}},[Kt,zt,F,n,d,vt,ke,Ia,Ut,ye,V,po,$e,W,je,no,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{sr(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),y,h,g,ha]),{handleBackgroundSession:Lo}=QD({setMessages:W,setIsLoading:Rn,resetLoadingState:za,setAbortController:rn,onBackgroundQuery:(0,Q.useCallback)(()=>{tn?.abort(`background`);let e=ho(e=>e.mode===`task-notification`);(async()=>{let t=Io(Dr.current,[],new AbortController,Se),[n,r,i]=await Promise.all([Zc(t.options.tools,Se,Array.from(I.additionalWorkingDirectories.keys()),t.options.mcpClients),Gn(),Ii()]),a=Xl({mainThreadAgentDefinition:F,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await or(e).catch(()=>[])).map(Zt),s=new Set;for(let e of Dr.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));aa({messages:[...Dr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Fo,toolUseContext:t,querySource:zu()},description:_r,setAppState:V,agentDefinition:F})})()},[tn,Se,I,F,Io,h,g,Fo,V])}),Ro=(0,Q.useCallback)(t=>{Eo(t,t=>{if(ku(t)?(Ts()?W(e=>{let n=Jn(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):W(()=>[t]),ha(U_()),vj?.setContextBlocked(!1)):t.type===`progress`&&Ni(t.data?.type)?W(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):W(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?vj?.setContextBlocked(!0):t.type===`assistant`&&vj?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(xa(t.message?.content??``)??``).toLowerCase();if(n.includes(`connection error`)||n.includes(`fetch failed`)||n.includes(`network error`)||n.includes(`enotfound`)||n.includes(`econnreset`)||n.includes(`etimedout`)){let{getGoal:t,pauseGoal:n}=(ia(),e(os)),{persistCurrentGoal:r}=(ra(),e(ud));t()?.status===`active`&&(n(),r(),$e({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Li(t=>t+e.length)},Jt,Qt,e=>{W(t=>t.filter(t=>t!==e)),qc(e.uuid)},en,e=>{let t=Date.now(),n=Pi.current;Fi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Vi)},[W,Li,Jt,Qt,en,Vi]),zo=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=LD(d,ye.getState().mcp.clients);br.handleQueryStart(e);let t=dl(e);t&&At(t)}if(fh(),!M&&!dr&&!gr&&!mr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?xa(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(mr.current=!0,vh(n,new AbortController().signal).then(e=>{e?pr(e):mr.current=!1},()=>{mr.current=!1}))}if(ye.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(ku)&&(ha(U_()),vj?.setContextBlocked(!1)),za(),rn(null);return}let o=Io(e,t,n,a),{tools:s,mcpClients:c}=o.options;vu(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,FO(I,V,ye.getState().fastMode),Zc(s,a,Array.from(I.additionalWorkingDirectories.keys()),c),Gn(),Ii()]),p={...u,...vj?.isProactiveActive()&&!Fa.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};vu(`query_context_loading_end`);let m=Xl({mainThreadAgentDefinition:F,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,vu(`query_query_start`),it(),ot(),gt();for await(let t of Pt({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:Fo,toolUseContext:o,querySource:zu()}))Ro(t);if(vu(`query_end`),process.env.USER_TYPE===`ant`&&Fi.current.length>0){let e=Fi.current,t=e.map(e=>e.ttftMs),n=e.map(e=>{let t=Math.round((e.endResponseLength-e.responseLengthBaseline)/4),n=e.lastTokenTime-e.firstTokenTime;return n>0?Math.round(t/(n/1e3)):0}),r=e.length>1,i=Le(),a=St(),o=Ye(),s=Ve(),c=Je(),l=We(),u=Date.now()-An.current;W(e=>[...e,fn({ttftMs:r?jj(t):t[0],otps:r?jj(n):n[0],isP50:r,hookDurationMs:i>0?i:void 0,hookCount:a>0?a:void 0,turnDurationMs:u>0?u:void 0,toolDurationMs:o>0?o:void 0,toolCount:s>0?s:void 0,classifierDurationMs:c>0?c:void 0,classifierCount:l>0?l:void 0,configWriteCount:Nf()})])}za(),Dl(),await v?.(Dr.current)},[d,za,Io,I,V,h,v,g,Fo,F,Ro,dr,M]),Bo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=xn.tryStart();if(s===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>xa(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Yr({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{us.current=!1,ln(!1),Pn(),W(t=>[...t,...e]),Pi.current=0,lt((o?Wa(o):null)??Re()),Fi.current=[],Qt([]),zi(null);let s=Dr.current;if(o&&await Ga(o,s,e.length),a&&o&&!await a(o,s))return!0;try{await zo(s,e,t,n,r,i)}catch(e){throw e}}finally{if(xn.end(s)){ln(t.signal.aborted),Wi(Date.now()),va.current=!1,za(),await Ka(Dr.current,t.signal.aborted),dn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&V(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Re()!==null&&Re()>0&&!t.signal.aborted&&(e={tokens:Ze(),limit:Re(),nudges:nt()}),lt(null);let n=Date.now()-An.current-jn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&W(t=>[...t,Fn(n,e,tf(t,vr))]),rn(null)}if(t.signal.reason===`user-cancel`&&!xn.isActive&&oi.current===``&&Gt()===0&&!ye.getState().viewingAgentTaskId){let e=Dr.current,t=e.findLast(Ih);t&&Rh(e,e.lastIndexOf(t))&&(hi(),pn.current(t))}}return!0},[zo,V,za,xn,Ga,Ka]),G=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||H||G.current)return;G.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Ma():void 0,{clearConversation:n}=await import(`./conversation-D48Kt3ar.js`);await n({setMessages:W,readFileState:io.current,discoveredSkillNames:so.current,loadedNestedMemoryPaths:co.current,getAppState:()=>ye.getState(),setAppState:V,setConversationId:ha}),mr.current=!1,pr(void 0),ao.current.clear(),oo.current=0,t&&Ba(pt(),t)}V(t=>{let n=e.mode?ai(t.toolPermissionContext,Hb(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=fi({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),xl()&&es(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Qr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Vo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Gr();rn(t),Bo([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,G)}t(e)},[ce,H,W,V,Bo,Se,Ht]);let Vo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Ur(),vj?.resumeProactive(),ds(e)){let n=Jr({content:e});W(e=>[...e,n]),r?.fromKeybinding||rd({display:kd(e,ui),pastedContents:Oi}),li(``),t.setCursorOffset(0),t.clearBuffer(),Ai({}),di(`prompt`),dt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=fa(e,Oi).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Kt.find(e=>Tt(e)&&(e.name===a||e.aliases?.includes(a)||Oo(e)===a));s?.name===`clear`&&Or.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:Or.current,idleMinutes:Math.round((Date.now()-ya.current)/6e4),messageCount:Dr.current.length,totalInputTokens:Pe()}),Or.current=!1);let c=xn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===oi.current.trim()&&(li(``),t.setCursorOffset(0),t.clearBuffer(),Ai({}));let n=ci(e).filter(e=>Oi[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(Oi[t.id]?.content.length??0),0)}),Z(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Zn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&($e({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Ts())){let e=r?.displayArgs??o;i.push(Mt(Pa(Oo(s),e)),Mt(`<${Kf}>${Nn(n)}</${Kf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Jr({content:e,isMeta:!0}))),i.length&&W(e=>[...e,...i]),pi!==void 0&&(li(pi.text),t.setCursorOffset(pi.cursorOffset),Ai(pi.pastedContents),gi(void 0))},r=Io(Dr.current,[],Gr(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Zn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(Di.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(rd({display:n?e:kd(e,ui),pastedContents:n?{}:Oi}),ui===`bash`&&iC(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!H||n||Di.isRemoteMode;if(pi!==void 0&&!i&&a?(li(pi.text),t.setCursorOffset(pi.cursorOffset),Ai(pi.pastedContents),gi(void 0)):a&&(r?.fromKeybinding||(li(``),t.setCursorOffset(0)),Ai({})),a&&(di(`prompt`),dt(void 0),Mi(e=>e+1),t.clearBuffer(),La.current=!1,!i&&ui===`prompt`&&!n&&!Di.isRemoteMode&&(kr(e),Pn()),V(e=>({...e,attribution:oa(e.attribution,e=>{Ms(e).catch(e=>{J(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Ko(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:W,readFileState:io,cwd:ht()});if(t){let e=Gr();rn(e),Bo([],e,!0,[],Se)}return}if(Di.isRemoteMode&&!(i&&Kt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Tt(t)&&(t.name===n||t.aliases?.includes(n)||Oo(t)===n)})?.type===`local-jsx`)){let t=Object.values(Oi),n=t.filter(e=>e.type===`image`),r=n.length>0?n.map(e=>e.id):void 0,i=e.trim(),a=e.trim();if(t.length>0){let n=[],r=[],o=e.trim();o&&(n.push({type:`text`,text:o}),r.push({type:`text`,text:o}));for(let e of t)if(e.type===`image`){let t={type:`base64`,media_type:e.mediaType??`image/png`,data:e.content};n.push({type:`image`,source:t}),r.push({type:`image`,source:t})}else n.push({type:`text`,text:e.content}),r.push({type:`text`,text:e.content});i=n,a=r}let o=Jr({content:i,imagePasteIds:r});W(e=>[...e,o]),await Di.sendMessage(a,{uuid:o.uuid});return}await Qr(),await jD({input:e,helpers:t,queryGuard:xn,isExternalLoading:Cn,mode:ui,commands:Kt,onInputChange:li,setPastedContents:Ai,setToolJSX:Zn,getToolUseContext:Io,messages:Dr.current,mainLoopModel:Se,pastedContents:Oi,ideSelection:ut,setUserInputOnProcessing:kr,setAbortController:rn,abortController:tn,onQuery:Bo,setAppState:V,querySource:zu(),onBeforeQuery:_,canUseTool:Fo,addNotification:$e,setMessages:W,streamMode:Yt.current,hasInterruptibleToolInProgress:xi.current}),(i||H)&&pi!==void 0&&(li(pi.text),t.setCursorOffset(pi.cursorOffset),Ai(pi.pastedContents),gi(void 0))},[xn,H,Cn,ui,Kt,li,di,Ai,Mi,dt,Zn,Io,Se,Oi,ut,kr,rn,$e,Bo,pi,gi,V,_,Fo,Si,W,Qr,Ur]),Ho=(0,Q.useCallback)(()=>{let e=mo?cA(mo):`/issue`;go(null),Vo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{J(`Auto-run ${e} failed: ${Ld(t)}`)})},[Vo,mo]),Uo=(0,Q.useCallback)(()=>{go(null)},[]),Wo=(0,Q.useCallback)(()=>{Vo(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{J(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Vo]),Go=(0,Q.useRef)(Vo);Go.current=Vo;let qo=(0,Q.useCallback)(async()=>{if(xo(!0),mi()){Y_(`tmux`,[`detach-client`],{stdio:`ignore`}),xo(!1);return}if(cn()!==null){yo((0,$.jsx)(Fg,{showWorktree:!0,onDone:()=>{},onCancel:()=>{yo(null),xo(!1)}}));return}let e=await(await As.load()).call(()=>{});yo(e),e===null&&xo(!1)},[]),Jo=(0,Q.useCallback)(()=>{sa(e=>!e)},[]),Yo=(0,Q.useCallback)(e=>{let t=Dr.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),W(t.slice(0,n)),ha(U_()),ur();let r=e.permissionMode;V(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[W,V]),Xo=(0,Q.useCallback)(e=>{Yo(e);let t=Vl(e);if(t&&(li(t.text),di(t.mode)),Array.isArray(e.message.content)&&e.message.content.some(e=>e.type===`image`)){let t=e.message.content.filter(e=>e.type===`image`);if(t.length>0){let n={};t.forEach((t,r)=>{if(t.source.type===`base64`){let i=e.imagePasteIds?.[r]??r+1;n[i]={id:i,type:`image`,content:t.source.data,mediaType:t.source.media_type}}}),Ai(n)}}},[Yo,li]);pn.current=Xo;let Zo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Xo,e)},[Xo]),Qo=e=>{let t=e.slice(0,24);return U.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:$o,handlers:ts}=vi(Rr,zr,Br,{copy:e=>void ie(e).then(e=>{e&&process.stdout.write(e),$e({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Qo(e.uuid),n=t>=0?U[t]:void 0;if(!n||!Ih(n))return;let r=!await Tc(se,n.uuid),i=Rh(U,t);r&&i?(ko(),Zo(n)):(ua(n),sa(!0))}});async function ns(){po();let e=await lr();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
136
- `);J(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else J(`No CLAUDE.md/rules files found`);for(let t of e)io.current.set(t.path,{content:t.contentDiffersFromDisk?t.rawContent??t.content:t.content,timestamp:Date.now(),offset:void 0,limit:void 0,isPartialView:t.contentDiffersFromDisk})}cD(y_()),Ov(U,U.length===i?.length);let{sendBridgeResult:rs}=kv(U,W,an,Kt,Se);dn.current=rs,lD();let is=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(le.length<1){is.current=!1;return}is.current||(is.current=!0,Af(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[le.length]),FD({executeQueuedInput:(0,Q.useCallback)(async e=>{await jD({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:xn,commands:Kt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Zn,getToolUseContext:Io,messages:U,mainLoopModel:Se,ideSelection:ut,setUserInputOnProcessing:kr,setAbortController:rn,onQuery:Bo,setAppState:V,querySource:zu(),onBeforeQuery:_,canUseTool:Fo,addNotification:$e,setMessages:W,queuedCommands:e})},[xn,Kt,Zn,Io,U,Se,ut,kr,Fo,rn,Bo,$e,V,_]),hasActiveLocalJsxUI:xr,queryGuard:xn}),(0,Q.useEffect)(()=>{Rt.recordUserActivity(),et(!0)},[ri,ji]),(0,Q.useEffect)(()=>{ji===1&&O_()},[ji]),(0,Q.useEffect)(()=>{if(H||ji===0||Ui===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Be()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=jf().messageIdleNotifThresholdMs&&cv({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},jf().messageIdleNotifThresholdMs,Ui,H,Wn,zn,xe);return()=>clearTimeout(e)},[H,Wn,ji,Ui,xe]),(0,Q.useEffect)(()=>{},[Ui,H,$e,rt]);let ss=(0,Q.useCallback)((e,t)=>{if(xn.isActive||Ed().some(e=>e.mode===`prompt`||e.mode===`bash`))return!1;let n=typeof e==`string`?{value:e,mode:`prompt`,isMeta:t?.isMeta?!0:void 0}:e;return(async()=>{let e=await hn([n]),t=e.attachmentCommands[0];if(!t)return;let r=Gr();rn(r);let i=Jr({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await Bo([i],r,!0,[],Se)!==!1}catch(t){try{await Ci({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Pd(),priority:`later`})}catch(e){Y(Hd(e))}Y(Hd(t));return}if(a)try{let t=await Ci({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Pd(),priority:`later`});for(let e of t)Yr(e)}catch(e){Y(Hd(e))}})().catch(e=>{Y(Hd(e))}),!0},[Bo,Se,ye]),{relayPipeMessage:cs,pipeReturnHadErrorRef:us}=Tj();ID({isLoading:H,onSubmitMessage:ss}),K(e=>Oh(e));let{routeToSelectedPipes:ds}=Ej({store:ye,setAppState:V,addNotification:$e});process.env.USER_TYPE===`ant`&&qD({taskListId:w,isLoading:H,onSubmitTask:ss}),Cj?.({isLoading:H||ce!==null,queuedCommandsLength:le.length,hasActiveLocalJsxUI:xr,isInPlanMode:I.mode===`plan`,onQueueTick:e=>Yr(e)}),wj?.({isLoading:H||ce!==null,wasAborted:sn,queuedCommandsLength:le.length,hasActiveLocalJsxUI:xr,isInPlanMode:I.mode===`plan`,isQueryActiveNow:xn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;W(e=>[...e,Jr({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{$e({key:`goal-max-turns-reached`,text:`Goal reached max continuation turns (1). Run /goal continue to reset turn counter and continue.`,priority:`immediate`})}}),(0,Q.useEffect)(()=>{if(!Te){Hm(null);return}if(!H){if(Ee!==null&&le.length===0&&!xr&&I.mode!==`plan`&&ce===null){Hm({enabled:!0,phase:`standby`,next_tick_at:Ee,sleep_until:null});return}Hm({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ce,H,xr,Te,Ee,le.length,I.mode]),(0,Q.useEffect)(()=>{le.some(e=>e.priority===`now`)&&an.current?.abort(`interrupt`)},[le]);let fs=(0,Q.useRef)(ns);fs.current=ns;let ps=(0,Q.useRef)(br);ps.current=br,(0,Q.useEffect)(()=>(fs.current(),()=>{ps.current.shutdown()}),[]);let{internal_eventEmitter:ms}=ne(),[hs,gs]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
137
- Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
138
- Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
139
- `)},t=()=>{gs(e=>e+1)};return ms?.on(`suspend`,e),ms?.on(`resume`,t),()=>{ms?.off(`suspend`,e),ms?.off(`resume`,t)}},[ms]);let _s=(0,Q.useMemo)(()=>{if(!H)return null;let e=U.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||U.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=tf(U,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${gp(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[U,H]),vs=(0,Q.useCallback)(()=>{ni({messagesLength:U.length,streamingToolUsesLength:Xt.length})},[U.length,Xt.length]),ys=(0,Q.useCallback)(()=>{ni(null)},[]),bs=Ts()&&!te,Ss=(0,Q.useRef)(null),[ws,Es]=(0,Q.useState)(!1),[Ds,Os]=(0,Q.useState)(``),[ks,Ns]=(0,Q.useState)(0),[Ps,Fs]=(0,Q.useState)(0),Is=(0,Q.useCallback)((e,t)=>{Ns(e),Fs(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Ss.current?.setAnchor(),Es(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&ks>0){let t=r===`n`?Ss.current?.nextMatch:Ss.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Me===`transcript`&&bs&&!ws&&!ze});let{setQuery:Ls,scanElement:Rs,setPositions:zs}=pe(),Vs=de().columns,Hs=Q.useRef(Vs);Q.useEffect(()=>{Hs.current!==Vs&&(Hs.current=Vs,(Ds||ws)&&(Es(!1),Os(``),Ns(0),Fs(0),Ss.current?.disarmSearch(),Ls(``)))},[Vs,Ds,ws,Ls]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ys(),n.stopImmediatePropagation();return}if(e===`[`&&!ze)He(!0),Ie(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Qe.current)return;Qe.current=!0;let e=Ke.current,t=t=>{e===Ke.current&&(clearTimeout(Xe.current),Ge(t))};t(`rendering ${$r.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await iv($r,Ht,e)).replace(/[ \t]+$/gm,``),r=I_(j_(),`cc-transcript-${Date.now()}.txt`);await q_(r,n);let i=ug(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Qe.current=!1,e===Ke.current&&(Xe.current=setTimeout(e=>e(``),4e3,Ge))})()}}},{isActive:Me===`transcript`&&bs&&!ws});let Us=Me===`transcript`&&bs;(0,Q.useEffect)(()=>{Us||(Os(``),Ns(0),Fs(0),Es(!1),Ke.current++,clearTimeout(Xe.current),He(!1),Ge(``))},[Us]),(0,Q.useEffect)(()=>{Ls(Us?Ds:``),Us||zs(null)},[Us,Ds,Ls,zs]);let Gs={screen:Me,setScreen:Ne,showAllInTranscript:Fe,setShowAllInTranscript:Ie,messageCount:U.length,onEnterTranscript:vs,onExitTranscript:ys,virtualScrollActive:bs,searchBarOpen:ws},qs=ti?$r.slice(0,ti.messagesLength):$r,Ys=ti?Xt.slice(0,ti.streamingToolUsesLength):Xt;_D({onOpenBackgroundTasks:xr?void 0:()=>Da(!0),onTogglePipeSelector:()=>{V(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Xs=ge?me[ge]:void 0,Qs=Xs&&js(Xs)?Xs:void 0,$s=Bi||!H,ec=Qs?.messages,tc=(0,Q.useMemo)(()=>{if(!Qs)return;let e=ec??[];if(!js(Qs)||Qs.agentType!==`fork`||!Qs.prompt)return e;let t=Qs.prompt.trim(),n=-1,r=-1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o.type===`user`&&Array.isArray(o.message?.content)){if(o.message.content.some(zj))n=a;else if(!i){let e=o.message.content.find(e=>e.type===`text`&&typeof e.text==`string`);e&&e.text.trim()===t&&(i=!0)}continue}o.type===`assistant`&&Array.isArray(o.message?.content)&&o.message.content.some(e=>e.type===`tool_use`)&&(r=a)}let a=n===-1?e:e.map((e,t)=>t!==n||!Array.isArray(e.message?.content)?e:{...e,message:{...e.message,content:e.message.content.filter(e=>!zj(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Jr({content:Qs.prompt,timestamp:new Date(Qs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Qs,ec]),nc=Qs?tc??[]:$s?U:$r;if(Me===`transcript`){let e=Ts()&&!te&&!ze?gn:void 0,t=(0,$.jsx)(u_,{messages:qs,tools:Ht,commands:Kt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:yi,isMessageSelectorVisible:!1,conversationId:ma,screen:Me,agentDefinitions:ae,streamingToolUses:Ys,showAllInTranscript:Fe,isLoading:H,hidePastThinking:!0,streamingThinking:$t,scrollRef:e,jumpRef:Ss,onSearchMatchesChange:Is,scanElement:Rs,setPositions:zs,disableRenderCap:ze}),n=Wn&&(0,$.jsx)(x,{flexDirection:`column`,width:`100%`,children:Wn.jsx}),r=(0,$.jsxs)(kl,{children:[(0,$.jsx)(Lj,{isAnimating:Sr,title:_r,disabled:M,noPrefix:!1}),(0,$.jsx)(fD,{...Gs}),(0,$.jsx)(mD,{onSubmit:Vo,isActive:!Wn?.isLocalJSXCommand}),e?(0,$.jsx)(qA,{scrollRef:gn,isActive:!0,isModal:!ws,onScroll:()=>Ss.current?.disarmSearch()}):null,(0,$.jsx)(gD,{...Mo}),e?(0,$.jsx)(c_,{scrollRef:gn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(VO,{})]}),bottom:ws?(0,$.jsx)(Nj,{jumpRef:Ss,initialQuery:``,count:ks,current:Ps,onClose:e=>{Os(ks>0?e:``),Es(!1),e||(Ns(0),Fs(0),Ss.current?.setSearchQuery(``))},onCancel:()=>{Es(!1),Ss.current?.setSearchQuery(``),Ss.current?.setSearchQuery(Ds),Ls(Ds)},setHighlight:Ls}):(0,$.jsx)(Mj,{showAllInTranscript:Fe,virtualScroll:!0,status:Ue||void 0,searchBadge:Ds&&ks>0?{current:Ps,count:ks}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(VO,{}),(0,$.jsx)(Mj,{showAllInTranscript:Fe,virtualScroll:!1,suppressShowAll:ze,status:Ue||void 0})]})]});return e?(0,$.jsx)(be,{mouseTracking:Js(),children:r}):r}let rc=En&&!Qs&&nc.length<=On.current?En:void 0,ic=wo===`tool-permission`?(0,$.jsx)(Mx,{onDone:()=>$n(([e,...t])=>t),onReject:jo,toolUseConfirm:Qn[0],toolUseContext:Io(U,U,tn??Gr(),Se),verbose:L,setStickyFooter:Ts()?nr:void 0},Qn[0]?.toolUseID):null,ac=Ts()&&Wn?.isLocalJSXCommand===!0,oc=ac?Wn.jsx:null,sc=(0,$.jsxs)(kl,{children:[(0,$.jsx)(Lj,{isAnimating:Sr,title:_r,disabled:M,noPrefix:!1}),(0,$.jsx)(fD,{...Gs}),(0,$.jsx)(mD,{onSubmit:Vo,isActive:!Wn?.isLocalJSXCommand}),(0,$.jsx)(qA,{scrollRef:gn,isActive:Ts()&&(oc!=null||!wo||wo===`tool-permission`),onScroll:Zr}),null,(0,$.jsx)(gD,{...Mo}),(0,$.jsx)(jh,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(c_,{scrollRef:gn,overlay:ic,modal:oc,modalScrollRef:_n,dividerYRef:Mr,hidePill:!!Qs,newMessageCount:Vr?.count??0,onPillClick:()=>{zr(null),Ir(gn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(u_,{messages:nc,tools:Ht,commands:Kt,verbose:L,toolJSX:Wn,toolUseConfirmQueue:Qn,inProgressToolUseIDs:yi,isMessageSelectorVisible:ea,conversationId:ma,screen:Me,streamingToolUses:Xt,showAllInTranscript:Fe,agentDefinitions:ae,isLoading:H,streamingText:H&&!Qs?Hi:null,isBriefOnly:!Qs&&De,unseenDivider:Qs?void 0:Vr,scrollRef:Ts()?gn:void 0,trackStickyPrompt:Ts()?!0:void 0,cursor:Rr,setCursor:zr,cursorNavRef:Br}),(0,$.jsx)(Vk,{}),!y&&rc&&!oc&&(0,$.jsx)(mn,{param:{text:rc,type:`text`},addMargin:!0,verbose:L}),Wn&&!(Wn.isLocalJSXCommand&&Wn.isImmediate)&&!ac&&(0,$.jsx)(x,{flexDirection:`column`,width:`100%`,children:Wn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(uA,{}),(0,$.jsx)(x,{flexGrow:1}),Ja&&(0,$.jsx)(Ks,{mode:qt,spinnerTip:ue,responseLengthRef:Pi,apiMetricsRef:Fi,overrideMessage:Gi,spinnerSuffix:_s,verbose:L,loadingStartTimeRef:An,totalPausedMsRef:jn,pauseStartTimeRef:Mn,overrideColor:Yi,overrideShimmerColor:Zi,hasActiveTools:yi.size>0,leaderIsIdle:!H}),!Ja&&!H&&!En&&De&&!Qs&&(0,$.jsx)(Vu,{})]}),bottom:(0,$.jsx)(x,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(x,{flexDirection:`column`,flexGrow:1,children:[Ts()&&(0,$.jsx)(dE,{}),er,Wn?.isLocalJSXCommand&&Wn.isImmediate&&!ac&&(0,$.jsx)(x,{flexDirection:`column`,width:`100%`,children:Wn.jsx}),!Ja&&!Wn?.isLocalJSXCommand&&fe&&Bt&&Bt.length>0&&(0,$.jsx)(x,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Ti,{tasks:Bt,isStandalone:!0})}),wo===`sandbox-permission`&&(0,$.jsx)(zO,{hostPattern:rr[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=rr[0];if(!r)return;let i=r.hostPattern.host;ir(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=cr.current.get(i);if(a){for(let e of a)e();cr.current.delete(i)}}},rr[0].hostPattern.host),wo===`prompt`&&(0,$.jsx)(nS,{title:ar[0].title,toolInputSummary:ar[0].toolInputSummary,request:ar[0].request,onRespond:e=>{let t=ar[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),sr(([,...e])=>e))},onAbort:()=>{let e=ar[0];e&&(e.reject(Error(`Prompt cancelled by user`)),sr(([,...e])=>e))}},ar[0].request.prompt),wo===`elicitation`&&(0,$.jsx)($x,{event:B.queue[0],onResponse:(e,t)=>{let n=B.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=B.queue[0];V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},B.queue[0].serverName+`:`+String(B.queue[0].requestId)),wo===`cost`&&(0,$.jsx)(av,{onDone:()=>{pa(!1),Ca(!0),Af(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),wo===`idle-return`&&ga&&(0,$.jsx)(ov,{idleMinutes:ga.idleMinutes,totalInputTokens:Pe(),onDone:async e=>{let t=ga;if(_a(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:Dr.current.length,totalInputTokens:Pe()}),e===`dismiss`){li(t.input);return}if(e===`never`&&Af(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-D48Kt3ar.js`);await e({setMessages:W,readFileState:io.current,discoveredSkillNames:so.current,loadedNestedMemoryPaths:co.current,getAppState:()=>ye.getState(),setAppState:V,setConversationId:ha}),mr.current=!1,pr(void 0),ao.current.clear(),oo.current=0}va.current=!0,Go.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),wo===`ide-onboarding`&&(0,$.jsx)(Zs,{onDone:()=>Ct(!1),installationStatus:vt}),process.env.USER_TYPE===`ant`&&wo===`model-switch`&&Dj&&(0,$.jsx)(Dj,{onDone:(e,t)=>{Et(!1),e===`switch`&&t&&V(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),wo===`remote-callout`&&(0,$.jsx)($D,{onDone:e=>{V(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),vo,wo===`plugin-hint`&&Ft&&(0,$.jsx)(pk,{pluginName:Ft.pluginName,pluginDescription:Ft.pluginDescription,marketplaceName:Ft.marketplaceName,sourceCommand:Ft.sourceCommand,onResponse:It}),wo===`search-extra-tools-hint`&&Lt.visible&&(0,$.jsx)(hk,{tools:Lt.tools,onSelect:Lt.handleSelect,onDismiss:Lt.handleDismiss}),wo===`lsp-recommendation`&&jt&&(0,$.jsx)(uk,{pluginName:jt.pluginName,pluginDescription:jt.pluginDescription,fileExtension:jt.fileExtension,onResponse:Nt}),wo===`desktop-upsell`&&(0,$.jsx)(Pk,{onDone:()=>kt(!1)}),qa(),!Wn?.shouldHidePromptInput&&!wo&&!bo&&!y&&!Rr&&(0,$.jsxs)($.Fragment,{children:[mo&&(0,$.jsx)(oA,{onRun:Ho,onCancel:Uo,reason:lA(mo)}),eo.state===`closed`?to.state===`closed`?(0,$.jsx)(yO,{state:$a.state,lastResponse:$a.lastResponse,handleSelect:$a.handleSelect,handleTranscriptSelect:$a.handleTranscriptSelect,inputValue:ri,setInputValue:li,onRequestFeedback:_o.current?void 0:Wo}):(0,$.jsx)(yO,{state:to.state,lastResponse:to.lastResponse,handleSelect:to.handleSelect,handleTranscriptSelect:to.handleTranscriptSelect,inputValue:ri,setInputValue:li,onRequestFeedback:Wo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(yO,{state:eo.state,lastResponse:eo.lastResponse,handleSelect:eo.handleSelect,inputValue:ri,setInputValue:li,onRequestFeedback:Wo}),Za.suggestion&&(0,$.jsx)(nD,{isOpen:Za.isOpen,skillName:Za.suggestion.skillName,updates:Za.suggestion.updates,handleSelect:Za.handleSelect,inputValue:ri,setInputValue:li}),Qa&&(0,$.jsx)(dA,{}),(0,$.jsx)(AE,{debug:n,ideSelection:ut,hasSuppressedDialogs:!!To,isLocalJSXCommandActive:xr,getToolUseContext:Io,toolPermissionContext:I,setToolPermissionContext:Po,apiKeyStatus:uo,commands:Kt,agents:ae.activeAgents,isLoading:H,onExit:qo,verbose:L,messages:U,onAutoUpdaterResult:Un,autoUpdaterResult:Hn,input:ri,onInputChange:li,mode:ui,onModeChange:di,stashedPrompt:pi,setStashedPrompt:gi,submitCount:ji,onShowMessageSelector:Jo,onMessageActionsEnter:void 0,mcpClients:st,pastedContents:Oi,setPastedContents:Ai,vimMode:wa,setVimMode:Ta,showBashesDialog:Ea,setShowBashesDialog:Da,onSubmit:Vo,isSearchingHistory:Oa,setIsSearchingHistory:ka,helpOpen:Aa,setHelpOpen:ja,insertTextRef:si}),(0,$.jsx)(ZD,{onBackgroundSession:Lo,isLoading:H}),(0,$.jsx)(GD,{})]}),Rr&&(0,$.jsx)(yn,{cursor:Rr}),wo===`message-selector`&&(0,$.jsx)(Bh,{messages:U,preselectedMessage:la,onPreRestore:ko,onRestoreCode:async e=>{await Su(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=Jn(U),i=r.indexOf(e);if(i===-1){W(e=>[...e,ki(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Gr(),o=Io(r,[],a,Se),s=o.getAppState(),c=await Zc(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=Xl({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([Gn(),Ii()]),f=await il(r,i,o,{systemPrompt:l,userContext:u,systemContext:d,toolUseContext:o,forkContextMessages:r},t,n),p=f.messagesToKeep??[],m=n===`up_to`?[...f.summaryMessages,...p]:[...p,...f.summaryMessages],h=[f.boundaryMarker,...m,...f.attachments,...f.hookResults];if(Ts()&&n===`from`?W(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):W(h),vj?.setContextBlocked(!1),ha(U_()),su(o.options.querySource),n===`from`){let t=Vl(e);t&&(li(t.text),di(t.mode))}let g=ta(`app:toggleTranscript`,`Global`,`ctrl+o`);$e({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Zo,onClose:()=>{sa(!1),ua(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(bA,{})]})})})},hs)]});return Ts()?(0,$.jsx)(be,{mouseTracking:Js(),children:sc}):sc}export{Bj as t};