@readmagic/workmate 0.0.10 → 0.0.11

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 (399) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Vmmm7p1c.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/App-BuKmqFPm.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +1 -0
  4. package/dist/chunks/ApproveApiKey-M6U-NafA.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-CLSACUmo.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BqNxQOXJ.js → ClaudeMdExternalIncludesDialog-CSywJdVL.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +1 -0
  10. package/dist/chunks/{DiffDialog-9AYwtupw.js → DiffDialog-DUbFrzKu.js} +2 -2
  11. package/dist/chunks/Doctor-BcnUfJ4I.js +1 -0
  12. package/dist/chunks/Doctor-Dz4TuYas.js +3 -0
  13. package/dist/chunks/ExitFlow-BwyAtIHx.js +2 -0
  14. package/dist/chunks/{Grove-B9-hhkZA.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-MxJ_W_np.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/InvalidConfigDialog-bih293Xt.js +1 -0
  17. package/dist/chunks/{InvalidSettingsDialog-YyQcHocx.js → InvalidSettingsDialog-Br8kQOHz.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +1 -0
  19. package/dist/chunks/MCPToolListView-DJ06N1DG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-BCpfHaBK.js → McpParsingWarnings-COa71S9q.js} +1 -1
  21. package/dist/chunks/MessageSelector-o4ULADFg.js +3 -0
  22. package/dist/chunks/Messages-qqwHuAW5.js +11 -0
  23. package/dist/chunks/{Onboarding-ClwHS5rh.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BSA9NrZc.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/{PromptInputHelpMenu-Bb4KdIX_.js → PromptInputHelpMenu-CfMFx-TF.js} +1 -1
  26. package/dist/chunks/QueryEngine-Dt0BKUeF.js +1 -0
  27. package/dist/chunks/REPL-CUbEDqEl.js +133 -0
  28. package/dist/chunks/REPL-DMaKNhTa.js +1 -0
  29. package/dist/chunks/{RemoteSessionManager-CS6mywIn.js → RemoteSessionManager-Bf44A0Ol.js} +2 -2
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-CoxQ8YpH.js → SSETransport-DN4tCDEh.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +1 -0
  33. package/dist/chunks/Settings-DfdcmvOV.js +2 -0
  34. package/dist/chunks/{TeleportProgress-Doucj-50.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/TeleportRepoMismatchDialog-BZL8Zblz.js +1 -0
  36. package/dist/chunks/{TeleportResumeWrapper-D6kpr2c6.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-DrC8tlp0.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-Fk4m_Sy4.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-D_OUa4RT.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DvfQHnZY.js → WelcomeV2-ZQRKlcT4.js} +1 -1
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-B755vMZE.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-CIvP8l0s.js → agents-CMC0iQP4.js} +1 -1
  44. package/dist/chunks/agents-ZgRKpjHv.js +103 -0
  45. package/dist/chunks/allErrors-_cOQksHC.js +1 -0
  46. package/dist/chunks/{api-nSHc_GIQ.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-5QB6tsfB.js → auth-7mJGtlZp.js} +2 -2
  49. package/dist/chunks/auth-DGZzCbU0.js +1 -0
  50. package/dist/chunks/auth-DN1MUpB8.js +1 -0
  51. package/dist/chunks/{autoMode-BnUiK9Cu.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/{autonomy-Src6sKCp.js → autonomy-DuQmYhq6.js} +9 -9
  53. package/dist/chunks/{autonomy-C1aSgWPQ.js → autonomy-lJV7yWUl.js} +1 -1
  54. package/dist/chunks/autonomyPanel-DAQm6lDz.js +1 -0
  55. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +1 -0
  56. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +17 -0
  57. package/dist/chunks/{banner-D0P7wXdw.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-DAPORXF3.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/{branch-DFWa4Oxo.js → branch-k3kirqbA.js} +2 -2
  61. package/dist/chunks/{break-cache-Chj9i9MP.js → break-cache-CAoZ9b72.js} +1 -1
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-Bb6URf4Q.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/{bridgeMessaging-C3huGcR3.js → bridgeMessaging-Ci5H68MX.js} +1 -1
  65. package/dist/chunks/{bridgePointer-DLYyvRKb.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/{bridgeStatusUtil-DFMftajD.js → bridgeStatusUtil-C36w15ge.js} +1 -1
  67. package/dist/chunks/btw-nVoVuIae.js +1 -0
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-amzeeBz0.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CsJfF1b-.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-ClFDpWVJ.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWcoyZDP.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-DFlE4fYh.js → client-B9404qIP.js} +1 -1
  76. package/dist/chunks/client-BCAbKdNz.js +1 -0
  77. package/dist/chunks/client-CJE6gEvU.js +1 -0
  78. package/dist/chunks/commands-DL-BzoMQ.js +1 -0
  79. package/dist/chunks/compact-Cx7BPXLU.js +2 -0
  80. package/dist/chunks/config-S5OW4Xqr.js +1 -0
  81. package/dist/chunks/{config-Do1870_d.js → config-aRiTrtCv.js} +2 -2
  82. package/dist/chunks/{config-CVHMRMwd.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/context-BN7DEjoH.js +1 -0
  84. package/dist/chunks/{context-noninteractive-D5iQhasu.js → context-noninteractive-D91W2B8e.js} +5 -5
  85. package/dist/chunks/context-noninteractive-DPacEFJ1.js +1 -0
  86. package/dist/chunks/conversation-D5Nbu9eT.js +1 -0
  87. package/dist/chunks/conversation-hcUx9e-C.js +1 -0
  88. package/dist/chunks/{createSSHSession-CJtzNQdZ.js → createSSHSession-DecOR6M5.js} +6 -6
  89. package/dist/chunks/createSession-D27zvmOs.js +1 -0
  90. package/dist/chunks/createSession-DRqkLZWt.js +1 -0
  91. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +40 -0
  92. package/dist/chunks/{datadog-DjeJThpV.js → datadog-bm551AVV.js} +1 -1
  93. package/dist/chunks/debug-BecbSVoN.js +39 -0
  94. package/dist/chunks/{debugUtils-DX0KAXNK.js → debugUtils-CmJfIUxW.js} +1 -1
  95. package/dist/chunks/{detached-X_yjYR7x.js → detached-CIyF0M5O.js} +1 -1
  96. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  97. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  98. package/dist/chunks/{diff-jEJJe58I.js → diff-DeK4bwjw.js} +1 -1
  99. package/dist/chunks/{directoryCompletion-BbXR2bfy.js → directoryCompletion-BJCu19HJ.js} +1 -1
  100. package/dist/chunks/doctor-BJORBomU.js +1 -0
  101. package/dist/chunks/{entry-oIqjxIjQ.js → entry-mdegyj8z.js} +3 -3
  102. package/dist/chunks/{esm-Cf4nSRjF.js → esm-Ka3lhafK.js} +1 -1
  103. package/dist/chunks/{execFileNoThrow-Dwu6psHW.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  104. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  105. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  106. package/dist/chunks/{extraUsage-Mi66JwFZ.js → extraUsage-BrKbpBK-.js} +1 -1
  107. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  108. package/dist/chunks/fast-0Vi354KI.js +1 -0
  109. package/dist/chunks/{fast-BU4iUZ8E.js → fast-DWn40OcQ.js} +1 -1
  110. package/dist/chunks/{fileSuggestions-BMfQIDdW.js → fileSuggestions-C7Pwq2yj.js} +3 -3
  111. package/dist/chunks/{firstPartyEventLogger-B3cXgR67.js → firstPartyEventLogger-BHjBQH0J.js} +2 -2
  112. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  113. package/dist/chunks/{flushGate-DgSDVGKZ.js → flushGate-DdJjxCes.js} +1 -1
  114. package/dist/chunks/gemini-DHv2iVfy.js +1 -0
  115. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  116. package/dist/chunks/{genericProcessUtils-CmsUPyRz.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  117. package/dist/chunks/git-DBlOv64X.js +6 -0
  118. package/dist/chunks/git-DF4RFFaT.js +1 -0
  119. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  120. package/dist/chunks/{goal-ZmSRBx4q.js → goal-BZG4gtnb.js} +3 -3
  121. package/dist/chunks/{grok-BXMvezWb.js → grok-BS57ZhyW.js} +1 -1
  122. package/dist/chunks/{grove-CeOjTaY6.js → grove-_zlQ83yR.js} +2 -2
  123. package/dist/chunks/{help-5DNZO6_H.js → help-C_2tdXHC.js} +1 -1
  124. package/dist/chunks/{hooks-C637tFtd.js → hooks-C7Bn7MBe.js} +2 -2
  125. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  126. package/dist/chunks/{initReplBridge-D1h10vQ9.js → initReplBridge-NkZRcM77.js} +1 -1
  127. package/dist/chunks/{install-C-6ItpH0.js → install-Du-DSVzj.js} +1 -1
  128. package/dist/chunks/{instrumentation-DaiPDUst.js → instrumentation-DMs3b82f.js} +5 -5
  129. package/dist/chunks/{job-BeYzQUiR.js → job-rbX1VZmp.js} +1 -1
  130. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  131. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  132. package/dist/chunks/{launchLocalMemory-CE4J98xO.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  133. package/dist/chunks/{launchOnboarding-BfTdC6vp.js → launchOnboarding-Al_X75Vz.js} +1 -1
  134. package/dist/chunks/{loadAgentsDir-C7lOqvfh.js → loadAgentsDir-BL93ulMm.js} +619 -619
  135. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  136. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  137. package/dist/chunks/{localSearch-BKrznW5x.js → localSearch-C5ipegd9.js} +1 -1
  138. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  139. package/dist/chunks/{log-CezCRpAN.js → log-Dauqle-Z.js} +1 -1
  140. package/dist/chunks/{logoV2Utils-BkQfyQ1-.js → logoV2Utils-CkvOihX7.js} +1 -1
  141. package/dist/chunks/{magicDocs-BpVcON9o.js → magicDocs-DLav5QK0.js} +3 -3
  142. package/dist/chunks/main-CVNWNAoh.js +513 -0
  143. package/dist/chunks/{main-CvOv59-7.js → main-LMyE3jXY.js} +2 -2
  144. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  145. package/dist/chunks/{managedEnv-DhWRJ5DK.js → managedEnv-DJSCuqCb.js} +1 -1
  146. package/dist/chunks/{mappers-bOab8ipV.js → mappers-DQxMcezy.js} +1 -1
  147. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  148. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  149. package/dist/chunks/{mcp-VcGPYCkW.js → mcp-D5HkCqUh.js} +2 -2
  150. package/dist/chunks/{memoize-DsqYrbeR.js → memoize-FeyE7JEh.js} +1 -1
  151. package/dist/chunks/memory-COa7aUbx.js +1 -0
  152. package/dist/chunks/{mode-DlKnUM8l.js → mode-Bl2RZC8M.js} +2 -2
  153. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  154. package/dist/chunks/{model-BsZ4sP_H.js → model-Bgh_r4lg.js} +1 -1
  155. package/dist/chunks/model-DiuEAv6h.js +1 -0
  156. package/dist/chunks/{modelOptions-CxP067Qv.js → modelOptions-BtEZe5BB.js} +1 -1
  157. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  158. package/dist/chunks/omit--yH_T4rf.js +1 -0
  159. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  160. package/dist/chunks/{openai-B9C2XN5Q.js → openai-DWs4D-nQ.js} +3 -3
  161. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  162. package/dist/chunks/{parser-BwPXQomy.js → parser-BH4u7QiV.js} +1 -1
  163. package/dist/chunks/parser-BMIaRErw.js +1 -0
  164. package/dist/chunks/{partition-D-UhsUCx.js → partition-DLcW5Oo_.js} +1 -1
  165. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  166. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  167. package/dist/chunks/{plan-CyU2zrCK.js → plan-BNYDTnQd.js} +1 -1
  168. package/dist/chunks/{platform-BMPbglug.js → platform-B0uTQc9P.js} +1 -1
  169. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  171. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  172. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  173. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  174. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  175. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  176. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  177. package/dist/chunks/plugins-CBW7kPyp.js +4 -0
  178. package/dist/chunks/{poorMode-DEwQOAJt.js → poorMode-B_xEvuEV.js} +1 -1
  179. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  180. package/dist/chunks/{print-eCRv_Li-.js → print-BZOx09SU.js} +16 -16
  181. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  182. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  183. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  184. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  185. package/dist/chunks/{prompt-M2lu8_Oa.js → prompt-Dx7IWhBt.js} +2 -2
  186. package/dist/chunks/{promptEditor-DhcZY-iu.js → promptEditor-WCkmpejM.js} +2 -2
  187. package/dist/chunks/{protocolHandler-CkFaJKKo.js → protocolHandler-BiVWrpHi.js} +4 -4
  188. package/dist/chunks/{proxy-CuMaO_YV.js → proxy-CVn7o19p.js} +3 -3
  189. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  190. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  191. package/dist/chunks/{registerProtocol-CsNYRZKr.js → registerProtocol-E0Iu5hEx.js} +2 -2
  192. package/dist/chunks/{reload-plugins-B7JAE3b4.js → reload-plugins-D-3AUT9g.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-CFLJhsB6.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  194. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  195. package/dist/chunks/{rename-BCp2Vtqu.js → rename-CSavuBIE.js} +1 -1
  196. package/dist/chunks/{renderOptions-Q5oCLFIC.js → renderOptions-DDLbSMQU.js} +1 -1
  197. package/dist/chunks/resume-CROylN3J.js +2 -0
  198. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  199. package/dist/chunks/{ripgrep-DvOOsDMv.js → ripgrep-C1ydIMzT.js} +5 -5
  200. package/dist/chunks/{runtimeObserver-CS_3BDNo.js → runtimeObserver-L7pSIWBT.js} +2 -2
  201. package/dist/chunks/{runtimeObserver-DYUva6g-.js → runtimeObserver-OU8KrZQG.js} +1 -1
  202. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  203. package/dist/chunks/{sandbox-toggle--zNSKce_.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  204. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  205. package/dist/chunks/{session-CO3gEqQP.js → session-DUYsfPy_.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  207. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  208. package/dist/chunks/{sessionObserver-YkRHC-Aa.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  209. package/dist/chunks/{sessionState-Bifmu95-.js → sessionState-D-SaBzWD.js} +2 -2
  210. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  211. package/dist/chunks/{sessionTitle-COBSgSXS.js → sessionTitle-uCuYaNif.js} +2 -2
  212. package/dist/chunks/{sessionTracing-BrNx1k2V.js → sessionTracing-Bqb3vJTt.js} +3 -3
  213. package/dist/chunks/settings-BG15IFYx.js +1 -0
  214. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  215. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  216. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  217. package/dist/chunks/{shadowedRuleDetection-DEaw-X5j.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  218. package/dist/chunks/{shellQuote-BYeOv3Ip.js → shellQuote-DS6WrivY.js} +2 -2
  219. package/dist/chunks/{sideQuestion-D0OKljee.js → sideQuestion-CvMBBjI8.js} +2 -2
  220. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  221. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  222. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  223. package/dist/chunks/{skillGapStore-N_kmvXML.js → skillGapStore-CqaT8c0C.js} +2 -2
  224. package/dist/chunks/{skillLifecycle-C4F5RXuh.js → skillLifecycle-CnR8IqJM.js} +2 -2
  225. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  226. package/dist/chunks/{skills-C4CTRN9o.js → skills-BgcFh0vy.js} +1 -1
  227. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  228. package/dist/chunks/{startupProfiler-L_UWZ03w.js → startupProfiler-CmH_aVy2.js} +2 -2
  229. package/dist/chunks/{stats-IzV0_vEc.js → stats-B8uQ-UDi.js} +1 -1
  230. package/dist/chunks/{status-CeVP_uDT.js → status-BekdWoIj.js} +1 -1
  231. package/dist/chunks/status-D6KlRJmR.js +2 -0
  232. package/dist/chunks/{statusNoticeHelpers-Bb9gxdSt.js → statusNoticeHelpers-BMM8_uJ1.js} +1 -1
  233. package/dist/chunks/{stringUtils-C84IJ91d.js → stringUtils-C8PaYpQF.js} +1 -1
  234. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  235. package/dist/chunks/{switcher-CCs9xl1z.js → switcher-DnAhkyIn.js} +1 -1
  236. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  237. package/dist/chunks/{tasks-DZDhgx0w.js → tasks-Dmh6qikm.js} +1 -1
  238. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  239. package/dist/chunks/{templateJobs-CrNPEKkh.js → templateJobs-CxqU-s5i.js} +1 -1
  240. package/dist/chunks/{terminalSetup-CBqcwQll.js → terminalSetup-BKGcmlWp.js} +1 -1
  241. package/dist/chunks/{terminalSetup-D-N8YPiQ.js → terminalSetup-Cy19F1Js.js} +4 -4
  242. package/dist/chunks/{theme-Dazsirbw.js → theme-U7lMFHQ0.js} +1 -1
  243. package/dist/chunks/{tmux-DewYVEBm.js → tmux-D5EvHWi3.js} +1 -1
  244. package/dist/chunks/{toolEventObserver-lnHJ9fLQ.js → toolEventObserver-D9qjoVl5.js} +1 -1
  245. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  246. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  247. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  248. package/dist/chunks/{types-3j8PS-Du.js → types-DafcFtmb.js} +2 -2
  249. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  250. package/dist/chunks/{updateCCB-BPe9_FW6.js → updateCCB-C6XftzIG.js} +6 -6
  251. package/dist/chunks/{upstreamproxy-DF00RzGG.js → upstreamproxy-CXmjxHpl.js} +2 -2
  252. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  253. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  254. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  255. package/dist/chunks/{useMergedTools-Dk5cPqLc.js → useMergedTools-DbhqKk1-.js} +1 -1
  256. package/dist/chunks/{useSearchInput-C7Y1I9P9.js → useSearchInput-gUDbkLaC.js} +1 -1
  257. package/dist/chunks/{useSettingsErrors-DAEO7AyB.js → useSettingsErrors-CgPad-H0.js} +1 -1
  258. package/dist/chunks/{userAgent-CIq27vUR.js → userAgent-CU7Ndh79.js} +1 -1
  259. package/dist/chunks/util-B4oMhJKh.js +1 -0
  260. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  261. package/dist/chunks/{vim-EYQn94Kx.js → vim-w37BfGZ5.js} +1 -1
  262. package/dist/chunks/{which-DzFN5TNM.js → which-BRWBO7Gu.js} +1 -1
  263. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  264. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  265. package/dist/chunks/{workSecret-DUqdPy44.js → workSecret-BEhXgH2M.js} +1 -1
  266. package/dist/chunks/{workerRegistry-C07BcZIw.js → workerRegistry-Bq9bS5pw.js} +5 -5
  267. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  268. package/dist/cli.js +1 -1
  269. package/package.json +2 -3
  270. package/dist/chunks/App-C2yQjBgY.js +0 -1
  271. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +0 -1
  272. package/dist/chunks/ApproveApiKey-MscC-ssL.js +0 -1
  273. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +0 -2
  274. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +0 -1
  275. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +0 -1
  276. package/dist/chunks/Doctor-DmgAwce2.js +0 -1
  277. package/dist/chunks/Doctor-jEs9chPk.js +0 -3
  278. package/dist/chunks/ExitFlow-DVKxFdpX.js +0 -2
  279. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +0 -1
  280. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +0 -1
  281. package/dist/chunks/MCPToolListView-CvqB4nCw.js +0 -1
  282. package/dist/chunks/MessageSelector-BLzw172f.js +0 -3
  283. package/dist/chunks/Messages-4K5sLmNh.js +0 -11
  284. package/dist/chunks/QueryEngine-DPHLSsax.js +0 -1
  285. package/dist/chunks/REPL-Bf46iQCN.js +0 -1
  286. package/dist/chunks/REPL-DIaAo9M9.js +0 -133
  287. package/dist/chunks/ResumeConversation-Br2KsBoe.js +0 -1
  288. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +0 -1
  289. package/dist/chunks/Settings-BMXysXIx.js +0 -2
  290. package/dist/chunks/TeleportRepoMismatchDialog-B5I73j7Y.js +0 -1
  291. package/dist/chunks/add-dir-CZ6Clvq8.js +0 -1
  292. package/dist/chunks/agents-DHnNg4h6.js +0 -103
  293. package/dist/chunks/allErrors-CU89tF-z.js +0 -1
  294. package/dist/chunks/api-BSeE6MwB.js +0 -1
  295. package/dist/chunks/auth-BIGJth5U.js +0 -1
  296. package/dist/chunks/auth-CDQMhIZP.js +0 -1
  297. package/dist/chunks/autonomyPanel-DnHpuiy4.js +0 -1
  298. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +0 -17
  299. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +0 -1
  300. package/dist/chunks/bg-50rllUNh.js +0 -1
  301. package/dist/chunks/bridgeConfig-BeqChxJC.js +0 -1
  302. package/dist/chunks/btw-DSK9R2C8.js +0 -1
  303. package/dist/chunks/caches-BTQAW9zc.js +0 -1
  304. package/dist/chunks/caches-BVtSCnV1.js +0 -1
  305. package/dist/chunks/ccrClient-Bu7Tf1Z5.js +0 -1
  306. package/dist/chunks/client-BWQ4-rN7.js +0 -1
  307. package/dist/chunks/client-c-3-PW1F.js +0 -1
  308. package/dist/chunks/commands-Bi7k3Wg-.js +0 -1
  309. package/dist/chunks/compact-J-h0Yf4b.js +0 -2
  310. package/dist/chunks/config-yyFe87vW.js +0 -1
  311. package/dist/chunks/context-Tb1Ca2Q-.js +0 -1
  312. package/dist/chunks/context-noninteractive-soPYKAc9.js +0 -1
  313. package/dist/chunks/conversation-CSEtUxOY.js +0 -1
  314. package/dist/chunks/conversation-Dk1WDQuN.js +0 -1
  315. package/dist/chunks/createSession-DkT1GL8y.js +0 -1
  316. package/dist/chunks/createSession-eE8mswkv.js +0 -1
  317. package/dist/chunks/crossProjectResume-04n3Ppy9.js +0 -40
  318. package/dist/chunks/debug-RAynG_nM.js +0 -39
  319. package/dist/chunks/detectRepository-DgpNd87p.js +0 -1
  320. package/dist/chunks/detectRepository-ctF9KDbb.js +0 -1
  321. package/dist/chunks/doctor-B-Wag4C1.js +0 -1
  322. package/dist/chunks/execSyncWrapper-BTZJjCuv.js +0 -1
  323. package/dist/chunks/exit-BtW7LfRX.js +0 -1
  324. package/dist/chunks/extractMemories-CUrdiNcr.js +0 -1
  325. package/dist/chunks/fast-C60p6AqJ.js +0 -1
  326. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +0 -1
  327. package/dist/chunks/gemini-BwvSxGgn.js +0 -1
  328. package/dist/chunks/generateSessionName-DlrdedOk.js +0 -1
  329. package/dist/chunks/git-2c7WlGDL.js +0 -6
  330. package/dist/chunks/git-XtKbtJMc.js +0 -1
  331. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +0 -1
  332. package/dist/chunks/hooks-DWg07LmS.js +0 -1
  333. package/dist/chunks/jwtUtils-CUPXdX3W.js +0 -1
  334. package/dist/chunks/keybindings-DgIPdBy9.js +0 -2
  335. package/dist/chunks/loadAgentsDir-zikjxLvn.js +0 -1
  336. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +0 -1
  337. package/dist/chunks/localSearch-ZFyFy5FN.js +0 -1
  338. package/dist/chunks/main-9r5gLzUW.js +0 -605
  339. package/dist/chunks/managedEnv-B61yLpwp.js +0 -1
  340. package/dist/chunks/mcp-BckPBjaM.js +0 -6
  341. package/dist/chunks/mcp-CS1DA3JL.js +0 -1
  342. package/dist/chunks/memory-C5ohwh-T.js +0 -1
  343. package/dist/chunks/model-BGu1AGq0.js +0 -1
  344. package/dist/chunks/model-D19IIcll.js +0 -1
  345. package/dist/chunks/nativeInstaller-QB8cEJ18.js +0 -1
  346. package/dist/chunks/omit-DDUIPHnl.js +0 -1
  347. package/dist/chunks/onChangeAppState-RBl6H7ho.js +0 -1
  348. package/dist/chunks/panel-KW-wmEvU.js +0 -1
  349. package/dist/chunks/parser-xSBaQRLH.js +0 -1
  350. package/dist/chunks/permissions-BoLXYN1j.js +0 -3
  351. package/dist/chunks/pidLock-nJHbufJN.js +0 -3
  352. package/dist/chunks/plugin-C6-GQke5.js +0 -17
  353. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +0 -1
  354. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +0 -1
  355. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +0 -1
  356. package/dist/chunks/pluginFlagging-DZaYzecY.js +0 -1
  357. package/dist/chunks/pluginOperations-D90IRawu.js +0 -2
  358. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +0 -1
  359. package/dist/chunks/pluginStartupCheck-CB2q2dLv.js +0 -1
  360. package/dist/chunks/plugins-B9eSjLSA.js +0 -4
  361. package/dist/chunks/poorMode-BAnubpn1.js +0 -1
  362. package/dist/chunks/processBashCommand-B5F2Cl7K.js +0 -1
  363. package/dist/chunks/processSlashCommand-BC_D3cH5.js +0 -5
  364. package/dist/chunks/prompt-C1JPqinc.js +0 -1
  365. package/dist/chunks/prompt-DZhBz_Vu.js +0 -1
  366. package/dist/chunks/reconciler-B4GDm_iC.js +0 -1
  367. package/dist/chunks/refresh-DBVizOzg.js +0 -1
  368. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +0 -1
  369. package/dist/chunks/resume-DVCSzKvv.js +0 -2
  370. package/dist/chunks/ripgrep-e-iewvTf.js +0 -1
  371. package/dist/chunks/sandbox-adapter-BFZFHplu.js +0 -1
  372. package/dist/chunks/searchExtraTools-ui5y2VSE.js +0 -1
  373. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +0 -1
  374. package/dist/chunks/sessionObserver-Ba7um95p.js +0 -1
  375. package/dist/chunks/sessionStorage-CedwLLQs.js +0 -1
  376. package/dist/chunks/settings-DkDH7WQT.js +0 -1
  377. package/dist/chunks/settings-DnptdP79.js +0 -20
  378. package/dist/chunks/settingsSync-PmU7SmkU.js +0 -1
  379. package/dist/chunks/setup-BEsBuzsk.js +0 -3
  380. package/dist/chunks/sinks-BJHgxz6Y.js +0 -1
  381. package/dist/chunks/sinks-D5-yhcgU.js +0 -2
  382. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +0 -1
  383. package/dist/chunks/skillSearchPanel-CftorvAM.js +0 -21
  384. package/dist/chunks/startupProfiler-D4FBdEQr.js +0 -1
  385. package/dist/chunks/status-Dzuw3hBv.js +0 -2
  386. package/dist/chunks/switcher-4KzBvuKH.js +0 -1
  387. package/dist/chunks/syncCache-CBRiRU5x.js +0 -1
  388. package/dist/chunks/teleport-Bw0jSxe9.js +0 -1
  389. package/dist/chunks/toolPool-CkXFlqsn.js +0 -1
  390. package/dist/chunks/trustedDevice-CFf5yaG-.js +0 -1
  391. package/dist/chunks/trustedDevice-CuwSv8dG.js +0 -1
  392. package/dist/chunks/udsClient-e9dIkwVA.js +0 -1
  393. package/dist/chunks/useMainLoopModel-2-eujv0n.js +0 -1
  394. package/dist/chunks/useManagePlugins-CYBIkaB1.js +0 -1
  395. package/dist/chunks/util-VO98TdOz.js +0 -1
  396. package/dist/chunks/validatePlugin-Kk6pxnO2.js +0 -1
  397. package/dist/chunks/windowsPaths-BU3yQWTB.js +0 -1
  398. package/dist/chunks/windowsPaths-DgZ3YY4a.js +0 -1
  399. package/dist/chunks/worktree-dFUkhVE_.js +0 -1
@@ -0,0 +1,133 @@
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-BDhHQY0-.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{$ as h,$C as g,$a as _,$b as v,$d as y,$g as b,$h as x,$n as S,$r as C,$t as w,$u as T,$v as E,$w as D,AC as O,AE as k,Aa as A,Ab as j,Ac as M,Ag as ee,Ah as te,Ai as N,Am as P,As as F,Au as ne,Aw as I,Ay as re,BC as ie,B_ as ae,Ba as oe,Bb as se,Bd as ce,Bf as le,Bi as L,Bo as ue,Br as de,Bs as fe,By as pe,C as me,Ca as he,Cc as ge,Cd as R,Cg as _e,Cr as ve,Cs as ye,Cy as be,DE as xe,D_ as Se,Dc as Ce,Df as we,Dh as Te,Di as Ee,Dm as De,Ds as Oe,Dv as ke,E as Ae,EE as je,E_ as Me,Ec as Ne,Ef as Pe,Er as Fe,Eu as Ie,Ey as Le,F as Re,FC as ze,FS as Be,FT as Ve,F_ as He,Fb as Ue,Fd as We,Fh as Ge,Fi as Ke,Fl as qe,Fo as Je,Fp as Ye,Fu as Xe,Fy as Ze,GC as Qe,Gc as $e,Gd as et,Gf as tt,Gg as nt,Gi as rt,Gl as it,Gn as at,Gs as ot,Gu as st,Gy as ct,Hb as lt,Hf as ut,Hg as dt,Hi as ft,Hl as pt,Hs as mt,Ht as ht,Hy as gt,IC as _t,IS as vt,I_ as yt,Id as bt,Ih as xt,Il as St,Im as Ct,In as wt,Io as Tt,Iu as Et,JC as Dt,JT as Ot,Ja as kt,Jb as At,Jc as jt,Jd as Mt,Jg as Nt,Jh as Pt,Jm as Ft,Js as It,Ju as Lt,Jy as Rt,K as zt,KC as Bt,Kc as Vt,Kd as Ht,Kf as Ut,Kg as Wt,Ki as Gt,Kl as Kt,Ko as qt,Kr as Jt,Ks as Yt,Ku as Xt,La as Zt,Ld as Qt,Lf as $t,Lg as en,Lh as tn,Ll as nn,Lo as rn,Lu as an,Ly as z,M as on,MC as sn,ME as cn,Ma as ln,Mb as un,Md as dn,Mg as fn,Mp as pn,Ms as mn,My as hn,N as gn,NE as _n,Nd as vn,Ng as yn,Ni as bn,Nn as xn,No as Sn,Np as Cn,Ns as wn,Nw as Tn,Ny as En,OE as Dn,O_ as On,Oa as kn,Ob as An,Oc as jn,Oh as Mn,Om as Nn,Oo as Pn,Or as Fn,Ov as In,Oy as Ln,Pb as Rn,Pd as zn,Pg as Bn,Ph as Vn,Pi as Hn,Po as Un,Pp as Wn,Pt as Gn,Pw as Kn,Py as qn,QC as Jn,Qd as Yn,Qh as Xn,Qu as Zn,Qw as Qn,Qy as $n,RC as er,RT as tr,Rb as nr,Rd as rr,Rh as ir,Rl as B,Rn as ar,Ro as or,Ru as sr,Rv as V,Ry as cr,S_ as lr,Sa as ur,Sb as dr,Sd as fr,Sg as H,Ss as pr,St as mr,Sy as hr,TT as gr,T_ as _r,Ta as vr,Tc as yr,Tf as br,Tp as xr,Tt as Sr,Tu as Cr,Tv as wr,Ty as Tr,U as Er,Ub as Dr,Ud as Or,Uf as kr,Ug as Ar,Ul as jr,Us as Mr,Uy as Nr,VT as Pr,Va as Fr,Vf as Ir,Vg as Lr,Vn as Rr,Vs as zr,Vy as Br,W as Vr,WC as Hr,Wb as Ur,Wd as Wr,Wf as Gr,Wg as Kr,Wi as qr,Wl as Jr,Wo as Yr,Ws as Xr,Wt as Zr,Wu as Qr,Wy as $r,X as ei,XC as ti,Xb as ni,Xd as ri,Xg as ii,Xm as ai,Xo as oi,Xp as si,Xs as ci,Xt as li,Xu as ui,Xy as di,Y as fi,YC as pi,Ya as mi,Yb as hi,Yd as gi,Yg as _i,Yh as vi,Ym as yi,Yn as bi,Yo as xi,Yp as Si,Yu as Ci,Yv as wi,Yy as Ti,Z as Ei,ZC as Di,Zb as Oi,Zc as ki,Zd as Ai,Zm as ji,Zu as Mi,Zv as Ni,Zw as Pi,_a as Fi,_d as Ii,_g as Li,_l as Ri,_m as zi,_o as Bi,_v as Vi,aT as Hi,a_ as Ui,ab as Wi,ac as Gi,ad as Ki,ag as qi,ah as Ji,ai as Yi,al as Xi,ao as Zi,aw as Qi,ay as $i,bS as ea,bb as ta,bg as na,bh as ra,bv as ia,by as aa,c_ as oa,ca as sa,cb as ca,ch as la,cl as ua,cp as da,ct as fa,cu as pa,cw as ma,cy as ha,dd as ga,dg as _a,dh as va,dl as ya,do as ba,dp as xa,dy as Sa,e_ as Ca,ed as wa,ef as Ta,eg as Ea,el as Da,ep as Oa,et as ka,ew as Aa,ey as ja,fb as Ma,fd as Na,ff as Pa,fg as Fa,fh as Ia,fl as La,fp as Ra,fy as za,g_ as Ba,gc as Va,gd as Ha,gg as Ua,gl as Wa,gm as Ga,gv as Ka,gw as qa,gx as Ja,gy as Ya,hE as Xa,h_ as Za,ha as Qa,hb as $a,hc as eo,hd as to,hg as no,hi as ro,hm as io,ho as ao,hp as oo,hr as so,hv as co,hx as lo,hy as uo,iT as fo,i_ as po,ib as mo,id as ho,ig as go,ih as _o,ii as vo,il as yo,ip as bo,is as xo,j as So,jC as Co,ja as wo,jb as To,jd as Eo,jg as Do,jm as Oo,jp as ko,ju as Ao,jy as jo,kC as Mo,kE as No,ka as Po,kb as Fo,kc as Io,kg as Lo,kh as Ro,km as zo,kp as Bo,ks as Vo,kv as Ho,ky as Uo,l_ as Wo,la as Go,lh as Ko,li as qo,ll as Jo,lt as Yo,lw as Xo,ly as Zo,m_ as Qo,mb as $o,md as es,mg as ts,mi as ns,mm as rs,mp as is,mw as as,my as os,nb as ss,nc as cs,nd as ls,ng as us,nh as ds,nl as fs,nm as ps,np as ms,nr as hs,nw as gs,o_ as _s,ob as vs,od as ys,og as bs,oh as xs,oi as Ss,ol as Cs,or as ws,ow as Ts,pE as Es,pb as Ds,pd as Os,pg as ks,ph as As,pl as js,pp as Ms,q as Ns,qC as Ps,qT as Fs,qb as Is,qc as Ls,qd as Rs,qf as zs,qg as Bs,ql as Vs,qm as Hs,qs as Us,qu as Ws,qy as Gs,rT as Ks,ra as qs,rc as Js,rg as Ys,rh as Xs,rm as Zs,rp as Qs,rr as $s,rs as ec,rt as tc,rw as nc,s_ as rc,sa as ic,sb as ac,sd as oc,sg as sc,sh as cc,sl as lc,so as uc,sp as dc,su as fc,sw as pc,sy as mc,t_ as hc,td as gc,tf as _c,tg as vc,ti as yc,tl as bc,to as xc,tp as Sc,u_ as Cc,ua as wc,ud as Tc,uf as Ec,uh as Dc,ul as Oc,un as kc,up as Ac,uw as jc,uy as Mc,v_ as Nc,va as Pc,vc as Fc,vd as Ic,vg as Lc,vh as Rc,vl as zc,vn as Bc,vo as Vc,vr as Hc,wT as Uc,w_ as Wc,wc as Gc,wd as Kc,wf as qc,wg as Jc,wo as Yc,wp as Xc,wr as Zc,ws as Qc,wy as $c,xS as el,x_ as tl,xc as nl,xd as rl,xg as U,xv as il,xy as al,y_ as ol,yc as sl,yd as cl,yg as ll,yh as ul,yv as dl,yy as fl,z_ as pl,zb as ml,zd as hl,zf as gl,zg as _l,zi as vl,zl as yl,zn as bl,zo as xl,zy as Sl}from"./loadAgentsDir-BL93ulMm.js";import{C as Cl,D as wl,Ft as Tl,Gr as El,Gt as Dl,H as Ol,I as W,Kr as kl,Kt as Al,Lt as jl,P as G,Pn as Ml,Rn as Nl,T as Pl,Tt as Fl,Vn as Il,Wt as Ll,Xn as Rl,Xt as zl,Y as Bl,Yt as Vl,Z as Hl,Zn as Ul,_n as Wl,bn as Gl,ct as Kl,di as ql,dr as Jl,et as Yl,fi as Xl,hn as Zl,ir as Ql,j as $l,lr as eu,lt as tu,ot as nu,p as ru,q as iu,qr as au,t as K,tr as ou,ui as su,vn as cu,x as lu,y as uu,yn as du,yt as fu}from"./src-P_wYS_NJ2.js";import{t as pu}from"./jsx-runtime-Bb4Xn-E0.js";import{A as mu,C as hu,S as gu,a as _u,b as vu,l as yu,r as bu,w as xu}from"./external-CEp-aPkt.js";import{n as Su,r as Cu,t as wu}from"./lazySchema-B4D4qJVE.js";import{At as Tu,B as Eu,D as Du,Dt as Ou,Et as ku,Ft as Au,Gt as ju,Ln as Mu,Ot as Nu,Rn as Pu,St as Fu,V as Iu,Vt as Lu,W as Ru,Wt as zu,Y as Bu,_n as Vu,ar as Hu,b as Uu,dt as Wu,en as Gu,et as Ku,it as qu,jn as Ju,jt as Yu,kt as Xu,lr as Zu,nn as Qu,or as $u,pt as ed,rn as td,sr as nd,tn as rd,un as id,ur as ad,z as od,zt as sd}from"./state-BemZdQIl.js";import{n as cd,t as ld}from"./cwd-Cfdf7z7s.js";import{B as ud,C as dd,E as fd,P as pd,R as md,S as hd,U as gd,W as _d,Z as vd,c as q,f as yd,g as bd,i as xd,nt as Sd,tt as Cd,u as wd,x as Td}from"./debug-BecbSVoN.js";import{H as Ed,Ht as Dd,Jn as Od,Jt as kd,Kt as Ad,Ln as jd,Lt as Md,Mt as Nd,Nt as Pd,Rn as Fd,Rt as Id,Ut as Ld,Wt as Rd,Yn as zd,Yt as Bd,c as Vd,cr as Hd,ct as Ud,f as Wd,g as Gd,jt as Kd,kn as qd,ln as Jd,n as Yd,on as Xd,or as Zd,qn as Qd,sr as $d,vt as ef,wn as tf,x as nf,xn as rf,z as af,zn as of,zt as sf}from"./settings-D4CpDv2y.js";import{M as cf,c as lf,h as uf,n as df,y as ff}from"./config-aRiTrtCv.js";import{O as pf,a as mf,i as hf,k as gf,l as _f,m as vf}from"./git-DBlOv64X.js";import{r as yf,t as bf}from"./execFileNoThrow-DHyW8FMX.js";import{B as xf,H as Sf,L as Cf,N as wf,R as Tf,k as Ef,o as Df,q as Of,s as J}from"./log-Dauqle-Z.js";import{n as kf,t as Af}from"./memoize-FeyE7JEh.js";import{n as jf,t as Mf}from"./which-BRWBO7Gu.js";import{i as Nf,o as Pf}from"./platform-B0uTQc9P.js";import{s as Ff,u as If}from"./types-DafcFtmb.js";import{n as Y,r as X}from"./analytics-DJobLaWP.js";import{n as Lf,o as Rf,s as zf,t as Bf}from"./intl-D2kgJmX7.js";import{C as Vf,_ as Hf,d as Uf,l as Wf,u as Gf,v as Kf}from"./startupProfiler-CmH_aVy2.js";import{n as qf,t as Jf}from"./bundledMode--fG1S62b.js";import{a as Yf,d as Xf,l as Zf,o as Qf,r as $f,s as ep}from"./stringUtils-C8PaYpQF.js";import{$n as tp,At as np,Bn as rp,Bt as ip,Ct as ap,D as op,Et as sp,Ft as cp,Gt as lp,Hr as up,Ht as dp,Kn as fp,St as pp,T as mp,Vn as hp,Wr as gp,X as _p,_ as vp,_r as yp,at as bp,b as xp,ct as Sp,et as Cp,h as wp,ii as Tp,it as Ep,m as Dp,mt as Op,nr as kp,nt as Ap,ot as jp,ri as Mp,rt as Np,st as Pp,tr as Fp,tt as Ip,u as Lp,vr as Rp,x as zp}from"./model-Bgh_r4lg.js";import{Bt as Bp,Ct as Vp,Jt as Hp,St as Up,Yt as Wp,an as Gp,bn as Kp,dn as qp,fn as Jp,hn as Yp,mn as Xp,nt as Zp,on as Qp,rn as $p,vn as em,zt as tm}from"./prompt-Dx7IWhBt.js";import{i as nm,m as rm,n as im,p as am}from"./terminalSetup-Cy19F1Js.js";import{C as om,D as sm,S as cm,T as lm,_ as um,at as dm,b as fm,dt as pm,n as mm,r as hm,ut as gm,v as _m,x as vm,y as ym}from"./sessionState-D-SaBzWD.js";import{a as bm,i as xm,r as Sm}from"./shellQuote-DS6WrivY.js";import{a as Cm}from"./ripgrep-C1ydIMzT.js";import{c as wm}from"./switcher-DnAhkyIn.js";import{et as Tm,rt as Em}from"./esm-Ka3lhafK.js";import{i as Dm,n as Om,r as km}from"./parser-BH4u7QiV.js";import{T as Am,c as jm,r as Mm,w as Nm}from"./sessionTracing-Bqb3vJTt.js";import{n as Pm,t as Fm}from"./poorMode-B_xEvuEV.js";import{o as Im,u as Lm}from"./api-BbJfMXRS.js";import{f as Rm,m as zm,n as Bm}from"./firstPartyEventLogger-BHjBQH0J.js";import{n as Vm,t as Hm}from"./mappers-DQxMcezy.js";import{n as Um,r as Wm}from"./sessionTitle-uCuYaNif.js";import{t as Gm}from"./bridgeMessaging-Ci5H68MX.js";import{C as Km,S as qm,d as Jm,l as Ym}from"./pidLock-DgOBc1Xo.js";import{n as Xm,t as Zm}from"./nativeInstaller-BEwayifa.js";import{t as Qm}from"./useManagePlugins-CjnsO-Of.js";import{n as $m,t as eh}from"./MCPConnectionManager-B9n4SXN4.js";import{n as th,t as nh}from"./toolPool-69mfSPAs.js";import{a as rh,i as ih,o as ah,r as oh,t as sh}from"./MessageSelector-o4ULADFg.js";import{n as ch,t as lh}from"./useExitOnCtrlCDWithKeybindings-DEEJhm_W.js";import{a as uh,i as dh,n as fh,t as ph}from"./bridgeStatusUtil-C36w15ge.js";import{n as mh,t as hh}from"./sideQuestion-CvMBBjI8.js";import{a as gh,n as _h,o as vh,r as yh,s as bh,t as xh}from"./skillChangeDetector-U5kRU5nd.js";import{n as Sh,t as Ch}from"./reconciler-C2Nd_e4n.js";import{n as wh,t as Th}from"./refresh-B84H2Ezd.js";import{i as Eh,n as Dh,r as Oh,t as kh}from"./directoryCompletion-BJCu19HJ.js";import{r as Ah,t as jh}from"./PromptInputFooterSuggestions-to5eYBvI.js";import{n as Mh,t as Nh}from"./useMergedTools-DbhqKk1-.js";import{a as Ph,i as Fh,n as Ih,o as Lh,r as Rh,t as zh}from"./promptEditor-WCkmpejM.js";import{n as Bh,t as Vh}from"./useMainLoopModel-6w7mhwhU.js";import{a as Hh,i as Uh,o as Wh,r as Gh,s as Kh,t as qh}from"./fileSuggestions-C7Pwq2yj.js";import{i as Jh,n as Yh,r as Xh,t as Zh}from"./extraUsage-BrKbpBK-.js";import{n as Qh,t as $h}from"./useSearchInput-gUDbkLaC.js";import{n as eg,t as tg}from"./staticRender-DrU6eWoq.js";import{n as ng,t as rg}from"./useSettingsErrors-CgPad-H0.js";import{n as ig,t as ag}from"./shadowedRuleDetection-BzAZ57p2.js";import{n as og,t as sg}from"./ExitFlow-BwyAtIHx.js";import{a as cg,i as lg,r as ug,t as dg}from"./fast-DWn40OcQ.js";import{i as fg,n as pg,r as mg,t as hg}from"./PermissionDialog-Cb3z8OUP.js";import{a as gg,i as _g,n as vg,r as yg,t as bg}from"./PromptInputHelpMenu-CfMFx-TF.js";import{n as xg,r as Sg}from"./autoModeDenials-BxNzGJdR.js";import{n as Cg,r as wg}from"./pluginAutoupdate-BBU9Jn4p.js";import{n as Tg,t as Eg}from"./generateSessionName-DhS_6oHd.js";import{a as Dg,c as Og,i as kg,l as Ag,n as jg,o as Mg,r as Ng,s as Pg,t as Fg}from"./Messages-qqwHuAW5.js";import{t as Ig}from"./lib-BlVGipXx.js";import{a as Lg,i as Rg,n as zg,o as Bg,r as Vg,t as Hg}from"./BackgroundTasksDialog-Pnpl3Ixx.js";import{n as Ug}from"./fpsMetrics-DffAomdg.js";import{t as Wg}from"./earlyInput-IghoCjG5.js";import{a as Gg,i as Kg,o as qg,r as Jg,s as Yg,t as Xg}from"./RemoteSessionManager-Bf44A0Ol.js";import{n as Zg,t as Qg}from"./backgroundHousekeeping-Cc7Ag7JG.js";import{homedir as $g,tmpdir as e_}from"os";import*as t_ from"path";import{basename as n_,dirname as r_,extname as i_,join as a_,relative as o_,sep as s_}from"path";import{dirname as c_,join as l_}from"node:path";import{createHash as u_}from"node:crypto";import{randomUUID as d_}from"crypto";import{readFile as f_,readdir as p_,stat as m_,writeFile as h_}from"fs/promises";import{spawn as g_,spawnSync as __}from"child_process";import{mkdir as v_,readFile as y_,rename as b_,writeFile as x_}from"node:fs/promises";function S_(e){return Array.isArray?Array.isArray(e):M_(e)===`[object Array]`}function C_(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function w_(e){return e==null?``:C_(e)}function T_(e){return typeof e==`string`}function E_(e){return typeof e==`number`}function D_(e){return e===!0||e===!1||k_(e)&&M_(e)==`[object Boolean]`}function O_(e){return typeof e==`object`}function k_(e){return O_(e)&&e!==null}function A_(e){return e!=null}function j_(e){return!e.trim().length}function M_(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function N_(e){let t=null,n=null,r=null,i=1,a=null;if(T_(e)||S_(e))r=e,t=P_(e),n=F_(e);else{if(!_v.call(e,`name`))throw Error(mv(`name`));let o=e.name;if(r=o,_v.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(hv(F_(o)));t=P_(o),n=F_(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function P_(e){return S_(e)?e:e.split(`.`)}function F_(e){return S_(e)?e.join(`.`):e}function I_(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(A_(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!A_(s))return;if(a===t.length-1&&(T_(s)||E_(s)||D_(s)||typeof s==`bigint`))n.push(o===void 0?w_(s):{v:w_(s),i:o});else if(S_(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,T_(t)?t.split(`.`):t,0),r?n:n[0]}function L_(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=1,a=!1;for(let e=0;e<t.length;e++)t.charCodeAt(e)===32?a||(i++,a=!0):a=!1;if(n.has(i))return n.get(i);let o=Math.round(r/i**(.5*e))/r;return n.set(i,o),o},clear(){n.clear()}}}function R_(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new Cv({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(N_)),i.setSources(t),i.create(),i}function z_(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Cv({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function B_(e=[],t=Z.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}function V_(e,t,n,{location:r=Z.location,distance:i=Z.distance,threshold:a=Z.threshold,findAllMatches:o=Z.findAllMatches,minMatchCharLength:s=Z.minMatchCharLength,includeMatches:c=Z.includeMatches,ignoreLocation:l=Z.ignoreLocation}={}){if(t.length>32)throw Error(pv(32));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=0,S=u+d,C=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=S;for(;r<i;)h(t,f+i)<=p?r=i:S=i,i=Math.floor((S-r)/2+r);S=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&C&&(b=h(t,i),b<=p)){if(p=b,m=i,x=t,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}if(g&&m>=0){let t=Math.min(d-1,m+u-1+x);for(let r=m;r<=t;r+=1)n[e[r]]&&(_[r]=1)}let w={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=B_(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function H_(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function U_(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}function W_(e){return e.startsWith(`inverse`)}function G_(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function K_(e,t){let n=e.match(t);return n?n[1]:null}function q_(e,t={}){return e.replace(/\\\|/g,jv).split(Mv).map(e=>{let n=G_(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<Av;){let e=kv[o],n=K_(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<Av;){let e=kv[o],n=K_(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function J_(...e){Pv.push(...e)}function Y_(e,t){for(let n=0,r=Pv.length;n<r;n+=1){let r=Pv[n];if(r.condition(e,t))return new r(e,t)}return new Dv(e,t)}function X_(e,t,{auto:n=!0}={}){let r=e=>{if(T_(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Y_(e,t)),r}let i=Object.keys(e),a=Rv(e);if(!a&&i.length>1&&!Lv(e))return r(Bv(e));if(zv(e)){let r=a?e[Iv.PATH]:i[0],o=a?e[Iv.PATTERN]:e[r];if(!T_(o))throw Error(fv(r));let s={keyId:F_(r),pattern:o};return n&&(s.searcher=Y_(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];S_(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Lv(e)||(e=Bv(e)),r(e)}function Z_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function Q_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=Z_(e.matches,{ignoreFieldNorm:t})})}function $_(e){let t=[];return e.matches.forEach(e=>{if(!A_(e.indices)||!e.indices.length)return;let n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.id),e.idx>-1&&(n.refIndex=e.idx),t.push(n)}),t}function ev(e,t,{includeMatches:n=Z.includeMatches,includeScore:r=Z.includeScore}={}){return e.map(e=>{let{idx:i}=e,a={item:t[i],refIndex:i};return n&&(a.matches=$_(e)),r&&(a.score=e.score),a})}function tv(e){Uv.has(e)||(Uv.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function nv(e){if(typeof e==`function`){let t=!1;return n=>{let r=e(n);if(!t&&(t=!0,!Array.isArray(r)||r.some(e=>typeof e!=`string`)))throw Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?`array containing non-strings`:typeof r}.`);return r}}return e instanceof RegExp?(e.global||tv(e),t=>t.match(e)||[]):e=>e.match(Hv)||[]}function rv({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=nv(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Ev(n)),r(n)}}}function iv(e,t,n,r){let i=r.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);let a=new Set(i),o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(let t of a)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function av(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){iv(e,a,i,r);return}if(o)for(let t=0;t<n;t++){let n=o[t];if(n)if(Array.isArray(n))for(let t of n)iv(e,t.v,i,r);else iv(e,n.v,i,r)}}function ov(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)av(r,i,t,n);return r}function sv(e,t,n,r){av(e,t,n,r)}function cv(e,t){let n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);let r=e.docTermFieldHits.get(t);if(r){for(let[t,n]of r){let r=(e.df.get(t)||0)-n;r<=0?e.df.delete(t):e.df.set(t,r)}e.docTermFieldHits.delete(t)}}function lv(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)cv(e,t);let r=e=>{let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e?t=i+1:r=i}return e-t},i=n[0],a=new Map;for(let[t,n]of e.docFieldCount)a.set(t>i?r(t):t,n);e.docFieldCount=a;let o=new Map;for(let[t,n]of e.docTermFieldHits)o.set(t>i?r(t):t,n);e.docTermFieldHits=o}var uv,dv,fv,pv,mv,hv,gv,_v,vv,yv,bv,xv,Sv,Z,Cv,wv,Tv,Ev,Dv,Ov,kv,Av,jv,Mv,Nv,Pv,Fv,Iv,Lv,Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv,Kv,qv=t((()=>{uv=`Incorrect 'index' type`,dv=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,fv=e=>`Invalid value for key ${e}`,pv=e=>`Pattern length exceeds max of ${e}.`,mv=e=>`Missing ${e} property in key`,hv=e=>`Property 'weight' in key '${e}' must be a positive integer`,gv=`Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`,_v=Object.prototype.hasOwnProperty,vv=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=N_(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}},yv={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},bv={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},xv={location:0,threshold:.6,distance:100},Sv={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:I_,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...bv,...yv,...xv,...Sv}),Cv=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=L_(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let e=this.docs.length;this.records=Array(e);let t=0;if(T_(this.docs[0]))for(let n=0;n<e;n++){let e=this._createStringRecord(this.docs[n],n);e&&(this.records[t++]=e)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw Error(dv);if(T_(e)){let n=this._createStringRecord(e,t);return n&&this.records.push(n),n}let n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw Error(dv);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&--this.records[t].i}removeAll(e){let t=new Set;for(let n of e)Number.isInteger(n)&&n>=0&&t.add(n);if(t.size===0)return;this.records=this.records.filter(e=>!t.has(e.i));let n=Array.from(t).sort((e,t)=>e-t);for(let e of this.records){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e.i?t=i+1:r=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!A_(e)||j_(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){let n={i:t,$:{}};for(let t=0,r=this.keys.length;t<r;t++){let r=this.keys[t],i=r.getFn?r.getFn(e):this.getFn(e,r.path);if(A_(i)){if(S_(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(A_(n)){if(T_(n)){if(!j_(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(A_(n.v)){let t=T_(n.v)?n.v:w_(n.v);if(!j_(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(T_(i)&&!j_(i)){let e={v:i,n:this.norm.get(i)};n.$[t]=e}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}},wv={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Tv=RegExp(`[`+Object.keys(wv).join(``)+`]`,`g`),Ev=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(Tv,e=>wv[e]):e=>e,Dv=class{constructor(e,{location:t=Z.location,threshold:n=Z.threshold,distance:r=Z.distance,includeMatches:i=Z.includeMatches,findAllMatches:a=Z.findAllMatches,minMatchCharLength:o=Z.minMatchCharLength,isCaseSensitive:s=Z.isCaseSensitive,ignoreDiacritics:c=Z.ignoreDiacritics,ignoreLocation:l=Z.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Ev(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:H_(e),startIndex:t})},d=this.pattern.length;if(d>32){let e=0,t=d%32,n=d-t;for(;e<n;)u(this.pattern.substr(e,32),e),e+=32;if(t){let e=d-32;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Ev(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=V_(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=U_(u)),p}},Ov=new Set([`fuzzy`,`include`]),kv=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new Dv(e,{location:t.location??Z.location,threshold:t.threshold??Z.threshold,distance:t.distance??Z.distance,includeMatches:t.includeMatches??Z.includeMatches,findAllMatches:t.findAllMatches??Z.findAllMatches,minMatchCharLength:t.minMatchCharLength??Z.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Z.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Z.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Z.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],Av=kv.length,jv=`\0`,Mv=`|`,Nv=class{constructor(e,{isCaseSensitive:t=Z.isCaseSensitive,ignoreDiacritics:n=Z.ignoreDiacritics,includeMatches:r=Z.includeMatches,minMatchCharLength:i=Z.minMatchCharLength,ignoreLocation:a=Z.ignoreLocation,findAllMatches:o=Z.findAllMatches,location:s=Z.location,threshold:c=Z.threshold,distance:l=Z.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Ev(e):e,this.pattern=e,this.query=q_(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Ev(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l)a+=1,s+=d,W_(r.type)&&(c=!0),n&&(Ov.has(r.type)?o.push(...u):o.push(u));else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=U_(o)),e}}return{isMatch:!1,score:1}}},Pv=[],Fv={AND:`$and`,OR:`$or`},Iv={PATH:`$path`,PATTERN:`$val`},Lv=e=>!!(e[Fv.AND]||e[Fv.OR]),Rv=e=>!!e[Iv.PATH],zv=e=>!S_(e)&&O_(e)&&!Lv(e),Bv=e=>({[Fv.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),Vv=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}},Hv=/[\p{L}\p{M}\p{N}_]+/gu,Uv=new WeakSet,Wv=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=rv({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new Dv(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=U_(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},Gv=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new vv(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=Y_(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Cv))throw Error(uv);if(this._myIndex=t||R_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=rv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=ov(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!A_(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=rv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});sv(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){this._invertedIndex&&lv(this._invertedIndex,n);let e=new Set(n);this._docs=this._docs.filter((t,n)=>!e.has(n)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw Error(dv);this._invertedIndex&&lv(this._invertedIndex,[e]);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(T_(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return E_(n)&&n>-1&&(e=e.slice(0,n)),e}let c=E_(n)&&n>0&&T_(e),l;if(c){let t=new Vv(n);T_(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=T_(e)?T_(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Q_(l,{ignoreFieldNorm:s}),a&&l.sort(o),E_(n)&&n>-1&&(l=l.slice(0,n));return ev(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=t?null:[];return a.forEach(({v:e,i:a,n:s})=>{if(!A_(e))return;let c=r.searchIn(e);if(c.isMatch){let r={score:c.score,value:e,norm:s,indices:c.indices};i&&(r.matchedMask=c.matchedMask,r.matchedTerms=c.matchedTerms,r.termCount=c.termCount);let l=[r];if(!i||this._coversAllTokens(l)){let r={item:e,idx:a,matches:l};t?(r.score=Z_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=X_(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===Fv.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(A_(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{keys:a,records:o}=this._myIndex,s=t?null:[];return o.forEach(({$:e,i:o})=>{if(!A_(e))return;let c=[],l=!1,u=!1;if(a.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(c.push(...i),i[0].hasInverse&&(u=!0)):l=!0}),!(u&&l)&&c.length&&(!i||this._coversAllTokens(c))){let r={idx:o,item:e,matches:c};t?(r.score=Z_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!A_(t))return[];let r=[];if(S_(t))t.forEach(({v:t,i,n:a})=>{if(!A_(t))return;let o=n.searchIn(t);if(o.isMatch){let n={score:o.score,key:e,value:t,idx:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),r.push(n)}});else{let{v:i,n:a}=t,o=n.searchIn(i);if(o.isMatch){let t={score:o.score,key:e,value:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(t.matchedMask=o.matchedMask,t.matchedTerms=o.matchedTerms,t.termCount=o.termCount),r.push(t)}}return r}_coversAllTokens(e){let t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let n=0;for(let t=0;t<e.length;t++)n|=e[t].matchedMask||0;return n===2**t-1}let n=new Set;for(let t=0;t<e.length;t++){let r=e[t].matchedTerms;if(r)for(let e of r)n.add(e)}return n.size===t}},Gv.version=`7.4.2`,Gv.createIndex=R_,Gv.parseIndex=z_,Gv.config=Z,Gv.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(gv);return Y_(e,{...Z,...n}).searchIn(t)},Gv.parseQuery=X_,J_(Nv),J_(Wv),Gv.use=function(...e){e.forEach(e=>J_(e))},Kv=Gv}));s(),c();var Jv=f();ql(),cu(),u(),K(),Cu(),ad(),zu(),cd(),Cd(),_d(),md(),Td(),yd(),xd(),pf(),Of(),Df(),yf(),Af(),Mf(),vf(),Pf(),Hd(),Od(),Fd(),Y(),tf(),Ff(),Rf(),Kf(),Jd(),wu(),Jf(),Bd(),Rd(),Nd(),ef(),af(),Qf(),Gd(),cf(),Mp(),Kp(),uf(),Yp(),gp(),Rp(),kp(),fp(),ip(),Cp(),vp(),Qp(),$p(),Wp(),cn(),pm(),Fs(),Cm(),tr(),Tm(),Hi(),Qn(),Tn(),I(),as(),Sm(),jc(),pc(),nc(),g(),Jn(),Di(),Qe(),O(),Bp(),el(),Ja(),Oi(),ml(),Fo(),dr(),$a(),Ma(),ac(),di(),ct(),Br(),Uo(),sm(),Ya(),Zo(),$i(),E(),V(),Vp(),Zp(),Ho(),wr(),il(),Vi(),um(),pl(),He(),km(),Se(),tl(),Ba(),Cc(),oa(),po(),hc(),Nt(),nt(),fn(),Lo(),ir(),Ge(),te(),Mn(),ul(),As(),va(),xs(),Nm(),ds(),ai(),Ft(),Ct(),P(),is(),Qs(),Sc(),tt(),we(),br(),Rm(),Bm(),_c(),rl(),gc(),st(),it(),jr(),B(),St(),Ri(),bc(),jm(),$e(),Io(),Fc(),eo(),Js(),ci(),Yt(),fe(),mn(),F(),ec(),oi(),xl(),Yc(),Bi(),ba(),Zi(),oe(),Gt(),L(),ve(),wt(),Bc(),h(),ei(),zt(),Vr(),me(),$h(),fg(),pg();var Q=n(Xl(),1);kl(),jg(),Dt(),Es(),U(),tg();var $=pu();function Yv({children:e}){let{bindings:t}=Xa(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(Al,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Xv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Zv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>eg((0,$.jsx)(na,{children:(0,$.jsx)(Yv,{children:(0,$.jsx)(Fg,{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+=Xv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(au(t).trim()===``)break;await n(t),o?.(e+a)}}async function Qv(e,t=[],n){let r=[];return await Zv(e,t,e=>void r.push(au(e)),{columns:n}),r.join(``)}Bt(),ie(),Lc(),ts(),ks(),Cn(),ko(),Ph(),T();function $v({onDone:e}){return(0,$.jsxs)(uu,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(G,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(jl,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(wa,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}K(),T();function ey({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(uu,{title:`You've been away ${ty(e)} and this conversation is ${Hf(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(W,{flexDirection:`column`,children:(0,$.jsx)(G,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(wa,{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 ty(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`}Ai();async function ny(e,t){let n=lf().preferredNotifChannel;await ht(e),X(`tengu_notification_method_used`,{configured_channel:n,method_used:await iy(n,e,t),term:Ad.terminal})}var ry=`Work Mate`;async function iy(e,t,n){let r=t.title||ry;try{switch(e){case`auto`:return ay(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:oy()}),`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 ay(e,t){let n=e.title||ry;switch(Ad.terminal){case`Apple_Terminal`:return await sy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:oy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function oy(){return Math.floor(Math.random()*1e4)}async function sy(){try{if(Ad.terminal!==`Apple_Terminal`)return!1;let e=(await bf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await bf(`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 J(e),!1}}var cy=300,ly=240*1e3,uy=null,dy=null,fy=0,py=!1;function my(){fy++,fy===1&&(yy(),_y())}function hy(){fy>0&&fy--,fy===0&&(vy(),by())}function gy(){fy=0,vy(),by()}function _y(){process.platform===`darwin`&&dy===null&&(dy=setInterval(()=>{fy>0&&(q(`Restarting caffeinate to maintain sleep prevention`),by(),yy())},ly),dy.unref())}function vy(){dy!==null&&(clearInterval(dy),dy=null)}function yy(){if(process.platform===`darwin`&&uy===null){py||(py=!0,Sd(async()=>{gy()}));try{uy=g_(`caffeinate`,[`-i`,`-t`,String(cy)],{stdio:`ignore`}),uy.unref();let e=uy;uy.on(`error`,t=>{q(`caffeinate spawn error: ${t.message}`),uy===e&&(uy=null)}),uy.on(`exit`,()=>{uy===e&&(uy=null)}),q(`Started caffeinate to prevent sleep`)}catch{uy=null}}}function by(){if(uy!==null){let e=uy;uy=null;try{e.kill(`SIGKILL`),q(`Stopped caffeinate, allowing sleep`)}catch{}}}var xy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,Zu()),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 Sy(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(C(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=at(f,e).findLast(Zc);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function Cy(e,t,n,r,i){return{sendBridgeResult:(0,Q.useCallback)(()=>{},[])}}Zn(),ui(),Xt(),Et(),lh(),oh(),Y();var wy=Su(()=>xu({method:vu(`log_event`),params:xu({eventName:mu(),eventData:xu({}).passthrough()})}));function Ty(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Rn(e);t&&t.client.setNotificationHandler(wy(),e=>{let{eventName:t,eventData:n}=e.params;X(`tengu_ide_${t}`,n)})},[e])}K();var Ey=6e3;function Dy(){return Date.now()-Ru()}function Oy(e){return Dy()<e}function ky(e){return!Oy(e)}function Ay(e,t){let n=Ml();(0,Q.useEffect)(()=>{nd(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{ky(6e3)&&!r&&(r=!0,clearInterval(i),ny({message:e,notificationType:t},n))},Ey);return()=>clearInterval(i)},[e,t,n])}am(),ti(),sn(),dc(),ri(),Rs(),et(),nm(),Qt(),Ic(),Ha(),Os(),ga(),Oc(),lc(),yo(),Rh(),K(),ze();var jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function My(e){return ll().syntaxHighlightingDisabled?(0,$.jsx)(Py,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Py,{...e,highlight:null}),children:(0,$.jsx)(Ny,{...e})})}function Ny(e){let t=(0,Q.use)(_a());return(0,$.jsx)(Py,{...e,highlight:t})}function Py({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=nu(),[s]=Ol(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>pn(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=>El(e))),g=Math.min(h+4,c),_=g-4,v=`${jy.topLeft}${jy.horizontal.repeat(g-2)}${jy.topRight}`,y=`${jy.bottomLeft}${jy.horizontal.repeat(g-2)}${jy.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${jy.horizontal.repeat(3)} \u2702 ${jy.horizontal.repeat(3)} ${e} lines hidden `,n=El(t),r=Math.max(0,g-2-n);return`${jy.teeLeft}${t}${jy.horizontal.repeat(r)}${jy.teeRight}`})():null;return(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(G,{dimColor:!0,children:v}),m.map((e,t)=>{let n=El(e)>_?_t(e,0,_):e,r=` `.repeat(Math.max(0,_-El(n)));return(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsxs)(G,{dimColor:!0,children:[jy.vertical,` `]}),(0,$.jsx)(Tl,{children:n}),(0,$.jsxs)(G,{dimColor:!0,children:[r,` `,jy.vertical]})]},t)}),b&&(0,$.jsx)(G,{color:`warning`,children:b}),(0,$.jsx)(G,{dimColor:!0,children:y})]})}Di(),K(),Kf();function Fy({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=nu(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${d.tick} Submit `,a=El(`← `)+El(` →`)+El(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+El(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+El(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?Vf(e,l-2-2):Vf(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(W,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(G,{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)(W,{children:i?(0,$.jsxs)(G,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(G,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(W,{children:t===e.length?(0,$.jsxs)(G,{backgroundColor:`permission`,color:`inverseText`,children:[` `,d.tick,` Submit`,` `]}):(0,$.jsxs)(G,{children:[` `,d.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(G,{color:t===e.length?`inactive`:void 0,children:` →`})]})}u(),Di(),K(),U(),ml();function Iy({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:h,onFinishPlanInterview:g}){let _=H(e=>e.toolPermissionContext.mode)===`plan`,[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=Fh(),D=E?Is(E):null,O=e.question,k=i[O],A=e.options,[j,M]=(0,Q.useState)(0),ee=(0,Q.useRef)(O);if(ee.current!==O){ee.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;M(t>=0?t:0)}let te=A[j],N=k?.selectedValue,P=k?.textInputValue||``,F=(0,Q.useCallback)(e=>{let t=A[e];t&&(M(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[A,O,c,l]),ne=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?j>0?j-1:j:j<A.length-1?j+1:j,t>=0&&t<A.length&&M(t)},[j,A.length,S]);Ll(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await Ih(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),Dl({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let I=(0,Q.useCallback)(()=>{C(!1),u(!1),N&&l(O,N)},[N,O,l,u]),re=(0,Q.useCallback)(()=>{y(!0)},[]),ie=(0,Q.useCallback)(()=>{y(!1)},[]),ae=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?ie():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),f());return}if(S){e.key===`escape`&&(e.preventDefault(),I());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),j>0&&ne(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),j===A.length-1?re():ne(`down`);else if(e.key===`return`)e.preventDefault(),F(j);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!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<A.length&&ne(t)}},[v,b,_,S,j,A.length,ie,re,ne,F,I,h,g,f,u]),oe=te?.preview||null,{columns:se}=nu(),ce=se-30-4,le=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:ae,children:[(0,$.jsx)(Cl,{color:`inactive`}),(0,$.jsxs)(W,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(W,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(W,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(W,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=j===t,r=N===e.label;return(0,$.jsxs)(W,{flexDirection:`row`,children:[n?(0,$.jsx)(G,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(G,{children:` `}),(0,$.jsxs)(G,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(G,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(G,{color:`success`,children:[` `,d.tick]})]},e.label)})}),(0,$.jsxs)(W,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(My,{content:oe||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(W,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(G,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(Tc,{value:P,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:I,onExit:I,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(G,{dimColor:!0,italic:!0,children:P||`press n to add notes`})]})]})]}),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Cl,{color:`inactive`}),(0,$.jsxs)(W,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(G,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(G,{children:` `}),(0,$.jsx)(G,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(W,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(G,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(G,{children:` `}),(0,$.jsx)(G,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsxs)(G,{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`}),S&&D&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,D]}),` · Esc to cancel`]})})]})]})]})}u(),K(),U(),Ph(),ml(),Rh(),T(),fg();function Ly({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:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=H(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=Fh(),A=k?Is(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),f(t)},[f]),M=(0,Q.useCallback)(()=>{w(!0)},[]),ee=(0,Q.useCallback)(()=>{w(!1)},[]),te=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?ee():E(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),S&&T===0&&E(1);return}if(e.key===`return`){e.preventDefault(),T===0?_():v();return}e.key===`escape`&&(e.preventDefault(),p())}},[C,T,S,ee,_,v,p]),N=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),P=e.question,F=i[P],ne=(0,Q.useCallback)(async(t,n)=>{let r=await Ih(t);r.content!==null&&r.content!==t&&(n(r.content),l(P,{textInputValue:r.content},e.multiSelect??!1))},[P,l,e.multiSelect]),I={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:F?.textInputValue??``,onChange:t=>{l(P,{textInputValue:t},e.multiSelect??!1)}},re=[...N,I];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Iy,{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:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(W,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:te,children:[S&&o&&(0,$.jsxs)(W,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(Cl,{color:`inactive`}),(0,$.jsxs)(G,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Co,{filePath:o})]})]}),(0,$.jsx)(W,{marginTop:-1,children:(0,$.jsx)(Cl,{color:`inactive`})}),(0,$.jsxs)(W,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(W,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(W,{marginTop:1,children:e.multiSelect?(0,$.jsx)(ls,{options:re,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[P]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(P,n,void 0,!1)},onFocus:j,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(wa,{options:re,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!1);let t=e===`__other__`?i[P]?.textInputValue:void 0;u(P,e,t)},onFocus:j,onCancel:p,onDownFromLastItem:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(Cl,{color:`inactive`}),(0,$.jsxs)(W,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(G,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(G,{children:` `}),(0,$.jsxs)(G,{color:C&&T===0?`suggestion`:void 0,children:[re.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(W,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(G,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(G,{children:` `}),(0,$.jsxs)(G,{color:C&&T===1?`suggestion`:void 0,children:[re.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsxs)(G,{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`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}function Ry(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 ${su.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${su.bold(Ed(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?` ${su.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${su.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 zy({permissionResult:e,toolType:t}){let n=H(e=>e.toolPermissionContext.mode),r=Ry(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,By.jsxs)(W,{marginBottom:1,flexDirection:`column`,children:[i?(0,By.jsx)(G,{color:i,children:r.reasonString}):(0,By.jsx)(G,{children:(0,By.jsx)(Tl,{children:r.reasonString})}),r.configString&&(0,By.jsx)(G,{dimColor:!0,children:r.configString})]})}var By,Vy=t((()=>{Xl(),K(),U(),By=pu()}));u(),K(),T(),fg(),Vy();function Hy({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Cl,{color:`inactive`}),(0,$.jsxs)(W,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(mg,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsxs)(G,{color:`warning`,children:[d.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(W,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(W,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(G,{children:[d.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(W,{marginLeft:2,children:(0,$.jsxs)(G,{color:`success`,children:[d.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(zy,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(G,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(wa,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Uy(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 Wy={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Gy(){let[e,t]=(0,Q.useReducer)(Uy,Wy),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}}Lc(),Di(),K(),Qe(),Y(),U(),ks(),Df(),Cn();var Ky=12,qy=40,Jy=15;function Yy(e){return ll().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(_a());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>pt.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=nu(),[s]=Ol(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Ky,o-Jy);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=pn(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,El(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,Ky),n),globalContentWidth:Math.max(t,qy)}},[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};bo(s),da(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`),_=H(e=>e.toolPermissionContext.mode)===`plan`,v=_?No():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:D}=Gy(),O=y<(a?.length||0)?a?.[y]:null,k=y===(a?.length||0),A=a?.every(e=>e?.question&&!!b[e.question])??!1,j=a.length===1&&!a[0]?.multiSelect,M=(0,Q.useCallback)(()=>{u&&X(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yl()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),ee=(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=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
+ `)}`;u&&X(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yl()});let r=await Qy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),te=(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=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
+ `)}`;u&&X(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yl()});let r=await Qy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),N=(0,Q.useCallback)(async n=>{u&&X(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&yl()});let r={};for(let e of a){let t=n[e.question],i=x[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 Qy(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),P=(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={...b,[e]:i};N(t).catch(J);return}E(e,i,r)},[E,a.length,b,N,d]);function F(e){if(e===`cancel`){M();return}e===`submit`&&N(b).catch(J)}let ne=j?(a?.length||1)-1:a?.length||0,I=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),re=(0,Q.useCallback)(()=>{y<ne&&C()},[y,ne,C]);return Dl({"tabs:previous":I,"tabs:next":re},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Ly,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:j,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:P,onTextInputFocus:D,onCancel:M,onSubmit:C,onTabPrev:I,onTabNext:re,onRespondToClaude:ee,onFinishPlanInterview:te,onImagePaste:(e,t,n,r,i)=>m(O.question,e,t,n,r,i),pastedContents:d[O.question]??{},onRemoveImage:e=>h(O.question,e)})}):k?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Hy,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:A,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:F})}):null}async function Qy(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Kn({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var $y=[`http://`,`https://`,`ftp://`],eb={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},tb=e=>Array.isArray(e)?e:[e];function nb(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 rb(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(`-`)?!nb(t,n):!1}function ib(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){rb(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||nb(r,t))return r}}}async function ab(e,t,n){let r=await ob(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&&tb(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){rb(c,t[s+1],n)&&s++;continue}break}if(await sb(c,t.slice(0,s),n))break;a&&!o&&(o=nb(c,n)),i.push(c)}return i.join(` `)}async function ob(e,t,n){let r=ib(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(eb[a])return eb[a];if(eb[i])return eb[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&&tb(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=tb(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=tb(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&&tb(n.args).some(e=>e?.isDangerous)?3:2}async function sb(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=$y.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&&tb(e.args).some(e=>e?.isModule))return!1}return!0}var cb=[{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 lb(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 ub=kf(async e=>cb.find(t=>t.name===e)||await lb(e)||null,e=>e),db=/^\d+$/,fb=/^[A-Za-z_][A-Za-z0-9_]*=/,pb=new Set([`nice`]),mb=e=>Array.isArray(e)?e:[e];function hb(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function gb(e,t=0,n=0){if(n>2||t>10)return null;let r=await Dm(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Om(a);if(!o)return{commandPrefix:null};let c=await ub(o),l=pb.has(o)||c?.args&&mb(c.args).some(e=>e?.isCommand);l&&s[0]&&hb(s[0],c)&&(l=!1);let u=l?await _b(o,s,t,n):await ab(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 _b(e,t,n,r){let i=await ub(e);if(i?.args){let a=mb(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 gb(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(`-`)&&!fb.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!db.test(e)&&!fb.test(e));if(!a)return e;let o=await gb(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function vb(e,t){let n=Ei(e);if(n.length<=1){let t=await gb(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await gb(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(yb(e));return a}function yb(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 bb(e){X(`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 xb=t((()=>{Y()}));to(),an(),Y(),U(),Bd(),xb();function Sb(e,t){let n=Jc(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{r.current!==e.toolUseID&&(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),X(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:Ve.isSandboxingEnabled()}),bb({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Ad.platform}}))},[e,t,n])}ql(),u(),K(),U(),af(),ig(),tr();function Cb(e){if(e.type===`classifier`)return`${su.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${su.bold(Ed(e.rule.ruleValue))} rule from ${Xd(e.rule.source)}`;case`mode`:return`${Id(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`${su.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${su.bold(e.hookName)} hook: ${e.reason}`:`${su.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function wb({title:e,decisionReason:t}){let[n]=Ol();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(W,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(G,{children:[t.behavior===`allow`?$l(`success`,n)(d.tick):$l(`error`,n)(d.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(G,{children:[(0,$.jsxs)(G,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(Tl,{children:Cb(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Tb,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(G,{children:(0,$.jsx)(Tl,{children:Cb(t)})})}}return(0,$.jsxs)(W,{flexDirection:`column`,children:[e&&(0,$.jsx)(G,{children:e}),r()]})}function Tb({suggestions:e}){let t=Za(e);return t.length===0?null:(0,$.jsxs)(G,{children:[(0,$.jsxs)(G,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(Tl,{children:t.map(e=>su.bold(Ed(e))).join(`, `)})]})}function Eb(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Db(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Ob({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(G,{children:`None`})]});let n=Za(e),r=Eb(e),i=Db(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(G,{children:`None`})]}):(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(G,{children:` `})]}),n.length>0&&(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(W,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(G,{children:[d.bullet,` `,Ed(e)]},t))})]}),r.length>0&&(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(W,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(G,{children:[d.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(G,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(G,{children:Id(i)})]})]})}function kb({permissionResult:e,toolName:t}){let n=H(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=Ve.isSandboxingEnabled()&&Ve.isAutoAllowBashIfSandboxedEnabled(),r=ag(n,{sandboxAutoAllowEnabled:e}),a=Za(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)(W,{flexDirection:`column`,children:[(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(G,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(G,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(G,{dimColor:!0,children:`Message `})}),(0,$.jsx)(G,{children:e.message})]}),(0,$.jsxs)(W,{flexDirection:`row`,children:[(0,$.jsx)(W,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(G,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(G,{children:`undefined`}):(0,$.jsx)(wb,{decisionReason:r})]}),(0,$.jsx)(Ob,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{color:`warning`,children:[d.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(W,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(G,{color:`warning`,children:Ed(e.rule.ruleValue)}),(0,$.jsxs)(G,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(G,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Cu(),Y(),Tm(),uf(),xd(),wu(),Df(),Fm(),Uc();var Ab={LOW:1,MEDIUM:2,HIGH:3},jb=1,Mb=2,Nb=3,Pb=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Fb={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`]}},Ib=Su(()=>xu({riskLevel:yu([`LOW`,`MEDIUM`,`HIGH`]),explanation:mu(),reasoning:mu(),risk:mu()}));function Lb(e){if(typeof e==`string`)return e;try{return dd(e,null,2)}catch{return String(e)}}function Rb(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(`
14
+
15
+ `)}function zb(){return lf().permissionExplainerEnabled!==!1}async function Bb({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!zb())return null;let a=Date.now();try{let o=Lb(t),s=r?.length?Rb(r):``,c=`Tool: ${e}
16
+ ${n?`Description: ${n}\n`:``}
17
+ Input:
18
+ ${o}
19
+ ${s?`\nRecent conversation context:\n${s}`:``}
20
+
21
+ Explain this command in context.`,l=await gr({model:Pm()?wp():Lp(),system:Pb,messages:[{role:`user`,content:c}],tools:[Fb],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;q(`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`){q(`Permission explainer: tool input: ${dd(d.input).slice(0,500)}`);let t=Ib().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 X(`tengu_permission_explainer_generated`,{tool_name:Em(e),risk_level:Ab[n.riskLevel],latency_ms:u}),q(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:jb,latency_ms:u}),q(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(q(`Permission explainer: request aborted for ${e}`),null):(q(`Permission explainer error: ${pd(t)}`),J(t),X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:t instanceof Error&&t.name===`AbortError`?Mb:Nb,latency_ms:n}),null)}}K(),Qe(),Y();var Vb=`Loading explanation…`;function Hb(){let[e,t]=sr(`responding`,Vb,!1);return(0,$.jsx)(W,{ref:e,children:(0,$.jsx)(G,{children:Vb.split(``).map((e,n)=>(0,$.jsx)(es,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Ub(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Wb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Gb(e){return Bb({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function Kb(e){let t=zb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return Ll(`confirm:toggleExplanation`,()=>{n||(X(`tengu_permission_explainer_shortcut_used`,{}),i||a(Gb(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function qb({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{children:t.explanation}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{children:t.reasoning})}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsxs)(G,{children:[(0,$.jsxs)(G,{color:Ub(t.riskLevel),children:[Wb(t.riskLevel),`:`]}),(0,$.jsxs)(G,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{dimColor:!0,children:`Explanation unavailable`})})}function Jb({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(Hb,{})}),children:(0,$.jsx)(qb,{promise:t})})}Di(),K(),Df(),Xn(),Ys();function Yb(e){let[t]=(0,Q.useState)(()=>Qb(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zb,{placeholder:!0}),children:(0,$.jsx)(Xb,{promise:t,file_path:e.file_path})})}function Xb({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=nu();return(0,$.jsx)(Zb,{children:(0,$.jsx)(us,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function Zb({children:e,placeholder:t}){return(0,$.jsx)(W,{flexDirection:`column`,children:(0,$.jsx)(W,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(G,{dimColor:!0,children:`…`}):e})})}async function Qb(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 $b(e,[r]);try{let t=await x(e);if(t===null)return $b(e,n);try{if(!r||r.old_string===``){let r=await Ea(t);return r===null?$b(e,n):{patch:Nr({filePath:e,fileContents:r,edits:n.map(e=>ex(r,e))}),firstLine:Yf(r),fileContent:r}}let i=await vc(t,r.old_string,3);if(i.truncated||i.content===``)return $b(e,[r]);let a=ex(i.content,r);return{patch:gt(Nr({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Yf(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return J(t),$b(e,n)}}function $b(e,t){return{patch:t.flatMap(t=>Nr({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function ex(e,t){let n=cr(e,t.old_string)||t.old_string;return{...t,old_string:n}}qi(),Y(),Br(),uf(),ct(),md(),ml(),Df();function tx({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)(()=>d_().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${n_(n)} (${c}) ⧉`,[n,c]),u=nr(t.options.mcpClients)&&lf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=Ue(t.options.mcpClients)??`IDE`;async function f(){if(u)try{X(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await rx(n,r,t,l);if(a.current)return;X(`tengu_ext_diff_accepted`,{});let c=nx(n,o,s,i);if(c.length===0){X(`tengu_ext_diff_rejected`,{});let i=Rn(t.options.mcpClients);i&&await ix(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){J(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Rn(t.options.mcpClients);return e?ix(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function nx(e,t,n,r){let i=r===`single`,a=$r({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&J(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),Sl(a))}async function rx(e,t,n,r){let i=!1,a=Zd(e),o=``;try{o=zd(a)}catch(e){if(!ud(e))throw e}async function s(){if(!i){i=!0;try{await ix(r,c)}catch(e){J(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Rn(n.options.mcpClients);try{let{updatedFile:e}=pe({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;Nf()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new ni(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await v(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(sx(u))return s(),{oldContent:o,newContent:u[1].text};if(ax(u))return s(),{oldContent:o,newContent:e};if(ox(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw J(e),s(),e}}async function ix(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await v(`close_tab`,{tab_name:e},t)}catch(e){J(e)}}function ax(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 ox(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 sx(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}K(),ml(),T();function cx({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)(lu,{color:`permission`,children:(0,$.jsxs)(W,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(G,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(G,{color:`warning`,children:o_(ld(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Ur()&&(0,$.jsx)(G,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(G,{children:[`Do you want to make this edit to `,(0,$.jsx)(G,{bold:!0,children:n_(r)}),`?`]}),(0,$.jsx)(wa,{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)(W,{marginTop:1,children:(0,$.jsxs)(G,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}zu(),K(),Hd();function lx(e){let t=Zd(e),n=Zd(`${Ku()}/.claude`),r=ar(t),i=ar(n);return r.startsWith(i+s_.toLowerCase())||r.startsWith(i+`/`)}function ux(e){let t=Zd(e),n=a_($g(),`.claude`),r=ar(t),i=ar(n);return r.startsWith(i+s_.toLowerCase())||r.startsWith(i+`/`)}function dx({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=pi(`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=bl(e,t),u=lx(e),d=ux(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)(G,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(G,{bold:!0,children:[`(`,c,`)`]})]});else{let r=n_($d(e))||`this directory`;t=n===`read`?(0,$.jsxs)(G,{children:[`Yes, allow reading from `,(0,$.jsxs)(G,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(G,{children:[`Yes, allow all edits in `,(0,$.jsxs)(G,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(G,{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}Y(),Tm(),Bd(),wt(),xb();function fx(e,t,n,r,i){bb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Ad.platform,hasFeedback:i??!1}})}function px(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;fx(`accept`,a,o,n),X(`tengu_accept_submitted`,{toolName:Em(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 mx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(fx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Jp,ruleContent:t.scope===`global-claude-folder`?Xp:qp}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?xn(r,l,a):[];o(),i.onAllow(i.input,u)}function hx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;fx(`reject`,o,s,n,t?.hasFeedback),X(`tengu_reject_submitted`,{toolName:Em(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 gx={"accept-once":px,"accept-session":mx,reject:hx};U(),Qe(),Y(),Tm();function _x({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=H(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),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>dx({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),w=(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=gx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?y:x,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,y,x]);return Dl({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=C.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);w(e.option,t)}},[C,o,r.input,w])},{context:`Confirmation`}),{options:C,onChange:w,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:Em(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),X(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),b(!0),X(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(v(!1),X(`tengu_reject_feedback_mode_collapsed`,t)):(v(!0),S(!0),X(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}K(),ks(),cd(),Hd(),T();function vx({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?Fa(l):`none`),[p,l]);Sb(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=Zd(l),{resolvedPath:t,isSymlink:n}=bd(wd(),e);return n?t:null},[l,d]),g=_x({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:b,handleInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w}=g,T=u(e.input),E=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:D,showingDiffInIDE:O,ideName:k}=tx(E?{onChange:(e,t)=>{let n=f.applyChanges(T,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:E.filePath,edits:(E.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:E.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),A=(e,t)=>{D?.(),g.onChange(e,T,t?.trim())};if(O&&E&&l)return(0,$.jsx)(cx,{onChange:(e,t,n)=>A(e,n),options:_,filePath:l,input:T,ideName:k,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:b,onInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w});let j=h!=null&&o_(ld(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(hg,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(W,{paddingX:1,marginBottom:1,children:(0,$.jsx)(G,{color:`warning`,children:j?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(W,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(G,{children:o}):o,(0,$.jsx)(wa,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();A(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();A(t.option,e||void 0);return}A(t.option)}},onCancel:()=>A({type:`reject`}),onFocus:e=>b(e),onInputModeToggle:x})]})]}),(0,$.jsx)(W,{paddingX:1,marginTop:1,children:(0,$.jsxs)(G,{dimColor:!0,children:[`Esc to reject`,(S===`yes`&&!C||S===`no`&&!w)&&` · Tab to add feedback`]})})]})}cd(),md(),Od(),yd(),K();function yx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(bx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Qd(n);return{oldContent:(await wd().readFile(n,{encoding:e})).replaceAll(`\r
22
+ `,`
23
+ `),fileExists:!0}})().catch(e=>{if(!ud(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function bx({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Rc(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)(vx,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:o_(ld(),r),question:(0,$.jsxs)(G,{children:[`Do you want to make this edit to `,(0,$.jsx)(G,{bold:!0,children:n_(r)}),`?`]}),content:s.length>0?(0,$.jsx)(Yb,{file_path:r,edits:s}):(0,$.jsx)(G,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Ia.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Bd(),xb();function xx(e,{assistantMessage:{message:{id:t}}},n,r){bb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:kd(),hasFeedback:r??!1}})}Y(),Tm(),U();function Sx({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Jc(),[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:Em(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),X(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),X(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),X(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),X(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(X(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),xx(`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}}zu(),K();function Cx(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(G,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(G,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(G,{bold:!0,children:e.slice(-1)[0]})]})}}function wx(e){return e.join(`, `).length>50?`similar`:Cx(e)}function Tx(e){if(e.length===0)return``;let t=e.map(e=>n_(e)||e);return t.length===1?(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{bold:!0,children:t[0]}),s_]}):t.length===2?(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{bold:!0,children:t[0]}),s_,` and `,(0,$.jsx)(G,{bold:!0,children:t[1]}),s_]}):(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{bold:!0,children:t[0]}),s_,`, `,(0,$.jsx)(G,{bold:!0,children:t[1]}),s_,` and `,e.length-2,` more`]})}function Ex(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=Aa(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)(G,{children:[`Yes, allow reading from `,(0,$.jsx)(G,{bold:!0,children:n_(e)||e}),s_,` from this project`]})}return(0,$.jsxs)(G,{children:[`Yes, allow reading from `,Tx(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(G,{children:[`Yes, and always allow access to `,(0,$.jsx)(G,{bold:!0,children:n_(e)||e}),s_,` from this project`]})}return(0,$.jsxs)(G,{children:[`Yes, and always allow access to `,Tx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(G,{children:[`Yes, and don't ask again for `,wx(c),` commands in `,(0,$.jsx)(G,{bold:!0,children:Ku()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(G,{children:[`Yes, and always allow access to `,Tx(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(G,{children:[`Yes, and allow access to `,Tx(e),` and `,wx(c),` commands`]}):(0,$.jsxs)(G,{children:[`Yes, and allow `,Tx(e),` access and `,wx(c),` commands`]})}return null}ei();function Dx(e){let{commandWithoutRedirections:t,redirections:n}=fi(e);return n.length>0?t:e}function Ox({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`}),lr()){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!t&&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=Ex(e,Gp,Dx);t&&f.push({label:t,value:`yes-apply-suggestions`})}}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}K(),Qe(),Y(),Tm(),U(),As(),ul(),Ba(),tr(),to(),an(),pg(),Vy();function kx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Ia.inputSchema.parse(t.input),c=ra(o);return c?(0,$.jsx)(yx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Ax,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Ax({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=Ol(),c=H(e=>e.toolPermissionContext),l=Kb({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:b,handleFocus:x}=Sx({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(o||``),[E,D]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!On())return;let e=new AbortController;return _r(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(T(t),D(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let O=e.permissionResult.decisionReason?.type===`subcommandResults`,[k,A]=(0,Q.useState)(()=>{if(O){let t=Za(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Ia.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Dc(a);if(t)return`${t}:*`;let n=Ko(a);return n?`${n}:*`:a}),j=(0,Q.useRef)(!1),M=(0,Q.useCallback)(e=>{j.current=!0,A(e)},[]);(0,Q.useEffect)(()=>{if(O)return;let e=!1;return vb(a,e=>Ia.isReadOnly({command:e})).then(t=>{e||j.current||t.length>0&&A(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,O]);let[ee]=(0,Q.useState)(!1),{destructiveWarning:te,sandboxingEnabled:N,isSandboxed:P}=(0,Q.useMemo)(()=>{let t=Ve.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Ns(e.input)}},[a,e.input]);Sb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let F=(0,Q.useMemo)(()=>Me(c),[c]),ne=(0,Q.useMemo)(()=>Ox({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:T,classifierDescription:w,initialClassifierDescriptionEmpty:E,existingAllowDescriptions:F,yesInputMode:u,noInputMode:d,editablePrefix:k,onEditablePrefixChange:M}),[e,w,E,F,u,d,k,M]);Ll(`permission:toggleDebug`,(0,Q.useCallback)(()=>{C(e=>!e)},[]),{context:`Confirmation`}),Ll(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function I(t){X(`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=Em(e.tool.name);if(t===`yes-prefix-edited`){let t=(k??``).trim();if(xx(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Ia.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();xx(`tool_use_single`,e,`accept`),X(`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`:{xx(`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();X(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),b(t||void 0);break}}}return(0,$.jsxs)(hg,{title:N&&!P?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{dimColor:l.visible,children:Ia.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(G,{dimColor:!0,children:e.description}),(0,$.jsx)(Jb,{visible:l.visible,promise:l.promise})]}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kb,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(W,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(G,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`command`}),te&&(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsx)(G,{color:`warning`,dimColor:!1,children:te})}),(0,$.jsx)(G,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(wa,{options:ne,isDisabled:!1,inlineDescriptions:!0,onChange:I,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(W,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(G,{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)(G,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}zu(),K(),Y(),U(),B(),T(),pg();function jx({toolUseConfirm:e,onDone:t,onReject:n}){let r=H(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(X(`tengu_plan_enter`,{interviewPhaseEnabled:yl(),entryMethod:`tool`}),sd(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(G,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(W,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(G,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(G,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(G,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(G,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(G,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(wa,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),Y(),U(),zu(),Tg(),K(),Ph(),ml(),Df(),vp(),Se(),Nd(),B(),cn(),Rh(),ve(),T(),pg(),Vy(),Tn(),dc();var Mx=(Vs(),e(Kt));function Nx(e,t){let n=[{type:`setMode`,mode:sf(e),destination:`session`}];return On()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Wc(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Px(e,t,n){ju()||Wd()?.cleanupPeriodDays===0||!n&&ws(ed())||Eg([vr({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||ws(ed()))return;let n=ed(),r=Hc();await qo(n,e,r,`auto`),await Ss(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(J)}function Fx({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=H(e=>e.toolPermissionContext),a=Jc();_e();let{addNotification:o}=Yn(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=H(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_}=i,v=(0,Q.useMemo)(()=>Ix({showClearContext:p,usedPercent:p?Lx(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};bo(o),da(o),u(e=>({...e,[a]:o}))}let b=(0,Q.useCallback)(e=>{u(t=>{let n={...t};return delete n[e],n})},[]),x=Object.values(l).filter(e=>e.type===`image`),S=x.length>0,C=e.tool.name===Hp,w=C?void 0:e.input.plan,T=C?No():void 0,E=e.input.allowedPrompts,D=w??Dn(),O=!D||D.trim()===``,[k]=(0,Q.useState)(()=>nn()??void 0),[A,j]=(0,Q.useState)(()=>w||(Dn()??`No plan found. Please write your plan to the plan file first.`)),[M,ee]=(0,Q.useState)(!1),[te,N]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(M){let e=setTimeout(ee,5e3,!1);return()=>clearTimeout(e)}},[M]);let P=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),X(`tengu_plan_external_editor_used`,{}),(async()=>{if(C&&T){let e=await zh(T);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==A&&N(!0),j(e.content),ee(!0))}else{let e=await Ih(A);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==A&&(j(e.content),ee(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),F(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function F(r){let o=s.trim(),c=o||void 0,l=C&&!te?{}:{plan:A};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Ae(),t=Mx?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Mx?.setAutoModeActive(!1),Mu(!0),a(e=>({...e,toolPermissionContext:{...So(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`&&Px(A,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`&&Ae()&&(i=`auto`,Mx?.setAutoModeActive(!0)),X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!0,interviewPhaseEnabled:yl(),planStructureVariant:k,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: ${Hc()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...vr({content:`Implement the following plan:\n\n${A}${o}${s}`}),planContent:A},clearContext:!0,mode:i,allowedPrompts:E}})),Vu(!0),Pu(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Ae()){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:yl(),planStructureVariant:k,hasFeedback:!!c}),Vu(!0),Pu(!0),Mx?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:on({...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){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:yl(),planStructureVariant:k,hasFeedback:!!c}),Vu(!0),Pu(!0),t(),e.onAllow(l,Nx(d,E),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,interviewPhaseEnabled:yl(),planStructureVariant:k,hasFeedback:!!c}),Vu(!0),Pu(!0),t(),e.onAllow(l,Nx(f,E),c);return}if(r===`no`){if(!o&&!S)return;X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:yl(),planStructureVariant:k});let r;S&&(r=await Promise.all(x.map(async e=>(await Kn({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(S?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let ne=Fh(),I=ne?Is(ne):null,re=(0,Q.useRef)(F);re.current=F;let ie=(0,Q.useRef)(void 0);ie.current=()=>{X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:yl(),planStructureVariant:k}),t(),n(),e.onReject()};let ae=!O&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ae)return r((0,$.jsxs)(W,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(G,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(wa,{options:v,onChange:e=>void re.current(e),onCancel:()=>ie.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})}),I&&(0,$.jsxs)(W,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(G,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(G,{bold:!0,dimColor:!0,children:I}),C&&T&&(0,$.jsxs)(G,{dimColor:!0,children:[` · `,rf(T)]}),M&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{dimColor:!0,children:` · `}),(0,$.jsxs)(G,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ae,r,v,l,I,C,T,M]),O){function r(r){r===`yes`?(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:yl(),planStructureVariant:k}),(Mx?.isAutoModeActive()??!1)&&(Mx?.setAutoModeActive(!1),Mu(!0),a(e=>({...e,toolPermissionContext:{...So(e.toolPermissionContext),prePlanMode:void 0}}))),Vu(!0),Pu(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:yl(),planStructureVariant:k}),t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(G,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(wa,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:yl(),planStructureVariant:k}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(W,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:P,children:[(0,$.jsx)(hg,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(W,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(G,{children:`Here is Claude's plan:`})}),(0,$.jsx)(W,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Bo,{children:A})}),(0,$.jsxs)(W,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`tool`}),On()&&E&&E.length>0&&(0,$.jsxs)(W,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(G,{bold:!0,children:`Requested permissions:`}),E.map((e,t)=>(0,$.jsxs)(G,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ae&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(wa,{options:v,onChange:F,onCancel:()=>ie.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})})]})]})]})}),!ae&&I&&(0,$.jsxs)(W,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(G,{bold:!0,dimColor:!0,children:I}),C&&T&&(0,$.jsxs)(G,{dimColor:!0,children:[` · `,rf(T)]})]}),M&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:` · `}),(0,$.jsxs)(G,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function Ix({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 Lx(e,t){if(!e)return null;let n=hp(Dp({permissionMode:t,mainLoopModel:Lp(),exceeds200kTokens:!1}),Wu()),{used:r}=rp({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 Rx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Jc(),[o,s]=(0,zx.useState)(``),[c,l]=(0,zx.useState)(``),[u,d]=(0,zx.useState)(!1),[f,p]=(0,zx.useState)(!1),[m,h]=(0,zx.useState)(null),[g,_]=(0,zx.useState)(!1),[v,y]=(0,zx.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,zx.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=Vx[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),C=(0,zx.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),X(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),X(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),y(!0),X(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),w=(0,zx.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`?X(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&X(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);Dl((0,zx.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>w(n.value));return t},[e,w]),{context:`Confirmation`});let T=(0,zx.useCallback)(()=>{X(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,Bx.jsxs)(W,{flexDirection:`column`,children:[typeof r==`string`?(0,Bx.jsx)(G,{children:r}):r,(0,Bx.jsx)(wa,{options:S,inlineDescriptions:!0,onChange:w,onCancel:T,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:C}),(0,Bx.jsx)(W,{marginTop:1,children:(0,Bx.jsxs)(G,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var zx,Bx,Vx,Hx=t((()=>{zx=n(Xl(),1),K(),Qe(),Y(),U(),gc(),Bx=pu(),Vx={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Wm(),zu(),K(),Tm(),Bd(),tl(),Qf(),xb(),pg(),Hx(),Vy();function Ux({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=Ol(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Sb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Ad.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Ad.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Ad.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Ad.platform}}),e.onReject(),n(),t()},[e,t,n]),l=Ku(),u=lr(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(G,{children:[`Yes, and don't ask again for `,(0,$.jsx)(G,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(G,{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:Em(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(hg,{title:`Tool use`,children:[(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(G,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(G,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(G,{dimColor:!0,children:Xf(e.description,3)})]}),(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Rx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function Wx(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}cd(),K();var Gx={getConfig:e=>Wx(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 Kx(e){let t=e=>ms.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:o_(ld(),n),question:(0,$.jsxs)(G,{children:[`Do you want to make this edit to `,(0,$.jsx)(G,{bold:!0,children:n_(n)}),`?`]}),content:(0,$.jsx)(Yb,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:Gx})}K();function qx(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 Jx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=Ol(),o=qx(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(vx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(G,{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)(Ux,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}Di(),K(),ct(),sc();function Yx({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=nu(),a=(0,Q.useMemo)(()=>n?Nr({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
24
+ `)[0]??null;return(0,$.jsx)(W,{flexDirection:`column`,children:(0,$.jsx)(W,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?of(a.map(t=>(0,$.jsx)(go,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(Fl,{fromLeftEdge:!0,children:(0,$.jsx)(G,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(bs,{code:t||`(No content)`,filePath:e})})})}K(),cd(),md(),Od();var Xx={getConfig:e=>{let t;try{t=zd(e.file_path)}catch(e){if(!ud(e))throw e;t=``}return Wx(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function Zx(e){let t=e=>Vn.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:zd(n)}}catch(e){if(!ud(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:o_(ld(),n),question:(0,$.jsxs)(G,{children:[`Do you want to `,o,` `,(0,$.jsx)(G,{bold:!0,children:n_(n)}),`?`]}),content:(0,$.jsx)(Yx,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:Xx})}K(),Fd(),cd(),ct(),yd(),sc(),qi();function Qx(e){let t=(0,Q.useMemo)(()=>wd().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>If(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)($x,{...e,promise:t})})}function $x({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=ma(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:Nr({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)(W,{flexDirection:`column`,children:(0,$.jsxs)(W,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(W,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(G,{bold:!0,children:a?e:o_(ld(),e)}),(0,$.jsxs)(G,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(W,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(bs,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(W,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(bs,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?of(u.map(t=>(0,$.jsx)(go,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
25
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(Fl,{fromLeftEdge:!0,children:(0,$.jsx)(G,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(bs,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}K(),Df();function eS(e){let t=e=>{let t=Oa.inputSchema.safeParse(e);return t.success?t.data:(J(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)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(G,{children:[`Do you want to `,s,` `,(0,$.jsx)(G,{bold:!0,children:n_(r)}),`?`]}),content:(0,$.jsx)(Qx,{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})}Qf(),Cs();async function tS(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||Xi.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 ub(n),i=await ab(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||eb[n])?null:i}async function nS(e,t){let n=await ya(e);if(!n.valid)return[];let r=Jo(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await tS(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await tS(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=rS(t);(n===``?0:$f(n,` `)+1)<=1&&((await ub(e))?.subcommands?.length||eb[e])||o.push(n)}return o}function rS(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(` `)}tl();function iS({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`}),lr()&&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=Ex(e,Up);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}K(),Qe(),Y(),Tm(),gc(),pg(),Vy();function aS(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=fs.inputSchema.parse(t.input),[s]=Ol(),c=Kb({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:b}=Sx({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(a.includes(`
26
+ `)?void 0:a),T=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return nS(a,e=>ua(e,e.text)).then(t=>{e||T.current||t.length>0&&w(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let E=(0,Q.useCallback)(e=>{T.current=!0,w(e)},[]);Sb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let D=(0,Q.useMemo)(()=>iS({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:C,onEditablePrefixChange:E}),[t,l,u,C,E]);Ll(`permission:toggleDebug`,(0,Q.useCallback)(()=>{S(e=>!e)},[]),{context:`Confirmation`});function O(e){X(`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=Em(t.tool.name);if(e===`yes-prefix-edited`){let e=(C??``).trim();if(xx(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:fs.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();xx(`tool_use_single`,t,`accept`),X(`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`:{xx(`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();X(`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)(hg,{title:`PowerShell command`,children:[(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{dimColor:c.visible,children:fs.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(G,{dimColor:!0,children:t.description}),(0,$.jsx)(Jb,{visible:c.visible,promise:c.promise})]}),x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kb,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(W,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(G,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(G,{children:`Do you want to proceed?`}),(0,$.jsx)(wa,{options:D,inlineDescriptions:!0,onChange:O,onCancel:()=>y(),onFocus:b,onInputModeToggle:v})]}),(0,$.jsxs)(W,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(G,{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)(G,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Df(),zu(),K(),Tm(),Bd(),tl(),xb(),pg(),Hx(),Vy();function oS(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=qc.inputSchema.safeParse(e);return t.success?t.data.skill:(J(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;Sb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=Ku(),c=lr(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(G,{children:[`Yes, and don't ask again for `,(0,$.jsx)(G,{bold:!0,children:a}),` in `,(0,$.jsx)(G,{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)(G,{children:[`Yes, and don't ask again for `,(0,$.jsx)(G,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(G,{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:Em(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Ad.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Ad.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:tm,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Ad.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:tm,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Ad.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Ad.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(hg,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(G,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(G,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Rx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}var sS=r({WorkflowPermissionRequest:()=>cS});function cS({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=Ol(),i=Qr(r),a=e.input,o=(0,lS.useMemo)(()=>lr(),[]),s=(0,lS.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,uS.jsxs)(G,{children:[`Yes, and don`,`’`,`t ask again for `,(0,uS.jsx)(G,{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,lS.useCallback)((r,i)=>{switch(r){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Ad.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Ad.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Ad.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,lS.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Ad.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,uS.jsx)(hg,{title:`Workflow`,children:(0,uS.jsxs)(W,{flexDirection:`column`,gap:1,children:[(0,uS.jsxs)(W,{flexDirection:`column`,children:[(0,uS.jsxs)(G,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,uS.jsxs)(G,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,uS.jsx)(zy,{permissionResult:e.permissionResult,toolType:`command`}),(0,uS.jsx)(Rx,{options:s,onSelect:c,onCancel:l})]})})}var lS,uS,dS=t((()=>{lS=n(Xl(),1),K(),Bd(),tl(),xb(),pg(),Hx(),Vy(),uS=pu()}));Qe(),jr(),As(),Qs(),Ge(),Sc(),yo(),br();var fS=(La(),e(js)).createWorkflowToolCore(),pS=(dS(),e(sS)).WorkflowPermissionRequest;function mS(e){switch(e){case ms:return Kx;case Vn:return Zx;case Ia:return kx;case fs:return aS;case Oa:return eS;case Jr:return Fx;case qe:return jx;case qc:return oS;case pt:return Yy;case fS:return pS??Ux;case Te:case Ro:case Mo:return Jx;default:return Ux}}function hS(e){let t=e.tool.userFacingName(e.input);return e.tool===Jr?`Claude Code needs your approval for the plan`:e.tool===qe?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function gS({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return Ll(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Ay(hS(e),`permission_prompt`),(0,$.jsx)(mS(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Be(),ho(),Df(),oe();async function _S(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=dm([`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:
27
+ - Current date and time: ${i} (UTC)
28
+ - Local timezone: ${c}
29
+ - Day of week: ${l}
30
+
31
+ User input: "${e}"
32
+
33
+ Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
34
+
35
+ 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 ka({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=kn(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 J(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function vS(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}Cu(),Td(),Qf();var yS=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function bS(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function xS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function SS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function CS(e,t){let n=xS(e).indexOf(t);return n>=0?SS(e)[n]??t:t}function wS(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function TS(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function ES(e,t){let n=wS(e).indexOf(t);return n>=0?TS(e)[n]??t:t}function DS(e){if(yS(e)){let[t,...n]=wS(e);return t?yu([t,...n]):gu()}if(e.type===`string`){let t=mu();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Zf(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Zf(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=_u({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 bu();throw Error(`Unsupported schema: ${dd(e)}`)}function OS(e,t){let n=DS(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function kS(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function AS(e,t,n){let r=OS(e,t);if(r.isValid)return r;if(kS(t)&&!vS(e)){let r=await _S(e,t.format,n);if(r.success){let e=OS(r.value,t);if(e.isValid)return e}}return r}u(),Di(),K(),Qe(),Qf(),Ye(),ga();var jS=e=>[`string`,`number`,`integer`].includes(e.type),MS=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,NS=e=>(e+1)%10;function PS(e){e.buffer=``,e.timer=void 0}function FS(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,NS);return()=>clearInterval(e)},[]),(0,$.jsx)(G,{color:`warning`,children:MS[e]})}function IS(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 LS({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(zS,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(RS,{event:e,onResponse:t})}function RS({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(jS(n)&&n?.default!==void 0){let r=OS(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,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&jS(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[y,b]=(0,Q.useState)(_.length),[x,S]=(0,Q.useState)(()=>new Set),[C,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(new Map),k=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=k.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:A,rows:j}=nu(),M=h===void 0?void 0:m[h],ee=M!==void 0&&jS(M.schema)&&!yS(M.schema)&&!s;oc(`elicitation`),Ay(`Claude Code needs your input`,`elicitation_dialog`);let te=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&jS(t.schema)&&!yS(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function N(e,t){if(!bS(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)?ne(e,`Select at least ${i} ${Zf(i,`item`)}`):a!==void 0&&n.length>a?ne(e,`Select at most ${a} ${Zf(a,`item`)}`):ne(e)}function P(e){M&&bS(M.schema)?(N(M.name,M.schema),w(void 0)):M&&yS(M.schema)&&w(void 0),ee&&M&&(re(M.name,M.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),kS(M.schema)&&_.trim()!==``&&f[M.name]&&ie(M.name,M.schema,_));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?(g(r),c(null),te(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function F(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`&&ne(e)}function ne(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function I(e){e&&(F(e,void 0),ne(e),v(``),b(0))}function re(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){I(e);return}if(r===``){l[e]!==void 0&&F(e,``);return}let i=OS(n,t);F(e,i.isValid?i.value:n),ne(e,i.isValid?void 0:i.error)}function ie(e,t,n){if(!r)return;let i=O.current.get(e);i&&i.abort();let a=new AbortController;O.current.set(e,a),S(t=>new Set(t).add(e)),AS(n,t,a.signal).then(t=>{if(O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){F(e,t.value),ne(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else ne(e,t.error)},()=>{O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n})})}function ae(e){if(v(e),M&&(re(M.name,M.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),kS(M.schema)&&e.trim()!==``&&f[M.name])){let t=M.name,n=M.schema;D.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,D,ie,t,n,e)}}function oe(){P(`down`)}function se(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(PS,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}Ll(`confirm:no`,()=>{if(ee&&M){let e=l[M.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!M&&!s&&!C}),Zl((e,n)=>{if(ee&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&M&&bS(M.schema)){let t=M.schema,r=xS(t),i=l[M.name]??[];if(n.leftArrow||n.escape){w(void 0),N(M.name,t);return}if(n.upArrow){T===0?(w(void 0),N(M.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;F(M.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||M.isRequired)?ne(M.name,`Select at least ${a} ${Zf(a,`item`)}`):o!==void 0&&n.length>o?ne(M.name,`Select at most ${o} ${Zf(o,`item`)}`):ne(M.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&F(M.name,[...i,e]),w(void 0),P(`down`);return}if(e){se(e,r.map(e=>CS(t,e).toLowerCase()),E);return}return}if(C&&M&&yS(M.schema)){let t=M.schema,r=wS(t);if(n.leftArrow||n.escape){w(void 0);return}if(n.upArrow){T===0?w(void 0):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&F(M.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&F(M.name,e),w(void 0),P(`down`);return}if(e){se(e,r.map(e=>ES(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(ce()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&ne(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&&(g(t),c(null),te(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=k.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),P(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!M)return;let{schema:r,name:i}=M,o=l[i];if(r.type===`boolean`){if(e===` `){F(i,o===void 0||!o);return}if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){I(i);return}if(e&&!n.return){se(e,[`yes`,`no`],e=>F(i,e===0));return}return}if(yS(r)||bS(r)){if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){I(i);return}let t,a=0;if(yS(r)){let e=wS(r);t=e.map(e=>ES(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=xS(r).map(e=>CS(r,e).toLowerCase());if(n.rightArrow){w(i),E(a);return}if(e&&!n.leftArrow){se(e,t,e=>{w(i),E(e)});return}return}if(n.backspace&&ee&&_===``){I(i);return}},{isActive:!0});function ce(){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 le=Math.max(2,Math.floor((j-14)/3)),L=(0,Q.useMemo)(()=>{let e=m.length;if(e<=le)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(le/2)),r=Math.min(n+le,e);return n=Math.max(0,r-le),{start:n,end:r}},[m.length,le,h]),ue=L.start>0,de=L.end<m.length;function fe(){return m.length?(0,$.jsxs)(W,{flexDirection:`column`,children:[ue&&(0,$.jsx)(W,{marginLeft:2,children:(0,$.jsxs)(G,{dimColor:!0,children:[d.arrowUp,` `,L.start,` more above`]})}),m.slice(L.start,L.end).map((e,t)=>{let n=L.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=x.has(r)?(0,$.jsx)(FS,{}):p?(0,$.jsx)(G,{color:`error`,children:d.warning}):u?(0,$.jsx)(G,{color:`success`,dimColor:!o,children:d.tick}):a?(0,$.jsx)(G,{color:`error`,children:`*`}):(0,$.jsx)(G,{children:` `}),g=p?`error`:u?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(G,{color:v,bold:o,children:i.title||r}),w,E=null;if(bS(i)){let e=xS(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(G,{dimColor:!0,children:d.triangleDownSmall}),E=(0,$.jsx)(W,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=CS(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(W,{gap:1,children:[(0,$.jsx)(G,{color:`suggestion`,children:o?d.pointer:` `}),(0,$.jsx)(G,{color:a?`success`:void 0,children:a?d.checkboxOn:d.checkboxOff}),(0,$.jsx)(G,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(G,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(G,{children:[e,(0,$.jsx)(G,{color:v,bold:o,children:t.map(e=>CS(i,e)).join(`, `)})]}):(0,$.jsxs)(G,{children:[e,(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(yS(i)){let e=wS(i);if(C===r&&o)w=(0,$.jsx)(G,{dimColor:!0,children:d.triangleDownSmall}),E=(0,$.jsx)(W,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=ES(i,e),r=c===e,a=t===T;return(0,$.jsxs)(W,{gap:1,children:[(0,$.jsx)(G,{color:`suggestion`,children:a?d.pointer:` `}),(0,$.jsx)(G,{color:r?`success`:void 0,children:r?d.radioOn:d.radioOff}),(0,$.jsx)(G,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(G,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(G,{children:[e,(0,$.jsx)(G,{color:v,bold:o,children:ES(i,c)})]}):(0,$.jsxs)(G,{children:[e,(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(G,{color:v,bold:!0,children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(G,{dimColor:!0,children:d.checkboxOff}):u?(0,$.jsx)(G,{children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`not set`});else if(jS(i))if(o)w=(0,$.jsx)(Tc,{value:_,onChange:ae,onSubmit:oe,placeholder:`Type something…`,columns:Math.min(A-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=u&&kS(i)?IS(String(c),i):String(c);w=u?(0,$.jsx)(G,{children:e}):(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(G,{children:String(c)}):(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(W,{gap:1,children:[(0,$.jsx)(G,{color:g,children:o?d.pointer:` `}),m,(0,$.jsxs)(W,{children:[S,(0,$.jsx)(G,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(W,{marginLeft:6,children:(0,$.jsx)(G,{dimColor:!0,children:i.description})}),(0,$.jsx)(W,{marginLeft:6,height:1,children:p?(0,$.jsx)(G,{color:`error`,italic:!0,children:p}):(0,$.jsx)(G,{children:` `})})]},r)}),de&&(0,$.jsx)(W,{marginLeft:2,children:(0,$.jsxs)(G,{dimColor:!0,children:[d.arrowDown,` `,m.length-L.end,` more below`]})})]}):null}return(0,$.jsx)(uu,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!M||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(G,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Pl,{children:[(0,$.jsx)(Wn,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(wl,{shortcut:`↑↓`,action:`navigate`}),M&&(0,$.jsx)(wl,{shortcut:`Backspace`,action:`unset`}),M&&M.schema.type===`boolean`&&(0,$.jsx)(wl,{shortcut:`Space`,action:`toggle`}),M&&yS(M.schema)&&(C?(0,$.jsx)(wl,{shortcut:`Space`,action:`select`}):(0,$.jsx)(wl,{shortcut:`→`,action:`expand`})),M&&bS(M.schema)&&(C?(0,$.jsx)(wl,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(wl,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(W,{flexDirection:`column`,children:[fe(),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{color:`success`,children:s===`accept`?d.pointer:` `}),(0,$.jsx)(G,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(G,{color:`error`,children:s===`decline`?d.pointer:` `}),(0,$.jsx)(G,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function zS({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;Ay(`Claude Code needs your input`,`elicitation_url_dialog`),oc(`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 g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{vt(s),t(`accept`),l(`waiting`),u.current=`waiting`,p(`open`)},[t,s]);if(Zl((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?y():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`?vt(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(uu,{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)(G,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Pl,{children:[(0,$.jsx)(Wn,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(wl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(W,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(G,{children:[_,(0,$.jsx)(G,{bold:!0,children:g}),v]})}),(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{color:`success`,children:f===`open`?d.pointer:` `}),(0,$.jsx)(G,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(G,{color:`success`,children:f===`action`?d.pointer:` `}),(0,$.jsx)(G,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{children:` `}),(0,$.jsx)(G,{color:`error`,children:f===`cancel`?d.pointer:` `}),(0,$.jsx)(G,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(uu,{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)(G,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Pl,{children:[(0,$.jsx)(Wn,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(wl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsx)(W,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(G,{children:[_,(0,$.jsx)(G,{bold:!0,children:g}),v]})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{color:`success`,children:f===`accept`?d.pointer:` `}),(0,$.jsx)(G,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(G,{color:`error`,children:f===`decline`?d.pointer:` `}),(0,$.jsx)(G,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}K(),Qe(),gc(),pg();function BS({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){Ll(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(hg,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(G,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(W,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(wa,{options:a,onChange:e=>{r(e)}})})})}function VS(){return(0,Q.useSyncExternalStore)(Ze,Le)}Df(),Cu(),ml(),wu();var HS=`at_mentioned`,US=Su(()=>xu({method:vu(HS),params:xu({filePath:mu(),lineStart:hu().optional(),lineEnd:hu().optional()})}));function WS(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Rn(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(US(),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){J(e)}})},[e,t])}cg(),ug(),Pg();function GS(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])}Vh();function KS(){let[e,t]=(0,Q.useState)({...mc});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return Mc.add(e),()=>{Mc.delete(e)}},[]),e}K();function qS({ideSelection:e,mcpClients:t}){let{status:n}=GS(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)(G,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(G,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,n_(e.filePath)]},`selection-indicator`)}function JS(){return(0,Q.useSyncExternalStore)(In.subscribe,In.getState)}K(),xr();function YS({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Hs(e,t),a=JS();if(!r||a)return null;let o=yi(),s=Xc(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(W,{flexDirection:`row`,children:o?(0,$.jsx)(G,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(G,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}K(),tr();function XS(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=Ps(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Ve.isSandboxingEnabled())return;let e=Ve.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)}},[]),!Ve.isSandboxingEnabled()||e===0?null:(0,$.jsx)(W,{paddingX:0,paddingY:0,children:(0,$.jsxs)(G,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Ai(),Y(),U(),K(),Ft(),Ph(),Kf(),ml(),oe(),Ye();var ZS=5e3;function QS({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)(()=>ja(ln(a)),[a]),p=Bh(),m=Hs(f,p).isAboveWarningThreshold,{status:h}=GS(l),g=H(e=>e.notifications),{addNotification:_,removeNotification:v}=Yn(),y=KS();(0,Q.useEffect)(()=>(qa((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>qa(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=cp(),S=x===`team`||x===`enterprise`,C=Fh(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(X(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(G,{dimColor:!0,children:(0,$.jsx)(Wn,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${Is(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(W,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)($S,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function $S({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(!np())return;let e=setInterval(e=>{let t=sp(),n=t>=1e4?Wf(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qS,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(G,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(G,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(W,{children:(0,$.jsx)(G,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(W,{children:[(0,$.jsxs)(G,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(G,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(W,{children:(0,$.jsx)(G,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(W,{children:(0,$.jsx)(G,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(W,{children:(0,$.jsxs)(G,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),(0,$.jsx)(YS,{tokenUsage:l,model:u}),(0,$.jsx)(XS,{})]})}Ai(),Ye(),K();var eC=10,tC=null,nC=0,rC;async function iC(e,t){let n=Math.ceil(e/eC)*eC;if(tC&&nC>=n&&rC===t)return tC;tC&&await tC,nC=n,rC=t,tC=(async()=>{let e=[],n=0;for await(let r of We())if(!(t&&Or(r.display)!==t)&&(e.push(r),n++,n>=nC))break;return e})();try{return await tC}finally{tC=null,nC=0,rC=void 0}}function aC(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}=Yn(),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=Or(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)(G,{dimColor:!0,children:(0,$.jsx)(Wn,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:ZS})},[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 iC(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])}}U();function oC(){let e=H(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(zr).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])}et(),Qt(),K(),Qe();function sC(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),[y,b]=(0,Q.useState)(`prompt`),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)(void 0),T=(0,Q.useRef)(void 0),E=(0,Q.useRef)(new Set),D=(0,Q.useRef)(null),O=(0,Q.useCallback)(()=>{T.current&&(T.current.return(void 0),T.current=void 0)},[]),k=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),v(0),b(`prompt`),S({}),w(void 0),O(),E.current.clear()},[c,O]),A=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){O(),E.current.clear(),w(void 0),m(!1),n(h),r(_),a(y),l(x);return}if(e||(O(),T.current=rr(),E.current.clear()),T.current)for(;;){if(t?.aborted)return;let e=await T.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!E.current.has(i)){E.current.add(i),w(e.value),m(!1),a(Or(i)),n(i),l(e.value.pastedContents);let t=Wr(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,O,n,r,a,l,h,_,y,x]),j=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),b(o),S(u),T.current=rr(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),ee=(0,Q.useCallback)(()=>{if(C){let e=Or(C.display);n(Wr(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),te=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),N=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=Or(C.display),n=Wr(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);Ll(`history:search`,j,{context:`Global`,isActive:!s}),Dl((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":ee,"historySearch:cancel":te,"historySearch:execute":N}),[M,ee,te,N]),{context:`HistorySearch`,isActive:s});let P=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),te())};Zl((e,t,n)=>{P(new Il(n.keypress))},{isActive:s});let F=(0,Q.useRef)(A);return F.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,F.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:P}}function cC({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}}K(),Y(),U();function lC({inputValue:e,isAssistantResponding:t}){let n=H(e=>e.promptSuggestion),r=Jc(),i=Rl(),{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)(()=>{Xr(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();X(`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}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}ye(),xd(),Km();var uC=15,dC=1e3,fC=[`|`,`||`,`&&`,`;`];function pC(e){return typeof e==`object`&&!!e&&`op`in e&&fC.includes(e.op)}function mC(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function hC(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function gC(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&pC(n)}function _C(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=bm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:mC(t)}}let a=hC(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&pC(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=mC(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=gC(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function vC(e,t){return t===`variable`?`compgen -v ${xm([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${xm([e])} 2>/dev/null | head -${uC} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${xm([e])} 2>/dev/null`}function yC(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${xm([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${xm([e])}*(N[1,${uC}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${xm([e])}*]} 2>/dev/null`}async function bC(e,t,n,r){let i;if(e===`bash`)i=vC(t,n);else if(e===`zsh`)i=yC(t,n);else return[];return(await(await Xo(i,r,`bash`,{timeout:dC})).result).stdout.split(`
36
+ `).filter(e=>e.trim()).slice(0,uC).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function xC(e,t,n){let r=qm();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=_C(e,t);return i?(await bC(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return q(`Shell completion failed: ${e}`),[]}}qv();var SC=/[:_-]/g,CC=null;function wC(e){if(CC?.commands===e)return CC.fuse;let t=new Kv(e.filter(e=>!e.isHidden).map(e=>{let t=ft(e),n=t.split(SC).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>IC(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 CC={commands:e,fuse:t},t}function TC(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function EC(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 DC(e,t){if(!e)return null;let n=PC(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!TC(t.metadata))continue;let n=ft(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function OC(e){return e.startsWith(`/`)}function kC(e){return!(!OC(e)||!e.includes(` `)||e.endsWith(` `))}function AC(e){return`/${e} `}function jC(e){let t=ft(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function MC(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function NC(e,t){let n=ft(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:bn(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:jC(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function PC(e,t){if(!OC(e)||kC(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:Pe(ft(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=>jC(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(jC(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)=>ft(e).localeCompare(ft(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=>NC(e))}let r=t.find(e=>e.isHidden&&ft(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&ft(e).toLowerCase()===n)&&(r=void 0);let i=wC(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`?Pe(ft(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 NC(t,MC(n,t.aliases))});if(r){let e=jC(r);if(!i.some(t=>t.id===e))return[NC(r),...i]}return i}function FC(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Hn(o,n):void 0;else{if(!TC(e.metadata))return;o=ft(e.metadata),s=e.metadata}let c=AC(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function IC(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function LC(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}Oh(),Qt(),xd();var RC=null,zC=0,BC=6e4;async function VC(){let e=Date.now();if(RC&&e-zC<BC)return RC;let t=[],n=new Set;try{for await(let e of We()){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){q(`Failed to read shell history: ${e}`)}return RC=t,zC=e,t}function HC(e){if(!RC)return;let t=RC.indexOf(e);t!==-1&&RC.splice(t,1),RC.unshift(e)}async function UC(e){if(!e||e.length<2||!e.trim())return null;let t=await VC();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}wm(),xd(),wu(),ad(),Td();var WC=`slack_search_channels`,GC=new Map,KC=new Set,qC=0,JC=Zu(),YC=JC.subscribe,XC=null,ZC=null;function QC(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function $C(e,t){let n=QC(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:WC,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?nw(tw(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
37
+ `))):[]}catch(e){return q(`Failed to fetch Slack channels: ${e}`),[]}}var ew=Su(()=>xu({results:mu()}));function tw(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=ew().safeParse(hd(t));if(e.success)return e.data.results}catch{}return e}function nw(e){let t=[],n=new Set;for(let r of e.split(`
38
+ `)){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 rw(e){return QC(e)!==void 0}function iw(){return qC}function aw(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!KC.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function ow(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function sw(e,t){let n,r=0;for(let[i,a]of GC)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function cw(e,t){if(!t)return[];let n=ow(t),r=t.toLowerCase(),i=GC.get(n)??sw(n,r);if(!i)if(XC===n&&ZC)i=await ZC;else{XC=n,ZC=$C(e,n),i=await ZC,GC.set(n,i);let t=KC.size;for(let e of i)KC.add(e);KC.size!==t&&(qC++,JC.emit()),GC.size>50&&GC.delete(GC.keys().next().value),XC===n&&(XC=null,ZC=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}qv(),Hh(),Zs(),Kf(),Df();function lw(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 uw=15,dw=60;function fw(e){return Vf(e,dw)}function pw(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:fw(e.whenToUse),agentType:e.agentType,color:ps(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 J(e),[]}}async function mw(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Uh(e,r),Promise.resolve(pw(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:fw(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,uw).map(lw);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 Kv(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:uw});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,uw).map(e=>e.source).map(lw)}Ai(),K(),Y(),L(),et(),ho(),Dt(),Qe(),Bt(),U(),Kf(),ve(),Hh();var hw=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,gw=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,_w=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,vw=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,yw=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,bw=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function xw(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function Sw(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 Cw(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function ww(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Tw(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 Ew(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 Dw=/(^|\s)@[\w-]*$/;function Ow(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 kw=null;async function Aw(e,t){try{return kw&&kw.abort(),kw=new AbortController,await xC(e,t,kw.signal)}catch{return X(`tengu_shell_completion_failed`,{}),[]}}function jw(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 Mw(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(hw);if(a&&a[0].length===i.length){let r=e.substring(t).match(gw),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?_w:vw,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(gw),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Nw(e){if(OC(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 Pw(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function Fw({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}=Yn(),g=Ps(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,v]=(0,Q.useState)(`none`),y=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=ft(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=H(e=>e.mcp.resources),C=_e(),w=H(e=>e.promptSuggestion),T=H(e=>!!e.viewingAgentTaskId),E=Vl(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=EC(i,a);if(!t)return;let n=DC(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),ee=(0,Q.useRef)(``),te=(0,Q.useRef)(``),N=(0,Q.useRef)(``),P=(0,Q.useRef)(``),F=(0,Q.useRef)(l);F.current=l;let ne=(0,Q.useRef)(null),I=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),re=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await mw(e,S,s,t);if(M.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(Kh(),Wh(()=>{let e=M.current;e!==null&&(M.current=null,re(e,e===``))})),[re]);let ie=du(re,50),ae=du((0,Q.useCallback)(async e=>{P.current=e;let t=await cw(C.getState().mcp.clients,e);P.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),oe=(0,Q.useCallback)(async(t,n)=>{let r=n??j.current;if(f){ie.cancel(),I();return}if(o===`prompt`){let n=EC(t,r);if(n&&DC(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){N.current=t;let e=await UC(t);if(N.current!==t)return;if(e){O({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}else O(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=C.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){ie.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(bw);if(e&&rw(C.getState().mcp.clients)){ae(e[2]);return}else _===`slack-channel`&&(ae.cancel(),I())}let a=t.substring(0,r).match(yw),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&OC(t)&&r>0){let e=Nw(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){ie.cancel(),I();return}let n=await kh(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}ie.cancel(),I();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await ro(t,{limit:10})).map(e=>{let t=so(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Uf(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}I();return}}let l=t.substring(0,r);if(o===`prompt`&&OC(l)&&r>0&&!Pw(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=ft(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=Qc(l.slice(n+1));t=pr(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=PC(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),v(n.length>0?`command`:`none`),n.length>0&&x(y);return}if(_===`command`?(ie.cancel(),I()):OC(l)&&Pw(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&I(),_===`agent`&&F.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||I()),a&&o!==`bash`){let e=Mw(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=ww(e);if(Eh(t)){te.current=t;let e=await Dh(t,{maxResults:10});if(te.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:Sw(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;ie(t,!0);return}}if(_===`file`){let e=Mw(t,r,!0);if(e){let t=ww(e);if(M.current===t)return;ie(t,!1)}else ie.cancel(),I()}if(_===`shell`){let e=F.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(ie.cancel(),I())}},[_,e,c,I,ie,ae,o,f,y]);(0,Q.useEffect)(()=>{ne.current!==i&&(ee.current!==i&&(ee.current=i,M.current=null),ne.current=null,oe(i))},[i,oe]);let se=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=EC(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=n+`/`+A.fullCommand+` `+a,s=e.startPos+1+A.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){ie.cancel(),ae.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=`/${ft(e)} `;t(n+i.slice(a)),r(n.length)}I()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Cw(n);t(e),r(e.length),I()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=OC(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=xw(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),xw(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),oe(o,o.length)):I()}else{let e=Mw(i,a,!0)??Mw(i,a,!1);if(e){let a=xw(n.metadata)&&n.metadata.type===`directory`,s=jw(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),oe(o,s.cursorPos)):I()}else I()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Ew(n,i,a,t,r,e?.completionType),I()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Ow(n,i,a,Dw,t,r),I())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(Ow(n,i,a,bw,t,r),I())}else if(_===`file`&&l.length>0){let n=Mw(i,a,!0);if(!n){I();return}let s=Gh(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=Tw({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});qh(e,i,n.token,n.startPos,t,r),oe(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);qh(Tw({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),I()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Aw(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Ew(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=Mw(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await mw(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,I,a,oe,S,c,s,ie,ae,A]),ce=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(FC(s,!0,e,t,r,n),ie.cancel(),I());else if(_===`custom-title`&&u<l.length){if(s){let e=Cw(s);t(e),r(e.length),n(e,!0),ie.cancel(),I()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Ew(e,i,a,t,r,n?.completionType),ie.cancel(),I()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Ow(s,i,a,Dw,t,r),ie.cancel(),I();else if(_===`slack-channel`&&u<l.length)s&&(Ow(s,i,a,bw,t,r),ae.cancel(),I());else if(_===`file`&&u<l.length){let e=Mw(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);qh(Tw({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),ie.cancel(),I()}}else if(_===`directory`&&u<l.length&&s){if(OC(i)){ie.cancel(),I();return}let e=Mw(i,a,!0)??Mw(i,a,!1);if(e){let n=xw(s.metadata)&&s.metadata.type===`directory`,a=jw(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}ie.cancel(),I()}},[l,u,_,e,i,a,o,t,r,n,I,ie,ae]),le=(0,Q.useCallback)(()=>{se()},[se]),L=(0,Q.useCallback)(()=>{ie.cancel(),ae.cancel(),I(),ne.current=i},[ie,ae,I,i]),ue=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":le,"autocomplete:dismiss":L,"autocomplete:previous":ue,"autocomplete:next":de}),[le,L,ue,de]),pe=l.length>0||!!A,me=Ki();oc(`autocomplete`,pe),zl(`Autocomplete`,pe),Dl(fe,{context:`Autocomplete`,isActive:pe&&!me});function he(e){let n=Or(e);if(n!==`prompt`&&m){m(n);let i=Wr(e);t(i),r(i.length)}else t(e),r(e.length)}let ge=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),he(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||A)return;let t=w.text,n=w.shownAt;if(t&&n>0&&i===``&&!T){e.preventDefault(),p(),he(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(G,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=E?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),de();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),ue();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),ce())};return Zl((e,t,n)=>{let r=new Il(n.keypress);ge(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:ge}}Zh();var Iw={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function Lw(e){return e in Iw}me();function Rw(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 zw(e){let t=Rw(e);return{nextMode:t,context:gn(e.mode,t,e)}}mh();var Bw=Ig();zu(),ho(),K(),Qe(),U(),uf();function Vw({onDone:e}){oc(`bridge-dialog`);let t=H(e=>e.replBridgeConnected),n=H(e=>e.replBridgeSessionActive),r=H(e=>e.replBridgeReconnecting),i=H(e=>e.replBridgeConnectUrl),a=H(e=>e.replBridgeSessionUrl),o=H(e=>e.replBridgeError),s=H(e=>e.replBridgeExplicit),c=H(e=>e.replBridgeEnvironmentId),l=H(e=>e.replBridgeSessionId),u=H(e=>e.verbose),d=Jc(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=n_(Ku());(0,Q.useEffect)(()=>{hf().then(_).catch(()=>{})},[]);let y=n?a:i;(0,Q.useEffect)(()=>{if(!f||!y){h(``);return}(0,Bw.toString)(y,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,y]),Dl({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),Zl(t=>{t===`d`&&(s&&ff(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:b,color:x}=uh({error:o,connected:t,sessionActive:n,reconnecting:r}),S=o?`×`:Ld,C=m?m.split(`
39
+ `).filter(e=>e.length>0):[],w=[];v&&w.push(v),g&&w.push(g);let T=w.length>0?` · `+w.join(` · `):``,E=o?ph:y?n?fh(y):dh(y):void 0;return(0,$.jsx)(uu,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(W,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(G,{children:[(0,$.jsxs)(G,{color:x,children:[S,` `,b]}),(0,$.jsx)(G,{dimColor:!0,children:T})]}),o&&(0,$.jsx)(G,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(G,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(G,{dimColor:!0,children:[`Session: `,l]})]}),f&&C.length>0&&(0,$.jsx)(W,{flexDirection:`column`,children:C.map((e,t)=>(0,$.jsx)(G,{children:e},t))}),E&&(0,$.jsx)(G,{dimColor:!0,children:E}),(0,$.jsx)(G,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}K(),ho(),Di(),K(),cd(),Ph(),Kf(),wt(),ho(),Qt(),Di(),K(),Kf(),Jh(),ho(),Hh(),Di(),K(),cd(),Ph(),Kf(),Jn(),K(),Qe(),Ye(),T();function Hw({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ch(),[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`}];Ll(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),Ll(`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)(lu,{color:`permission`,children:[(0,$.jsxs)(W,{flexDirection:`column`,children:[(0,$.jsxs)(W,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(G,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(G,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(W,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(wa,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(W,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(G,{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)(G,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(G,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(Pl,{children:[(0,$.jsx)(wl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Wn,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(Pl,{children:[(0,$.jsx)(wl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Wn,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}kr(),Im(),fc(),Vg(),zg();function Uw(e,t,n){let r=t;for(let t=0;t<n;t++){let t=Ww(e,r);if(t.equals(r))break;r=t}return r}function Ww(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 Gw(e){return`eE$`.includes(e)}function Kw(e){return`jkG`.includes(e)||e===`gg`}var qw={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function Jw(e,t,n,r){if(n===`w`)return Yw(e,t,r,Kc);if(n===`W`)return Yw(e,t,r,e=>!R(e));let i=qw[n];if(i){let[n,a]=i;return n===a?Xw(e,t,n,r):Zw(e,t,n,a,r)}return null}function Yw(e,t,n,r){let i=[];for(let{segment:t,index:n}of Lf().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=>R(o(e)),l=e=>r(o(e)),u=e=>fr(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 Xw(e,t,n,r){let i=e.lastIndexOf(`
40
+ `,t-1)+1,a=e.indexOf(`
41
+ `,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 Zw(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}}rl(),Rf(),Qf();function Qw(e,t,n,r){let i=Uw(t,r.cursor,n);if(i.equals(r.cursor))return;let a=uT(r.cursor,i,t,e,n);fT(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function $w(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new cl(i.cursor.measuredText,a),s=dT(i.cursor,o,t);fT(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function eT(e,t,n,r,i){let a=Jw(i.text,i.cursor.offset,n,t===`inner`);a&&(fT(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function tT(e,t,n){let r=n.text,i=r.split(`
42
+ `),a=$f(r.slice(0,n.cursor.offset),`
43
+ `),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(`
44
+ `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
45
+ `)||(l+=`
46
+ `),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]===`
47
+ `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(zf(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(`
48
+ `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function nT(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-(zf(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function rT(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Bf(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 iT(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=Bf(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 aT(e,t){let n=t.text.split(`
49
+ `),{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(`
50
+ `);t.setText(c),t.setOffset(lT(s,r)+o),t.recordChange({type:`join`,count:e})}function oT(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
51
+ `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
52
+ `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
53
+ `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
54
+ `);n.setText(u),n.setOffset(lT(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=zf(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function sT(e,t,n){let r=n.text.split(`
55
+ `),{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(`
56
+ `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(lT(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function cT(e,t){let n=t.text.split(`
57
+ `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
58
+ `);t.setText(o),t.enterInsert(lT(a,i)),t.recordChange({type:`openLine`,direction:e})}function lT(e,t){return e.slice(0,t).join(`
59
+ `).length+ +(t>0)}function uT(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(Kw(n)){s=!0;let t=e.text,n=t.indexOf(`
60
+ `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
61
+ `&&--a):o=n+1}else Gw(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 dT(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 fT(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
62
+ `)&&(a+=`
63
+ `),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-(zf(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 pT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=uT(n.cursor,r,`G`,e,t);fT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function mT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=uT(n.cursor,r,`gg`,e,t);fT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var hT={d:`delete`,c:`change`,y:`yank`};function gT(e){return e in hT}var _T=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),vT=new Set([`f`,`F`,`t`,`T`]),yT={i:`inner`,a:`around`};function bT(e){return e in yT}var xT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),ST=1e4;function CT(){return{mode:`INSERT`,insertedText:``}}function wT(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function TT(e,t,n){switch(e.type){case`idle`:return OT(t,n);case`count`:return kT(e,t,n);case`operator`:return AT(e,t,n);case`operatorCount`:return jT(e,t,n);case`operatorFind`:return MT(e,t,n);case`operatorTextObj`:return NT(e,t,n);case`find`:return PT(e,t,n);case`g`:return FT(e,t,n);case`operatorG`:return IT(e,t,n);case`replace`:return LT(e,t,n);case`indent`:return RT(e,t,n)}}function ET(e,t,n){return gT(e)?{next:{type:`operator`,op:hT[e],count:t}}:_T.has(e)?{execute:()=>{let r=Uw(e,n.cursor,t);n.setOffset(r.offset)}}:vT.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:()=>iT(t,n)}:e===`x`?{execute:()=>nT(t,n)}:e===`J`?{execute:()=>aT(t,n)}:e===`p`||e===`P`?{execute:()=>oT(e===`p`,t,n)}:e===`D`?{execute:()=>Qw(`delete`,`$`,1,n)}:e===`C`?{execute:()=>Qw(`change`,`$`,1,n)}:e===`Y`?{execute:()=>tT(`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:()=>zT(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:()=>cT(`below`,n)}:e===`O`?{execute:()=>cT(`above`,n)}:null}function DT(e,t,n,r){return bT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:yT[n]}}:vT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:_T.has(n)?{execute:()=>Qw(e,n,t,r)}:n===`G`?{execute:()=>pT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function OT(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:ET(e,1,t)||{}}function kT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),ST))}}}return ET(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function AT(e,t,n){return t===e.op[0]?{execute:()=>tT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:DT(e.op,e.count,t,n)||{next:{type:`idle`}}}function jT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),ST);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return DT(e.op,i,t,n)||{next:{type:`idle`}}}function MT(e,t,n){return{execute:()=>$w(e.op,e.find,t,e.count,n)}}function NT(e,t,n){return xT.has(t)?{execute:()=>eT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function PT(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 FT(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=Uw(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
64
+ `),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 IT(e,t,n){return t===`j`||t===`k`?{execute:()=>Qw(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>mT(e.op,e.count,n)}:{next:{type:`idle`}}}function LT(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>rT(t,e.count,n)}}function RT(e,t,n){return t===e.dir?{execute:()=>sT(e.dir,e.count,n)}:{next:{type:`idle`}}}function zT(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)}rl(),Rf();function BT(e){let t=Q.useRef(CT()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(wT()),a=Ii({...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]!==`
65
+ `&&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=cl.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`:nT(t.count,r);break;case`replace`:rT(t.char,t.count,r);break;case`toggleCase`:iT(t.count,r);break;case`indent`:sT(t.dir,t.count,r);break;case`join`:aT(t.count,r);break;case`openLine`:cT(t.direction,r);break;case`operator`:Qw(t.op,t.motion,t.count,r);break;case`operatorFind`:$w(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:eT(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=cl.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,-(zf(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=TT(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}}ql(),K();function VT(e){let[t]=Ol(),n=Rl();Mt(n,!!e.onImagePaste);let r=BT({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?su.inverse:e=>e,themeText:$l(`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)(W,{flexDirection:`column`,children:(0,$.jsx)(Na,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Sr(),yg(),s();function HT(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 UT(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function WT(e){let t=u_(`sha256`).update(e).digest(`hex`).slice(0,16);return l_(o(),`cache-stats`,`${t}.json`)}var GT={version:1,signature:null,lastResetAt:null,lastHitRate:null};function KT(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 qT(e){try{let t=await y_(e,`utf8`),n=JSON.parse(t);return KT(n)?n:{...GT}}catch{return{...GT}}}async function JT(e,t){await v_(c_(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await x_(n,JSON.stringify(t),`utf8`),await b_(n,e)}catch{}}var YT={signature:null,lastResetAt:null,lastHitRate:null},XT=null;async function ZT(e){XT=e;let t=await qT(WT(e));YT={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function QT(e){let t=UT(e),n=HT(e);return t!==YT.signature&&(YT={signature:t,lastResetAt:Date.now(),lastHitRate:n},XT!==null&&JT(WT(XT),{version:1,signature:t,lastResetAt:YT.lastResetAt,lastHitRate:n})),{...YT}}function $T(){return{...YT}}K(),Kf(),Di();function eE(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 tE(){return(0,$.jsx)(G,{dimColor:!0,children:` │ `})}function nE({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=nu(),[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=`${Hf(n)}/${Hf(r)}`;return(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{children:u}),(0,$.jsx)(tE,{}),(0,$.jsx)(G,{dimColor:!0,children:`Context `}),(0,$.jsxs)(G,{children:[t,`%`]}),!d&&(0,$.jsxs)(G,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(G,{dimColor:!0,children:`Session `}),(0,$.jsxs)(G,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(G,{dimColor:!0,children:[` `,eE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(G,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(G,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(G,{dimColor:!0,children:[` `,eE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(G,{children:Gs(i)})]})]})}var rE=Q.memo(nE);Y(),U(),zu(),Ai(),di(),Vh(),Lc(),K(),Zo(),uf(),fp(),cd(),xd(),Bc(),oe(),vp(),ve(),E(),Kf();var iE=3600*1e3;function aE(e){return String(Math.floor(e)).padStart(2,`0`)}function oE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${aE(t)}:${aE(n)}`}function sE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Ni(e),o=(0,Q.useRef)(null);if(a!==null){let e=UT(a);e!==o.current&&(o.current=e,QT(a))}let{lastResetAt:s,lastHitRate:c}=$T(),l=s===null?null:t-s,u=l===null?null:iE-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,ZT(ed()))},[]);let h=a===null?c:HT(a);if(h===null&&s===null)return(0,$.jsx)(G,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:oE(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{dimColor:!0,children:` Cache `}),(0,$.jsx)(G,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(G,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function cE(){let{getGoal:t,formatGoalStatusLabel:n}=(ac(),e(Wi)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Hf(r.tokensUsed):`${Hf(r.tokensUsed)}/${Hf(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(G,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(G,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(G,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(G,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(G,{children:o})}return(0,$.jsxs)(G,{children:[s,(0,$.jsx)(G,{dimColor:!0,children:` · `}),(0,$.jsx)(G,{dimColor:!0,children:i}),(0,$.jsx)(G,{dimColor:!0,children:` · `}),(0,$.jsx)(G,{children:a})]})}function lE(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function uE(e,t,n,r,i,a,o){let s=Bu(),c=mr(),l=Dp({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Ni(r),f=hp(l,Wu()),p=rp(d,f),m=ws(ed()),h=ha(),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{...Gn(),...m&&{session_name:m},model:{id:l,display_name:mp(l)},workspace:{current_dir:ld(),project_dir:Ku(),added_dirs:i},version:`0.0.11`,output_style:{name:u},cost:{total_cost_usd:ku(),total_duration_ms:Ou(),total_api_duration_ms:Fu(),total_lines_added:Xu(),total_lines_removed:Tu()},context_window:{total_input_tokens:Nu(),total_output_tokens:Yu(),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},...gg()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...Eu()&&{remote:{session_id:ed()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function dE(e){return wo(e)?.uuid??null}function fE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=H(e=>e.toolPermissionContext.mode),a=H(e=>e.toolPermissionContext.additionalWorkingDirectories),o=H(e=>e.statusLineText),s=Jc(),c=ll(),{addNotification:l}=Yn(),u=Bh(),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}),_=(0,Q.useRef)(void 0),v=(0,Q.useRef)(!0),y=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=v.current;if(v.current=!1,d.current?.statusLine?.command)try{let e=g.current.exceeds200kTokens,r=dE(n);r!==g.current.messageId&&(e=wi(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await w(uE(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]),b=(0,Q.useCallback)(()=>{_.current!==void 0&&clearTimeout(_.current),_.current=setTimeout((e,t)=>{e.current=void 0,t()},300,_,y)},[y]);(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,b())},[t,i,n,u,b]);let x=c?.statusLine?.command,S=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(S.current){S.current=!1;return}v.current=!0,y()},[x,y]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(X(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&q(`Status line is configured but disableAllHooks is true`,{level:`warn`}),df()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),q(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(y(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let C=c?.statusLine?.padding??0,T=Dp({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),E=hp(T,Wu()),D=Ni(e.current),O=D?D.input_tokens+D.cache_creation_input_tokens+D.cache_read_input_tokens:0,k=D?Math.round(rp(D,E).used??0):0,A=ha(),j={...A.five_hour&&{five_hour:{utilization:A.five_hour.utilization,resets_at:A.five_hour.resets_at}},...A.seven_day&&{seven_day:{utilization:A.seven_day.utilization,resets_at:A.seven_day.resets_at}}},M=c?.statusLineEnabled===!0,ee=!!c?.statusLine?.command;return(0,$.jsxs)(W,{flexDirection:`column`,paddingX:C,children:[M&&(0,$.jsxs)(W,{gap:2,children:[(0,$.jsx)(rE,{modelName:mp(T),contextUsedPct:k,usedTokens:O,contextWindowSize:E,totalCostUsd:ku(),rateLimits:j}),(0,$.jsx)(cE,{}),(0,$.jsx)(sE,{messages:e.current})]}),o?(0,$.jsx)(G,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(Tl,{children:o})}):ee&&no()?(0,$.jsx)(G,{children:` `}):null]})}var pE=(0,Q.memo)(fE);u(),U(),Ir(),K();function mE({tasksSelected:e,onOpenDialog:t}){let n=H(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>Gr(e)),[n]);return Rg(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hE,{selected:e,onClick:t,children:le(r)}),ut(r)&&(0,$.jsxs)(G,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function hE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(G,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(W,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}K(),ga();function gE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(W,{gap:1,children:[(0,$.jsx)(G,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Tc,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:El(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}yf(),vf(),Td();var _E=5e3;function vE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function yE(){if(!await _f())return null;let[e,t]=await Promise.all([hf(),mf()]);if(e===t)return null;let{stdout:n,code:r}=await bf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:_E,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=hd(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:vE(e.isDraft,e.reviewDecision)}}catch{return null}}zu();var bE=6e4,xE=4e3,SE=60*6e4,CE={number:null,url:null,reviewState:null,lastUpdated:0};function wE(e,t=!0){let[n,r]=(0,Q.useState)(CE),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=Ru();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=SE)return;let l=Date.now(),u=await yE();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>xE){a.current=!0;return}e||(i.current=setTimeout(c,bE))}}let l=Date.now()-o.current;return l>=bE?c():i.current=setTimeout(c,bE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}K(),u(),yg(),Bt(),Nd(),kr(),Fd(),Vg(),U(),zu(),Di(),Kf(),ts(),uf(),Pf(),zs();var TE=(um(),e(vm)),EE=e=>()=>{},DE=()=>null,OE=5e3,kE=1e3;function AE(){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=Gf(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,OE);return()=>clearInterval(n)},[]),e}function jE(){let e=(0,Q.useSyncExternalStore)(TE?.subscribeToProactiveChanges??EE,TE?.getNextTickAt??DE,DE),[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)(G,{dimColor:!0,children:[`waiting `,Wf(t*1e3,{mostSignificantOnly:!0})]})}function ME(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),kE);return()=>clearInterval(e)},[]);let r=(ac(),e(Wi)),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)(G,{color:d,children:[`goal (`,u,`)`]})}function NE({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)(G,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(G,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=gg()&&t===`INSERT`&&!l;return(0,$.jsxs)(W,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(gE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(G,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(PE,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function PE({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=nu(),l=Ps(`chat:cycleMode`,`Chat`,`shift+tab`),u=H(e=>e.tasks),f=_e(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=wE(i,IE()),h=(0,Q.useSyncExternalStore)(TE?.subscribeToProactiveChanges??EE,TE?.getNextTickAt??DE,DE),g=Kl(),_=tu().getState,v=h!==null,y=(0,Q.useMemo)(()=>jd(Object.values(u),e=>Gr(e)),[u]),b=Ws(),x=b!==void 0&&b.length>0,S=Ps(`chat:cancel`,`Chat`,`esc`).toLowerCase(),C=Ps(`app:toggleTodos`,`Global`,`ctrl+t`),w=Ps(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),T=H(e=>e.notifications.current?.key===`kill-agents-confirm`),E=AE();if(t===`bash`)return(0,$.jsx)(G,{color:`bashBorder`,children:`! for bash mode`});let D=n?.mode,O=!Pd(D),k=y>0,A=+!!O+ +!!k,j=IE()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&A<2&&(A===0||c>=80),M=A<2,ee=D&&O&&!Eu()?(0,$.jsxs)(G,{color:Kd(D),children:[Md(D),` `,Id(D).toLowerCase(),` on`,M&&(0,$.jsxs)(G,{dimColor:!0,children:[` `,(0,$.jsx)(wl,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,te=[...p?[(0,$.jsx)(jl,{url:p,children:(0,$.jsxs)(G,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...j?[(0,$.jsx)(Ut,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...E?[(0,$.jsxs)(G,{dimColor:E.level===`normal`,color:E.level===`error`?`error`:E.level===`warning`?`warning`:void 0,children:[E.text,` · pid:`,process.pid]},`rss`)]:[],...(ac(),e(Wi)).getGoal()?[(0,$.jsx)(ME,{},`goal-elapsed`)]:[]],N=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),P=r?FE(i,S,C,w,x,N,T):[];v?te.push((0,$.jsx)(jE,{},`proactive`)):r&&te.push(...P);let F=k&&!Rg(u,!1)?(0,$.jsx)(mE,{tasksSelected:a,onOpenDialog:s}):null;te.length===0&&!F&&!ee&&r&&te.push((0,$.jsx)(G,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ne=lf().copyOnSelect??!0,I=g&&(!ne||Ql());if(no()&&I){let e=Nf()===`macos`,t=e&&(_()?.lastPressHadAlt??!1);te.push((0,$.jsx)(G,{dimColor:!0,children:(0,$.jsxs)(Pl,{children:[!ne&&(0,$.jsx)(wl,{shortcut:`ctrl+c`,action:`copy`}),Ql()&&(t?(0,$.jsx)(G,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(wl,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return F&&r&&te.push((0,$.jsx)(G,{dimColor:!0,children:a?(0,$.jsx)(wl,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(wl,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),te.length===0&&!F&&!ee?no()?(0,$.jsx)(G,{children:` `}):null:(0,$.jsxs)(W,{height:1,overflow:`hidden`,children:[ee&&(0,$.jsxs)(W,{flexShrink:0,children:[ee,(F||te.length>0)&&(0,$.jsx)(G,{dimColor:!0,children:` · `})]}),F&&(0,$.jsxs)(W,{flexShrink:0,children:[F,te.length>0&&(0,$.jsx)(G,{dimColor:!0,children:` · `})]}),te.length>0&&(0,$.jsx)(G,{wrap:`truncate`,children:(0,$.jsx)(Pl,{children:te})})]})}function FE(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(G,{dimColor:!0,children:(0,$.jsx)(wl,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(G,{dimColor:!0,children:(0,$.jsx)(wl,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(G,{dimColor:!0,children:(0,$.jsx)(wl,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function IE(){return lf().prStatusFooterEnabled??!0}Lc(),Di(),K(),ts(),Ah(),vg();function LE({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:x,isPasting:S=!1,isInputWrapped:C=!1,messages:w,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k}){let A=ll(),{columns:j,rows:M}=nu(),ee=(0,Q.useRef)(w);ee.current=w;let te=(0,Q.useMemo)(()=>dE(w),[w]),N=j<80,P=no(),F=P&&M<24,ne=_,I=h||lE(A)||T;return Og((0,Q.useMemo)(()=>P&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[P,u,d,f])),u.length&&!P?(0,$.jsx)(W,{paddingX:2,paddingY:0,children:(0,$.jsx)(jh,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(bg,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(W,{flexDirection:N?`column`:`row`,justifyContent:N?`flex-start`:`space-between`,paddingX:2,gap:+!N,children:[(0,$.jsxs)(W,{flexDirection:`column`,flexShrink:+!N,children:[i===`prompt`&&!F&&!n.show&&!S&&lE(A)&&(0,$.jsx)(pE,{messagesRef:ee,lastAssistantMessageId:te,vimMode:r}),(0,$.jsx)(zE,{}),(0,$.jsx)(NE,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:I,isLoading:g,tasksSelected:ne,tmuxSelected:y,isPasting:S,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k})]}),(0,$.jsx)(W,{flexShrink:1,gap:1,children:P?null:(0,$.jsx)(QS,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:w,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:b,mcpClients:x,isInputWrapped:C,isNarrow:N})})]})})}var RE=(0,Q.memo)(LE);function zE(){return null}u(),K();function BE({isLoading:e}){return(0,$.jsxs)(G,{dimColor:e,children:[d.pointer,`\xA0`]})}function VE({mode:e,isLoading:t}){return(0,$.jsx)(W,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(G,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(BE,{isLoading:t})})}K();var HE=Q.createContext(void 0),UE=2;function WE({isFirst:e,children:t}){let n=UE,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(HE.Provider,{value:r,children:(0,$.jsx)(W,{paddingX:n,children:t})})}K(),U(),Uo(),oe(),Td(),gl();var GE=new Set;function KE(e){try{return hd(e)?.type===`idle_notification`}catch{return!1}}var qE=3;function JE(e){return`<${xf}>
66
+ <${Tf}>+${e} more tasks completed</${Tf}>
67
+ <${Cf}>completed</${Cf}>
68
+ </${xf}>`}function YE(e){let t=e.filter(e=>typeof e.value!=`string`||!KE(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=qE)return[...r,...n];let i=n.slice(0,qE-1),a={value:JE(n.length-(qE-1)),mode:`task-notification`};return[...r,...i,a]}function XE(){let e=VS(),t=H(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(jo);return t.length===0?null:kt(YE(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),vr({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(W,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(WE,{isFirst:t===0,children:(0,$.jsx)($t,{message:e,lookups:qs,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:GE,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var ZE=Q.memo(XE);xa(),u(),K();function QE({hasStash:e}){return e?(0,$.jsx)(W,{paddingLeft:2,children:(0,$.jsxs)(G,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Qt();var $E=1e4,eD=1e3;function tD(e,t){if(e.length<=$E)return{truncatedText:e,placeholderContent:``};let n=Math.floor(eD/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+nD(t,bt(a))+i,placeholderContent:a}}function nD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function rD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=tD(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function iD({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}=rD(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}U(),uf(),Uo();var aD=(um(),e(vm)),oD=3;function sD({input:e,submitCount:t}){let n=VS(),r=H(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(re)&&(lf().queuedCommandUpHintCount||0)<oD)return`Press up to edit queued messages`;if(t<1&&r&&!aD?.isProactiveActive())return Yg()}},[e,n,t,r])}var cD=5e3,lD=!1;function uD(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(lD||!e)return;lD=!0,n(!0);let t=setTimeout(n,cD,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}ql(),Ai(),Y(),U(),cd(),Uo(),kl(),L(),ho(),Pg(),Qt(),Vh(),Di(),K(),Dt(),ti(),Qe(),Yt(),Fd(),rl(),uf(),xd(),Bd(),md(),ts(),dc(),Df(),vp(),Pf(),Rh(),Ye(),ga(),Vg(),et(),yg();var dD=5,fD=3;function pD({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:y,onMessageActionsEnter:b,mcpClients:x,pastedContents:S,setPastedContents:C,vimMode:w,setVimMode:T,showBashesDialog:E,setShowBashesDialog:D,onExit:O,getToolUseContext:k,onSubmit:A,isSearchingHistory:j,setIsSearchingHistory:M,onDismissSideQuestion:ee,isSideQuestionVisible:te,helpOpen:N,setHelpOpen:P,hasSuppressedDialogs:F,isLocalJSXCommandActive:ne=!1,insertTextRef:I}){let ie=Bh(),ae=Ki()||ne,[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)({show:!1}),[L,ue]=(0,Q.useState)(f.length),de=Q.useRef(f);f!==de.current&&(ue(f.length),de.current=f);let fe=Q.useCallback(e=>{de.current=e,p(e)},[p]);I&&(I.current={cursorOffset:L,insert:e=>{let t=L===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,L)+t+f.slice(L);de.current=n,p(n),ue(L+t.length)},setInputWithCursor:(e,t)=>{de.current=e,p(e),ue(t)}});let pe=_e(),me=Jc(),he=H(e=>e.tasks),ge=H(e=>e.replBridgeConnected),R=H(e=>e.replBridgeExplicit),ve=H(e=>e.replBridgeReconnecting),ye=ge&&(R||ve),be=VS(),xe=H(e=>e.promptSuggestion),Se=H(e=>e.speculation),Ce=H(e=>e.speculationSessionTimeSavedMs),we=H(e=>e.mainLoopModel),Te=H(e=>e.mainLoopModelForSession),Ee=H(e=>e.thinkingEnabled),De=H(e=>Np()?e.fastMode:!1),Oe=H(e=>e.viewingAgentTaskId);H(e=>e.viewSelectionMode);let{historyQuery:ke,setHistoryQuery:Ae,historyMatch:je,historyFailedMatch:Me}=sC(e=>{C(e.pastedContents),Xt(e.display)},f,fe,ue,L,h,m,j,M,C,S),Ne=(0,Q.useRef)(-1);Ne.current===-1&&(Ne.current=mD(l));let Pe=(0,Q.useRef)(!1),[Fe,Ie]=(0,Q.useState)(!1),Le=H(e=>e.selectedBgAgentIndex),Re=(0,Q.useCallback)(e=>me(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[me]),[ze,Be]=(0,Q.useState)(!1),[Ve,He]=(0,Q.useState)(!1),[Ue,We]=(0,Q.useState)(!1),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(!1),[Ye,Xe]=(0,Q.useState)(!1),[Ze,Qe]=(0,Q.useState)(!1),[$e,et]=(0,Q.useState)(!1),tt=(0,Q.useMemo)(()=>{let e=f.indexOf(`
69
+ `);return e===-1||L<=e},[f,L]),nt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
70
+ `);return e===-1||L>e},[f,L]),rt=(0,Q.useMemo)(()=>jd(Object.values(he),e=>e.status===`running`),[he])>0&&!Rg(he,!1),it=oC(),at=it.length>0,ot=(0,Q.useMemo)(()=>[at&&`bg_agent`,rt&&`tasks`,ye&&`bridge`].filter(Boolean),[at,rt,ye]),st=H(e=>e.footerSelection),ct=st&&ot.includes(st)?st:null;(0,Q.useEffect)(()=>{st&&!ct&&me(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[st,ct,me]);let lt=ct===`tasks`,ut=ct===`tmux`,dt=ct===`bridge`,ft=ct===`bg_agent`;function pt(e){me(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Re(-1)}function mt(e,t=!1){let n=ct?ot.indexOf(ct):-1,r=ot[n+e];return r?(pt(r),!0):e<0&&t?(pt(null),!0):!1}let{suggestion:ht,markAccepted:gt,logOutcomeAtSubmission:_t,markShown:vt}=lC({inputValue:f,isAssistantResponding:s}),yt=(0,Q.useMemo)(()=>j&&je?Wr(typeof je==`string`?je:je.display):f,[j,je,f]),xt=(0,Q.useMemo)(()=>Ra(yt),[yt]),St=(0,Q.useMemo)(()=>hh(yt),[yt]),Ct=(0,Q.useMemo)(()=>LC(yt).filter(e=>vl(yt.slice(e.start+1,e.end),a)),[yt,a]),wt=(0,Q.useMemo)(()=>jn(yt),[yt]),Tt=(0,Q.useMemo)(()=>rw(pe.getState().mcp.clients)?aw(yt):[],[yt,(0,Q.useSyncExternalStore)(YC,iw)]),Et=(0,Q.useMemo)(()=>hl(yt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[yt]),Dt=Et.some(e=>e.start===L);(0,Q.useEffect)(()=>{let e=Et.find(e=>L>e.start&&L<e.end);if(e){let t=(e.start+e.end)/2;ue(L<t?e.start:e.end)}},[L,Et,ue]);let Ot=(0,Q.useMemo)(()=>{let e=[];for(let t of Et)L===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});j&&je&&!Me&&e.push({start:L,end:L+ke.length,color:`warning`,priority:20});for(let t of St)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of Ct)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of wt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Tt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(oo())for(let t of xt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Ms(n-t.start),shimmerColor:Ms(n-t.start,!0),priority:10});return e},[j,ke,je,Me,L,St,Et,Ct,wt,Tt,yt,xt]),{addNotification:kt,removeNotification:At}=Yn();(0,Q.useEffect)(()=>{xt.length&&oo()?kt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):At(`ultrathink-active`)},[kt,At,xt.length]);let jt=(0,Q.useRef)(f.length),Mt=(0,Q.useRef)(f.length),Nt=(0,Q.useCallback)(()=>{At(`stash-hint`)},[At]);(0,Q.useEffect)(()=>{let e=jt.current,t=Mt.current,n=f.length;if(jt.current=n,n>t){Mt.current=n;return}if(n===0){Mt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(lf().hasUsedStash||kt({key:`stash-hint`,jsx:(0,$.jsxs)(G,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Wn,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:ZS}),Mt.current=n)},[f.length,kt]);let{pushToBuffer:Pt,undo:Ft,canUndo:It,clearBuffer:Lt}=cC({maxBufferSize:50,debounceMs:1e3});iD({input:f,pastedContents:S,onInputChange:fe,setCursorOffset:ue,setPastedContents:C});let Rt=sD({input:f,submitCount:v}),zt=(0,Q.useCallback)(e=>{if(e===`?`){X(`tengu_help_toggled`,{}),P(e=>!e);return}P(!1),Nt(),cs(),Xr(me);let t=e.length===f.length+1,n=L===0,r=Or(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Wr(e).replaceAll(` `,` `);Pt(f,L,S),fe(t),ue(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Pt(f,L,S),me(e=>e.footerSelection===null?e:{...e,footerSelection:null}),fe(i)},[fe,h,f,L,Pt,S,Nt,me]),{resetHistory:Bt,onHistoryUp:Vt,onHistoryDown:Ht,dismissSearchHint:Ut,historyIndex:Wt}=aC((e,t,n)=>{zt(e),h(t),C(n)},f,S,ue,m);(0,Q.useEffect)(()=>{j&&Ut()},[j,Ut]);function Gt(){if(!(Zt.length>1)&&tt){if(be.some(re)){cn();return}Vt()}}function Kt(){if(!(Zt.length>1)&&nt&&Ht()&&ot.length>0){let e=ot[0];pt(e),e===`tasks`&&!lf().hasSeenTasksHint&&ff(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[qt,Jt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Yt=(0,Q.useCallback)(e=>{Jt(t=>typeof e==`function`?e(t):e)},[]),Xt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=pe.getState();if(n.footerSelection&&ot.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=xe.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(Se.status===`active`){gt(),_t(i,{skipReset:!0}),A(i,{setCursorOffset:ue,clearBuffer:Lt,resetHistory:Bt},{state:Se,speculationSessionTimeSavedMs:Ce,setAppState:me});return}xe.shownAt>0&&(gt(),e=i)}if(e.trim()===``&&!r)return;let a=qt.suggestions.length>0&&qt.suggestions.every(e=>e.description===`directory`);if(qt.suggestions.length>0&&!t&&!a){q(`[onSubmit] early return: suggestions showing (count=${qt.suggestions.length})`);return}xe.text&&xe.shownAt>0&&_t(e),At(`stash-hint`),await A(e,{setCursorOffset:ue,clearBuffer:Lt,resetHistory:Bt})},[xe,Se,Ce,pe,ot,qt.suggestions,A,Lt,Bt,_t,me,gt,S,At]),{suggestions:Zt,selectedSuggestion:Qt,commandArgumentHint:$t,inlineGhostText:en,maxColumnWidth:tn}=Fw({commands:a,onInputChange:fe,onSubmit:Xt,setCursorOffset:ue,input:f,cursorOffset:L,mode:m,agents:o,setSuggestionsState:Yt,suggestionsState:qt,suppressSuggestions:j||Wt>0,markAccepted:gt,onModeChange:h}),nn=m===`prompt`&&Zt.length===0&&ht&&!Oe;nn&&vt(),xe.text&&!ht&&xe.shownAt===0&&!Oe&&(Gi(`timing`,xe.text),me(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function rn(e,t,n,r,i){X(`tengu_paste_image`,{}),h(`prompt`);let a=Ne.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};bo(o),da(o),C(e=>({...e,[a]:o})),on((Pe.current?` `:``)+vn(a)),Pe.current=!0}(0,Q.useEffect)(()=>{let e=new Set(hl(f).map(e=>e.id));C(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,C]);function an(e){Pe.current=!1;let t=au(e).replace(/\r/g,`
71
+ `).replaceAll(` `,` `);if(f.length===0){let e=Or(t);e!==`prompt`&&(h(e),t=Wr(t))}let n=bt(t),r=Math.min(wn-10,2);if(t.length>800||n>r){let e=Ne.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),on(zn(e,n))}else on(t)}let z=(0,Q.useCallback)((e,t)=>Pe.current?(Pe.current=!1,_g(e,t)?` `+e:e):e,[]);function on(e){Pt(f,L,S);let t=f.slice(0,L)+e+f.slice(L);fe(t),ue(L+e.length)}let sn=Yl(()=>{},()=>y()),cn=(0,Q.useCallback)(()=>{let e=En(f,L);return e?(fe(e.text),h(`prompt`),ue(e.cursorOffset),e.images.length>0&&C(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[fe,h,f,L,C]);WS(x,function(e){X(`tengu_ext_at_mentioned`,{});let t,n=t_.relative(ld(),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[L-1]??` `;/\s/.test(r)||(t=` ${t}`),on(t)});let ln=(0,Q.useCallback)(()=>{if(It){let e=Ft();e&&(fe(e.text),ue(e.cursorOffset),C(e.pastedContents))}},[It,Ft,fe,C]),un=(0,Q.useCallback)(()=>{Pt(f,L,S);let e=f.slice(0,L)+`
72
+ `+f.slice(L);fe(e),ue(L+1)},[f,L,fe,ue,Pt,S]),dn=(0,Q.useCallback)(async()=>{X(`tengu_external_editor_used`,{}),He(!0);try{let e=await Ih(f,S);e.error&&kt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Pt(f,L,S),fe(e.content),ue(e.content.length))}catch(e){e instanceof Error&&J(e),kt({key:`external-editor-error`,text:`External editor failed: ${pd(e)}`,color:`warning`,priority:`high`})}finally{He(!1)}},[f,L,S,Pt,fe,kt]),fn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(fe(g.text),ue(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:L,pastedContents:S}),fe(``),ue(0),C({}),ff(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,L,g,fe,_,S,C]),pn=(0,Q.useCallback)(()=>{We(e=>!e),N&&P(!1)},[N]),mn=(0,Q.useCallback)(()=>{Qe(e=>!e),N&&P(!1)},[N]),hn=(0,Q.useCallback)(()=>{et(e=>!e),N&&P(!1)},[N]),gn=(0,Q.useCallback)(()=>{q(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=Rw(n),{context:t}=zw(n);X(`tengu_mode_cycle`,{to:e}),e===`plan`&&ff(e=>({...e,lastPlanModeUse:Date.now()})),me(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),N&&P(!1)},[n,me,r,N]),_n=(0,Q.useCallback)(()=>{gi().then(e=>{if(e)rn(e.base64,e.mediaType);else{let e=pi(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Ad.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;kt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[kt,rn]),yn=Vl();(0,Q.useEffect)(()=>{if(!(!yn||ae))return yn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Xt(f)}})},[yn,ae,Xt,f]),Dl((0,Q.useMemo)(()=>({"chat:undo":ln,"chat:newline":un,"chat:externalEditor":dn,"chat:stash":fn,"chat:modelPicker":pn,"chat:thinkingToggle":hn,"chat:cycleMode":gn,"chat:imagePaste":_n}),[ln,un,dn,fn,pn,hn,gn,_n]),{context:`Chat`,isActive:!ae}),Ll(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!ae&&!j}),Ll(`chat:fastMode`,mn,{context:`Chat`,isActive:!ae&&Np()&&Ip()}),Ll(`help:dismiss`,()=>{P(!1)},{context:`Help`,isActive:N}),Ll(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),Ll(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),Ll(`history:search`,()=>{},{context:`Global`,isActive:!1}),Ll(`app:interrupt`,()=>{Xr(me)},{context:`Global`,isActive:!s&&Se.status===`active`}),Dl({"footer:up":()=>{if(ft){Le>-1?Re(e=>e-1):pt(null);return}mt(-1,!0)},"footer:down":()=>{if(ft){Le<it.length-1&&Re(e=>e+1);return}if(lt){D(!0),pt(null);return}mt(1)},"footer:next":()=>{mt(1)},"footer:previous":()=>{mt(-1)},"footer:openSelected":()=>{switch(ct){case`tasks`:D(!0),pt(null);break;case`tmux`:break;case`bridge`:Ie(!0),pt(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{pt(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!ct&&!ae}),Zl((e,t)=>{if(!(Ge||qe||Ye)){if(Nf()===`macos`&&Lw(e)){let t=Iw[e],n=im();kt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(G,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(G,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(G,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(ct&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){zt(f.slice(0,L)+e+f.slice(L)),ue(L+e.length);return}if(L===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),P(!1)),N&&f===``&&(t.backspace||t.delete)&&P(!1),t.escape){if(Se.status===`active`){Xr(me);return}if(te&&ee){ee();return}if(N){P(!1);return}if(ct)return;if(be.some(re)){cn();return}l.length>0&&!f&&!s&&sn()}t.return&&N&&P(!1)}});let bn=Np()?Ap():!1,xn=Np()?De&&(Ip()||bn):!1,Sn=uD(xn??!1),{columns:Cn,rows:wn}=nu(),Tn=Cn-3,Dn=no()?Math.max(fD,Math.floor(wn/2)-dD):void 0,On=(0,Q.useCallback)(e=>{if(!f||j)return;let t=cl.fromText(f,Tn,L),n=t.getViewportStartLine(Dn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});ue(r)},[f,Tn,j,L,Dn]),kn=(0,Q.useCallback)(e=>D(e??!0),[D]),An=nn&&ht?ht:Rt,Mn=(0,Q.useMemo)(()=>f.includes(`
73
+ `),[f]),Nn=(0,Q.useCallback)(e=>{let t=!1;me(n=>(t=Np()&&!Ep(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),We(!1);let n=(De??!1)&&!t,r=`Model set to ${zp(e)}`;Yh(e,n,xp())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),kt({key:`model-switched`,jsx:(0,$.jsx)(G,{children:r}),priority:`immediate`,timeoutMs:3e3}),X(`tengu_model_picker_hotkey`,{model:e})},[me,kt,De]),Pn=(0,Q.useCallback)(()=>{We(!1)},[]),Fn=(0,Q.useMemo)(()=>Ue?(0,$.jsx)(W,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Xh,{initial:we,sessionModel:Te,onSelect:Nn,onCancel:Pn,isStandaloneCommand:!0,showFastModeNotice:Np()&&De&&Ep(we)&&Ip()})}):null,[Ue,we,Te,Nn,Pn]),In=(0,Q.useCallback)(e=>{Qe(!1),e&&kt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(G,{children:e}),priority:`immediate`,timeoutMs:3e3})},[kt]),Ln=(0,Q.useMemo)(()=>Ze?(0,$.jsx)(W,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(dg,{onDone:In,unavailableReason:_p()})}):null,[Ze,In]),Rn=(0,Q.useCallback)(e=>{me(t=>({...t,thinkingEnabled:e})),et(!1),X(`tengu_thinking_toggled_hotkey`,{enabled:e}),kt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(G,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[me,kt]),Bn=(0,Q.useCallback)(()=>{et(!1)},[]),Vn=(0,Q.useMemo)(()=>$e?(0,$.jsx)(W,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Hw,{currentValue:Ee??!0,onSelect:Rn,onCancel:Bn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[$e,Ee,Rn,Bn,l.length]);if(Ag(null),E)return(0,$.jsx)(Hg,{onDone:()=>D(!1),toolUseContext:k(l,[],new AbortController,ie),initialDetailTaskId:typeof E==`string`?E:void 0});if(Fn)return Fn;if(Ln)return Ln;if(Vn)return Vn;if(Fe)return(0,$.jsx)(Vw,{onDone:()=>{Ie(!1),pt(null)}});let Hn={multiline:!0,onSubmit:Xt,onChange:zt,value:je?Wr(typeof je==`string`?je:je.display):f,onHistoryUp:Gt,onHistoryDown:Kt,onHistoryReset:Bt,placeholder:An,onExit:O,onExitMessage:(e,t)=>le({show:e,key:t}),onImagePaste:rn,columns:Tn,maxVisibleLines:Dn,disableCursorMovementForUpDownKeys:Zt.length>0||!!ct,disableEscapeDoublePress:Zt.length>0,cursorOffset:L,onChangeCursorOffset:ue,onPaste:an,onIsPastingChange:Be,focus:!j&&!ae&&!ct,showCursor:!ct&&!j&&!Dt,argumentHint:$t,onUndo:It?()=>{let e=Ft();e&&(fe(e.text),ue(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:Ot,inlineGhostText:en,inputFilter:z},Un=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Ve)return(0,$.jsx)(W,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Un(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(G,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Gn=gg()?(0,$.jsx)(VT,{...Hn,initialMode:w,onModeChange:T}):(0,$.jsx)(Tc,{...Hn});return(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[!no()&&(0,$.jsx)(ZE,{}),F&&(0,$.jsx)(W,{marginTop:1,marginLeft:2,children:(0,$.jsx)(G,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(QE,{hasStash:g!==void 0}),(0,$.jsxs)(W,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Un(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:hD(xn??!1,Sn,bn),children:[(0,$.jsx)(VE,{mode:m,isLoading:s}),(0,$.jsx)(W,{flexGrow:1,flexShrink:1,onClick:On,children:Gn})]}),(0,$.jsx)(RE,{apiKeyStatus:i,debug:e,exitMessage:ce,vimMode:gg()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:oe,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:se,suggestions:Zt,selectedSuggestion:Qt,maxColumnWidth:tn,toolPermissionContext:n,helpOpen:N,suppressHint:f.length>0,isLoading:s,tasksSelected:lt,bridgeSelected:dt,tmuxSelected:ut,ideSelection:t,mcpClients:x,isPasting:ze,isInputWrapped:Mn,messages:l,isSearching:j,historyQuery:ke,setHistoryQuery:Ae,historyFailedMatch:Me,onOpenTasksDialog:no()?kn:void 0}),no()?(0,$.jsx)(W,{position:`absolute`,marginTop:-1,height:+(Zt.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(QS,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:oe,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:se,ideSelection:t,mcpClients:x,isInputWrapped:Mn})}):null]})}function mD(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=hl(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function hD(e,t,n){if(e)return{content:` ${t?`${lg(!0,n)} ${su.dim(`/fast`)}`:lg(!0,n)} `,position:`top`,align:`end`,offset:0}}var gD=Q.memo(pD);Td();function _D(e,t){return{type:`assistant`,uuid:d_(),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 vD(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:dd(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}xd(),Vm(),oe();function yD(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function bD(e){return{type:`stream_event`,event:e.event}}function xD(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 SD(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function CD(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 wD(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 TD(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:Hm(e.compact_metadata)}}function ED(e,t){switch(e.type){case`assistant`:return{type:`message`,message:yD(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:vr({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:bD(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:xD(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:SD(t)};if(t.subtype===`status`){let t=CD(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:TD(e)}:(q(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:wD(e)};case`auth_status`:return q(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return q(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return q(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return q(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return q(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function DD(e){return e.type===`result`}U(),xd(),Kf(),oe();var OD=6e4,kD=18e4;function AD({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Jc(),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 Gm(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;q(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new Xg(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(q(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){q(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;q(`[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(DD(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=ED(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?Zt(l.event,e=>t(t=>[...t,e]),()=>{},s,o):q(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{q(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=em(y.current,e.tool_name)??vD(e.tool_name),o=_D(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)=>{q(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{q(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{q(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{q(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{q(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{q(`[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 q(`[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:kn(r,` `);n&&Um(n,new AbortController().signal).then(e=>{Lm(t,e??Vf(n,75))})}if(!e?.viewerOnly){let e=h.current?kD:OD;m.current=setTimeout((e,t)=>{q(`[useRemoteSession] Response timeout - attempting reconnect`);let n=ur(`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])}xd(),Td(),c();function jD(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var MD=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(`
74
+ `).filter(e=>e.trim());for(let e of t){let t;try{t=hd(e)}catch{continue}if(!jD(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(q(`[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=dd({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=dd({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=dd({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=dd({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}};Kp(),xd();function ND({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,q(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new MD(e,{onMessage:e=>{if(DD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=ED(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{q(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=em(l.current,e.tool_name)??vD(e.tool_name),o=_D(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:()=>{q(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{q(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
75
+ Server disconnected.
76
+ `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,y(1),n(!1)},onError:e=>{q(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{q(`[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])}Kp(),xd(),_c();function PD({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,q(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(DD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=ED(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{q(`[useSSHSession] permission request: ${e.tool_name}`);let a=em(l.current,e.tool_name)??vD(e.tool_name),o=_D(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:()=>{q(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{q(`[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:d_(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{q(`[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}`),y(1,`other`,{finalMessage:a})},onError:e=>{q(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{q(`[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])}Qf();var FD=400;function ID({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=FD}){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=ep(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])}K();var LD=[`0`,`1`,`2`,`3`],RD={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},zD=e=>LD.includes(e),BD=`How is Claude doing this session? (optional)`;function VD({onSelect:e,inputValue:t,setInputValue:n,message:r=BD}){return ID({inputValue:t,setInputValue:n,isValidDigit:zD,onDigit:t=>e(RD[t])}),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(G,{bold:!0,children:r})]}),(0,$.jsxs)(W,{marginLeft:2,children:[(0,$.jsx)(W,{width:10,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(W,{width:10,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(W,{width:10,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(W,{children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Rd(),K(),Qf();function HD({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!zD(i)?null:(0,$.jsx)(GD,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var UD=[`0`,`1`];function WD(e){return UD.includes(e)}function GD({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=ep(r.slice(-1));WD(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(W,{children:[(0,$.jsxs)(G,{color:`ansi:cyan`,children:[Dd,` `]}),(0,$.jsxs)(G,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(W,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(G,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(W,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(W,{width:12,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(W,{width:14,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Y(),U(),oe();function KD(e){let t=H(e=>e.skillImprovement.suggestion),n=Jc(),[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,X(`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`;X(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&Zg(r.skillName,r.updates).then(()=>{e(e=>[...e,ur(`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 qD(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}z(),Ka(),Yo(),di();function JD(e){(0,Q.useEffect)(()=>{let t=()=>{uo()&&process.stdout.write(`
77
+ `+Rt()+`
78
+ `),$n(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function YD(){(0,Q.useEffect)(()=>{},[])}function XD(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])}zu(),h(),ip();function ZD(){let[e,t]=(0,Q.useState)(()=>{if(!dp()||lp())return`valid`;let{key:e,source:t}=pp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!dp()||lp()){t(`valid`);return}await ap(od());let{key:e,source:n}=pp();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 tc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}zu(),K(),cd(),xd(),K(),Qe(),Y(),U();function QD({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=H(e=>e.expandedView),u=Jc(),d=(0,Q.useCallback)(()=>{X(`tengu_toggle_todos`,{is_expanded:l===`tasks`}),u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let s=e!==`transcript`;X(`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,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{X(`tengu_transcript_toggle_show_all`,{is_expanding:!n,message_count:i}),r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{X(`tengu_transcript_exit`,{show_all:n,message_count:i}),t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);Ll(`app:toggleTodos`,d,{context:`Global`}),Ll(`app:toggleTranscript`,f,{context:`Global`}),Ll(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),Ll(`app:redraw`,(0,Q.useCallback)(()=>{Nl.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return Ll(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),Ll(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}ho(),Dt(),Qe();var $D={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function eO({onSubmit:e,isActive:t=!0}){let n=Vl(),r=Ki(),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 Dl((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,$D,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Ao(),Y(),U(),yg(),Ai(),ho(),ti(),Qe(),fe(),Uo();var tO=3e3;function nO(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=_e(),g=Jc(),_=VS().length,{addNotification:v,removeNotification:y}=Yn(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){X(`tengu_cancel`,e),t(()=>[]),n();return}if(Ln()&&s){s();return}X(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=ys(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(gg()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);Ll(`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;mt(e,g);let n=[];for(let[e,r]of t)Mr(e,g),n.push(r.description),lm(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return be({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 Ll(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),Ll(`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<=tO){b.current=0,y(`kill-agents-confirm`),X(`tengu_cancel`,{source:`kill_agents`}),fl(),k();return}b.current=t;let n=pi(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:tO})},[h,v,y,k]),{context:`Chat`}),null}K(),U(),kr();function rO(e){let t=H(e=>e.tasks),n=H(e=>e.pipeIpc),r=Object.values(t).some(Gr),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 Zl((e,t,n)=>{i(new Il(n.keypress))}),{handleKeyDown:i}}xg(),Df();async function iO(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?J(e):J(Error(`Automated permission check failed: ${String(e)}`))}return null}var aO=new Map,oO=null;function sO(){return oO??null}function cO(e,t){let n=sO();if(!n)return null;let r=d_(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return aO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function lO(e){e&&aO.delete(e)}function uO(e,t){if(!e)return;let n=sO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Y(),Tm(),va(),xd(),Bc(),oe(),Ba(),Ga();function dO(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 fO(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){zi({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){X(`tengu_tool_use_cancelled`,{messageID:s,toolName:Em(e.name)})},async persistPermissions(e){return e.length===0?!1:(Nc(e),a(Qo(n.getAppState().toolPermissionContext,e)),e.some(e=>ol(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?wc:sa}${t}`:a?Go:ic,s=a?o:xc(o);return(r||!t&&!i?.length&&!a)&&(q(`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 Zr(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&&(q(`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 pO(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))}}}xd(),K(),va(),xs(),md();function mO(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=dO(t),u,d,f=o?d_():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){uO(h,e),lO(h),h=null}function _(){lO(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||Ji(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 Er(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=cO(v,e=>{l()&&(_(),Ji(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),Ji(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))})()}K(),va(),xs(),xd(),md(),Df(),Vr(),Ga();function hO(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=fO(n,r,i,a,o,t,pO(e));if(!l.resolveIfAborted(c))return(s===void 0?Er(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&cc(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`:zi({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Sg({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)(G,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await iO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;mO({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:void 0},c);return}}).catch(e=>{e instanceof fd||e instanceof vd?(q(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(J(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{Ji(o)})}),[e,t])}mm(),Y(),L(),Qt(),cd(),xd(),_c(),md(),Df(),Uo(),vp();function gO(){Ta(0)}async function _O(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){jt(),await vO({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(hl(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(Ds);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?_O({...e,input:`/exit`}):gO();return}let j=dn(T,k),M=hl(T).filter(e=>k[e.id]?.type===`text`),ee=M.length;if(X(`tengu_paste_text`,{pastedTextCount:ee,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.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&&qr(e)&&(e.name===f||e.aliases?.includes(f)||ft(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){X(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],lo(),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?hr({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&&(q(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),X(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),hr({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}jt(),await vO({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?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 vO(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=lo();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Ls(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await Nn(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 Tp(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await ah({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(Ls(`query_process_user_input_end`),_l()&&(Ls(`query_file_history_snapshot_start`),s.filter(rh).forEach(e=>{dt(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Ls(`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?op(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?hr({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 zo({commands:e,outcome:{type:`failed`,error:k},currentDir:ld(),priority:`later`,workload:D})}catch(e){J(gd(e))}else try{let t=await zo({commands:e,outcome:{type:`completed`},currentDir:ld(),priority:`later`,workload:D});for(let e of t)hr(e)}catch(e){J(gd(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}Uo();function yO(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 bO({executeInput:e}){let t=e=>e.agentId===void 0,n=hn(t);if(!n)return{processed:!1};if(yO(n)||n.mode===`bash`)return e([aa(t)]),{processed:!0};let r=n.mode,i=al(e=>t(e)&&!yO(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Uo();function xO({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Ze,Le);(0,Q.useEffect)(()=>{r||t||i.length!==0&&bO({executeInput:e})},[i,r,e,t,n])}function SO({isLoading:e,onSubmitMessage:t}){let n=ee();(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 CO(e,t){return e&&t&&t.length>0?Ot([...e,...t],`name`):e||[]}function wO(e,t){return(0,Q.useMemo)(()=>CO(e,t),[e,t])}io(),nh(),Nh(),Fs();function TO(e,t){return(0,Q.useMemo)(()=>t.length>0?Ot([...e,...t],`name`):e,[e,t])}L(),Df();function EO(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{N(),t(await Ke(e))}catch(e){e instanceof Error&&J(e)}},[e,t]);(0,Q.useEffect)(()=>xh.subscribe(n),[n])}Df(),Cu(),ml(),wu();var DO=Su(()=>xu({method:vu(`selection_changed`),params:xu({selection:xu({start:xu({line:hu(),character:hu()}),end:xu({line:hu(),character:hu()})}).nullable().optional(),text:mu().optional(),filePath:mu().optional()})}));function OO(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Rn(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(DO(),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){J(e)}}),n.current=!0},[e,t])}vi(),Si(),Ie(),K(),Lg(),U(),Kf();function kO({task:e,selected:t}){let n=Bg(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(W,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(W,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(G,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(G,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(G,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(W,{flexShrink:0,children:(0,$.jsxs)(G,{dimColor:!0,children:[n,` · ↓ `,Hf(r),` tokens`]})})]})}function AO(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 jO(){let e=oC(),t=H(e=>e.viewingAgentTaskId),n=H(e=>e.footerSelection),r=H(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)(W,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(W,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(G,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(G,{dimColor:!0,children:AO(i,s)})]}),e.map(e=>(0,$.jsx)(kO,{task:e,selected:e.agentId===a},e.agentId))]})}uf(),s(),ml();function MO({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(lf().autoConnectIde||e||Dr()||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`}})}se(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}og(),Ic(),K(),Qe(),Bt(),U(),uf(),Bd(),s();function NO({onBackgroundSession:e,isLoading:t}){let n=Jc(),r=_e(),[i,o]=(0,Q.useState)(!1),s=Yl(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Ca(r.getState())?(b(()=>r.getState(),n),lf().hasUsedBackgroundTask||ff(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=H(Ca),u=a(`false`);Ll(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=Ps(`task:background`,`Task`,`ctrl+b`),f=Ad.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(W,{paddingLeft:2,children:(0,$.jsx)(G,{dimColor:!0,children:(0,$.jsx)(wl,{shortcut:f,action:`background`})})})}U();function PO({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=H(e=>e.foregroundedTaskId),o=H(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Jc(),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}}hi(),K(),ip(),uf(),gc(),pg();function FO({onDone:e}){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useCallback)(()=>{t.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{ff(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);let r=(0,Q.useCallback)(e=>{t.current(e)},[]);return(0,$.jsx)(hg,{title:`Remote Control`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(W,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(G,{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)(G,{children:` `}),(0,$.jsx)(G,{children:`You can disconnect remote access anytime by running /remote-control again.`})]}),(0,$.jsx)(W,{children:(0,$.jsx)(wa,{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})})]})})}$m();function IO(e,t){return t}Ec(),zu(),oe(),Di(),K(),Qe(),h(),ip(),Be(),xd(),Bd(),vf(),Df(),ve(),Td(),Vi(),Ye(),ga();function LO(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(),ip(),xd(),md(),kp(),oe(),ve(),Td();async function RO(e,t,n){try{q(`Collecting transcript for sharing`,{level:`info`});let r=mi(e),i=await de(S(e)),a;try{let e=Hc(),{size:t}=await m_(e);t<=52428800?a=await f_(e,`utf-8`):q(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=LO(dd({trigger:t,version:`0.0.11`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await Op();let s=tp();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Fp(),...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 q(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return q(pd(e),{level:`error`}),{success:!1}}}function zO({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)(d_()),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=d_(),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])}}Y(),uf(),s(),oe(),vp(),Gd();var BO={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},VO={probability:0};function HO(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=wo(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=IO(`tengu_feedback_survey_config`,BO),u=IO(`tengu_bad_survey_transcript_ask_config`,VO),d=IO(`tengu_good_survey_transcript_ask_config`,VO),f=Yd().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}),lf().feedbackSurveyState?.lastShownTime!==e&&ff(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),Am(`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`||lf().transcriptShareDismissed||!Pa(`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`;X(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),Am(`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(X(`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`&&ff(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await RO(g.current,i,e);return X(`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}=zO({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Lp(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||zm()||!Pa(`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=lf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Rm(),Y(),uf(),s(),oe(),Nm();var UO=3e3,WO=`tengu_memory_survey_event`,GO=`memory_survey`;function KO(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}=zO({hideThanksAfterMs:UO,onOpen:(0,Q.useCallback)(e=>{X(WO,{event_type:`appeared`,appearance_id:e}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(WO,{event_type:`responded`,appearance_id:e,response:t}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!1,[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{X(WO,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:GO}),Am(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(X(WO,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:GO}),t===`dont_ask_again`&&ff(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await RO(o.current,GO,e);return X(WO,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:GO}),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)(()=>wo(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Rm(),Y(),s(),oe(),Nm();var qO=3e3,JO=.2;function YO(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 XO(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}=zO({hideThanksAfterMs:qO,onOpen:(0,Q.useCallback)(e=>{X(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:ji()}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:ji()}),Am(`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=>Fr(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||zm()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&YO(e,c.current)){c.current=null,Math.random()<JO&&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}}Rd(),K();var ZO=[`1`,`2`,`3`],QO={1:`yes`,2:`no`,3:`dont_ask_again`},$O=e=>ZO.includes(e);function ek({onSelect:e,inputValue:t,setInputValue:n}){return ID({inputValue:t,setInputValue:n,isValidDigit:$O,onDigit:t=>e(QO[t])}),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(W,{children:[(0,$.jsxs)(G,{color:`ansi:cyan`,children:[Dd,` `]}),(0,$.jsx)(G,{bold:!0,children:`Can we look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(W,{marginLeft:2,children:(0,$.jsx)(G,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(W,{marginLeft:2,children:[(0,$.jsx)(W,{width:10,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(W,{width:10,children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(W,{children:(0,$.jsxs)(G,{children:[(0,$.jsx)(G,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Y(),K();function tk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(rk,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(W,{marginTop:1,children:(0,$.jsxs)(G,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(W,{marginTop:1,children:(0,$.jsxs)(G,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(ek,{onSelect:r,inputValue:i,setInputValue:a}):i&&!zD(i)?null:(0,$.jsx)(VD,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var nk=e=>e===`1`;function rk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return ID({inputValue:t,setInputValue:n,isValidDigit:nk,enabled:!!i,once:!0,onDigit:()=>{X(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(W,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(G,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(G,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(G,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(G,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(G,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}Jm(),Zm(),zu(),Ai(),Df();function ik(e){let{addNotification:t}=Yn(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{Eu()||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(J))},[t])}function ak(){ik(async()=>(await Xm()).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`}}))}uf(),_d(),xd(),oe(),vp(),Vi(),h(),K(),oe();function ok(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=Ul();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{Ul()},[n,!1])}Y(),uf(),xd(),s(),md(),Df();function sk(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var ck={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function lk(e){let t=ck.INITIAL_DELAY_MS*ck.BACKOFF_MULTIPLIER**e;return Math.min(t,ck.MAX_DELAY_MS)}function uk(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>=ck.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function dk(){let e=lf();if(!uk(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return q(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(sk())return q(`Official marketplace auto-install disabled via env var, skipping`),ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await ue())[`claude-plugins-official`])return q(`Official marketplace '${Ks}' already installed, skipping`),ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!xo(fo))return q(`Official marketplace blocked by enterprise policy, skipping`),ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=rn(),n=a_(t,Ks);if(await xi(n,t)!==null){let e=await ue();return e[Ks]={source:fo,installLocation:n,lastUpdated:new Date().toISOString()},await qt(e),ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await Pi()){q(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+lk(t),i=!1;try{ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,J(gd(e)),q(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}q(`Attempting to auto-install official marketplace`),await Sn(fo),q(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`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 D(),q(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};q(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),J(gd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+lk(r),o=!1;try{ff(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,J(gd(e)),q(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}K(),xd();function fk(){ik(async()=>{let e=await dk(),t=[];return e.configSaveFailed&&(q(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(G,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(q(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(G,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(q(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(G,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Gd(),Y();function pk(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:Kg(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function mk(e){if(Wd().spinnerTipsEnabled===!1)return;let t=await Jg(e);if(t.length!==0)return pk(t)}function hk(e){Gg(e.id),X(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}md(),Df(),zu(),U(),me();var gk=!1;async function _k(e,t,n){{if(gk)return;gk=!0;let{updateContext:r,notification:i}=await Re(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 vk(){gk=!1}function yk(){let e=H(e=>e.mainLoopModel),t=H(e=>e.mainLoopModelForSession),n=H(e=>e.fastMode),r=Jc(),i=_e(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{Eu()||(a.current?a.current=!1:vk(),_k(i.getState().toolPermissionContext,r,n).catch(e=>{J(Error(`Auto mode gate check failed`,{cause:gd(e)}))}))},[e,t,n])}nt();function bk(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!_l()||r.current||(r.current=!0,e&&Ar(e,n))},[t,e,n])}K(),tr(),gc(),pg();function xk({hostPattern:{host:e},onUserResponse:t}){function n(e){switch(e){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`},...Pr()?[]:[{label:(0,$.jsxs)(G,{children:[`Yes, and don't ask again for `,(0,$.jsx)(G,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(G,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(G,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(hg,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(G,{children:[` `,e]})]}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(W,{children:(0,$.jsx)(wa,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}K(),tr(),Pf();function Sk(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function Ck(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Ve.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Ve.isSandboxingEnabled()||Nf()===`linux`||n===0?null:(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(W,{marginLeft:0,children:(0,$.jsxs)(G,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(W,{paddingLeft:2,children:(0,$.jsxs)(G,{dimColor:!0,children:[Sk(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(W,{paddingLeft:2,children:(0,$.jsxs)(G,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}rg(),Ai(),zu(),K();var wk=[];function Tk({mcpClients:e=wk}){let{addNotification:t}=Yn();(0,Q.useEffect)(()=>{if(Eu())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`&&ea(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`&&ea(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)(G,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}K(),Gd(),T();var Ek=`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.`;cu(),zu(),Ai(),K(),U(),xd(),s();var Dk=5e3;function Ok(){let{addNotification:e}=Yn(),t=Jc(),[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),q(`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)(G,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Eu()||Iu())return;let e=xt();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=tn();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);Gl(s,n?Dk:null),Q.useEffect(()=>{Eu()||!n||s()},[s,n])}xd();var kk=new Map;async function Ak(e){if(!e||!e.trim())return q(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=kk.get(t);if(n!==void 0)return q(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await jf(t).catch(()=>null)&&(r=!0),kk.set(t,r),q(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}uf(),xd(),xl();var jk=5;function Mk(e){return Ud.has(e.toLowerCase())}function Nk(e){if(!e)return null;if(typeof e==`string`)return q(`[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=Fk(t);if(e)return e}return null}return Fk(e)}function Pk(e){return typeof e==`object`&&!!e}function Fk(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!Pk(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(Pk(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function Ik(){let e=new Map;try{let t=await ue();for(let n of Object.keys(t))try{let t=await Tt(n),r=Mk(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=Nk(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){q(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){q(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function Lk(e){if(Bk())return q(`[lspRecommendation] Recommendations are disabled`),[];let t=i_(e).toLowerCase();if(!t)return q(`[lspRecommendation] No file extension found`),[];q(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await Ik(),r=lf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){q(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Pn(e)){q(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await Ak(e.command)?(a.push({info:e,pluginId:t}),q(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):q(`[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 Rk(e){ff(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),q(`[lspRecommendation] Added ${e} to never suggest`)}function zk(){ff(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),q(`[lspRecommendation] Incremented ignored count`)}function Bk(){let e=lf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=jk}u(),zu(),K(),Df(),xl();function Vk(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{Eu()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(J).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function Hk(e,t,n,r,i){try{let a=await or(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(G,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){J(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(G,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}zu(),Ai(),U(),uf(),xd(),Df(),Gd();var Uk=28e3;function Wk(){let e=H(e=>e.fileHistory.trackedFiles),{addNotification:t}=Yn(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=Vk();return Q.useEffect(()=>{a(async()=>{if(Lu())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 Lk(e))[0];if(t)return q(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ju(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:i_(e),shownAt:Date.now()}}catch(e){J(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(q(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:Hk(n,a,`lsp-plugin`,t,async e=>{q(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?a_(e.marketplaceInstallLocation,e.entry.source):void 0;await ao(n,e.entry,`user`,void 0,t),nf(`userSettings`,{enabledPlugins:{...Vd(`userSettings`)?.enabledPlugins,[n]:!0}}),q(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=Uk&&(q(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),zk());break}case`never`:Rk(n);break;case`disable`:ff(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}K(),gc(),pg();var Gk=3e4;function Kk({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`),Gk,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)(hg,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsx)(G,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(G,{children:[` `,e]})]}),t&&(0,$.jsx)(W,{children:(0,$.jsx)(G,{dimColor:!0,children:t})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(G,{children:[` `,n,` files`]})]}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(W,{children:(0,$.jsx)(wa,{options:[{label:(0,$.jsxs)(G,{children:[`Yes, install `,(0,$.jsx)(G,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(G,{children:[`Never for `,(0,$.jsx)(G,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Ai(),Y(),xd(),Bi();function qk(){let e=Q.useSyncExternalStore(ii,Bs),{addNotification:t}=Yn(),{recommendation:n,clearRecommendation:r,tryResolve:i}=Vk();return Q.useEffect(()=>{e&&i(async()=>{let t=await Bn(e);return t&&(q(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),_i()),Bs()===e&&Wt(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(yn(n.pluginId),X(`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;Hk(e,r,`hint-plugin`,t,async t=>{let n=await Vc({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`:Do();break;case`no`:break}r()}},[n,t,r])}}K(),gc(),pg();var Jk=3e4;function Yk({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`),Jk,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)(hg,{title:`Plugin Recommendation`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsxs)(G,{dimColor:!0,children:[`The `,(0,$.jsx)(G,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(G,{children:[` `,e]})]}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(G,{children:[` `,n]})]}),t&&(0,$.jsx)(W,{children:(0,$.jsx)(G,{dimColor:!0,children:t})}),(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{children:`Would you like to install it?`})}),(0,$.jsx)(W,{children:(0,$.jsx)(wa,{options:[{label:(0,$.jsxs)(G,{children:[`Yes, install `,(0,$.jsx)(G,{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`)})})]})})}gc(),pg();var Xk=3e4;function Zk({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(),Xk,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)(hg,{title:`Tool Recommendation`,children:(0,$.jsx)(wa,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}Ne();var Qk=.15,$k=3;function eA(){let e=Q.useSyncExternalStore(Ce,yr),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)>=Qk,handleSelect:Q.useCallback(e=>{Gc()},[]),handleDismiss:Q.useCallback(()=>{Gc()},[])}}zu(),cd(),xd(),yf(),tf();var tA=`1.1.2396`;function nA(){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 rA(e){let t=nA()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,ld()),n.toString()}async function iA(){if(nA())return!0;let e=process.platform;if(e===`darwin`)return qd(`/Applications/Claude.app`);if(e===`linux`){let{code:e,stdout:t}=await bf(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await bf(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function aA(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await bf(`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=a_(e,`AnthropicClaude`);try{let e=(await p_(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,Jv.coerce)(e)!==null).sort((e,t)=>{let n=(0,Jv.coerce)(e),r=(0,Jv.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function oA(){if(!await iA())return{status:`not-installed`};let e;try{e=await aA()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,Jv.coerce)(e);return!t||!gm(t.version,tA)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function sA(e){let t=process.platform;if(q(`Opening deep link: ${e}`),t===`darwin`){if(nA()){let{code:t}=await bf(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await bf(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await bf(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await bf(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function cA(){let e=ed();if(!await iA())return{success:!1,error:`Claude Desktop is not installed. Install it from https://claude.ai/download`};let t=rA(e);return await sA(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Claude Desktop. Please try opening it manually.`,deepLinkUrl:t}}K(),Be(),md(),_c(),ve();var lA=`https://clau.de/desktop`;function uA(){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 dA({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return Zl(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?(vt(uA()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${lA}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${lA}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await oA();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 hs(),n(`opening`);let r=await cA();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 y(0,`other`)},500,e)}t().catch(e=>{i(pd(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(G,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(G,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(G,{children:a}),(0,$.jsx)(G,{children:`Download now? (y/n)`})]}):(0,$.jsx)(ru,{message:{checking:`Checking for Claude Desktop…`,flushing:`Saving session…`,opening:`Opening Claude Desktop…`,success:`Opening in Claude Desktop…`}[t]})}K(),Y(),uf(),gc(),pg();var fA={enable_shortcut_tip:!1,enable_startup_dialog:!1};function pA(){return fA}function mA(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function hA(){if(!mA()||!pA().enable_startup_dialog)return!1;let e=lf();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function gA({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(lf().desktopUpsellSeenCount??0)+1;ff(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),X(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(dA,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:ff(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(hg,{title:`Try Claude Code Desktop`,children:(0,$.jsxs)(W,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(W,{marginBottom:1,children:(0,$.jsx)(G,{children:`Same Claude Code with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(wa,{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`)})]})})}zu(),Ai(),K(),U(),xd(),Qf();function _A(){let{addNotification:e}=Yn(),t=H(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(!Eu()){if(!t){q(`No installation status to monitor`);return}n!==0&&(q(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(q(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{color:`error`,children:[n,` `,Zf(n,`plugin`),` failed to install`]}),(0,$.jsx)(G,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}zu(),Ai(),K(),xd(),Cg();function vA(){let{addNotification:e}=Yn(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!Eu())return wg(e=>{q(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(Eu()||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)(G,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(G,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),q(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}xd(),Df(),xl(),Th(),Y();function yA(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 bA(e){q(`performBackgroundPluginInstallations called`);try{let t=Ch(Je(),await ue().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;q(`Installing ${n.length} marketplace(s) in background`);let r=await Sh({onProgress:t=>{switch(t.type){case`installing`:yA(e,t.name,`installing`);break;case`installed`:yA(e,t.name,`installed`);break;case`failed`:yA(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(X(`tengu_marketplace_background_install`,i),gf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Un(),q(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await wh(e)}catch(t){J(t),q(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),uc(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Un(),uc(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){J(e)}}uf(),xd(),xl(),ba();async function xA(e){if(q(`performStartupChecks called`),!df()){q(`Trust not accepted for current directory - skipping plugin installations`);return}try{q(`Starting background plugin installations`),await Yr()&&(Un(),uc(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await bA(e)}catch(e){q(`Error initiating background plugin installations: ${e}`)}}K();var SA=/https?:\/\/\S+/;function CA(){let[e,t]=(0,Q.useState)(yp.getInstance().getStatus());return(0,Q.useEffect)(()=>yp.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(W,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(G,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(W,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(SA);if(!n)return(0,$.jsx)(G,{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)(G,{dimColor:!0,children:[a,(0,$.jsx)(jl,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(W,{marginTop:1,children:(0,$.jsx)(G,{color:`error`,children:e.error})})]})}Ai(),K(),Zo(),ip(),Ya(),zu();function wA(e){let{addNotification:t}=Yn(),n=KS(),r=(0,Q.useMemo)(()=>Sa(n,e),[n,e]),i=(0,Q.useMemo)(()=>za(n),[n]),a=(0,Q.useRef)(null),o=cp(),s=os(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{Eu()||(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)(()=>{Eu()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(G,{children:(0,$.jsx)(G,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Ai(),zu();function TA(e){let{addNotification:t}=Yn(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(Eu())return;let r=qg(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 EA=``;function DA(){ik(async()=>qf()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await Ym()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:EA,color:`warning`,priority:`high`})}Ai(),K(),uf(),ml(),zu();var OA=5;function kA({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Yn(),{status:a,ideName:o}=GS(t),s=(0,Q.useRef)(!1),c=n?lt(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(Eu())return;if(Dr()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(lf().ideHintShownCount??0)>=OA)return;let e=setTimeout((e,t)=>{un(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,ff(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(G,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(G,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!Eu()){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(!Eu()){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(!Eu()){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])}uf();var AA=[e=>{if(MA(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(MA(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 jA(){ik(()=>{let e=lf(),t=[];for(let n of AA){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function MA(e){return e!==void 0&&Date.now()-e<3e3}ip(),K(),Y(),uf();var NA=3;function PA(){ik(async()=>{if((lf().subscriptionNoticeCount??0)>=NA)return null;let e=await FA();return e===null?null:(ff(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),X(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(G,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`]}),priority:`low`})})}async function FA(){if(lp())return null;let e=await up();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Ai(),U(),Cp(),Kf(),zu();var IA=`fast-mode-cooldown-started`,LA=`fast-mode-cooldown-expired`,RA=`fast-mode-org-changed`,zA=`fast-mode-overage-rejected`;function BA(){let{addNotification:e}=Yn(),t=H(e=>e.fastMode),n=Jc();(0,Q.useEffect)(()=>{if(!Eu()&&Np())return Sp(r=>{r?e({key:RA,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:RA,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!Eu()&&Np())return Pp(t=>{n(e=>({...e,fastMode:!1})),e({key:zA,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(Eu()||!t)return;let n=jp((t,n)=>{let r=VA(n,Wf(t-Date.now(),{hideTrailingZeros:!0}));e({key:IA,invalidates:[LA],text:r,color:`warning`,priority:`immediate`})}),r=bp(()=>{e({key:LA,invalidates:[IA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function VA(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}`}}K(),Qe();function HA({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return Ll(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(W,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(W,{children:(0,$.jsx)(G,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(W,{children:(0,$.jsxs)(G,{dimColor:!0,children:[`Press `,(0,$.jsx)(wl,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(W,{children:(0,$.jsxs)(G,{dimColor:!0,children:[`Reason: `,n]})})]})}function UA(e){switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function WA(e){return`/issue`}function GA(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`}}function KA(){return null}function qA(e,t){return!1}Dg(),K(),uf(),st();function JA(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||!(lf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function YA(e){let[t]=Ol();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Qr(t).selectionBg)},[e,t])}Ai(),K(),Qe(),xd();var XA=40,ZA=.3,QA=6,$A=200,ej=15,tj=15,nj=3,rj=1500,ij=150,aj=5,oj=5,sj=80,cj=3,lj=6,uj=500;function dj(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 fj(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 pj(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>rj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>$A)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<oj)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/ij),n=Math.max(tj,e.base*2),i=1+(e.mult-1)*t+ej*t;return e.mult=Math.min(n,i,e.mult+nj),Math.floor(e.mult)}if(r>XA)e.mult=e.base;else{let t=Math.max(QA,e.base*2);e.mult=Math.min(t,e.mult+ZA)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<oj)return 1;if(!i||r>uj)e.mult=2,e.frac=0;else{let t=.5**(r/ij);e.mult=Math.min(r>=sj?cj:lj,1+(e.mult-1)*t+aj*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function mj(){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 hj(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function gj(){let e=Ql(),t=mj();return q(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),hj(e,t)}var _j=2,vj=50,yj=200;function bj({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=tu(),{addNotification:a}=Yn(),o=(0,Q.useRef)(null);function s(e){let t=eu(),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 Dl({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(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=Cj(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=gj()),Tj(t,pj(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=gj());let r=wj(t,pj(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}),Dl({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(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=Cj(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=Cj(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=Cj(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),Zl((t,r,i)=>{let a=e.current;if(!a)return;let o=Dj(a,Ej(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),Zl((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=fj(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}dj(t)&&i.clearSelection()},{isActive:t}),xj(e,i,t,n),JA(i,t,s),YA(i),null}function xj(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>yj){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(_j,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(_j,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(_j)}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,vj)))}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=Sj(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 Sj(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 Cj(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 wj(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 Tj(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function Ej(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 Dj(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),Cj(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),Cj(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),Cj(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 Oj=r({useProactive:()=>kj});function kj(e){let t=(0,Aj.useRef)(e);t.current=e,(0,Aj.useEffect)(()=>{if(!ym())return;let e=null,n=!1,r=!1;function i(){cm(Date.now()+jj),e=setTimeout(()=>{if(e=null,!om()){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 Oo({basePrompt:`<${Sf}>${new Date().toLocaleTimeString()}</${Sf}>`,currentDir:ld(),shouldCreate:()=>!n});if(n){await De({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await De({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>q(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},jj)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),cm(null)}},[ym(),fm(),_m()])}var Aj,jj,Mj=t((()=>{Aj=n(Xl(),1),Of(),cd(),P(),xd(),jj=3e4}));function Nj(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 Pj(e){let t=ss(e),n=Nj(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
79
+ You have an active goal to work on. Continue making progress.
80
+
81
+ ## Active Goal
82
+ ${e.objective}
83
+
84
+ ## Status
85
+ - Elapsed active time: ${t}
86
+ - ${n}
87
+ - ${r}
88
+
89
+ ## Instructions
90
+
91
+ 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.
92
+
93
+ When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
94
+
95
+ ### Completion Audit
96
+ 1. Derive concrete requirements from the objective and any referenced files.
97
+ 2. Preserve the original scope — do not redefine success around what is already done.
98
+ 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
99
+ 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
100
+ 5. Treat uncertain or indirect evidence as "not achieved".
101
+ 6. The audit must PROVE completion, not merely fail to find remaining work.
102
+
103
+ ### Blocked Audit
104
+ If you encounter an obstacle you genuinely cannot overcome:
105
+ - Do NOT mark blocked on the first encounter.
106
+ - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
107
+ - "Difficult", "slow", or "partially incomplete" is NOT blocked.
108
+ - If blocked, use the GoalTool with status "blocked" and a clear reason.
109
+
110
+ Resume working now.
111
+ </goal-steering>`}function Fj(e){return`<goal-steering type="budget_limit">
112
+ ## Token Budget Reached
113
+
114
+ Your token budget for this goal has been exhausted.
115
+
116
+ - Goal: ${e.objective}
117
+ - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
118
+ - Active time: ${ss(e)}
119
+
120
+ **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
121
+
122
+ Instead, provide a brief summary:
123
+ 1. What has been accomplished so far.
124
+ 2. What remains to be done.
125
+ 3. Any blockers or issues encountered.
126
+
127
+ 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.
128
+ </goal-steering>`}var Ij=t((()=>{})),Lj=r({useGoalContinuation:()=>zj});function Rj(e){q(`[goal] hook: ${e}`)}function zj(e){let t=(0,Bj.useRef)(e);t.current=e;let n=(0,Bj.useRef)(!1),r=(0,Bj.useRef)(!1);(0,Bj.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){Rj(`skip: queryActiveNow=true`);return}if(e.wasAborted){Rj(`skip: wasAborted=true`);return}if(n.current)return;if(Le().length>0){Rj(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){Rj(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){Rj(`skip: planMode`);return}let t=mo();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=Fj(t);q(`[goal] hook: budget limit reached, injecting wrap-up prompt`),hr({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){Rj(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){ca()&&(zc(),e.onMaxTurnsReached?.()),q(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=vs();zc();let a=Pj(t);q(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),hr({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 Bj,Vj=t((()=>{Bj=n(Xl(),1),xd(),ac(),Ij(),Uo()}));zu(),Io(),Fd(),u(),K(),Di(),Ph(),Ai(),xd(),s(),Kf(),P(),fe(),L(),oh(),di(),Qt(),et(),Bt(),ti(),md(),Df(),cd(),Ba(),me(),va(),uf(),Ya(),Y(),oe(),Wm(),Of(),_c(),$e(),jg(),Xt(),Bc(),Vh(),U(),cn(),ve(),nt(),ml(),Sr(),Uo(),Yt(),Ja(),tr(),ts();var Hj=(um(),e(vm)),Uj=e=>()=>{},Wj=()=>!1,Gj=()=>null,Kj=(e,t)=>!1,qj=(Mj(),e(Oj)).useProactive,Jj=(Vj(),e(Lj)).useGoalContinuation,Yj=[],Xj=3e3;function Zj({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=Ps(`app:toggleTranscript`,`Global`,`ctrl+o`),o=Ps(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(W,{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)(G,{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)(W,{flexGrow:1}),(0,$.jsxs)(G,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(W,{flexGrow:1}),(0,$.jsxs)(G,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function Qj({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Qh({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)(W,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(G,{children:`/`}),(0,$.jsx)(G,{children:s.slice(0,f)}),(0,$.jsx)(G,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(G,{children:s.slice(f+1)}),(0,$.jsx)(W,{flexGrow:1}),l===`building`?(0,$.jsx)(G,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(G,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(G,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(G,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var $j=[`⠂`,`⠐`],eM=`✳`,tM=960;function nM({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=Rl(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%$j.length),tM,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?$j[a]??eM:eM;return Bl(n?null:r?t:`${s} ${t}`),null}var rM=`<${Ef}>`;function iM(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(rM)}function aM({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:v,onTurnComplete:y,disabled:b=!1,mainThreadAgentDefinition:x,disableSlashCommands:S=!1,taskListId:C,remoteSessionConfig:w,directConnectConfig:T,sshSession:E,thinkingConfig:D}){let O=!!w,ee=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),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)(()=>(q(`[REPL:mount] REPL mounted, disabled=${b}`),()=>q(`[REPL:unmount] REPL unmounting`)),[b]);let[N,P]=(0,Q.useState)(x),F=H(e=>e.toolPermissionContext),I=H(e=>e.verbose),re=H(e=>e.mcp),ie=H(e=>e.plugins),oe=H(e=>e.agentDefinitions),se=H(e=>e.fileHistory),le=H(e=>e.initialMessage),L=VS(),ue=H(e=>e.spinnerTip),de=H(e=>e.expandedView)===`tasks`,fe=H(e=>e.tasks),pe=H(e=>e.elicitation),me=H(e=>e.viewingAgentTaskId),R=Jc(),ve=me?fe[me]:void 0,ye=zr(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!me||!ye)return;let e=me;$s(_s(e)).then(t=>{R(n=>{let r=n.tasks[e];if(!zr(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}}}})})},[me,ye,R]);let be=_e(),Se=Ml(),Ce=Bh(),[we,Te]=(0,Q.useState)(t);EO(O?void 0:qu(),Te);let De=Q.useSyncExternalStore(Hj?.subscribeToProactiveChanges??Uj,Hj?.isProactiveActive??Wj),Ae=Q.useSyncExternalStore(Hj?.subscribeToProactiveChanges??Uj,Hj?.getNextTickAt??Gj),Me=(0,Q.useMemo)(()=>Da(F),[F,De]);yk();let[Ne,Pe]=(0,Q.useState)(f),Ie=(0,Q.useCallback)(e=>{Pe(e)},[Pe]),[Le,Re]=(0,Q.useState)(`prompt`),[ze,Be]=(0,Q.useState)(!1),[He,Ue]=(0,Q.useState)(!1),[We,Ge]=(0,Q.useState)(``),Ke=(0,Q.useRef)(0),qe=(0,Q.useRef)(void 0),Je=(0,Q.useRef)(!1),{addNotification:Ye,removeNotification:Ze}=Yn(),Qe=Kj,$e=wO(d,re.clients),[et,tt]=(0,Q.useState)(void 0),[nt,it]=(0,Q.useState)(null),[at,st]=(0,Q.useState)(null),[ct,lt]=(0,Q.useState)(!1),ut=H(e=>e.showRemoteCallout),[pt,mt]=(0,Q.useState)(()=>hA());jA(),PA(),kA({ideSelection:et,mcpClients:$e,ideInstallationStatus:at}),Tk({mcpClients:$e}),_A(),vA(),ng(),wA(Ce),BA(),TA(Ce),DA(),ak(),fk(),Ok();let{recommendation:ht,handleResponse:gt}=Wk(),{recommendation:_t,handleResponse:vt}=qk(),bt=eA(),xt=(0,Q.useMemo)(()=>[...Me,...r],[Me,r]);Qm({enabled:!O});let St=Lt();(0,Q.useEffect)(()=>{O||xA(R)},[R,O]);let Ct=Mh(xt,re.tools,F),{tools:wt,allowedAgentTypes:Tt}=(0,Q.useMemo)(()=>{if(!N)return{tools:Ct,allowedAgentTypes:void 0};let e=si(N,Ct,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[N,Ct]),Et=TO(TO(we,ie.commands),re.commands),Dt=(0,Q.useMemo)(()=>S?[]:Et,[S,Et]);Ty(O?Yj:re.clients),OO(O?Yj:re.clients,tt);let[Ot,kt]=(0,Q.useState)(`responding`),jt=(0,Q.useRef)(Ot);jt.current=Ot;let[Mt,Nt]=(0,Q.useState)([]),[Ft,Rt]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Ft&&!Ft.isStreaming&&Ft.streamingEndedAt){let e=3e4-(Date.now()-Ft.streamingEndedAt);if(e>0){let t=setTimeout(Rt,e,null);return()=>clearTimeout(t)}else Rt(null)}},[Ft]);let[zt,Bt]=(0,Q.useState)(null),Ut=(0,Q.useRef)(null);Ut.current=zt;let Wt=(0,Q.useRef)(0),[Gt,Kt]=(0,Q.useState)(!1),qt=(0,Q.useRef)(()=>{}),Yt=(0,Q.useRef)(()=>{}),Xt=(0,Q.useRef)(null),Qt=(0,Q.useRef)(null),$t=(0,Q.useRef)(0),tn=Q.useRef(new xy).current,nn=Q.useSyncExternalStore(tn.subscribe,tn.getSnapshot),[rn,an]=Q.useState(w?.hasInitialPrompt??!1),z=nn||rn,[sn,cn]=Q.useState(void 0),un=Q.useRef(0),fn=Q.useRef(!1),pn=Q.useRef(0),mn=Q.useRef(0),hn=Q.useRef(null),gn=Q.useCallback(()=>{pn.current=Date.now(),mn.current=0,hn.current=null},[]),vn=Q.useRef(!1);nn&&!vn.current&&gn(),vn.current=nn;let yn=Q.useCallback(e=>{an(e),e&&gn()},[gn]),bn=Q.useRef(void 0),[xn,Sn]=Q.useState(!1),[Cn,Tn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Cn?.notifications&&Cn.notifications.forEach(e=>{Ye({key:`auto-updater-notification`,text:e,priority:`low`})})},[Cn,Ye]),(0,Q.useEffect)(()=>{no()&&Li().then(e=>{e&&Ye({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Dn,On]=(0,Q.useState)(null),kn=(0,Q.useRef)(null),jn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;kn.current={...n,isLocalJSXCommand:!0},On(n);return}if(kn.current){if(e?.clearLocalJSX){kn.current=null,On(null),Wt.current=Date.now();return}return}if(e?.clearLocalJSX){On(null);return}On(e)},[]),[Mn,Pn]=(0,Q.useState)([]),[In,Ln]=(0,Q.useState)(null),[zn,Bn]=(0,Q.useState)([]),[Vn,Hn]=(0,Q.useState)([]),Un=(0,Q.useRef)(new Map),Wn=H(e=>e.settings.terminalTitleFromRename)===!1?void 0:ws(ed()),[Gn,Kn]=(0,Q.useState)(),Jn=(0,Q.useRef)((i?.length??0)>0),Xn=N?.agentType,Zn=Wn??Xn??Gn??`Work Mate`,Qn=Mn.length>0||Vn.length>0,tr=Dn?.isLocalJSXCommand===!0&&Dn?.jsx!=null,nr=z&&!Qn&&!tr;(0,Q.useEffect)(()=>{if(z&&!Qn&&!tr)return my(),()=>hy()},[z,Qn,tr]);let rr=Qn||tr?`waiting`:z?`busy`:`idle`,ir=rr===`waiting`?Mn.length>0?`approve ${Mn[0].tool.name}`:tr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{nl({status:rr,waitingFor:ir})},[rr,ir]),Hl(null);let[B,ar]=(0,Q.useState)(i??[]),or=(0,Q.useRef)(B),sr=(0,Q.useRef)(!1),V=(0,Q.useCallback)(e=>{let t=or.current,n=typeof e==`function`?e(or.current):e;if(or.current=n,n.length<un.current)un.current=0;else if(n.length>t.length&&fn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(wn)?fn.current=!1:un.current=n.length}ar(n)},[]),cr=(0,Q.useCallback)(e=>{e===void 0?fn.current=!1:(un.current=or.current.length,fn.current=!0),cn(e)},[]),{dividerIndex:lr,dividerYRef:dr,onScrollAway:fr,onRepin:pr,jumpToNew:gr,shiftDivider:_r}=Mg(B.length);ok(B,V,z);let[yr,br]=(0,Q.useState)(null),xr=(0,Q.useRef)(null),Sr=(0,Q.useMemo)(()=>kg(B,lr),[lr,B.length]),wr=(0,Q.useCallback)(()=>{Xt.current?.scrollToBottom(),pr(),br(null)},[pr,br]),Er=B.at(-1),Dr=Er!=null&&wn(Er);(0,Q.useEffect)(()=>{Dr&&wr()},[Dr,Er,wr]);let Or=(0,Q.useCallback)((e,t)=>{$t.current=Date.now(),e?pr():fr(t)},[pr,fr,R]),kr=XD(o,V),Ar=(0,Q.useDeferredValue)(Q.useMemo(()=>B.length>500?B.slice(-500):B,[B])),jr=B.length-Ar.length;jr>0&&q(`[useDeferredValue] Messages deferred by ${jr} (${Ar.length}→${B.length})`);let[Mr,Nr]=(0,Q.useState)(null),[Pr,Ir]=(0,Q.useState)(()=>Wg()),Br=(0,Q.useRef)(Pr);Br.current=Pr;let Vr=(0,Q.useRef)(null),Ur=(0,Q.useCallback)(e=>{Qe(Br.current,e)||(Br.current===``&&e!==``&&Date.now()-$t.current>=Xj&&wr(),Br.current=e,Ir(e),Sn(e.trim().length>0))},[Sn,wr,Qe]);(0,Q.useEffect)(()=>{if(Pr.trim().length===0)return;let e=setTimeout(Sn,1500,!1);return()=>clearTimeout(e)},[Pr]);let[Wr,Gr]=(0,Q.useState)(`prompt`),[Jr,Yr]=(0,Q.useState)(),Xr=(0,Q.useCallback)(e=>{let t=new Set(e);Te(e=>e.filter(e=>t.has(e.name)||Ee.has(e)))},[Te]),[Zr,Qr]=(0,Q.useState)(new Set),$r=(0,Q.useRef)(!1),ei=AD({config:w,setMessages:V,setIsLoading:yn,onInit:Xr,setToolUseConfirmQueue:Pn,tools:xt,setStreamingToolUses:Nt,setStreamMode:kt,setInProgressToolUseIDs:Qr}),ti=ND({config:T,setMessages:V,setIsLoading:yn,setToolUseConfirmQueue:Pn,tools:xt}),ni=PD({session:E,setMessages:V,setIsLoading:yn,setToolUseConfirmQueue:Pn,tools:xt}),ri=ni.isRemoteMode?ni:ti.isRemoteMode?ti:ei,[ii,ai]=(0,Q.useState)({}),[oi,ci]=(0,Q.useState)(0),ui=(0,Q.useRef)(0),di=(0,Q.useRef)([]),fi=(0,Q.useCallback)(e=>{let t=ui.current;if(ui.current=e(t),ui.current>t){let e=di.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=ui.current}}},[]),[mi,hi]=(0,Q.useState)(null),gi=!(H(e=>e.settings.prefersReducedMotion)??!1)&&!ou(),_i=(0,Q.useCallback)(e=>{gi&&hi(e)},[gi]),vi=mi&&gi&&mi.substring(0,mi.lastIndexOf(`
129
+ `)+1)||null,[yi,xi]=(0,Q.useState)(0),[Si,wi]=(0,Q.useState)(null),[Ei,Di]=(0,Q.useState)(null),[Oi,Ai]=(0,Q.useState)(null),[ji,Ni]=(0,Q.useState)(!1),[Pi,Ii]=(0,Q.useState)(void 0),[zi,Bi]=(0,Q.useState)(!1),[Vi,Hi]=(0,Q.useState)(d_()),[Gi,Ki]=(0,Q.useState)(null),qi=(0,Q.useRef)(!1),Ji=(0,Q.useRef)(yi);Ji.current=yi;let[Xi]=(0,Q.useState)(()=>({current:Qi(i,c)}));Xs(()=>{Xi.current=gs()});let[Zi,$i]=(0,Q.useState)(lf().hasAcknowledgedCostThreshold),[ea,na]=(0,Q.useState)(`INSERT`),[ra,aa]=(0,Q.useState)(!1),[oa,sa]=(0,Q.useState)(!1),[ca,ua]=(0,Q.useState)(!1),da=Rl(),ma=(0,Q.useRef)(da);ma.current=da;let[ha]=Ol(),ga=Q.useRef(!1),_a=(0,Q.useCallback)(()=>{if(ga.current)return;ga.current=!0;let e=or.current.slice(za.current);for(let t of Us(e))Ra.current.add(t);za.current=or.current.length,mk({theme:ha,readFileState:La.current,bashTools:Ra.current}).then(async e=>{if(e){let t=await e.content({theme:ha});R(e=>({...e,spinnerTip:t})),hk(e)}else R(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[R,ha]),va=(0,Q.useCallback)(()=>{yn(!1),cr(void 0),ui.current=0,di.current=[],hi(null),Nt([]),wi(null),Di(null),Ai(null),_a(),Mm(),la()},[_a]),ya=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(F.mode!==`auto`){ya.current=!1;return}if(ya.current||(lf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,ff(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,ur(Ek,`warning`)])},800,ya,V);return()=>clearTimeout(e)}},[F.mode,V]);let ba=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ba.current)return;let e=mr();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ba.current=!0;let t=Math.round(e.creationDurationMs/1e3);V(e=>[...e,ur(`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`)])},[V]);let xa=(0,Q.useMemo)(()=>{let e=B.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`&&Zr.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[B,Zr]),{onBeforeQuery:Sa,onTurnComplete:Ca,render:wa}=qD({enabled:!1,setMessages:V,inputValue:Pr,setInputValue:Ur,setToolJSX:jn}),Ea=(!Dn||Dn.showSpinner===!0)&&Mn.length===0&&Vn.length===0&&(z||sn||Tr()>0)&&!xa&&!vi,Oa=Mn.length>0||Vn.length>0||zn.length>0||pe.queue.length>0,ka=HO(B,z,oi,`session`,Oa),Aa=KD(V),ja=qA(B,oi),Ma=(0,Q.useMemo)(()=>({...ka,handleSelect:e=>{Xa.current=!1;let t=ka.handleSelect(e);e===`bad`&&!t&&UA(`feedback_survey_bad`)&&(Ya(`feedback_survey_bad`),Xa.current=!0)}}),[ka]),Na=XO(B,z,Oa,{enabled:!O}),Pa=KO(B,z,Oa,{enabled:!O});MO({autoConnectIdeFlag:p,ideToInstallExtension:nt,setDynamicMcpConfig:Pe,setShowIdeOnboarding:lt,setIDEInstallationState:st}),bk(s,se,e=>R(t=>({...t,fileHistory:e})));let Fa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Cr(n.messages),o=kc();await li(`resume`,{getAppState:()=>be.getState(),setAppState:R,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await ae(`resume`,{sessionId:t,agentType:N?.agentType,model:Ce});a.push(...s),r===`fork`?je(n,rc(t)):xe(n,rc(t)),vh(n,R),n.fileHistorySnapshots&&en(n);let{agentDefinition:c}=gh(n.agentSetting,x,oe);P(c),R(e=>({...e,agent:c?.agentType})),R(e=>({...e,standaloneAgentContext:_h(n.agentName,n.agentColor)})),ge(n.agentName),Ga(a,n.projectPath??Ku()),va(),Bt(null),Hi(t);let l=Ti(t);if($n(),Gu(),$u(rc(t),n.fullPath?r_(n.fullPath):null),await vo(),bi(),Yi(n),n.goal){let{hydrateGoalFromTranscript:r}=(Ri(),e(Wa)),i=new Map;i.set(t,n.goal),r(i,t)}if(Jn.current=!0,Kn(void 0),r!==`fork`)yh(),bh(n.worktreeSession),Rr(),pa({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:R});else{let e=mr();e&&ns(e)}l&&id(l),Xi.current&&r!==`fork`&&(Xi.current=Ts(a,n.contentReplacements??[])),V(()=>a),jn(null),Ur(``),X(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw X(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[va,R]),[Ia]=(0,Q.useState)(()=>An(100)),La=(0,Q.useRef)(Ia),Ra=(0,Q.useRef)(new Set),za=(0,Q.useRef)(0),Ba=(0,Q.useRef)(new Set),Ha=(0,Q.useRef)(new Set),Ga=(0,Q.useCallback)((e,t)=>{let n=It(e,t,100);La.current=j(La.current,n);for(let t of Us(e))Ra.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Ga(i,Ku()),pa({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:R}))},[]);let{status:Ka,reverify:qa}=ZD(),[Ja,Ya]=(0,Q.useState)(null),Xa=(0,Q.useRef)(!1),[Za,$a]=(0,Q.useState)(null),[eo,to]=(0,Q.useState)(!1),ro=!z&&zi;function io(){if(eo||Za)return;if(ji)return`message-selector`;if(xn)return;if(zn[0])return`sandbox-permission`;let e=!Dn||Dn.shouldContinueAnimation;if(e&&Mn[0])return`tool-permission`;if(e&&Vn[0])return`prompt`;if(e&&pe.queue[0])return`elicitation`;if(e&&ro)return`cost`;if(e&&Gi)return`idle-return`;if(e&&ct)return`ide-onboarding`;if(e&&ut)return`remote-callout`;if(e&&ht)return`lsp-recommendation`;if(e&&_t)return`plugin-hint`;if(e&&bt.visible)return`search-extra-tools-hint`;if(e&&pt)return`desktop-upsell`}let ao=io(),oo=xn&&(zn[0]||Mn[0]||Vn[0]||pe.queue[0]||ro);bn.current=ao,(0,Q.useEffect)(()=>{if(!z)return;let e=ao===`tool-permission`,t=Date.now();e&&hn.current===null?hn.current=t:!e&&hn.current!==null&&(mn.current+=t-hn.current,hn.current=null)},[ao,z]);let so=(0,Q.useRef)(ao);(0,Q.useLayoutEffect)(()=>{so.current===`tool-permission`!=(ao===`tool-permission`)&&wr(),so.current=ao},[ao,wr]);function fo(){if(ao!==`elicitation`){if(Wt.current!==0&&Date.now()-Wt.current<500){Wt.current=0,q(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Wt.current=0,q(`[onCancel] focusedInputDialog=${ao} streamMode=${Ot}`),Hj?.pauseProactive(),tn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ac(),e(Wi)),{persistCurrentGoal:r}=(Ri(),e(Wa));t()?.status===`active`&&(n(),r())}if(Kt(!0),tn.forceEnd(),qi.current=!1,mi?.trim()&&V(e=>[...e,Fi({content:mi})]),va(),Hu(null),ao===`tool-permission`)Mn[0]?.onAbort(),Pn([]);else if(ao===`prompt`){for(let e of Vn)e.reject(Error(`Prompt cancelled by user`));Hn([]),zt?.abort(`user-cancel`)}else ri.isRemoteMode?ri.cancelRequest():zt?.abort(`user-cancel`);Bt(null),Ca(or.current,!0)}}let po=(0,Q.useCallback)(()=>{let e=En(Pr,0);e&&(Ur(e.text),Gr(`prompt`),e.images.length>0&&ai(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Ur,Gr,Pr,ai]),mo={setToolUseConfirmQueue:Pn,onCancel:fo,onAgentsKilled:()=>V(e=>[...e,Qa()]),isMessageSelectorVisible:ji||!!ra,screen:Le,abortSignal:zt?.signal,popCommandFromQueue:po,vimMode:ea,isLocalJSXCommand:Dn?.isLocalJSXCommand,isSearchingHistory:oa,isHelpOpen:ca,inputMode:Wr,inputValue:Pr,streamMode:Ot};(0,Q.useEffect)(()=>{ku()>=5&&!zi&&!Zi&&(X(`tengu_cost_threshold_reached`,{}),$i(!0),uo()&&Bi(!0))},[B,zi,Zi]);let ho=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Bn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[R,be]);(0,Q.useEffect)(()=>{let e=Ve.getSandboxUnavailableReason();if(e){if(Ve.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Ta(1,`other`);return}q(`sandbox disabled: ${e}`,{level:`warn`}),Ye({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(G,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ye]),Ve.isSandboxingEnabled()&&Ve.initialize(ho).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${pd(e)}\n`),Ta(1,`other`)});let go=(0,Q.useCallback)((e,t)=>{R(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Pn)},[R,Pn]),yo=hO(Pn,go),bo=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=ki(e.toolPermissionContext,e.mcp.tools),n=th(xt,t,e.toolPermissionContext.mode);return N?si(N,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Dt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:D,mcpClients:CO(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:at,isNonInteractiveSession:!1,dynamicMcpConfig:Ne,theme:ha,agentDefinitions:Tt?{...a.agentDefinitions,allowedAgentTypes:Tt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:R,messages:e,setMessages:V,updateFileHistoryState(e){R(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){R(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{b||Ni(!0)},onChangeAPIKey:qa,readFileState:La.current,setToolJSX:jn,addNotification:Ye,appendSystemMessage:e=>V(t=>[...t,e]),sendOSNotification:e=>{ny(e,Se)},onChangeDynamicMcpConfig:Ie,onInstallIDEExtension:it,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ha.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Ba.current,setResponseLength:fi,pushApiMetricsEntry:void 0,setStreamMode:kt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Di(`claudeBlue_FOR_SYSTEM_SPINNER`),Ai(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),wi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:wi(`Compacting conversation`);break;case`compact_end`:wi(null),Di(null),Ai(null);break}},setInProgressToolUseIDs:Qr,setHasInterruptibleToolInProgress:e=>{$r.current=e},resume:Fa,setConversationId:Hi,requestPrompt:void 0,contentReplacementState:Xi.current}},[Dt,xt,N,n,d,at,Ne,ha,Tt,be,R,qa,Ye,V,Ie,Fa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Hn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),b,h,g,Hi]),{handleBackgroundSession:xo}=PO({setMessages:V,setIsLoading:yn,resetLoadingState:va,setAbortController:Bt,onBackgroundQuery:(0,Q.useCallback)(()=>{zt?.abort(`background`);let e=qn(e=>e.mode===`task-notification`);(async()=>{let t=bo(or.current,[],new AbortController,Ce),[n,r,i]=await Promise.all([fa(t.options.tools,Ce,Array.from(F.additionalWorkingDirectories.keys()),t.options.mcpClients),ia(),dl()]),a=co({mainThreadAgentDefinition:N,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Vo(e).catch(()=>[])).map(Oe),s=new Set;for(let e of or.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)));Ui({messages:[...or.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:yo,toolUseContext:t,querySource:rs()},description:Zn,setAppState:R,agentDefinition:N})})()},[zt,Ce,F,N,bo,h,g,yo,R])}),So=(0,Q.useCallback)(t=>{Zt(t,t=>{if(Fr(t)?(no()?V(e=>{let n=ln(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):V(()=>[t]),Hi(d_()),Hj?.setContextBlocked(!1)):t.type===`progress`&&Fe(t.data?.type)?V(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]}):V(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?Hj?.setContextBlocked(!0):t.type===`assistant`&&Hj?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(A(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}=(ac(),e(Wi)),{persistCurrentGoal:r}=(Ri(),e(Wa));t()?.status===`active`&&(n(),r(),Ye({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{fi(t=>t+e.length)},kt,Nt,e=>{V(t=>t.filter(t=>t!==e)),yc(e.uuid)},Rt,e=>{let t=Date.now(),n=ui.current;di.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},_i)},[V,fi,kt,Nt,Rt,_i]),Co=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=CO(d,be.getState().mcp.clients);$o.handleQueryStart(e);let t=Rn(e);t&&To(t)}if(rm(),!ee&&!Wn&&!Xn&&!Jn.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?A(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(Jn.current=!0,Um(n,new AbortController().signal).then(e=>{e?Kn(e):Jn.current=!1},()=>{Jn.current=!1}))}if(be.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(Fr)&&(Hi(d_()),Hj?.setContextBlocked(!1)),va(),Bt(null);return}let o=bo(e,t,n,a),{tools:s,mcpClients:c}=o.options;Ls(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,_k(F,R,be.getState().fastMode),fa(s,a,Array.from(F.additionalWorkingDirectories.keys()),c),ia(),dl()]),p={...u,...Hj?.isProactiveActive()&&!ma.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Ls(`query_context_loading_end`);let m=co({mainThreadAgentDefinition:N,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,Ls(`query_query_start`),Qu(),td(),rd();for await(let t of Va({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:yo,toolUseContext:o,querySource:rs()}))So(t);Ls(`query_end`),va(),Vt(),await y?.(or.current)},[d,va,bo,F,R,h,y,g,yo,N,So,Wn,ee]),wo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=tn.tryStart();if(s===null)return X(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>A(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{hr({value:e,mode:`prompt`}),t===0&&X(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Kt(!1),gn(),V(t=>[...t,...e]),ui.current=0,Hu((o?M(o):null)??Du()),di.current=[],Nt([]),hi(null);let s=or.current;if(o&&await Sa(o,s,e.length),a&&o&&!await a(o,s))return!0;await Co(s,e,t,n,r,i)}finally{if(tn.end(s)){Kt(t.signal.aborted),xi(Date.now()),qi.current=!1,va(),await Ca(or.current,t.signal.aborted),qt.current();let e;Du()!==null&&Du()>0&&!t.signal.aborted&&(e={tokens:Au(),limit:Du(),nudges:Uu()}),Hu(null);let n=Date.now()-pn.current-mn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!De&&V(t=>[...t,he(n,e,jd(t,Fn))]),Bt(null)}if(t.signal.reason===`user-cancel`&&!tn.isActive&&Br.current===``&&Tr()===0&&!be.getState().viewingAgentTaskId){let e=or.current,t=e.findLast(rh);t&&ih(e,e.lastIndexOf(t))&&(ce(),Yt.current(t))}}return!0},[Co,R,va,tn,Sa,Ca]),Do=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=le;if(!e||z||Do.current)return;Do.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?k():void 0,{clearConversation:n}=await import(`./conversation-hcUx9e-C.js`);await n({setMessages:V,readFileState:La.current,discoveredSkillNames:Ba.current,loadedNestedMemoryPaths:Ha.current,getAppState:()=>be.getState(),setAppState:R,setConversationId:Hi}),Jn.current=!1,Kn(void 0),Ra.current.clear(),za.current=0,t&&_n(ed(),t)}R(t=>{let n=e.mode?Qo(t.toolPermissionContext,Nx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=on({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),_l()&&dt(e=>{R(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await kr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Oo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=lo();Bt(t),wo([e.message],t,!0,[],Ce)}setTimeout(e=>{e.current=!1},100,Do)}t(e)},[le,z,V,R,wo,Ce,wt]);let Oo=(0,Q.useCallback)(async(e,t,n,r)=>{if(wr(),Hj?.resumeProactive(),!n&&e.trim().startsWith(`/`)){let n=dn(e,ii).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Dt.find(e=>qr(e)&&(e.name===a||e.aliases?.includes(a)||ft(e)===a));s?.name===`clear`&&sr.current&&(X(`tengu_idle_return_action`,{action:`hint_converted`,variant:sr.current,idleMinutes:Math.round((Date.now()-Ji.current)/6e4),messageCount:or.current.length,totalInputTokens:Nu()}),sr.current=!1);let c=tn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Br.current.trim()&&(Ur(``),t.setCursorOffset(0),t.clearBuffer(),ai({}));let n=hl(e).filter(e=>ii[e.id]?.type===`text`),i=n.length;X(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ii[t.id]?.content.length??0),0)}),X(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,jn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ye({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!no())){let e=r?.displayArgs??o;i.push(Pc(Po(ft(s),e)),Pc(`<${wf}>${Wo(n)}</${wf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>vr({content:e,isMeta:!0}))),i.length&&V(e=>[...e,...i]),Jr!==void 0&&(Ur(Jr.text),t.setCursorOffset(Jr.cursorOffset),ai(Jr.pastedContents),Yr(void 0))},r=bo(or.current,[],lo(),Ce),i=await(await s.load()).call(n,r,o);i&&!e&&jn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(ri.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Eo({display:n?e:Ht(e,Wr),pastedContents:n?{}:ii}),Wr===`bash`&&HC(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!z||n||ri.isRemoteMode;if(Jr!==void 0&&!i&&a?(Ur(Jr.text),t.setCursorOffset(Jr.cursorOffset),ai(Jr.pastedContents),Yr(void 0)):a&&(r?.fromKeybinding||(Ur(``),t.setCursorOffset(0)),ai({})),a&&(Gr(`prompt`),tt(void 0),ci(e=>e+1),t.clearBuffer(),ga.current=!1,!i&&Wr===`prompt`&&!n&&!ri.isRemoteMode&&(cr(e),gn()),R(e=>({...e,attribution:Pt(e.attribution,e=>{Jt(e).catch(e=>{q(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await ot(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:V,readFileState:La,cwd:Ku()});if(t){let e=lo();Bt(e),wo([],e,!0,[],Ce)}return}if(ri.isRemoteMode&&!(i&&Dt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return qr(t)&&(t.name===n||t.aliases?.includes(n)||ft(t)===n)})?.type===`local-jsx`)){let t=Object.values(ii),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=vr({content:i,imagePasteIds:r});V(e=>[...e,o]),await ri.sendMessage(a,{uuid:o.uuid});return}await kr(),await _O({input:e,helpers:t,queryGuard:tn,isExternalLoading:rn,mode:Wr,commands:Dt,onInputChange:Ur,setPastedContents:ai,setToolJSX:jn,getToolUseContext:bo,messages:or.current,mainLoopModel:Ce,pastedContents:ii,ideSelection:et,setUserInputOnProcessing:cr,setAbortController:Bt,abortController:zt,onQuery:wo,setAppState:R,querySource:rs(),onBeforeQuery:v,canUseTool:yo,addNotification:Ye,setMessages:V,streamMode:jt.current,hasInterruptibleToolInProgress:$r.current}),(i||z)&&Jr!==void 0&&(Ur(Jr.text),t.setCursorOffset(Jr.cursorOffset),ai(Jr.pastedContents),Yr(void 0))},[tn,z,rn,Wr,Dt,Ur,Gr,ai,ci,tt,jn,bo,Ce,ii,et,cr,Bt,Ye,wo,Jr,Yr,R,v,yo,ei,V,kr,wr]),ko=(0,Q.useCallback)(()=>{let e=Ja?WA(Ja):`/issue`;Ya(null),Oo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{q(`Auto-run ${e} failed: ${pd(t)}`)})},[Oo,Ja]),Ao=(0,Q.useCallback)(()=>{Ya(null)},[]),jo=(0,Q.useCallback)(()=>{Oo(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{q(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Oo]),Mo=(0,Q.useRef)(Oo);Mo.current=Oo;let No=(0,Q.useCallback)(async()=>{if(to(!0),sl()){__(`tmux`,[`detach-client`],{stdio:`ignore`}),to(!1);return}if(mr()!==null){$a((0,$.jsx)(sg,{showWorktree:!0,onDone:()=>{},onCancel:()=>{$a(null),to(!1)}}));return}let e=await(await rt.load()).call(()=>{});$a(e),e===null&&to(!1)},[]),Fo=(0,Q.useCallback)(()=>{Ni(e=>!e)},[]),Io=(0,Q.useCallback)(e=>{let t=or.current,n=t.lastIndexOf(e);if(n===-1)return;X(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),V(t.slice(0,n)),Hi(d_()),ke();let r=e.permissionMode;R(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}}))},[V,R]),Lo=(0,Q.useCallback)(e=>{Io(e);let t=_(e);if(t&&(Ur(t.text),Gr(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)}}},[Io,Ur]);Yt.current=Lo;let Ro=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Lo,e)},[Lo]),Bo=e=>{let t=e.slice(0,24);return B.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Ho,handlers:Uo}=Hr(yr,br,xr,{copy:e=>void Jl(e).then(e=>{e&&process.stdout.write(e),Ye({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Bo(e.uuid),n=t>=0?B[t]:void 0;if(!n||!rh(n))return;let r=!await Lr(se,n.uuid),i=ih(B,t);r&&i?(fo(),Ro(n)):(Ii(n),Ni(!0))}});async function Go(){qa();let e=await ta();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
130
+ `);q(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else q(`No CLAUDE.md/rules files found`);for(let t of e)La.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})}JD(Ug()),Sy(B,B.length===i?.length);let{sendBridgeResult:Ko}=Cy(B,V,Ut,Dt,Ce);qt.current=Ko,YD();let qo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(L.length<1){qo.current=!1;return}qo.current||(qo.current=!0,ff(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[L.length]),xO({executeQueuedInput:(0,Q.useCallback)(async e=>{await _O({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:tn,commands:Dt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:jn,getToolUseContext:bo,messages:B,mainLoopModel:Ce,ideSelection:et,setUserInputOnProcessing:cr,setAbortController:Bt,onQuery:wo,setAppState:R,querySource:rs(),onBeforeQuery:v,canUseTool:yo,addNotification:Ye,setMessages:V,queuedCommands:e})},[tn,Dt,jn,bo,B,Ce,et,cr,yo,Bt,wo,Ye,R,v]),hasActiveLocalJsxUI:tr,queryGuard:tn}),(0,Q.useEffect)(()=>{Mi.recordUserActivity(),nd(!0)},[Pr,oi]),(0,Q.useEffect)(()=>{oi===1&&Qg()},[oi]),(0,Q.useEffect)(()=>{if(z||oi===0||yi===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Ru()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=lf().messageIdleNotifThresholdMs&&ny({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},lf().messageIdleNotifThresholdMs,yi,z,Dn,bn,Se);return()=>clearTimeout(e)},[z,Dn,oi,yi,Se]),(0,Q.useEffect)(()=>{},[yi,z,Ye,Ze]),SO({isLoading:z,onSubmitMessage:(0,Q.useCallback)((e,t)=>{if(tn.isActive||$c().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 Nn([n]),t=e.attachmentCommands[0];if(!t)return;let r=lo();Bt(r);let i=vr({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await wo([i],r,!0,[],Ce)!==!1}catch(t){try{await zo({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:ld(),priority:`later`})}catch(e){J(gd(e))}J(gd(t));return}if(a)try{let t=await zo({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:ld(),priority:`later`});for(let e of t)hr(e)}catch(e){J(gd(e))}})().catch(e=>{J(gd(e))}),!0},[wo,Ce,be])}),qj?.({isLoading:z||le!==null,queuedCommandsLength:L.length,hasActiveLocalJsxUI:tr,isInPlanMode:F.mode===`plan`,onQueueTick:e=>hr(e)}),Jj?.({isLoading:z||le!==null,wasAborted:Gt,queuedCommandsLength:L.length,hasActiveLocalJsxUI:tr,isInPlanMode:F.mode===`plan`,isQueryActiveNow:tn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;V(e=>[...e,vr({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Ye({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(!De){hm(null);return}if(!z){if(Ae!==null&&L.length===0&&!tr&&F.mode!==`plan`&&le===null){hm({enabled:!0,phase:`standby`,next_tick_at:Ae,sleep_until:null});return}hm({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[le,z,tr,De,Ae,L.length,F.mode]),(0,Q.useEffect)(()=>{L.some(e=>e.priority===`now`)&&Ut.current?.abort(`interrupt`)},[L]);let Jo=(0,Q.useRef)(Go);Jo.current=Go;let Yo=(0,Q.useRef)($o);Yo.current=$o,(0,Q.useEffect)(()=>(Jo.current(),()=>{Yo.current.shutdown()}),[]);let{internal_eventEmitter:Xo}=Wl(),[Zo,es]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
131
+ Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
132
+ Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
133
+ `)},t=()=>{es(e=>e+1)};return Xo?.on(`suspend`,e),Xo?.on(`resume`,t),()=>{Xo?.off(`suspend`,e),Xo?.off(`resume`,t)}},[Xo]);let ts=(0,Q.useMemo)(()=>{if(!z)return null;let e=B.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||B.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=jd(B,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`;return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[B,z]),is=(0,Q.useCallback)(()=>{Nr({messagesLength:B.length,streamingToolUsesLength:Mt.length})},[B.length,Mt.length]),as=(0,Q.useCallback)(()=>{Nr(null)},[]),os=no()&&!te,ss=(0,Q.useRef)(null),[cs,ls]=(0,Q.useState)(!1),[us,ds]=(0,Q.useState)(``),[fs,ps]=(0,Q.useState)(0),[ms,hs]=(0,Q.useState)(0),vs=(0,Q.useCallback)((e,t)=>{ps(e),hs(t)},[]);Zl((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){ss.current?.setAnchor(),ls(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&fs>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:Le===`transcript`&&os&&!cs&&!He});let{setQuery:ys,scanElement:bs,setPositions:xs}=iu(),Ss=nu().columns,Cs=Q.useRef(Ss);Q.useEffect(()=>{Cs.current!==Ss&&(Cs.current=Ss,(us||cs)&&(ls(!1),ds(``),ps(0),hs(0),ss.current?.disarmSearch(),ys(``)))},[Ss,us,cs,ys]),Zl((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){as(),n.stopImmediatePropagation();return}if(e===`[`&&!He)Ue(!0),Be(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Je.current)return;Je.current=!0;let e=Ke.current,t=t=>{e===Ke.current&&(clearTimeout(qe.current),Ge(t))};t(`rendering ${Ar.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Qv(Ar,wt,e)).replace(/[ \t]+$/gm,``),r=a_(e_(),`cc-transcript-${Date.now()}.txt`);await h_(r,n);let i=Lh(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Je.current=!1,e===Ke.current&&(qe.current=setTimeout(e=>e(``),4e3,Ge))})()}}},{isActive:Le===`transcript`&&os&&!cs});let Es=Le===`transcript`&&os;(0,Q.useEffect)(()=>{Es||(ds(``),ps(0),hs(0),ls(!1),Ke.current++,clearTimeout(qe.current),Ue(!1),Ge(``))},[Es]),(0,Q.useEffect)(()=>{ys(Es?us:``),Es||xs(null)},[Es,us,ys,xs]);let Ds={screen:Le,setScreen:Re,showAllInTranscript:ze,setShowAllInTranscript:Be,messageCount:B.length,onEnterTranscript:is,onExitTranscript:as,virtualScrollActive:os,searchBarOpen:cs},Os=Mr?Ar.slice(0,Mr.messagesLength):Ar,ks=Mr?Mt.slice(0,Mr.streamingToolUsesLength):Mt;rO({onOpenBackgroundTasks:tr?void 0:()=>aa(!0),onTogglePipeSelector:()=>{R(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let As=me?fe[me]:void 0,js=As&&zr(As)?As:void 0,Ms=gi||!z,Ns=js?.messages,Ps=(0,Q.useMemo)(()=>{if(!js)return;let e=Ns??[];if(!zr(js)||js.agentType!==`fork`||!js.prompt)return e;let t=js.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(iM))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=>!iM(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=vr({content:js.prompt,timestamp:new Date(js.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[js,Ns]),Fs=js?Ps??[]:Ms?B:Ar;if(Le===`transcript`){let e=no()&&!te&&!He?Xt:void 0,t=(0,$.jsx)(Fg,{messages:Os,tools:wt,commands:Dt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Zr,isMessageSelectorVisible:!1,conversationId:Vi,screen:Le,agentDefinitions:oe,streamingToolUses:ks,showAllInTranscript:ze,isLoading:z,hidePastThinking:!0,streamingThinking:Ft,scrollRef:e,jumpRef:ss,onSearchMatchesChange:vs,scanElement:bs,setPositions:xs,disableRenderCap:He}),n=Dn&&(0,$.jsx)(W,{flexDirection:`column`,width:`100%`,children:Dn.jsx}),r=(0,$.jsxs)(ne,{children:[(0,$.jsx)(nM,{isAnimating:nr,title:Zn,disabled:ee,noPrefix:!1}),(0,$.jsx)(QD,{...Ds}),(0,$.jsx)(eO,{onSubmit:Oo,isActive:!Dn?.isLocalJSXCommand}),e?(0,$.jsx)(bj,{scrollRef:Xt,isActive:!0,isModal:!cs,onScroll:()=>ss.current?.disarmSearch()}):null,(0,$.jsx)(nO,{...mo}),e?(0,$.jsx)(Ng,{scrollRef:Xt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(Ck,{})]}),bottom:cs?(0,$.jsx)(Qj,{jumpRef:ss,initialQuery:``,count:fs,current:ms,onClose:e=>{ds(fs>0?e:``),ls(!1),e||(ps(0),hs(0),ss.current?.setSearchQuery(``))},onCancel:()=>{ls(!1),ss.current?.setSearchQuery(``),ss.current?.setSearchQuery(us),ys(us)},setHighlight:ys}):(0,$.jsx)(Zj,{showAllInTranscript:ze,virtualScroll:!0,status:We||void 0,searchBadge:us&&fs>0?{current:ms,count:fs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(Ck,{}),(0,$.jsx)(Zj,{showAllInTranscript:ze,virtualScroll:!1,suppressShowAll:He,status:We||void 0})]})]});return e?(0,$.jsx)(fu,{mouseTracking:Ua(),children:r}):r}let Is=sn&&!js&&Fs.length<=un.current?sn:void 0,Rs=ao===`tool-permission`?(0,$.jsx)(gS,{onDone:()=>Pn(([e,...t])=>t),onReject:po,toolUseConfirm:Mn[0],toolUseContext:bo(B,B,zt??lo(),Ce),verbose:I,setStickyFooter:no()?Ln:void 0},Mn[0]?.toolUseID):null,zs=no()&&Dn?.isLocalJSXCommand===!0,Bs=zs?Dn.jsx:null,Vs=(0,$.jsxs)(ne,{children:[(0,$.jsx)(nM,{isAnimating:nr,title:Zn,disabled:ee,noPrefix:!1}),(0,$.jsx)(QD,{...Ds}),(0,$.jsx)(eO,{onSubmit:Oo,isActive:!Dn?.isLocalJSXCommand}),(0,$.jsx)(bj,{scrollRef:Xt,isActive:no()&&(Bs!=null||!ao||ao===`tool-permission`),onScroll:Or}),null,(0,$.jsx)(nO,{...mo}),(0,$.jsx)(eh,{dynamicMcpConfig:Ne,isStrictMcpConfig:m,children:(0,$.jsx)(Ng,{scrollRef:Xt,overlay:Rs,modal:Bs,modalScrollRef:Qt,dividerYRef:dr,hidePill:!!js,newMessageCount:Sr?.count??0,onPillClick:()=>{br(null),gr(Xt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fg,{messages:Fs,tools:wt,commands:Dt,verbose:I,toolJSX:Dn,toolUseConfirmQueue:Mn,inProgressToolUseIDs:Zr,isMessageSelectorVisible:ji,conversationId:Vi,screen:Le,streamingToolUses:Mt,showAllInTranscript:ze,agentDefinitions:oe,isLoading:z,streamingText:z&&!js?vi:null,unseenDivider:js?void 0:Sr,scrollRef:no()?Xt:void 0,trackStickyPrompt:no()?!0:void 0,cursor:yr,setCursor:br,cursorNavRef:xr}),(0,$.jsx)(CA,{}),!b&&Is&&!Bs&&(0,$.jsx)(Ac,{param:{text:Is,type:`text`},addMargin:!0,verbose:I}),Dn&&!(Dn.isLocalJSXCommand&&Dn.isImmediate)&&!zs&&(0,$.jsx)(W,{flexDirection:`column`,width:`100%`,children:Dn.jsx}),(0,$.jsx)(W,{flexGrow:1}),Ea&&(0,$.jsx)(Xe,{mode:Ot,spinnerTip:ue,responseLengthRef:ui,apiMetricsRef:di,overrideMessage:Si,spinnerSuffix:ts,verbose:I,loadingStartTimeRef:pn,totalPausedMsRef:mn,pauseStartTimeRef:hn,overrideColor:Ei,overrideShimmerColor:Oi,hasActiveTools:Zr.size>0,leaderIsIdle:!z})]}),bottom:(0,$.jsx)(W,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(W,{flexDirection:`column`,flexGrow:1,children:[no()&&(0,$.jsx)(ZE,{}),In,Dn?.isLocalJSXCommand&&Dn.isImmediate&&!zs&&(0,$.jsx)(W,{flexDirection:`column`,width:`100%`,children:Dn.jsx}),!Ea&&!Dn?.isLocalJSXCommand&&de&&St&&St.length>0&&(0,$.jsx)(W,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Ci,{tasks:St,isStandalone:!0})}),ao===`sandbox-permission`&&(0,$.jsx)(xk,{hostPattern:zn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=zn[0];if(!r)return;let i=r.hostPattern.host;Bn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=Un.current.get(i);if(a){for(let e of a)e();Un.current.delete(i)}}},zn[0].hostPattern.host),ao===`prompt`&&(0,$.jsx)(BS,{title:Vn[0].title,toolInputSummary:Vn[0].toolInputSummary,request:Vn[0].request,onRespond:e=>{let t=Vn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Hn(([,...e])=>e))},onAbort:()=>{let e=Vn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Hn(([,...e])=>e))}},Vn[0].request.prompt),ao===`elicitation`&&(0,$.jsx)(LS,{event:pe.queue[0],onResponse:(e,t)=>{let n=pe.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||R(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=pe.queue[0];R(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},pe.queue[0].serverName+`:`+String(pe.queue[0].requestId)),ao===`cost`&&(0,$.jsx)($v,{onDone:()=>{Bi(!1),$i(!0),ff(e=>({...e,hasAcknowledgedCostThreshold:!0})),X(`tengu_cost_threshold_acknowledged`,{})}}),ao===`idle-return`&&Gi&&(0,$.jsx)(ey,{idleMinutes:Gi.idleMinutes,totalInputTokens:Nu(),onDone:async e=>{let t=Gi;if(Ki(null),X(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:or.current.length,totalInputTokens:Nu()}),e===`dismiss`){Ur(t.input);return}if(e===`never`&&ff(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-hcUx9e-C.js`);await e({setMessages:V,readFileState:La.current,discoveredSkillNames:Ba.current,loadedNestedMemoryPaths:Ha.current,getAppState:()=>be.getState(),setAppState:R,setConversationId:Hi}),Jn.current=!1,Kn(void 0),Ra.current.clear(),za.current=0}qi.current=!0,Mo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),ao===`ide-onboarding`&&(0,$.jsx)(At,{onDone:()=>lt(!1),installationStatus:at}),ao===`remote-callout`&&(0,$.jsx)(FO,{onDone:e=>{R(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),Za,ao===`plugin-hint`&&_t&&(0,$.jsx)(Yk,{pluginName:_t.pluginName,pluginDescription:_t.pluginDescription,marketplaceName:_t.marketplaceName,sourceCommand:_t.sourceCommand,onResponse:vt}),ao===`search-extra-tools-hint`&&bt.visible&&(0,$.jsx)(Zk,{tools:bt.tools,onSelect:bt.handleSelect,onDismiss:bt.handleDismiss}),ao===`lsp-recommendation`&&ht&&(0,$.jsx)(Kk,{pluginName:ht.pluginName,pluginDescription:ht.pluginDescription,fileExtension:ht.fileExtension,onResponse:gt}),ao===`desktop-upsell`&&(0,$.jsx)(gA,{onDone:()=>mt(!1)}),wa(),!Dn?.shouldHidePromptInput&&!ao&&!eo&&!b&&!yr&&(0,$.jsxs)($.Fragment,{children:[Ja&&(0,$.jsx)(HA,{onRun:ko,onCancel:Ao,reason:GA(Ja)}),Na.state===`closed`?Pa.state===`closed`?(0,$.jsx)(tk,{state:Ma.state,lastResponse:Ma.lastResponse,handleSelect:Ma.handleSelect,handleTranscriptSelect:Ma.handleTranscriptSelect,inputValue:Pr,setInputValue:Ur,onRequestFeedback:Xa.current?void 0:jo}):(0,$.jsx)(tk,{state:Pa.state,lastResponse:Pa.lastResponse,handleSelect:Pa.handleSelect,handleTranscriptSelect:Pa.handleTranscriptSelect,inputValue:Pr,setInputValue:Ur,onRequestFeedback:jo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(tk,{state:Na.state,lastResponse:Na.lastResponse,handleSelect:Na.handleSelect,inputValue:Pr,setInputValue:Ur,onRequestFeedback:jo}),Aa.suggestion&&(0,$.jsx)(HD,{isOpen:Aa.isOpen,skillName:Aa.suggestion.skillName,updates:Aa.suggestion.updates,handleSelect:Aa.handleSelect,inputValue:Pr,setInputValue:Ur}),ja&&(0,$.jsx)(KA,{}),(0,$.jsx)(gD,{debug:n,ideSelection:et,hasSuppressedDialogs:!!oo,isLocalJSXCommandActive:tr,getToolUseContext:bo,toolPermissionContext:F,setToolPermissionContext:go,apiKeyStatus:Ka,commands:Dt,agents:oe.activeAgents,isLoading:z,onExit:No,verbose:I,messages:B,onAutoUpdaterResult:Tn,autoUpdaterResult:Cn,input:Pr,onInputChange:Ur,mode:Wr,onModeChange:Gr,stashedPrompt:Jr,setStashedPrompt:Yr,submitCount:oi,onShowMessageSelector:Fo,onMessageActionsEnter:void 0,mcpClients:$e,pastedContents:ii,setPastedContents:ai,vimMode:ea,setVimMode:na,showBashesDialog:ra,setShowBashesDialog:aa,onSubmit:Oo,isSearchingHistory:oa,setIsSearchingHistory:sa,helpOpen:ca,setHelpOpen:ua,insertTextRef:Vr}),(0,$.jsx)(NO,{onBackgroundSession:xo,isLoading:z}),(0,$.jsx)(jO,{})]}),yr&&(0,$.jsx)(er,{cursor:yr}),ao===`message-selector`&&(0,$.jsx)(sh,{messages:B,preselectedMessage:Pi,onPreRestore:fo,onRestoreCode:async e=>{await Kr(e=>{R(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=ln(B),i=r.indexOf(e);if(i===-1){V(e=>[...e,ur(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=lo(),o=bo(r,[],a,Ce),s=o.getAppState(),c=await fa(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=co({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([ia(),dl()]),f=await yt(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(no()&&n===`from`?V(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):V(h),Hj?.setContextBlocked(!1),Hi(d_()),_o(o.options.querySource),n===`from`){let t=_(e);t&&(Ur(t.text),Gr(t.mode))}let g=pi(`app:toggleTranscript`,`Global`,`ctrl+o`);Ye({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Ro,onClose:()=>{Ni(!1),Ii(void 0)}})]})})})},Zo)]});return no()?(0,$.jsx)(fu,{mouseTracking:Ua(),children:Vs}):Vs}export{aM as t};