claude-code-zanii 2.8.4

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 (669) hide show
  1. package/README.md +146 -0
  2. package/dist/chunks/AddWorkspaceDirectory-y_rd6sRl.js +1 -0
  3. package/dist/chunks/App-DgWSavG1.js +1 -0
  4. package/dist/chunks/ApproveApiKey-CJKWha-a.js +1 -0
  5. package/dist/chunks/ApproveApiKey-DTs2ExZH.js +1 -0
  6. package/dist/chunks/AssistantSessionChooser-BAhVk4id.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-XU_JPh7R.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-DV0Pi7ys.js +1 -0
  9. package/dist/chunks/ClaudeInChromeOnboarding-6erm_8Fn.js +1 -0
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-CjBvzB5s.js +1 -0
  11. package/dist/chunks/ClaudeMdExternalIncludesDialog-ts0XnWwl.js +1 -0
  12. package/dist/chunks/ConsoleOAuthFlow-DySPdSqQ.js +1 -0
  13. package/dist/chunks/CustomSelect-DqZxzBZP.js +1 -0
  14. package/dist/chunks/DesktopHandoff-5c90JK88.js +1 -0
  15. package/dist/chunks/DevChannelsDialog-DCMderzu.js +1 -0
  16. package/dist/chunks/Dialog-Dgg8bqcG.js +1 -0
  17. package/dist/chunks/DiffDialog-BU765aqh.js +6 -0
  18. package/dist/chunks/Doctor-B73iDB-d.js +3 -0
  19. package/dist/chunks/Doctor-CLZDdNRo.js +1 -0
  20. package/dist/chunks/ExitFlow-DBqn2mUf.js +2 -0
  21. package/dist/chunks/Feedback-D-JHabwi.js +2 -0
  22. package/dist/chunks/Grove-D-uQNMMo.js +11 -0
  23. package/dist/chunks/HybridTransport-B-G4QJcy.js +4 -0
  24. package/dist/chunks/ITermBackend-KP1vKsRN.js +1 -0
  25. package/dist/chunks/InProcessTransport-ByBEKxrQ.js +1 -0
  26. package/dist/chunks/InvalidConfigDialog-CMqiZ5nG.js +1 -0
  27. package/dist/chunks/InvalidSettingsDialog-CjPCKzVZ.js +1 -0
  28. package/dist/chunks/ListItem-B6MyhHvM.js +1 -0
  29. package/dist/chunks/MCPConnectionManager-BJ8PcYPe.js +1 -0
  30. package/dist/chunks/Message-DNxJ_tMS.js +1 -0
  31. package/dist/chunks/MessageSelector-D79Ug71B.js +3 -0
  32. package/dist/chunks/Messages-CtIbkB2M.js +11 -0
  33. package/dist/chunks/Onboarding-DVrgKrI9.js +1 -0
  34. package/dist/chunks/OverageCreditUpsell-D_td1ss4.js +1 -0
  35. package/dist/chunks/PermissionDialog-BCS22yEO.js +1 -0
  36. package/dist/chunks/PermissionDialog-C5O1fL53.js +1 -0
  37. package/dist/chunks/PermissionRequestTitle-CtlbBU9t.js +1 -0
  38. package/dist/chunks/PluginSettings-OPrg-_3N.js +17 -0
  39. package/dist/chunks/PressEnterToContinue-DmzxIgbZ.js +1 -0
  40. package/dist/chunks/PromptInputFooterSuggestions-CcsKj5DK.js +1 -0
  41. package/dist/chunks/PromptInputHelpMenu-JedFdsxU.js +1 -0
  42. package/dist/chunks/REPL-ByhyIRnf.js +1 -0
  43. package/dist/chunks/REPL-Clve-8zC.js +157 -0
  44. package/dist/chunks/RemoteCallout-BZcabEKb.js +1 -0
  45. package/dist/chunks/RemoteSessionManager-C2PIFDHt.js +1 -0
  46. package/dist/chunks/ResumeConversation-D3ZRTFcF.js +1 -0
  47. package/dist/chunks/SSETransport-DmZWnH0k.js +4 -0
  48. package/dist/chunks/SearchBox-DQg2Ph0V.js +1 -0
  49. package/dist/chunks/SearchExtraToolsTool-CLO4nt6N.js +1 -0
  50. package/dist/chunks/SentryErrorBoundary-BVfBaOOU.js +2 -0
  51. package/dist/chunks/SentryErrorBoundary-DIaVFad-.js +1 -0
  52. package/dist/chunks/Settings-rOCxQdS8.js +2 -0
  53. package/dist/chunks/TeleportProgress-CP8IY6bz.js +1 -0
  54. package/dist/chunks/TeleportRepoMismatchDialog-DMmHgBqo.js +1 -0
  55. package/dist/chunks/TeleportResumeWrapper-D5wEAW1-.js +1 -0
  56. package/dist/chunks/ThemePicker-Bgr7yOQB.js +1 -0
  57. package/dist/chunks/TmuxBackend-BzbtUtP1.js +9 -0
  58. package/dist/chunks/TrustDialog-BI5U3BQ0.js +1 -0
  59. package/dist/chunks/TungstenTool-CiQclNwj.js +1 -0
  60. package/dist/chunks/TungstenTool-kMqy-ifa.js +1 -0
  61. package/dist/chunks/ValidationErrorsList-DprGtB2w.js +2 -0
  62. package/dist/chunks/WelcomeV2-C4vfBnIy.js +1 -0
  63. package/dist/chunks/WindowsTerminalBackend-BSoezOCE.js +2 -0
  64. package/dist/chunks/add-dir-DpOmv6kv.js +1 -0
  65. package/dist/chunks/agentDisplay-DuYEwOwO.js +1 -0
  66. package/dist/chunks/agents-BlurXZrF.js +2 -0
  67. package/dist/chunks/agents-DhZf7ftU.js +103 -0
  68. package/dist/chunks/ajv-CDrSAj3O.js +8 -0
  69. package/dist/chunks/analytics-i6X1et4O.js +1 -0
  70. package/dist/chunks/ant-D9hd_iYy.js +1 -0
  71. package/dist/chunks/api-CoaOHwDQ.js +4 -0
  72. package/dist/chunks/api-DvyGR-L7.js +1 -0
  73. package/dist/chunks/api-YHYC4Zdk.js +1 -0
  74. package/dist/chunks/artifacts-BMAYdaqh.js +1 -0
  75. package/dist/chunks/asciicast-DpHRoebc.js +1 -0
  76. package/dist/chunks/asciicast-HG1EoAQe.js +4 -0
  77. package/dist/chunks/assistant-D4-qcNT1.js +1 -0
  78. package/dist/chunks/assistant-DO2ZmZn1.js +1 -0
  79. package/dist/chunks/assistant-Dd86NmJM.js +1 -0
  80. package/dist/chunks/attributionHooks-BUmHrLhB.js +1 -0
  81. package/dist/chunks/attributionTrailer-r2Pbpu2N.js +1 -0
  82. package/dist/chunks/auth-CF3BGNYT.js +1 -0
  83. package/dist/chunks/auth-DwWwG43F.js +1 -0
  84. package/dist/chunks/auth-V_Xk2iea.js +1 -0
  85. package/dist/chunks/autoMode-DUksX5_i.js +45 -0
  86. package/dist/chunks/autoModeDenials-0CPO-Jbu.js +1 -0
  87. package/dist/chunks/autonomy-C5mNhAdz.js +21 -0
  88. package/dist/chunks/autonomy-CLt1dWaC.js +1 -0
  89. package/dist/chunks/autonomyPanel-rioFnrQO.js +1 -0
  90. package/dist/chunks/axios-DPuSPBlH.js +1 -0
  91. package/dist/chunks/axios-Zh7qGPze.js +12 -0
  92. package/dist/chunks/backgroundHousekeeping-BGtfqu-J.js +1 -0
  93. package/dist/chunks/backgroundHousekeeping-BqKZEvy0.js +17 -0
  94. package/dist/chunks/banner-BGLr3KYQ.js +2 -0
  95. package/dist/chunks/base64-js-B1tFNiG0.js +1 -0
  96. package/dist/chunks/bedrockClient-BFzWuhQK.js +15 -0
  97. package/dist/chunks/bg-B-YgGwLj.js +9 -0
  98. package/dist/chunks/bg-IU4gG3jc.js +1 -0
  99. package/dist/chunks/branch-BWY5W7hf.js +3 -0
  100. package/dist/chunks/break-cache-CY-O23fJ.js +8 -0
  101. package/dist/chunks/bridge-CqWd70vK.js +2 -0
  102. package/dist/chunks/bridgeConfig-CWO8AmCY.js +1 -0
  103. package/dist/chunks/bridgeConfig-D38y9eXn.js +1 -0
  104. package/dist/chunks/bridgeConfig-EwUq__ct.js +1 -0
  105. package/dist/chunks/bridgeConfig-GYR-LUiu.js +1 -0
  106. package/dist/chunks/bridgeEnabled-DKqmLnKO.js +1 -0
  107. package/dist/chunks/bridgeEnabled-DZIGDtfY.js +1 -0
  108. package/dist/chunks/bridgeMain-CXVks2ND.js +1 -0
  109. package/dist/chunks/bridgeMain-D4nsECwJ.js +68 -0
  110. package/dist/chunks/bridgeMessaging-BUOZU_ba.js +1 -0
  111. package/dist/chunks/bridgePointer-BpzIEsD_.js +1 -0
  112. package/dist/chunks/browser-D1vC3BNd.js +1 -0
  113. package/dist/chunks/btw-CVXJwoXo.js +1 -0
  114. package/dist/chunks/buddy-BLcvL8lP.js +3 -0
  115. package/dist/chunks/bundledMode-DQNSSQbt.js +1 -0
  116. package/dist/chunks/caches-BrfvzKn5.js +1 -0
  117. package/dist/chunks/caches-CkSv3MfC.js +3 -0
  118. package/dist/chunks/capacityWake-BWCSatN6.js +1 -0
  119. package/dist/chunks/changeDetector-DEZU6tum.js +1 -0
  120. package/dist/chunks/changeDetector-Df7c6U3d.js +1 -0
  121. package/dist/chunks/channelAllowlist-BApjAS0V.js +1 -0
  122. package/dist/chunks/channelNotification-BjWwF85R.js +1 -0
  123. package/dist/chunks/channelNotification-D01YVwNj.js +1 -0
  124. package/dist/chunks/chokidar-DPwMBcWI.js +1 -0
  125. package/dist/chunks/chokidar-DkDXNCTz.js +1 -0
  126. package/dist/chunks/chrome-D7coxEOI.js +1 -0
  127. package/dist/chunks/chromeNativeHost-CPj9M_4-.js +1 -0
  128. package/dist/chunks/chunk-DR8-3Aex.js +1 -0
  129. package/dist/chunks/classPrivateFieldSet2-DZkxcFPS.js +1 -0
  130. package/dist/chunks/claudeAiLimitsHook-ATshVrOH.js +1 -0
  131. package/dist/chunks/claudeDesktop-PVa9tWsM.js +1 -0
  132. package/dist/chunks/cleanup-C-PGmKpV.js +1 -0
  133. package/dist/chunks/clear-CxGE9Ntr.js +1 -0
  134. package/dist/chunks/cliLaunch-CMXoY_LO.js +1 -0
  135. package/dist/chunks/client-BWED8Tbu.js +35 -0
  136. package/dist/chunks/client-CinDjeSq.js +7 -0
  137. package/dist/chunks/client-CpXGg9e0.js +1 -0
  138. package/dist/chunks/color-B3w_VQTn.js +1 -0
  139. package/dist/chunks/color-convert-BQZnVz_5.js +1 -0
  140. package/dist/chunks/commands-DFp48zwy.js +1 -0
  141. package/dist/chunks/commitAttribution-B0cXmbvv.js +2 -0
  142. package/dist/chunks/commitAttribution-DRSKRoH6.js +1 -0
  143. package/dist/chunks/common-BX7bn3hg.js +1 -0
  144. package/dist/chunks/common-Ce3LanTX.js +1 -0
  145. package/dist/chunks/common-DdLQuE2_.js +1 -0
  146. package/dist/chunks/common-HfKcqOYK.js +1 -0
  147. package/dist/chunks/compact-C8ljGMdo.js +3 -0
  148. package/dist/chunks/companion-mD1jw6xX.js +1 -0
  149. package/dist/chunks/completionCache-BqQXVTa9.js +1 -0
  150. package/dist/chunks/completionCache-BtP4vfAi.js +4 -0
  151. package/dist/chunks/computerUseLock-ADE_PhIK.js +1 -0
  152. package/dist/chunks/config-CmyaIIOY.js +1 -0
  153. package/dist/chunks/config-Rl1Y_Dtq.js +1 -0
  154. package/dist/chunks/connectHeadless-MFABhXpz.js +1 -0
  155. package/dist/chunks/constants-BM62Vf_X.js +1 -0
  156. package/dist/chunks/constants-BfXy-5cI.js +1 -0
  157. package/dist/chunks/context-BeiZkUNq.js +1 -0
  158. package/dist/chunks/context-noninteractive-CRdF3iv8.js +54 -0
  159. package/dist/chunks/controlMessageCompat-591iGHUK.js +1 -0
  160. package/dist/chunks/conversation-BoguXZEI.js +1 -0
  161. package/dist/chunks/conversation-yhs7tT-g.js +1 -0
  162. package/dist/chunks/copy-BpeUcqku.js +7 -0
  163. package/dist/chunks/createSSHSession-B3JOB4TE.js +6 -0
  164. package/dist/chunks/createSession-BJSnFBGt.js +1 -0
  165. package/dist/chunks/createSession-CnRHI3RU.js +1 -0
  166. package/dist/chunks/cron-iqTFGIos.js +1 -0
  167. package/dist/chunks/cronScheduler-zRXhgEEU.js +6 -0
  168. package/dist/chunks/cronTasks-CMJldfoP.js +2 -0
  169. package/dist/chunks/crossProjectResume-DxO6TX30.js +40 -0
  170. package/dist/chunks/cwd-B2guYBbl.js +1 -0
  171. package/dist/chunks/cwd-B5bbyUwz.js +1 -0
  172. package/dist/chunks/cwd-BXiaJzLh.js +1 -0
  173. package/dist/chunks/daemon-B3v4OoOu.js +2 -0
  174. package/dist/chunks/dangerousBackend-OmCzoW35.js +1 -0
  175. package/dist/chunks/datadog-3-Vvz0yz.js +1 -0
  176. package/dist/chunks/datadog-BQlp3bTs.js +1 -0
  177. package/dist/chunks/debug-BDBIipC1.js +2 -0
  178. package/dist/chunks/debug-C7tW7DFW.js +1 -0
  179. package/dist/chunks/debug-CjIaNjpK.js +5 -0
  180. package/dist/chunks/debugUtils-Dsg-UHeg.js +1 -0
  181. package/dist/chunks/defineProperty-CaCI0a5T.js +1 -0
  182. package/dist/chunks/desktop-C_SS0068.js +1 -0
  183. package/dist/chunks/detached-B7RNZeyl.js +5 -0
  184. package/dist/chunks/detect-libc-DFFGDzPC.js +1 -0
  185. package/dist/chunks/detectRepository-BnTCJAXR.js +1 -0
  186. package/dist/chunks/detectRepository-Gobn9eFt.js +1 -0
  187. package/dist/chunks/detection-CN_uLGU2.js +1 -0
  188. package/dist/chunks/detection-DW6grIlc.js +1 -0
  189. package/dist/chunks/diff-B8YmRG5T.js +1 -0
  190. package/dist/chunks/directoryCompletion-J560aATd.js +1 -0
  191. package/dist/chunks/dist-B1wOprSs.js +29 -0
  192. package/dist/chunks/dist-DZQOarNX.js +5 -0
  193. package/dist/chunks/dist-HZfkKiUF.js +20 -0
  194. package/dist/chunks/dist-es-4xyrZoNc2.js +1 -0
  195. package/dist/chunks/dist-es-6kjvVbJd.js +1 -0
  196. package/dist/chunks/dist-es-BJldFHbt.js +3 -0
  197. package/dist/chunks/dist-es-BM013UFT.js +1 -0
  198. package/dist/chunks/dist-es-BPPewn1A.js +1 -0
  199. package/dist/chunks/dist-es-BZGG3Hnm.js +1 -0
  200. package/dist/chunks/dist-es-BZjJL64k2.js +1 -0
  201. package/dist/chunks/dist-es-BctcPxLN.js +1 -0
  202. package/dist/chunks/dist-es-Bf2jR30y.js +1 -0
  203. package/dist/chunks/dist-es-BgLoR-hQ.js +1 -0
  204. package/dist/chunks/dist-es-BismPcTW.js +1 -0
  205. package/dist/chunks/dist-es-BrPzXmSP.js +1 -0
  206. package/dist/chunks/dist-es-Bu21Wvhs.js +1 -0
  207. package/dist/chunks/dist-es-BuWNNAXW.js +1 -0
  208. package/dist/chunks/dist-es-Bz11sFiK2.js +1 -0
  209. package/dist/chunks/dist-es-C5VplyPL2.js +5 -0
  210. package/dist/chunks/dist-es-C66BuLgn.js +1 -0
  211. package/dist/chunks/dist-es-CCIzgNln2.js +1 -0
  212. package/dist/chunks/dist-es-CLyx7Kge2.js +1 -0
  213. package/dist/chunks/dist-es-CUbatGdn.js +1 -0
  214. package/dist/chunks/dist-es-CYe_-TbD.js +1 -0
  215. package/dist/chunks/dist-es-C_IHUdzL.js +1 -0
  216. package/dist/chunks/dist-es-Ci_rKlMr.js +1 -0
  217. package/dist/chunks/dist-es-ClDZBAj7.js +1 -0
  218. package/dist/chunks/dist-es-Cp--qjOi.js +1 -0
  219. package/dist/chunks/dist-es-CzE4kW1L.js +9 -0
  220. package/dist/chunks/dist-es-DUg5w7-v.js +1 -0
  221. package/dist/chunks/dist-es-Dl0ZRczY.js +1 -0
  222. package/dist/chunks/dist-es-Do_155z5.js +1 -0
  223. package/dist/chunks/dist-es-DxIM0jd82.js +1 -0
  224. package/dist/chunks/dist-es-Fav2oBDs.js +1 -0
  225. package/dist/chunks/dist-es-TZjwPaGn.js +1 -0
  226. package/dist/chunks/dist-es-W22ud2el2.js +1 -0
  227. package/dist/chunks/dist-es-aU8-02YH.js +1 -0
  228. package/dist/chunks/dist-es-b3yZSGx82.js +1 -0
  229. package/dist/chunks/dist-es-dIP5JtXz.js +5 -0
  230. package/dist/chunks/dist-es-mQ4HvnYs2.js +1 -0
  231. package/dist/chunks/distRoot-CJaacAHy.js +1 -0
  232. package/dist/chunks/doctor-DLZPF4iY.js +1 -0
  233. package/dist/chunks/earlyInput-BTI1CSNt.js +2 -0
  234. package/dist/chunks/earlyInput-BwGtzhhP.js +1 -0
  235. package/dist/chunks/effort-BaHvpBWr.js +9 -0
  236. package/dist/chunks/entry-_e-lyRwv.js +14 -0
  237. package/dist/chunks/env-CesrOJJq.js +1 -0
  238. package/dist/chunks/envLessBridgeConfig-4oys0_9A.js +1 -0
  239. package/dist/chunks/envLessBridgeConfig-DJ1Sts3F.js +1 -0
  240. package/dist/chunks/envUtils-CFG7IQID.js +1 -0
  241. package/dist/chunks/errorLogSink-Ti4Suoz6.js +2 -0
  242. package/dist/chunks/escHotkey-CVn_80xM.js +259 -0
  243. package/dist/chunks/esm-BFnjHW38.js +1 -0
  244. package/dist/chunks/esm-BQg_LX3V.js +1 -0
  245. package/dist/chunks/esm-BtC6CMmM.js +1 -0
  246. package/dist/chunks/esm-BwzC0MQp.js +1 -0
  247. package/dist/chunks/esm-CFybeQ_Q.js +1 -0
  248. package/dist/chunks/esm-CK-5CT5X.js +1 -0
  249. package/dist/chunks/esm-CL1OwlZB.js +1 -0
  250. package/dist/chunks/esm-CMzgSTAl.js +1 -0
  251. package/dist/chunks/esm-CPE_H2Lx.js +1 -0
  252. package/dist/chunks/esm-CcWquv5a.js +10 -0
  253. package/dist/chunks/esm-CeNEpRZt.js +1 -0
  254. package/dist/chunks/esm-D7hykoRB.js +1 -0
  255. package/dist/chunks/esm-DUtcefEV.js +1 -0
  256. package/dist/chunks/esm-DhrUwJBp.js +1 -0
  257. package/dist/chunks/esm-Duu1fRQ8.js +1 -0
  258. package/dist/chunks/esm-Ght2BaU2.js +1 -0
  259. package/dist/chunks/esm-Q6Yz2GMx.js +56 -0
  260. package/dist/chunks/esm-WONEiurY.js +13 -0
  261. package/dist/chunks/event-streams-BumpU1aB.js +1 -0
  262. package/dist/chunks/eventLoopStallDetector-DxyFdg1h.js +1 -0
  263. package/dist/chunks/execAsync-ChKxDZ8C.js +1 -0
  264. package/dist/chunks/execFileNoThrow-DdmR1mBS.js +1 -0
  265. package/dist/chunks/execSyncWrapper-Ch4TNj8u.js +1 -0
  266. package/dist/chunks/execa-BMaINL7N.js +34 -0
  267. package/dist/chunks/executor-C7INr19-.js +1 -0
  268. package/dist/chunks/executor-Dnf3YYma.js +1604 -0
  269. package/dist/chunks/exit-BakzsOD0.js +1 -0
  270. package/dist/chunks/exit-CiDn2tN9.js +2 -0
  271. package/dist/chunks/export-b-6pqMqz.js +2 -0
  272. package/dist/chunks/exportRenderer-RxtEIyTm.js +1 -0
  273. package/dist/chunks/extra-usage-7EPJNjNW.js +1 -0
  274. package/dist/chunks/extra-usage-ChvuewCq.js +1 -0
  275. package/dist/chunks/extra-usage-core-BVhLtoDF.js +1 -0
  276. package/dist/chunks/extra-usage-noninteractive-_Njh6q-q.js +1 -0
  277. package/dist/chunks/extraUsage-qOBMQB6g.js +1 -0
  278. package/dist/chunks/extractMemories-CRBVNiG1.js +1 -0
  279. package/dist/chunks/fast-C4uw_g7o.js +1 -0
  280. package/dist/chunks/fast-CEaIzaPl.js +1 -0
  281. package/dist/chunks/featureCheck-B1GSTyhh.js +1 -0
  282. package/dist/chunks/featureCheck-DKigAPal.js +1 -0
  283. package/dist/chunks/feedback-Bf3TjjuD.js +1 -0
  284. package/dist/chunks/figures-fES5sASd.js +1 -0
  285. package/dist/chunks/fileStateCache-DAsLEZau.js +1 -0
  286. package/dist/chunks/files-B-m_4X8b.js +2 -0
  287. package/dist/chunks/findExecutable-D8vJrFnO.js +1 -0
  288. package/dist/chunks/firstPartyEventLogger-BtrGagNa.js +1 -0
  289. package/dist/chunks/flushGate-2zqab-Pp.js +1 -0
  290. package/dist/chunks/foundry-sdk-CtX8C0x3.js +1 -0
  291. package/dist/chunks/fpsMetrics-ts_jaF3g.js +1 -0
  292. package/dist/chunks/fuse-ivQ_eRwF.js +1 -0
  293. package/dist/chunks/gates-CmKoQ0O-.js +1 -0
  294. package/dist/chunks/gates-_wbPDQ3M.js +1 -0
  295. package/dist/chunks/gemini-DRx495gn.js +3 -0
  296. package/dist/chunks/generateRecap-Cv8gd_QF.js +1 -0
  297. package/dist/chunks/generateSessionName-Dpjg-u_x.js +1 -0
  298. package/dist/chunks/genericProcessUtils-BFJMxLqn.js +23 -0
  299. package/dist/chunks/getMachineId-bsd-C9pL9Ajr.js +1 -0
  300. package/dist/chunks/getMachineId-darwin-Ma4F9rJg.js +2 -0
  301. package/dist/chunks/getMachineId-linux-C0lXMqsj.js +1 -0
  302. package/dist/chunks/getMachineId-unsupported-ByHQTXat.js +1 -0
  303. package/dist/chunks/getMachineId-win-DZsXZmTz.js +1 -0
  304. package/dist/chunks/git-Bj8Ow4pJ.js +6 -0
  305. package/dist/chunks/git-Q_b4oZ17.js +1 -0
  306. package/dist/chunks/githubRepoPathMapping-DGivBX9h.js +1 -0
  307. package/dist/chunks/goal-BrHEJv8o.js +3 -0
  308. package/dist/chunks/goalStorage-CsuPOQbk.js +1 -0
  309. package/dist/chunks/graceful-fs-BuPWC-vB.js +2 -0
  310. package/dist/chunks/grok-CDkDDaY_.js +1 -0
  311. package/dist/chunks/growthbook-D3_Cr9n-.js +1 -0
  312. package/dist/chunks/growthbook-p4aJ_UMv.js +32 -0
  313. package/dist/chunks/hash-KW-tVnPp.js +1 -0
  314. package/dist/chunks/heapdump-CloylIZ9.js +5 -0
  315. package/dist/chunks/help-DpSJlHIc.js +1 -0
  316. package/dist/chunks/hooks-2pogt8nv.js +79 -0
  317. package/dist/chunks/hooks-BBODdwnE.js +1 -0
  318. package/dist/chunks/hostAdapter-B5KTUqhv.js +1 -0
  319. package/dist/chunks/hostGuard-DyWr2TwE.js +1 -0
  320. package/dist/chunks/httpAuthSchemes-CgPbtGos.js +13 -0
  321. package/dist/chunks/ide-CJEcfBZq.js +2 -0
  322. package/dist/chunks/inboundAttachments-RNpYpRTO.js +1 -0
  323. package/dist/chunks/index.min-DCDiLq-j.js +1 -0
  324. package/dist/chunks/initReplBridge-D2E6IM2B.js +1 -0
  325. package/dist/chunks/initReplBridge-p2uwDBPx.js +1 -0
  326. package/dist/chunks/insights-DnpZScKs.js +822 -0
  327. package/dist/chunks/install-D_vTxUlG.js +1 -0
  328. package/dist/chunks/install-github-app-BK8A7g3i.js +147 -0
  329. package/dist/chunks/install-slack-app-C47R9VoI.js +1 -0
  330. package/dist/chunks/instinctParser-DxKdI3JC.js +1 -0
  331. package/dist/chunks/instrumentation-DkdAJFrZ.js +12 -0
  332. package/dist/chunks/intl-Pse97ORk.js +1 -0
  333. package/dist/chunks/isObject-DaxDnPKm.js +1 -0
  334. package/dist/chunks/isSymbol-D7QeUnS5.js +1 -0
  335. package/dist/chunks/job-opl00C4l.js +2 -0
  336. package/dist/chunks/json-bigint-BRRVs1dv.js +8 -0
  337. package/dist/chunks/jsx-runtime-BTgGEFjL.js +1 -0
  338. package/dist/chunks/jws-B_ieuaZg.js +3 -0
  339. package/dist/chunks/jwtUtils-D-tJzoJY.js +1 -0
  340. package/dist/chunks/keybindings-mRf9VSe8.js +2 -0
  341. package/dist/chunks/lang-eH4EJErj.js +1 -0
  342. package/dist/chunks/language-DD9ar6RA.js +1 -0
  343. package/dist/chunks/language-EZLNdETg.js +1 -0
  344. package/dist/chunks/launchAgentsPlatform-Cq0_7-IM.js +1 -0
  345. package/dist/chunks/launchAutofixPr-Bw7aUHUs.js +18 -0
  346. package/dist/chunks/launchCommand-Bk1Fn-qZ.js +1 -0
  347. package/dist/chunks/launchLocalMemory-CLBCUgwd.js +3 -0
  348. package/dist/chunks/launchLocalVault-BfWJWrBg.js +3 -0
  349. package/dist/chunks/launchMemoryStores-DdnSVSDZ.js +1 -0
  350. package/dist/chunks/launchOnboarding-ziCEX3GI.js +8 -0
  351. package/dist/chunks/launchSchedule-G_c7sgmy.js +1 -0
  352. package/dist/chunks/launchSkillStore-Z1Kd7nCg.js +1 -0
  353. package/dist/chunks/launchTeleport-Dp9AFbPx.js +3 -0
  354. package/dist/chunks/launchVault-hwK-Ljek.js +1 -0
  355. package/dist/chunks/lazySchema-2sOku3cX.js +1 -0
  356. package/dist/chunks/lib-BHRYgENJ.js +8 -0
  357. package/dist/chunks/lib-DRyNc7xD.js +2 -0
  358. package/dist/chunks/lib-Ddq71jM5.js +14 -0
  359. package/dist/chunks/loadAgentsDir-Bz0FfcVt.js +5620 -0
  360. package/dist/chunks/loadAgentsDir-CLM0ws7u.js +1 -0
  361. package/dist/chunks/loadPluginHooks-B5SIS2uo.js +1 -0
  362. package/dist/chunks/loadSso-RY87rrJO.js +1 -0
  363. package/dist/chunks/localSearch-BLF6PSv2.js +1 -0
  364. package/dist/chunks/localSearch-CTycGe3E.js +1 -0
  365. package/dist/chunks/localSearch-inDahM8I.js +1 -0
  366. package/dist/chunks/lockfile--gk1HDM6.js +1 -0
  367. package/dist/chunks/log-B-Nj3Yed.js +1 -0
  368. package/dist/chunks/log-DVv8YiNo.js +1 -0
  369. package/dist/chunks/login-BeLvLowc.js +1 -0
  370. package/dist/chunks/login-DUUOeNoz.js +1 -0
  371. package/dist/chunks/logoV2Utils-D5SpeZ3C.js +1 -0
  372. package/dist/chunks/logout-C2QuTBdS.js +1 -0
  373. package/dist/chunks/magicDocs-CUXKi-Wv.js +57 -0
  374. package/dist/chunks/main-CFhpWtpC.js +1420 -0
  375. package/dist/chunks/main-sboa5RKc.js +31 -0
  376. package/dist/chunks/mappers-DLkk0PZz.js +1 -0
  377. package/dist/chunks/mcp-C2f6IgAp.js +2 -0
  378. package/dist/chunks/mcp-Djui9m3_.js +6 -0
  379. package/dist/chunks/mcp-DvTSxrJ4.js +1 -0
  380. package/dist/chunks/mcpServer-DMA0bdFC.js +1 -0
  381. package/dist/chunks/mcpServer-DxEHfW2v.js +1 -0
  382. package/dist/chunks/memoize-Bg2dXTzV.js +1 -0
  383. package/dist/chunks/memoize-DNnuA2aU.js +1 -0
  384. package/dist/chunks/memory-B9io9Zcv.js +1 -0
  385. package/dist/chunks/mobile-CPnnvkQV.js +2 -0
  386. package/dist/chunks/modalContext-B1b0Gsro.js +1 -0
  387. package/dist/chunks/mode-BDgwh_Xb.js +2 -0
  388. package/dist/chunks/model-B6cpEh-s.js +1 -0
  389. package/dist/chunks/model-BcunOCC9.js +1 -0
  390. package/dist/chunks/modelOptions-CHUHQ9WG.js +1 -0
  391. package/dist/chunks/normalization-cjPqid31.js +1 -0
  392. package/dist/chunks/oauth-CnBLewrU.js +1 -0
  393. package/dist/chunks/oauth-DMPGYAoZ.js +1 -0
  394. package/dist/chunks/observationStore-DVBxrSdI.js +4 -0
  395. package/dist/chunks/onChangeAppState-M61XDN6V.js +1 -0
  396. package/dist/chunks/open-CsUNPSNx.js +1 -0
  397. package/dist/chunks/openai-BHvlYW3m.js +2 -0
  398. package/dist/chunks/output-style-BtKuBrs4.js +1 -0
  399. package/dist/chunks/outputStyles-hHuIBkRB.js +84 -0
  400. package/dist/chunks/overageCreditGrant-BLFT-rF3.js +1 -0
  401. package/dist/chunks/p-map-C-WNcN6g.js +1 -0
  402. package/dist/chunks/p-map-CQ2NythB.js +1 -0
  403. package/dist/chunks/package-9IAs5Qf0.js +1 -0
  404. package/dist/chunks/panel-27xLZI7c.js +1 -0
  405. package/dist/chunks/panel-NoDfShEZ.js +1 -0
  406. package/dist/chunks/panelCall-CEOWVNCM.js +1 -0
  407. package/dist/chunks/parseConnectUrl-CxU4IX9o.js +1 -0
  408. package/dist/chunks/parser-DGlAnaNj.js +1 -0
  409. package/dist/chunks/parser-DGoLe2RS.js +1 -0
  410. package/dist/chunks/passes-CExcqu66.js +1 -0
  411. package/dist/chunks/path-uaxlnhva.js +1 -0
  412. package/dist/chunks/permissions-B3PceQul.js +1 -0
  413. package/dist/chunks/permissions-DezIL2xF.js +3 -0
  414. package/dist/chunks/permissions-DnpI8Whh.js +1 -0
  415. package/dist/chunks/pipeTransport-CB_Wq_Kx.js +1 -0
  416. package/dist/chunks/plan-cfZBclh9.js +1 -0
  417. package/dist/chunks/platform-BXz_rgpy.js +2 -0
  418. package/dist/chunks/plist-DLGDWBD6.js +6 -0
  419. package/dist/chunks/plugin-CuhENLRs.js +1 -0
  420. package/dist/chunks/pluginAutoupdate-wTeOXfQe.js +1 -0
  421. package/dist/chunks/pluginBlocklist-D6pkKfXr.js +1 -0
  422. package/dist/chunks/pluginCliCommands-DqxdCwsq.js +1 -0
  423. package/dist/chunks/pluginFlagging-CjH48f-K.js +1 -0
  424. package/dist/chunks/pluginOperations-DMFYB3pK.js +2 -0
  425. package/dist/chunks/pluginStartupCheck-BW3_KfZz.js +1 -0
  426. package/dist/chunks/pluginStartupCheck-Cj2BMjVw.js +1 -0
  427. package/dist/chunks/plugins-CarsG2v8.js +4 -0
  428. package/dist/chunks/policyLimits-DFn1vHkN.js +1 -0
  429. package/dist/chunks/pollConfig-C8nODJY1.js +1 -0
  430. package/dist/chunks/poller-DXZJ-dUP.js +1 -0
  431. package/dist/chunks/poor-C7GQ4a5X.js +1 -0
  432. package/dist/chunks/poorMode-CBe0rfxB.js +1 -0
  433. package/dist/chunks/poorMode-CbZTudtw.js +1 -0
  434. package/dist/chunks/postCommitAttribution--vvAWIqD.js +1 -0
  435. package/dist/chunks/print-CwwtGSbK.js +114 -0
  436. package/dist/chunks/privacy-settings-Bz8cAVp5.js +11 -0
  437. package/dist/chunks/privacyLevel-CRCHhztk.js +1 -0
  438. package/dist/chunks/process-CnhUplBr.js +1 -0
  439. package/dist/chunks/process-X4vCP9x0.js +1 -0
  440. package/dist/chunks/processBashCommand-NL0YEUqW.js +3 -0
  441. package/dist/chunks/processSlashCommand-FPMWElsI.js +6 -0
  442. package/dist/chunks/processSlashCommand-_oJs6_w8.js +6 -0
  443. package/dist/chunks/processUserInput-QAJK0XSn.js +1 -0
  444. package/dist/chunks/projectContext-B21hXj9q.js +1 -0
  445. package/dist/chunks/projectContext-DbTQHQS3.js +1 -0
  446. package/dist/chunks/prompt-C6eleu4x.js +1 -0
  447. package/dist/chunks/prompt-CUdoQXyN.js +1 -0
  448. package/dist/chunks/prompt-CsBCtw4l.js +228 -0
  449. package/dist/chunks/prompt-hnIDYhP4.js +54 -0
  450. package/dist/chunks/promptEditor-CrlVcc17.js +4 -0
  451. package/dist/chunks/protectedNamespace-Cn4901XG.js +1 -0
  452. package/dist/chunks/protocolHandler-DM_w7sJ5.js +13 -0
  453. package/dist/chunks/protocols-CpoQzjyI.js +7 -0
  454. package/dist/chunks/proxy-9WvtUy8E.js +99 -0
  455. package/dist/chunks/rate-limit-options-BehQ3MoX.js +1 -0
  456. package/dist/chunks/rcDebugLog-BbHlIxCm.js +11 -0
  457. package/dist/chunks/referral-BfAZEIZL.js +1 -0
  458. package/dist/chunks/refresh-Bl3Miver.js +1 -0
  459. package/dist/chunks/registerProtocol-BHZ3vZED.js +36 -0
  460. package/dist/chunks/registerSkillHooks-BR7v5qDA.js +1 -0
  461. package/dist/chunks/registry-C2igpRd-.js +1 -0
  462. package/dist/chunks/release-notes-C_Cou6ye.js +4 -0
  463. package/dist/chunks/releaseNotes-DveQShyB.js +2 -0
  464. package/dist/chunks/reload-plugins-D-pAUoB5.js +1 -0
  465. package/dist/chunks/remote-env-C_dBgbgo.js +1 -0
  466. package/dist/chunks/remoteBridgeCore-BxWhTy1u.js +1 -0
  467. package/dist/chunks/remoteControlServer-D3OjUlB-.js +3 -0
  468. package/dist/chunks/rename-f3m0ETSt.js +1 -0
  469. package/dist/chunks/renderOptions-QZLxGnh_.js +1 -0
  470. package/dist/chunks/replBridge-qeVmCJOb.js +1 -0
  471. package/dist/chunks/resume-CM_8p9Iu.js +2 -0
  472. package/dist/chunks/rewind-0cB7o6fx.js +1 -0
  473. package/dist/chunks/ripgrep-BEWqxrpl.js +5 -0
  474. package/dist/chunks/ripgrep-G82m12Ng.js +1 -0
  475. package/dist/chunks/rollback-CVo2gqgR.js +11 -0
  476. package/dist/chunks/runtimeObserver-1EdvvoYw.js +1 -0
  477. package/dist/chunks/runtimeObserver-CX6vepq9.js +10 -0
  478. package/dist/chunks/sandbox-adapter-DzHfW2tH.js +1 -0
  479. package/dist/chunks/sandbox-toggle-N6KgmH2T.js +1 -0
  480. package/dist/chunks/sanitization-CIBpY9KT.js +1 -0
  481. package/dist/chunks/satisfies-B7ZvBUQP.js +1 -0
  482. package/dist/chunks/schemas-Bwt-7U5W.js +40 -0
  483. package/dist/chunks/sdk-Drp69kIx.js +1 -0
  484. package/dist/chunks/sdkHeapDumpMonitor-B9GVkISU.js +1 -0
  485. package/dist/chunks/searchExtraTools-BphNJsl8.js +1 -0
  486. package/dist/chunks/semver-BsItM2Z4.js +1 -0
  487. package/dist/chunks/semver-D3lOjiBN.js +1 -0
  488. package/dist/chunks/sentry-ySzRCXGd.js +1 -0
  489. package/dist/chunks/server-C8nMDji6.js +1 -0
  490. package/dist/chunks/server-XZG51Slr.js +1 -0
  491. package/dist/chunks/serverBanner-D68EBGzH.js +1 -0
  492. package/dist/chunks/serverLog-hv2hc5US.js +1 -0
  493. package/dist/chunks/session-CVoGFb8a.js +2 -0
  494. package/dist/chunks/sessionDataUploader-BaD1Q7v3.js +1 -0
  495. package/dist/chunks/sessionDiscovery-D7g66TX6.js +1 -0
  496. package/dist/chunks/sessionFileAccessHooks-9lPjspRX.js +1 -0
  497. package/dist/chunks/sessionManager-BhOjMNAP.js +1 -0
  498. package/dist/chunks/sessionMemory-BA6cdxqP.js +1 -0
  499. package/dist/chunks/sessionMemory-CtEhIRGF.js +1 -0
  500. package/dist/chunks/sessionMemoryUtils-D_B92ypa.js +1 -0
  501. package/dist/chunks/sessionObserver-CESI-uVZ.js +1 -0
  502. package/dist/chunks/sessionObserver-SpE_eglb.js +20 -0
  503. package/dist/chunks/sessionRestore-DqsqYK4K.js +1 -0
  504. package/dist/chunks/sessionState-Dgky34M4.js +1 -0
  505. package/dist/chunks/sessionStorage-DJb5HKhQ.js +1 -0
  506. package/dist/chunks/sessionStorage-DSMfHTcg.js +1 -0
  507. package/dist/chunks/sessionStoragePortable-DyM_hZnp.js +3 -0
  508. package/dist/chunks/sessionTitle-Bzxk_EW9.js +14 -0
  509. package/dist/chunks/sessionTracing-DR8O0686.js +12 -0
  510. package/dist/chunks/setup-BHNS9sBS.js +9 -0
  511. package/dist/chunks/setup-BafJxZ0F.js +4 -0
  512. package/dist/chunks/setup-MLNNYLi6.js +1 -0
  513. package/dist/chunks/shadowedRuleDetection-Ch9gTxfD.js +1 -0
  514. package/dist/chunks/shellQuote-3s6tV-hK.js +1 -0
  515. package/dist/chunks/sideQuestion-BBn6XIOD.js +20 -0
  516. package/dist/chunks/signal-BTxmab6r.js +1 -0
  517. package/dist/chunks/signin-ChbUAEGq.js +1 -0
  518. package/dist/chunks/sink-B1qICbRh.js +1 -0
  519. package/dist/chunks/sink-yBIcxQf1.js +1 -0
  520. package/dist/chunks/sinks-C7weduDR.js +1 -0
  521. package/dist/chunks/skill-learning-08nEdOJ2.js +5 -0
  522. package/dist/chunks/skillGapStore-CuvWGqFb.js +5 -0
  523. package/dist/chunks/skillGapStore-DmMuDXKO.js +1 -0
  524. package/dist/chunks/skillGenerator-mEMjcmmm.js +8 -0
  525. package/dist/chunks/skillLearning-B3a-8Ys3.js +1 -0
  526. package/dist/chunks/skillLearning-q5T6o0mH.js +1 -0
  527. package/dist/chunks/skillPanel-BuUMhONI.js +28 -0
  528. package/dist/chunks/skillSearchPanel-BUEv7Sm9.js +21 -0
  529. package/dist/chunks/skillUsageTracking-BBTiWOKB.js +1 -0
  530. package/dist/chunks/skills-DvQuQfDW.js +1 -0
  531. package/dist/chunks/slashCommandParsing-BkTC3GRb.js +1 -0
  532. package/dist/chunks/sleep-CC8jykQd.js +1 -0
  533. package/dist/chunks/slowOperations-niPqC54V.js +1 -0
  534. package/dist/chunks/sprites-C5X62Vyh.js +1 -0
  535. package/dist/chunks/src-58uAJYF_.js +6 -0
  536. package/dist/chunks/src-7Y8fx6gl.js +2 -0
  537. package/dist/chunks/src-BuserDTl.js +1 -0
  538. package/dist/chunks/src-CMY4XoRy.js +1 -0
  539. package/dist/chunks/src-CfeAM1FB.js +1 -0
  540. package/dist/chunks/src-CxT2FDXy.js +1 -0
  541. package/dist/chunks/src-CyQf7rVu.js +26 -0
  542. package/dist/chunks/src-DJLbU8sT.js +1 -0
  543. package/dist/chunks/src-DJQlyVK6.js +5 -0
  544. package/dist/chunks/src-DNHWYkls.js +53 -0
  545. package/dist/chunks/src-DU_g0n_Q.js +1 -0
  546. package/dist/chunks/src-DhqzQjMg.js +19 -0
  547. package/dist/chunks/src-Duzv1Znh.js +1 -0
  548. package/dist/chunks/src-OBx6GAig.js +1 -0
  549. package/dist/chunks/src-WjnK2Dbo.js +1 -0
  550. package/dist/chunks/src-hjAMxWFj.js +7 -0
  551. package/dist/chunks/src-lLwoqdC0.js +9 -0
  552. package/dist/chunks/src-yRsWbJp_.js +2 -0
  553. package/dist/chunks/sso-oidc-yfC-A2A2.js +1 -0
  554. package/dist/chunks/startupProfiler-4P7GdVw6.js +3 -0
  555. package/dist/chunks/startupProfiler-CipS0otN.js +1 -0
  556. package/dist/chunks/state-9wSimHaL.js +1 -0
  557. package/dist/chunks/state-BQkyHx88.js +1 -0
  558. package/dist/chunks/state-CEAUTY3A.js +1 -0
  559. package/dist/chunks/state-CUZTq6r0.js +1 -0
  560. package/dist/chunks/state-U0HNbTx8.js +1 -0
  561. package/dist/chunks/staticRender-BB3CisKd.js +1 -0
  562. package/dist/chunks/stats-Dyi2U_mq.js +1 -0
  563. package/dist/chunks/status-CSL-GMou.js +1 -0
  564. package/dist/chunks/statusNoticeHelpers-BaXE951d.js +1 -0
  565. package/dist/chunks/stdio-BuUJYJFs.js +3 -0
  566. package/dist/chunks/stdio-iX0TTmbp.js +1 -0
  567. package/dist/chunks/stickers-2CRSckfH.js +1 -0
  568. package/dist/chunks/store-DdfsZvtr.js +1 -0
  569. package/dist/chunks/stringUtils-U7kMYMJq.js +4 -0
  570. package/dist/chunks/sts-CJmdeT7s.js +1 -0
  571. package/dist/chunks/subprocessEnv-DKTILev5.js +1 -0
  572. package/dist/chunks/subprocessEnv-WjRguKWf.js +1 -0
  573. package/dist/chunks/supports-color-DaytqqjM.js +1 -0
  574. package/dist/chunks/systemPromptSections-BnrxBWdc.js +1 -0
  575. package/dist/chunks/systemPromptSections-Dk6azdAb.js +1 -0
  576. package/dist/chunks/systemTheme-C1GNqIfy.js +1 -0
  577. package/dist/chunks/tag-C4cH016L.js +11 -0
  578. package/dist/chunks/tasks-CEdUW3RQ.js +1 -0
  579. package/dist/chunks/teamHelpers-CTA_CtTT.js +1 -0
  580. package/dist/chunks/teamHelpers-D65qZInv.js +1 -0
  581. package/dist/chunks/teammate-C-FiRloZ.js +1 -0
  582. package/dist/chunks/teammateModeSnapshot-DWRG5-Us.js +1 -0
  583. package/dist/chunks/teammateModeSnapshot-DtgsNj1G.js +1 -0
  584. package/dist/chunks/teleport-C_UgMy0V.js +1 -0
  585. package/dist/chunks/templateJobs-CMbS0tuk.js +12 -0
  586. package/dist/chunks/terminalSetup--jwGVap8.js +33 -0
  587. package/dist/chunks/terminalSetup-zID-wokH.js +1 -0
  588. package/dist/chunks/theme-C6XwTpVy.js +1 -0
  589. package/dist/chunks/thinkback-CVLnmLAT.js +1 -0
  590. package/dist/chunks/thinkback-MeOOO7gf.js +1 -0
  591. package/dist/chunks/thinkback-play-D7G260F4.js +1 -0
  592. package/dist/chunks/tmux-DtYJuTWh.js +1 -0
  593. package/dist/chunks/toolEventObserver-BtC9xDYY.js +1 -0
  594. package/dist/chunks/toolEventObserver-MfsHAt8h.js +1 -0
  595. package/dist/chunks/toolPool-CEi_2xIH.js +1 -0
  596. package/dist/chunks/toolPool-CdYJcCnc.js +1 -0
  597. package/dist/chunks/trustedDevice-CjQTGAa4.js +1 -0
  598. package/dist/chunks/trustedDevice-DADcxAAs.js +1 -0
  599. package/dist/chunks/tui-B8Ijq4Pk.js +6 -0
  600. package/dist/chunks/turndown.es-T-Xe93nc.js +69 -0
  601. package/dist/chunks/types-BVelRhgb.js +17 -0
  602. package/dist/chunks/types-Bqp3meR4.js +1 -0
  603. package/dist/chunks/types-CNmINIu3.js +1 -0
  604. package/dist/chunks/types-DgzOOCDl.js +3 -0
  605. package/dist/chunks/udsClient-ClY_0CKr.js +1 -0
  606. package/dist/chunks/ultrareviewCommand-CqvHj9Io.js +3 -0
  607. package/dist/chunks/undercover-CVCVOSrs.js +1 -0
  608. package/dist/chunks/undercover-CbxiJO2b.js +31 -0
  609. package/dist/chunks/up-CBJhVVbd.js +12 -0
  610. package/dist/chunks/updateCCB-DPPpquAw.js +11 -0
  611. package/dist/chunks/upgrade-DaaHOvft.js +1 -0
  612. package/dist/chunks/upgrade-k7ZvAWZ0.js +1 -0
  613. package/dist/chunks/upload-CEDxwMa1.js +1 -0
  614. package/dist/chunks/upstreamproxy-BtGJ2LRi.js +11 -0
  615. package/dist/chunks/usage-CsUSu4fb.js +1 -0
  616. package/dist/chunks/usage-oABvixCs.js +1 -0
  617. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CBce_-hb.js +1 -0
  618. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CLYjTZXb.js +1 -0
  619. package/dist/chunks/useKeybinding-DAQL_dB_.js +1 -0
  620. package/dist/chunks/useMainLoopModel-QC_H3esG.js +1 -0
  621. package/dist/chunks/useManageMCPConnections-bf-VfJGD.js +1 -0
  622. package/dist/chunks/useManagePlugins-CXdYUpit.js +1 -0
  623. package/dist/chunks/useMergedTools-DERzhQOJ.js +1 -0
  624. package/dist/chunks/useSearchInput-nqhdILI2.js +1 -0
  625. package/dist/chunks/useTerminalSize-DzV4aaTi.js +1 -0
  626. package/dist/chunks/useVoice-CO69xtWC.js +1 -0
  627. package/dist/chunks/util-C8wqPqv0.js +1 -0
  628. package/dist/chunks/utils-CDFsSXHr.js +1 -0
  629. package/dist/chunks/utils-ZO5TryVH.js +1 -0
  630. package/dist/chunks/v4-DLhvDPkt.js +1 -0
  631. package/dist/chunks/validatePlugin-C4cd71Yz.js +1 -0
  632. package/dist/chunks/vertex-sdk-CC3U26o7.js +9 -0
  633. package/dist/chunks/vim-BNiQx5Vf.js +1 -0
  634. package/dist/chunks/voice-BCbnJzYL.js +8 -0
  635. package/dist/chunks/voice-BJyz9KZO.js +8 -0
  636. package/dist/chunks/voice-CP2ULpju.js +2 -0
  637. package/dist/chunks/voiceModeEnabled-C-pa8B3Q.js +1 -0
  638. package/dist/chunks/voiceModeEnabled-CMtRN2pa.js +1 -0
  639. package/dist/chunks/voiceStreamSTT-31b2u0rj.js +1 -0
  640. package/dist/chunks/voiceStreamSTT-Fkhm6Ftg.js +1 -0
  641. package/dist/chunks/voiceStreamSTT-sI-hg-aP.js +1 -0
  642. package/dist/chunks/web-tools-CLmlPgLk.js +1 -0
  643. package/dist/chunks/which-C0ex-06E.js +1 -0
  644. package/dist/chunks/windowsPaths-C5TNvKYu.js +1 -0
  645. package/dist/chunks/windowsPaths-Kue_7s52.js +1 -0
  646. package/dist/chunks/workSecret-Dh5Ayceu.js +1 -0
  647. package/dist/chunks/workerRegistry-B5iWYqpK.js +1 -0
  648. package/dist/chunks/worktree-BypJA0GB.js +1 -0
  649. package/dist/chunks/worktreeModeEnabled-DPTdK3JV.js +1 -0
  650. package/dist/chunks/worktreeModeEnabled-Dtrcn7eD.js +1 -0
  651. package/dist/chunks/wrapper-BDPb4PTV.js +6 -0
  652. package/dist/chunks/wrapper-DRTs77RK.js +1 -0
  653. package/dist/chunks/xdg-BaVL-FHd.js +1 -0
  654. package/dist/chunks/xml-E8VMPwdJ.js +1 -0
  655. package/dist/chunks/zod-B_P2Eo_D.js +1 -0
  656. package/dist/cli-bun.js +2 -0
  657. package/dist/cli-node.js +2 -0
  658. package/dist/cli.js +2 -0
  659. package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
  660. package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
  661. package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
  662. package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
  663. package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
  664. package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
  665. package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
  666. package/package.json +233 -0
  667. package/scripts/postinstall.cjs +389 -0
  668. package/scripts/run-parallel.mjs +10 -0
  669. package/scripts/setup-chrome-mcp.mjs +70 -0
@@ -0,0 +1,157 @@
1
+ import{a as e,n as t,o as n,r}from"./chunk-DR8-3Aex.js";import{n as i,t as a}from"./memoize-DNnuA2aU.js";import{f as o,l as s,n as c,s as l,u}from"./envUtils-CFG7IQID.js";import{g as d}from"./client-BWED8Tbu.js";import{n as f,t as p}from"./defineProperty-CaCI0a5T.js";import{n as m,t as h}from"./figures-fES5sASd.js";import{p as g}from"./zod-B_P2Eo_D.js";import{n as _,t as v}from"./axios-Zh7qGPze.js";import{Cn as y,Ln as b,un as x,vt as S,wn as C,yn as w}from"./schemas-Bwt-7U5W.js";import{i as T,r as E,t as D}from"./v4-DLhvDPkt.js";import{A as O,B as k,Cn as A,Ct as j,F as ee,Ft as M,I as N,In as P,K as F,Kt as te,L as I,Ln as L,Lt as ne,M as re,O as ie,Q as ae,Rn as oe,St as se,T as ce,Tn as le,Tt as ue,U as de,Ut as fe,Wt as pe,Yt as R,Z as me,at as he,b as z,ct as ge,en as _e,f as ve,g as B,gn as ye,h as V,k as be,m as xe,nt as Se,ot as Ce,p as we,qt as Te,t as H,tn as Ee,tt as De,v as Oe,wn as ke,wt as Ae,x as U,xt as je,z as Me,zt as Ne}from"./src-DNHWYkls.js";import{t as Pe}from"./jsx-runtime-BTgGEFjL.js";import{$t as Fe,An as Ie,At as Le,C as Re,Ct as ze,Dn as Be,Dt as Ve,En as He,Et as Ue,F as We,H as Ge,Ht as Ke,I as qe,Jn as Je,K as Ye,Lt as Xe,Mn as Ze,Mt as Qe,N as $e,Ot as et,P as tt,Qt as nt,St as rt,Tn as it,U as at,Ut as ot,Xn as st,Y as ct,Yn as lt,Zt as ut,_ as dt,at as ft,bt as pt,cn as mt,en as ht,et as gt,jt as _t,kn as vt,kt as yt,lt as bt,m as xt,mt as St,pn as Ct,vt as wt,xt as Tt,yt as Et,z as Dt,zt as Ot}from"./state-CUZTq6r0.js";import{$o as kt,A as At,Ao as jt,C as Mt,Ds as Nt,E as Pt,Fu as Ft,Gr as It,Gs as Lt,Gt as Rt,H as zt,Ha as Bt,Hl as Vt,Jr as Ht,Js as Ut,Jt as Wt,K as Gt,Kr as Kt,Ms as qt,Or as Jt,Ou as Yt,Pu as Xt,Ql as Zt,Qr as Qt,R as $t,Rs as en,Ru as tn,Sl as nn,Sr as rn,T as an,Uc as on,Vr as sn,Vs as cn,Wa as ln,Xi as un,Yl as dn,Z as fn,Zr as pn,_s as mn,_t as hn,ao as gn,ar as _n,bl as vn,bn as yn,bo as bn,bs as xn,c as Sn,ci as Cn,ea as wn,ei as Tn,el as En,en as Dn,eo as On,es as kn,fl as An,ft as jn,g as Mn,ga as Nn,gc as Pn,gl as Fn,ha as In,hn as Ln,ht as Rn,ia as zn,ii as Bn,io as Vn,it as Hn,kl as Un,ko as Wn,kr as Gn,ks as Kn,ku as qn,l as Jn,lc as Yn,li as Xn,ls as W,m as Zn,ml as Qn,na as $n,nd as er,ni as tr,no as nr,nr as rr,nt as ir,pa as ar,pi as or,pl as sr,pn as cr,ql as lr,qr as ur,qt as dr,ra as fr,rd as pr,rs as G,rt as mr,s as hr,sr as gr,ss as _r,st as vr,ta as yr,ts as br,us as xr,vl as Sr,wl as Cr,xl as wr,xo as Tr,xr as Er,xs as Dr,yc as Or,yl as kr,z as Ar,zl as jr,zu as Mr}from"./growthbook-p4aJ_UMv.js";import{$ as Nr,D as Pr,E as Fr,G as Ir,J as Lr,K as Rr,O as zr,Q as Br,U as Vr,_ as Hr,h as Ur,j as Wr,l as K,p as q,x as Gr,z as Kr}from"./debug-CjIaNjpK.js";import{n as qr,t as Jr}from"./cwd-B2guYBbl.js";import{t as Yr}from"./sdk-Drp69kIx.js";import{M as Xr,_ as Zr,a as Qr,f as $r,g as ei,i as ti,j as ni,r as ri,v as ii}from"./git-Bj8Ow4pJ.js";import{r as ai,t as oi}from"./execa-BMaINL7N.js";import{F as si,G as ci,L as li,M as ui,N as di,O as fi,a as pi,o as mi,w as hi,y as gi,z as _i}from"./privacyLevel-CRCHhztk.js";import{o as vi,s as yi}from"./log-DVv8YiNo.js";import{n as bi,r as xi,t as Si}from"./execFileNoThrow-DdmR1mBS.js";import{n as Ci,t as wi}from"./memoize-Bg2dXTzV.js";import{n as Ti,t as Ei}from"./which-C0ex-06E.js";import{i as Di,o as Oi}from"./platform-BXz_rgpy.js";import{i as ki,n as Ai,o as ji,r as Mi}from"./path-uaxlnhva.js";import{s as Ni,u as Pi}from"./types-BVelRhgb.js";import{C as Fi,D as Ii,O as Li,_ as Ri,a as zi,b as Bi,d as Vi,f as Hi,k as Ui,l as Wi,n as Gi,o as Ki,r as qi,u as Ji,v as Yi,x as Xi}from"./teammate-C-FiRloZ.js";import{a as Zi,c as Qi,d as $i,f as J,i as ea,n as ta,o as na,s as ra,u as ia}from"./stringUtils-U7kMYMJq.js";import{n as aa,r as Y}from"./analytics-i6X1et4O.js";import{c as oa,n as sa,s as ca,t as la}from"./intl-Pse97ORk.js";import{d as ua,f as da,l as fa,m as pa,u as ma,v as ha,w as ga,x as _a,y as va}from"./startupProfiler-4P7GdVw6.js";import{n as ya,t as ba}from"./lazySchema-2sOku3cX.js";import{f as xa,l as Sa,m as Ca,u as wa}from"./oauth-DMPGYAoZ.js";import{n as Ta,t as Ea}from"./bundledMode-DQNSSQbt.js";import{a as Da,i as Oa,n as ka}from"./env-CesrOJJq.js";import{i as Aa,n as ja}from"./genericProcessUtils-BFJMxLqn.js";import{n as Ma,r as Na}from"./log-B-Nj3Yed.js";import{$A as Pa,$F as Fa,$I as Ia,$M as La,$N as Ra,$O as za,$P as Ba,$T as Va,$a as Ha,$c as Ua,$d as Wa,$f as Ga,$j as Ka,$n as qa,$o as Ja,$p as Ya,$w as Xa,$x as Za,$y as Qa,AA as $a,AE as eo,AI as to,AO as no,AP as ro,AS as io,AT as ao,Af as oo,Ag as so,Aj as co,Al as lo,An as uo,Aw as fo,BA as po,BC as mo,BE as X,BO as ho,BS as go,BT as _o,Bc as vo,Bf as yo,Bg as bo,Bh as xo,Bi as So,Bj as Co,Bl as wo,Bn as To,Bp as Eo,Bv as Do,Bw as Oo,By as ko,CA as Ao,CE as jo,CF as Mo,CI as No,CP as Po,Cc as Fo,Cm as Io,Cn as Lo,Cr as Ro,Cw as zo,Cy as Bo,D as Vo,DE as Ho,DF as Uo,DM as Wo,DP as Go,DT as Ko,D_ as qo,Db as Jo,Dd as Yo,Dg as Xo,Di as Zo,Dm as Qo,Dn as $o,Dp as es,Dt as ts,Dw as ns,Dy as rs,EC as is,EE as as,EF as os,EO as ss,ET as cs,E_ as ls,Eb as us,Ec as ds,Eg as fs,Ej as ps,Em as ms,En as hs,Ep as gs,Es as _s,Ew as vs,Ey as ys,F as bs,FA as xs,FE as Ss,FP as Cs,FS as ws,FT as Ts,Fd as Es,Ff as Ds,Fg as Os,Fl as ks,Fv as As,Fw as js,Fy as Ms,GA as Ns,GC as Ps,GE as Fs,GF as Is,GN as Ls,GO as Rs,GP as zs,GT as Bs,Gd as Vs,Gf as Hs,Gg as Us,Gi as Ws,Gl as Gs,Gp as Ks,Gx as qs,Gy as Js,H as Ys,HA as Xs,HE as Zs,HN as Qs,HO as $s,HP as ec,HT as tc,Ha as nc,Hc as rc,Hg as ic,Hj as ac,Hl as oc,Hp as sc,Hw as cc,Hy as lc,IA as uc,IE as dc,If as fc,Ig as pc,Ij as mc,Il as hc,In as gc,Iy as _c,J as vc,JA as yc,JE as Z,JF as bc,JI as xc,JT as Sc,J_ as Cc,Ja as wc,Jc as Tc,Jg as Ec,Jl as Dc,Jn as Oc,Jp as kc,Jw as Ac,Jx as jc,Jy as Mc,K as Nc,KA as Pc,KC as Fc,KE as Ic,KF as Lc,KI as Rc,KN as zc,KO as Bc,K_ as Vc,Kf as Hc,Kg as Uc,Kl as Wc,Kt as Gc,Kx as Kc,Ky as qc,L as Jc,LD as Yc,LN as Xc,LP as Zc,Ld as Qc,Lf as $c,Lg as el,Lh as tl,Li as nl,Lj as rl,Ll as il,Lr as al,Lt as ol,Lv as sl,Lx as cl,Ly as ll,ME as ul,MF as dl,MP as fl,Mg as pl,Mj as ml,Ml as hl,Mp as gl,Mv as _l,Mw as vl,My as yl,N as bl,NE as xl,NP as Sl,NS as Cl,NT as wl,Nc as Tl,Ng as El,Nh as Dl,Ni as Ol,Nj as kl,Nl as Al,Nt as jl,Nw as Ml,Ny as Nl,O as Pl,OC as Fl,OE as Il,OF as Ll,OM as Rl,ON as zl,OS as Bl,OT as Vl,O_ as Hl,Oc as Ul,Od as Wl,Og as Gl,Oi as Kl,Ol as ql,On as Jl,Ow as Yl,P as Xl,PA as Zl,PE as Ql,PP as $l,PS as eu,PT as tu,Pc as nu,Pg as ru,Ph as iu,Pi as au,Pj as ou,Pl as su,Py as cu,Q as lu,QI as uu,QM as du,QO as fu,QT as pu,Q_ as mu,Qa as hu,Qc as gu,Qd as _u,Qj as vu,Qo as yu,Qp as bu,Qr as xu,Qs as Su,Qw as Cu,Qy as wu,RD as Tu,RE as Eu,RP as Du,RS as Ou,RT as ku,Ra as Au,Rc as ju,Rf as Mu,Rg as Nu,Rh as Pu,Ri as Fu,Rj as Iu,Rv as Lu,Rx as Ru,S as zu,SE as Bu,SF as Vu,SP as Hu,ST as Uu,Sa as Wu,Sc as Gu,Sd as Ku,Sm as qu,Sr as Ju,Sy as Yu,TE as Xu,TF as Zu,TI as Qu,TM as $u,TP as ed,TT as td,T_ as nd,Ta as rd,Tb as id,Tg as ad,Ti as od,Tj as sd,Tl as cd,Tp as ld,Tr as ud,Ts as dd,Tw as fd,Ty as pd,U as md,UE as hd,UO as gd,UP as _d,US as vd,UT as yd,Ub as bd,Ug as xd,Ui as Sd,Uj as Cd,Ul as wd,Um as Td,Up as Ed,Ur as Dd,Ut as Od,Uy as kd,VA as Ad,VC as jd,VE as Md,VN as Nd,VO as Pd,VS as Fd,VT as Id,Vb as Ld,Vc as Rd,Vg as zd,Vl as Bd,Vp as Vd,WE as Hd,WO as Ud,WP as Wd,WT as Gd,W_ as Kd,Wd as qd,Wg as Jd,Wj as Yd,Wl as Xd,Wm as Zd,Wn as Qd,Wp as $d,Wy as ef,X as tf,XE as nf,XM as rf,XN as af,XO as of,XT as sf,X_ as cf,Xa as lf,Xd as uf,Xg as df,Xp as ff,Xr as pf,Xw as mf,Xx as hf,Xy as gf,Y as _f,YE as vf,YF as yf,YP as bf,YT as xf,Y_ as Sf,Ya as Cf,Yg as wf,Yl as Tf,Yp as Ef,Yw as Df,Yx as Of,Yy as kf,Z as Af,ZI as jf,ZM as Mf,ZO as Nf,ZT as Pf,Z_ as Ff,Za as If,Zc as Lf,Zd as Rf,Zg as zf,Zj as Bf,Zl as Vf,Zp as Hf,Zs as Uf,Zw as Wf,Zx as Gf,_A as Kf,_D as qf,_M as Jf,_P as Yf,_T as Xf,_b as Zf,_g as Qf,_k as $f,_l as ep,_m as tp,_o as np,_s as rp,_x as ip,aD as ap,aE as op,aF as sp,aI as cp,aN as lp,aT as up,a_ as dp,ab as fp,ac as pp,af as mp,ag as hp,ah as gp,aj as _p,al as vp,am as yp,as as bp,at as xp,au as Sp,aw as Cp,ax as wp,ay as Tp,bA as Ep,bD as Dp,bE as Op,bM as kp,bP as Ap,bT as jp,bb as Mp,bd as Np,bl as Pp,br as Fp,bs as Ip,by as Lp,cD as Rp,cN as zp,cS as Bp,cT as Vp,ca as Hp,cf as Up,cs as Wp,cw as Gp,cx as Kp,cy as qp,dA as Jp,dC as Yp,dD as Xp,dE as Zp,dN as Qp,dO as $p,dS as em,dT as tm,db as nm,dc as rm,dd as im,dm as am,dp as om,ds as sm,dw as cm,dx as lm,dy as um,eE as dm,eF as fm,eI as pm,eM as mm,eN as hm,eP as gm,eS as _m,eT as vm,eb as ym,ef as bm,ej as xm,ek as Sm,em as Cm,eo as wm,ep as Tm,es as Em,et as Dm,ew as Om,fA as km,fC as Am,fE as jm,fT as Mm,f_ as Nm,fc as Pm,fi as Fm,fl as Im,fp as Lm,fr as Rm,fs as zm,fx as Bm,fy as Vm,g as Hm,gA as Um,gI as Wm,gL as Gm,gM as Km,gT as qm,gb as Jm,gg as Ym,gk as Xm,gl as Zm,gm as Qm,gx as $m,h as eh,hD as th,hL as nh,hM as rh,hT as ih,hi as ah,hk as oh,hl as sh,hn as ch,hr as lh,hs as uh,ht as dh,hv as fh,hw as ph,hx as mh,iD as hh,iE as gh,iF as _h,iN as vh,iS as yh,iT as bh,i_ as xh,ib as Sh,if as Ch,ig as wh,ii as Th,ij as Eh,im as Dh,io as Oh,ix as kh,jE as Ah,jI as jh,jS as Mh,jT as Nh,jc as Ph,jg as Fh,ji as Ih,jl as Lh,jp as Rh,jw as zh,jy as Bh,kA as Vh,kI as Hh,kP as Uh,kS as Wh,k_ as Gh,kc as Kh,kd as qh,kf as Jh,kg as Yh,kl as Xh,km as Zh,kw as Qh,lA as $h,lD as eg,lE as tg,lN as ng,lP as rg,lS as ig,lf as ag,lo as og,lp as sg,ls as cg,lw as lg,lx as ug,m as dg,mA as fg,mD as pg,mL as mg,mM as hg,mT as gg,m_ as _g,ma as vg,mb as yg,ml as bg,mn as xg,ms as Sg,mv as Cg,mw as wg,mx as Tg,my as Eg,nA as Dg,nD as Og,nE as kg,nF as Ag,nI as jg,nM as Mg,nN as Ng,nS as Pg,nb as Fg,nc as Ig,ni as Lg,nj as Rg,nm as zg,nn as Bg,np as Vg,ns as Hg,nw as Ug,nx as Wg,o as Gg,oD as Kg,oE as qg,oI as Jg,oN as Yg,oS as Xg,oT as Zg,o_ as Qg,oa as $g,of as e_,ol as t_,om as n_,oo as r_,op as i_,os as a_,ow as o_,ox as s_,oy as c_,pC as l_,pI as u_,pL as d_,pT as f_,p_,pc as m_,pi as h_,ps as g_,pv as __,px as v_,py as y_,q as b_,qA as x_,qE as S_,qI as C_,qN as w_,qO as T_,qP as E_,qT as D_,q_ as O_,qa as k_,qc as A_,qg as j_,ql as M_,qp as N_,qw as P_,qx as F_,qy as I_,rD as L_,rE as R_,rF as z_,rI as B_,rM as V_,rN as H_,rT as U_,rb as W_,rc as G_,rj as K_,rl as q_,rm as J_,rr as Y_,rs as X_,rt as Z_,rx as Q_,ry as $_,sD as ev,sE as tv,sN as nv,sT as rv,s_ as iv,sf as av,si as ov,sm as sv,sp as cv,ss as lv,sw as uv,sx as dv,sy as fv,tA as pv,tD as mv,tE as hv,tF as gv,tI as _v,tM as vv,tN as yv,tS as bv,tb as xv,tf as Sv,ti as Cv,tj as wv,tl as Tv,tm as Ev,to as Dv,tp as Ov,tr as kv,ts as Av,tx as jv,ty as Mv,u as Nv,uA as Pv,uC as Fv,uD as Iv,uE as Lv,uN as Rv,uO as zv,uP as Bv,uS as Vv,u_ as Hv,ub as Uv,uc as Wv,ud as Gv,uf as Kv,uh as qv,um as Jv,un as Yv,uo as Xv,up as Zv,us as Qv,uw as $v,ux as ey,vA as ty,vD as ny,vM as ry,vP as iy,vT as ay,va as oy,vb as sy,vc as cy,vd as ly,vl as uy,vo as dy,vt as fy,vw as py,vx as my,vy as hy,w as gy,wE as _y,wF as vy,wI as yy,wN as by,wT as xy,w_ as Sy,wa as Cy,wc as wy,wg as Ty,wj as Ey,wp as Dy,wt as Oy,ww as ky,wy as Ay,x as jy,xA as My,xE as Ny,xF as Py,xP as Fy,xT as Iy,xc as Ly,xd as Ry,xl as zy,xn as By,xr as Vy,xy as Hy,yA as Uy,yD as Wy,yE as Gy,yM as Ky,yP as qy,yT as Jy,yb as Yy,yc as Xy,yd as Zy,ys as Qy,yw as $y,yy as eb,zE as tb,zN as nb,zO as rb,zP as ib,zS as ab,zT as ob,z_ as sb,zc as cb,zf as lb,zg as ub,zh as db,zi as fb,zj as pb,zl as mb,zv as hb,zw as gb,zy as _b}from"./loadAgentsDir-Bz0FfcVt.js";import{o as vb,r as yb}from"./debug-BDBIipC1.js";import{$t as bb,Dt as xb,Gn as Sb,N as Cb,On as wb,Qn as Tb,Qt as Eb,Rt as Db,Tn as Ob,Zn as kb,_n as Ab,_t as jb,ar as Mb,er as Nb,gn as Pb,j as Fb,or as Ib,tr as Lb,vn as Rb,vt as zb,yn as Bb,zt as Vb}from"./prompt-CsBCtw4l.js";import{a as Hb,n as Ub,r as Wb,v as Gb}from"./companion-mD1jw6xX.js";import{a as Kb,s as qb}from"./ripgrep-BEWqxrpl.js";import{i as Jb,o as Yb,r as Xb,t as Zb}from"./xml-E8VMPwdJ.js";import{a as Qb,i as $b,r as ex}from"./shellQuote-3s6tV-hK.js";import{c as tx,l as nx,t as rx}from"./commitAttribution-B0cXmbvv.js";import{H as ix,S as ax,a as ox,c as sx,i as cx,l as lx,o as ux,r as dx,s as fx,w as px}from"./rcDebugLog-BbHlIxCm.js";import{A as mx,D as hx,E as gx,I as _x,L as vx,M as yx,O as bx,S as xx,a as Sx,d as Cx,g as wx,h as Tx,k as Ex,m as Dx,o as Ox,p as kx,u as Ax,v as jx,w as Mx,y as Nx}from"./teamHelpers-CTA_CtTT.js";import{t as Px}from"./useKeybinding-DAQL_dB_.js";import{t as Fx}from"./useTerminalSize-DzV4aaTi.js";import{a as Ix,n as Lx,o as Rx,s as zx}from"./fileStateCache-DAsLEZau.js";import{D as Bx,O as Vx,T as Hx,k as Ux,r as Wx,s as Gx}from"./sessionTracing-DR8O0686.js";import{i as Kx,n as qx,r as Jx}from"./parser-DGoLe2RS.js";import{n as Yx,t as Xx}from"./cwd-BXiaJzLh.js";import{n as Zx,t as Qx}from"./poorMode-CBe0rfxB.js";import{a as $x,f as eS,l as tS,o as nS}from"./api-YHYC4Zdk.js";import{n as rS,t as iS}from"./browser-D1vC3BNd.js";import{r as aS}from"./semver-D3lOjiBN.js";import{c as oS,u as sS}from"./common-BX7bn3hg.js";import{c as cS,i as lS,m as uS,n as dS,p as fS}from"./terminalSetup--jwGVap8.js";import{a as pS,n as mS,t as hS}from"./useExitOnCtrlCDWithKeybindings-CBce_-hb.js";import{a as gS,c as _S,o as vS,s as yS}from"./constants-BfXy-5cI.js";import{n as bS,t as xS}from"./SentryErrorBoundary-BVfBaOOU.js";import{o as SS,r as CS,s as wS}from"./detection-DW6grIlc.js";import{n as TS,r as ES}from"./systemPromptSections-BnrxBWdc.js";import{n as DS,r as OS}from"./undercover-CbxiJO2b.js";import{a as kS,r as AS,s as jS,t as MS}from"./referral-BfAZEIZL.js";import{i as NS,r as PS}from"./bridgeEnabled-DKqmLnKO.js";import{t as FS}from"./lib-Ddq71jM5.js";import{t as IS}from"./Dialog-Dgg8bqcG.js";import{n as LS,t as RS}from"./mappers-DLkk0PZz.js";import{n as zS,r as BS}from"./sessionTitle-Bzxk_EW9.js";import{t as VS}from"./bridgeMessaging-BUOZU_ba.js";import{t as HS}from"./sessionState-Dgky34M4.js";import{a as US,f as WS}from"./cronTasks-CMJldfoP.js";import{a as GS,i as KS,r as qS,t as JS}from"./pipeTransport-CB_Wq_Kx.js";import{t as YS}from"./useManagePlugins-CXdYUpit.js";import{c as XS,n as ZS,o as QS}from"./channelNotification-BjWwF85R.js";import{a as $S,i as eC,n as tC,o as nC,r as rC,t as iC}from"./useManageMCPConnections-bf-VfJGD.js";import{i as aC,n as oC,r as sC,t as cC}from"./directoryCompletion-J560aATd.js";import{r as lC,t as uC}from"./PromptInputFooterSuggestions-CcsKj5DK.js";import{i as dC,n as fC}from"./toolPool-CEi_2xIH.js";import{n as pC,t as mC}from"./useMergedTools-DERzhQOJ.js";import{a as hC,i as gC,n as _C,o as vC,r as yC,t as bC}from"./promptEditor-CrlVcc17.js";import{n as xC,t as SC}from"./useMainLoopModel-QC_H3esG.js";import{n as CC,t as wC}from"./PermissionRequestTitle-CtlbBU9t.js";import{n as TC,t as EC}from"./PermissionDialog-BCS22yEO.js";import{n as DC,t as OC}from"./RemoteCallout-BZcabEKb.js";import{n as kC,t as AC}from"./sideQuestion-BBn6XIOD.js";import{i as jC,n as MC,r as NC,t as PC}from"./sprites-C5X62Vyh.js";import{a as FC,n as IC,t as LC}from"./setup-BHNS9sBS.js";import{a as RC,c as zC,i as BC,l as VC,o as HC,r as UC,s as WC,u as GC}from"./caches-CkSv3MfC.js";import{i as KC,n as qC,r as JC,t as YC}from"./conversation-yhs7tT-g.js";import{n as XC,t as ZC}from"./useExitOnCtrlCDWithKeybindings-CLYjTZXb.js";import{a as QC,i as $C,n as ew,o as tw,r as nw,s as rw,t as iw}from"./extraUsage-qOBMQB6g.js";import{n as aw,t as ow}from"./useSearchInput-nqhdILI2.js";import{n as sw,r as cw,t as lw}from"./overageCreditGrant-BLFT-rF3.js";import{i as uw,o as dw}from"./OverageCreditUpsell-D_td1ss4.js";import{n as fw,t as pw}from"./DesktopHandoff-5c90JK88.js";import{n as mw,t as hw}from"./shadowedRuleDetection-Ch9gTxfD.js";import{n as gw,t as _w}from"./ExitFlow-DBqn2mUf.js";import{a as vw,c as yw,i as bw,l as xw,n as Sw,o as Cw,r as ww,s as Tw,t as Ew}from"./Messages-CtIbkB2M.js";import{r as Dw,t as Ow}from"./Message-DNxJ_tMS.js";import{n as kw,t as Aw}from"./exportRenderer-RxtEIyTm.js";import{a as jw,i as Mw,r as Nw,t as Pw}from"./fast-CEaIzaPl.js";import{n as Fw,r as Iw}from"./Feedback-D-JHabwi.js";import{n as Lw,t as Rw}from"./PermissionDialog-C5O1fL53.js";import{a as zw,i as Bw,n as Vw,r as Hw,t as Uw}from"./PromptInputHelpMenu-JedFdsxU.js";import{n as Ww,r as Gw}from"./language-EZLNdETg.js";import{n as Kw,r as qw}from"./pluginAutoupdate-wTeOXfQe.js";import{n as Jw,r as Yw}from"./autoModeDenials-0CPO-Jbu.js";import{n as Xw,t as Zw}from"./claudeAiLimitsHook-ATshVrOH.js";import{n as Qw,t as $w}from"./refresh-Bl3Miver.js";import{n as eT,t as tT}from"./generateSessionName-Dpjg-u_x.js";import{n as nT,t as rT}from"./fuse-ivQ_eRwF.js";import{a as iT,c as aT,i as oT,l as sT,n as cT,o as lT,r as uT,s as dT,t as fT,u as pT}from"./BackgroundTasksDialog-XU_JPh7R.js";import{r as mT,t as hT}from"./useVoice-CO69xtWC.js";import{n as gT}from"./fpsMetrics-ts_jaF3g.js";import"./asciicast-HG1EoAQe.js";import{t as _T}from"./earlyInput-BTI1CSNt.js";import{i as vT,n as yT,r as bT,t as xT}from"./goalStorage-CsuPOQbk.js";import{a as ST,i as CT,r as wT,s as TT,t as ET}from"./RemoteSessionManager-C2PIFDHt.js";import{a as DT,i as OT,n as kT,r as AT,t as jT}from"./processUserInput-QAJK0XSn.js";import{n as MT,t as NT}from"./skillUsageTracking-BBTiWOKB.js";import{n as PT,t as FT}from"./backgroundHousekeeping-BqKZEvy0.js";import{a as IT,c as LT,l as RT,o as zT,r as BT,t as VT,u as HT}from"./cronScheduler-zRXhgEEU.js";import{homedir as UT,tmpdir as WT}from"os";import*as GT from"path";import{basename as KT,dirname as qT,extname as JT,join as YT,posix as XT,relative as ZT,resolve as QT,sep as $T,win32 as eE}from"path";import{dirname as tE,join as nE}from"node:path";import{statSync as rE,watch as iE}from"fs";import{createHash as aE}from"node:crypto";import{randomUUID as oE}from"crypto";import{open as sE,readFile as cE,stat as lE,writeFile as uE}from"fs/promises";import{spawn as dE,spawnSync as fE}from"child_process";import{createConnection as pE}from"net";import{mkdir as mE,readFile as hE,rename as gE,writeFile as _E}from"node:fs/promises";a(),l(),f();var vE=n(g(),1);v(),D(),L(),ke(),j(),m(),Ke(),pr(),Xt(),qr(),Br(),Yr(),Vr(),Fr(),Hr(),K(),ni(),ai(),ci(),pi(),vi(),xi(),wi(),Ei(),ii(),Oi(),ki(),Yt(),Li(),$i(),Zt(),Ni(),aa(),ca(),va(),Vt(),Un(),ba(),xa(),wa(),Ea(),Da(),Cr(),sr(),En(),Pn(),Zi(),Yn(),Lt(),Nt(),Fi(),mn(),br(),jt(),Tr(),Xi(),gn(),nr(),Aa(),ln(),In(),or(),Ht(),Jt(),Ri(),Wi(),Er(),gr(),Ln(),dr(),Ma(),ir(),Pt(),Zn(),yb(),nh(),Ia(),Ib(),Lb(),Sb(),C_(),Rc(),Kb(),wb(),Wm(),Jg(),pm(),Lc(),dl(),Ob(),Bb(),bx(),Ab(),Uo(),sp(),_h(),Ag(),fm(),Px(),bf(),Fx(),ib(),bb(),Db(),xb(),Fb(),$l(),ro(),ed(),Ap(),Bv(),Rx(),gm(),w_(),Nd(),zl(),Qp(),lp(),$u(),Jf(),V_(),vv(),Vx(),Yx(),Yd(),pb(),ex(),rl(),kl(),Ey(),yc(),Bx(),Ad(),xs(),$a(),Ao(),Uy(),px(),fg(),$f(),iS(),aS(),oS(),$p(),ny(),Iv(),ap(),L_(),mv(),S_(),Fs(),hd(),tb(),Ss(),Ql(),Ah(),fS(),lS(),eo(),Xu(),tg(),kg(),pS(),dm(),Pf(),D_(),Bs(),_o(),ob(),xy(),Uu(),ay(),Mm(),jx(),_S(),Sx(),Xa(),Oo(),zh(),Om(),Ps(),Fd(),ab(),Wh(),em(),ig(),Gf(),F_(),cl(),kh(),bd(),Gx(),nm(),fp(),Fg(),ym(),gf(),Mc(),_b(),Nl(),Hy(),eb(),Eg(),Vm(),qp(),c_(),_l(),fh(),mu(),Gh(),dx(),Nm(),bS(),xo(),Pu(),iu(),Zd(),ms(),ES(),Ov(),Hs(),Mu(),oo(),mp(),Sv(),Wa(),Es(),Yo(),Ry(),Zy(),Sp(),Tf(),Dc(),su(),zy(),Zm(),Lf(),G_(),_s(),uh(),Hp(),Sd(),fb(),Fp(),hs(),xg(),Yv(),tf(),vc(),Nc(),md(),gy(),eh(),Gg(),US(),hC(),CC(),TC(),ow(),Sw(),Aw(),Fw(),Lw();var Q=n(oe(),1);H(),py();var $=Pe();function yE({onDone:e}){return(0,$.jsxs)(ve,{title:`You've spent $5 on the Anthropic API this session.`,onCancel:e,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(ae,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(ku,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}H(),py();function bE({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ve,{title:`You've been away ${xE(e)} and this conversation is ${ha(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(z,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(ku,{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 xE(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`}Wy();var SE=300,CE=240*1e3,wE=null,TE=null,EE=0,DE=!1;function OE(){EE++,EE===1&&(NE(),jE())}function kE(){EE>0&&EE--,EE===0&&(ME(),PE())}function AE(){EE=0,ME(),PE()}function jE(){process.platform===`darwin`&&TE===null&&(TE=setInterval(()=>{EE>0&&(q(`Restarting caffeinate to maintain sleep prevention`),PE(),NE())},CE),TE.unref())}function ME(){TE!==null&&(clearInterval(TE),TE=null)}function NE(){if(process.platform===`darwin`&&wE===null){DE||(DE=!0,Nr(async()=>{AE()}));try{wE=dE(`caffeinate`,[`-i`,`-t`,String(SE)],{stdio:`ignore`}),wE.unref();let e=wE;wE.on(`error`,t=>{q(`caffeinate spawn error: ${t.message}`),wE===e&&(wE=null)}),wE.on(`exit`,()=>{wE===e&&(wE=null)}),q(`Started caffeinate to prevent sleep`)}catch{wE=null}}}function PE(){if(wE!==null){let e=wE;wE=null;try{e.kill(`SIGKILL`),q(`Stopped caffeinate, allowing sleep`)}catch{}}}var FE=class{constructor(){p(this,`_status`,`idle`),p(this,`_generation`,0),p(this,`_changed`,Bi()),p(this,`subscribe`,this._changed.subscribe),p(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()}};tn(),_d(),Ts(),Ko(),Xf(),f_(),U_(),vs(),zg(),Ef(),H(),up();function IE({name:e,color:t}){return(0,$.jsx)(U,{flexDirection:`row`,gap:1,children:(0,$.jsxs)(z,{color:Zg(t),children:[wr,` `,(0,$.jsxs)(z,{bold:!0,children:[`@`,e]})]})})}H();function LE({toolName:e,description:t}){let n=zi(),r=Gi(),i=Ki();return(0,$.jsxs)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:`warning`,paddingX:1,children:[(0,$.jsxs)(U,{marginBottom:1,children:[(0,$.jsx)(ky,{}),(0,$.jsxs)(z,{color:`warning`,bold:!0,children:[` `,`Waiting for team lead approval`]})]}),r&&i&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(IE,{name:r,color:i})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Tool: `}),(0,$.jsx)(z,{children:e})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Action: `}),(0,$.jsx)(z,{children:t})]}),n&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[`Permission request sent to team `,`"`,n,`"`,` leader`]})})]})}Vd();function RE(e,t=!1){let n=X(e=>e.teamContext),r=(0,Q.useRef)(0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(void 0),o=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let s=e[0]?.uuid,c=r.current,l=a.current===void 0,u=s!==void 0&&!l&&s===a.current&&c<=e.length,d=s!==void 0&&!l&&s===a.current&&c>e.length,f=u?c:0;if(f===e.length)return;let p=f===0?e:e.slice(f),m=u?i.current:void 0,h=++o.current;if(pf(p,Gn()?{teamName:n?.teamName,agentName:n?.selfAgentName}:{},m,e).then(e=>{h===o.current&&e&&!u&&(i.current=e)}),u||l||d){let t=To(p,e).findLast(Vy);t&&(i.current=t.uuid)}r.current=e.length,a.current=s},[e,t,n?.teamName,n?.selfAgentName])}function zE(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function BE(e,t){if(typeof e.message==`string`&&e.message)return e.message;if(typeof t?.message==`string`&&t.message)return t.message;if(typeof e.error==`string`&&e.error)return e.error}function VE(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&zE(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&zE(t.response)?t.response:void 0,r=BE(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function HE(t){{let{pauseProactive:t}=(dx(),e(fx));t()}t?.abort()}function UE(e,t){return e<t}function WE(e,t){return e&&t===0}function GE({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t?!0:UE(n,r)}function KE(e){if(e.type!==`user`)return;let t=e.message?.content;if(!t||Array.isArray(t)&&t.length===0)return;let n=`uuid`in e&&typeof e.uuid==`string`?e.uuid:void 0;return{content:Array.isArray(t)?qE(t):t,uuid:n}}function qE(e){return e.some(JE)?e.map(e=>{if(!JE(e))return e;let t=e.source,n=typeof t.mediaType==`string`&&t.mediaType?t.mediaType:Fa(e.source.data);return{...e,source:{type:`base64`,media_type:n,data:e.source.data}}}):e}function JE(e){return e.type!==`image`||e.source?.type!==`base64`?!1:!e.source.media_type}JC();function YE(e){return{id:e.id,subject:e.subject,description:e.description,activeForm:e.activeForm,status:e.status,owner:e.owner,blocks:[...e.blocks],blockedBy:[...e.blockedBy]}}function XE(e,t){return e.id.localeCompare(t.id)}function ZE(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(YE).sort(XE)}}function QE(e,t){return JSON.stringify(ZE(e,t))}function $E(e,t){let n=ZE(e,t);return{type:`task_state`,uuid:oE(),...n}}H(),tb(),K();var eD=50,tD=5e3,nD=1e4,rD=3;function iD(e,t,n,r,i){let a=(0,Q.useRef)(null),o=(0,Q.useRef)(void 0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(new Set),d=(0,Q.useRef)(void 0),f=(0,Q.useRef)(0),p=Zs(),m=(0,Q.useRef)(r);m.current=r;let h=(0,Q.useRef)(i);h.current=i;let g=(0,Q.useRef)(e);g.current=e;let _=Md(),{addNotification:v}=Ic(),y=X(e=>e.replBridgeEnabled),b=X(e=>e.replBridgeConnected),x=X(e=>e.replBridgeSessionActive),S=X(e=>e.replBridgeOutboundOnly),C=X(e=>e.replBridgeInitialName);return(0,Q.useEffect)(()=>{{if(!y)return;let r=S;function i(e){r||v({key:`bridge-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(z,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=rD){q(`[bridge:repl] Hook: ${f.current} consecutive init failures, not retrying this session`);let e=`disabled after repeated failures · restart to retry`;i(e),p(t=>t.replBridgeError===e&&!t.replBridgeEnabled?t:{...t,replBridgeError:e,replBridgeEnabled:!1});return}let b=!1,x=e.length;return(async()=>{try{if(o.current&&(q(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,q(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),b)return;let{initReplBridge:v}=await import(`./initReplBridge-p2uwDBPx.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-4oys0_9A.js`),S=!1;{let{isAssistantMode:e}=await import(`./assistant-DO2ZmZn1.js`);S=e()}async function w(e){try{let t=KE(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-RNpYpRTO.js`),i=t.content,a=await r(e,i);q(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),La({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){q(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function T(e,n){if(b)return;if(r){q(`[bridge:repl] Mirror state=${e}${n?` detail=${n}`:``}`),e===`failed`?p(e=>e.replBridgeConnected?{...e,replBridgeConnected:!1}:e):(e===`ready`||e===`connected`)&&p(e=>e.replBridgeConnected?e:{...e,replBridgeConnected:!0});return}let o=a.current;switch(e){case`ready`:p(e=>{let t=o&&o.environmentId!==``?Nh(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?cp(o.bridgeSessionId,o.sessionIngressUrl):e.replBridgeSessionUrl,r=o?.environmentId,i=o?.bridgeSessionId;return e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeReconnecting&&e.replBridgeConnectUrl===t&&e.replBridgeSessionUrl===n&&e.replBridgeEnvironmentId===r&&e.replBridgeSessionId===i?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:t,replBridgeSessionUrl:n,replBridgeEnvironmentId:r,replBridgeSessionId:i,replBridgeError:void 0}});break;case`connected`:{let e=_.getState().replBridgeSessionActive;p(e=>e.replBridgeSessionActive?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!0,replBridgeReconnecting:!1,replBridgeError:void 0}),e||t(e=>[...e,Ul(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]),Jn(`tengu_bridge_system_init`,!1)&&(async()=>{try{let e=await nl(Jr());if(b)return;let t=_.getState();a.current?.writeSdkMessages([DT({tools:[],mcpClients:[],model:h.current,permissionMode:t.toolPermissionContext.mode,commands:m.current.filter(So),agents:t.agentDefinitions.activeAgents,skills:e,plugins:[],fastMode:t.fastMode})])}catch(e){q(`[bridge:repl] Failed to send system/init: ${Kr(e)}`,{level:`error`})}})();break}case`reconnecting`:p(e=>e.replBridgeReconnecting?e:{...e,replBridgeReconnecting:!0,replBridgeSessionActive:!1});break;case`failed`:clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n,replBridgeReconnecting:!1,replBridgeSessionActive:!1,replBridgeConnected:!1})),d.current=setTimeout(()=>{b||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},nD);break}}let E=new Map;function D(e){let t=e.response?.request_id;if(!t)return;let n=E.get(t);if(!n){q(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=VE(e);if(!r){q(`[bridge:repl] Ignoring unrecognized control_response request_id=${t}`);return}E.delete(t),n(r)}let O=await v({outboundOnly:r,tags:r?[`ccr-mirror`]:void 0,onInboundMessage:w,onPermissionResponse:D,onInterrupt(){HE(n.current)},onSetModel(e){let t=e===`default`?null:e??null;He(t),p(e=>e.mainLoopModelForSession===t?e:{...e,mainLoopModelForSession:t})},onSetMaxThinkingTokens(e){let t=e!==null;p(e=>e.thinkingEnabled===t?e:{...e,thinkingEnabled:t})},onSetPermissionMode(e){if(e===`bypassPermissions`){if(Pl())return{ok:!1,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`};if(!_.getState().toolPermissionContext.isBypassPermissionsModeAvailable)return{ok:!1,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}if(e===`auto`&&!Vo()){let e=zu();return{ok:!1,error:e?`Cannot set permission mode to auto: ${jy(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=bs(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),setImmediate(()=>{Eo()?.(e=>(e.forEach(e=>{e.recheckPermission()}),e))}),{ok:!0}},onStateChange:T,initialMessages:e.length>0?e:void 0,getMessages:()=>g.current,previouslyFlushedUUIDs:u.current,initialName:C,perpetual:S}),k=O?{...O,markTranscriptReset(){l.current=!0,c.current=!1,s.current=0}}:null;if(b){q(`[bridge:repl] Hook: init cancelled during flight, tearing down${k?` env=${k.environmentId}`:``}`),k&&k.teardown();return}if(!k){f.current++,q(`[bridge:repl] Init returned null (precondition or session creation failed); consecutive failures: ${f.current}`),clearTimeout(d.current),p(e=>({...e,replBridgeError:e.replBridgeError??`check debug logs for details`})),d.current=setTimeout(()=>{b||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},nD);return}if(a.current=k,KC(k),f.current=0,s.current=x,r)p(e=>e.replBridgeConnected&&e.replBridgeSessionId===k.bridgeSessionId?e:{...e,replBridgeConnected:!0,replBridgeSessionId:k.bridgeSessionId,replBridgeSessionUrl:void 0,replBridgeConnectUrl:void 0,replBridgeError:void 0}),q(`[bridge:repl] Mirror initialized, session=${k.bridgeSessionId}`);else{let e={sendRequest(e,t,n,r,i,a,o){k.sendControlRequest({type:`control_request`,request_id:e,request:{subtype:`can_use_tool`,tool_name:t,input:n,tool_use_id:r,description:i,...a?{permission_suggestions:a}:{},...o?{blocked_path:o}:{}}})},sendResponse(e,t){let n={...t};k.sendControlResponse({type:`control_response`,response:{subtype:`success`,request_id:e,response:n}})},cancelRequest(e){k.sendControlCancelRequest(e)},onResponse(e,t){return E.set(e,t),()=>{E.delete(e)}}};p(t=>({...t,replBridgePermissionCallbacks:e}));let n=cp(k.bridgeSessionId,k.sessionIngressUrl),r=k.environmentId===``?void 0:Nh(k.environmentId,k.sessionIngressUrl);p(e=>e.replBridgeConnected&&e.replBridgeSessionUrl===n?e:{...e,replBridgeConnected:!0,replBridgeSessionUrl:n,replBridgeConnectUrl:r??e.replBridgeConnectUrl,replBridgeEnvironmentId:k.environmentId,replBridgeSessionId:k.bridgeSessionId,replBridgeError:void 0});let i=S?!1:await y().catch(()=>!1);if(b)return;t(e=>[...e,Fo(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),q(`[bridge:repl] Hook initialized, session=${k.bridgeSessionId}`)}}catch(e){if(b)return;f.current++;let n=Kr(e);q(`[bridge:repl] Init failed: ${n}; consecutive failures: ${f.current}`),clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n})),d.current=setTimeout(()=>{b||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},nD),r||t(e=>[...e,Ul(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{b=!0,clearTimeout(d.current),d.current=void 0,a.current&&(q(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,KC(null)),p(e=>!e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeError?e:{...e,replBridgeConnected:!1,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:void 0,replBridgeSessionUrl:void 0,replBridgeEnvironmentId:void 0,replBridgeSessionId:void 0,replBridgeError:void 0,replBridgePermissionCallbacks:void 0}),s.current=0,c.current=!1,l.current=!1}}},[y,S,p,t,v]),(0,Q.useEffect)(()=>{{if(!b)return;let t=a.current;if(!t)return;s.current>e.length&&q(`[bridge:repl] Compaction detected: lastWrittenIndex=${s.current} > messages.length=${e.length}, clamping`);let n=Math.min(s.current,e.length),r=[];for(let t=n;t<e.length;t++){let n=e[t];n&&(n.type===`user`||n.type===`assistant`||n.type===`system`&&n.subtype===`local_command`)&&r.push(n)}if(s.current=e.length,r.length>0&&(t.writeMessages(r),l.current=!1),c.current&&WE(l.current,e.length)){l.current=!1,c.current=!1,t.sendResult();return}c.current&&!l.current&&(c.current=!1,t.sendResult())}},[e,b]),(0,Q.useEffect)(()=>{{if(!x||S)return;let e=!1,t,n,r=null,i=null,o=null,s=null,c=e=>{if(!(e===i&&r!==null)){r?.close(),r=null,i=e;try{r=iE(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=gx();c(hx(n));try{let r=await mx(n);if(e||a.current!==t)return;let i=QE(n,r);if(i===o&&t===s)return;t.writeSdkMessages([$E(n,r)]),o=i,s=t}catch(e){q(`[bridge:repl] Failed to publish task_state: ${Kr(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},eD),t.unref?.()};l();let d=yx(u);return n=setInterval(()=>{l()},tD),n.unref?.(),()=>{e=!0,d(),t&&clearTimeout(t),n&&clearInterval(n),r?.close()}}},[x,S]),{sendBridgeResult:(0,Q.useCallback)(()=>{{let e=a.current;if(!e){c.current=!0;return}if(WE(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||GE({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}hS(),H(),Lf(),vs(),Bh(),va();function aD(e){return e.type===`text`}function oD(e){return e===`summarize`||e===`summarize_up_to`}var sD=7;function cD({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:i,onClose:a,preselectedMessage:o}){let s=Z(e=>e.fileHistory),[c,l]=(0,Q.useState)(void 0),u=_c(),d=(0,Q.useMemo)(oE,[]),f=(0,Q.useMemo)(()=>[...e.filter(hD),{...Ph({content:``}),uuid:d}],[e,d]),[p,m]=(0,Q.useState)(f.length-1),g=Math.max(0,Math.min(p-Math.floor(sD/2),f.length-sD)),_=f.length>1,[v,y]=(0,Q.useState)(o),[b,x]=(0,Q.useState)(void 0);(0,Q.useEffect)(()=>{if(!o||!u)return;let e=!1;return ll(s,o.uuid).then(t=>{e||x(t)}),()=>{e=!0}},[o,u,s]);let[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(`both`),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(``);function ee(e){let t=e?[{value:`both`,label:`Restore code and conversation`},{value:`conversation`,label:`Restore conversation`},{value:`code`,label:`Restore code`}]:[{value:`conversation`,label:`Restore conversation`}],n={type:`input`,placeholder:`add context (optional)`,initialValue:``,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `};return t.push({value:`summarize`,label:`Summarize from here`,...n,onChange:k}),process.env.USER_TYPE===`ant`&&t.push({value:`summarize_up_to`,label:`Summarize up to here`,...n,onChange:j}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,Q.useEffect)(()=>{J(`tengu_message_selector_opened`,{})},[]);async function M(e){t(),C(!0);try{await n(e),C(!1),a()}catch(e){Na(e),C(!1),l(`Failed to restore the conversation:\n${e}`)}}async function N(t){let n=e.indexOf(t);if(J(`tengu_message_selector_selected`,{index_from_end:e.length-1-n,message_type:t.type,is_current_prompt:!1}),!e.includes(t)){a();return}if(!u){await M(t);return}let r=await ll(s,t.uuid);y(t),x(r)}async function P(e){if(J(`tengu_message_selector_restore_option_selected`,{option:e}),!v){l(`Message not found.`);return}if(e===`nevermind`){o?a():y(void 0);return}if(oD(e)){t(),C(!0),T(e),l(void 0);try{let t=e===`summarize_up_to`?`up_to`:`from`;await i(v,(t===`up_to`?A:O).trim()||void 0,t),C(!1),T(null),y(void 0),a()}catch(e){Na(e),C(!1),T(null),y(void 0),l(`Failed to summarize:\n${e}`)}return}t(),C(!0),l(void 0);let s=null,c=null;if(e===`code`||e===`both`)try{await r(v)}catch(e){s=e,Na(s)}if(e===`conversation`||e===`both`)try{await n(v)}catch(e){c=e,Na(c)}C(!1),y(void 0),c&&s?l(`Failed to restore the conversation and code:\n${c}\n${s}`):c?l(`Failed to restore the conversation:\n${c}`):s?l(`Failed to restore the code:\n${s}`):a()}let F=mS(),te=(0,Q.useCallback)(()=>{if(v&&!o){y(void 0);return}J(`tengu_message_selector_cancelled`,{}),a()},[a,v,o]),I=(0,Q.useCallback)(()=>m(e=>Math.max(0,e-1)),[]),L=(0,Q.useCallback)(()=>m(e=>Math.min(f.length-1,e+1)),[f.length]),ne=(0,Q.useCallback)(()=>m(0),[]),re=(0,Q.useCallback)(()=>m(f.length-1),[f.length]),ie=(0,Q.useCallback)(()=>{let e=f[p];e&&N(e)},[f,p,N]);De(`confirm:no`,te,{context:`Confirmation`,isActive:!v}),Se({"messageSelector:up":I,"messageSelector:down":L,"messageSelector:top":ne,"messageSelector:bottom":re,"messageSelector:select":ie},{context:`MessageSelector`,isActive:!S&&!c&&!v&&_});let[ae,oe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{async function t(){u&&Promise.all(f.map(async(t,n)=>{if(t.uuid!==d){let r=Ms(s,t.uuid),i=f.at(n+1),a=r?mD(e,t.uuid,i?.uuid===d?void 0:i?.uuid):void 0;oe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[f,e,d,s,u]);let se=u&&b?.filesChanged&&b.filesChanged.length>0,ce=!c&&!v&&!o&&_;return(0,$.jsxs)(U,{flexDirection:`column`,width:`100%`,children:[(0,$.jsx)(xe,{color:`suggestion`}),(0,$.jsxs)(U,{flexDirection:`column`,marginX:1,gap:1,children:[(0,$.jsx)(z,{bold:!0,color:`suggestion`,children:`Rewind`}),c&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(z,{color:`error`,children:[`Error: `,c]})}),!_&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(z,{children:`Nothing to rewind to yet.`})}),!c&&v&&_&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(z,{children:[`Confirm you want to restore `,!b&&`the conversation `,`to the point before you sent this message:`]}),(0,$.jsxs)(U,{flexDirection:`column`,paddingLeft:1,borderStyle:`single`,borderRight:!1,borderTop:!1,borderBottom:!1,borderLeft:!0,borderLeftDimColor:!0,children:[(0,$.jsx)(pD,{userMessage:v,color:`text`,isCurrent:!1}),(0,$.jsxs)(z,{dimColor:!0,children:[`(`,pa(new Date(v.timestamp)),`)`]})]}),(0,$.jsx)(uD,{selectedRestoreOption:E,canRestoreCode:!!se,diffStatsForRestore:b}),S&&oD(w)?(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[(0,$.jsx)(ky,{}),(0,$.jsx)(z,{children:`Summarizing…`})]}):(0,$.jsx)(ku,{isDisabled:S,options:ee(!!se),defaultFocusValue:se?`both`:`conversation`,onFocus:e=>D(e),onChange:e=>P(e),onCancel:()=>o?a():y(void 0)}),se&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.warning,` Rewinding does not affect files edited manually or via bash.`]})})]}),ce&&(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(z,{children:`Restore the code and/or conversation to the point before…`}):(0,$.jsx)(z,{children:`Restore and fork the conversation to the point before…`}),(0,$.jsx)(U,{width:`100%`,flexDirection:`column`,children:f.slice(g,g+sD).map((e,t)=>{let n=g+t,r=n===p,i=e.uuid===d,a=n in ae,o=ae[n],s=o?.filesChanged&&o.filesChanged.length;return(0,$.jsxs)(U,{height:u?3:2,overflow:`hidden`,width:`100%`,flexDirection:`row`,children:[(0,$.jsx)(U,{width:2,minWidth:2,children:r?(0,$.jsxs)(z,{color:`permission`,bold:!0,children:[h.pointer,` `]}):(0,$.jsx)(z,{children:` `})}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{flexShrink:1,height:1,overflow:`hidden`,children:(0,$.jsx)(pD,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:i,paddingRight:10})}),u&&a&&(0,$.jsx)(U,{height:1,flexDirection:`row`,children:o?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(z,{dimColor:!r,color:`inactive`,children:s?(0,$.jsxs)($.Fragment,{children:[s===1&&o.filesChanged[0]?`${GT.basename(o.filesChanged[0])} `:`${s} files changed `,(0,$.jsx)(fD,{diffStats:o})]}):(0,$.jsx)($.Fragment,{children:`No code changes`})})}):(0,$.jsxs)(z,{dimColor:!0,color:`warning`,children:[h.warning,` No code restore`]})})]})]},e.uuid)})})]}),!v&&(0,$.jsx)(z,{dimColor:!0,italic:!0,children:F.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,F.keyName,` again to exit`]}):(0,$.jsxs)($.Fragment,{children:[!c&&_&&`Enter to continue · `,`Esc to exit`]})})]})]})}function lD(e){switch(e){case`summarize`:return`Messages after this point will be summarized.`;case`summarize_up_to`:return`Preceding messages will be summarized. This and subsequent messages will remain unchanged — you will stay at the end of the conversation.`;case`both`:case`conversation`:return`The conversation will be forked.`;case`code`:case`nevermind`:return`The conversation will be unchanged.`}}function uD({selectedRestoreOption:e,canRestoreCode:t,diffStatsForRestore:n}){let r=t&&(e===`both`||e===`code`);return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{dimColor:!0,children:lD(e)}),!oD(e)&&(r?(0,$.jsx)(dD,{diffStatsForRestore:n}):(0,$.jsx)(z,{dimColor:!0,children:`The code will be unchanged.`}))]})}function dD({diffStatsForRestore:e}){if(e===void 0)return;if(!e.filesChanged||!e.filesChanged[0])return(0,$.jsx)(z,{dimColor:!0,children:`The code has not changed (nothing will be restored).`});let t=e.filesChanged.length,n=``;return n=t===1?GT.basename(e.filesChanged[0]||``):t===2?`${GT.basename(e.filesChanged[0]||``)} and ${GT.basename(e.filesChanged[1]||``)}`:`${GT.basename(e.filesChanged[0]||``)} and ${e.filesChanged.length-1} other files`,(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(z,{dimColor:!0,children:[`The code will be restored `,(0,$.jsx)(fD,{diffStats:e}),` in `,n,`.`]})})}function fD({diffStats:e}){if(!(!e||!e.filesChanged))return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(z,{color:`diffAddedWord`,children:[`+`,e.insertions,` `]}),(0,$.jsxs)(z,{color:`diffRemovedWord`,children:[`-`,e.deletions]})]})}function pD({userMessage:e,color:t,dimColor:n,isCurrent:r,paddingRight:i}){let{columns:a}=ee();if(r)return(0,$.jsx)(U,{width:`100%`,children:(0,$.jsx)(z,{italic:!0,color:t,dimColor:n,children:`(current)`})});let o=e.message.content,s=typeof o==`string`?null:o[o.length-1],c=mi(typeof o==`string`?o.trim():s&&aD(s)?s.text.trim():`(no prompt)`);if(Ua(c))return(0,$.jsx)(U,{flexDirection:`row`,width:`100%`,children:(0,$.jsx)(z,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(c.includes(`<bash-input>`)){let e=Tl(c,`bash-input`);if(e)return(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,children:[(0,$.jsx)(z,{color:`bashBorder`,children:`!`}),(0,$.jsxs)(z,{color:t,dimColor:n,children:[` `,e]})]})}if(c.includes(`<command-message>`)){let e=Tl(c,gi),r=Tl(c,`command-args`),i=Tl(c,`skill-format`)===`true`;if(e)return i?(0,$.jsx)(U,{flexDirection:`row`,width:`100%`,children:(0,$.jsxs)(z,{color:t,dimColor:n,children:[`Skill(`,e,`)`]})}):(0,$.jsx)(U,{flexDirection:`row`,width:`100%`,children:(0,$.jsxs)(z,{color:t,dimColor:n,children:[`/`,e,` `,r]})})}return(0,$.jsx)(U,{flexDirection:`row`,width:`100%`,children:(0,$.jsx)(z,{color:t,dimColor:n,children:i?_a(c,a-i,!0):c.slice(0,500).split(`
2
+ `).slice(0,4).join(`
3
+ `)})})}function mD(e,t,n){let r=e.findIndex(e=>e.uuid===t);if(r===-1)return;let i=n?e.findIndex(e=>e.uuid===n):e.length;i===-1&&(i=e.length);let a=[],o=0,s=0;for(let t=r+1;t<i;t++){let n=e[t];if(!n||!q_(n))continue;let r=n.toolUseResult;if(!(!r||!r.filePath||!r.structuredPatch)){a.includes(r.filePath)||a.push(r.filePath);try{if(`type`in r&&r.type===`create`)o+=r.content.split(/\r?\n/).length;else for(let e of r.structuredPatch){let t=Ii(e.lines,e=>e.startsWith(`+`)),n=Ii(e.lines,e=>e.startsWith(`-`));o+=t,s+=n}}catch{}}}return{filesChanged:a,insertions:o,deletions:s}}function hD(e){if(e.type!==`user`||Array.isArray(e.message.content)&&e.message.content[0]?.type===`tool_result`||Tv(e)||e.isMeta||e.isCompactSummary||e.isVisibleInTranscriptOnly)return!1;let t=e.message.content,n=typeof t==`string`?null:t[t.length-1],r=typeof t==`string`?t.trim():n&&aD(n)?n.text.trim():``;return!(r.indexOf(`<local-command-stdout>`)!==-1||r.indexOf(`<local-command-stderr>`)!==-1||r.indexOf(`<bash-stdout>`)!==-1||r.indexOf(`<bash-stderr>`)!==-1||r.indexOf(`<task-notification>`)!==-1||r.indexOf(`<tick>`)!==-1||r.indexOf(`<teammate-message`)!==-1)}function gD(e,t){for(let n=t+1;n<e.length;n++){let t=e[n];if(t&&!Tv(t)&&!q_(t)&&t.type!==`progress`&&t.type!==`system`&&t.type!==`attachment`&&!(t.type===`user`&&t.isMeta)){if(t.type===`assistant`){let e=t.message.content;if(Array.isArray(e)&&e.some(e=>e.type===`text`&&e.text.trim()||e.type===`tool_use`))return!1;continue}if(t.type===`user`)return!1}}return!0}$i();var _D=ya(()=>C({method:x(`log_event`),params:C({eventName:b(),eventData:C({}).passthrough()})}));function vD(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Xh(e);t&&t.client.setNotificationHandler(_D(),e=>{let{eventName:t,eventData:n}=e.params;J(`tengu_ide_${t}`,n)})},[e])}Ke(),H();var yD=6e3;function bD(){return Date.now()-Dt()}function xD(e){return bD()<e}function SD(e){return!xD(e)}function CD(e,t){let n=M();(0,Q.useEffect)(()=>{st(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{SD(6e3)&&!r&&(r=!0,clearInterval(i),Dp({message:e,notificationType:t},n))},yD);return()=>clearInterval(i)},[e,t,n])}pg(),wu(),lc(),zf(),yC(),H(),Wd();var wD={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function TD(e){return dc().syntaxHighlightingDisabled?(0,$.jsx)(DD,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(DD,{...e,highlight:null}),children:(0,$.jsx)(ED,{...e})})}function ED(e){let t=(0,Q.use)(Ka());return(0,$.jsx)(DD,{...e,highlight:t})}function DD({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=ee(),[s]=ce(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Hl(e,s,a),[e,s,a]).split(`
4
+ `),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=>A(e))),g=Math.min(h+4,c),_=g-4,v=`${wD.topLeft}${wD.horizontal.repeat(g-2)}${wD.topRight}`,y=`${wD.bottomLeft}${wD.horizontal.repeat(g-2)}${wD.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${wD.horizontal.repeat(3)} \u2702 ${wD.horizontal.repeat(3)} ${e} lines hidden `,n=A(t),r=Math.max(0,g-2-n);return`${wD.teeLeft}${t}${wD.horizontal.repeat(r)}${wD.teeRight}`})():null;return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{dimColor:!0,children:v}),m.map((e,t)=>{let n=A(e)>_?zs(e,0,_):e,r=` `.repeat(Math.max(0,_-A(n)));return(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsxs)(z,{dimColor:!0,children:[wD.vertical,` `]}),(0,$.jsx)(me,{children:n}),(0,$.jsxs)(z,{dimColor:!0,children:[r,` `,wD.vertical]})]},t)}),b&&(0,$.jsx)(z,{color:`warning`,children:b}),(0,$.jsx)(z,{dimColor:!0,children:y})]})}m(),Fx(),H(),va();function OD({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=ee(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${h.tick} Submit `,a=i-(A(`← `)+A(` →`)+A(n));if(a<=0)return e.map((e,n)=>{let r=e?.header||`Q${n+1}`;return n===t?r.slice(0,3):``});let o=e.map((e,t)=>e?.header||`Q${t+1}`);if(o.map(e=>4+A(e)).reduce((e,t)=>e+t,0)<=a)return o;let s=4+A(o[t]||``),c=Math.min(s,a/2),l=a-c,u=e.length-1,d=Math.max(6,Math.floor(l/Math.max(u,1)));return o.map((e,n)=>n===t?ga(e,c-2-2):ga(e,d-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(U,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(z,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?h.checkboxOn:h.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(U,{children:i?(0,$.jsxs)(z,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(z,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(U,{children:t===e.length?(0,$.jsxs)(z,{backgroundColor:`permission`,color:`inverseText`,children:[` `,h.tick,` Submit`,` `]}):(0,$.jsxs)(z,{children:[` `,h.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(z,{color:t===e.length?`inactive`:void 0,children:` →`})]})}m(),Fx(),H(),Px(),tb(),su();function kD({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:u,onCancel:d,onTabPrev:f,onTabNext:p,onRespondToClaude:m,onFinishPlanInterview:g}){let _=X(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=gC(),D=E?wd(E):null,O=e.question,k=i[O],A=e.options,[j,M]=(0,Q.useState)(0),N=(0,Q.useRef)(O);if(N.current!==O){N.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;M(t>=0?t:0)}let P=A[j],F=k?.selectedValue,te=k?.textInputValue||``,I=(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]),L=(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]);De(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await _C(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),Se({"tabs:previous":()=>f?.(),"tabs:next":()=>p?.()},{context:`Tabs`,isActive:!S&&!v});let ne=(0,Q.useCallback)(()=>{C(!1),u(!1),F&&l(O,F)},[F,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?m():g();return}e.key===`escape`&&(e.preventDefault(),d());return}if(S){e.key===`escape`&&(e.preventDefault(),ne());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),j>0&&L(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),j===A.length-1?re():L(`down`);else if(e.key===`return`)e.preventDefault(),I(j);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!0),u(!0);else if(e.key===`escape`)e.preventDefault(),d();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<A.length&&L(t)}},[v,b,_,S,j,A.length,ie,re,L,I,ne,m,g,d,u]),oe=P?.preview||null,{columns:se}=ee(),ce=se-30-4,le=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:ae,children:[(0,$.jsx)(xe,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(OD,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(wC,{title:e.question,color:`text`}),(0,$.jsxs)(U,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(U,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(U,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=j===t,r=F===e.label;return(0,$.jsxs)(U,{flexDirection:`row`,children:[n?(0,$.jsx)(z,{color:`suggestion`,children:h.pointer}):(0,$.jsx)(z,{children:` `}),(0,$.jsxs)(z,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(z,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(z,{color:`success`,children:[` `,h.tick]})]},e.label)})}),(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(TD,{content:oe||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(z,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(Gd,{value:te,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:ne,onExit:ne,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(z,{dimColor:!0,italic:!0,children:te||`press n to add notes`})]})]})]}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(xe,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(z,{color:`suggestion`,children:h.pointer}):(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(z,{color:`suggestion`,children:h.pointer}):(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,h.arrowUp,`/`,h.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`]})})]})]})]})}m(),H(),tb(),hC(),su(),yC(),py(),CC();function AD({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:d,onCancel:f,onSubmit:p,onTabPrev:m,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=X(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=gC(),A=k?wd(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),d(t)},[d]),ee=(0,Q.useCallback)(()=>{w(!0)},[]),M=(0,Q.useCallback)(()=>{w(!1)},[]),N=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?M():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(),f())}},[C,T,S,M,_,v,f]),P=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),F=e.question,te=i[F],I=(0,Q.useCallback)(async(t,n)=>{let r=await _C(t);r.content!==null&&r.content!==t&&(n(r.content),l(F,{textInputValue:r.content},e.multiSelect??!1))},[F,l,e.multiSelect]),L={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:te?.textInputValue??``,onChange:t=>{l(F,{textInputValue:t},e.multiSelect??!1)}},ne=[...P,L];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(kD,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:d,onCancel:f,onTabPrev:m,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(U,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:N,children:[S&&o&&(0,$.jsxs)(U,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(xe,{color:`inactive`}),(0,$.jsxs)(z,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(df,{filePath:o})]})]}),(0,$.jsx)(U,{marginTop:-1,children:(0,$.jsx)(xe,{color:`inactive`})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(OD,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(wC,{title:e.question,color:`text`}),(0,$.jsxs)(U,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(U,{marginTop:1,children:e.multiSelect?(0,$.jsx)($y,{options:ne,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(F,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[F]?.textInputValue:void 0;u(F,e.filter(e=>e!==`__other__`).concat(t?[t]:[]),void 0,!1)},onFocus:j,onCancel:f,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:p,onDownFromLastItem:ee,isDisabled:C,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(ku,{options:ne,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(F,{selectedValue:e},!1),u(F,e,e===`__other__`?i[F]?.textInputValue:void 0)},onFocus:j,onCancel:f,onDownFromLastItem:ee,isDisabled:C,layout:`compact-vertical`,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(xe,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(z,{color:`suggestion`,children:h.pointer}):(0,$.jsx)(z,{children:` `}),(0,$.jsxs)(z,{color:C&&T===0?`suggestion`:void 0,children:[ne.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(z,{color:`suggestion`,children:h.pointer}):(0,$.jsx)(z,{children:` `}),(0,$.jsxs)(z,{color:C&&T===1?`suggestion`:void 0,children:[ne.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[h.arrowUp,`/`,h.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}function jD(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 ${P.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${P.bold(Or(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?` ${P.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${P.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 MD({permissionResult:e,toolType:t}){let n=X(e=>e.toolPermissionContext.mode),r=jD(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,ND.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[i?(0,ND.jsx)(z,{color:i,children:r.reasonString}):(0,ND.jsx)(z,{children:(0,ND.jsx)(me,{children:r.reasonString})}),r.configString&&(0,ND.jsx)(z,{dimColor:!0,children:r.configString})]})}var ND,PD=t((()=>{oe(),H(),tb(),ND=Pe()}));m(),H(),py(),CC(),PD();function FD({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(xe,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(OD,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(wC,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(z,{color:`warning`,children:[h.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(U,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(U,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(z,{children:[h.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(z,{color:`success`,children:[h.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(MD,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(z,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(ku,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function ID(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 LD={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function RD(){let[e,t]=(0,Q.useReducer)(ID,LD),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}}Ss(),Fx(),H(),Px(),tb(),vv(),pm(),Gh();var zD=12,BD=40,VD=15;function HD(e){return dc().syntaxHighlightingDisabled?(0,$.jsx)(WD,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(WD,{...e,highlight:null}),children:(0,$.jsx)(UD,{...e})})}function UD(e){let t=(0,Q.use)(Ka());return(0,$.jsx)(WD,{...e,highlight:t})}function WD({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>tl.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=ee(),[s]=ce(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(zD,o-VD);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=Hl(e.preview,s,r).split(`
5
+ `),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,A(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,zD),n),globalContentWidth:Math.max(t,BD)}},[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};Xp(s),th(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`),_=X(e=>e.toolPermissionContext.mode)===`plan`,v=_?vy():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:D}=RD(),O=y<(a?.length||0)?a?.[y]:null,k=y===(a?.length||0),j=a?.every(e=>e?.question&&!!b[e.question])??!1,M=a.length===1&&!a[0]?.multiSelect,N=(0,Q.useCallback)(()=>{u&&Y(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ep()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),P=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
6
+ This means they may have additional information, context or questions for you.
7
+ Take their response into account and then reformulate the questions if appropriate.
8
+ Start by asking them what they would like to clarify.
9
+
10
+ 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(`
11
+ `)}`;u&&Y(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ep()});let r=await GD(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),F=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
12
+ Stop asking clarifying questions and proceed to finish the plan with the information you have.
13
+
14
+ 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(`
15
+ `)}`;u&&Y(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ep()});let r=await GD(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),te=(0,Q.useCallback)(async n=>{u&&Y(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&ep()});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 GD(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),I=(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){te({...b,[e]:i}).catch(yi);return}E(e,i,r)},[E,a.length,b,te,d]);function L(e){if(e===`cancel`){N();return}e===`submit`&&te(b).catch(yi)}let ne=M?(a?.length||1)-1:a?.length||0,re=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),ie=(0,Q.useCallback)(()=>{y<ne&&C()},[y,ne,C]);return Se({"tabs:previous":re,"tabs:next":ie},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(AD,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:M,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:I,onTextInputFocus:D,onCancel:N,onSubmit:C,onTabPrev:re,onTabNext:ie,onRespondToClaude:P,onFinishPlanInterview:F,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)(FD,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:j,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:L})}):null}async function GD(e){if(e.length!==0)return Promise.all(e.map(async e=>(await _v({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var KD=[{pattern:/\bgit\s+reset\s+--hard\b/,warning:`Note: may discard uncommitted changes`},{pattern:/\bgit\s+push\b[^;&|\n]*[ \t](--force|--force-with-lease|-f)\b/,warning:`Note: may overwrite remote history`},{pattern:/\bgit\s+clean\b(?![^;&|\n]*(?:-[a-zA-Z]*n|--dry-run))[^;&|\n]*-[a-zA-Z]*f/,warning:`Note: may permanently delete untracked files`},{pattern:/\bgit\s+checkout\s+(--\s+)?\.[ \t]*($|[;&|\n])/,warning:`Note: may discard all working tree changes`},{pattern:/\bgit\s+restore\s+(--\s+)?\.[ \t]*($|[;&|\n])/,warning:`Note: may discard all working tree changes`},{pattern:/\bgit\s+stash[ \t]+(drop|clear)\b/,warning:`Note: may permanently remove stashed changes`},{pattern:/\bgit\s+branch\s+(-D[ \t]|--delete\s+--force|--force\s+--delete)\b/,warning:`Note: may force-delete a branch`},{pattern:/\bgit\s+(commit|push|merge)\b[^;&|\n]*--no-verify\b/,warning:`Note: may skip safety hooks`},{pattern:/\bgit\s+commit\b[^;&|\n]*--amend\b/,warning:`Note: may rewrite the last commit`},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*[rR][a-zA-Z]*f|(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*f[a-zA-Z]*[rR]/,warning:`Note: may recursively force-remove files`},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*[rR]/,warning:`Note: may recursively remove files`},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*f/,warning:`Note: may force-remove files`},{pattern:/\b(DROP|TRUNCATE)\s+(TABLE|DATABASE|SCHEMA)\b/i,warning:`Note: may drop or truncate database objects`},{pattern:/\bDELETE\s+FROM\s+\w+[ \t]*(;|"|'|\n|$)/i,warning:`Note: may delete all rows from a database table`},{pattern:/\bkubectl\s+delete\b/,warning:`Note: may delete Kubernetes resources`},{pattern:/\bterraform\s+destroy\b/,warning:`Note: may destroy Terraform infrastructure`}];function qD(e){for(let{pattern:t,warning:n}of KD)if(t.test(e))return n;return null}var JD=[`http://`,`https://`,`ftp://`],YD={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},XD=e=>Array.isArray(e)?e:[e];function ZD(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 QD(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(`-`)?!ZD(t,n):!1}function $D(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){QD(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||ZD(r,t))return r}}}async function eO(e,t,n){let r=await tO(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&&XD(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){QD(c,t[s+1],n)&&s++;continue}break}if(await nO(c,t.slice(0,s),n))break;a&&!o&&(o=ZD(c,n)),i.push(c)}return i.join(` `)}async function tO(e,t,n){let r=$D(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(YD[a])return YD[a];if(YD[i])return YD[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&&XD(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=XD(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=XD(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&&XD(n.args).some(e=>e?.isDangerous)?3:2}async function nO(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=JD.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&&XD(e.args).some(e=>e?.isModule))return!1}return!0}Jx();var rO=[{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 iO(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 aO=Ci(async e=>rO.find(t=>t.name===e)||await iO(e)||null,e=>e),oO=/^\d+$/,sO=/^[A-Za-z_][A-Za-z0-9_]*=/,cO=new Set([`nice`]),lO=e=>Array.isArray(e)?e:[e];function uO(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function dO(e,t=0,n=0){if(n>2||t>10)return null;let r=await Kx(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=qx(a);if(!o)return{commandPrefix:null};let c=await aO(o),l=cO.has(o)||c?.args&&lO(c.args).some(e=>e?.isCommand);l&&s[0]&&uO(s[0],c)&&(l=!1);let u=l?await fO(o,s,t,n):await eO(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 fO(e,t,n,r){let i=await aO(e);if(i?.args){let a=lO(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 dO(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(`-`)&&!sO.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!oO.test(e)&&!sO.test(e));if(!a)return e;let o=await dO(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function pO(e,t){let n=Iu(e);if(n.length<=1){let t=await dO(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await dO(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(mO(e));return a}function mO(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 hO(e){J(`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 gO=t((()=>{$i()}));Rg(),Va(),rv(),$i(),tb(),gO();function _O(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=ac(e.suggestions),n=t.length>0?t.map(e=>Co(e)).join(`, `):`none`;return`ask: ${e.message},
16
+ suggestions: ${n}
17
+ reason: ${vO(e.decisionReason)}`}case`deny`:return`deny: ${e.message},
18
+ reason: ${vO(e.decisionReason)}`;case`passthrough`:{let t=ac(e.suggestions),n=t.length>0?t.map(e=>Co(e)).join(`, `):`none`;return`passthrough: ${e.message},
19
+ suggestions: ${n}
20
+ reason: ${vO(e.decisionReason)}`}}}function vO(e){if(!e)return`No decision reason`;if(e.type===`classifier`)return`Classifier: ${e.classifier}, Reason: ${e.reason}`;switch(e.type){case`rule`:return`Rule: ${Co(e.rule.ruleValue)}`;case`mode`:return`Mode: ${e.mode}`;case`subcommandResults`:return`Subcommand Results: ${Array.from(e.reasons.entries()).map(([e,t])=>`${e}: ${_O(t)}`).join(`,
21
+ `)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${zr(e.toolResult)}`;case`hook`:return`Hook: ${e.hookName}${e.reason?`, Reason: ${e.reason}`:``}`;case`workingDir`:return`Working Directory: ${e.reason}`;case`safetyCheck`:return`Safety check: ${e.reason}`;case`other`:return`Other: ${e.reason}`;default:return zr(e,null,2)}}function yO(e,t){let n=Zs(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(r.current!==e.toolUseID){if(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),J(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:xc(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:po.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===bm.name&&t.behavior===`ask`&&!Cd(t.suggestions)&&J(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:xc(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:po.isSandboxingEnabled(),decisionReasonDetails:vO(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=bm.inputSchema.safeParse(e.input);if(e.tool.name===bm.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=_f(t.data.command)}catch{}J(`tengu_internal_bash_tool_use_permission_request`,{parts:zr(n),input:zr(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:vO(e.permissionResult.decisionReason)})}}hO({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:ka.platform}})}},[e,t,n])}L(),m(),H(),tb(),Pn(),mw();function bO(e){if(e.type===`classifier`)return`${P.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${P.bold(Or(e.rule.ruleValue))} rule from ${jr(e.rule.source)}`;case`mode`:return`${kr(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`${P.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${P.bold(e.hookName)} hook: ${e.reason}`:`${P.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function xO({title:e,decisionReason:t}){let[n]=ce();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(U,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(z,{children:[t.behavior===`allow`?Oe(`success`,n)(h.tick):Oe(`error`,n)(h.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(me,{children:bO(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(SO,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(z,{children:(0,$.jsx)(me,{children:bO(t)})})}}return(0,$.jsxs)(U,{flexDirection:`column`,children:[e&&(0,$.jsx)(z,{children:e}),r()]})}function SO({suggestions:e}){let t=qy(e);return t.length===0?null:(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(me,{children:t.map(e=>P.bold(Or(e))).join(`, `)})]})}function CO(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function wO(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function TO({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(z,{children:`None`})]});let n=qy(e),r=CO(e),i=wO(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(z,{children:`None`})]}):(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(z,{children:` `})]}),n.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(U,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(z,{children:[h.bullet,` `,Or(e)]},t))})]}),r.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(U,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(z,{children:[h.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(z,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(z,{children:kr(i)})]})]})}function EO({permissionResult:e,toolName:t}){let n=X(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=hw(n,{sandboxAutoAllowEnabled:u_.isSandboxingEnabled()&&u_.isAutoAllowBashIfSandboxedEnabled()}),r=qy(i);return r.length>0?e.filter(e=>r.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?e.filter(e=>e.rule.ruleValue.toolName===t):e},[n,t,i]);return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(z,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(z,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(z,{dimColor:!0,children:`Message `})}),(0,$.jsx)(z,{children:e.message})]}),(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(z,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(z,{children:`undefined`}):(0,$.jsx)(xO,{decisionReason:r})]}),(0,$.jsx)(TO,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(z,{color:`warning`,children:[h.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(U,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(z,{color:`warning`,children:Or(e.rule.ruleValue)}),(0,$.jsxs)(z,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(z,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}D(),aa(),K(),Vr(),ba(),vi(),Qx(),Eh(),Fr();var DO={LOW:1,MEDIUM:2,HIGH:3},OO=1,kO=2,AO=3,jO=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,MO={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`]}},NO=ya(()=>C({riskLevel:S([`LOW`,`MEDIUM`,`HIGH`]),explanation:b(),reasoning:b(),risk:b()}));function PO(e){if(typeof e==`string`)return e;try{return zr(e,null,2)}catch{return String(e)}}function FO(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(`
22
+
23
+ `)}function IO(){return W().permissionExplainerEnabled!==!1}async function LO({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!IO())return null;let a=Date.now();try{let o=PO(t),s=r?.length?FO(r):``,c=`Tool: ${e}
24
+ ${n?`Description: ${n}\n`:``}
25
+ Input:
26
+ ${o}
27
+ ${s?`\nRecent conversation context:\n${s}`:``}
28
+
29
+ Explain this command in context.`,l=await _p({model:Zx()?Kt():sn(),system:jO,messages:[{role:`user`,content:c}],tools:[MO],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: ${zr(d.input).slice(0,500)}`);let t=NO().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 Y(`tengu_permission_explainer_generated`,{tool_name:rn(e),risk_level:DO[n.riskLevel],latency_ms:u}),q(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Y(`tengu_permission_explainer_error`,{tool_name:rn(e),error_type:OO,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: ${Kr(t)}`),yi(t),Y(`tengu_permission_explainer_error`,{tool_name:rn(e),error_type:t instanceof Error&&t.name===`AbortError`?kO:AO,latency_ms:n}),null)}}H(),Px(),aa();var RO=`Loading explanation…`;function zO(){let[e,t]=Vp(`responding`,RO,!1);return(0,$.jsx)(U,{ref:e,children:(0,$.jsx)(z,{children:RO.split(``).map((e,n)=>(0,$.jsx)(pu,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function BO(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function VO(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function HO(e){return LO({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function UO(e){let t=IO(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return De(`confirm:toggleExplanation`,()=>{n||(Y(`tengu_permission_explainer_shortcut_used`,{}),i||a(HO(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function WO({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(z,{children:t.explanation}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{children:t.reasoning})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{color:BO(t.riskLevel),children:[VO(t.riskLevel),`:`]}),(0,$.jsxs)(z,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,children:`Explanation unavailable`})})}function GO({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(zO,{})}),children:(0,$.jsx)(WO,{promise:t})})}Ke(),Pg();var KO=5e3;function qO(e,t){return t===0?e:e.map(e=>({...e,oldStart:e.oldStart+t,newStart:e.newStart+t}))}var JO=`<<:AMPERSAND_TOKEN:>>`,YO=`<<:DOLLAR_TOKEN:>>`;function XO(e){return e.replaceAll(`&`,JO).replaceAll(`$`,YO)}function ZO(e){return e.replaceAll(JO,`&`).replaceAll(YO,`$`)}function QO({filePath:e,oldContent:t,newContent:n,ignoreWhitespace:r=!1,singleHunk:i=!1}){let a=Cs(e,e,XO(t),XO(n),void 0,void 0,{ignoreWhitespace:r,context:i?1e5:3,timeout:KO});return a?a.hunks.map(e=>({...e,lines:e.lines.map(ZO)})):[]}function $O({filePath:e,fileContents:t,edits:n,ignoreWhitespace:r=!1}){let i=XO(lr(t)),a=Cs(e,e,i,n.reduce((e,t)=>{let{old_string:n,new_string:r}=t,i=`replace_all`in t?t.replace_all:!1,a=XO(lr(n)),o=XO(lr(r));return i?e.replaceAll(a,()=>o):e.replace(a,()=>o)},i),void 0,void 0,{context:3,ignoreWhitespace:r,timeout:KO});return a?a.hunks.map(e=>({...e,lines:e.lines.map(ZO)})):[]}wn(),Vr();var ek=8*1024,tk=10*1024*1024,nk=10;async function rk(e){try{return await sE(e,`r`)}catch(e){if(Ir(e))return null;throw e}}async function ik(e,t,n){if(t===``)return{content:``,lineOffset:1,truncated:!1};let r=Buffer.from(t,`utf8`),i=0;for(let e=0;e<r.length;e++)r[e]===nk&&i++;let a,o=r.length+i-1,s=Buffer.allocUnsafe(ek+o),c=0,l=0,u=0;for(;c<tk;){let{bytesRead:d}=await e.read(s,u,ek,c);if(d===0)break;let f=u+d,p=ok(s,r,f),m=r.length;if(p===-1&&i>0&&(a??(a=Buffer.from(t.replaceAll(`
30
+ `,`\r
31
+ `),`utf8`)),p=ok(s,a,f),m=a.length),p!==-1)return await lk(e,s,c-u+p,m,n,l+sk(s,0,p));c+=d;let h=Math.min(o,f);l+=sk(s,0,f-h),u=h,s.copyWithin(0,f-u,f)}return{content:``,lineOffset:1,truncated:c>=tk}}async function ak(e){let t=Buffer.allocUnsafe(ek),n=0;for(;;){if(n===t.length){let e=Buffer.allocUnsafe(Math.min(t.length*2,tk+ek));t.copy(e,0,0,n),t=e}let{bytesRead:r}=await e.read(t,n,t.length-n,n);if(r===0)break;if(n+=r,n>10485760)return null}return ck(t,n)}function ok(e,t,n){let r=e.indexOf(t);return r===-1||r+t.length>n?-1:r}function sk(e,t,n){let r=0;for(let i=t;i<n;i++)e[i]===nk&&r++;return r}function ck(e,t){let n=e.toString(`utf8`,0,t);return n.includes(`\r`)?n.replaceAll(`\r
32
+ `,`
33
+ `):n}async function lk(e,t,n,r,i,a){let o=Math.min(n,ek),{bytesRead:s}=await e.read(t,0,o,n-o),c=n,l=0;for(let e=s-1;e>=0&&l<=i&&!(t[e]===nk&&(l++,l>i));e--)c--;let u=a-sk(t,s-(n-c),s)+1,d=n+r,{bytesRead:f}=await e.read(t,0,ek,d),p=d;l=0;for(let e=0;e<f&&(p++,!(t[e]===nk&&(l++,l>=i+1)));e++);let m=p-c,h=m<=t.length?t:Buffer.allocUnsafe(m),{bytesRead:g}=await e.read(h,0,m,c);return{content:ck(h,g),lineOffset:u,truncated:!1}}Fx(),H(),vi(),Bo();function uk(e){let[t]=(0,Q.useState)(()=>pk(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(fk,{placeholder:!0}),children:(0,$.jsx)(dk,{promise:t,file_path:e.file_path})})}function dk({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=ee();return(0,$.jsx)(fk,{children:(0,$.jsx)(Yu,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function fk({children:e,placeholder:t}){return(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(U,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(z,{dimColor:!0,children:`…`}):e})})}async function pk(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 mk(e,[r]);try{let t=await rk(e);if(t===null)return mk(e,n);try{if(!r||r.old_string===``){let r=await ak(t);return r===null?mk(e,n):{patch:$O({filePath:e,fileContents:r,edits:n.map(e=>hk(r,e))}),firstLine:ea(r),fileContent:r}}let i=await ik(t,r.old_string,3);if(i.truncated||i.content===``)return mk(e,[r]);let a=hk(i.content,r);return{patch:qO($O({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?ea(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return yi(t),mk(e,n)}}function mk(e,t){return{patch:t.flatMap(t=>$O({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function hk(e,t){let n=jc(e,t.old_string)||t.old_string;return{...t,old_string:n}}pd(),$i(),Gf(),mn(),Vr(),su(),vi();function gk({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)(()=>oE().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Claude Code] ${KT(n)} (${c}) ⧉`,[n,c]),u=Al(t.options.mcpClients)&&W().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=lo(t.options.mcpClients)??`IDE`;async function f(){if(u)try{J(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await vk(n,r,t,l);if(a.current)return;J(`tengu_ext_diff_accepted`,{});let c=_k(n,o,s,i);if(c.length===0){J(`tengu_ext_diff_rejected`,{});let i=Xh(t.options.mcpClients);i&&await yk(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){yi(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Xh(t.options.mcpClients);return e?yk(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function _k(e,t,n,r){let i=r===`single`,a=QO({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&yi(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),Of(a))}async function vk(e,t,n,r){let i=!1,a=Vh(e),o=``;try{o=cu(a)}catch(e){if(!Ir(e))throw e}async function s(){if(!i){i=!0;try{await yk(r,c)}catch(e){yi(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Xh(n.options.mcpClients);try{let{updatedFile:e}=hf({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;Di()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Wc(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await Vf(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(Sk(u))return s(),{oldContent:o,newContent:u[1].text};if(bk(u))return s(),{oldContent:o,newContent:e};if(xk(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw yi(e),s(),e}}async function yk(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await Vf(`close_tab`,{tab_name:e},t)}catch(e){yi(e)}}function bk(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 xk(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 Sk(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}H(),qr(),su(),py();function Ck({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)(we,{color:`permission`,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(z,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(z,{color:`warning`,children:ZT(Jr(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),wo()&&(0,$.jsx)(z,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(z,{children:[`Do you want to make this edit to `,(0,$.jsx)(z,{bold:!0,children:KT(r)}),`?`]}),(0,$.jsx)(ku,{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)(U,{marginTop:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Ke(),H();function wk(e){let t=Ai(e),n=Ai(`${Ye()}/.claude`),r=Jl(t),i=Jl(n);return r.startsWith(i+$T.toLowerCase())||r.startsWith(i+`/`)}function Tk(e){let t=Ai(e),n=YT(UT(),`.zaniicode`),r=Jl(t),i=Jl(n);return r.startsWith(i+$T.toLowerCase())||r.startsWith(i+`/`)}function Ek({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=z_(`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=uo(e,t),u=wk(e),d=Tk(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)(z,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(z,{bold:!0,children:[`(`,c,`)`]})]});else{let r=KT(Mi(e))||`this directory`;t=n===`read`?(0,$.jsxs)(z,{children:[`Yes, allow reading from `,(0,$.jsxs)(z,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(z,{children:[`Yes, allow all edits in `,(0,$.jsxs)(z,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(z,{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}aa(),Er(),Da(),hs(),gO();function Dk(e,t,n,r,i){hO({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:ka.platform,hasFeedback:i??!1}})}function Ok(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;Dk(`accept`,a,o,n),Y(`tengu_accept_submitted`,{toolName:rn(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 kk(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(Dk(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Tb,ruleContent:t.scope===`global-claude-folder`?Nb:kb}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?By(r,l,a):[];o(),i.onAllow(i.input,u)}function Ak(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;Dk(`reject`,o,s,n,t?.hasFeedback),Y(`tengu_reject_submitted`,{toolName:rn(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 jk={"accept-once":Ok,"accept-session":kk,reject:Ak};S_(),Px(),aa(),Er();function Mk({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=Z(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)(()=>Ek({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=jk[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 Se({"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:rn(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),Y(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),b(!0),Y(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(v(!1),Y(`tengu_reject_feedback_mode_collapsed`,t)):(v(!0),S(!0),Y(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}H(),vv(),qr(),ki(),py();function Nk({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,workerBadge:p,languageName:m}){let h=(0,Q.useMemo)(()=>m??(l?mm(l):`none`),[m,l]);yO(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:h}),[c,h]));let g=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=Ai(l),{resolvedPath:t,isSymlink:n}=Gr(Ur(),e);return n?t:null},[l,d]),_=Mk({filePath:l||``,completionType:c,languageName:h,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:v,acceptFeedback:y,rejectFeedback:b,setFocusedOption:x,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:T}=_,E=u(e.input),D=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:O,showingDiffInIDE:k,ideName:A}=gk(D?{onChange:(e,t)=>{let n=f.applyChanges(E,t.edits);_.onChange(e,n)},toolUseContext:t,filePath:D.filePath,edits:(D.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:D.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),j=(e,t)=>{O?.(),_.onChange(e,E,t?.trim())};if(k&&D&&l)return(0,$.jsx)(Ck,{onChange:(e,t,n)=>j(e,n),options:v,filePath:l,input:E,ideName:A,symlinkTarget:g,rejectFeedback:b,acceptFeedback:y,setFocusedOption:x,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:T});let ee=g!=null&&ZT(Jr(),g).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(EC,{title:i,subtitle:a,innerPaddingX:0,workerBadge:p,children:[g?(0,$.jsx)(U,{paddingX:1,marginBottom:1,children:(0,$.jsx)(z,{color:`warning`,children:ee?`This will modify ${g} (outside working directory) via a symlink`:`Symlink target: ${g}`})}):null,s,(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(z,{children:o}):o,(0,$.jsx)(ku,{options:v,inlineDescriptions:!0,onChange:e=>{let t=v.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=b.trim();j(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=y.trim();j(t.option,e||void 0);return}j(t.option)}},onCancel:()=>j({type:`reject`}),onFocus:e=>x(e),onInputModeToggle:S})]})]}),(0,$.jsx)(U,{paddingX:1,marginTop:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!T)&&` · Tab to add feedback`]})})]})}Nl(),H(),Sv();function Pk({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Fk,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=yl(n);return{oldContent:(await kf().readFile(n,{encoding:e})).replaceAll(`\r
34
+ `,`
35
+ `),fileExists:!0}})().catch(e=>{if(!Vb(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Fk({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>xv(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)(Nk,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:ZT(Xx(),r),question:(0,$.jsxs)(z,{children:[`Do you want to make this edit to `,(0,$.jsx)(z,{bold:!0,children:KT(r)}),`?`]}),content:s.length>0?(0,$.jsx)(uk,{file_path:r,edits:s}):(0,$.jsx)(z,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...bm.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}}),workerBadge:n.workerBadge})}Da(),gO();function Ik(e,{assistantMessage:{message:{id:t}}},n,r){hO({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Oa(),hasFeedback:r??!1}})}aa(),Er(),tb();function Lk({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Zs(),[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:rn(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),Y(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),Y(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),Y(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),Y(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(Y(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),Ik(`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}}function Rk(e){return e.match(/^(.+):\*$/)?.[1]??null}Ke(),H();function zk(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(z,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(z,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(z,{bold:!0,children:e.slice(-1)[0]})]})}}function Bk(e){return e.join(`, `).length>50?`similar`:zk(e)}function Vk(e){if(e.length===0)return``;let t=e.map(e=>KT(e)||e);return t.length===1?(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{bold:!0,children:t[0]}),$T]}):t.length===2?(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{bold:!0,children:t[0]}),$T,` and `,(0,$.jsx)(z,{bold:!0,children:t[1]}),$T]}):(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{bold:!0,children:t[0]}),$T,`, `,(0,$.jsx)(z,{bold:!0,children:t[1]}),$T,` and `,e.length-2,` more`]})}function Hk(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=Rk(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)(z,{children:[`Yes, allow reading from `,(0,$.jsx)(z,{bold:!0,children:KT(e)||e}),$T,` from this project`]})}return(0,$.jsxs)(z,{children:[`Yes, allow reading from `,Vk(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(z,{children:[`Yes, and always allow access to `,(0,$.jsx)(z,{bold:!0,children:KT(e)||e}),$T,` from this project`]})}return(0,$.jsxs)(z,{children:[`Yes, and always allow access to `,Vk(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,Bk(c),` commands in `,(0,$.jsx)(z,{bold:!0,children:Ye()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(z,{children:[`Yes, and always allow access to `,Vk(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(z,{children:[`Yes, and allow access to `,Vk(e),` and `,Bk(c),` commands`]}):(0,$.jsxs)(z,{children:[`Yes, and allow `,Vk(e),` access and `,Bk(c),` commands`]})}return null}rl();function Uk(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function Wk(e){let{commandWithoutRedirections:t,redirections:n}=mc(e);return n.length>0?t:e}function Gk({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`}),Go()){let n=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!n&&e.length>0)f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., npm run:*)`,initialValue:u,onChange:d,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else if(e.length>0){let t=Hk(e,Mb,Wk);t&&f.push({label:t,value:`yes-apply-suggestions`})}let r=f.some(e=>e.value===`yes-prefix-edited`);process.env.USER_TYPE===`ant`&&!r&&K_()&&i&&!o&&!Uk(a??``,s)&&t?.type!==`classifier`&&f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-classifier-reviewed`,placeholder:`describe what to allow...`,initialValue:a??``,onChange:i,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0})}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}H(),Px(),Zn(),aa(),Er(),tb(),Sv(),Fg(),Rg(),Ap(),Wm(),ob(),Va(),rv(),TC(),PD();function Kk(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o}=e,{command:s,description:c}=bm.inputSchema.parse(t.input),l=W_(s);return l?(0,$.jsx)(Pk,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,sedInfo:l}):(0,$.jsx)(qk,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,command:s,description:c})}function qk({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,command:o,description:s}){let[c]=ce(),l=X(e=>e.toolPermissionContext),u=UO({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:d,noInputMode:f,yesFeedbackModeEntered:p,noFeedbackModeEntered:m,acceptFeedback:h,rejectFeedback:g,setAcceptFeedback:_,setRejectFeedback:v,focusedOption:y,handleInputModeToggle:b,handleReject:x,handleFocus:S}=Lk({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:u.visible}),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(s||``),[D,O]=(0,Q.useState)(!s?.trim());(0,Q.useEffect)(()=>{if(!K_())return;let e=new AbortController;return xm(o,s,e.signal).then(t=>{t&&!e.signal.aborted&&(E(t),O(!1))}).catch(()=>{}),()=>e.abort()},[o,s]);let k=e.permissionResult.decisionReason?.type===`subcommandResults`,[A,j]=(0,Q.useState)(()=>{if(k){let t=qy(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===bm.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=_u(o);if(t)return`${t}:*`;let n=Rf(o);return n?`${n}:*`:o}),ee=(0,Q.useRef)(!1),M=(0,Q.useCallback)(e=>{ee.current=!0,j(e)},[]);(0,Q.useEffect)(()=>{if(k)return;let e=!1;return pO(o,e=>bm.isReadOnly({command:e})).then(t=>{e||ee.current||t.length>0&&j(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[o,k]);let[N]=(0,Q.useState)(!1),{destructiveWarning:P,sandboxingEnabled:F,isSandboxed:te}=(0,Q.useMemo)(()=>{let t=Jn(`tengu_destructive_command_warning`,!1)?qD(o):null,n=u_.isSandboxingEnabled();return{destructiveWarning:t,sandboxingEnabled:n,isSandboxed:n&&b_(e.input)}},[o,e.input]);yO(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let I=(0,Q.useMemo)(()=>wv(l),[l]),L=(0,Q.useMemo)(()=>Gk({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,onClassifierDescriptionChange:E,classifierDescription:T,initialClassifierDescriptionEmpty:D,existingAllowDescriptions:I,yesInputMode:d,noInputMode:f,editablePrefix:A,onEditablePrefixChange:M}),[e,T,D,I,d,f,A,M]);De(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`}),De(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function ne(t){Y(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:u.visible});let r=rn(e.tool.name);if(t===`yes-prefix-edited`){let t=(A??``).trim();if(Ik(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:bm.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=h.trim();Ik(`tool_use_single`,e,`accept`),Y(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{Ik(`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=g.trim();Y(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:m}),x(t||void 0);break}}}return(0,$.jsxs)(EC,{workerBadge:a,title:F&&!te?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(z,{dimColor:u.visible,children:bm.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!u.visible&&(0,$.jsx)(z,{dimColor:!0,children:e.description}),(0,$.jsx)(GO,{visible:u.visible,promise:u.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(EO,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(MD,{permissionResult:e.permissionResult,toolType:`command`}),P&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(z,{color:`warning`,dimColor:!1,children:P})}),(0,$.jsx)(z,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(ku,{options:L,isDisabled:!1,inlineDescriptions:!0,onChange:ne,onCancel:()=>x(),onFocus:S,onInputModeToggle:b})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(z,{dimColor:!0,children:[`Esc to reject`,(y===`yes`&&!d||y===`no`&&!f)&&` · Tab to add feedback`,u.enabled&&` · ctrl+e to ${u.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(z,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ke(),H(),aa(),tb(),Zm(),py(),TC();function Jk({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let i=X(e=>e.toolPermissionContext.mode);function a(r){r===`yes`?(Y(`tengu_plan_enter`,{interviewPhaseEnabled:ep(),entryMethod:`tool`}),Xe(i,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(EC,{color:`planMode`,title:`Enter plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(z,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(z,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(z,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(z,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(z,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(z,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(ku,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:a,onCancel:()=>a(`no`)})})]})})}m(),$i(),S_(),Ke(),eT(),Hg(),H(),Jt(),hC(),Zt(),su(),vi(),lp(),Lf(),Ht(),Rg(),sr(),gy(),Zm(),Uo(),yC(),Fp(),py(),TC(),PD(),pm(),pg();var Yk=(Pc(),e(Ns));function Xk(e,t){let n=[{type:`setMode`,mode:vn(e),destination:`session`}];return K_()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Pa(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Zk(e,t,n){ot()||cn()?.cleanupPeriodDays===0||!n&&Y_(ft())||tT([Ph({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Y_(ft()))return;let n=ft(),r=lh();await ov(n,e,r,`auto`),await Th(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(yi)}function Qk({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r,setStickyFooter:i}){let a=Z(e=>e.toolPermissionContext),o=nf(),s=vf(),{addNotification:c}=ul(),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0),m=Z(e=>e.settings.showClearContextOnPlanAccept)??!1,g=Z(e=>e.ultraplanSessionUrl),_=Z(e=>e.ultraplanLaunching),v=!g&&!_,y=e.assistantMessage.message.usage,{mode:b,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S}=a,C=(0,Q.useMemo)(()=>$k({showClearContext:m,showUltraplan:v,usedPercent:m?eA(y,b):null,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S,onFeedbackChange:u}),[m,v,y,b,x,S]);function w(e,t,n,r,i){let a=p.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};Xp(o),th(o),f(e=>({...e,[a]:o}))}let T=(0,Q.useCallback)(e=>{f(t=>{let n={...t};return delete n[e],n})},[]),E=Object.values(d).filter(e=>e.type===`image`),D=E.length>0,O=e.tool.name===Pb,k=O?void 0:e.input.plan,A=O?vy():void 0,j=e.input.allowedPrompts,ee=k??Mo(),M=!ee||ee.trim()===``,[N]=(0,Q.useState)(()=>sh()??void 0),[P,F]=(0,Q.useState)(()=>k||(Mo()??`No plan found. Please write your plan to the plan file first.`)),[te,I]=(0,Q.useState)(!1),[L,ne]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(te){let e=setTimeout(I,5e3,!1);return()=>clearTimeout(e)}},[te]);let re=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),J(`tengu_plan_external_editor_used`,{}),(async()=>{if(O&&A){let e=await bC(A);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==P&&ne(!0),F(e.content),I(!0))}else{let e=await _C(P);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==P&&(F(e.content),I(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),ie(m?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function ie(r){let i=l.trim(),c=i||void 0;if(r===`ultraplan`){J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`ultraplan`,interviewPhaseEnabled:ep(),planStructureVariant:N}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),X_({blurb:``,seedPlan:P,getAppState:s.getState,setAppState:s.setState,signal:new AbortController().signal}).then(e=>hm({value:e,mode:`task-notification`})).catch(yi);return}let u=O&&!L?{}:{plan:P};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Vo(),t=Yk?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Yk?.setAutoModeActive(!1),vt(!0),o(e=>({...e,toolPermissionContext:{...bl(e.toolPermissionContext),prePlanMode:void 0}})))}let d=r===`yes-accept-edits-keep-context`||r===`yes-default-keep-context`||r===`yes-resume-auto-mode`;if(r!==`no`&&Zk(P,o,!d),r!==`no`&&!d){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&Vo()&&(i=`auto`,Yk?.setAutoModeActive(!0)),J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!0,interviewPhaseEnabled:ep(),planStructureVariant:N,hasFeedback:!!c});let a=`\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: ${lh()}`,s=Gn()?`\n\nIf this plan can be broken down into multiple independent tasks, consider using the ${x_} tool to create a team and parallelize the work.`:``,l=c?`\n\nUser feedback on this plan: ${c}`:``;o(e=>({...e,initialMessage:{message:{...Ph({content:`Implement the following plan:\n\n${P}${a}${s}${l}`}),planContent:P},clearContext:!0,mode:i,allowedPrompts:j}})),Ct(!0),Ie(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Vo()){J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ep(),planStructureVariant:N,hasFeedback:!!c}),Ct(!0),Ie(!0),Yk?.setAutoModeActive(!0),o(e=>({...e,toolPermissionContext:Xl({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(u,[],c);return}let f={"yes-accept-edits-keep-context":a.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(f){J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ep(),planStructureVariant:N,hasFeedback:!!c}),Ct(!0),Ie(!0),t(),e.onAllow(u,Xk(f,j),c);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,interviewPhaseEnabled:ep(),planStructureVariant:N,hasFeedback:!!c}),Ct(!0),Ie(!0),t(),e.onAllow(u,Xk(p,j),c);return}if(r===`no`){if(!i&&!D)return;J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:ep(),planStructureVariant:N});let r;D&&(r=await Promise.all(E.map(async e=>(await _v({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(i||(D?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let ae=gC(),oe=ae?wd(ae):null,se=(0,Q.useRef)(ie);se.current=ie;let ce=(0,Q.useRef)(void 0);ce.current=()=>{J(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:ep(),planStructureVariant:N}),t(),n(),e.onReject()};let le=!M&&!!i;if((0,Q.useLayoutEffect)(()=>{if(le)return i((0,$.jsxs)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(z,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(ku,{options:C,onChange:e=>void se.current(e),onCancel:()=>ce.current?.(),onImagePaste:w,pastedContents:d,onRemoveImage:T})}),oe&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(z,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(z,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(z,{dimColor:!0,children:[` · `,dn(A)]}),te&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{dimColor:!0,children:` · `}),(0,$.jsxs)(z,{color:`success`,children:[h.tick,`Plan saved!`]})]})]})]})),()=>i(null)},[le,i,C,d,oe,O,A,te]),M){function i(r){r===`yes`?(J(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:ep(),planStructureVariant:N}),(Yk?.isAutoModeActive()??!1)&&(Yk?.setAutoModeActive(!1),vt(!0),o(e=>({...e,toolPermissionContext:{...bl(e.toolPermissionContext),prePlanMode:void 0}}))),Ct(!0),Ie(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(J(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ep(),planStructureVariant:N}),t(),n(),e.onReject())}return(0,$.jsx)(EC,{color:`planMode`,title:`Exit plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(z,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(ku,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:i,onCancel:()=>{J(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ep(),planStructureVariant:N}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(U,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:re,children:[(0,$.jsx)(EC,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(U,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(z,{children:`Here is Claude's plan:`})}),(0,$.jsx)(U,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Hv,{children:P})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(MD,{permissionResult:e.permissionResult,toolType:`tool`}),K_()&&j&&j.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(z,{bold:!0,children:`Requested permissions:`}),j.map((e,t)=>(0,$.jsxs)(z,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!le&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(ku,{options:C,onChange:ie,onCancel:()=>ce.current?.(),onImagePaste:w,pastedContents:d,onRemoveImage:T})})]})]})]})}),!le&&oe&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(z,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(z,{dimColor:!0,children:[` · `,dn(A)]})]}),te&&(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:` · `}),(0,$.jsxs)(z,{color:`success`,children:[h.tick,`Plan saved!`]})]})]})]})}function $k({showClearContext:e,showUltraplan:t,usedPercent:n,isAutoModeAvailable:r,isBypassPermissionsModeAvailable:i,onFeedbackChange:a}){let o=[],s=n===null?``:` (${n}% used)`;return e&&(r?o.push({label:`Yes, clear context${s} and use auto mode`,value:`yes-auto-clear-context`}):i?o.push({label:`Yes, clear context${s} and bypass permissions`,value:`yes-bypass-permissions`}):o.push({label:`Yes, clear context${s} and auto-accept edits`,value:`yes-accept-edits`})),r?o.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):i?o.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):o.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),o.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),t&&o.push({label:`No, refine with Ultraplan on Claude Code on the web`,value:`ultraplan`}),o.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Claude what to change`,description:`shift+tab to approve with this feedback`,onChange:a}),o}function eA(e,t){if(!e)return null;let n=Xn(It({permissionMode:t,mainLoopModel:sn(),exceeds200kTokens:!1}),gt()),{used:r}=Cn({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 tA({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Zs(),[o,s]=(0,nA.useState)(``),[c,l]=(0,nA.useState)(``),[u,d]=(0,nA.useState)(!1),[f,p]=(0,nA.useState)(!1),[m,h]=(0,nA.useState)(null),[g,_]=(0,nA.useState)(!1),[v,y]=(0,nA.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,nA.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=iA[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,nA.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),Y(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),Y(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),Y(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),y(!0),Y(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),w=(0,nA.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`?Y(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&Y(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);Se((0,nA.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,nA.useCallback)(()=>{Y(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,rA.jsxs)(U,{flexDirection:`column`,children:[typeof r==`string`?(0,rA.jsx)(z,{children:r}):r,(0,rA.jsx)(ku,{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,rA.jsx)(U,{marginTop:1,children:(0,rA.jsxs)(z,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var nA,rA,iA,aA=t((()=>{nA=n(oe(),1),H(),Px(),aa(),tb(),ob(),rA=Pe(),iA={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));nS(),ph(),cm(),jd(),Fl(),sb(),BS(),Ke(),H(),Er(),Da(),ed(),Zi(),gO(),TC(),aA(),PD();function oA({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ce(),o=e.tool.userFacingName(e.input),s=o.endsWith(` (MCP)`)?o.slice(0,-6):o;yO(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ka.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ka.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ka.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ka.platform}}),e.onReject(),n(),t()},[e,t,n]),u=Ye(),d=Go(),f=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return d&&e.push({label:(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,(0,$.jsx)(z,{bold:!0,children:s}),` commands in`,` `,(0,$.jsx)(z,{bold:!0,children:u})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[s,u,d]),p=(0,Q.useMemo)(()=>({toolName:rn(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(EC,{title:`Tool use`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(z,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:!0}),`)`,o.endsWith(` (MCP)`)?(0,$.jsx)(z,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(z,{dimColor:!0,children:ia(e.description,3)})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(MD,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(tA,{options:f,onSelect:c,onCancel:l,toolAnalyticsContext:p})]})]})}function sA(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}Yx(),H();var cA={getConfig:e=>sA(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 lA(e){let t=e=>Lp.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Nk,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit file`,subtitle:ZT(Xx(),n),question:(0,$.jsxs)(z,{children:[`Do you want to make this edit to `,(0,$.jsx)(z,{bold:!0,children:KT(n)}),`?`]}),content:(0,$.jsx)(uk,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:cA})}H();function uA(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 dA({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i,workerBadge:a}){let[o]=ce(),s=uA(e),c=e.tool.userFacingName(e.input),l=e.tool.isReadOnly(e.input),u=`${l?`Read`:`Edit`} file`;return s?(0,$.jsx)(Nk,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,workerBadge:a,title:u,content:(0,$.jsx)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(z,{children:[c,`(`,e.tool.renderToolUseMessage(e.input,{theme:o,verbose:r}),`)`]})}),path:s,parseInput:e=>e,operationType:l?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(oA,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r,workerBadge:a})}Fx(),H(),Li(),rs();function fA({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=ee(),a=(0,Q.useMemo)(()=>n?$O({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
36
+ `)[0]??null;return(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(U,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?Ui(a.map(t=>(0,$.jsx)(Ay,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(F,{fromLeftEdge:!0,children:(0,$.jsx)(z,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ys,{code:t||`(No content)`,filePath:e})})})}H(),qr(),Vr();var pA={getConfig:e=>{let t;try{t=qn(e.file_path)}catch(e){if(!Ir(e))throw e;t=``}return sA(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function mA(e){let t=e=>hy.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:qn(n)}}catch(e){if(!Ir(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Nk,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:i?`Overwrite file`:`Create file`,subtitle:ZT(Jr(),n),question:(0,$.jsxs)(z,{children:[`Do you want to `,o,` `,(0,$.jsx)(z,{bold:!0,children:KT(n)}),`?`]}),content:(0,$.jsx)(fA,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:pA})}Hr(),ki(),Fr();function hA(e){let t=e.match(/^cell-(\d+)$/);if(t&&t[1]){let e=parseInt(t[1],10);return isNaN(e)?void 0:e}}H(),Li(),qr(),Hr(),rs(),pd();function gA(e){let t=(0,Q.useMemo)(()=>Ur().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>Pi(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_A,{...e,promise:t})})}function _A({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=hA(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:$O({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)(U,{flexDirection:`column`,children:(0,$.jsxs)(U,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(U,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:a?e:ZT(Jr(),e)}),(0,$.jsxs)(z,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ys,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ys,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Ui(u.map(t=>(0,$.jsx)(Ay,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
37
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(F,{fromLeftEdge:!0,children:(0,$.jsx)(z,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ys,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}H(),vi();function vA(e){let t=e=>{let t=fv.inputSchema.safeParse(e);return t.success?t.data:(yi(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)(Nk,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit notebook`,question:(0,$.jsxs)(z,{children:[`Do you want to `,s,` `,(0,$.jsx)(z,{bold:!0,children:KT(r)}),`?`]}),content:(0,$.jsx)(gA,{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})}var yA=[{pattern:/(?:^|[|;&\n({])\s*(Remove-Item|rm|del|rd|rmdir|ri)\b[^|;&\n}]*-Recurse\b[^|;&\n}]*-Force\b/i,warning:`Note: may recursively force-remove files`},{pattern:/(?:^|[|;&\n({])\s*(Remove-Item|rm|del|rd|rmdir|ri)\b[^|;&\n}]*-Force\b[^|;&\n}]*-Recurse\b/i,warning:`Note: may recursively force-remove files`},{pattern:/(?:^|[|;&\n({])\s*(Remove-Item|rm|del|rd|rmdir|ri)\b[^|;&\n}]*-Recurse\b/i,warning:`Note: may recursively remove files`},{pattern:/(?:^|[|;&\n({])\s*(Remove-Item|rm|del|rd|rmdir|ri)\b[^|;&\n}]*-Force\b/i,warning:`Note: may force-remove files`},{pattern:/\bClear-Content\b[^|;&\n]*\*/i,warning:`Note: may clear content of multiple files`},{pattern:/\bFormat-Volume\b/i,warning:`Note: may format a disk volume`},{pattern:/\bClear-Disk\b/i,warning:`Note: may clear a disk`},{pattern:/\bgit\s+reset\s+--hard\b/i,warning:`Note: may discard uncommitted changes`},{pattern:/\bgit\s+push\b[^|;&\n]*\s+(--force|--force-with-lease|-f)\b/i,warning:`Note: may overwrite remote history`},{pattern:/\bgit\s+clean\b(?![^|;&\n]*(?:-[a-zA-Z]*n|--dry-run))[^|;&\n]*-[a-zA-Z]*f/i,warning:`Note: may permanently delete untracked files`},{pattern:/\bgit\s+stash\s+(drop|clear)\b/i,warning:`Note: may permanently remove stashed changes`},{pattern:/\b(DROP|TRUNCATE)\s+(TABLE|DATABASE|SCHEMA)\b/i,warning:`Note: may drop or truncate database objects`},{pattern:/\bStop-Computer\b/i,warning:`Note: will shut down the computer`},{pattern:/\bRestart-Computer\b/i,warning:`Note: will restart the computer`},{pattern:/\bClear-RecycleBin\b/i,warning:`Note: permanently deletes recycled files`}];function bA(e){for(let{pattern:t,warning:n}of yA)if(t.test(e))return n;return null}Js();var xA=new Set([`invoke-command`,`start-job`,`start-threadjob`,`register-scheduledjob`]),SA=new Set([`invoke-command`,`invoke-expression`,`start-job`,`start-threadjob`,`register-scheduledjob`,`register-engineevent`,`register-objectevent`,`register-wmievent`,`new-pssession`,`enter-pssession`]),CA=new Set([`import-module`,`ipmo`,`install-module`,`save-module`,`update-module`,`install-script`,`save-script`]),wA=[`pwsh`,`powershell`,`cmd`,`bash`,`wsl`,`sh`,`start-process`,`start`,`add-type`,`new-object`];function TA(e){return Object.entries(kd).filter(([,t])=>e.has(t.toLowerCase())).map(([e])=>e)}var EA=new Set([`invoke-webrequest`,`invoke-restmethod`]),DA=new Set([`set-alias`,`sal`,`new-alias`,`nal`,`set-variable`,`sv`,`new-variable`,`nv`]),OA=new Set([`invoke-wmimethod`,`iwmi`,`invoke-cimmethod`]),kA=new Set([`select-object`,`sort-object`,`group-object`,`where-object`,`measure-object`,`write-output`,`write-host`,`start-sleep`,`format-table`,`format-list`,`format-wide`,`format-custom`,`out-string`,`out-host`,`ipconfig`,`hostname`,`route`]),AA=(()=>{let e=new Set([...wA,...xA,...SA,...CA,...EA,...DA,...OA,...kA,`foreach-object`,...I_.filter(e=>!e.includes(` `))]);return new Set([...e,...TA(e)])})();Zi(),Js();async function jA(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||AA.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 aO(n),i=await eO(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||YD[n])?null:i}async function MA(e,t){let n=await qc(e);if(!n.valid)return[];let r=ef(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await jA(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await jA(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=NA(t);(n===``?0:ta(n,` `)+1)<=1&&((await aO(e))?.subcommands?.length||YD[e])||o.push(n)}return o}function NA(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(` `)}ed();function PA({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`}),Go()&&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=Hk(e,Eb);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}H(),Px(),Zn(),aa(),Er(),ob(),TC(),PD();function FA(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,workerBadge:a}=e,{command:o,description:s}=ko.inputSchema.parse(t.input),[c]=ce(),l=UO({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:b,handleFocus:x}=Lk({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:l.visible}),S=Jn(`tengu_destructive_command_warning`,!1)?bA(o):null,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(o.includes(`
38
+ `)?void 0:o),D=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return MA(o,e=>Qa(e,e.text)).then(t=>{e||D.current||t.length>0&&E(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[o]);let O=(0,Q.useCallback)(e=>{D.current=!0,E(e)},[]);yO(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let k=(0,Q.useMemo)(()=>PA({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,yesInputMode:u,noInputMode:d,editablePrefix:T,onEditablePrefixChange:O}),[t,u,d,T,O]);De(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`});function A(e){Y(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:l.visible});let n=rn(t.tool.name);if(e===`yes-prefix-edited`){let e=(T??``).trim();if(Ik(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:ko.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=m.trim();Ik(`tool_use_single`,t,`accept`),Y(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{Ik(`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=h.trim();Y(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:p}),b(e||void 0);break}}}return(0,$.jsxs)(EC,{workerBadge:a,title:`PowerShell command`,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(z,{dimColor:l.visible,children:ko.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!l.visible&&(0,$.jsx)(z,{dimColor:!0,children:t.description}),(0,$.jsx)(GO,{visible:l.visible,promise:l.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(EO,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(z,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(MD,{permissionResult:t.permissionResult,toolType:`command`}),S&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(z,{color:`warning`,children:S})}),(0,$.jsx)(z,{children:`Do you want to proceed?`}),(0,$.jsx)(ku,{options:k,inlineDescriptions:!0,onChange:A,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(z,{dimColor:!0,children:[`Esc to cancel`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to amend`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(z,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ma(),Ke(),H(),Er(),Da(),ed(),gO(),TC(),aA(),PD();function IA(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i,workerBadge:a}=e,o=(e=>{let t=Jh.inputSchema.safeParse(e);return t.success?t.data.skill:(Na(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),s=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;yO(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=Ye(),l=Go(),u=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(l){t.push({label:(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,(0,$.jsx)(z,{bold:!0,children:o}),` in `,(0,$.jsx)(z,{bold:!0,children:c})]}),value:`yes-exact`});let e=o.indexOf(` `);if(e>0){let n=o.substring(0,e);t.push({label:(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,(0,$.jsx)(z,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(z,{bold:!0,children:c})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[o,c,l]),d=(0,Q.useMemo)(()=>({toolName:rn(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),f=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ka.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ka.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Rb,ruleContent:o}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ka.platform}});let e=o.indexOf(` `),r=e>0?o.substring(0,e):o;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Rb,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ka.platform}}),t.onReject(i),r(),n();break}},[t,n,r,o]),p=(0,Q.useCallback)(()=>{hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ka.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(EC,{title:`Use skill "${o}"?`,workerBadge:a,children:[(0,$.jsx)(z,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(z,{dimColor:!0,children:s?.description})}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(MD,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(tA,{options:u,onSelect:f,onCancel:p,toolAnalyticsContext:d})]})]})}H(),ed(),ob(),TC(),PD();function LA(e){try{let t=Ff.inputSchema.safeParse(e);if(!t.success)return`input:${e.toString()}`;let{url:n}=t.data;return`domain:${new URL(n).hostname}`}catch{return`input:${e.toString()}`}}function RA({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ce(),{url:o}=e.input,s=new URL(o).hostname;yO(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=Go(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`}];return c&&e.push({label:(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,(0,$.jsx)(z,{bold:!0,children:s})]}),value:`yes-dont-ask-again-domain`}),e.push({label:(0,$.jsxs)(z,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(z,{bold:!0,children:`(esc)`})]}),value:`no`}),e},[s,c]);function u(r){switch(r){case`yes`:Ik(`tool_use_single`,e,`accept`),e.onAllow(e.input,[]),t();break;case`yes-dont-ask-again-domain`:{Ik(`tool_use_single`,e,`accept`);let n=LA(e.input),r={toolName:e.tool.name,ruleContent:n};e.onAllow(e.input,[{type:`addRules`,rules:[r],behavior:`allow`,destination:`localSettings`}]),t();break}case`no`:Ik(`tool_use_single`,e,`reject`),e.onReject(),n(),t();break}}return(0,$.jsxs)(EC,{title:`Fetch`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(z,{children:Ff.renderToolUseMessage(e.input,{theme:a,verbose:r})}),(0,$.jsx)(z,{dimColor:!0,children:e.description})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(MD,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(z,{children:`Do you want to allow Claude to fetch this content?`}),(0,$.jsx)(ku,{options:l,onChange:u,onCancel:()=>u(`no`)})]})]})}function zA(){return en(`policySettings`)?.allowManagedPermissionRulesOnly===!0}function BA(){return!zA()}var VA=t((()=>{Yt(),Hr(),Ni(),vi(),Vt(),Lt(),Pn()}));async function HA(e){J(`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 UA=t((()=>{$i()}));function WA({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Zs(),[o,s]=(0,GA.useState)(``),[c,l]=(0,GA.useState)(``),[u,d]=(0,GA.useState)(!1),[f,p]=(0,GA.useState)(!1),[m,h]=(0,GA.useState)(null),[g,_]=(0,GA.useState)(!1),[v,y]=(0,GA.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,GA.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=qA[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,GA.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),Y(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),Y(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),Y(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),y(!0),Y(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),w=(0,GA.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`?Y(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&Y(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);Se((0,GA.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,GA.useCallback)(()=>{Y(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,KA.jsxs)(U,{flexDirection:`column`,children:[typeof r==`string`?(0,KA.jsx)(z,{children:r}):r,(0,KA.jsx)(ku,{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,KA.jsx)(U,{marginTop:1,children:(0,KA.jsxs)(z,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var GA,KA,qA,JA=t((()=>{GA=n(oe()),H(),Px(),aa(),tb(),ob(),KA=Pe(),qA={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));function YA(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 ${P.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${P.bold(Or(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?` ${P.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${P.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 XA({permissionResult:e,toolType:t}){let n=X(e=>e.toolPermissionContext.mode),r=YA(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,ZA.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[i?(0,ZA.jsx)(z,{color:i,children:r.reasonString}):(0,ZA.jsx)(z,{children:(0,ZA.jsx)(me,{children:r.reasonString})}),r.configString&&(0,ZA.jsx)(z,{dimColor:!0,children:r.configString})]})}var ZA,QA=t((()=>{L(),oe(),H(),ay(),tb(),Pn(),ZA=Pe()})),$A=r({WorkflowPermissionRequest:()=>ej});function ej({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ce(),a=Td(i),o=e.input,s=(0,tj.useMemo)(()=>BA(),[]),c=(0,tj.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,nj.jsxs)(z,{children:[`Yes, and don`,`’`,`t ask again for `,(0,nj.jsx)(z,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[s,e.tool.name]),l=(0,tj.useCallback)((r,i)=>{switch(r){case`yes`:HA({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sh.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:HA({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sh.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:HA({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sh.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,tj.useCallback)(()=>{HA({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sh.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,nj.jsx)(Rw,{title:`Workflow`,workerBadge:r,children:(0,nj.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,nj.jsxs)(U,{flexDirection:`column`,children:[(0,nj.jsxs)(z,{bold:!0,color:a.permission,children:[`Execute workflow: `,o.workflow]}),o.args&&(0,nj.jsxs)(z,{dimColor:!0,children:[`Arguments: `,o.args]})]}),(0,nj.jsx)(XA,{permissionResult:e.permissionResult,toolType:`command`}),(0,nj.jsx)(WA,{options:c,onSelect:l,onCancel:u})]})})}var tj,nj,rj=t((()=>{tj=n(oe(),1),H(),VA(),UA(),JA(),QA(),nj=Pe()})),ij=r({MonitorPermissionRequest:()=>aj});function aj({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ce(),a=tm(i),o=e.input,s=(0,oj.useMemo)(()=>Go(),[]),c=(0,oj.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,sj.jsxs)(z,{children:[`Yes, and don`,`’`,`t ask again for `,(0,sj.jsx)(z,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[s,e.tool.name]),l=(0,oj.useCallback)((r,i)=>{switch(r){case`yes`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ka.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:hO({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ka.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ka.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,oj.useCallback)(()=>{hO({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ka.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,sj.jsx)(EC,{title:`Monitor`,workerBadge:r,children:(0,sj.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,sj.jsxs)(U,{flexDirection:`column`,children:[(0,sj.jsx)(z,{bold:!0,color:a.permission,children:o.description}),(0,sj.jsx)(z,{dimColor:!0,children:ia(o.command,5)})]}),(0,sj.jsx)(MD,{permissionResult:e.permissionResult,toolType:`command`}),(0,sj.jsx)(tA,{options:c,onSelect:l,onCancel:u})]})})}var oj,sj,cj=t((()=>{oj=n(oe(),1),H(),Da(),ed(),Zi(),gO(),TC(),aA(),PD(),sj=Pe()}));Px(),Pu(),Sv(),Hy(),eb(),qp(),lc(),oo(),mu();var lj=null,uj=null,dj=(lb(),e(yo)).createWorkflowToolCore(),fj=(rj(),e($A)).WorkflowPermissionRequest,pj=(tp(),e(Qm)).MonitorTool,mj=(cj(),e(ij)).MonitorPermissionRequest;function hj(e){switch(e){case Lp:return lA;case hy:return mA;case bm:return Kk;case ko:return FA;case lj:return uj??oA;case Ff:return RA;case fv:return vA;case db:return Qk;case Dl:return Jk;case Jh:return IA;case tl:return HD;case dj:return fj??oA;case pj:return mj??oA;case um:case y_:case Ig:return dA;default:return oA}}function gj(e){let t=e.tool.userFacingName(e.input);return e.tool===db?`Claude Code needs your approval for the plan`:e.tool===Dl?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function _j({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o}){return De(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),CD(gj(e),`permission_prompt`),(0,$.jsx)(hj(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o})}vi(),Lf();async function vj(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=ix([`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:
39
+ - Current date and time: ${i} (UTC)
40
+ - Local timezone: ${c}
41
+ - Day of week: ${l}
42
+
43
+ User input: "${e}"
44
+
45
+ Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
46
+
47
+ 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 Af({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=nu(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 yi(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function yj(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}D(),Fr(),Zi();var bj=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function xj(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function Sj(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function Cj(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function wj(e,t){let n=Sj(e).indexOf(t);return n>=0?Cj(e)[n]??t:t}function Tj(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function Ej(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function Dj(e,t){let n=Tj(e).indexOf(t);return n>=0?Ej(e)[n]??t:t}function Oj(e){if(bj(e)){let[t,...n]=Tj(e);return t?S([t,...n]):w()}if(e.type===`string`){let t=b();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Qi(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Qi(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=T({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 E();throw Error(`Unsupported schema: ${zr(e)}`)}function kj(e,t){let n=Oj(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function Aj(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function jj(e,t,n){let r=kj(e,t);if(r.isValid)return r;if(Aj(t)&&!yj(e)){let r=await vj(e,t.format,n);if(r.success){let e=kj(r.value,t);if(e.isValid)return e}}return r}m(),Fx(),H(),Px(),Zi(),Bs();var Mj=e=>[`string`,`number`,`integer`].includes(e.type),Nj=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,Pj=e=>(e+1)%10;function Fj(e){e.buffer=``,e.timer=void 0}function Ij(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,Pj);return()=>clearInterval(e)},[]),(0,$.jsx)(z,{color:`warning`,children:Nj[e]})}function Lj(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 Rj({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(Bj,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(zj,{event:e,onResponse:t})}function zj({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}),[d,f]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(Mj(n)&&n?.default!==void 0){let r=kj(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 p=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[m,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=p[0];if(e&&Mj(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}=ee(),M=m===void 0?void 0:p[m],N=M!==void 0&&Mj(M.schema)&&!bj(M.schema)&&!s;yd(`elicitation`),CD(`Claude Code needs your input`,`elicitation_dialog`);let P=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=p[e];if(t&&Mj(t.schema)&&!bj(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[p,l]);function F(e,t){if(!xj(t))return;let n=l[e]??[],r=p.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?L(e,`Select at least ${i} ${Qi(i,`item`)}`):a!==void 0&&n.length>a?L(e,`Select at most ${a} ${Qi(a,`item`)}`):L(e)}function te(e){M&&xj(M.schema)?(F(M.name,M.schema),w(void 0)):M&&bj(M.schema)&&w(void 0),N&&M&&(re(M.name,M.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),Aj(M.schema)&&_.trim()!==``&&d[M.name]&&ie(M.name,M.schema,_));let t=p.length+2,n=m??(s===`accept`?p.length:s===`decline`?p.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<p.length?(g(r),c(null),P(r)):(g(void 0),c(r===p.length?`accept`:`decline`),v(``))}function I(e,t){u(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&d[e]===`This field is required`&&L(e)}function L(e,t){f(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function ne(e){e&&(I(e,void 0),L(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)){ne(e);return}if(r===``){l[e]!==void 0&&I(e,``);return}let i=kj(n,t);I(e,i.isValid?i.value:n),L(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)),jj(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){I(e,t.value),L(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else L(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),Aj(M.schema)&&e.trim()!==``&&d[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(){te(`down`)}function se(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(Fj,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}De(`confirm:no`,()=>{if(N&&M){let e=l[M.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!M&&!s&&!C}),je((e,n)=>{if(N&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&M&&xj(M.schema)){let t=M.schema,r=Sj(t),i=l[M.name]??[];if(n.leftArrow||n.escape){w(void 0),F(M.name,t);return}if(n.upArrow){T===0?(w(void 0),F(M.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),te(`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;I(M.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||M.isRequired)?L(M.name,`Select at least ${a} ${Qi(a,`item`)}`):o!==void 0&&n.length>o?L(M.name,`Select at most ${o} ${Qi(o,`item`)}`):L(M.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&I(M.name,[...i,e]),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>wj(t,e).toLowerCase()),E);return}return}if(C&&M&&bj(M.schema)){let t=M.schema,r=Tj(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),te(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&I(M.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&I(M.name,e),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>Dj(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(ce()&&Object.keys(d).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&L(t,`This field is required`);let t=p.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||d[t.name]!==void 0);t!==-1&&(g(t),c(null),P(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),te(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===` `){I(i,o===void 0?!0:!o);return}if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){ne(i);return}if(e&&!n.return){se(e,[`yes`,`no`],e=>I(i,e===0));return}return}if(bj(r)||xj(r)){if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){ne(i);return}let t,a=0;if(bj(r)){let e=Tj(r);t=e.map(e=>Dj(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=Sj(r).map(e=>wj(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&&N&&_===``){ne(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)),ue=(0,Q.useMemo)(()=>{let e=p.length;if(e<=le)return{start:0,end:e};let t=m??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}},[p.length,le,m]),de=ue.start>0,fe=ue.end<p.length;function pe(){return p.length?(0,$.jsxs)(U,{flexDirection:`column`,children:[de&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.arrowUp,` `,ue.start,` more above`]})}),p.slice(ue.start,ue.end).map((e,t)=>{let n=ue.start+t,{name:r,schema:i,isRequired:a}=e,o=n===m&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),f=d[r],p=x.has(r)?(0,$.jsx)(Ij,{}):f?(0,$.jsx)(z,{color:`error`,children:h.warning}):u?(0,$.jsx)(z,{color:`success`,dimColor:!o,children:h.tick}):a?(0,$.jsx)(z,{color:`error`,children:`*`}):(0,$.jsx)(z,{children:` `}),g=f?`error`:u?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(z,{color:v,bold:o,children:i.title||r}),w,E=null;if(xj(i)){let e=Sj(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(z,{dimColor:!0,children:h.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=wj(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(z,{color:`suggestion`,children:o?h.pointer:` `}),(0,$.jsx)(z,{color:a?`success`:void 0,children:a?h.checkboxOn:h.checkboxOff}),(0,$.jsx)(z,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(z,{dimColor:!0,children:[h.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(z,{children:[e,(0,$.jsx)(z,{color:v,bold:o,children:t.map(e=>wj(i,e)).join(`, `)})]}):(0,$.jsxs)(z,{children:[e,(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(bj(i)){let e=Tj(i);if(C===r&&o)w=(0,$.jsx)(z,{dimColor:!0,children:h.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=Dj(i,e),r=c===e,a=t===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(z,{color:`suggestion`,children:a?h.pointer:` `}),(0,$.jsx)(z,{color:r?`success`:void 0,children:r?h.radioOn:h.radioOff}),(0,$.jsx)(z,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(z,{dimColor:!0,children:[h.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(z,{children:[e,(0,$.jsx)(z,{color:v,bold:o,children:Dj(i,c)})]}):(0,$.jsxs)(z,{children:[e,(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(z,{color:v,bold:!0,children:c?h.checkboxOn:h.checkboxOff}):(0,$.jsx)(z,{dimColor:!0,children:h.checkboxOff}):u?(0,$.jsx)(z,{children:c?h.checkboxOn:h.checkboxOff}):(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`not set`});else if(Mj(i))if(o)w=(0,$.jsx)(Gd,{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&&Aj(i)?Lj(String(c),i):String(c);w=u?(0,$.jsx)(z,{children:e}):(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(z,{children:String(c)}):(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(z,{color:g,children:o?h.pointer:` `}),p,(0,$.jsxs)(U,{children:[S,(0,$.jsx)(z,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(U,{marginLeft:6,children:(0,$.jsx)(z,{dimColor:!0,children:i.description})}),(0,$.jsx)(U,{marginLeft:6,height:1,children:f?(0,$.jsx)(z,{color:`error`,italic:!0,children:f}):(0,$.jsx)(z,{children:` `})})]},r)}),fe&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.arrowDown,` `,p.length-ue.end,` more below`]})})]}):null}return(0,$.jsx)(ve,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!M||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(z,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(V,{children:[(0,$.jsx)(eg,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(B,{shortcut:`↑↓`,action:`navigate`}),M&&(0,$.jsx)(B,{shortcut:`Backspace`,action:`unset`}),M&&M.schema.type===`boolean`&&(0,$.jsx)(B,{shortcut:`Space`,action:`toggle`}),M&&bj(M.schema)&&(C?(0,$.jsx)(B,{shortcut:`Space`,action:`select`}):(0,$.jsx)(B,{shortcut:`→`,action:`expand`})),M&&xj(M.schema)&&(C?(0,$.jsx)(B,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(B,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[pe(),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{color:`success`,children:s===`accept`?h.pointer:` `}),(0,$.jsx)(z,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(z,{color:`error`,children:s===`decline`?h.pointer:` `}),(0,$.jsx)(z,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function Bj({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`),[d,f]=(0,Q.useState)(`accept`),p=a?.showCancel??!1;CD(`Claude Code needs your input`,`elicitation_url_dialog`),yd(`elicitation-url`),u.current=c;let m=(0,Q.useRef)(n);m.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?m.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?.(p?`retry`:`dismiss`)},[c,e.completed,n,p]);let y=(0,Q.useCallback)(()=>{rS(s),t(`accept`),l(`waiting`),u.current=`waiting`,f(`open`)},[t,s]);if(je((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){f(e=>e===`accept`?`decline`:`accept`);return}r.return&&(d===`accept`?y():t(`decline`))}else{let e=p?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){f(t=>e[(e.indexOf(t)+(r.rightArrow?1:-1)+e.length)%e.length]);return}r.return&&(d===`open`?rS(s):d===`cancel`?n?.(`cancel`):n?.(p?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ve,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(z,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(V,{children:[(0,$.jsx)(eg,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(B,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(z,{children:[_,(0,$.jsx)(z,{bold:!0,children:g}),v]})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{color:`success`,children:d===`open`?h.pointer:` `}),(0,$.jsx)(z,{bold:d===`open`,color:d===`open`?`success`:void 0,dimColor:d!==`open`,children:` Reopen URL `}),(0,$.jsx)(z,{color:`success`,children:d===`action`?h.pointer:` `}),(0,$.jsx)(z,{bold:d===`action`,color:d===`action`?`success`:void 0,dimColor:d!==`action`,children:` ${e}`}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{children:` `}),(0,$.jsx)(z,{color:`error`,children:d===`cancel`?h.pointer:` `}),(0,$.jsx)(z,{bold:d===`cancel`,color:d===`cancel`?`error`:void 0,dimColor:d!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ve,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(z,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(V,{children:[(0,$.jsx)(eg,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(B,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(z,{children:[_,(0,$.jsx)(z,{bold:!0,children:g}),v]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{color:`success`,children:d===`accept`?h.pointer:` `}),(0,$.jsx)(z,{bold:d===`accept`,color:d===`accept`?`success`:void 0,dimColor:d!==`accept`,children:` Accept `}),(0,$.jsx)(z,{color:`error`,children:d===`decline`?h.pointer:` `}),(0,$.jsx)(z,{bold:d===`decline`,color:d===`decline`?`error`:void 0,dimColor:d!==`decline`,children:` Decline`})]})]})})}H(),Px(),ob(),TC();function Vj({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){De(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(EC,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(z,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(U,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(ku,{options:a,onChange:e=>{r(e)}})})})}lp();function Hj(){return(0,Q.useSyncExternalStore)(Rv,H_)}Ma(),D(),su(),ba();var Uj=`at_mentioned`,Wj=ya(()=>C({method:x(Uj),params:C({filePath:b(),lineStart:y().optional(),lineEnd:y().optional()})}));function Gj(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Xh(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(Wj(),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){Na(e)}})},[e,t])}m(),Fx(),H(),tb(),mn(),Wb(),PC(),Gb();var Kj=1e3,qj=10,Jj=3,Yj=2500,Xj=[0,0,0,0,1,0,0,0,-1,0,0,2,0,0,0],Zj=h.heart,Qj=[` ${Zj} ${Zj} `,` ${Zj} ${Zj} ${Zj} `,` ${Zj} ${Zj} ${Zj} `,`${Zj} ${Zj} ${Zj} `,`· · · `];function $j(e,t){let n=e.split(` `),r=[],i=``;for(let e of n)i.length+e.length+1>t&&i?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function eM({text:e,color:t,fading:n,tail:r}){let i=$j(e,30),a=n?`inactive`:t,o=(0,$.jsx)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:a,paddingX:1,width:34,children:i.map((e,t)=>(0,$.jsx)(z,{italic:!0,dimColor:!n,color:n?`inactive`:void 0,children:e},t))});return r===`right`?(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`center`,children:[o,(0,$.jsx)(z,{color:a,children:`─`})]}):(0,$.jsxs)(U,{flexDirection:`column`,alignItems:`flex-end`,marginRight:1,children:[o,(0,$.jsxs)(U,{flexDirection:`column`,alignItems:`flex-end`,paddingRight:6,children:[(0,$.jsx)(z,{color:a,children:`╲ `}),(0,$.jsx)(z,{color:a,children:`╲`})]})]})}var tM=12,nM=2,rM=2,iM=36,aM=24;function oM(e){return Math.max(tM,e+nM)}function sM(e,t){let n=Ub();if(!n||W().companionMuted||e<100)return 0;let r=A(n.name),i=t&&!R_()?iM:0;return oM(r)+rM+i}function cM(){let e=X(e=>e.companionReaction),t=X(e=>e.companionPetAt),n=X(e=>e.footerSelection===`companion`),r=Zs(),{columns:i}=ee(),[a,o]=(0,Q.useState)(0),s=(0,Q.useRef)(0),[{petStartTick:c,forPetAt:l},u]=(0,Q.useState)({petStartTick:0,forPetAt:t});t!==l&&u({petStartTick:a,forPetAt:t}),(0,Q.useEffect)(()=>{let e=setInterval(e=>e(e=>e+1),Kj,o);return()=>clearInterval(e)},[]),(0,Q.useEffect)(()=>{if(!e)return;s.current=a;let t=setTimeout(e=>e(e=>e.companionReaction===void 0?e:{...e,companionReaction:void 0}),qj*Kj,r);return()=>clearTimeout(t)},[e,r]);let d=Ub();if(!d||W().companionMuted)return null;let f=Hb[d.rarity],p=oM(A(d.name)),m=e?a-s.current:0,g=e!==void 0&&m>=qj-Jj,_=t?a-c:1/0,v=_*Kj<Yj;if(i<100){let t=e&&e.length>aM?e.slice(0,aM-1)+`…`:e,r=t?`"${t}"`:n?` ${d.name} `:d.name;return(0,$.jsx)(U,{paddingX:1,alignSelf:`flex-end`,children:(0,$.jsxs)(z,{children:[v&&(0,$.jsxs)(z,{color:`autoAccept`,children:[h.heart,` `]}),(0,$.jsx)(z,{bold:!0,color:f,children:MC(d)}),` `,(0,$.jsx)(z,{italic:!0,dimColor:!n&&!e,bold:n,inverse:n&&!e,color:e?g?`inactive`:f:n?f:void 0,children:r})]})})}let y=jC(d.species),b=v?Qj[_%Qj.length]:null,x,S=!1;if(e||v)x=a%y;else{let e=Xj[a%Xj.length];e===-1?(x=0,S=!0):x=e%y}let C=NC(d,x).map(e=>S?e.replaceAll(d.eye,`-`):e),w=(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:0,alignItems:`center`,width:p,children:[(b?[b,...C]:C).map((e,t)=>(0,$.jsx)(z,{color:t===0&&b?`autoAccept`:f,children:e},t)),(0,$.jsx)(z,{italic:!0,bold:n,dimColor:!n,color:n?f:void 0,inverse:n,children:n?` ${d.name} `:d.name})]});return!e||R_()?(0,$.jsx)(U,{paddingX:1,children:w}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-end`,paddingX:1,flexShrink:0,children:[(0,$.jsx)(eM,{text:e,color:f,fading:g,tail:`right`}),w]})}function lM(){let e=X(e=>e.companionReaction),[{tick:t,forReaction:n},r]=(0,Q.useState)({tick:0,forReaction:e});if(e!==n&&r({tick:0,forReaction:e}),(0,Q.useEffect)(()=>{if(!e)return;let t=setInterval(e=>e(e=>({...e,tick:e.tick+1})),Kj,r);return()=>clearInterval(t)},[e]),!e)return null;let i=Ub();return!i||W().companionMuted?null:(0,$.jsx)(eM,{text:e,color:Hb[i.rarity],fading:t>=qj-Jj,tail:`down`})}Uf(),Ja(),Tw(),jw(),Nw();function uM(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])}function dM(){let e=X(e=>e.settings.voiceEnabled===!0),t=X(e=>e.settings.voiceProvider),n=(0,fM.useMemo)(Sg,[X(e=>e.authVersion)]);return t===`doubao`?e&&rp():e&&n&&rp()}var fM,pM=t((()=>{fM=n(oe(),1),tb()}));SC(),Zw(),pM(),H();function mM({ideSelection:e,mcpClients:t}){let{status:n}=uM(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)(z,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(z,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,KT(e.filePath)]},`selection-indicator`)}var hM=1.5*1024*1024*1024,gM=2.5*1024*1024*1024;function _M(){let[e,t]=(0,Q.useState)(null);return ue(()=>{let e=process.memoryUsage().heapUsed,n=e>=gM?`critical`:e>=hM?`high`:`normal`;t(t=>n===`normal`?t===null?t:null:{heapUsed:e,status:n})},1e4),e}H(),va();function vM(){if(process.env.USER_TYPE!==`ant`)return null;let e=_M();if(!e)return null;let{heapUsed:t,status:n}=e;if(n===`normal`)return null;let r=ma(t);return(0,$.jsx)(U,{children:(0,$.jsxs)(z,{color:n===`critical`?`error`:`warning`,wrap:`truncate`,children:[`High memory usage (`,r,`) · /heapdump`]})})}function yM(){return(0,Q.useSyncExternalStore)(rg.subscribe,rg.getState)}H(),Zn(),_g();function bM({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=ly(e,t),a=yM();if(!r||a)return null;let o=Np(),s=p_(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(U,{flexDirection:`row`,children:o?(0,$.jsx)(z,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(z,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}H(),Wm();function xM(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=gv(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!u_.isSandboxingEnabled())return;let e=u_.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)}},[]),!u_.isSandboxingEnabled()||e===0?null:(0,$.jsx)(U,{paddingX:0,paddingY:0,children:(0,$.jsxs)(z,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}var SM=r({VoiceIndicator:()=>CM,VoiceWarmupHint:()=>TM});function CM(e){return(0,DM.jsx)(wM,{...e})}function wM({voiceState:e}){switch(e){case`recording`:return(0,DM.jsx)(z,{dimColor:!0,children:`listening…`});case`processing`:return(0,DM.jsx)(EM,{});case`idle`:return null}}function TM(){return(0,DM.jsx)(z,{dimColor:!0,children:`keep holding…`})}function EM(){let e=dc().prefersReducedMotion??!1,[t,n]=k(e?null:50);if(e)return(0,DM.jsx)(z,{color:`warning`,children:`Voice: processing…`});let r=n/1e3;return(0,DM.jsx)(U,{ref:t,children:(0,DM.jsx)(z,{color:xf(Sc(OM,kM,(Math.sin(r*Math.PI*2/AM)+1)/2)),children:`Voice: processing…`})})}var DM,OM,kM,AM,jM=t((()=>{oe(),Ss(),H(),DM=Pe(),OM={r:153,g:153,b:153},kM={r:185,g:185,b:185},AM=2}));Ah(),$i(),S_(),H(),Zy(),hC(),va(),su(),Lf(),Iv();var MM=(jM(),e(SM)).VoiceIndicator,NM=5e3;function PM({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)(()=>Qs(rc(a)),[a]),p=xC(),m=ly(f,p).isAboveWarningThreshold,{status:h}=uM(l),g=Z(e=>e.notifications),{addNotification:_,removeNotification:v}=ul(),y=Xw();(0,Q.useEffect)(()=>(Ug((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Ug(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=fn(),S=x===`team`||x===`enterprise`,C=gC(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(J(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(eg,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${wd(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(xS,{children:(0,$.jsx)(U,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(FM,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})})}function FM({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:a,debug:o,verbose:s,tokenUsage:c,mainLoopModel:l}){let[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!Gt())return;let e=setInterval(e=>{let t=zt(),n=t>=1e4?fa(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]);let p=Rp(e=>e.voiceState),m=dM(),h=Rp(e=>e.voiceError),g=Z(e=>e.isBriefOnly);return m&&(p===`recording`||p===`processing`)?(0,$.jsx)(MM,{voiceState:p}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mM,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(z,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(z,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(U,{children:[(0,$.jsxs)(z,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(z,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(a===`invalid`||a===`missing`)&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{color:`error`,wrap:`truncate`,children:u(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in · Run /login`})}),o&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),a!==`invalid`&&a!==`missing`&&s&&(0,$.jsx)(U,{children:(0,$.jsxs)(z,{dimColor:!0,wrap:`truncate`,children:[c,` tokens`]})}),!g&&(0,$.jsx)(bM,{tokenUsage:c,model:l}),m&&h&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{color:`error`,wrap:`truncate`,children:h})}),(0,$.jsx)(vM,{}),(0,$.jsx)(xM,{})]})}Ah(),Iv(),H();var IM=10,LM=null,RM=0,zM;async function BM(e,t){let n=Math.ceil(e/IM)*IM;if(LM&&RM>=n&&zM===t)return LM;LM&&await LM,RM=n,zM=t,LM=(async()=>{let e=[],n=0;for await(let r of jo())if(!(t&&xl(r.display)!==t)&&(e.push(r),n++,n>=RM))break;return e})();try{return await LM}finally{LM=null,RM=0,zM=void 0}}function VM(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}=ul(),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=xl(e.display);y(n===`bash`?e.display.slice(1):e.display,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(eg,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:NM})},[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;e===0&&(h.current=r===`bash`?r:void 0,c(t.trim()===``?void 0:{display:t,pastedContents:n,mode:r}));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 BM(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])}}tb();function HM(){let e=X(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(e_).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])}function UM(e,t){switch(t){case`bash`:return`!${e}`;default:return e}}function WM(e){return e.startsWith(`!`)?`bash`:`prompt`}function GM(e){return WM(e)===`prompt`?e:e.slice(1)}Xu(),H(),Px();function KM(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=as(),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(WM(i)),n(i),l(e.value.pastedContents);let t=GM(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=as(),E.current.clear()},[c,t,i,o,u]),ee=(0,Q.useCallback)(()=>{A(!0)},[A]),M=(0,Q.useCallback)(()=>{if(C){let e=WM(C.display);n(GM(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),N=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),P=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=WM(C.display),n=GM(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);De(`history:search`,j,{context:`Global`,isActive:!s}),Se((0,Q.useMemo)(()=>({"historySearch:next":ee,"historySearch:accept":M,"historySearch:cancel":N,"historySearch:execute":P}),[ee,M,N,P]),{context:`HistorySearch`,isActive:s});let F=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),N())};je((e,t,n)=>{F(new Ne(n.keypress))},{isActive:s});let te=(0,Q.useRef)(A);return te.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,te.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:F}}function qM({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}}H(),aa(),tb();function JM({inputValue:e,isAssistantResponding:t}){let n=X(e=>e.promptSuggestion),r=Zs(),i=fe(),{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)(()=>{Kf(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();Y(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100,...process.env.USER_TYPE===`ant`&&{suggestion:a,userInput:e}}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}us(),K(),za(),zm();var YM=15,XM=1e3,ZM=[`|`,`||`,`&&`,`;`];function QM(e){return typeof e==`object`&&!!e&&`op`in e&&ZM.includes(e.op)}function $M(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function eN(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function tN(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&QM(n)}function nN(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=Qb(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:$M(t)}}let a=eN(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&QM(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=$M(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=tN(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function rN(e,t){return t===`variable`?`compgen -v ${$b([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${$b([e])} 2>/dev/null | head -${YM} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${$b([e])} 2>/dev/null`}function iN(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${$b([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${$b([e])}*(N[1,${YM}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${$b([e])}*]} 2>/dev/null`}async function aN(e,t,n,r){let i;if(e===`bash`)i=rN(t,n);else if(e===`zsh`)i=iN(t,n);else return[];return(await(await sm(i,r,`bash`,{timeout:XM})).result).stdout.split(`
48
+ `).filter(e=>e.trim()).slice(0,YM).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function oN(e,t,n){let r=fu();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=nN(e,t);return i?(await aN(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return q(`Shell completion failed: ${e}`),[]}}nT(),fb(),MT();var sN=/[:_-]/g,cN=null;function lN(e){if(cN?.commands===e)return cN.fuse;let t=new rT(e.filter(e=>!e.isHidden).map(e=>{let t=Qy(e),n=t.split(sN).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>xN(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 cN={commands:e,fuse:t},t}function uN(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function dN(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 fN(e,t){if(!e)return null;let n=yN(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!uN(t.metadata))continue;let n=Qy(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function pN(e){return e.startsWith(`/`)}function mN(e){return!(!pN(e)||!e.includes(` `)||e.endsWith(` `))}function hN(e){return`/${e} `}function gN(e){let t=Qy(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function _N(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function vN(e,t){let n=Qy(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:Ih(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:gN(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function yN(e,t){if(!pN(e)||mN(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:NT(Qy(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=>gN(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(gN(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)=>Qy(e).localeCompare(Qy(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=>vN(e))}let r=t.find(e=>e.isHidden&&Qy(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&Qy(e).toLowerCase()===n)&&(r=void 0);let i=lN(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`?NT(Qy(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 vN(t,_N(n,t.aliases))});if(r){let e=gN(r);if(!i.some(t=>t.id===e))return[vN(r),...i]}return i}function bN(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Ol(o,n):void 0;else{if(!uN(e.metadata))return;o=Qy(e.metadata),s=e.metadata}let c=hN(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function xN(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function SN(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}sC(),Xu(),K();var CN=null,wN=0,TN=6e4;async function EN(){let e=Date.now();if(CN&&e-wN<TN)return CN;let t=[],n=new Set;try{for await(let e of jo()){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 CN=t,wN=e,t}function DN(e){if(!CN)return;let t=CN.indexOf(e);t!==-1&&CN.splice(t,1),CN.unshift(e)}async function ON(e){if(!e||e.length<2||!e.trim())return null;let t=await EN();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}K(),ba(),Xi(),Fr();var kN=`slack_search_channels`,AN=new Map,jN=new Set,MN=0,NN=Bi(),PN=NN.subscribe,FN=null,IN=null;function LN(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function RN(e,t){let n=LN(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:kN,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?VN(BN(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
49
+ `))):[]}catch(e){return q(`Failed to fetch Slack channels: ${e}`),[]}}var zN=ya(()=>C({results:b()}));function BN(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=zN().safeParse(Pr(t));if(e.success)return e.data.results}catch{}return e}function VN(e){let t=[],n=new Set;for(let r of e.split(`
50
+ `)){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 HN(e){return LN(e)!==void 0}function UN(){return MN}function WN(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!jN.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function GN(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function KN(e,t){let n,r=0;for(let[i,a]of AN)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function qN(e,t){if(!t)return[];let n=GN(t),r=t.toLowerCase(),i=AN.get(n)??KN(n,r);if(!i)if(FN===n&&IN)i=await IN;else{FN=n,IN=RN(e,n),i=await IN,AN.set(n,i);let t=jN.size;for(let e of i)jN.add(e);jN.size!==t&&(MN++,NN.emit()),AN.size>50&&AN.delete(AN.keys().next().value),FN===n&&(FN=null,IN=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}RC(),VC(),aa(),mn(),qr(),K(),Vr(),Hr(),vi(),ki(),Lt(),Xi();var JN=null;function YN(){return JN||(JN=new zC),JN}var XN=null,ZN=Bi();ZN.subscribe;var QN=0,$N=null,eP=[],tP=[],nP=[],rP=null,iP=null,aP=0,oP=null,sP=null,cP=null;function lP(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function uP(){let e=ri(Jr());if(!e)return null;try{return rE(GT.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function dP(e,t,n){return n===t?e:e.map(e=>{let r=GT.join(t,e);return GT.relative(n,r)})}async function fP(e){if(e.length===0||!JN||eP.length===0)return;let t=await hP(e),n=[...eP,...tP,...nP,...e,...t],r=lP(n);if(r===cP){q(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await JN.loadFromFileListAsync(n).done,cP=r,q(`[FileIndex] rebuilt index with ${eP.length} tracked + ${e.length} untracked files`)}async function pP(e,t){let n=`${e}:${t}`;if(iP===n)return rP;let r=Ur(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,vE.default)(),s=!1,c=a.flatMap(e=>i.map(t=>GT.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,q(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return rP=u,iP=n,u}async function mP(e,t){let n=Date.now();q(`[FileIndex] getFilesUsingGit called`);let r=Jr(),i=ri(r);if(!i)return q(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await bi(Zr(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(q(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return q(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=dP(o.stdout.trim().split(`
51
+ `).filter(Boolean),i,r),c=await pP(i,r);if(c){let e=s.length;s=c.filter(s),q(`[FileIndex] applied ignore patterns: ${e} -> ${s.length} files`)}eP=s;let l=Date.now()-n;if(q(`[FileIndex] git ls-files: ${s.length} tracked files in ${l}ms`),Y(`tengu_file_suggestions_git_ls_files`,{file_count:s.length,tracked_count:s.length,untracked_count:0,duration_ms:l}),!$N){let e=t?[`-c`,`core.quotepath=false`,`ls-files`,`--others`,`--exclude-standard`]:[`-c`,`core.quotepath=false`,`ls-files`,`--others`],n=QN;$N=bi(Zr(),e,{timeout:1e4,cwd:i}).then(async e=>{if(n===QN&&e.code===0){let t=dP(e.stdout.trim().split(`
52
+ `).filter(Boolean),i,r),n=await pP(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),q(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}q(`[FileIndex] background untracked fetch: ${t.length} files`),fP(t)}}).catch(e=>{q(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{$N=null})}return s}catch(e){return q(`[FileIndex] git ls-files error: ${Kr(e)}`),null}}async function hP(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)gP(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await GC(),n=performance.now());return[...t].map(e=>e+GT.sep)}function gP(e,t,n,r){for(let i=t;i<n;i++){let t=GT.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=GT.dirname(t);if(e===t)break;r.add(t),t=e}}}async function _P(e){return(await Promise.all(dg.map(t=>Hm(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function vP(e,t){q(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await mP(e,t);if(n!==null)return q(`[FileIndex] using git ls-files result (${n.length} files)`),n;q(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await qb(i,`.`,e)).map(e=>GT.relative(Jr(),e)),o=Date.now()-r;return q(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),Y(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function yP(){let e=AbortSignal.timeout(1e4),t=YN();try{let n=qt(),r=W(),i=n.respectGitignore??r.respectGitignore??!0,a=Jr(),[o,s]=await Promise.all([vP(e,i),_P(a)]);tP=s;let c=[...o,...s],l=await hP(c);nP=l;let u=[...l,...c],d=lP(u);d===sP?q(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(u).done,sP=d,cP=null)}catch(e){yi(e)}return t}function bP(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}var xP=15;function SP(e,t){return e.search(t,xP).map(e=>bP(e.path,e.score))}var CP=5e3;function wP(){if(XN)return;let e=uP();if(JN&&!(e!==null&&e!==oP)&&Date.now()-aP<CP)return;let t=QN,n=Date.now();YN(),XN=yP().then(r=>t===QN?(XN=null,ZN.emit(),oP=e,aP=Date.now(),q(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(q(`[FileIndex] Cache refresh failed: ${Kr(e)}`),yi(e),t===QN&&(XN=null),YN()))}async function TP(){let e=Ur(),t=Jr();try{return(await e.readdir(t)).map(e=>{let n=GT.join(t,e.name),r=GT.relative(t,n);return e.isDirectory()?r+GT.sep:r})}catch(e){return yi(e),[]}}async function EP(e,t=!1){if(!e&&!t)return[];if(qt().fileSuggestion?.type===`command`)return(await jl({...ts(),query:e})).slice(0,xP).map(bP);if(e===``||e===`.`||e===`./`){let e=await TP();return wP(),e.slice(0,xP).map(bP)}let n=Date.now();try{let t=XN!==null;wP();let r=e,i=`.`+GT.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=Ai(r));let a=JN?SP(JN,r):[],o=Date.now()-n;return q(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),Y(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return yi(e),[]}}nT(),Ma();function DP(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 OP=15,kP=60;function AP(e){return ga(e,kP)}function jP(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:AP(e.whenToUse),agentType:e.agentType,color:Iy(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 Na(e),[]}}async function MP(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([EP(e,r),Promise.resolve(jP(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:KT(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:AP(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,OP).map(DP);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 rT(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:OP});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,OP).map(e=>e.source).map(DP)}Ah(),H(),$i(),j(),fb(),_o(),Px(),fm(),tb(),Jt(),va(),Fp();var NP=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,PP=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,FP=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,IP=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,LP=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,RP=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function zP(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function BP(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 VP(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function HP(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function UP(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 WP(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 GP=/(^|\s)@[\w-]*$/;function KP(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 qP=null;async function JP(e,t){try{return qP&&qP.abort(),qP=new AbortController,await oN(e,t,qP.signal)}catch{return J(`tengu_shell_completion_failed`,{}),[]}}function YP(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 XP(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(NP);if(a&&a[0].length===i.length){let r=e.substring(t).match(PP),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?FP:IP,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(PP),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function ZP(e){if(pN(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 QP(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function $P({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}=ul(),g=gv(`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=Qy(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=X(e=>e.mcp.resources),C=Md(),w=X(e=>e.promptSuggestion),T=X(e=>!!e.viewingAgentTaskId),E=he(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=dN(i,a);if(!t)return;let n=fN(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 ee=(0,Q.useRef)(null),M=(0,Q.useRef)(``),N=(0,Q.useRef)(``),P=(0,Q.useRef)(``),F=(0,Q.useRef)(``),te=(0,Q.useRef)(l);te.current=l;let I=(0,Q.useRef)(null),L=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),ne=(0,Q.useCallback)(async(e,t=!1)=>{ee.current=e;let n=await MP(e,S,s,t);if(ee.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:BP(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(WC(),HC(()=>{let e=ee.current;e!==null&&(ee.current=null,ne(e,e===``))})),[ne]);let re=Ae(ne,50),ie=Ae((0,Q.useCallback)(async e=>{F.current=e;let t=await qN(C.getState().mcp.clients,e);F.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:BP(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),ae=(0,Q.useCallback)(async(t,n)=>{let r=n??j.current;if(f){re.cancel(),L();return}if(o===`prompt`){let n=dN(t,r);if(n&&fN(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){P.current=t;let e=await ON(t);if(P.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;if(Gn()&&t.teamContext)for(let i of Object.values(t.teamContext.teammates??{}))i.name!==`team-lead`&&i.name.toLowerCase().startsWith(e)&&(r.add(i.name),n.push({id:`dm-${i.name}`,displayText:`@${i.name}`,description:`send message`}));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){re.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:BP(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(RP);if(e&&HN(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),L())}let a=t.substring(0,r).match(LP),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&pN(t)&&r>0){let e=ZP(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){re.cancel(),L();return}let n=await cC(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:BP(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}re.cancel(),L();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await h_(t,{limit:10})).map(e=>{let t=Rm(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:ua(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:BP(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}L();return}}let l=t.substring(0,r);if(o===`prompt`&&pN(l)&&r>0&&!QP(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=Qy(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=Jo(l.slice(n+1));t=id(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=yN(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`?(re.cancel(),L()):pN(l)&&QP(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&L(),_===`agent`&&te.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||L()),a&&o!==`bash`){let e=XP(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=HP(e);if(aC(t)){N.current=t;let e=await oC(t,{maxResults:10});if(N.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:BP(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(ee.current===t)return;re(t,!0);return}}if(_===`file`){let e=XP(t,r,!0);if(e){let t=HP(e);if(ee.current===t)return;re(t,!1)}else re.cancel(),L()}if(_===`shell`){let e=te.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(re.cancel(),L())}},[_,e,c,L,re,ie,o,f,y]);(0,Q.useEffect)(()=>{I.current!==i&&(M.current!==i&&(M.current=i,ee.current=null),I.current=null,ae(i))},[i,ae]);let oe=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=dN(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){re.cancel(),ie.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=`/${Qy(e)} `;t(n+i.slice(a)),r(n.length)}L()}}else if(_===`custom-title`&&l.length>0){if(n){let e=VP(n);t(e),r(e.length),L()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=pN(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=zP(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),zP(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):L()}else{let e=XP(i,a,!0)??XP(i,a,!1);if(e){let a=zP(n.metadata)&&n.metadata.type===`directory`,s=YP(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,s.cursorPos)):L()}else L()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;WP(n,i,a,t,r,e?.completionType),L()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(KP(n,i,a,GP,t,r),L())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(KP(n,i,a,RP,t,r),L())}else if(_===`file`&&l.length>0){let n=XP(i,a,!0);if(!n){L();return}let s=BC(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=UP({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});UC(e,i,n.token,n.startPos,t,r),ae(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);UC(UP({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),L()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await JP(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;WP(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=XP(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await MP(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:BP(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,L,a,ae,S,c,s,re,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(bN(s,!0,e,t,r,n),re.cancel(),L());else if(_===`custom-title`&&u<l.length){if(s){let e=VP(s);t(e),r(e.length),n(e,!0),re.cancel(),L()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;WP(e,i,a,t,r,n?.completionType),re.cancel(),L()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))KP(s,i,a,GP,t,r),re.cancel(),L();else if(_===`slack-channel`&&u<l.length)s&&(KP(s,i,a,RP,t,r),ie.cancel(),L());else if(_===`file`&&u<l.length){let e=XP(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);UC(UP({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),re.cancel(),L()}}else if(_===`directory`&&u<l.length&&s){if(pN(i)){re.cancel(),L();return}let e=XP(i,a,!0)??XP(i,a,!1);if(e){let n=zP(s.metadata)&&s.metadata.type===`directory`,a=YP(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}re.cancel(),L()}},[l,u,_,e,i,a,o,t,r,n,L,re,ie]),ce=(0,Q.useCallback)(()=>{oe()},[oe]),le=(0,Q.useCallback)(()=>{re.cancel(),ie.cancel(),L(),I.current=i},[re,ie,L,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":ce,"autocomplete:dismiss":le,"autocomplete:previous":ue,"autocomplete:next":de}),[ce,le,ue,de]),pe=l.length>0||!!A,R=Id();yd(`autocomplete`,pe),Ce(`Autocomplete`,pe),Se(fe,{context:`Autocomplete`,isActive:pe&&!R});function me(e){let n=WM(e);if(n!==`prompt`&&m){m(n);let i=GM(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(),me(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(),me(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(z,{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(),se())};return je((e,t,n)=>{let r=new Ne(n.keypress);ge(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:ge}}aa();var eF=3e4;function tF(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`local_agent`}function nF(e){return{...e,retain:!1,messages:void 0,diskLoaded:!1,evictAfter:ch(e.status)?Date.now()+eF:void 0}}function rF(e,t){Y(`tengu_transcript_view_enter`,{}),t(t=>{let n=t.tasks[e],r=t.viewingAgentTaskId,i=r===void 0?void 0:t.tasks[r],a=r!==void 0&&r!==e&&tF(i)&&i.retain,o=tF(n)&&(!n.retain||n.evictAfter!==void 0),s=t.viewingAgentTaskId!==e||t.viewSelectionMode!==`viewing-agent`;if(!o&&!s&&!a)return t;let c=t.tasks;return(a||o)&&(c={...t.tasks},a&&(c[r]=nF(i)),o&&(c[e]={...n,retain:!0,evictAfter:void 0})),{...t,viewingAgentTaskId:e,viewSelectionMode:`viewing-agent`,tasks:c}})}function iF(e){Y(`tengu_transcript_view_exit`,{}),e(e=>{let t=e.viewingAgentTaskId,n={...e,viewingAgentTaskId:void 0,viewSelectionMode:`none`};if(t===void 0)return e.viewSelectionMode===`none`?e:n;let r=e.tasks[t];return!tF(r)||!r.retain?n:{...n,tasks:{...e.tasks,[t]:nF(r)}}})}function aF(e,t){t(t=>{let n=t.tasks[e];if(!tF(n))return t;if(n.status===`running`)return n.abortController?.abort(),t;if(n.evictAfter===0)return t;let r=t.viewingAgentTaskId===e;return{...t,tasks:{...t.tasks,[e]:{...nF(n),evictAfter:0}},...r&&{viewingAgentTaskId:void 0,viewSelectionMode:`none`}}})}function oF(e){let t=e.match(/^@([\w-]+)\s+(.+)$/s);if(!t)return null;let[,n,r]=t;if(!n||!r)return null;let i=r.trim();return i?{recipientName:n,message:i}:null}async function sF(e,t,n,r){return!n||!r?{success:!1,error:`no_team_context`}:Object.values(n.teammates??{}).find(t=>t.name===e)?(await r(e,{from:`user`,text:t,timestamp:new Date().toISOString()},n.teamName),{success:!0,recipientName:e}):{success:!1,error:`unknown_recipient`,recipientName:e}}iw();var cF={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function lF(e){return e in cF}gy();function uF(e,t){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 dF(e,t){let n=uF(e,t);return{nextMode:n,context:bs(e.mode,n,e)}}CS(),Rh(),kC();var fF=FS();Ke(),Ts(),Cr(),_o(),H(),Px(),tb(),mn(),ii();function pF({onDone:e}){yd(`bridge-dialog`);let t=X(e=>e.replBridgeConnected),n=X(e=>e.replBridgeSessionActive),r=X(e=>e.replBridgeReconnecting),i=X(e=>e.replBridgeConnectUrl),a=X(e=>e.replBridgeSessionUrl),o=X(e=>e.replBridgeError),s=X(e=>e.replBridgeExplicit),c=X(e=>e.replBridgeEnvironmentId),l=X(e=>e.replBridgeSessionId),u=X(e=>e.verbose),d=Zs(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=KT(Ye());(0,Q.useEffect)(()=>{ti().then(_).catch(()=>{})},[]);let y=n?a:i;(0,Q.useEffect)(()=>{if(!f||!y){h(``);return}(0,fF.toString)(y,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,y]),Se({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),je(t=>{t===`d`&&(s&&Dr(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:b,color:x}=tu({error:o,connected:t,sessionActive:n,reconnecting:r}),S=o?`×`:nn,C=m?m.split(`
53
+ `).filter(e=>e.length>0):[],w=[];v&&w.push(v),g&&w.push(g);let T=w.length>0?` · `+w.join(` · `):``,E=o?Vl:y?n?ao(y):wl(y):void 0;return(0,$.jsx)(ve,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(z,{children:[(0,$.jsxs)(z,{color:x,children:[S,` `,b]}),(0,$.jsx)(z,{dimColor:!0,children:T})]}),o&&(0,$.jsx)(z,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(z,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(z,{dimColor:!0,children:[`Session: `,l]})]}),f&&C.length>0&&(0,$.jsx)(U,{flexDirection:`column`,children:C.map((e,t)=>(0,$.jsx)(z,{children:e},t))}),E&&(0,$.jsx)(z,{dimColor:!0,children:E}),(0,$.jsx)(z,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}m(),Cr(),Fx(),H(),tb(),mp(),va(),uT();function mF(e){return Object.values(e).filter(e=>av(e)&&e.evictAfter!==0).sort((e,t)=>e.startTime-t.startTime)}function hF(){let e=X(e=>e.tasks),t=X(e=>e.viewingAgentTaskId),n=X(e=>e.agentNameRegistry),r=X(e=>e.coordinatorTaskIndex),i=X(e=>e.footerSelection===`tasks`)?r:void 0,a=Zs(),o=mF(e),s=Object.values(e).some(av),c=Q.useRef(e);c.current=e;let[,l]=Q.useState(0);Q.useEffect(()=>{if(!s)return;let e=setInterval((e,t,n)=>{let r=Date.now();for(let n of Object.values(e.current))av(n)&&(n.evictAfter??1/0)<=r&&km(n.id,t);n(e=>e+1)},1e3,c,a,l);return()=>clearInterval(e)},[s,a]);let u=Q.useMemo(()=>{let e=new Map;for(let[t,r]of n)e.set(r,t);return e},[n]);return o.length===0?null:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(_F,{isSelected:i===0,isViewed:t===void 0,onClick:()=>iF(a)}),o.map((e,n)=>(0,$.jsx)(vF,{task:e,name:u.get(e.id),isSelected:i===n+1,isViewed:t===e.id,onClick:()=>rF(e.id,a)},e.id))]})}function gF(){let e=X(e=>e.tasks);return Q.useMemo(()=>{if(process.env.USER_TYPE!==`ant`)return 0;let t=mF(e).length;return t>0?t+1:0},[e])}function _F({isSelected:e,isViewed:t,onClick:n}){let[r,i]=Q.useState(!1),a=e||r?h.pointer+` `:` `,o=t?wr:h.circle;return(0,$.jsx)(U,{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:(0,$.jsxs)(z,{dimColor:!e&&!t&&!r,bold:t,children:[a,o,` main`]})})}function vF({task:e,name:t,isSelected:n,isViewed:r,onClick:i}){let{columns:a}=ee(),[o,s]=Q.useState(!1),c=!oT(e.status),l=e.totalPausedMs??0,u=fa(Math.max(0,c?Date.now()-e.startTime-l:(e.endTime??e.startTime)-e.startTime-l)),d=e.progress?.tokenCount,f=e.progress?.lastActivity?h.arrowDown:h.arrowUp,p=d!==void 0&&d>0?` · ${f} ${da(d)} tokens`:``,m=e.pendingMessages.length,g=m>0?` · ${m} queued`:``,_=e.progress?.summary||e.description,v=n||o,y=v?h.pointer+` `:` `,b=r?wr:h.circle,x=!v&&!r,S=c?`▶`:`⏸`,C=t?`${t}: `:``,w=n&&!r?` · x to ${c?`stop`:`clear`}`:``,T=` ${S} ${u}${p}${g}${w}`,E=a-A(y)-A(`${b} `)-A(C)-A(T),D=ye(_,Math.max(0,E),`truncate-end`),O=(0,$.jsxs)(z,{dimColor:x,bold:r,children:[y,b,` `,t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{dimColor:!1,bold:!0,children:t}),`: `]}),D,` `,S,` `,u,p,m>0&&(0,$.jsx)(z,{color:`warning`,children:g}),w&&(0,$.jsx)(z,{dimColor:!0,children:w})]});return i?(0,$.jsx)(U,{onClick:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:O}):O}pv(),rw(),lT(),H(),_o(),Fx(),H(),qr(),hC(),va(),hs(),Kb(),_o(),Xu(),Fx(),H(),va(),ZC(),$C(),_o(),RC(),Fx(),H(),qr(),hC(),va(),dl(),H(),Px(),Iv(),py();function yF({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=XC(),[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`}];De(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),De(`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)(we,{color:`permission`,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(z,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(z,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(U,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(ku,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(z,{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)(z,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(z,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(V,{children:[(0,$.jsx)(B,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(eg,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(V,{children:[(0,$.jsx)(B,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(eg,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}pT(),cT(),m(),j(),_o(),H(),Px(),fm(),tb(),Uu(),K(),xi(),va(),sr(),Fr(),_S(),bx(),GS(),ay();function bF({initialTeams:e,onDone:t}){yd(`teams-dialog`);let n=Zs(),[r,i]=(0,Q.useState)({type:`teammateList`,teamName:e?.[0]?.name??``}),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(0),l=(0,Q.useMemo)(()=>KS(r.teamName),[r.teamName,s]);ue(()=>{c(e=>e+1)},1e3);let u=(0,Q.useMemo)(()=>r.type===`teammateDetail`?l.find(e=>e.name===r.memberName)??null:null,[r,l]),d=X(e=>e.toolPermissionContext.isBypassPermissionsModeAvailable),f=()=>{i({type:`teammateList`,teamName:r.teamName}),o(0)};Se({"confirm:cycleMode":(0,Q.useCallback)(()=>{r.type===`teammateDetail`&&u?(AF(u,r.teamName,d),c(e=>e+1)):r.type===`teammateList`&&l.length>0&&(jF(l,r.teamName,d),c(e=>e+1))},[r,u,l,d])},{context:`Confirmation`}),je((e,s)=>{if(s.leftArrow){r.type===`teammateDetail`&&f();return}if(s.upArrow||s.downArrow){let e=p();s.upArrow?o(e=>Math.max(0,e-1)):o(t=>Math.min(e,t+1));return}if(s.return){r.type===`teammateList`&&l[a]?i({type:`teammateDetail`,teamName:r.teamName,memberName:l[a].name}):r.type===`teammateDetail`&&u&&(TF(u.tmuxPaneId,u.backendType&&Nx(u.backendType)?u.backendType:void 0),t());return}if(e===`k`){r.type===`teammateList`&&l[a]?wF(l[a].tmuxPaneId,l[a].backendType&&Nx(l[a].backendType)?l[a].backendType:void 0,r.teamName,l[a].agentId,l[a].name,n).then(()=>{c(e=>e+1),o(e=>Math.max(0,Math.min(e,l.length-2)))}):r.type===`teammateDetail`&&u&&(wF(u.tmuxPaneId,u.backendType&&Nx(u.backendType)?u.backendType:void 0,r.teamName,u.agentId,u.name,n),f());return}if(e===`s`){if(r.type===`teammateList`&&l[a]){let e=l[a];ip(e.name,r.teamName,`Graceful shutdown requested by team lead`)}else r.type===`teammateDetail`&&u&&(ip(u.name,r.teamName,`Graceful shutdown requested by team lead`),f());return}if(e===`h`){let e=gs(),t=r.type===`teammateList`?l[a]:r.type===`teammateDetail`?u:null;t&&e?.supportsHideShow&&(EF(t,r.teamName).then(()=>{c(e=>e+1)}),r.type===`teammateDetail`&&f());return}if(e===`H`&&r.type===`teammateList`){if(gs()?.supportsHideShow&&l.length>0){let e=l.some(e=>!e.isHidden);Promise.all(l.map(t=>e?DF(t,r.teamName):OF(t,r.teamName))).then(()=>{c(e=>e+1)})}return}if(e===`p`&&r.type===`teammateList`){let e=l.filter(e=>e.status===`idle`);e.length>0&&Promise.all(e.map(e=>wF(e.tmuxPaneId,e.backendType&&Nx(e.backendType)?e.backendType:void 0,r.teamName,e.agentId,e.name,n))).then(()=>{c(e=>e+1),o(t=>Math.max(0,Math.min(t,l.length-e.length-1)))});return}});function p(){return r.type===`teammateList`?Math.max(0,l.length-1):0}return r.type===`teammateList`?(0,$.jsx)(xF,{teamName:r.teamName,teammates:l,selectedIndex:a,onCancel:t}):r.type===`teammateDetail`&&u?(0,$.jsx)(CF,{teammate:u,teamName:r.teamName,onCancel:f}):null}function xF({teamName:e,teammates:t,selectedIndex:n,onCancel:r}){let i=`${t.length} ${t.length===1?`teammate`:`teammates`}`,a=gs()?.supportsHideShow??!1,o=gv(`confirm:cycleMode`,`Confirmation`,`shift+tab`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ve,{title:`Team ${e}`,subtitle:i,onCancel:r,color:`background`,hideInputGuide:!0,children:t.length===0?(0,$.jsx)(z,{dimColor:!0,children:`No teammates`}):(0,$.jsx)(U,{flexDirection:`column`,children:t.map((e,t)=>(0,$.jsx)(SF,{teammate:e,isSelected:t===n},e.agentId))})}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.arrowUp,`/`,h.arrowDown,` select · Enter view · k kill · s shutdown · p prune idle`,a&&` · h hide/show · H hide/show all`,` · `,o,` sync cycle modes for all · Esc close`]})})]})}function SF({teammate:e,isSelected:t}){let n=e.status===`idle`,r=n&&!t,i=e.mode?Fn(e.mode):`default`,a=Sr(i),o=An(i);return(0,$.jsxs)(z,{color:t?`suggestion`:void 0,dimColor:r,children:[t?h.pointer+` `:` `,e.isHidden&&(0,$.jsx)(z,{dimColor:!0,children:`[hidden] `}),n&&(0,$.jsx)(z,{dimColor:!0,children:`[idle] `}),a&&(0,$.jsxs)(z,{color:o,children:[a,` `]}),`@`,e.name,e.model&&(0,$.jsxs)(z,{dimColor:!0,children:[` (`,e.model,`)`]})]})}function CF({teammate:e,teamName:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),a=gv(`confirm:cycleMode`,`Confirmation`,`shift+tab`),o=e.color?jp[e.color]:void 0,[s,c]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let n=!1;return mx(t).then(t=>{n||c(t.filter(t=>t.owner===e.agentId||t.owner===e.name))}),()=>{n=!0}},[t,e.agentId,e.name]),je(e=>{e===`p`&&i(e=>!e)});let l=e.worktreePath||e.cwd,u=[];e.model&&u.push(e.model),l&&u.push(e.worktreePath?`worktree: ${l}`:l);let d=u.join(` · `)||void 0,f=e.mode?Fn(e.mode):`default`,p=Sr(f),m=An(f);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ve,{title:(0,$.jsxs)($.Fragment,{children:[p&&(0,$.jsxs)(z,{color:m,children:[p,` `]}),o?(0,$.jsx)(z,{color:o,children:`@${e.name}`}):`@${e.name}`]}),subtitle:d,onCancel:n,color:`background`,hideInputGuide:!0,children:[s.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:`Tasks`}),s.map(e=>(0,$.jsxs)(z,{color:e.status===`completed`?`success`:void 0,children:[e.status===`completed`?h.tick:`◼`,` `,e.subject]},e.id))]}),e.prompt&&(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{bold:!0,children:`Prompt`}),(0,$.jsxs)(z,{children:[r?e.prompt:ga(e.prompt,80),A(e.prompt)>80&&!r&&(0,$.jsx)(z,{dimColor:!0,children:` (p to expand)`})]})]})]}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.arrowLeft,` back · Esc close · k kill · s shutdown`,gs()?.supportsHideShow&&` · h hide/show`,` · `,a,` cycle mode`]})})]})}async function wF(e,t,n,r,i,a){if(t)try{await Dy(),await ld(t).killPane(e,!wS())}catch(t){q(`[TeamsDialog] Failed to kill pane ${e}: ${t}`)}else q(`[TeamsDialog] Skipping pane kill for ${e}: no backendType recorded`);Ax(n,e);let{notificationMessage:o}=await _x(n,r,i,`terminated`);a(e=>{if(!e.teamContext?.teammates||!(r in e.teamContext.teammates))return e;let{[r]:t,...n}=e.teamContext.teammates;return{...e,teamContext:{...e.teamContext,teammates:n},inbox:{messages:[...e.inbox.messages,{id:oE(),from:`system`,text:zr({type:`teammate_terminated`,message:o}),timestamp:new Date().toISOString(),status:`pending`}]}}}),q(`[TeamsDialog] Removed ${r} from teamContext`)}async function TF(e,t){t===`iterm2`?await Si(`it2`,[`session`,`focus`,`-s`,e]):t===`windows-terminal`?q(`[TeamsDialog] viewTeammateOutput: Windows Terminal pane ${e} — manual tab switch required`):await Si(vS,wS()?[`select-pane`,`-t`,e]:[`-L`,yS(),`select-pane`,`-t`,e])}async function EF(e,t){e.isHidden?await OF(e,t):await DF(e,t)}async function DF(e,t){}async function OF(e,t){}function kF(e,t,n){Dx(t,e,n),my(e,{from:`team-lead`,text:zr(Wg({mode:n,from:`team-lead`})),timestamp:new Date().toISOString()},t),q(`[TeamsDialog] Sent mode change to ${e}: ${n}`)}function AF(e,t,n){let r=e.mode?Fn(e.mode):`default`,i=uF({...uu(),mode:r,isBypassPermissionsModeAvailable:n});kF(e.name,t,i)}function jF(e,t,n){if(e.length===0)return;let r=e.map(e=>e.mode?Fn(e.mode):`default`),i=r.every(e=>e===r[0])?uF({...uu(),mode:r[0]??`default`,isBypassPermissionsModeAvailable:n}):`default`;Tx(t,e.map(e=>({memberName:e.name,mode:i})));for(let n of e){let e=Wg({mode:i,from:`team-lead`});my(n.name,{from:`team-lead`,text:zr(e),timestamp:new Date().toISOString()},t)}q(`[TeamsDialog] Sent mode change to all ${e.length} teammates: ${i}`)}function MF(e,t,n){let r=t;for(let t=0;t<n;t++){let t=NF(e,r);if(t.equals(r))break;r=t}return r}function NF(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 PF(e){return`eE$`.includes(e)}function FF(e){return`jkG`.includes(e)||e===`gg`}var IF={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function LF(e,t,n,r){if(n===`w`)return RF(e,t,r,jm);if(n===`W`)return RF(e,t,r,e=>!Zp(e));let i=IF[n];if(i){let[n,a]=i;return n===a?zF(e,t,n,r):BF(e,t,n,a,r)}return null}function RF(e,t,n,r){let i=[];for(let{segment:t,index:n}of sa().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=>Zp(o(e)),l=e=>r(o(e)),u=e=>Lv(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 zF(e,t,n,r){let i=e.lastIndexOf(`
54
+ `,t-1)+1,a=e.indexOf(`
55
+ `,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 BF(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}}tg(),ca(),Zi();function VF(e,t,n,r){let i=MF(t,r.cursor,n);if(i.equals(r.cursor))return;let a=$F(r.cursor,i,t,e,n);tI(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function HF(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new tv(i.cursor.measuredText,a),s=eI(i.cursor,o,t);tI(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function UF(e,t,n,r,i){let a=LF(i.text,i.cursor.offset,n,t===`inner`);a&&(tI(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function WF(e,t,n){let r=n.text,i=r.split(`
56
+ `),a=ta(r.slice(0,n.cursor.offset),`
57
+ `),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(`
58
+ `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
59
+ `)||(l+=`
60
+ `),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]===`
61
+ `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(oa(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(`
62
+ `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function GF(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-(oa(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function KF(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=la(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 qF(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=la(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 JF(e,t){let n=t.text.split(`
63
+ `),{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(`
64
+ `);t.setText(c),t.setOffset(QF(s,r)+o),t.recordChange({type:`join`,count:e})}function YF(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
65
+ `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
66
+ `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
67
+ `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
68
+ `);n.setText(u),n.setOffset(QF(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=oa(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function XF(e,t,n){let r=n.text.split(`
69
+ `),{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(`
70
+ `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(QF(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function ZF(e,t){let n=t.text.split(`
71
+ `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
72
+ `);t.setText(o),t.enterInsert(QF(a,i)),t.recordChange({type:`openLine`,direction:e})}function QF(e,t){return e.slice(0,t).join(`
73
+ `).length+ +(t>0)}function $F(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(FF(n)){s=!0;let t=e.text,n=t.indexOf(`
74
+ `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
75
+ `&&--a):o=n+1}else PF(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 eI(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 tI(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
76
+ `)&&(a+=`
77
+ `),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-(oa(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 nI(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=$F(n.cursor,r,`G`,e,t);tI(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function rI(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=$F(n.cursor,r,`gg`,e,t);tI(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var iI={d:`delete`,c:`change`,y:`yank`};function aI(e){return e in iI}var oI=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),sI=new Set([`f`,`F`,`t`,`T`]),cI={i:`inner`,a:`around`};function lI(e){return e in cI}var uI=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),dI=1e4;function fI(){return{mode:`INSERT`,insertedText:``}}function pI(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function mI(e,t,n){switch(e.type){case`idle`:return _I(t,n);case`count`:return vI(e,t,n);case`operator`:return yI(e,t,n);case`operatorCount`:return bI(e,t,n);case`operatorFind`:return xI(e,t,n);case`operatorTextObj`:return SI(e,t,n);case`find`:return CI(e,t,n);case`g`:return wI(e,t,n);case`operatorG`:return TI(e,t,n);case`replace`:return EI(e,t,n);case`indent`:return DI(e,t,n)}}function hI(e,t,n){return aI(e)?{next:{type:`operator`,op:iI[e],count:t}}:oI.has(e)?{execute:()=>{let r=MF(e,n.cursor,t);n.setOffset(r.offset)}}:sI.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:()=>qF(t,n)}:e===`x`?{execute:()=>GF(t,n)}:e===`J`?{execute:()=>JF(t,n)}:e===`p`||e===`P`?{execute:()=>YF(e===`p`,t,n)}:e===`D`?{execute:()=>VF(`delete`,`$`,1,n)}:e===`C`?{execute:()=>VF(`change`,`$`,1,n)}:e===`Y`?{execute:()=>WF(`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:()=>OI(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:()=>ZF(`below`,n)}:e===`O`?{execute:()=>ZF(`above`,n)}:null}function gI(e,t,n,r){return lI(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:cI[n]}}:sI.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:oI.has(n)?{execute:()=>VF(e,n,t,r)}:n===`G`?{execute:()=>nI(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function _I(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:hI(e,1,t)||{}}function vI(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),dI))}}}return hI(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function yI(e,t,n){return t===e.op[0]?{execute:()=>WF(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:gI(e.op,e.count,t,n)||{next:{type:`idle`}}}function bI(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),dI);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return gI(e.op,i,t,n)||{next:{type:`idle`}}}function xI(e,t,n){return{execute:()=>HF(e.op,e.find,t,e.count,n)}}function SI(e,t,n){return uI.has(t)?{execute:()=>UF(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function CI(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 wI(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=MF(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
78
+ `),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 TI(e,t,n){return t===`j`||t===`k`?{execute:()=>VF(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>rI(e.op,e.count,n)}:{next:{type:`idle`}}}function EI(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>KF(t,e.count,n)}}function DI(e,t,n){return t===e.dir?{execute:()=>XF(e.dir,e.count,n)}:{next:{type:`idle`}}}function OI(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)}tg(),ca();function kI(e){let t=Q.useRef(fI()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(pI()),a=hv({...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]!==`
79
+ `&&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=tv.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`:GF(t.count,r);break;case`replace`:KF(t.char,t.count,r);break;case`toggleCase`:qF(t.count,r);break;case`indent`:XF(t.dir,t.count,r);break;case`join`:JF(t.count,r);break;case`openLine`:ZF(t.direction,r);break;case`operator`:VF(t.op,t.motion,t.count,r);break;case`operatorFind`:HF(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:UF(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=tv.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,-(oa(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=mI(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}L(),H();function AI(e){let[t]=ce(),n=fe();Hd(n,!!e.onImagePaste);let r=kI({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?P.inverse:e=>e,themeText:Oe(`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)(U,{flexDirection:`column`,children:(0,$.jsx)(sf,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}nx(),DS(),PS(),fy(),qS(),Hw(),l();function jI(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 MI(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function NI(e){let t=aE(`sha256`).update(e).digest(`hex`).slice(0,16);return nE(c(),`cache-stats`,`${t}.json`)}var PI={version:1,signature:null,lastResetAt:null,lastHitRate:null};function FI(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 II(e){try{let t=await hE(e,`utf8`),n=JSON.parse(t);return FI(n)?n:{...PI}}catch{return{...PI}}}async function LI(e,t){await mE(tE(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await _E(n,JSON.stringify(t),`utf8`),await gE(n,e)}catch{}}var RI={signature:null,lastResetAt:null,lastHitRate:null},zI=null;async function BI(e){zI=e;let t=await II(NI(e));RI={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function VI(e){let t=MI(e),n=jI(e);return t!==RI.signature&&(RI={signature:t,lastResetAt:Date.now(),lastHitRate:n},zI!==null&&LI(NI(zI),{version:1,signature:t,lastResetAt:RI.lastResetAt,lastHitRate:n})),{...RI}}function HI(){return{...RI}}Pg(),H(),va(),Fx();function UI(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 WI(){return(0,$.jsx)(z,{dimColor:!0,children:` │ `})}function GI({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=ee(),[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=`${ha(n)}/${ha(r)}`;return(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{children:u}),(0,$.jsx)(WI,{}),(0,$.jsx)(z,{dimColor:!0,children:`Context `}),(0,$.jsxs)(z,{children:[t,`%`]}),!d&&(0,$.jsxs)(z,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(WI,{}),(0,$.jsx)(z,{dimColor:!0,children:`Session `}),(0,$.jsxs)(z,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(z,{dimColor:!0,children:[` `,UI(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(WI,{}),(0,$.jsx)(z,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(z,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(z,{dimColor:!0,children:[` `,UI(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(WI,{}),(0,$.jsx)(z,{children:Za(i)})]})]})}var KI=Q.memo(GI);$i(),S_(),Ke(),Fs(),Pg(),SC(),Ss(),H(),mn(),or(),qr(),K(),kg(),Yv(),Lf(),Ht(),Fp(),Nd(),ib();var qI=3600*1e3;function JI(e){return String(Math.floor(e)).padStart(2,`0`)}function YI(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${JI(t)}:${JI(n)}`}function XI({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=nb(e),o=(0,Q.useRef)(null);if(a!==null){let e=MI(a);e!==o.current&&(o.current=e,VI(a))}let{lastResetAt:s,lastHitRate:c}=HI(),l=s===null?null:t-s,u=l===null?null:qI-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,BI(ft()))},[]);let h=a===null?c:jI(a);if(h===null&&s===null)return(0,$.jsx)(z,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:YI(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{dimColor:!0,children:` Cache `}),(0,$.jsx)(z,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(z,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function ZI(){let{getGoal:t,formatGoalStatusLabel:n}=(ig(),e(Bp)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Du(r.tokensUsed):`${Du(r.tokensUsed)}/${Du(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(z,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(z,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(z,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(z,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(z,{children:o})}return(0,$.jsxs)(z,{children:[s,(0,$.jsx)(z,{dimColor:!0,children:` · `}),(0,$.jsx)(z,{dimColor:!0,children:i}),(0,$.jsx)(z,{dimColor:!0,children:` · `}),(0,$.jsx)(z,{children:a})]})}function QI(e){return qe()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function $I(e,t,n,r,i,a,o){let s=at(),c=dh(),l=It({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=nb(r),f=Xn(l,gt()),p=Cn(d,f),m=Y_(ft()),h=Is(),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{...ts(),...m&&{session_name:m},model:{id:l,display_name:tr(l)},workspace:{current_dir:Jr(),project_dir:Ye(),added_dirs:i},version:`2.8.4`,output_style:{name:u},cost:{total_cost_usd:wt(),total_duration_ms:Et(),total_api_duration_ms:St(),total_lines_added:Tt(),total_lines_removed:rt()},context_window:{total_input_tokens:pt(),total_output_tokens:ze(),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},...zw()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...tt()&&{remote:{session_id:ft()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function eL(e){return Rd(e)?.uuid??null}function tL({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=Z(e=>e.toolPermissionContext.mode),a=Z(e=>e.toolPermissionContext.additionalWorkingDirectories),o=Z(e=>e.statusLineText),s=nf(),c=dc(),{addNotification:l}=Ic(),u=xC(),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=eL(n);r!==g.current.messageId&&(e=Xc(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Gc($I(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&&(J(`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`}),G()||(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,w=It({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),T=Xn(w,gt()),E=nb(e.current),D=E?E.input_tokens+E.cache_creation_input_tokens+E.cache_read_input_tokens:0,O=E?Math.round(Cn(E,T).used??0):0,k=Is(),A={...k.five_hour&&{five_hour:{utilization:k.five_hour.utilization,resets_at:k.five_hour.resets_at}},...k.seven_day&&{seven_day:{utilization:k.seven_day.utilization,resets_at:k.seven_day.resets_at}}},j=c?.statusLineEnabled===!0,ee=!!c?.statusLine?.command;return(0,$.jsxs)(U,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(U,{gap:2,children:[(0,$.jsx)(KI,{modelName:tr(w),contextUsedPct:O,usedTokens:D,contextWindowSize:T,totalCostUsd:wt(),rateLimits:A}),(0,$.jsx)(ZI,{}),(0,$.jsx)(XI,{messages:e.current})]}),o?(0,$.jsx)(z,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(me,{children:o})}):ee&&gh()?(0,$.jsx)(z,{children:` `}):null]})}var nL=(0,Q.memo)(tL);Cr(),Li();function rL(e){let t=e.length;if(e.every(t=>t.type===e[0].type))switch(e[0].type){case`local_bash`:{let n=Ii(e,e=>e.type===`local_bash`&&e.kind===`monitor`),r=t-n,i=[];return r>0&&i.push(r===1?`1 shell`:`${r} shells`),n>0&&i.push(n===1?`1 monitor`:`${n} monitors`),i.join(`, `)}case`in_process_teammate`:{let t=new Set(e.map(e=>e.type===`in_process_teammate`?e.identity.teamName:``)).size;return t===1?`1 team`:`${t} teams`}case`local_agent`:return t===1?`1 local agent`:`${t} local agents`;case`remote_agent`:{let n=e[0];if(t===1&&n.type===`remote_agent`&&n.isUltraplan)switch(n.ultraplanPhase){case`plan_ready`:return`◆ ultraplan ready`;case`needs_input`:return`◇ ultraplan needs your input`;default:return`◇ ultraplan`}return t===1?`◇ 1 cloud session`:`◇ ${t} cloud sessions`}case`local_workflow`:return t===1?`1 background workflow`:`${t} background workflows`;case`monitor_mcp`:return t===1?`1 monitor`:`${t} monitors`;case`dream`:return`dreaming`}return`${t} background ${t===1?`task`:`tasks`}`}function iL(e){if(e.length!==1)return!1;let t=e[0];return t.type===`remote_agent`&&t.isUltraplan===!0&&t.ultraplanPhase!==void 0}function aL(e,t,n,r,i=!0){let a=e.length;if(a===0)return{startIndex:0,endIndex:0,showLeftArrow:!1,showRightArrow:!1};let o=Math.max(0,Math.min(r,a-1));if(e.reduce((e,t)=>e+t,0)<=t)return{startIndex:0,endIndex:a,showLeftArrow:!1,showRightArrow:!1};let s=[0];for(let t=0;t<a;t++)s.push(s[t]+e[t]);function c(e,t){let n=s[t]-s[e];return i&&e>0?n-1:n}function l(e,r){let i=t;return e>0&&(i-=n),r<a&&(i-=n),i}let u=0,d=1;for(;d<a&&c(u,d+1)<=l(u,d+1);)d++;if(o>=u&&o<d)return{startIndex:u,endIndex:d,showLeftArrow:u>0,showRightArrow:d<a};if(o>=d)for(d=o+1,u=o;u>0&&c(u-1,d)<=l(u-1,d);)u--;else for(u=o,d=o+1;d<a&&c(u,d+1)<=l(u,d+1);)d++;return{startIndex:u,endIndex:d,showLeftArrow:u>0,showRightArrow:d<a}}m(),Bh(),H(),S_(),Uu(),uT();function oL({tasksSelected:e,isViewingTeammate:t,teammateFooterIndex:n=0,isLeaderIdle:r=!1,onOpenDialog:i}){let a=nf(),{columns:o}=ee(),s=Z(e=>e.tasks),c=Z(e=>e.viewingAgentTaskId),l=(0,Q.useMemo)(()=>Object.values(s??{}).filter(e=>dT(e)&&!(process.env.USER_TYPE===`ant`&&Dg(e))),[s]),u=Z(e=>e.expandedView)===`teammates`,d=!u&&l.length>0&&l.every(e=>e.type===`in_process_teammate`),f=(0,Q.useMemo)(()=>l.filter(e=>e.type===`in_process_teammate`).sort((e,t)=>e.identity.agentName.localeCompare(t.identity.agentName)),[l]),p=(0,Q.useMemo)(()=>{let t={name:`main`,color:void 0,isIdle:r,taskId:void 0},n=f.map(e=>({name:e.identity.agentName,color:lL(e.identity.color),isIdle:e.isIdle,taskId:e.id}));return e||n.sort((e,t)=>e.isIdle===t.isIdle?0:e.isIdle?1:-1),[t,...n].map((e,t)=>({...e,idx:t}))},[f,r,e]),m=(0,Q.useMemo)(()=>p.map((e,t)=>A(`@${e.name}`)+ +(t>0)),[p]);if(d||!u&&t){let t=e?n:-1,r=c?f.findIndex(e=>e.id===c)+1:0,{startIndex:i,endIndex:s,showLeftArrow:l,showRightArrow:u}=aL(m,Math.max(20,o-20-4),2,t>=0?t:0),d=p.slice(i,s);return(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsxs)(z,{dimColor:!0,children:[h.arrowLeft,` `]}),d.map((e,n)=>{let i=n>0;return(0,$.jsxs)(Q.Fragment,{children:[i&&(0,$.jsx)(z,{children:` `}),(0,$.jsx)(sL,{name:e.name,color:e.color,isSelected:t===e.idx,isViewed:r===e.idx,isIdle:e.isIdle,onClick:()=>e.taskId?aT(e.taskId,a):sT(a)})]},e.name)}),u&&(0,$.jsxs)(z,{dimColor:!0,children:[` `,h.arrowRight]}),(0,$.jsxs)(z,{dimColor:!0,children:[` · `,(0,$.jsx)(B,{shortcut:`shift + ↓`,action:`expand`})]})]})}return iT(s??{},u)||l.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cL,{selected:e,onClick:i,children:rL(l)}),iL(l)&&(0,$.jsxs)(z,{dimColor:!0,children:[` · `,h.arrowDown,` to view`]})]})}function sL({name:e,color:t,isSelected:n,isViewed:r,isIdle:i,onClick:a}){let[o,s]=(0,Q.useState)(!1),c=n||o,l;return l=c?t?(0,$.jsxs)(z,{backgroundColor:t,color:`inverseText`,bold:r,children:[`@`,e]}):(0,$.jsxs)(z,{color:`background`,inverse:!0,bold:r,children:[`@`,e]}):i?(0,$.jsxs)(z,{dimColor:!0,bold:r,children:[`@`,e]}):r?(0,$.jsxs)(z,{color:t,bold:!0,children:[`@`,e]}):(0,$.jsxs)(z,{color:t,dimColor:!t,children:[`@`,e]}),a?(0,$.jsx)(U,{onClick:a,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:l}):l}function cL({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(z,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(U,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}function lL(e){if(e&&Jy.includes(e))return jp[e]}H(),tb();function uL({teamsSelected:e,showHint:t}){let n=X(e=>e.teamContext),r=n?Object.values(n.teammates).filter(e=>e.name!==`team-lead`).length:0;if(r===0)return null;let i=t&&e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{dimColor:!0,children:`· `}),(0,$.jsx)(z,{dimColor:!0,children:`Enter to view`})]}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{color:`background`,inverse:e,children:`${r} ${r===1?`teammate`:`teammates`}`},e?`selected`:`normal`),i?(0,$.jsxs)(z,{children:[` `,i]}):null]})}H(),Bs();function dL({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(z,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Gd,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:A(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}xi(),ii(),Fr();var fL=5e3;function pL(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function mL(){if(!await $r())return null;let[e,t]=await Promise.all([ti(),Qr()]);if(e===t)return null;let{stdout:n,code:r}=await Si(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:fL,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Pr(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:pL(e.isDraft,e.reviewDecision)}}catch{return null}}Ke();var hL=6e4,gL=4e3,_L=60*6e4,vL={number:null,url:null,reviewState:null,lastUpdated:0};function yL(e,t=!0){let[n,r]=(0,Q.useState)(vL),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=Dt();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=_L)return;let l=Date.now(),u=await mL();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>gL){a.current=!0;return}e||(i.current=setTimeout(c,hL))}}let l=Date.now()-o.current;return l>=hL?c():i.current=setTimeout(c,hL-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}H(),m(),Hw(),fm(),sr(),mp(),Li(),uT(),Jt(),Rh(),S_(),Ke(),Fx(),va(),jM(),pM(),ap(),kg(),mn(),Oi(),Qf();var bL=(Lm(),e(om)),xL=(dx(),e(fx)),SL=e=>()=>{},CL=()=>null,wL=3,TL=5e3,EL=1e3;function DL(){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=ma(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,TL);return()=>clearInterval(n)},[]),e}function OL(){let e=(0,Q.useSyncExternalStore)(xL?.subscribeToProactiveChanges??SL,xL?.getNextTickAt??CL,CL),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){n(Math.max(0,Math.ceil((e-Date.now())/1e3)))}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(z,{dimColor:!0,children:[`waiting `,fa(t*1e3,{mostSignificantOnly:!0})]})}function kL(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),EL);return()=>clearInterval(e)},[]);let r=(ig(),e(Bp)),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)(z,{color:d,children:[`goal (`,u,`)`]})}function AL({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,teamsSelected:s,tmuxSelected:c,teammateFooterIndex:l,isPasting:u,isSearching:d,historyQuery:f,setHistoryQuery:p,historyFailedMatch:m,onOpenTasksDialog:h}){if(e.show)return(0,$.jsxs)(z,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(u)return(0,$.jsx)(z,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let g=zw()&&t===`INSERT`&&!d;return(0,$.jsxs)(U,{justifyContent:`flex-start`,gap:1,children:[d&&(0,$.jsx)(dL,{value:f,onChange:p,historyFailedMatch:m}),g?(0,$.jsx)(z,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(jL,{mode:n,toolPermissionContext:r,showHint:!i&&!g,isLoading:a,tasksSelected:o,teamsSelected:s,teammateFooterIndex:l,tmuxSelected:c,onOpenTasksDialog:h})]})}function jL({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,teamsSelected:o,tmuxSelected:s,teammateFooterIndex:c,onOpenTasksDialog:l}){let{columns:u}=ee(),d=gv(`chat:cycleMode`,`Chat`,`shift+tab`),f=Z(e=>e.tasks),p=Z(e=>e.teamContext),m=vf(),[g]=(0,Q.useState)(()=>m.getState().remoteSessionUrl),_=Z(e=>e.viewSelectionMode),v=Z(e=>e.viewingAgentTaskId),y=Z(e=>e.expandedView),b=y===`teammates`,x=yL(i,NL()),S=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),C=(0,Q.useSyncExternalStore)(xL?.subscribeToProactiveChanges??SL,xL?.getNextTickAt??CL,CL),w=dM(),T=Rp(e=>e.voiceState),E=Rp(e=>e.voiceWarmingUp),D=N(),O=I().getState,k=C!==null,A=bL?.isCoordinatorMode()===!0,j=(0,Q.useMemo)(()=>Ii(Object.values(f),e=>bh(e)&&!(process.env.USER_TYPE===`ant`&&av(e))),[f]),M=gg(),P=M!==void 0&&M.length>0,F=gv(`chat:cancel`,`Chat`,`esc`).toLowerCase(),te=gv(`app:toggleTodos`,`Global`,`ctrl+t`),L=gv(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),ne=gv(`voice:pushToTalk`,`Chat`,`Space`),[re]=(0,Q.useState)(()=>(W().voiceFooterHintSeenCount??0)<wL),ie=re,oe=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(!w||!ie||oe?.current)return;oe&&(oe.current=!0);let e=(W().voiceFooterHintSeenCount??0)+1;Dr(t=>(t.voiceFooterHintSeenCount??0)>=e?t:{...t,voiceFooterHintSeenCount:e})}},[w,ie]);let se=Z(e=>e.notifications.current?.key===`kill-agents-confirm`),ce=DL(),le=Gn()&&!gl()&&p!==void 0&&Ii(Object.values(p.teammates),e=>e.name!==`team-lead`)>0;if(t===`bash`)return(0,$.jsx)(z,{color:`bashBorder`,children:`! for bash mode`});let ue=n?.mode,de=!Qn(ue),fe=v?f[v]:void 0,pe=_===`viewing-agent`&&fe?.type===`in_process_teammate`,me=pe&&fe!=null&&fe.status!==`running`,he=j>0||pe,ge=(A||de?1:0)+ +!!he+ +!!le,_e=NL()&&x.number!==null&&x.reviewState!==null&&x.url!==null&&ge<2&&(ge===0||u>=80),ve=ge<2,ye=!b&&he&&Object.values(f).some(e=>e.type===`in_process_teammate`)||!b&&pe,be=ue&&de&&!tt()?(0,$.jsxs)(z,{color:An(ue),children:[Sr(ue),` `,kr(ue).toLowerCase(),` on`,ve&&(0,$.jsxs)(z,{dimColor:!0,children:[` `,(0,$.jsx)(B,{shortcut:d,action:`cycle`,parens:!0})]})]},`mode`):null,xe=[...g?[(0,$.jsx)(ae,{url:g,children:(0,$.jsxs)(z,{color:`ide`,children:[h.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&S?[(0,$.jsx)(TungstenPill,{selected:s},`tmux`)]:[],...Gn()&&le?[(0,$.jsx)(uL,{teamsSelected:o,showHint:r&&!he},`teams`)]:[],..._e?[(0,$.jsx)(Ym,{number:x.number,url:x.url,reviewState:x.reviewState},`pr-status`)]:[],...ce?[(0,$.jsxs)(z,{dimColor:ce.level===`normal`,color:ce.level===`error`?`error`:ce.level===`warning`?`warning`:void 0,children:[ce.text,` · pid:`,process.pid]},`rss`)]:[],...(ig(),e(Bp)).getGoal()?[(0,$.jsx)(kL,{},`goal-elapsed`)]:[]],Se=Object.values(f).some(e=>e.type===`in_process_teammate`&&e.status===`running`),Ce=Object.values(f).some(e=>e.type===`local_agent`&&e.status===`running`),we=r?ML(i,F,te,L,P,y,Se,Ce,se):[];if(me?xe.push((0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(B,{shortcut:F,action:`return to team lead`})},`esc-return`)):k?xe.push((0,$.jsx)(OL,{},`proactive`)):!ye&&r&&xe.push(...we),ye){let e=[...be?[be]:[],...xe,...me?[]:we];return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{children:(0,$.jsx)(oL,{tasksSelected:a,isViewingTeammate:pe,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l})}),e.length>0&&(0,$.jsx)(U,{children:(0,$.jsx)(V,{children:e})})]})}let Te=process.env.USER_TYPE===`ant`&&mF(f).length>0,H=he&&!ye&&!iT(f,b)?(0,$.jsx)(oL,{tasksSelected:a,isViewingTeammate:pe,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l}):null;xe.length===0&&!H&&!be&&r&&xe.push((0,$.jsx)(z,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let Ee=W().copyOnSelect??!0,De=D&&(!Ee||R());if(w&&E)xe.push((0,$.jsx)(TM,{},`voice-warmup`));else if(gh()&&De){let e=Di()===`macos`,t=e&&(O()?.lastPressHadAlt??!1);xe.push((0,$.jsx)(z,{dimColor:!0,children:(0,$.jsxs)(V,{children:[!Ee&&(0,$.jsx)(B,{shortcut:`ctrl+c`,action:`copy`}),R()&&(t?(0,$.jsx)(z,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(B,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}else xe.length>0&&r&&w&&T===`idle`&&we.length===0&&ie&&xe.push((0,$.jsxs)(z,{dimColor:!0,children:[`hold `,ne,` to speak`]},`voice-hint`));return(H||Te)&&r&&!le&&xe.push((0,$.jsx)(z,{dimColor:!0,children:a?(0,$.jsx)(B,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(B,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),xe.length===0&&!H&&!be?gh()?(0,$.jsx)(z,{children:` `}):null:(0,$.jsxs)(U,{height:1,overflow:`hidden`,children:[be&&(0,$.jsxs)(U,{flexShrink:0,children:[be,(H||xe.length>0)&&(0,$.jsx)(z,{dimColor:!0,children:` · `})]}),H&&(0,$.jsxs)(U,{flexShrink:0,children:[H,xe.length>0&&(0,$.jsx)(z,{dimColor:!0,children:` · `})]}),xe.length>0&&(0,$.jsx)(z,{wrap:`truncate`,children:(0,$.jsx)(V,{children:xe})})]})}function ML(e,t,n,r,i,a,o,s,c){let l;if(o)switch(a){case`none`:l=`show tasks`;break;case`tasks`:l=`show teammates`;break;case`teammates`:l=`hide`;break}else l=a===`tasks`?`hide tasks`:`show tasks`;let u=i||o;return[...e?[(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(B,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&s&&!c?[(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(B,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...u?[(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(B,{shortcut:n,action:l})},`toggle-tasks`)]:[]]}function NL(){return W().prStatusFooterEnabled??!0}Ts(),Ss(),Fx(),H(),_o(),tb(),kg(),lC(),Vw();function PL({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:_,teamsSelected:v,bridgeSelected:y,tmuxSelected:b,teammateFooterIndex:x,ideSelection:S,mcpClients:C,isPasting:w=!1,isInputWrapped:T=!1,messages:E,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j}){let M=dc(),{columns:N,rows:P}=ee(),F=(0,Q.useRef)(E);F.current=E;let te=(0,Q.useMemo)(()=>eL(E),[E]),I=N<80,L=gh(),ne=L&&P<24,re=gF(),ie=X(e=>e.coordinatorTaskIndex),ae=_&&(re===0||ie<0),oe=h||QI(M)||D;return yw((0,Q.useMemo)(()=>L&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[L,u,d,f])),u.length&&!L?(0,$.jsx)(U,{paddingX:2,paddingY:0,children:(0,$.jsx)(uC,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Uw,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:I?`column`:`row`,justifyContent:I?`flex-start`:`space-between`,paddingX:2,gap:+!I,children:[(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:+!I,children:[i===`prompt`&&!ne&&!n.show&&!w&&QI(M)&&(0,$.jsx)(nL,{messagesRef:F,lastAssistantMessageId:te,vimMode:r}),(0,$.jsx)(LL,{}),(0,$.jsx)(AL,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:oe,isLoading:g,tasksSelected:ae,teamsSelected:v,teammateFooterIndex:x,tmuxSelected:b,isPasting:w,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j})]}),(0,$.jsxs)(U,{flexShrink:1,gap:1,children:[L?null:(0,$.jsx)(PM,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:S,mcpClients:C,isInputWrapped:T,isNarrow:I}),process.env.USER_TYPE===`ant`&&OS()&&(0,$.jsx)(z,{dimColor:!0,children:`undercover`}),(0,$.jsx)(IL,{bridgeSelected:y})]})]}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(hF,{})]})}var FL=(0,Q.memo)(PL);function IL({bridgeSelected:e}){let t=X(e=>e.replBridgeEnabled),n=X(e=>e.replBridgeConnected),r=X(e=>e.replBridgeSessionActive),i=X(e=>e.replBridgeReconnecting),a=X(e=>e.replBridgeExplicit);if(!NS()||!t)return null;let o=tu({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(z,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(z,{dimColor:!0,children:` · Enter to view`})]})}function LL(){return null}m(),H(),Uu(),Jt();function RL(){if(!Gn())return;let e=Kc();if(e&&Jy.includes(e))return jp[e]}function zL({isLoading:e,themeColor:t}){let n=t,r=process.env.USER_TYPE===`ant`;return(0,$.jsxs)(z,{color:n??(r?`subtle`:void 0),dimColor:e,children:[h.pointer,`\xA0`]})}function BL({mode:e,isLoading:t,viewingAgentName:n,viewingAgentColor:r}){let i=RL(),a=r?jp[r]:void 0;return(0,$.jsx)(U,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:n?(0,$.jsx)(zL,{isLoading:t,themeColor:a}):e===`bash`?(0,$.jsx)(z,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(zL,{isLoading:t,themeColor:Gn()?i:void 0})})}Os(),lp();function VL(){return(0,Q.useSyncExternalStore)(Rv,H_)}H(),S_(),ci(),lp(),Lf(),Fr(),Dw();var HL=new Set;function UL(e){try{return Pr(e)?.type===`idle_notification`}catch{return!1}}var WL=3;function GL(e){return`<${si}>
80
+ <${di}>+${e} more tasks completed</${di}>
81
+ <${ui}>completed</${ui}>
82
+ </${si}>`}function KL(e){let t=e.filter(e=>typeof e.value!=`string`||!UL(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=WL)return[...r,...n];let i=n.slice(0,WL-1),a={value:GL(n.length-(WL-1)),mode:`task-notification`};return[...r,...i,a]}function qL(){let e=VL(),t=Z(e=>!!e.viewingAgentTaskId),n=Z(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(Yg);return t.length===0?null:vp(KL(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Ph({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(U,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(ru,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(Ow,{message:e,lookups:pp,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:HL,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var JL=Q.memo(qL);m(),H();function YL({hasStash:e}){return e?(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(z,{dimColor:!0,children:[h.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Ke(),K(),l(),Vr(),Hr(),Fr();function XL(e){return(e.match(/\r\n|\r|\n/g)||[]).length}var ZL=1e4,QL=1e3;function $L(e,t){if(e.length<=ZL)return{truncatedText:e,placeholderContent:``};let n=Math.floor(QL/2),r=Math.floor(QL/2),i=e.slice(0,n),a=e.slice(-r),o=e.slice(n,-r);return{truncatedText:i+eR(t,XL(o))+a,placeholderContent:o}}function eR(e,t){return`[...Truncated text #${e} +${t} lines...]`}function tR(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=$L(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function nR({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}=tR(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}qr(),mn(),Da(),xi(),ii(),vi();var rR=[/(?:^|\/)(?:package-lock\.json|yarn\.lock|bun\.lock|bun\.lockb|pnpm-lock\.yaml|Pipfile\.lock|poetry\.lock|Cargo\.lock|Gemfile\.lock|go\.sum|composer\.lock|uv\.lock)$/,/\.generated\./,/(?:^|\/)(?:dist|build|out|target|node_modules|\.next|__pycache__)\//,/\.(?:min\.js|min\.css|map|pyc|pyo)$/,/\.(?:json|ya?ml|toml|xml|ini|cfg|conf|env|lock|txt|md|mdx|rst|csv|log|svg)$/i,/(?:^|\/)\.?(?:eslintrc|prettierrc|babelrc|editorconfig|gitignore|gitattributes|dockerignore|npmrc)/,/(?:^|\/)(?:tsconfig|jsconfig|biome|vitest\.config|jest\.config|webpack\.config|vite\.config|rollup\.config)\.[a-z]+$/,/(?:^|\/)\.(?:github|vscode|idea|claude)\//,/(?:^|\/)(?:CHANGELOG|LICENSE|CONTRIBUTING|CODEOWNERS|README)(?:\.[a-z]+)?$/i];function iR(e){return!rR.some(t=>t.test(e))}function aR(e,t){let n=[],r=new Set,i=new Map;for(let a=1;n.length<t&&a<=t;a++)for(let o of e){if(n.length>=t)break;if(!iR(o))continue;let e=Math.max(o.lastIndexOf(`/`),o.lastIndexOf(`\\`)),s=e>=0?o.slice(e+1):o;if(!s||r.has(s))continue;let c=e>=0?o.slice(0,e):`.`;(i.get(c)??0)>=a||(n.push(s),r.add(s),i.set(c,(i.get(c)??0)+1))}return n.length>=t?n:[]}async function oR(){if(ka.platform===`win32`||!await $r())return[];try{let e=await On(),t=[`log`,`-n`,`1000`,`--pretty=format:`,`--name-only`,`--diff-filter=M`],n=new Map,r=e=>{for(let t of e.split(`
83
+ `)){let e=t.trim();e&&n.set(e,(n.get(e)??0)+1)}};if(e){let{stdout:n}=await bi(`git`,[...t,`--author=${e}`],{cwd:Jr()});r(n)}if(n.size<10){let{stdout:e}=await bi(Zr(),t,{cwd:Jr()});r(e)}return aR(Array.from(n.entries()).sort((e,t)=>t[1]-e[1]).map(([e])=>e),5)}catch(e){return yi(e),[]}}var sR=10080*60*1e3,cR=i(()=>{let e=_r(),t=e.exampleFiles?.length?Mr(e.exampleFiles):`<filepath>`;return`Try "${Mr([`fix lint errors`,`fix typecheck errors`,`how does ${t} work?`,`refactor ${t}`,`how do I log an error?`,`edit ${t} to...`,`write a test for ${t}`,`create a util logging.py that...`])}"`});i(async()=>{let e=_r();Date.now()-(e.exampleFilesGeneratedAt??0)>sR&&(e.exampleFiles=[]),e.exampleFiles?.length||oR().then(e=>{e.length&&xn(t=>({...t,exampleFiles:e,exampleFilesGeneratedAt:Date.now()}))})}),S_();var lR=(dx(),e(fx)),uR=3,dR=20;function fR({input:e,submitCount:t,viewingAgentName:n}){let r=Hj(),i=Z(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n)return`Message @${n.length>dR?n.slice(0,dR-3)+`...`:n}…`;if(r.some(Qo)&&(Rt().queuedCommandUpHintCount||0)<uR)return`Press up to edit queued messages`;if(t<1&&i&&!lR?.isProactiveActive())return cR()}},[e,r,t,i,n])}var pR=5e3,mR=!1;function hR(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(mR||!e)return;mR=!0,n(!0);let t=setTimeout(n,pR,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}Wi();function gR(e){if(!zi())return e.standaloneAgentContext?.name}tb(),Uu(),CS(),Rh(),_S(),Wi();function _R(){let e=X(e=>e.teamContext),t=X(e=>e.standaloneAgentContext),n=X(e=>e.agent);X(e=>e.viewingAgentTaskId);let r=Md(),[i,a]=Q.useState(null);Q.useEffect(()=>{SS().then(a)},[]);let o=r.getState();if(Hi()&&!Yi()){let t=Gi();if(t&&zi())return{text:`@${t}`,bgColor:vR(e?.selfAgentColor??Ki())}}if(e?.teamName&&e.teammates&&Object.keys(e.teammates).length>0){let e=fo(o),t=vR(e?.identity.color),n=gl(),r=es(),a=r?.isNative??!1,s=r?.backend.type;if(i===!1&&!n&&!a)return{text:s===`windows-terminal`?`View teammates in the Windows Terminal tabs spawned for each teammate`:`View teammates: \`tmux -L ${yS()} a\``,bgColor:t};if((i===!0||n||a)&&e)return{text:`@${e.identity.agentName}`,bgColor:t}}let s=Qh(o);if(s.type===`named_agent`){let e=s.task,t;for(let[n,r]of o.agentNameRegistry)if(r===e.id){t=n;break}return{text:t?`@${t}`:e.description,bgColor:Iy(e.agentType)??`cyan_FOR_SUBAGENTS_ONLY`}}let c=gR(o),l=t?.color;return c||l?{text:c??``,bgColor:vR(l)}:n?{text:n,bgColor:vR(o.agentDefinitions.activeAgents.find(e=>e.agentType===n)?.color,`promptBorder`)}:null}function vR(e,t=`cyan_FOR_SUBAGENTS_ONLY`){return e&&Jy.includes(e)?jp[e]:t}L(),Ah(),$i(),S_(),Yx(),ms(),fb(),_o(),Tw(),Xu(),SC(),Fx(),H(),Ag(),_h(),Px(),Uy(),zh(),mp(),U_(),Uu(),Jt(),Li(),tg(),mn(),K(),Da(),Vr(),kg(),pg(),vi(),Ht(),Oi(),yC(),Rh(),Sx(),Wi(),Ri(),kh(),Iv(),Bs(),uT(),Hw();var yR=5,bR=3;function xR({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:j,onAgentSubmit:M,isSearchingHistory:N,setIsSearchingHistory:P,onDismissSideQuestion:F,isSideQuestionVisible:te,helpOpen:I,setHelpOpen:L,hasSuppressedDialogs:ne,isLocalJSXCommandActive:ie=!1,insertTextRef:ae,voiceInterimRange:oe}){let se=xC(),ce=Id()||ie,[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)({show:!1}),[R,me]=(0,Q.useState)(f.length),ge=Q.useRef(f);f!==ge.current&&(me(f.length),ge.current=f);let _e=Q.useCallback(e=>{ge.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:R,insert:e=>{let t=R===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,R)+t+f.slice(R);ge.current=n,p(n),me(R+t.length)},setInputWithCursor:(e,t)=>{ge.current=e,p(e),me(t)}});let ve=vf(),B=nf(),ye=Z(e=>e.tasks),V=Z(e=>e.replBridgeConnected),be=Z(e=>e.replBridgeExplicit),xe=Z(e=>e.replBridgeReconnecting),Ce=V&&(be||xe),we=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Te=process.env.USER_TYPE===`ant`&&we,H=Z(e=>!1),Ee=Z(e=>e.teamContext),Oe=Hj(),ke=Z(e=>e.promptSuggestion),Ae=Z(e=>e.speculation),Me=Z(e=>e.speculationSessionTimeSavedMs),Ne=Z(e=>e.viewingAgentTaskId),Pe=Z(e=>e.viewSelectionMode),Fe=Z(e=>e.expandedView)===`teammates`,{companion:Ie,companionMuted:Le}=W(),Re=!!Ie&&!Le,ze=Z(e=>e.isBriefOnly)&&!Ne,Be=Z(e=>e.mainLoopModel),Ve=Z(e=>e.mainLoopModelForSession),He=Z(e=>e.thinkingEnabled),Ue=Z(e=>fr()?e.fastMode:!1),We=Z(e=>e.effortValue),Ge=fo(ve.getState()),Ke=Ge?.identity.agentName,qe=Ge?.identity.color&&Jy.includes(Ge.identity.color)?Ge.identity.color:void 0,Je=(0,Q.useMemo)(()=>Cu(ye),[ye]),Ye=Je.length>0||Ge!==void 0,Xe=(0,Q.useMemo)(()=>Ge?{...n,mode:Ge.permissionMode}:n,[Ge,n]),{historyQuery:Ze,setHistoryQuery:Qe,historyMatch:$e,historyFailedMatch:et}=KM(e=>{C(e.pastedContents),Rn(e.display)},f,_e,me,R,h,m,N,P,C,S),tt=(0,Q.useRef)(-1);tt.current===-1&&(tt.current=SR(l));let nt=(0,Q.useRef)(!1),[rt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),[st,ct]=(0,Q.useState)(0),lt=Z(e=>e.coordinatorTaskIndex),ut=Z(e=>e.selectedBgAgentIndex),dt=(0,Q.useCallback)(e=>B(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[B]),ft=(0,Q.useCallback)(e=>B(t=>{let n=typeof e==`function`?e(t.coordinatorTaskIndex):e;return n===t.coordinatorTaskIndex?t:{...t,coordinatorTaskIndex:n}}),[B]),pt=gF(),mt=(0,Q.useMemo)(()=>Object.values(ye).some(e=>bh(e)&&!(process.env.USER_TYPE===`ant`&&av(e))),[ye])?-1:0;(0,Q.useEffect)(()=>{lt>=pt?ft(Math.max(mt,pt-1)):lt<mt&&ft(mt)},[pt,lt,mt]);let[ht,gt]=(0,Q.useState)(!1),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(!1),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),[Tt,Et]=(0,Q.useState)(!1),[Dt,Ot]=(0,Q.useState)(!1),[kt,At]=(0,Q.useState)(!1),jt=(0,Q.useMemo)(()=>{let e=f.indexOf(`
84
+ `);return e===-1?!0:R<=e},[f,R]),Mt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
85
+ `);return e===-1?!0:R>e},[f,R]),Nt=(0,Q.useMemo)(()=>{if(!Gn()||gl()||!Ee)return[];let e=Ii(Object.values(Ee.teammates),e=>e.name!==`team-lead`);return[{name:Ee.teamName,memberCount:e,runningCount:0,idleCount:0}]},[Ee]),Pt=((0,Q.useMemo)(()=>Ii(Object.values(ye),e=>e.status===`running`),[ye])>0||process.env.USER_TYPE===`ant`&&pt>0)&&!iT(ye,Fe),Ft=Nt.length>0,It=HM(),Lt=It.length>0,Rt=(0,Q.useMemo)(()=>[Lt&&`bg_agent`,Pt&&`tasks`,Te&&`tmux`,H&&`bagel`,Ft&&`teams`,Ce&&`bridge`,Re&&`companion`].filter(Boolean),[Lt,Pt,Te,H,Ft,Ce,Re]),zt=Z(e=>e.footerSelection),Bt=zt&&Rt.includes(zt)?zt:null;(0,Q.useEffect)(()=>{zt&&!Bt&&B(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[zt,Bt,B]);let Vt=Bt===`tasks`,Ht=Bt===`tmux`,Ut=Bt===`teams`,Wt=Bt===`bridge`,Gt=Bt===`bg_agent`;function Kt(e){B(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`tasks`&&(ct(0),ft(mt)),e===`bg_agent`&&dt(-1)}function qt(e,t=!1){let n=Rt[(Bt?Rt.indexOf(Bt):-1)+e];return n?(Kt(n),!0):e<0&&t?(Kt(null),!0):!1}let{suggestion:Jt,markAccepted:Yt,logOutcomeAtSubmission:Xt,markShown:Zt}=JM({inputValue:f,isAssistantResponding:s}),$t=(0,Q.useMemo)(()=>N&&$e?GM(typeof $e==`string`?$e:$e.display):f,[N,$e,f]),en=(0,Q.useMemo)(()=>d_($t),[$t]),tn=Z(e=>e.ultraplanSessionUrl),nn=Z(e=>e.ultraplanLaunching),rn=(0,Q.useMemo)(()=>!tn&&!nn?AT($t):[],[$t,tn,nn]),an=(0,Q.useMemo)(()=>Su()?OT($t):[],[$t]),on=(0,Q.useMemo)(()=>AC($t),[$t]),sn=(0,Q.useMemo)(()=>yu($t),[$t]),cn=(0,Q.useMemo)(()=>SN($t).filter(e=>Fu($t.slice(e.start+1,e.end),a)),[$t,a]),ln=(0,Q.useMemo)(()=>Ou($t),[$t]),dn=(0,Q.useMemo)(()=>HN(ve.getState().mcp.clients)?WN($t):[],[$t,(0,Q.useSyncExternalStore)(PN,UN)]),fn=(0,Q.useMemo)(()=>{if(!Gn()||!Ee?.teammates)return[];let e=[],t=Ee.teammates;if(!t)return e;let n=/(^|\s)@([\w-]+)/g,r=Object.values(t),i;for(;(i=n.exec($t))!==null;){let t=i[1]??``,n=i.index+t.length,a=i[0].trimStart(),o=i[2],s=r.find(e=>e.name===o);if(s?.color){let t=jp[s.color];t&&e.push({start:n,end:n+a.length,themeColor:t})}}return e},[$t,Ee]),mn=(0,Q.useMemo)(()=>Ho($t).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[$t]),hn=mn.some(e=>e.start===R);(0,Q.useEffect)(()=>{let e=mn.find(e=>R>e.start&&R<e.end);e&&me(R<(e.start+e.end)/2?e.start:e.end)},[R,mn,me]);let gn=(0,Q.useMemo)(()=>{let e=[];for(let t of mn)R===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});N&&$e&&!et&&e.push({start:R,end:R+Ze.length,color:`warning`,priority:20});for(let t of on)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of cn)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of ln)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of dn)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of fn)e.push({start:t.start,end:t.end,color:t.themeColor,priority:5});if(oe&&e.push({start:oe.start,end:oe.end,color:void 0,dimColor:!0,priority:1}),Gm())for(let t of en)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mg(n-t.start),shimmerColor:mg(n-t.start,!0),priority:10});for(let t of rn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mg(n-t.start),shimmerColor:mg(n-t.start,!0),priority:10});for(let t of an)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mg(n-t.start),shimmerColor:mg(n-t.start,!0),priority:10});for(let t of sn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mg(n-t.start),shimmerColor:mg(n-t.start,!0),priority:10});return e},[N,Ze,$e,et,R,on,mn,fn,cn,ln,dn,$t,oe,en,rn,an,sn]),{addNotification:_n,removeNotification:vn}=ul();(0,Q.useEffect)(()=>{en.length&&Gm()?_n({key:`ultrathink-active`,text:`Effort set to high for this turn`,priority:`immediate`,timeoutMs:5e3}):vn(`ultrathink-active`)},[_n,vn,en.length]),(0,Q.useEffect)(()=>{rn.length?_n({key:`ultraplan-active`,text:`This prompt will launch an ultraplan session in Claude Code on the web`,priority:`immediate`,timeoutMs:5e3}):vn(`ultraplan-active`)},[_n,vn,rn.length]),(0,Q.useEffect)(()=>{Su()&&an.length&&_n({key:`ultrareview-active`,text:`Run /ultrareview after Claude finishes to review these changes in the cloud`,priority:`immediate`,timeoutMs:5e3})},[_n,an.length]);let yn=(0,Q.useRef)(f.length),bn=(0,Q.useRef)(f.length),xn=(0,Q.useCallback)(()=>{vn(`stash-hint`)},[vn]);(0,Q.useEffect)(()=>{let e=yn.current,t=bn.current,n=f.length;if(yn.current=n,n>t){bn.current=n;return}if(n===0){bn.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(W().hasUsedStash||_n({key:`stash-hint`,jsx:(0,$.jsxs)(z,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(eg,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:NM}),bn.current=n)},[f.length,_n]);let{pushToBuffer:Sn,undo:Cn,canUndo:wn,clearBuffer:Tn}=qM({maxBufferSize:50,debounceMs:1e3});nR({input:f,pastedContents:S,onInputChange:_e,setCursorOffset:me,setPastedContents:C});let En=fR({input:f,submitCount:v,viewingAgentName:Ke}),Dn=(0,Q.useCallback)(e=>{if(e===`?`){J(`tengu_help_toggled`,{}),L(e=>!e);return}L(!1),xn(),Zl(),Kf(B);let t=e.length===f.length+1,n=R===0,r=WM(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=GM(e).replaceAll(` `,` `);Sn(f,R,S),_e(t),me(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Sn(f,R,S),B(e=>e.footerSelection===null?e:{...e,footerSelection:null}),_e(i)},[_e,h,f,R,Sn,S,xn,B]),{resetHistory:On,onHistoryUp:kn,onHistoryDown:An,dismissSearchHint:jn,historyIndex:Mn}=VM((e,t,n)=>{Dn(e),h(t),C(n)},f,S,me,m);(0,Q.useEffect)(()=>{N&&jn()},[N,jn]);function Nn(){if(!(Bn.length>1)&&jt){if(Oe.some(Qo)){Qn();return}kn()}}function Pn(){if(!(Bn.length>1)&&Mt&&An()&&Rt.length>0){let e=Rt[0];Kt(e),e===`tasks`&&!W().hasSeenTasksHint&&Dr(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[Fn,In]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Ln=(0,Q.useCallback)(e=>{In(t=>typeof e==`function`?e(t):e)},[]),Rn=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=ve.getState();if(n.footerSelection&&Rt.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=ke.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(Ae.status===`active`){Yt(),Xt(i,{skipReset:!0}),j(i,{setCursorOffset:me,clearBuffer:Tn,resetHistory:On},{state:Ae,speculationSessionTimeSavedMs:Me,setAppState:B});return}ke.shownAt>0&&(Yt(),e=i)}if(Gn()){let t=oF(e);if(t){let e=await sF(t.recipientName,t.message,Ee,my);if(e.success){_n({key:`direct-message-sent`,text:`Sent to @${e.recipientName}`,priority:`immediate`,timeoutMs:3e3}),_e(``),me(0),Tn(),On();return}else !e.success&&e.error}}if(e.trim()===``&&!r)return;let a=Fn.suggestions.length>0&&Fn.suggestions.every(e=>e.description===`directory`);if(Fn.suggestions.length>0&&!t&&!a){q(`[onSubmit] early return: suggestions showing (count=${Fn.suggestions.length})`);return}ke.text&&ke.shownAt>0&&Xt(e),vn(`stash-hint`);let o=Qh(ve.getState());if(o.type!==`leader`&&M){J(`tengu_transcript_input_to_teammate`,{}),await M(e,o.task,{setCursorOffset:me,clearBuffer:Tn,resetHistory:On});return}await j(e,{setCursorOffset:me,clearBuffer:Tn,resetHistory:On})},[ke,Ae,Me,Ee,ve,Rt,Fn.suggestions,j,M,Tn,On,Xt,B,Yt,S,vn]),{suggestions:Bn,selectedSuggestion:Vn,commandArgumentHint:Hn,inlineGhostText:Un,maxColumnWidth:Wn}=$P({commands:a,onInputChange:_e,onSubmit:Rn,setCursorOffset:me,input:f,cursorOffset:R,mode:m,agents:o,setSuggestionsState:Ln,suggestionsState:Fn,suppressSuggestions:N||Mn>0,markAccepted:Yt,onModeChange:h}),Kn=m===`prompt`&&Bn.length===0&&Jt&&!Ne;Kn&&Zt(),ke.text&&!Jt&&ke.shownAt===0&&!Ne&&(uc(`timing`,ke.text),B(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function qn(e,t,n,r,i){J(`tengu_paste_image`,{}),h(`prompt`);let a=tt.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};Xp(o),th(o),C(e=>({...e,[a]:o})),Xn((nt.current?` `:``)+Ny(a)),nt.current=!0}(0,Q.useEffect)(()=>{let e=new Set(Ho(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 Jn(e){nt.current=!1;let t=le(e).replace(/\r/g,`
86
+ `).replaceAll(` `,` `);if(f.length===0){let e=WM(t);e!==`prompt`&&(h(e),t=GM(t))}let n=_y(t),r=Math.min(_r-10,2);if(t.length>800||n>r){let e=tt.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),Xn(Bu(e,n))}else Xn(t)}let Yn=(0,Q.useCallback)((e,t)=>nt.current?(nt.current=!1,Bw(e,t)?` `+e:e):e,[]);function Xn(e){Sn(f,R,S),_e(f.slice(0,R)+e+f.slice(R)),me(R+e.length)}let Zn=re(()=>{},()=>y()),Qn=(0,Q.useCallback)(()=>{let e=Zh(f,R);return e?(_e(e.text),h(`prompt`),me(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},[_e,h,f,R,C]);Gj(x,function(e){J(`tengu_ext_at_mentioned`,{});let t,n=GT.relative(Xx(),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[R-1]??` `;/\s/.test(r)||(t=` ${t}`),Xn(t)});let er=(0,Q.useCallback)(()=>{if(wn){let e=Cn();e&&(_e(e.text),me(e.cursorOffset),C(e.pastedContents))}},[wn,Cn,_e,C]),tr=(0,Q.useCallback)(()=>{Sn(f,R,S),_e(f.slice(0,R)+`
87
+ `+f.slice(R)),me(R+1)},[f,R,_e,me,Sn,S]),nr=(0,Q.useCallback)(async()=>{J(`tengu_external_editor_used`,{}),vt(!0);try{let e=await _C(f,S);e.error&&_n({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Sn(f,R,S),_e(e.content),me(e.content.length))}catch(e){e instanceof Error&&yi(e),_n({key:`external-editor-error`,text:`External editor failed: ${Kr(e)}`,color:`warning`,priority:`high`})}finally{vt(!1)}},[f,R,S,Sn,_e,_n]),rr=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(_e(g.text),me(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:R,pastedContents:S}),_e(``),me(0),C({}),Dr(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,R,g,_e,_,S,C]),ir=(0,Q.useCallback)(()=>{bt(e=>!e),I&&L(!1)},[I]),ar=(0,Q.useCallback)(()=>{Ot(e=>!e),I&&L(!1)},[I]),or=(0,Q.useCallback)(()=>{At(e=>!e),I&&L(!1)},[I]),sr=(0,Q.useCallback)(()=>{if(Gn()&&Ge&&Ne){let e=uF({...n,mode:Ge.permissionMode},void 0);J(`tengu_mode_cycle`,{to:e});let t=Ne;B(n=>{let r=n.tasks[t];return!r||r.type!==`in_process_teammate`||r.permissionMode===e?n:{...n,tasks:{...n.tasks,[t]:{...r,permissionMode:e}}}}),I&&L(!1);return}q(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=uF(n,Ee),{context:t}=dF(n,Ee);J(`tengu_mode_cycle`,{to:e}),e===`plan`&&Dr(e=>({...e,lastPlanModeUse:Date.now()})),B(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),wx(e,Ee?.teamName),I&&L(!1)},[n,Ee,Ge,B,r,I]),cr=(0,Q.useCallback)(()=>{qf().then(e=>{if(e)qn(e.base64,e.mediaType);else{let e=z_(`chat:imagePaste`,`Chat`,`ctrl+v`);_n({key:`no-image-in-clipboard`,text:ka.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`,priority:`immediate`,timeoutMs:1e3})}})},[_n,qn]),lr=he();(0,Q.useEffect)(()=>{if(!(!lr||ce))return lr.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Rn(f)}})},[lr,ce,Rn,f]),Se((0,Q.useMemo)(()=>({"chat:undo":er,"chat:newline":tr,"chat:externalEditor":nr,"chat:stash":rr,"chat:modelPicker":ir,"chat:thinkingToggle":or,"chat:cycleMode":sr,"chat:imagePaste":cr}),[er,tr,nr,rr,ir,or,sr,cr]),{context:`Chat`,isActive:!ce}),De(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!ce&&!N}),De(`chat:fastMode`,ar,{context:`Chat`,isActive:!ce&&fr()&&yr()}),De(`help:dismiss`,()=>{L(!1)},{context:`Help`,isActive:I}),De(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),De(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),De(`history:search`,()=>{},{context:`Global`,isActive:!1}),De(`app:interrupt`,()=>{Kf(B)},{context:`Global`,isActive:!s&&Ae.status===`active`}),Se({"footer:up":()=>{if(Gt){ut>-1?dt(e=>e-1):Kt(null);return}if(Vt&&process.env.USER_TYPE===`ant`&&pt>0&&lt>mt){ft(e=>e-1);return}qt(-1,!0)},"footer:down":()=>{if(Gt){ut<It.length-1&&dt(e=>e+1);return}if(Vt&&process.env.USER_TYPE===`ant`&&pt>0){lt<pt-1&&ft(e=>e+1);return}if(Vt&&!Ye){D(!0),Kt(null);return}qt(1)},"footer:next":()=>{if(Vt&&Ye){let e=1+Je.length;ct(t=>(t+1)%e);return}qt(1)},"footer:previous":()=>{if(Vt&&Ye){let e=1+Je.length;ct(t=>(t-1+e)%e);return}qt(-1)},"footer:openSelected":()=>{if(Pe!==`selecting-agent`)switch(Bt){case`companion`:Kt(null),Rn(`/buddy`);break;case`tasks`:if(Ye)if(st===0)iF(B);else{let e=Je[st-1];e&&rF(e.id,B)}else if(lt===0&&pt>0)iF(B);else{let e=mF(ye)[lt-1]?.id;e?rF(e,B):(D(!0),Kt(null))}break;case`tmux`:process.env.USER_TYPE===`ant`&&B(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`teams`:it(!0),Kt(null);break;case`bridge`:ot(!0),Kt(null);break;case`bg_agent`:if(ut===-1)iF(B);else{let e=It[ut];e&&rF(e.agentId,B)}break}},"footer:clearSelection":()=>{Kt(null)},"footer:close":()=>{if(Vt&&lt>=1){let e=mF(ye)[lt-1];if(!e)return!1;if(Pe===`viewing-agent`&&e.id===Ne){Dn(f.slice(0,R)+`x`+f.slice(R)),me(R+1);return}aF(e.id,B),e.status!==`running`&&ft(e=>Math.max(mt,e-1));return}return!1}},{context:`Footer`,isActive:!!Bt&&!ce}),je((e,t)=>{if(!(rt||xt||Ct||Tt)){if(Di()===`macos`&&lF(e)){let t=cF[e],n=dS();_n({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(z,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(z,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(z,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(Bt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Dn(f.slice(0,R)+e+f.slice(R)),me(R+e.length);return}if(R===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),L(!1)),I&&f===``&&(t.backspace||t.delete)&&L(!1),t.escape){if(Ae.status===`active`){Kf(B);return}if(te&&F){F();return}if(I){L(!1);return}if(Bt)return;if(Oe.some(Qo)){Qn();return}l.length>0&&!f&&!s&&Zn()}t.return&&I&&L(!1)}});let ur=_R(),dr=fr()?$n():!1,pr=fr()?Ue&&(yr()||dr):!1,G=hR(pr??!1),mr=ze?void 0:tw(We,se);(0,Q.useEffect)(()=>{if(!mr){vn(`effort-level`);return}_n({key:`effort-level`,text:mr,priority:`high`,timeoutMs:12e3})},[mr,_n,vn]),Em();let hr=Z(e=>e.companionReaction)!==void 0,{columns:gr,rows:_r}=ee(),vr=gr-3-sM(gr,hr),br=gh()?Math.max(bR,Math.floor(_r/2)-yR):void 0,xr=(0,Q.useCallback)(e=>{if(!f||N)return;let t=tv.fromText(f,vr,R),n=t.getViewportStartLine(br);me(t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol}))},[f,vr,N,R,br]),Sr=(0,Q.useCallback)(e=>D(e??!0),[D]),Cr=Kn&&Jt?Jt:En,wr=(0,Q.useMemo)(()=>f.includes(`
88
+ `),[f]),Tr=(0,Q.useCallback)((e,t)=>{let n=!1;B(t=>(n=fr()&&!zn(e)&&!!t.fastMode,{...t,mainLoopModel:e,mainLoopModelForSession:null,...n&&{fastMode:!1}})),bt(!1);let r=(Ue??!1)&&!n,i=`Model set to ${Qt(e)}`;ew(e,r,pn())&&(i+=` · Billed as extra usage`),n&&(i+=` · Fast mode OFF`),_n({key:`model-switched`,jsx:(0,$.jsx)(z,{children:i}),priority:`immediate`,timeoutMs:3e3}),J(`tengu_model_picker_hotkey`,{model:e})},[B,_n,Ue]),Er=(0,Q.useCallback)(()=>{bt(!1)},[]),Or=(0,Q.useMemo)(()=>yt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(nw,{initial:Be,sessionModel:Ve,onSelect:Tr,onCancel:Er,isStandaloneCommand:!0,showFastModeNotice:fr()&&Ue&&zn(Be)&&yr()})}):null,[yt,Be,Ve,Tr,Er]),kr=(0,Q.useCallback)(e=>{Ot(!1),e&&_n({key:`fast-mode-toggled`,jsx:(0,$.jsx)(z,{children:e}),priority:`immediate`,timeoutMs:3e3})},[_n]),Ar=(0,Q.useMemo)(()=>Dt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Pw,{onDone:kr,unavailableReason:un()})}):null,[Dt,kr]),jr=(0,Q.useCallback)(e=>{B(t=>({...t,thinkingEnabled:e})),At(!1),J(`tengu_thinking_toggled_hotkey`,{enabled:e}),_n({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(z,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[B,_n]),Mr=(0,Q.useCallback)(()=>{At(!1)},[]),Nr=(0,Q.useMemo)(()=>kt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(yF,{currentValue:He??!0,onSelect:jr,onCancel:Mr,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[kt,He,jr,Mr,l.length]);if(xw(null),E)return(0,$.jsx)(fT,{onDone:()=>D(!1),toolUseContext:k(l,[],new AbortController,se),initialDetailTaskId:typeof E==`string`?E:void 0});if(Gn()&&rt)return(0,$.jsx)(bF,{initialTeams:Nt,onDone:()=>{it(!1)}});if(Or)return Or;if(Ar)return Ar;if(Nr)return Nr;if(at)return(0,$.jsx)(pF,{onDone:()=>{ot(!1),Kt(null)}});let Pr={multiline:!0,onSubmit:Rn,onChange:Dn,value:$e?GM(typeof $e==`string`?$e:$e.display):f,onHistoryUp:Nn,onHistoryDown:Pn,onHistoryReset:On,placeholder:Cr,onExit:O,onExitMessage:(e,t)=>pe({show:e,key:t}),onImagePaste:qn,columns:vr,maxVisibleLines:br,disableCursorMovementForUpDownKeys:Bn.length>0||!!Bt,disableEscapeDoublePress:Bn.length>0,cursorOffset:R,onChangeCursorOffset:me,onPaste:Jn,onIsPastingChange:gt,focus:!N&&!ce&&!Bt,showCursor:!Bt&&!N&&!hn,argumentHint:Hn,onUndo:wn?()=>{let e=Cn();e&&(_e(e.text),me(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:gn,inlineGhostText:Un,inputFilter:Yn},Fr=()=>{let e={bash:`bashBorder`};if(e[m])return e[m];if(Yi())return`promptBorder`;let t=Ki();return t&&Jy.includes(t)?jp[t]:`promptBorder`};if(_t)return(0,$.jsx)(U,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Fr(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Ir=zw()?(0,$.jsx)(AI,{...Pr,initialMode:w,onModeChange:T}):(0,$.jsx)(Gd,{...Pr});return(0,$.jsxs)(U,{flexDirection:`column`,marginTop:+!ze,children:[!gh()&&(0,$.jsx)(JL,{}),ne&&(0,$.jsx)(U,{marginTop:1,marginLeft:2,children:(0,$.jsx)(z,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(YL,{hasStash:g!==void 0}),ur?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{color:ur.bgColor,children:ur.text?(0,$.jsxs)($.Fragment,{children:[`─`.repeat(Math.max(0,gr-A(ur.text)-4)),(0,$.jsxs)(z,{backgroundColor:ur.bgColor,color:`inverseText`,children:[` `,ur.text,` `]}),`──`]}):`─`.repeat(gr)}),(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,children:[(0,$.jsx)(BL,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:xr,children:Ir})]}),(0,$.jsx)(z,{color:ur.bgColor,children:`─`.repeat(gr)})]}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Fr(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:CR(pr??!1,G,dr),children:[(0,$.jsx)(BL,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:xr,children:Ir})]}),(0,$.jsx)(FL,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:zw()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:ue,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:de,suggestions:Bn,selectedSuggestion:Vn,maxColumnWidth:Wn,toolPermissionContext:Xe,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:Vt,teamsSelected:Ut,bridgeSelected:Wt,tmuxSelected:Ht,teammateFooterIndex:st,ideSelection:t,mcpClients:x,isPasting:ht,isInputWrapped:wr,messages:l,isSearching:N,historyQuery:Ze,setHistoryQuery:Qe,historyFailedMatch:et,onOpenTasksDialog:gh()?Sr:void 0}),gh()?(0,$.jsx)(U,{position:`absolute`,marginTop:ze?-2:-1,height:+(Bn.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(PM,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:ue,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:de,ideSelection:t,mcpClients:x,isInputWrapped:wr})}):null]})}function SR(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=Ho(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function CR(e,t,n){if(e)return{content:` ${t?`${Mw(!0,n)} ${P.dim(`/fast`)}`:Mw(!0,n)} `,position:`top`,align:`end`,offset:0}}var wR=Q.memo(xR);Fr();function TR(e,t){return{type:`assistant`,uuid:oE(),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 ER(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:zr(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}K(),LS(),Lf();function DR(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function OR(e){return{type:`stream_event`,event:e.event}}function kR(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 AR(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function jR(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 MR(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 NR(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:RS(e.compact_metadata)}}function PR(e,t){switch(e.type){case`assistant`:return{type:`message`,message:DR(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:Ph({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:OR(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:kR(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:AR(t)};if(t.subtype===`status`){let t=jR(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:NR(e)}:(q(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:MR(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 FR(e){return e.type===`result`}tb(),Ia(),K(),va(),Lf();var IR=6e4,LR=18e4;function RR({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Zs(),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 VS(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 ET(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(FR(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=PR(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?Tc(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=jf(y.current,e.tool_name)??ER(e.tool_name),o=TR(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:nu(r,` `);n&&zS(n,new AbortController().signal).then(e=>{eS(t,e??ga(n,75))})}if(!e?.viewerOnly){let e=h.current?LR:IR;m.current=setTimeout((e,t)=>{q(`[useRemoteSession] Response timeout - attempting reconnect`);let n=Ul(`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])}K(),Fr(),f();function zR(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var BR=class{constructor(e,t){p(this,`ws`,null),p(this,`config`,void 0),p(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(`
89
+ `).filter(e=>e.trim());for(let e of t){let t;try{t=Pr(e)}catch{continue}if(!zR(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=zr({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=zr({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=zr({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=zr({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}};Ia(),K();function VR({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 BR(e,{onMessage:e=>{if(FR(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=PR(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=jf(l.current,e.tool_name)??ER(e.tool_name),o=TR(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(`
90
+ Server disconnected.
91
+ `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,oh(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])}Ia(),K(),$f();function HR({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(FR(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=PR(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{q(`[useSSHSession] permission request: ${e.tool_name}`);let a=jf(l.current,e.tool_name)??ER(e.tool_name),o=TR(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:oE(),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}`),oh(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])}K(),nS();async function UR(e){let{accessToken:t,orgUUID:n}=await tS();return{baseUrl:`${Sa().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...$x(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function WR(e,t,n){let r=await _.get(e.baseUrl,{headers:e.headers,params:t,timeout:15e3,validateStatus:()=>!0}).catch(()=>null);return!r||r.status!==200?(q(`[${n}] HTTP ${r?.status??`error`}`),null):{events:Array.isArray(r.data.data)?r.data.data:[],firstId:r.data.first_id,hasMore:r.data.has_more}}async function GR(e,t=100){return WR(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function KR(e,t,n=100){return WR(e,{limit:n,before_id:t},`fetchOlderEvents`)}K();var qR=40,JR=10,YR=`loading older messages…`,XR=`failed to load older messages — scroll up to retry`,ZR=`start of session`;function QR(e){let t=[];for(let n of e.events){let e=PR(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function $R({config:e,setMessages:t,scrollRef:n,onPrepend:r}){let i=e?.viewerOnly===!0,a=(0,Q.useRef)(void 0),o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useRef)(oE());function d(e){return{type:`system`,subtype:`informational`,content:e,isMeta:!1,timestamp:new Date().toISOString(),uuid:u.current,level:`info`}}let f=(0,Q.useCallback)((e,r)=>{let i=QR(e);if(a.current=e.hasMore?e.firstId:null,!r){let e=n.current;c.current=e?{beforeHeight:e.getFreshScrollHeight(),count:i.length}:null}let o=e.hasMore?null:d(ZR);t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return o?[o,...i,...t]:[...i,...t]}),q(`[useAssistantHistory] ${r?`initial`:`older`} page: ${i.length} msgs (raw ${e.events.length}), hasMore=${e.hasMore}`)},[t]);(0,Q.useEffect)(()=>{if(!i||!e)return;let t=!1;return(async()=>{let n=await UR(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await GR(n);t||!r||(l.current=JR,f(r,!0))})(),()=>{t=!0}},[i]);let p=(0,Q.useCallback)(async()=>{if(!i||s.current)return;let e=a.current,n=o.current;if(!(!e||!n)){s.current=!0,t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(YR),...t]});try{let r=await KR(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(XR),...t]});return}f(r,!1)}finally{s.current=!1}}},[i,f,t]);return(0,Q.useLayoutEffect)(()=>{let e=c.current;if(e===null)return;c.current=null;let t=n.current;if(!t||t.isSticky())return;let i=t.getFreshScrollHeight()-e.beforeHeight;i>0&&t.scrollBy(i),r?.(e.count,i)}),(0,Q.useEffect)(()=>{if(l.current<=0||!a.current||s.current)return;let e=n.current;if(!e)return;let t=e.getFreshScrollHeight(),r=e.getViewportHeight();q(`[useAssistantHistory] fill-check: content=${t} viewport=${r} budget=${l.current}`),t<=r?(l.current--,p()):l.current=0}),{maybeLoadOlder:(0,Q.useCallback)(e=>{e.getScrollTop()<qR&&p()},[p])}}Zi();var ez=400;function tz({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=ez}){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=na(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])}H();var nz=[`0`,`1`,`2`,`3`],rz={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},iz=e=>nz.includes(e),az=`How is Claude doing this session? (optional)`;function oz({onSelect:e,inputValue:t,setInputValue:n,message:r=az}){return tz({inputValue:t,setInputValue:n,isValidDigit:iz,onDigit:t=>e(rz[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(z,{bold:!0,children:r})]}),(0,$.jsxs)(U,{marginLeft:2,children:[(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Cr(),H(),Zi();function sz({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!iz(i)?null:(0,$.jsx)(uz,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var cz=[`0`,`1`];function lz(e){return cz.includes(e)}function uz({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=na(r.slice(-1));lz(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsxs)(z,{color:`ansi:cyan`,children:[wr,` `]}),(0,$.jsxs)(z,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(U,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(z,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(U,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(U,{width:12,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(U,{width:14,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}aa(),tb(),Lf();function dz(e){let t=X(e=>e.skillImprovement.suggestion),n=Zs(),[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,Y(`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`;Y(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&PT(r.skillName,r.updates).then(()=>{e(e=>[...e,Ul(`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 fz(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}jb(),qs(),am(),im(),Pg();function pz(e){(0,Q.useEffect)(()=>{let t=()=>{bn()&&process.stdout.write(`
92
+ `+_m()+`
93
+ `),yh(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}l();function mz(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&u(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function hz(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])}Ke(),tf(),ir();function gz(){let[e,t]=(0,Q.useState)(()=>{if(!Hn()||vr())return`valid`;let{key:e,source:t}=$t({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Hn()||vr()){t(`valid`);return}await Ar($e());let{key:e,source:n}=$t();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{t(await Dm(e,!1)?`valid`:`invalid`);return}catch(e){r(e),t(`error`);return}},[]),error:n}}Ke(),H(),qr(),K(),H(),Px(),Zn(),aa(),tb(),Li();function _z({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=X(e=>e.expandedView),d=Zs(),f=(0,Q.useCallback)(()=>{Y(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(t=>{let{getAllInProcessTeammateTasks:n}=(Xa(),e(Df));if(Ii(n(t.tasks),e=>e.status===`running`)>0)switch(t.expandedView){case`none`:return{...t,expandedView:`tasks`};case`tasks`:return{...t,expandedView:`teammates`};case`teammates`:return{...t,expandedView:`none`}}return{...t,expandedView:t.expandedView===`tasks`?`none`:`tasks`}})},[u,d]),p=X(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(qo(),e(ls));if(!n()&&p&&t!==`transcript`){d(e=>e.isBriefOnly?{...e,isBriefOnly:!1}:e);return}}let c=t!==`transcript`;Y(`tengu_toggle_transcript`,{is_entering:c,show_all:r,message_count:a}),n(e=>e===`transcript`?`prompt`:`transcript`),i(!1),c&&o&&o(),!c&&s&&s()},[t,n,p,r,i,a,d,o,s]),h=(0,Q.useCallback)(()=>{Y(`tengu_transcript_toggle_show_all`,{is_expanding:!r,message_count:a}),i(e=>!e)},[r,i,a]),g=(0,Q.useCallback)(()=>{Y(`tengu_transcript_exit`,{show_all:r,message_count:a}),n(`prompt`),i(!1),s&&s()},[n,r,i,a,s]),_=(0,Q.useCallback)(()=>{{let{isBriefEnabled:t}=(qo(),e(ls));if(!t()&&!p)return;let n=!p;Y(`tengu_brief_mode_toggled`,{enabled:n,gated:!1,source:`keybinding`}),d(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n})}},[p,d]);De(`app:toggleTodos`,f,{context:`Global`}),De(`app:toggleTranscript`,m,{context:`Global`}),De(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),De(`app:toggleTeammatePreview`,()=>{d(e=>({...e,showTeammateMessagePreview:!e.showTeammateMessagePreview}))},{context:`Global`}),De(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),De(`app:redraw`,(0,Q.useCallback)(()=>{ne.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return De(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),De(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}_o(),Ag(),Px();var vz={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function yz({onSubmit:e,isActive:t=!0}){let n=he(),r=Id(),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 Se((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,vz,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}$i(),S_(),Hw(),Fs(),_o(),_h(),Px(),mp(),lp();var bz=3e3;function xz(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=vf(),g=nf(),_=VL().length,{addNotification:v,removeNotification:y}=Ic(),b=(0,Q.useRef)(0),x=Z(e=>e.viewSelectionMode),S=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){J(`tengu_cancel`,e),t(()=>[]),n();return}if(vh()&&s){s();return}J(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),C=tc(),w=o!==void 0&&!o.aborted,T=_>0,E=f!==void 0&&f!==`prompt`&&!p,D=x===`viewing-agent`,O=a!==`transcript`&&!u&&!i&&!l&&!d&&!C&&!(zw()&&c===`INSERT`),k=O&&(w||T)&&!E&&!D,A=O&&(w||T||D);De(`chat:cancel`,S,{context:`Chat`,isActive:k});let j=(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;Up(e,g);let n=[];for(let[e,r]of t)ag(e,g),n.push(r.description),ax(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return hm({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 De(`app:interrupt`,(0,Q.useCallback)(()=>{D&&(j(),iF(g)),(w||T)&&S()},[D,j,g,w,T,S]),{context:`Global`,isActive:A}),De(`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<=bz){b.current=0,y(`kill-agents-confirm`),J(`tengu_cancel`,{source:`kill_agents`}),rf(),j();return}b.current=t,v({key:`kill-agents-confirm`,text:`Press ${z_(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`)} again to stop background agents`,priority:`immediate`,timeoutMs:bz})},[h,v,y,j]),{context:`Chat`}),null}H(),tb(),Xa(),U_();function Sz(e,t){t(t=>{let n=Cu(t.tasks).length;if(n===0)return t;if(t.expandedView!==`teammates`)return{...t,expandedView:`teammates`,viewSelectionMode:`selecting-agent`,selectedIPAgentIndex:-1};let r=n,i=t.selectedIPAgentIndex,a=e===1?i>=r?-1:i+1:i<=-1?r:i-1;return{...t,selectedIPAgentIndex:a,viewSelectionMode:`selecting-agent`}})}function Cz(e){let t=X(e=>e.tasks),n=X(e=>e.viewSelectionMode),r=X(e=>e.viewingAgentTaskId),i=X(e=>e.selectedIPAgentIndex),a=X(e=>e.pipeIpc),o=Zs(),s=Cu(t),c=s.length,l=Object.values(t).some(e=>bh(e)&&e.type!==`in_process_teammate`),u=(0,Q.useRef)(c);(0,Q.useEffect)(()=>{let e=u.current;u.current=c,o(t=>{let n=Cu(t.tasks).length;if(n===0&&e>0&&t.selectedIPAgentIndex!==-1)return t.viewSelectionMode===`viewing-agent`?{...t,selectedIPAgentIndex:-1}:{...t,selectedIPAgentIndex:-1,viewSelectionMode:`none`};let r=t.expandedView===`teammates`?n:n-1;return n>0&&t.selectedIPAgentIndex>r?{...t,selectedIPAgentIndex:r}:t})},[c,o]);let d=()=>{if(c===0)return null;let e=s[i];return e?{taskId:e.id,task:e}:null},f=s=>{if(s.key===`escape`&&n===`viewing-agent`){s.preventDefault();let e=r;if(e){let n=t[e];if(td(n)&&n.status===`running`){n.currentWorkAbortController?.abort();return}}iF(o);return}if(s.key===`escape`&&n===`selecting-agent`){s.preventDefault(),o(e=>({...e,viewSelectionMode:`none`,selectedIPAgentIndex:-1}));return}if(s.shift&&(s.key===`up`||s.key===`down`)){s.preventDefault(),c>0?Sz(s.key===`down`?1:-1,o):l?e?.onOpenBackgroundTasks?.():s.key===`down`&&a?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}if(s.key===`f`&&n===`selecting-agent`&&c>0){s.preventDefault();let e=d();e&&rF(e.taskId,o);return}if(s.key===`return`&&n===`selecting-agent`){if(s.preventDefault(),i===-1)iF(o);else if(i>=c)o(e=>({...e,expandedView:`none`,viewSelectionMode:`none`,selectedIPAgentIndex:-1}));else{let e=d();e&&rF(e.taskId,o)}return}if(s.key===`k`&&n===`selecting-agent`&&i>=0){s.preventDefault();let e=d();e&&e.task.status===`running`&&Ac.kill(e.taskId,o);return}};return je((e,t,n)=>{f(new Ne(n.keypress))}),{handleKeyDown:f}}K(),Ap(),Fr(),Wi(),kh(),Sx();function wz(e,t,n){let{teamName:r,agentId:i,agentName:a}=n,o=Ox(r);if(!o){q(`[TeammateInit] Team file not found for team: ${r}`);return}let s=o.leadAgentId;if(o.teamAllowedPaths&&o.teamAllowedPaths.length>0){q(`[TeammateInit] Found ${o.teamAllowedPaths.length} team-wide allowed path(s)`);for(let t of o.teamAllowedPaths){let n=t.path.startsWith(`/`)?`/${t.path}/**`:`${t.path}/**`;q(`[TeammateInit] Applying team permission: ${t.toolName} allowed in ${t.path} (rule: ${n})`),e(e=>({...e,toolPermissionContext:Yf(e.toolPermissionContext,{type:`addRules`,rules:[{toolName:t.toolName,ruleContent:n}],behavior:`allow`,destination:`session`})}))}}let c=o.members.find(e=>e.agentId===s)?.name||`team-lead`;if(i===s){q(`[TeammateInit] This agent is the team leader - skipping idle notification hook`);return}q(`[TeammateInit] Registering Stop hook for teammate ${a} to notify leader ${c}`),Ld(e,t,`Stop`,``,async(e,t)=>(kx(r,a,!1),await my(c,{from:a,text:zr(jv(a,{idleReason:`available`,summary:Q_(e)})),timestamp:new Date().toISOString(),color:Ki()}),q(`[TeammateInit] Sent idle notification to leader ${c}`),!0),`Failed to send idle notification to team leader`,{timeout:1e4})}Ke(),Jt(),Sx(),Wi();function Tz(e,t,{enabled:n=!0}={}){(0,Q.useEffect)(()=>{if(n&&Gn()){let n=t?.[0],r=n&&`teamName`in n?n.teamName:void 0,i=n&&`agentName`in n?n.agentName:void 0;if(r&&i){TT(e,r,i);let t=Ox(r)?.members.find(e=>e.name===i);t&&wz(e,ft(),{teamName:r,agentId:t.agentId,agentName:i})}else{let t=qi?.();t?.teamName&&t?.agentId&&t?.agentName&&wz(e,ft(),{teamName:t.teamName,agentId:t.agentId,agentName:t.agentName})}}},[e,t,n])}tb(),xy();function Ez(){let e=Zs(),t=X(e=>e.viewingAgentTaskId),n=X(e=>e.viewingAgentTaskId?e.tasks[e.viewingAgentTaskId]:void 0),r=n&&td(n)?n:void 0,i=r?.status,a=r?.error,o=n!==void 0;(0,Q.useEffect)(()=>{if(t){if(!o){iF(e);return}if(r&&(i===`killed`||i===`failed`||a||i!==`running`&&i!==`completed`&&i!==`pending`)){iF(e);return}}},[t,o,r,i,a,e])}Jw(),vi();async function Dz(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?yi(e):yi(Error(`Automated permission check failed: ${String(e)}`))}return null}Jb(),Xb(),XS(),eC();var Oz=new Map,kz=null,Az=!1;function jz(){return kz??null}function Mz(e,t){if(Az)return null;let n=jz();if(!n)return null;let r=oE(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return Oz.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function Nz(e){e&&Oz.delete(e)}function Pz(e,t){if(!e||Az)return;let n=jz();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}$i(),C_(),Wa(),K(),Yv(),Lf(),Ap(),Bf();function Fz(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 Iz(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){vu({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){J(`tengu_tool_use_cancelled`,{messageID:s,toolName:xc(e.name)})},async persistPermissions(e){return e.length===0?!1:(Hu(e),a(iy(n.getAppState().toolPermissionContext,e)),e.some(e=>Po(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?m_:rm}${t}`:a?Pm:Wv,s=a?o:bg(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 ol(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 Lz(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))}}}Ke(),H(),Wa(),kl(),Vr();function Rz(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
94
+ `):``}function zz(e){let t=e.match(RegExp(`<${zb}\\b([^>]*)>`));if(!t?.[1])return null;let n=t[1],r=n.match(/\bsource="([^"]+)"/)?.[1],i=n.match(/\bchat_id="([^"]+)"/)?.[1];return!r&&!i?null:{sourceServer:r,chatId:i}}function Bz(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type!==`user`||n?.origin?.kind!==`channel`)continue;let r=zz(Rz(n.message?.content));if(r)return{sourceServer:r.sourceServer||(typeof n.origin.server==`string`?n.origin.server:void 0),chatId:r.chatId}}return null}function Vz(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o,channelCallbacks:s}=e,{resolve:c,isResolved:l,claim:u}=Fz(t),d,f,p=o?oE():void 0,m,h=Date.now(),g=i.updatedInput??n.input,_=null;function v(e){Pz(_,e),Nz(_),_=null}function y(){Nz(_),_=null}let b={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:g,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:h,onUserInteraction(){Date.now()-h<200||ml(n.toolUseID)},onDismissCheckmark(){d&&(clearTimeout(d),d=void 0,f&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,f),f=void 0),n.removeFromQueue())},onAbort(){u()&&(v(`Permission request was aborted locally in sub.`),o&&p&&(o.sendResponse(p,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(p)),m?.(),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:h}),c(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){u()&&(v(`Permission request was approved locally in sub.`),o&&p&&(o.sendResponse(p,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(p)),m?.(),c(await n.handleUserAllow(e,t,r,h,a,i.decisionReason)))},onReject(e,t){u()&&(v(`Permission request was rejected locally in sub.`),o&&p&&(o.sendResponse(p,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(p)),m?.(),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:h}),c(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(l())return;let e=await Ys(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!u())return;v(`Permission request was resolved locally in sub.`),o&&p&&o.cancelRequest(p),m?.(),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),c(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(b),_=Mz(b,e=>{u()&&(y(),ml(n.toolUseID),n.removeFromQueue(),m?.(),o&&p&&o.cancelRequest(p),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:h}),c(n.buildAllow(e.updatedInput??g,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:h}),c(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&p){o.sendRequest(p,n.tool.name,g,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(p,r=>{u()&&(v(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),ml(n.toolUseID),n.removeFromQueue(),m?.(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:h}),c(n.buildAllow(r.updatedInput??g))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:h}),c(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}if(s&&!n.tool.requiresUserInteraction?.()){let e=$S(n.toolUseID),t=xt(),i=rC(n.toolUseContext.getAppState().mcp.clients,e=>QS(e,t)!==void 0);if(i.length>0){let t={request_id:e,tool_name:n.tool.name,description:r,input_preview:nC(g)},a=Bz(n.toolUseContext.messages);(a?.sourceServer||a?.chatId)&&(t.channel_context={...a.sourceServer&&{source_server:a.sourceServer},...a.chatId&&{chat_id:a.chatId}});for(let e of i)e.type===`connected`&&e.client.notification({method:ZS,params:t}).catch(t=>{vb(`Channel permission_request failed for ${e.name}: ${Kr(t)}`,{level:`error`})});let l=n.toolUseContext.abortController.signal,d=s.onResponse(e,e=>{u()&&(v(`Permission request was resolved by channel before pipe response.`),m?.(),ml(n.toolUseID),n.removeFromQueue(),o&&p&&o.cancelRequest(p),e.behavior===`allow`?(n.logDecision({decision:`accept`,source:{type:`user`,permanent:!1}},{permissionPromptStartTimeMs:h}),c(n.buildAllow(g))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!1}},{permissionPromptStartTimeMs:h}),c(n.cancelAndAbort(`Denied via channel ${e.fromServer}`))))});m=()=>{d(),l.removeEventListener(`abort`,m)},l.addEventListener(`abort`,m,{once:!0})}}a||(async()=>{if(l())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,h);!t||!u()||(v(`Permission request was resolved by hook before pipe response.`),o&&p&&o.cancelRequest(p),m?.(),n.removeFromQueue(),c(t))})()}Jt(),Vr(),vi();async function Hz(e){if(!Gn()||!J_())return null;let{ctx:t,description:n,updatedInput:r,suggestions:i}=e;try{let e=()=>t.toolUseContext.setAppState(e=>({...e,pendingWorkerRequest:null}));return await new Promise(r=>{let{resolve:a,claim:o}=Fz(r),s=Cm({toolName:t.tool.name,toolUseId:t.toolUseID,input:t.input,description:n,permissionSuggestions:i});bu({requestId:s.id,toolUseId:t.toolUseID,async onAllow(n,r,i,s){if(!o())return;e();let c=n&&Object.keys(n).length>0?n:t.input;a(await t.handleUserAllow(c,r,i,void 0,s))},onReject(n,r){o()&&(e(),t.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!n}}),a(t.cancelAndAbort(n,void 0,r)))}}),Dh(s),t.toolUseContext.setAppState(e=>({...e,pendingWorkerRequest:{toolName:t.tool.name,toolUseId:t.toolUseID,description:n}})),t.toolUseContext.abortController.signal.addEventListener(`abort`,()=>{o()&&(e(),t.logCancelled(),a(t.cancelAndAbort(void 0,!0)))},{once:!0})})}catch(e){return yi(Lr(e)),null}}$i(),C_(),H(),Wa(),kl(),K(),Vr(),vi(),md(),Fr(),Bf();function Uz(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=Iz(n,r,i,a,o,t,Lz(e));if(!l.resolveIfAborted(c))return(s===void 0?Ys(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&J(`tengu_internal_tool_permission_decision`,{toolName:xc(n.name),behavior:e.behavior,input:zr(r),messageID:l.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&ou(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`:vu({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Yw({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)(z,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:{if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await Dz({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;let n=await Hz({ctx:l,description:a,updatedInput:e.updatedInput,suggestions:e.suggestions});if(n){c(n);return}Vz({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks,channelCallbacks:t.channelPermissionCallbacks},c);return}}}).catch(e=>{e instanceof Wr||e instanceof d?(q(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(yi(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{ml(o)})}),[e,t])}$i(),fb(),Xu(),qr(),K(),$f(),Vr(),vi(),lp(),Ht(),Fv();function Wz(){Xm(0)}async function Gz(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){l_(),await Kz({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(Ho(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(kT);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?Gz({...e,input:`/exit`}):Wz();return}let j=Op(T,k),ee=Ho(T).filter(e=>k[e.id]?.type===`text`),M=ee.length;if(J(`tengu_paste_text`,{pastedTextCount:M,pastedTextBytes:ee.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&&Ip(e)&&(e.name===f||e.aliases?.includes(f)||Qy(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){J(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Mg(),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?La({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}`),J(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),La({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}l_(),await Kz({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 Kz(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=Mg();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Am(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await rh(w);w=T.attachmentCommands;let E=T.claimedCommands;if(w.length===0){l(null);return}let D=w[0]?.workload,O=D!==void 0&&w.every(e=>e.workload===D)?D:void 0,k=new Set,A;try{await Nn(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await jT({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&&k.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.effort,S=u.nextInput,C=u.submitNextInput)}if(Am(`query_process_user_input_end`),o_()&&(Am(`query_file_history_snapshot_start`),s.filter(hD).forEach(e=>{Gp(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Am(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=w[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?Bn(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?La({value:S,mode:`prompt`}):e.onInputChange(S))})}catch(e){A=e}if(E.length){let e=E.filter(e=>{let t=e.autonomy?.runId;return!t||!k.has(t)});if(A)try{await Km({commands:e,outcome:{type:`failed`,error:A},currentDir:Jr(),priority:`later`,workload:O})}catch(e){yi(Lr(e))}else try{let t=await Km({commands:e,outcome:{type:`completed`},currentDir:Jr(),priority:`later`,workload:O});for(let e of t)La(e)}catch(e){yi(Lr(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}lp();function qz(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 Jz({executeInput:e}){let t=e=>e.agentId===void 0,n=nv(t);if(!n)return{processed:!1};if(qz(n)||n.mode===`bash`)return e([Mf(t)]),{processed:!0};let r=n.mode,i=du(e=>t(e)&&!qz(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}lp();function Yz({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Rv,H_);(0,Q.useEffect)(()=>{r||t||i.length!==0&&Jz({executeInput:e})},[i,r,e,t,n])}function Xz({isLoading:e,onSubmitMessage:t}){let n=hh();(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])}qd();function Zz(e,t){return e&&t&&t.length>0?Ft([...e,...t],`name`):e||[]}function Qz(e,t){return(0,Q.useMemo)(()=>Zz(e,t),[e,t])}Hp(),Lt();function $z(){let e=cn()?.outputStyle??`default`;return e===`default`?`repl_main_thread`:e in $g?`repl_main_thread:outputStyle:${e}`:`repl_main_thread:outputStyle:custom`}fC(),mC(),Xt();function eB(e,t){return(0,Q.useMemo)(()=>t.length>0?Ft([...e,...t],`name`):e,[e,t])}fb(),Zn(),vi();function tB(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Kl(),t(await au(e))}catch(e){e instanceof Error&&yi(e)}},[e,t]);(0,Q.useEffect)(()=>vT.subscribe(n),[n]);let r=(0,Q.useCallback)(async()=>{if(e)try{Zo(),t(await au(e))}catch(e){e instanceof Error&&yi(e)}},[e,t]);(0,Q.useEffect)(()=>Mn(r),[r])}H(),up(),tb(),zh();function nB(){let e=X(e=>fo(e));if(!e)return null;let t=Zg(e.identity.color);return(0,$.jsx)(Uv,{children:(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{children:`Viewing `}),(0,$.jsxs)(z,{color:t,bold:!0,children:[`@`,e.identity.agentName]}),(0,$.jsxs)(z,{dimColor:!0,children:[` · `,(0,$.jsx)(B,{shortcut:`esc`,action:`return`})]})]}),(0,$.jsx)(z,{dimColor:!0,children:e.prompt})]})})}Ma(),D(),su(),ba();var rB=ya(()=>C({method:x(`selection_changed`),params:C({selection:C({start:C({line:y(),character:y()}),end:C({line:y(),character:y()})}).nullable().optional(),text:b().optional(),filePath:b().optional()})}));function iB(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Xh(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(rB(),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){Na(e)}}),n.current=!0},[e,t])}qv(),sg(),i_(),Ke(),Pg(),qr(),K(),cm(),Lf(),Ht(),Uo(),zm(),Fp(),bx(),fy();function aB(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type!==`assistant`)continue;let r=n.message.content.find(e=>e.type===`tool_use`&&e.name===`TodoWrite`);if(!r||r.type!==`tool_use`)continue;let i=r.input;if(typeof i!=`object`||!i)return[];let a=bT().safeParse(i.todos);return a.success?a.data:[]}return[]}function oB(e,t){if(e.fileHistorySnapshots&&e.fileHistorySnapshots.length>0&&lg(e.fileHistorySnapshots,e=>{t(t=>({...t,fileHistory:e}))}),e.attributionSnapshots&&e.attributionSnapshots.length>0&&rx(e.attributionSnapshots,e=>{t(t=>({...t,attribution:e}))}),!Ex()&&e.messages&&e.messages.length>0){let n=aB(e.messages);if(n.length>0){let e=ft();t(t=>({...t,todos:{...t.todos,[e]:n}}))}}}function sB(e,t){if(!(!e&&!t))return{name:e??``,color:t===`default`?void 0:t}}function cB(e,t,n){if(t)return{agentDefinition:t,agentType:void 0};if(!e)return Be(void 0),{agentDefinition:void 0,agentType:void 0};let r=n.activeAgents.find(t=>t.agentType===e);return r?(Be(r.agentType),!Ge()&&r.model&&r.model!==`inherit`&&He(Tn(r.model)),{agentDefinition:r,agentType:r.agentType}):(q(`Resumed session had agent "${e}" but it is no longer available. Using default behavior.`),Be(void 0),{agentDefinition:void 0,agentType:void 0})}function lB(e){let t=dh();if(t){Fm(t);return}if(e){try{process.chdir(e.worktreePath)}catch{Fm(null);return}g_(e.worktreePath),Ze(Jr()),Oy(e),af(),TS(),os.cache.clear?.()}}function uB(){let e=dh();if(e){Oy(null),af(),TS(),os.cache.clear?.();try{process.chdir(e.originalCwd)}catch{return}g_(e.originalCwd),Ze(Jr())}}H(),ns(),tb(),va();function dB({task:e,selected:t}){let n=Yl(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(U,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(z,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(z,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(z,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(U,{flexShrink:0,children:(0,$.jsxs)(z,{dimColor:!0,children:[n,` · ↓ `,ha(r),` tokens`]})})]})}function fB(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 pB(){let e=HM(),t=X(e=>e.viewingAgentTaskId),n=X(e=>e.footerSelection),r=X(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)(U,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(z,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(z,{dimColor:!0,children:fB(i,s)})]}),e.map(e=>(0,$.jsx)(dB,{task:e,selected:e.agentId===a},e.agentId))]})}xy(),fg(),kh();function mB(e,t){for(let n of Object.values(t.tasks))if(td(n)&&n.identity.agentName===e)return n.id}function hB(e,t,n){Um(e,t,e=>({...e,awaitingPlanApproval:n}))}function gB(e,t,n){hB(e,n,!1)}j(),ci(),H(),Wy(),tb(),Ia(),xy(),K(),Lf(),sr(),Ap(),Fr(),CS(),Rh(),_S(),Vd(),zg(),Sx(),bx(),Wi(),Ri(),kh(),Ef();function _B(e){if(!Yi()){if(Hi())return Gi();if(Vi(e.teamContext)){let t=e.teamContext.leadAgentId;return e.teamContext.teammates[t]?.name||`team-lead`}}}var vB=1e3;function yB({enabled:e,isLoading:t,focusedInputDialog:n,onSubmitMessage:r}){let i=r,a=Md(),o=Zs(),s=X(e=>e.inbox.messages.length),c=M(),l=(0,Q.useCallback)(async()=>{if(!e)return;let r=a.getState(),s=_B(r);if(!s)return;let l=await $m(s,r.teamContext?.teamName);if(l.length===0)return;if(q(`[InboxPoller] Found ${l.length} unread message(s)`),Hi()&&Ji())for(let e of l){let t=ug(e.text);if(t&&e.from===`team-lead`)if(q(`[InboxPoller] Received plan approval response from team-lead: approved=${t.approved}`),t.approved){let e=t.permissionMode??`default`;o(t=>({...t,toolPermissionContext:Yf(t.toolPermissionContext,{type:`setMode`,mode:vn(e),destination:`session`})})),q(`[InboxPoller] Plan approved by team lead, exited plan mode to ${e}`)}else q(`[InboxPoller] Plan rejected by team lead: ${t.feedback||`No feedback provided`}`);else t&&q(`[InboxPoller] Ignoring plan approval response from non-team-lead: ${e.from}`)}let u=()=>{mh(s,r.teamContext?.teamName)},d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=[],b=[];for(let e of l){let t=s_(e.text),n=dv(e.text),r=ey(e.text),i=lm(e.text),a=v_(e.text),o=Bm(e.text),s=Tg(e.text),c=wp(e.text),l=Kp(e.text);t?d.push(e):n?f.push(e):r?p.push(e):i?m.push(e):a?h.push(e):o?g.push(e):s?_.push(e):c?v.push(e):l?y.push(e):b.push(e)}if(d.length>0&&Vi(r.teamContext)){q(`[InboxPoller] Found ${d.length} permission request(s)`);let e=Eo(),i=r.teamContext?.teamName;for(let t of d){let n=s_(t.text);if(n)if(e){let t=jf(fc(),n.tool_name);if(!t){q(`[InboxPoller] Unknown tool ${n.tool_name}, skipping permission request`);continue}let r={assistantMessage:Ly({content:``}),tool:t,description:n.description,input:n.input,toolUseContext:{},toolUseID:n.tool_use_id,permissionResult:{behavior:`ask`,message:n.description},permissionPromptStartTimeMs:Date.now(),workerBadge:{name:n.agent_id,color:`cyan`},onUserInteraction(){},onAbort(){yp(n.agent_id,{decision:`rejected`,resolvedBy:`leader`},n.request_id,i)},onAllow(e,t){yp(n.agent_id,{decision:`approved`,resolvedBy:`leader`,updatedInput:e,permissionUpdates:t},n.request_id,i)},onReject(e){yp(n.agent_id,{decision:`rejected`,resolvedBy:`leader`,feedback:e},n.request_id,i)},async recheckPermission(){}};e(e=>e.some(e=>e.toolUseID===n.tool_use_id)?e:[...e,r])}else q(`[InboxPoller] ToolUseConfirmQueue unavailable, dropping permission request from ${n.agent_id}`)}let a=s_(d[0]?.text??``);a&&!t&&!n&&Dp({message:`${a.agent_id} needs permission for ${a.tool_name}`,notificationType:`worker_permission_prompt`},c)}if(f.length>0&&Hi()){q(`[InboxPoller] Found ${f.length} permission response(s)`);for(let e of f){let t=dv(e.text);t&&N_(t.request_id)&&(q(`[InboxPoller] Processing permission response for ${t.request_id}: ${t.subtype}`),t.subtype===`success`?ff({requestId:t.request_id,decision:`approved`,updatedInput:t.response?.updated_input,permissionUpdates:t.response?.permission_updates}):ff({requestId:t.request_id,decision:`rejected`,feedback:t.error}))}}if(p.length>0&&Vi(r.teamContext)){q(`[InboxPoller] Found ${p.length} sandbox permission request(s)`);let e=[];for(let t of p){let n=ey(t.text);if(n){if(!n.hostPattern?.host){q(`[InboxPoller] Invalid sandbox permission request: missing hostPattern.host`);continue}e.push({requestId:n.requestId,workerId:n.workerId,workerName:n.workerName,workerColor:n.workerColor,host:n.hostPattern.host,createdAt:n.createdAt})}}if(e.length>0){o(t=>({...t,workerSandboxPermissions:{...t.workerSandboxPermissions,queue:[...t.workerSandboxPermissions.queue,...e]}}));let r=e[0];r&&!t&&!n&&Dp({message:`${r.workerName} needs network access to ${r.host}`,notificationType:`worker_permission_prompt`},c)}}if(m.length>0&&Hi()){q(`[InboxPoller] Found ${m.length} sandbox permission response(s)`);for(let e of m){let t=lm(e.text);t&&kc(t.requestId)&&(q(`[InboxPoller] Processing sandbox permission response for ${t.requestId}: allow=${t.allow}`),Hf({requestId:t.requestId,host:t.host,allow:t.allow}),o(e=>({...e,pendingSandboxRequest:null})))}}if(_.length>0&&Hi()){q(`[InboxPoller] Found ${_.length} team permission update(s)`);for(let e of _){let t=Tg(e.text);if(!t){q(`[InboxPoller] Failed to parse team permission update: ${e.text.substring(0,100)}`);continue}if(!t.permissionUpdate?.rules||!t.permissionUpdate?.behavior){q(`[InboxPoller] Invalid team permission update: missing permissionUpdate.rules or permissionUpdate.behavior`);continue}q(`[InboxPoller] Applying team permission update: ${t.toolName} allowed in ${t.directoryPath}`),q(`[InboxPoller] Permission update rules: ${zr(t.permissionUpdate.rules)}`),o(e=>{let n=Yf(e.toolPermissionContext,{type:`addRules`,rules:t.permissionUpdate.rules,behavior:t.permissionUpdate.behavior,destination:`session`});return q(`[InboxPoller] Updated session allow rules: ${zr(n.alwaysAllowRules.session)}`),{...e,toolPermissionContext:n}})}}if(v.length>0&&Hi()){q(`[InboxPoller] Found ${v.length} mode set request(s)`);for(let e of v){if(e.from!==`team-lead`){q(`[InboxPoller] Ignoring mode set request from non-team-lead: ${e.from}`);continue}let t=wp(e.text);if(!t){q(`[InboxPoller] Failed to parse mode set request: ${e.text.substring(0,100)}`);continue}let n=Fn(t.mode);q(`[InboxPoller] Applying mode change from team-lead: ${n}`),o(e=>({...e,toolPermissionContext:Yf(e.toolPermissionContext,{type:`setMode`,mode:vn(n),destination:`session`})}));let i=r.teamContext?.teamName,a=Gi();i&&a&&Dx(i,a,n)}}if(y.length>0&&Vi(r.teamContext)){q(`[InboxPoller] Found ${y.length} plan approval request(s), auto-approving`);let e=r.teamContext?.teamName,t=vn(r.toolPermissionContext.mode),n=t===`plan`?`default`:t;for(let t of y){let i=Kp(t.text);if(!i)continue;let a={type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n};my(t.from,{from:gS,text:zr(a),timestamp:new Date().toISOString()},e);let s=mB(t.from,r);s&&gB(s,{type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n},o),q(`[InboxPoller] Auto-approved plan from ${t.from} (request ${i.requestId})`),b.push(t)}}if(h.length>0&&Hi()){q(`[InboxPoller] Found ${h.length} shutdown request(s)`);for(let e of h)b.push(e)}if(g.length>0&&Vi(r.teamContext)){q(`[InboxPoller] Found ${g.length} shutdown approval(s)`);for(let e of g){let t=Bm(e.text);if(!t)continue;t.paneId&&t.backendType&&(async()=>{try{await Dy();let e=await SS(),n=await ld(t.backendType)?.killPane(t.paneId,!e);q(`[InboxPoller] Killed pane ${t.paneId} for ${t.from}: ${n}`)}catch(e){q(`[InboxPoller] Failed to kill pane for ${t.from}: ${e}`)}})();let n=t.from;if(n&&r.teamContext?.teammates){let e=Object.entries(r.teamContext.teammates).find(([,e])=>e.name===n)?.[0];if(e){let t=r.teamContext?.teamName;t&&Cx(t,{agentId:e,name:n});let{notificationMessage:i}=t?await _x(t,e,n,`shutdown`):{notificationMessage:`${n} has shut down.`};o(t=>{if(!t.teamContext?.teammates||!(e in t.teamContext.teammates))return t;let{[e]:n,...r}=t.teamContext.teammates,a={...t.tasks};for(let[t,n]of Object.entries(a))td(n)&&n.identity.agentId===e&&(a[t]={...n,status:`completed`,endTime:Date.now()});return{...t,tasks:a,teamContext:{...t.teamContext,teammates:r},inbox:{messages:[...t.inbox.messages,{id:oE(),from:`system`,text:zr({type:`teammate_terminated`,message:i}),timestamp:new Date().toISOString(),status:`pending`}]}}}),q(`[InboxPoller] Removed ${n} (${e}) from teamContext`)}}b.push(e)}}if(b.length===0){u();return}let x=b.map(e=>{let t=e.color?` color="${e.color}"`:``,n=e.summary?` summary="${e.summary}"`:``,r=e.text;return`<${li} teammate_id="${e.from}"${t}${n}>\n${r}\n</${li}>`}).join(`
95
+
96
+ `),S=()=>{o(e=>({...e,inbox:{messages:[...e.inbox.messages,...b.map(e=>({id:oE(),from:e.from,text:e.text,timestamp:e.timestamp,status:`pending`,color:e.color,summary:e.summary}))]}}))};!t&&!n?(q(`[InboxPoller] Session idle, submitting immediately`),i(x)||(q(`[InboxPoller] Submission rejected, queuing for later delivery`),S())):(q(`[InboxPoller] Session busy, queuing for later delivery`),S()),u()},[e,t,n,i,o,c,a]);(0,Q.useEffect)(()=>{if(!e||t||n)return;let r=a.getState();if(!_B(r))return;let s=r.inbox.messages.filter(e=>e.status===`pending`),c=r.inbox.messages.filter(e=>e.status===`processed`);if(c.length>0){q(`[InboxPoller] Cleaning up ${c.length} processed message(s) that were delivered mid-turn`);let e=new Set(c.map(e=>e.id));o(t=>({...t,inbox:{messages:t.inbox.messages.filter(t=>!e.has(t.id))}}))}if(s.length!==0)if(q(`[InboxPoller] Session idle, delivering ${s.length} pending message(s)`),i(s.map(e=>{let t=e.color?` color="${e.color}"`:``,n=e.summary?` summary="${e.summary}"`:``;return`<teammate-message teammate_id="${e.from}"${t}${n}>\n${e.text}\n</teammate-message>`}).join(`
97
+
98
+ `))){let e=new Set(s.map(e=>e.id));o(t=>({...t,inbox:{messages:t.inbox.messages.filter(t=>!e.has(t.id))}}))}else q(`[InboxPoller] Submission rejected, keeping messages queued`)},[e,t,n,i,o,s,a]),ue(()=>void l(),e&&_B(a.getState())?vB:null);let u=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{e&&(u.current||_B(a.getState())&&(u.current=!0,l()))},[e,l,a])}K(),bx();var bB=1e3;function xB({taskListId:e,isLoading:t,onSubmitTask:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)(n);o.current=n;let s=e!==void 0,c=e??`tasklist`,l=(0,Q.useRef)(async()=>{});l.current=async()=>{if(!s||a.current)return;let t=await mx(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)q(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=SB(t);if(!n)return;q(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await xx(e,n.id,c);if(!i.success){q(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=CB(n);q(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(q(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await vx(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;Mx(e);let t=hx(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),bB,l)};u.current=r;try{n=iE(t,r),n.unref(),q(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){q(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function SB(e){let t=new Set(e.filter(e=>e.status!==`completed`).map(e=>e.id));return e.find(e=>e.status!==`pending`||e.owner?!1:e.blockedBy.every(e=>!t.has(e)))}function CB(e){let t=`Complete all open tasks. Start with task #${e.id}: \n\n ${e.subject}`;return e.description&&(t+=`\n\n${e.description}`),t}mn(),l(),su();function wB({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:i}){(0,Q.useEffect)(()=>{function a(r){r&&(W().autoConnectIde||e||mb()||process.env.CLAUDE_CODE_SSE_PORT||t||u(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!s(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`}})}ks(a,t,()=>r(!0),e=>i(e))},[e,t,n,r,i])}gw(),pS(),H(),Px(),fm(),tb(),Cc(),mn(),Da(),l();function TB({onBackgroundSession:e,isLoading:t}){let n=Zs(),r=Md(),[i,a]=(0,Q.useState)(!1),o=re(a,e,()=>{}),s=(0,Q.useCallback)(()=>{u(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(O_(r.getState())?(Vc(()=>r.getState(),n),W().hasUsedBackgroundTask||Dr(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):u(`false`)&&t&&o())},[n,r,t,o]),c=X(O_),l=u(`false`);De(`task:background`,s,{context:`Task`,isActive:c||l&&t});let d=gv(`task:background`,`Task`,`ctrl+b`),f=ka.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsx)(z,{dimColor:!0,children:(0,$.jsx)(B,{shortcut:f,action:`background`})})})}Sf(),tb();function EB({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=X(e=>e.foregroundedTaskId),o=X(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Zs(),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}}Gs(),H(),Px(),mn(),Da(),su();function DB({onDone:e,installationStatus:t}){kB(),Se({"confirm:yes":e,"confirm:no":e},{context:`Confirmation`});let n=t?.ideType??hl(),r=il(n),i=wd(n),a=t?.installedVersion,o=r?`plugin`:`extension`,s=ka.platform===`darwin`?`Cmd+Option+K`:`Ctrl+Alt+K`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ve,{title:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{color:`claude`,children:`✻ `}),(0,$.jsxs)(z,{children:[`Welcome to Claude Code for `,i]})]}),subtitle:a?`installed ${o} v${a}`:void 0,color:`ide`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(z,{children:[`• Claude has context of `,(0,$.jsx)(z,{color:`suggestion`,children:`⧉ open files`}),` and`,` `,(0,$.jsx)(z,{color:`suggestion`,children:`⧉ selected lines`})]}),(0,$.jsxs)(z,{children:[`• Review Claude Code's changes `,(0,$.jsx)(z,{color:`diffAddedWord`,children:`+11`}),` `,(0,$.jsx)(z,{color:`diffRemovedWord`,children:`-22`}),` in the comfort of your IDE`]}),(0,$.jsxs)(z,{children:[`• Cmd+Esc`,(0,$.jsx)(z,{dimColor:!0,children:` for Quick Launch`})]}),(0,$.jsxs)(z,{children:[`• `,s,(0,$.jsx)(z,{dimColor:!0,children:` to reference files or lines in your input`})]})]})}),(0,$.jsx)(U,{paddingX:1,children:(0,$.jsx)(z,{dimColor:!0,italic:!0,children:`Press Enter to continue`})})]})}function OB(){let e=W(),t=Xd.terminal||`unknown`;return e.hasIdeOnboardingBeenShown?.[t]===!0}function kB(){if(OB())return;let e=Xd.terminal||`unknown`;Dr(t=>({...t,hasIdeOnboardingBeenShown:{...t.hasIdeOnboardingBeenShown,[e]:!0}}))}H(),ir(),mn(),Ht(),Lt(),ob(),rw(),TC();var AB=3e4;function jB({model:e,onDone:t}){let n=gb(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{FB()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,AB);return()=>clearTimeout(e)},[i]);let a=Ml(e),o=a?vl(a):`high`,s=(0,Q.useCallback)(e=>{Ut(`userSettings`,{effortLevel:P_(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(NB,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(NB,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(NB,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(EC,{title:n.dialogTitle,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(z,{children:n.dialogDescription})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[(0,$.jsx)(MB,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(MB,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(MB,{level:`high`}),` high`]})}),(0,$.jsx)(ku,{options:c,onChange:s,onCancel:i})]})})}function MB({level:e}){return(0,$.jsx)(z,{color:`suggestion`,children:QC(e)})}function NB({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(MB,{level:e}),` `,t]})}function PB(e){if(!Tn(e).toLowerCase().includes(`opus-4-6`))return!1;let t=W();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(FB(),!1):Rn()?t.effortCalloutDismissed?(FB(),!1):gb().enabled:jn()||hn()?gb().enabled:(FB(),!1)}function FB(){Dr(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}DC(),iC();var IB=(0,Q.createContext)(null);function LB({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=tC(t,n),a=(0,Q.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,$.jsx)(IB.Provider,{value:a,children:e})}Zn();function RB(e,t){let[n,r]=Q.useState(t);return Q.useEffect(()=>{hr(e,t).then(r)},[e,t]),n}async function zB(e,t,n){try{q(`Collecting transcript for sharing`,{level:`info`});let r=t_(e),i=await al(Oc(e)),a;try{let e=lh(),{size:t}=await lE(e);t<=52428800?a=await cE(e,`utf-8`):q(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=Iw(zr({trigger:t,version:`2.8.4`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await At();let s=Mt();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":an(),...s.headers},l=await _.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(Kr(e),{level:`error`}),{success:!1}}}var BB=t((()=>{v(),ir(),K(),Vr(),Lf(),Fp(),Fr()}));Z_(),BB();function VB({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)(oE()),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=oE(),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])}}$i(),mn(),l(),Lf(),Ht(),Lt();var HB={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},UB={probability:0};function WB(e,t,n,r=`session`,i=!1){let a=(0,Q.useRef)(`unknown`);a.current=Rd(e)?.message?.id||`unknown`;let[o,s]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),c=RB(`tengu_feedback_survey_config`,HB),l=RB(`tengu_bad_survey_transcript_ask_config`,UB),d=RB(`tengu_good_survey_transcript_ask_config`,UB),f=qt().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)=>{s(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),W().feedbackSurveyState?.lastShownTime!==e&&Dr(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),J(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r}),Ux(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),J(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:a.current,survey_type:r}),Ux(`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`||W().transcriptShareDismissed||!Ws(`allow_product_feedback`))return!1;let t=e===`bad`?l.probability:d.probability;return Math.random()<=t},[l.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;J(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:n}),Ux(`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(J(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&Dr(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await zB(g.current,i,e);return J(`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}=VB({hideThanksAfterMs:c.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=sn(),j=(0,Q.useMemo)(()=>c.onForModels.length===0?!1:c.onForModels.includes(`*`)?!0:c.onForModels.includes(A),[c.onForModels,A]),ee=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!o.timeLastShown)return!0;if(!j||u(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||xp()||!Ws(`allow_product_feedback`))return!1;if(o.timeLastShown){if(Date.now()-o.timeLastShown<c.minTimeBetweenFeedbackMs||o.submitCountAtLastAppearance!==null&&n<o.submitCountAtLastAppearance+c.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<c.minTimeBeforeFeedbackMs||n<m.current+c.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??c.probability)),!_.current)return!1;let e=W().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<c.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,o.timeLastShown,o.submitCountAtLastAppearance,n,c.minTimeBetweenFeedbackMs,c.minTimeBetweenGlobalFeedbackMs,c.minUserTurnsBetweenFeedback,c.minTimeBeforeFeedbackMs,c.minUserTurnsBeforeFeedback,c.probability,f]);return(0,Q.useEffect)(()=>{ee&&D()},[ee,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Z_(),$i(),Sd(),mn(),l(),wh(),Lf(),Vx(),BB();var GB=3e3,KB=`tengu_dunwich_bell`,qB=`tengu_memory_survey_event`,JB=.2,YB=`memory_survey`,XB=/\bmemor(?:y|ies)\b/i;function ZB(e){for(let t of e){if(t.type!==`assistant`)continue;let e=t.message.content;if(Array.isArray(e))for(let t of e){if(t.type!==`tool_use`||t.name!==`Read`)continue;let e=t.input;if(typeof e.file_path==`string`&&hp(e.file_path))return!0}}return!1}function QB(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:d,handleTranscriptSelect:f}=VB({hideThanksAfterMs:GB,onOpen:(0,Q.useCallback)(e=>{J(qB,{event_type:`appeared`,appearance_id:e}),Ux(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{J(qB,{event_type:`responded`,appearance_id:e,response:t}),Ux(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!(process.env.USER_TYPE!==`ant`||e!==`bad`&&e!==`good`||W().transcriptShareDismissed||!Ws(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{J(qB,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:YB}),Ux(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(J(qB,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:YB}),t===`dont_ask_again`&&Dr(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await zB(o.current,YB,e);return J(qB,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:YB}),t.success}return!1},[])}),p=(0,Q.useMemo)(()=>Rd(e),[e]);return(0,Q.useEffect)(()=>{if(!r)return;if(e.length===0){a.current=!1,i.current.clear();return}if(s!==`closed`||t||n||!_n(KB,!1)||!Kn()||xp()||!Ws(`allow_product_feedback`)||u(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||!p||i.current.has(p.uuid))return;let o=nu(Array.isArray(p.message.content)?p.message.content:[],` `);XB.test(o)&&(i.current.add(p.uuid),a.current||(a.current=ZB(e)),a.current&&Math.random()<JB&&l())},[r,s,t,n,p,e,l]),{state:s,lastResponse:c,handleSelect:d,handleTranscriptSelect:f}}Z_(),gr(),$i(),l(),Lf(),Vx();var $B=3e3,eV=`tengu_post_compact_survey`,tV=.2;function nV(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 rV(e,t,n=!1,{enabled:r=!0}={}){let[i,a]=(0,Q.useState)(null),o=(0,Q.useRef)(new Set),s=(0,Q.useRef)(null),{state:c,lastResponse:l,open:d,handleSelect:f}=VB({hideThanksAfterMs:$B,onOpen:(0,Q.useCallback)(e=>{J(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:Ku()}),Ux(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{J(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:Ku()}),Ux(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&a(rr(eV))},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>gu(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||c!==`closed`||t||n||i!==!0||xp()||u(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(s.current!==null&&nV(e,s.current)){s.current=null,Math.random()<tV&&d();return}let a=Array.from(p).filter(e=>!o.current.has(e));a.length>0&&(o.current=new Set(p),s.current=a[a.length-1])},[r,p,c,t,n,i,e,d]),{state:c,lastResponse:l,handleSelect:f}}Cr(),H();var iV=[`1`,`2`,`3`],aV={1:`yes`,2:`no`,3:`dont_ask_again`},oV=e=>iV.includes(e);function sV({onSelect:e,inputValue:t,setInputValue:n}){return tz({inputValue:t,setInputValue:n,isValidDigit:oV,onDigit:t=>e(aV[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsxs)(z,{color:`ansi:cyan`,children:[wr,` `]}),(0,$.jsx)(z,{bold:!0,children:`Can Anthropic look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsx)(z,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(U,{marginLeft:2,children:[(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}$i(),H();function cV({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(uV,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(sV,{onSelect:r,inputValue:i,setInputValue:a}):i&&!iz(i)?null:(0,$.jsx)(oz,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var lV=e=>e===`1`;function uV({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;tz({inputValue:t,setInputValue:n,isValidDigit:lV,enabled:!!i,once:!0,onDigit:()=>{J(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}});let a=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;return(0,$.jsxs)(U,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(z,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(z,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(z,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(z,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(z,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}no(),Nf(),of(),Ke(),Fs(),vi();function dV(e){let{addNotification:t}=Ic(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{tt()||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(yi))},[t])}function fV(){dV(async()=>(await ss()).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`}}))}Yr(),Ia(),K(),Lf(),Ht(),Qp(),Gw(),tf(),Ke();var pV=30,mV=`The user stepped away and is coming back. Write exactly 1-3 short sentences. Start by stating the high-level task — what they are building or debugging, not implementation details. Next: the concrete next step. Skip status reports and commit recaps.`,hV=`用户离开后回来了。用中文写 1-3 句话。先说明用户在做什么(高层目标,不是实现细节),然后说明下一步具体操作。不要写状态报告或提交总结。`;function gV(e){return`${e?`Session memory (broader context):\n${e}\n\n`:``}${Ww()===`zh`?hV:mV}`}async function _V(e,t){if(e.length===0)return null;let n=Kt(),r=co()?sd({sessionId:ft(),model:n,provider:Wn(),name:`away-summary`}):null;try{let i=await by(),a=e.slice(-pV);a.push(Ph({content:gV(i)}));let o=await lu({messages:a,systemPrompt:ix([]),thinkingConfig:{type:`disabled`},tools:[],signal:t,options:{getToolPermissionContext:async()=>uu(),model:n,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,agents:[],querySource:`away_summary`,mcpTools:[],skipCacheWrite:!0,langfuseTrace:r}});return o.isApiErrorMessage?(q(`[awaySummary] API error: ${cb(o)}`),ps(r,void 0,`error`),null):(ps(r),cb(o))}catch(e){return e instanceof d||t.aborted?null:(q(`[awaySummary] generation failed: ${e}`),ps(r,void 0,`error`),null)}}H(),Zn(),Lf();var vV=5*6e4;function yV(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`user`&&!n.isMeta&&!n.isCompactSummary)return!1;if(n.type===`system`&&n.subtype===`away_summary`)return!0}return!1}function bV(e,t,n){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(e),o=(0,Q.useRef)(n),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(null);a.current=e,o.current=n;let l=Jn(`tengu_sedge_lantern`,!1);(0,Q.useEffect)(()=>{if(!l)return;function e(){r.current!==null&&(clearTimeout(r.current),r.current=null)}function n(){i.current?.abort(),i.current=null}async function u(){if(s.current=!1,yV(a.current))return;n();let e=new AbortController;i.current=e;let r=await _V(a.current,e.signal);e.signal.aborted||r===null||t(e=>[...e,Gu(r)])}function d(){if(r.current=null,o.current){s.current=!0;return}u()}function f(){let t=pe();t===`blurred`||t===`unknown`?(e(),r.current=setTimeout(d,vV)):t===`focused`&&(e(),n(),s.current=!1)}let p=te(f);return f(),c.current=u,()=>{p(),e(),n(),c.current=null}},[l,t]),(0,Q.useEffect)(()=>{if(n||!s.current)return;let e=pe();e!==`blurred`&&e!==`unknown`||c.current?.()},[n]),(0,Q.useEffect)(()=>{pe()===`unknown`&&l&&(n?(r.current!==null&&(clearTimeout(r.current),r.current=null),i.current?.abort(),i.current=null,s.current=!1):(r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{if(r.current=null,o.current){s.current=!0;return}c.current?.()},vV)))},[n,l])}H(),ir(),LC(),l();function xV(){if(process.argv.includes(`--chrome`))return!0;if(process.argv.includes(`--no-chrome`))return!1}function SV(){dV(async()=>{let e=xV();return FC(e)?process.env.USER_TYPE!==`ant`&&!vr()?{key:`chrome-requires-subscription`,jsx:(0,$.jsx)(z,{color:`error`,children:`Claude in Chrome requires a claude.ai subscription`}),priority:`immediate`,timeoutMs:5e3}:!await IC()&&!o()?{key:`chrome-extension-not-detected`,jsx:(0,$.jsx)(z,{color:`warning`,children:`Chrome extension not detected · https://claude.ai/chrome to install`}),priority:`immediate`,timeoutMs:3e3}:e===void 0?{key:`claude-in-chrome-default-enabled`,text:`Claude in Chrome enabled · /chrome`,priority:`low`}:null:null})}Zn(),aa(),mn(),K(),l(),Vr(),vi(),yy(),np(),Ha(),jh(),Xv();function CV(){return u(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var wV={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function TV(e){let t=wV.INITIAL_DELAY_MS*wV.BACKOFF_MULTIPLIER**e;return Math.min(t,wV.MAX_DELAY_MS)}function EV(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>=wV.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function DV(){let e=W();if(!EV(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return q(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(CV())return q(`Official marketplace auto-install disabled via env var, skipping`),Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Y(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await wm())[`claude-plugins-official`])return q(`Official marketplace '${Hh}' already installed, skipping`),Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!dy(to))return q(`Official marketplace blocked by enterprise policy, skipping`),Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Y(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=If(),n=YT(t,Hh);if(await og(n,t)!==null){let e=await wm();return e[Hh]={source:to,installLocation:n,lastUpdated:new Date().toISOString()},await r_(e),Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Y(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!Jn(`tengu_plugin_official_mkt_git_fallback`,!0)){q(`Official marketplace GCS failed; git fallback disabled by flag — skipping install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+TV(t);return Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`gcs_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r})),Y(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,gcs_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`gcs_unavailable`}}if(!await No()){q(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+TV(t),i=!1;try{Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,yi(Lr(e)),q(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return Y(`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 k_(to),q(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Y(`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 Qu(),q(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),Y(`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`}),yi(Lr(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+TV(r),o=!1;try{Dr(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,yi(Lr(e)),q(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return Y(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}H(),K();function OV(){dV(async()=>{let e=await DV(),t=[];return e.configSaveFailed&&(q(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(z,{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)(z,{color:`success`,children:`✓ Anthropic 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)(z,{color:`warning`,children:`Failed to install Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}yg(),Au(),Cy(),oy(),Ma(),D(),ba(),lp();var kV=ya(()=>C({method:x(`notifications/message`),params:C({prompt:b(),image:C({type:x(`base64`),media_type:S([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]),data:b()}).optional(),tabId:y().optional()})}));function AV(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(process.env.USER_TYPE!==`ant`)return;let t=jV(e);n.current!==t&&(n.current=t),t&&t.client.setNotificationHandler(kV(),e=>{if(n.current!==t)return;let{tabId:r,prompt:i,image:a}=e.params;if(!(typeof r!=`number`||!sS(r)))try{hm(a?{value:[{type:`text`,text:i},{type:`image`,source:{type:a.type,media_type:a.media_type,data:a.data}}],mode:`prompt`}:{value:i,mode:`prompt`})}catch(e){Na(e)}})},[e]),(0,Q.useEffect)(()=>{let n=jV(e);n&&Vf(`set_permission_mode`,{mode:t===`bypassPermissions`?`skip_all_permission_checks`:`ask`},n)},[e,t])}function jV(e){return e.find(e=>e.type===`connected`&&e.name===`claude-in-chrome`)}L(),yb(),_b(),lS(),H(),uw(),_h(),ir(),Wh(),mn(),Oo(),Da(),ii(),su(),Ht(),Oi(),Ha(),jh(),Fp(),Zn(),cw(),jS();var MV;async function NV(){return MV===void 0&&(MV=Hh in await Dv()),MV}async function PV(e,t,n){if(!await NV()||nc(`${e}@claude-plugins-official`))return!1;let{bashTools:r}=t??{};return!!(n.cli&&r?.size&&n.cli.some(e=>r.has(e))||n.filePath&&t?.readFileState&&Lx(t.readFileState).some(e=>n.filePath.test(e)))}var FV=[{id:`new-user-warmup`,content:async()=>`Start with small features or bug fixes, tell Claude to propose a plan, and verify its suggested edits`,cooldownSessions:3,async isRelevant(){return W().numStartups<10}},{id:`plan-mode-for-complex-tasks`,content:async()=>`Use Plan Mode to prepare for a complex request before making changes. Press ${z_(`chat:cycleMode`,`Chat`,`shift+tab`)} twice to enable.`,cooldownSessions:5,isRelevant:async()=>{let e=W();return(e.lastPlanModeUse?(Date.now()-e.lastPlanModeUse)/(1e3*60*60*24):1/0)>7}},{id:`default-permission-mode-config`,content:async()=>`Use /config to change your default permission mode (including Plan Mode)`,cooldownSessions:10,isRelevant:async()=>{try{let e=W(),t=Tp(),n=!!e.lastPlanModeUse,r=!!t?.permissions?.defaultMode;return n&&!r}catch(e){return vb(`Failed to check default-permission-mode-config tip relevance: ${e}`,{level:`warn`}),!1}}},{id:`git-worktrees`,content:async()=>`Use git worktrees to run multiple Claude sessions in parallel.`,cooldownSessions:10,isRelevant:async()=>{try{let e=W();return await ei()<=1&&e.numStartups>50}catch{return!1}}},{id:`color-when-multi-clauding`,content:async()=>`Running multiple Claude sessions? Use /color and /rename to tell them apart at a glance.`,cooldownSessions:10,isRelevant:async()=>kv()?!1:await Bl()>=2},{id:`terminal-setup`,content:async()=>ka.terminal===`Apple_Terminal`?`Run /terminal-setup to enable convenient terminal integration like Option + Enter for new line and more`:`Run /terminal-setup to enable convenient terminal integration like Shift + Enter for new line and more`,cooldownSessions:10,async isRelevant(){let e=W();return ka.terminal===`Apple_Terminal`?!e.optionAsMetaKeyInstalled:!e.shiftEnterKeyBindingInstalled}},{id:`shift-enter`,content:async()=>ka.terminal===`Apple_Terminal`?`Press Option+Enter to send a multi-line message`:`Press Shift+Enter to send a multi-line message`,cooldownSessions:10,async isRelevant(){let e=W();return!!((ka.terminal===`Apple_Terminal`?e.optionAsMetaKeyInstalled:e.shiftEnterKeyBindingInstalled)&&e.numStartups>3)}},{id:`shift-enter-setup`,content:async()=>ka.terminal===`Apple_Terminal`?`Run /terminal-setup to enable Option+Enter for new lines`:`Run /terminal-setup to enable Shift+Enter for new lines`,cooldownSessions:10,async isRelevant(){if(!cS())return!1;let e=W();return!(ka.terminal===`Apple_Terminal`?e.optionAsMetaKeyInstalled:e.shiftEnterKeyBindingInstalled)}},{id:`memory-command`,content:async()=>`Use /memory to view and manage Claude memory`,cooldownSessions:15,async isRelevant(){return W().memoryUsageCount<=0}},{id:`theme-command`,content:async()=>`Use /theme to change the color theme`,cooldownSessions:20,isRelevant:async()=>!0},{id:`colorterm-truecolor`,content:async()=>`Try setting environment variable COLORTERM=truecolor for richer colors`,cooldownSessions:30,isRelevant:async()=>!process.env.COLORTERM&&P.level<3},{id:`powershell-tool-env`,content:async()=>`PowerShell is the default shell on Windows. Set CLAUDE_CODE_USE_POWERSHELL_TOOL=0 or defaultShell=bash to prefer Bash/Git Bash instead.`,cooldownSessions:20,isRelevant:async()=>Di()===`windows`&&process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL===void 0&&Tp().defaultShell===void 0},{id:`status-line`,content:async()=>`Use /statusline to set up a custom status line that will display beneath the input box`,cooldownSessions:25,isRelevant:async()=>Tp().statusLine===void 0},{id:`prompt-queue`,content:async()=>`Hit Enter to queue up additional messages while Claude is working.`,cooldownSessions:5,async isRelevant(){return W().promptQueueUseCount<=3}},{id:`enter-to-steer-in-relatime`,content:async()=>`Send messages to Claude while it works to steer Claude in real-time`,cooldownSessions:20,isRelevant:async()=>!0},{id:`todo-list`,content:async()=>`Ask Claude to create a todo list when working on complex tasks to track progress and remain on track`,cooldownSessions:20,isRelevant:async()=>!0},{id:`vscode-command-install`,content:async()=>`Open the Command Palette (Cmd+Shift+P) and run "Shell Command: Install '${ka.terminal===`vscode`?`code`:ka.terminal}' command in PATH" to enable IDE integration`,cooldownSessions:0,async isRelevant(){if(!wo()||Di()!==`macos`)return!1;switch(ka.terminal){case`vscode`:return!await Bd();case`cursor`:return!await hc();case`windsurf`:return!await oc();default:return!1}}},{id:`ide-upsell-external-terminal`,content:async()=>`Connect Claude to your IDE · /ide`,cooldownSessions:4,async isRelevant(){return mb()||(await Lh()).length!==0?!1:(await ql()).length>0}},{id:`install-github-app`,content:async()=>`Run /install-github-app to tag @claude right from your Github issues and PRs`,cooldownSessions:10,isRelevant:async()=>!W().githubActionSetupCount},{id:`install-slack-app`,content:async()=>`Run /install-slack-app to use Claude in Slack`,cooldownSessions:10,isRelevant:async()=>!W().slackAppInstallCount},{id:`permissions`,content:async()=>`Use /permissions to pre-approve and pre-deny bash, edit, and MCP tools`,cooldownSessions:10,async isRelevant(){return W().numStartups>10}},{id:`drag-and-drop-images`,content:async()=>`Did you know you can drag and drop image files into your terminal?`,cooldownSessions:10,isRelevant:async()=>!ka.isSSH()},{id:`paste-images-mac`,content:async()=>`Paste images into Claude Code using control+v (not cmd+v!)`,cooldownSessions:10,isRelevant:async()=>Di()===`macos`},{id:`double-esc`,content:async()=>`Double-tap esc to rewind the conversation to a previous point in time`,cooldownSessions:10,isRelevant:async()=>!_c()},{id:`double-esc-code-restore`,content:async()=>`Double-tap esc to rewind the code and/or conversation to a previous point in time`,cooldownSessions:10,isRelevant:async()=>_c()},{id:`continue`,content:async()=>`Run ccb --continue or ccb --resume to resume a conversation`,cooldownSessions:10,isRelevant:async()=>!0},{id:`rename-conversation`,content:async()=>`Name your conversations with /rename to find them easily in /resume later`,cooldownSessions:15,isRelevant:async()=>Ju()&&W().numStartups>10},{id:`custom-commands`,content:async()=>`Create skills by adding .md files to .claude/skills/ in your project or ~/.claude/skills/ for skills that work in any project`,cooldownSessions:15,async isRelevant(){return W().numStartups>10}},{id:`shift-tab`,content:async()=>`Hit ${z_(`chat:cycleMode`,`Chat`,`shift+tab`)} to cycle between default, accept edits, plan, auto, and bypass modes`,cooldownSessions:10,isRelevant:async()=>!0},{id:`image-paste`,content:async()=>`Use ${z_(`chat:imagePaste`,`Chat`,`ctrl+v`)} to paste images from your clipboard`,cooldownSessions:20,isRelevant:async()=>!0},{id:`custom-agents`,content:async()=>`Use /agents to optimize specific tasks. Eg. Software Architect, Code Writer, Code Reviewer`,cooldownSessions:15,async isRelevant(){return W().numStartups>5}},{id:`agent-flag`,content:async()=>`Use --agent <agent_name> to directly start a conversation with a subagent`,cooldownSessions:15,async isRelevant(){return W().numStartups>5}},{id:`desktop-app`,content:async()=>`Run Claude Code locally or remotely using the Claude desktop app: clau.de/desktop`,cooldownSessions:15,isRelevant:async()=>Di()!==`linux`},{id:`desktop-shortcut`,content:async e=>`Continue your session in Claude Code Desktop with ${Oe(`suggestion`,e?.theme??`dark`)(`/desktop`)}`,cooldownSessions:15,isRelevant:async()=>ST().enable_shortcut_tip?process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`:!1},{id:`web-app`,content:async()=>`Run tasks in the cloud while you keep coding locally · clau.de/web`,cooldownSessions:15,isRelevant:async()=>!0},{id:`mobile-app`,content:async()=>`/mobile to use Claude Code from the Claude app on your phone`,cooldownSessions:15,isRelevant:async()=>!0},{id:`opusplan-mode-reminder`,content:async()=>`Your default model setting is Opus Plan Mode. Press ${z_(`chat:cycleMode`,`Chat`,`shift+tab`)} twice to activate Plan Mode and plan with Claude Opus.`,cooldownSessions:2,async isRelevant(){if(process.env.USER_TYPE===`ant`)return!1;let e=W(),t=ur()===`opusplan`,n=e.lastPlanModeUse?(Date.now()-e.lastPlanModeUse)/(1e3*60*60*24):1/0;return t&&n>3}},{id:`frontend-design-plugin`,content:async e=>`Working with HTML/CSS? Install the frontend-design plugin:\n${Oe(`suggestion`,e?.theme??`dark`)(`/plugin install frontend-design@${Hh}`)}`,cooldownSessions:3,isRelevant:async e=>PV(`frontend-design`,e,{filePath:/\.(html|css|htm)$/i})},{id:`vercel-plugin`,content:async e=>`Working with Vercel? Install the vercel plugin:\n${Oe(`suggestion`,e?.theme??`dark`)(`/plugin install vercel@${Hh}`)}`,cooldownSessions:3,isRelevant:async e=>PV(`vercel`,e,{filePath:/(?:^|[/\\])vercel\.json$/i,cli:[`vercel`]})},{id:`effort-high-nudge`,content:async e=>{let t=Oe(`suggestion`,e?.theme??`dark`)(`/effort high`);return Jn(`tengu_tide_elm`,`off`)===`copy_b`?`Use ${t} for better one-shot answers. Claude thinks it through first.`:`Working on something tricky? ${t} gives better first answers`},cooldownSessions:3,isRelevant:async()=>{if(!mr()||!cc(sn())||$_(`policySettings`)?.effortLevel!==void 0||js()!==void 0)return!1;let e=Mv().effortLevel;return e===`high`||e===`max`?!1:Jn(`tengu_tide_elm`,`off`)!==`off`}},{id:`subagent-fanout-nudge`,content:async e=>{let t=Oe(`suggestion`,e?.theme??`dark`);return Jn(`tengu_tern_alloy`,`off`)===`copy_b`?`For big tasks, tell Claude to ${t(`use subagents`)}. They work in parallel and keep your main thread clean.`:`Say ${t(`"fan out subagents"`)} and Claude sends a team. Each one digs deep so nothing gets missed.`},cooldownSessions:3,isRelevant:async()=>mr()?Jn(`tengu_tern_alloy`,`off`)!==`off`:!1},{id:`loop-command-nudge`,content:async e=>{let t=Oe(`suggestion`,e?.theme??`dark`);return Jn(`tengu_timber_lark`,`off`)===`copy_b`?`Use ${t(`/loop 5m check the deploy`)} to run any prompt on a schedule. Set it and forget it.`:`${t(`/loop`)} runs any prompt on a recurring schedule. Great for monitoring deploys, babysitting PRs, or polling status.`},cooldownSessions:3,isRelevant:async()=>!mr()||!Cb()?!1:Jn(`tengu_timber_lark`,`off`)!==`off`},{id:`guest-passes`,content:async e=>{let t=Oe(`claude`,e?.theme??`dark`),n=kS();return n?`Share Claude Code and earn ${t(AS(n))} of extra usage · ${t(`/passes`)}`:`You have free guest passes to share · ${t(`/passes`)}`},cooldownSessions:3,isRelevant:async()=>{if(W().hasVisitedPasses)return!1;let{eligible:e}=MS();return e}},{id:`overage-credit`,content:async e=>{let t=Oe(`claude`,e?.theme??`dark`),n=sw(),r=n?lw(n):null;return r?`${t(`${r} in extra usage, on us`)} · third-party apps · ${t(`/extra-usage`)}`:``},cooldownSessions:3,isRelevant:async()=>dw()},{id:`feedback-command`,content:async()=>`Use /feedback to help us improve!`,cooldownSessions:15,async isRelevant(){return process.env.USER_TYPE===`ant`?!1:W().numStartups>5}}],IV=process.env.USER_TYPE===`ant`?[{id:`important-claudemd`,content:async()=>`[ANT-ONLY] Use "IMPORTANT:" prefix for must-follow CLAUDE.md rules`,cooldownSessions:30,isRelevant:async()=>!0},{id:`skillify`,content:async()=>`[ANT-ONLY] Use /skillify at the end of a workflow to turn it into a reusable skill`,cooldownSessions:15,isRelevant:async()=>!0}]:[];function LV(){let e=Mv().spinnerTipsOverride;return e?.tips?.length?e.tips.map((e,t)=>({id:`custom-tip-${t}`,content:async()=>e,cooldownSessions:0,isRelevant:async()=>!0})):[]}async function RV(e){let t=Mv().spinnerTipsOverride,n=LV();if(t?.excludeDefault&&n.length>0)return n;let r=[...FV,...IV],i=await Promise.all(r.map(t=>t.isRelevant?.(e)??Promise.resolve(!0)));return[...r.filter((e,t)=>i[t]).filter(e=>wT(e.id)>=e.cooldownSessions),...n]}Lt(),aa();function zV(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:wT(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function BV(e){if(cn().spinnerTipsEnabled===!1)return;let t=await RV(e);if(t.length!==0)return zV(t)}function VV(e){CT(e.id),Y(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}Vr(),vi(),Ke(),tb(),gy();var HV=!1;async function UV(e,t,n){{if(HV)return;HV=!0;let{updateContext:r,notification:i}=await Jc(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 WV(){HV=!1}function GV(){let e=X(e=>e.mainLoopModel),t=X(e=>e.mainLoopModelForSession),n=X(e=>e.fastMode),r=Zs(),i=Md(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{tt()||(a.current?a.current=!1:WV(),UV(i.getState().toolPermissionContext,r,n).catch(e=>{yi(Error(`Auto mode gate check failed`,{cause:Lr(e)}))}))},[e,t,n])}cm();function KV(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!o_()||r.current||(r.current=!0,e&&lg(e,n))},[t,e,n])}H(),Ad(),aa(),ob(),TC();function qV({hostPattern:{host:e},onUserResponse:t}){function n(n){switch(process.env.USER_TYPE===`ant`&&Y(`tengu_sandbox_network_dialog_result`,{host:e,result:n}),n){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...Xs()?[]:[{label:(0,$.jsxs)(z,{children:[`Yes, and don't ask again for `,(0,$.jsx)(z,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(z,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(z,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(EC,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(z,{children:[` `,e]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(ku,{options:r,onChange:n,onCancel:()=>{process.env.USER_TYPE===`ant`&&Y(`tengu_sandbox_network_dialog_result`,{host:e,result:`cancel`}),t({allow:!1,persistToSettings:!1})}})})]})})}H(),Wm();function JV(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function YV(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=u_.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!u_.isSandboxingEnabled()||Hx()===`linux`||n===0?null:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(U,{marginLeft:0,children:(0,$.jsxs)(z,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(z,{dimColor:!0,children:[JV(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(z,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}Ah(),Ke(),Tu();var XV=`settings-errors`;function ZV(){let{addNotification:e,removeNotification:t}=ul(),[n,r]=(0,Q.useState)(()=>{let{errors:e}=Yc();return e});return Og((0,Q.useCallback)(()=>{let{errors:e}=Yc();r(e)},[])),(0,Q.useEffect)(()=>{tt()||(n.length>0?e({key:XV,text:`Found ${n.length} settings ${n.length===1?`issue`:`issues`} · /doctor for details`,color:`warning`,priority:`high`,timeoutMs:6e4}):t(XV))},[n,e,t]),n}Ah(),Ke(),H();var QV=[];function $V({mcpClients:e=QV}){let{addNotification:t}=ul();(0,Q.useEffect)(()=>{if(tt())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`&&zv(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`&&zv(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)(z,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(z,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(z,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(z,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}H(),Lt(),py();var eH=`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.`;j(),Ke(),Fs(),H(),tb(),K(),l();var tH=5e3;function nH(){let{addNotification:e}=Ic(),t=Zs(),[n,r]=Q.useState(()=>u(`true`)),i=Q.useRef(new Set),a=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)(z,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),o=Q.useCallback(()=>{if(tt()||We())return;let e=__();if(e.status===`failed`){a(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=Cg();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&a(t,n.lastError.message)}},[a]);ue(o,n?tH:null),Q.useEffect(()=>{tt()||!n||o()},[o,n])}K();var rH=new Map;async function iH(e){if(!e||!e.trim())return q(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=rH.get(t);if(n!==void 0)return q(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Ti(t).catch(()=>null)&&(r=!0),rH.set(t,r),q(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}mn(),K(),Au(),Ha();var aH=5;function oH(e){return on.has(e.toLowerCase())}function sH(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=lH(t);if(e)return e}return null}return lH(e)}function cH(e){return typeof e==`object`&&!!e}function lH(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!cH(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(cH(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function uH(){let e=new Map;try{let t=await wm();for(let n of Object.keys(t))try{let t=await lf(n),r=oH(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=sH(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 dH(e){if(mH())return q(`[lspRecommendation] Recommendations are disabled`),[];let t=JT(e).toLowerCase();if(!t)return q(`[lspRecommendation] No file extension found`),[];q(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await uH(),r=W().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(nc(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 iH(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 fH(e){Dr(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),q(`[lspRecommendation] Added ${e} to never suggest`)}function pH(){Dr(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),q(`[lspRecommendation] Incremented ignored count`)}function mH(){let e=W();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=aH}m(),Ke(),H(),vi(),Ha();function hH(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{tt()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(yi).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function gH(e,t,n,r,i){try{let a=await hu(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(z,{color:`success`,children:[h.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){yi(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(z,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ke(),Fs(),tb(),mn(),K(),vi(),Lt();var _H=28e3;function vH(){let e=X(e=>e.fileHistory.trackedFiles),{addNotification:t}=Ic(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=hH();return Q.useEffect(()=>{a(async()=>{if(Ot())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 dH(e))[0];if(t)return q(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),it(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:JT(e),shownAt:Date.now()}}catch(e){yi(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`:gH(n,a,`lsp-plugin`,t,async e=>{q(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?YT(e.marketplaceInstallLocation,e.entry.source):void 0;await Wu(n,e.entry,`user`,void 0,t),Ut(`userSettings`,{enabledPlugins:{...en(`userSettings`)?.enabledPlugins,[n]:!0}}),q(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=_H&&(q(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),pH());break}case`never`:fH(n);break;case`disable`:Dr(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}H(),ob(),TC();var yH=3e4;function bH({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`),yH,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)(EC,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(z,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(z,{children:[` `,e]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{dimColor:!0,children:t})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(z,{children:[` `,n,` files`]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(ku,{options:[{label:(0,$.jsxs)(z,{children:[`Yes, install `,(0,$.jsx)(z,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(z,{children:[`Never for `,(0,$.jsx)(z,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Zn(),aa(),sy(),mn(),K(),Au(),Ha();async function xH(e){let t=e.value,{name:n,marketplace:r}=Yb(t),i=await hu(t);return Y(`tengu_plugin_hint_detected`,{_PROTO_plugin_name:n??``,_PROTO_marketplace_name:r??``,result:i?`passed`:`not_in_cache`}),i?{pluginId:t,pluginName:i.entry.name,marketplaceName:r??``,pluginDescription:i.entry.description,sourceCommand:e.sourceCommand}:(q(`[hintRecommendation] ${t} not found in marketplace cache`),null)}function SH(e){Dr(t=>{let n=t.claudeCodeHints?.plugin??[];return n.includes(e)?t:{...t,claudeCodeHints:{...t.claudeCodeHints,plugin:[...n,e]}}})}function CH(){Dr(e=>e.claudeCodeHints?.disabled?e:{...e,claudeCodeHints:{...e.claudeCodeHints,disabled:!0}})}Fs(),aa(),sy(),K(),Cy();function wH(){let e=Q.useSyncExternalStore(Mp,Zf),{addNotification:t}=Ic(),{recommendation:n,clearRecommendation:r,tryResolve:i}=hH();return Q.useEffect(()=>{e&&i(async()=>{let t=await xH(e);return t&&(q(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Yy()),Zf()===e&&Jm(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(SH(n.pluginId),Y(`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;gH(e,r,`hint-plugin`,t,async t=>{let n=await rd({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`:CH();break;case`no`:break}r()}},[n,t,r])}}H(),ob(),TC();var TH=3e4;function EH({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`),TH,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)(EC,{title:`Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(z,{dimColor:!0,children:[`The `,(0,$.jsx)(z,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(z,{children:[` `,e]})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(z,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(z,{children:[` `,n]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(z,{dimColor:!0,children:t})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{children:`Would you like to install it?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(ku,{options:[{label:(0,$.jsxs)(z,{children:[`Yes, install `,(0,$.jsx)(z,{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`)})})]})})}ob(),TC();var DH=3e4;function OH({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(),DH,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)(EC,{title:`Tool Recommendation`,children:(0,$.jsx)(ku,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}eu(),K(),ws();var kH=[],AH=new Set;function jH(){for(let e of AH)e()}function MH(e){return AH.add(e),()=>{AH.delete(e)}}function NH(){return kH}function PH(){kH=[],jH()}var FH=.15,IH=3;function LH(){let e=Q.useSyncExternalStore(MH,NH),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,IH).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)>=FH,handleSelect:Q.useCallback(e=>{PH()},[]),handleDismiss:Q.useCallback(()=>{PH()},[])}}H(),Zn(),aa(),mn(),ob(),fw(),TC();var RH={enable_shortcut_tip:!1,enable_startup_dialog:!1};function zH(){return Sn(`tengu_desktop_upsell`,RH)}function BH(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function VH(){if(!BH()||!zH().enable_startup_dialog)return!1;let e=W();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function HH({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(W().desktopUpsellSeenCount??0)+1;Dr(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),Y(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(pw,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:Dr(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(EC,{title:`Try Claude Code Desktop`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(z,{children:`Same Claude Code with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(ku,{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`)})]})})}Ke(),Fs(),H(),tb(),K(),Zi();function UH(){let{addNotification:e}=Ic(),t=X(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(!tt()){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)(z,{color:`error`,children:[n,` `,Qi(n,`plugin`),` failed to install`]}),(0,$.jsx)(z,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}Ke(),Fs(),H(),K(),Kw();function WH(){let{addNotification:e}=Ic(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!tt())return qw(e=>{q(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(tt()||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)(z,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(z,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),q(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}K(),vi(),Ha(),$w(),aa();function GH(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 KH(e){q(`performBackgroundPluginInstallations called`);try{let t=LT(Cf(),await wm().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 RT({onProgress:t=>{switch(t.type){case`installing`:GH(e,t.name,`installing`);break;case`installed`:GH(e,t.name,`installed`);break;case`failed`:GH(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(Y(`tengu_marketplace_background_install`,i),Xr(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){wc(),q(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Qw(e)}catch(t){yi(t),q(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),vg(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(wc(),vg(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){yi(e)}}mn(),K(),Ha(),oy();async function qH(e){if(q(`performStartupChecks called`),!G()){q(`Trust not accepted for current directory - skipping plugin installations`);return}try{q(`Starting background plugin installations`),await Oh()&&(wc(),vg(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await KH(e)}catch(e){q(`Error initiating background plugin installations: ${e}`)}}ci(),Jt(),Lf(),nd(),wf(),j_(),Us(),xd(),zd(),ub(),el(),El(),Fh(),Yh();function JH({addMargin:t,param:n,verbose:r,planContent:i,isTranscriptMode:a,timestamp:o}){if(n.text.trim()===`(no content)`)return null;if(i)return(0,$.jsx)(pc,{addMargin:t,planContent:i});if(Tl(n.text,`tick`)||n.text.includes(`<local-command-caveat>`))return null;if(n.text.startsWith(`<bash-stdout`)||n.text.startsWith(`<bash-stderr`))return(0,$.jsx)(Jd,{content:n.text,verbose:r});if(n.text.startsWith(`<local-command-stdout`)||n.text.startsWith(`<local-command-stderr`))return(0,$.jsx)(bo,{content:n.text});if(n.text===`[Request interrupted by user]`||n.text===`[Request interrupted by user for tool use]`)return(0,$.jsx)(ec,{height:1,children:(0,$.jsx)(Sy,{})});if(n.text.includes(`<bash-input>`))return(0,$.jsx)(Uc,{addMargin:t,param:n});if(n.text.includes(`<command-message>`))return(0,$.jsx)(ic,{addMargin:t,param:n});if(n.text.includes(`<user-memory-input>`))return(0,$.jsx)(Nu,{addMargin:t,text:n.text});if(Gn()&&n.text.includes(`<teammate-message`))return(0,$.jsx)(Gl,{addMargin:t,param:n,isTranscriptMode:a});if(n.text.includes(`<task-notification`))return(0,$.jsx)(Ec,{addMargin:t,param:n});if(n.text.includes(`<mcp-resource-update`)||n.text.includes(`<mcp-polling-update`))return(0,$.jsx)(so,{addMargin:t,param:n});if(n.text.includes(`<fork-boilerplate>`)){let{UserForkBoilerplateMessage:r}=(Xo(),e(fs));return(0,$.jsx)(r,{addMargin:t,param:n,isTranscriptMode:a,timestamp:o})}if(n.text.includes(`<channel source="`)){let{UserChannelMessage:r}=(ad(),e(Ty));return(0,$.jsx)(r,{addMargin:t,param:n})}return(0,$.jsx)(pl,{addMargin:t,param:n,isTranscriptMode:a,timestamp:o})}H();var YH=/https?:\/\/\S+/;function XH(){let[e,t]=(0,Q.useState)(Vn.getInstance().getStatus());return(0,Q.useEffect)(()=>Vn.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(z,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(YH);if(!n)return(0,$.jsx)(z,{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)(z,{dimColor:!0,children:[a,(0,$.jsx)(ae,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(z,{color:`error`,children:e.error})})]})}Ah(),H(),Qg(),dp(),Ke();function ZH(e){let{addNotification:t}=ul(),n=iv(),r=(0,Q.useMemo)(()=>bc(n,e),[n,e]),i=(0,Q.useMemo)(()=>yf(n),[n]),a=(0,Q.useRef)(null),o=cr(),s=xh(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{tt()||(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)(()=>{tt()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(z,{children:(0,$.jsx)(z,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}jt();var QH={"claude-3-opus":{modelName:`Claude 3 Opus`,retirementDates:{firstParty:`January 5, 2026`,bedrock:`January 15, 2026`,vertex:`January 5, 2026`,foundry:`January 5, 2026`}},"claude-3-7-sonnet":{modelName:`Claude 3.7 Sonnet`,retirementDates:{firstParty:`February 19, 2026`,bedrock:`April 28, 2026`,vertex:`May 11, 2026`,foundry:`February 19, 2026`}},"claude-3-5-haiku":{modelName:`Claude 3.5 Haiku`,retirementDates:{firstParty:`February 19, 2026`,bedrock:null,vertex:null,foundry:null}}};function $H(e){let t=e.toLowerCase(),n=Wn();for(let[e,r]of Object.entries(QH)){let i=r.retirementDates[n];if(!(!t.includes(e)||!i))return{isDeprecated:!0,modelName:r.modelName,retirementDate:i}}return{isDeprecated:!1}}function eU(e){if(!e)return null;let t=$H(e);return t.isDeprecated?`⚠ ${t.modelName} will be retired on ${t.retirementDate}. Consider switching to a newer model.`:null}Ah(),Ke();function tU(e){let{addNotification:t}=ul(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(tt())return;let r=eU(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])}jg(),mn(),qr(),l(),xi(),Hr(),za(),T_(),Oi(),Kb(),Wm(),Fr(),Ei();function nU(){let e=process.argv[1]||``,t=process.execPath||process.argv[0]||``;return Di()===`windows`&&(e=e.split(eE.sep).join(XT.sep),t=t.split(eE.sep).join(XT.sep)),[e,t]}async function rU(){let[e]=nU();if(Ta())return $s()||Bc()||gd()||ho()||await Ud()||await Pd()||await Rs()||await rb()?`package-manager`:`native`;if(Sm())return`npm-local`;if([`/usr/local/lib/node_modules`,`/usr/lib/node_modules`,`/opt/homebrew/lib/node_modules`,`/opt/homebrew/bin`,`/usr/local/bin`,`/.nvm/versions/node/`].some(t=>e.includes(t))||e.includes(`/npm/`)||e.includes(`/nvm/`))return`npm-global`;let t=await oi(`npm config get prefix`,{shell:!0,reject:!1}),n=t.exitCode===0?t.stdout.trim():null;return n&&e.startsWith(n)?`npm-global`:`unknown`}var iU=``;function aU(){dV(async()=>B_()||Ca(process.env.DISABLE_INSTALLATION_CHECKS)||await rU()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:iU,color:`warning`,priority:`high`})}ai(),a(),Ke(),Sp(),mn(),Da(),l(),xi(),Hr(),vi(),Oi(),K(),Vr(),Dc(),Fr();function oU(e){try{return process.kill(e,0),!0}catch{return!1}}function sU(){let e=null;return()=>(e||(e=ja(process.ppid,10).then(e=>new Set(e))),e)}var cU={cursor:{ideKind:`vscode`,displayName:`Cursor`,processKeywordsMac:[`Cursor Helper`,`Cursor.app`],processKeywordsWindows:[`cursor.exe`],processKeywordsLinux:[`cursor`]},windsurf:{ideKind:`vscode`,displayName:`Windsurf`,processKeywordsMac:[`Windsurf Helper`,`Windsurf.app`],processKeywordsWindows:[`windsurf.exe`],processKeywordsLinux:[`windsurf`]},vscode:{ideKind:`vscode`,displayName:`VS Code`,processKeywordsMac:[`Visual Studio Code`,`Code Helper`],processKeywordsWindows:[`code.exe`],processKeywordsLinux:[`code`]},intellij:{ideKind:`jetbrains`,displayName:`IntelliJ IDEA`,processKeywordsMac:[`IntelliJ IDEA`],processKeywordsWindows:[`idea64.exe`],processKeywordsLinux:[`idea`,`intellij`]},pycharm:{ideKind:`jetbrains`,displayName:`PyCharm`,processKeywordsMac:[`PyCharm`],processKeywordsWindows:[`pycharm64.exe`],processKeywordsLinux:[`pycharm`]},webstorm:{ideKind:`jetbrains`,displayName:`WebStorm`,processKeywordsMac:[`WebStorm`],processKeywordsWindows:[`webstorm64.exe`],processKeywordsLinux:[`webstorm`]},phpstorm:{ideKind:`jetbrains`,displayName:`PhpStorm`,processKeywordsMac:[`PhpStorm`],processKeywordsWindows:[`phpstorm64.exe`],processKeywordsLinux:[`phpstorm`]},rubymine:{ideKind:`jetbrains`,displayName:`RubyMine`,processKeywordsMac:[`RubyMine`],processKeywordsWindows:[`rubymine64.exe`],processKeywordsLinux:[`rubymine`]},clion:{ideKind:`jetbrains`,displayName:`CLion`,processKeywordsMac:[`CLion`],processKeywordsWindows:[`clion64.exe`],processKeywordsLinux:[`clion`]},goland:{ideKind:`jetbrains`,displayName:`GoLand`,processKeywordsMac:[`GoLand`],processKeywordsWindows:[`goland64.exe`],processKeywordsLinux:[`goland`]},rider:{ideKind:`jetbrains`,displayName:`Rider`,processKeywordsMac:[`Rider`],processKeywordsWindows:[`rider64.exe`],processKeywordsLinux:[`rider`]},datagrip:{ideKind:`jetbrains`,displayName:`DataGrip`,processKeywordsMac:[`DataGrip`],processKeywordsWindows:[`datagrip64.exe`],processKeywordsLinux:[`datagrip`]},appcode:{ideKind:`jetbrains`,displayName:`AppCode`,processKeywordsMac:[`AppCode`],processKeywordsWindows:[`appcode.exe`],processKeywordsLinux:[`appcode`]},dataspell:{ideKind:`jetbrains`,displayName:`DataSpell`,processKeywordsMac:[`DataSpell`],processKeywordsWindows:[`dataspell64.exe`],processKeywordsLinux:[`dataspell`]},aqua:{ideKind:`jetbrains`,displayName:`Aqua`,processKeywordsMac:[],processKeywordsWindows:[`aqua64.exe`],processKeywordsLinux:[]},gateway:{ideKind:`jetbrains`,displayName:`Gateway`,processKeywordsMac:[],processKeywordsWindows:[`gateway64.exe`],processKeywordsLinux:[]},fleet:{ideKind:`jetbrains`,displayName:`Fleet`,processKeywordsMac:[],processKeywordsWindows:[`fleet.exe`],processKeywordsLinux:[]},androidstudio:{ideKind:`jetbrains`,displayName:`Android Studio`,processKeywordsMac:[`Android Studio`],processKeywordsWindows:[`studio64.exe`],processKeywordsLinux:[`android-studio`]}};function lU(e){if(!e)return!1;let t=cU[e];return t&&t.ideKind===`vscode`}function uU(e){if(!e)return!1;let t=cU[e];return t&&t.ideKind===`jetbrains`}var dU=i(()=>lU(ka.terminal)),fU=i(()=>uU(Bt.terminal)),pU=i(()=>dU()||fU()||!!process.env.FORCE_CODE_TERMINAL);async function mU(){try{let e=await vU();return(await Promise.all(e.map(async e=>{try{let t=(await Ur().readdir(e)).filter(e=>e.name.endsWith(`.lock`));return(await Promise.all(t.map(async t=>{let n=YT(e,t.name);try{return{path:n,mtime:(await Ur().stat(n)).mtime}}catch{return null}}))).filter(e=>e!==null)}catch(e){return Rr(e)||yi(e),[]}}))).flat().sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).map(e=>e.path)}catch(e){return yi(e),[]}}async function hU(e){try{let t=await Ur().readFile(e,{encoding:`utf-8`}),n=[],r,i,a=!1,o=!1,s;try{let e=Pr(t);e.workspaceFolders&&(n=e.workspaceFolders),r=e.pid,i=e.ideName,a=e.transport===`ws`,o=e.runningInWindows===!0,s=e.authToken}catch{n=t.split(`
99
+ `).map(e=>e.trim())}let c=e.split($T).pop();if(!c)return null;let l=c.replace(`.lock`,``);return{workspaceFolders:n,port:parseInt(l,10),pid:r,ideName:i,useWebSocket:a,runningInWindows:o,authToken:s}}catch(e){return yi(e),null}}async function gU(e,t,n=500){try{return new Promise(r=>{let i=pE({host:e,port:t,timeout:n});i.on(`connect`,()=>{i.destroy(),r(!0)}),i.on(`error`,()=>{r(!1)}),i.on(`timeout`,()=>{i.destroy(),r(!1)})})}catch{return!1}}var _U=i(async()=>{if(process.env.USERPROFILE)return process.env.USERPROFILE;let{stdout:e,code:t}=await Si(`powershell.exe`,[`-NoProfile`,`-NonInteractive`,`-Command`,`$env:USERPROFILE`]);if(t===0&&e.trim())return e.trim();q(`Unable to get Windows USERPROFILE via PowerShell - IDE detection may be incomplete`)});async function vU(){let e=[YT(c(),`ide`)];if(Di()!==`wsl`)return e;let t=await _U();if(t){let n=new Wc(process.env.WSL_DISTRO_NAME).toLocalPath(t);e.push(QT(n,`.claude`,`ide`))}try{let t=`/mnt/c/Users`,n=await Ur().readdir(t);for(let r of n)!r.isDirectory()&&!r.isSymbolicLink()||r.name===`Public`||r.name===`Default`||r.name===`Default User`||r.name===`All Users`||e.push(YT(t,r.name,`.claude`,`ide`))}catch(e){Rr(e)?q(`WSL IDE lockfile path detection failed (${e.code}): ${Kr(e)}`):yi(e)}return e}async function yU(e){let t=[];try{let n=process.env.CLAUDE_CODE_SSE_PORT,r=n?parseInt(n,10):null,i=Ye().normalize(`NFC`),a=await mU(),o=await Promise.all(a.map(hU)),s=sU(),c=Di()!==`wsl`&&pU();for(let n of o){if(!n)continue;let a=!1;if(a=u(process.env.CLAUDE_CODE_IDE_SKIP_VALID_CHECK)||n.port===r?!0:n.workspaceFolders.some(e=>{if(!e)return!1;let t=e;if(Di()===`wsl`&&n.runningInWindows&&process.env.WSL_DISTRO_NAME){if(!M_(e,process.env.WSL_DISTRO_NAME))return!1;let n=QT(t).normalize(`NFC`);if(i===n||i.startsWith(n+$T))return!0;t=new Wc(process.env.WSL_DISTRO_NAME).toLocalPath(e)}let r=QT(t).normalize(`NFC`);if(Di()===`windows`){let e=i.replace(/^[a-zA-Z]:/,e=>e.toUpperCase()),t=r.replace(/^[a-zA-Z]:/,e=>e.toUpperCase());return e===t||e.startsWith(t+$T)}return i===r||i.startsWith(r+$T)}),!a&&!e||c&&!(r!==null&&n.port===r)&&(!n.pid||!oU(n.pid)||process.ppid!==n.pid&&!(await s()).has(n.pid)))continue;let o=n.ideName??(pU()?xU(Bt.terminal):`IDE`),l=await SU(n.runningInWindows,n.port),d;d=n.useWebSocket?`ws://${l}:${n.port}`:`http://${l}:${n.port}/sse`,t.push({url:d,name:o,workspaceFolders:n.workspaceFolders,port:n.port,isValid:a,authToken:n.authToken,ideRunningInWindows:n.runningInWindows})}if(!e&&r){let e=t.filter(e=>e.isValid&&e.port===r);if(e.length===1)return e}}catch(e){yi(e)}return t}process.env.USER_TYPE;var bU={code:`VS Code`,cursor:`Cursor`,windsurf:`Windsurf`,antigravity:`Antigravity`,vi:`Vim`,vim:`Vim`,nano:`nano`,notepad:`Notepad`,"start /wait notepad":`Notepad`,emacs:`Emacs`,subl:`Sublime Text`,atom:`Atom`};function xU(e){if(!e)return`IDE`;let t=cU[e];if(t)return t.displayName;let n=bU[e.toLowerCase().trim()];if(n)return n;let r=e.split(` `)[0],i=r?KT(r).toLowerCase():null;return i?bU[i]||er(i):er(e)}var SU=i(async(e,t)=>{if(process.env.CLAUDE_CODE_IDE_HOST_OVERRIDE)return process.env.CLAUDE_CODE_IDE_HOST_OVERRIDE;if(Di()!==`wsl`||!e)return`127.0.0.1`;try{let e=await oi(`ip route show | grep -i default`,{shell:!0,reject:!1});if(e.exitCode===0&&e.stdout){let n=e.stdout.match(/default via (\d+\.\d+\.\d+\.\d+)/);if(n){let e=n[1];if(await gU(e,t))return e}}}catch{}return`127.0.0.1`},(e,t)=>`${e}:${t}`);Ah(),H(),dr(),Ke();var CU=5;function wU({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=ul(),{status:a,ideName:o}=uM(t),s=(0,Q.useRef)(!1),c=n?uU(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(tt())return;if(pU()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Rt().ideHintShownCount??0)>=CU)return;let e=setTimeout((e,t)=>{yU(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Wt(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(z,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(z,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!tt()){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(!tt()){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(!tt()){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])}dr();var TU=[e=>{if(DU(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(DU(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 EU(){dV(()=>{let e=Rt(),t=[];for(let n of TU){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function DU(e){return e!==void 0&&Date.now()-e<3e3}v(),Ln(),dr(),Ma();async function OU(){let e=Rt().oauthAccount?.accountUuid,t=Dn();if(!e||!t)return;let n=`${kn().BASE_API_URL}/api/claude_cli_profile`;try{return(await _.get(n,{headers:{"x-api-key":t,"anthropic-beta":kt},params:{account_uuid:e},timeout:1e4})).data}catch(e){Na(e)}}Ln(),H(),aa(),mn();var kU=3;function AU(){dV(async()=>{if((W().subscriptionNoticeCount??0)>=kU)return null;let e=await jU();return e===null?null:(Dr(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Y(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(z,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`,(0,$.jsxs)(z,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function jU(){if(yn())return null;let e=await OU();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Ke(),Fs(),tb(),xy();function MU(e){if(!(`text`in e))return 1;let t=e.text.match(/^(\d+)/);return t?.[1]?parseInt(t[1],10):1}function NU(e,t){return PU(MU(e)+1)}function PU(e){return{key:`teammate-spawn`,text:e===1?`1 agent spawned`:`${e} agents spawned`,priority:`low`,timeoutMs:5e3,fold:NU}}function FU(e,t){return IU(MU(e)+1)}function IU(e){return{key:`teammate-shutdown`,text:e===1?`1 agent shut down`:`${e} agents shut down`,priority:`low`,timeoutMs:5e3,fold:FU}}function LU(){let e=X(e=>e.tasks),{addNotification:t}=Ic(),n=(0,Q.useRef)(new Set),r=(0,Q.useRef)(new Set);(0,Q.useEffect)(()=>{if(!tt())for(let[i,a]of Object.entries(e))td(a)&&(a.status===`running`&&!n.current.has(i)&&(n.current.add(i),t(PU(1))),a.status===`completed`&&!r.current.has(i)&&(r.current.add(i),t(IU(1))))},[e,t])}Ah(),S_(),ib(),Ke();var RU=`fast-mode-cooldown-started`,zU=`fast-mode-cooldown-expired`,BU=`fast-mode-org-changed`,VU=`fast-mode-overage-rejected`;function HU(){let{addNotification:e}=ul(),t=Z(e=>e.fastMode),n=nf();(0,Q.useEffect)(()=>{if(!tt()&&As())return Do(r=>{r?e({key:BU,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:BU,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!tt()&&As())return hb(t=>{n(e=>({...e,fastMode:!1})),e({key:VU,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(tt()||!t)return;let n=Lu((t,n)=>{let r=UU(n,Zc(t-Date.now(),{hideTrailingZeros:!0}));e({key:RU,invalidates:[zU],text:r,color:`warning`,priority:`immediate`})}),r=sl(()=>{e({key:zU,invalidates:[RU],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function UU(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}`}}H(),Px();function WU({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return De(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(U,{children:(0,$.jsx)(z,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(U,{children:(0,$.jsxs)(z,{dimColor:!0,children:[`Press `,(0,$.jsx)(B,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(z,{dimColor:!0,children:[`Reason: `,n]})})]})}function GU(e){if(process.env.USER_TYPE!==`ant`)return!1;switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function KU(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function qU(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}var JU=()=>null;Cr(),H();function YU(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(U,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(U,{minWidth:2,children:(0,$.jsx)(z,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(z,{children:[(0,$.jsx)(z,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(z,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(z,{dimColor:!0,children:` /issue to report it`})]})]}):null}Ib(),Lf();var XU=[/\bcurl\b/,/\bwget\b/,/\bssh\b/,/\bkubectl\b/,/\bsrun\b/,/\bdocker\b/,/\bbq\b/,/\bgsutil\b/,/\bgcloud\b/,/\baws\b/,/\bgit\s+push\b/,/\bgit\s+pull\b/,/\bgit\s+fetch\b/,/\bgh\s+(pr|issue)\b/,/\bnc\b/,/\bncat\b/,/\btelnet\b/,/\bftp\b/],ZU=[/^no[,!]\s/i,/\bthat'?s (wrong|incorrect|not (what|right|correct))\b/i,/\bnot what I (asked|wanted|meant|said)\b/i,/\bI (said|asked|wanted|told you|already said)\b/i,/\bwhy did you\b/i,/\byou should(n'?t| not)? have\b/i,/\byou were supposed to\b/i,/\btry again\b/i,/\b(undo|revert) (that|this|it|what you)\b/i];function QU(e){for(let t of e){if(t.type!==`assistant`)continue;let e=t.message.content;if(Array.isArray(e))for(let t of e){if(t.type!==`tool_use`||!(`name`in t))continue;let e=t.name;if(e.startsWith(`mcp__`))return!1;if(e===`Bash`){let e=t.input?.command||``;if(XU.some(t=>t.test(e)))return!1}}}return!0}function $U(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=A_(n);if(r)return ZU.some(e=>e.test(r))}return!1}var eW=3,tW=1800*1e3;function nW(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>QU(e)&&$U(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<tW||t<eW||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}Ke(),H();function rW(){return process.env.USER_TYPE===`ant`}function iW(){let[e,t]=(0,Q.useState)(bt);return Me(()=>{t(bt())},rW()?500:null),!rW()||e.length===0?null:(0,$.jsxs)(z,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}IS(),qC(),H(),tb();function aW(e,t=!0){let n=(0,Q.useContext)(Eu)?.setState;(0,Q.useEffect)(()=>{if(!(!t||!n))return n(t=>{if(t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.add(e),{...t,activeOverlays:n}}),()=>{n(t=>{if(!t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.delete(e),{...t,activeOverlays:n}})}},[e,t,n]),(0,Q.useLayoutEffect)(()=>{if(t)return()=>ne.get(process.stdout)?.invalidatePrevFrame()},[t])}m(),H(),Fx(),ob(),tb(),Ke(),Lf(),lp(),fg(),qr(),ki();var oW=24,sW=11;function cW(){return new Date().toISOString().split(`T`)[0]}function lW({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){aW(`ultraplan-choice`);let l=Zs(),{rows:u,columns:d}=ee(),f=Q.useMemo(()=>Math.min(oW,Math.max(1,Math.floor(u/2)-sW)),[u]),p=Q.useMemo(()=>ye(e,Math.max(1,d-4),`wrap`).split(`
100
+ `),[e,d]),m=Math.max(0,p.length-f),[g,_]=Q.useState(0);Q.useEffect(()=>{_(e=>Math.min(e,m))},[m]);let v=p.length>f;je((e,t)=>{if(!v)return;let n=Math.max(1,Math.floor(f/2));if(t.ctrl&&e===`d`||t.wheelDown){let e=t.wheelDown?3:n;_(t=>Math.min(t+e,m))}else if(t.ctrl&&e===`u`||t.wheelUp){let e=t.wheelUp?3:n;_(t=>Math.max(t-e,0))}});let y=p.slice(g,g+f).join(`
101
+ `),b=g>0,x=g<m,S=Q.useCallback(async a=>{switch(a){case`here`:hm({value:[`Ultraplan approved in browser. Here is the plan:`,``,`<ultraplan>`,e,`</ultraplan>`,``,`The user approved this plan in the remote session. Give them a brief summary, then start implementing.`].join(`
102
+ `),mode:`task-notification`});break;case`fresh`:let t=ft(),n=await lE(gp()).then(()=>!0,()=>!1);await YC({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,Ul(`Previous session saved · resume with: ccb --resume ${t}`,`suggestion`)]),hm({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=YT(Jr(),`${cW()}-ultraplan.md`);await uE(t,e,{encoding:`utf-8`}),r(e=>[...e,Ul(`Ultraplan rejected · Plan saved to ${ji(t)}`,`suggestion`)]);break}}Um(n,l,e=>e.status===`running`?{...e,status:`completed`,endTime:Date.now()}:e),l(e=>e.ultraplanPendingChoice?{...e,ultraplanPendingChoice:void 0,ultraplanSessionUrl:void 0}:e),is(t)},[e,t,n,r,o,l,i,s]),C=Q.useMemo(()=>[{label:`Implement here`,value:`here`,description:`Inject plan into the current conversation`},{label:`Start new session`,value:`fresh`,description:`Clear conversation and start with only the plan`},{label:`Cancel`,value:`cancel`,description:`Don't implement — save plan and return`}],[]);return(0,$.jsx)(ve,{title:`Ultraplan approved`,subtitle:`How should the plan be implemented?`,onCancel:()=>{},hideInputGuide:!0,children:(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(z,{children:y}),v&&(0,$.jsxs)(z,{dimColor:!0,children:[b?h.arrowUp:` `,x?h.arrowDown:` `,` `,g+1,`–`,Math.min(g+f,p.length),` of `,p.length,` · ctrl+u/ctrl+d to scroll`]})]}),(0,$.jsx)(ku,{options:C,onChange:e=>void S(e)})]})})}gr(),cg(),lv(),bp();var uW=`simple_plan`,dW={simple_plan:Qv,visual_plan:Wp,three_subagents_with_critique:a_};function fW(e){return e in dW}function pW(){let e=_n(`tengu_ultraplan_prompt_identifier`,uW);return fW(e)?e:uW}var mW={timeEstimate:`a few minutes`,dialogBody:`Interactive planning on the web where you can edit and leave targeted comments on Claude's plan.`,dialogPipeline:`Plan → Edit → Execute`,usageBlurb:[`Remote plan mode with rich web editing experience.`,`Runs in Claude Code on the web. When the plan is ready,`,`you can execute it in the web session or send it back here.`,`You can continue to work while the plan is generated remotely.`]},hW={simple_plan:mW,visual_plan:mW,three_subagents_with_critique:{timeEstimate:`~10–30 min`,dialogBody:`Interactive planning on the web where you can edit and leave targeted comments on Claude's plan.`,dialogPipeline:`Scope → Critique → Edit → Execute`,usageBlurb:[`Advanced multi-agent plan mode.`,`Runs in Claude Code on the web. When the plan is ready,`,`you can execute it in the web session or send it back here.`,`You can continue to work while the plan is generated remotely.`]}};function gW(e){return hW[e??pW()]}H(),ob(),IS(),tb(),mn(),Hg();function _W(){return!W().hasSeenUltraplanTerms}function vW(){return pW()}function yW({onChoice:e}){let[t]=Q.useState(_W),[n]=Q.useState(vW),r=Q.useMemo(()=>gW(n),[n]),i=X(e=>e.replBridgeEnabled),a=Zs(),o=Q.useCallback(r=>{let o=r===`run`&&i;o&&a(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1,replBridgeExplicit:!1,replBridgeOutboundOnly:!1}:e),r!==`cancel`&&t&&Dr(e=>e.hasSeenUltraplanTerms?e:{...e,hasSeenUltraplanTerms:!0}),e(r,{disconnectedBridge:o,promptIdentifier:n})},[e,i,a,t]),s=Q.useCallback(()=>{o(`cancel`)},[o]),c=[{label:`Run ultraplan`,value:`run`,description:i?`Disable remote control and launch in Claude Code on the web`:`launch in Claude Code on the web`},{label:`Not now`,value:`cancel`}];return(0,$.jsx)(ve,{title:`Run ultraplan in the cloud?`,subtitle:r.timeEstimate,onCancel:s,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(z,{dimColor:!0,children:r.dialogBody}),t?(0,$.jsxs)(z,{dimColor:!0,children:[`For more information on Claude Code on the web:`,(0,$.jsx)(ae,{url:Av,children:Av})]}):null]}),(0,$.jsx)(z,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(ku,{options:c,onChange:o})]})})}vw(),H(),mn(),Mm();function bW(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||!(W().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function xW(e){let[t]=ce();(0,Q.useEffect)(()=>{e.setSelectionBgColor(tm(t).selectionBg)},[e,t])}Fs(),H(),Px(),K();var SW=40,CW=.3,wW=6,TW=200,EW=15,DW=15,OW=3,kW=1500,AW=150,jW=5,MW=5,NW=80,PW=3,FW=6,IW=500;function LW(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 RW(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 zW(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>kW&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>TW)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<MW)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/AW),n=Math.max(DW,e.base*2),i=1+(e.mult-1)*t+EW*t;return e.mult=Math.min(n,i,e.mult+OW),Math.floor(e.mult)}if(r>SW)e.mult=e.base;else{let t=Math.max(wW,e.base*2);e.mult=Math.min(t,e.mult+CW)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<MW)return 1;if(!i||r>IW)e.mult=2,e.frac=0;else{let t=.5**(r/AW);e.mult=Math.min(r>=NW?PW:FW,1+(e.mult-1)*t+jW*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function BW(){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 VW(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function HW(){let e=R(),t=BW();return q(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),VW(e,t)}var UW=2,WW=50,GW=200;function KW({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=I(),{addNotification:a}=Ic(),o=(0,Q.useRef)(null);function s(e){let t=_e(),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 Se({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=YW(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=YW(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=HW()),ZW(t,zW(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=HW());let r=XW(t,zW(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}),Se({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=YW(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=YW(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=YW(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=YW(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),je((t,r,i)=>{let a=e.current;if(!a)return;let o=$W(a,QW(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),je((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=RW(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}LW(t)&&i.clearSelection()},{isActive:t}),qW(e,i,t,n),bW(i,t,s),xW(i),null}function qW(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>GW){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(UW,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-UW)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(UW,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(UW)}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,WW)))}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=JW(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 JW(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 YW(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 XW(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 ZW(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function QW(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 $W(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),YW(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),YW(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),YW(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 eG=r({VoiceKeybindingHandler:()=>iG,useVoiceIntegration:()=>nG,useVoiceKeybindingHandler:()=>rG});function tG(e,t){return!((e.key===`space`?` `:e.key===`return`?`enter`:e.key.toLowerCase())!==t.key||e.ctrl!==t.ctrl||e.shift!==t.shift||e.meta!==(t.alt||t.meta)||e.superKey!==t.super)}function nG({setInputValueRaw:e,inputValueRef:t,insertTextRef:n}){let{addNotification:r}=Ic(),i=(0,aG.useRef)(null),a=(0,aG.useRef)(``),o=(0,aG.useRef)(null),s=(0,aG.useCallback)((r,{char:s=` `,anchor:c=!1,floor:l=0}={})=>{let u=t.current,d=n.current?.cursorOffset??u.length,f=u.slice(0,d),p=u.slice(d),m=s===` `?ra(f):f,h=0;for(;h<m.length&&m[m.length-1-h]===s;)h++;let g=Math.max(0,Math.min(h-l,r)),_=h-g,v=f.slice(0,f.length-g),y=``;c&&(i.current=v,a.current=p,p.length>0&&!/^\s/.test(p)&&(y=` `));let b=v+y+p;return c&&(o.current=b),b===u&&g===0||(n.current?n.current.setInputWithCursor(b,v.length):e(b)),_},[e,t,n]),c=(0,aG.useCallback)(()=>{let t=i.current;if(t===null)return;let r=a.current;i.current=null,a.current=``;let o=t+r;n.current?n.current.setInputWithCursor(o,t.length):e(o)},[e,n]),l=dM(),u=Rp(e=>e.voiceState),d=Rp(e=>e.voiceInterimTranscript);(0,aG.useEffect)(()=>{if(u===`recording`&&i.current===null){let e=t.current,r=n.current?.cursorOffset??e.length;i.current=e.slice(0,r),a.current=e.slice(r),o.current=e}u===`idle`&&(i.current=null,a.current=``,o.current=null)},[u,t,n]),(0,aG.useEffect)(()=>{if(i.current===null)return;let r=i.current,s=a.current;if(t.current!==o.current)return;let c=r.length>0&&!/\s$/.test(r)&&d.length>0,l=s.length>0&&!/^\s/.test(s),u=c?` `:``,f=l?` `:``,p=r+u+d+f+s,m=r.length+u.length+d.length;n.current?n.current.setInputWithCursor(p,m):e(p),o.current=p},[d,e,t,n]);let f=(0,aG.useCallback)(r=>{let s=i.current;if(s===null)return;let c=a.current;if(t.current!==o.current)return;let l=s.length>0&&!/\s$/.test(s)&&r.length>0,u=c.length>0&&!/^\s/.test(c)&&r.length>0,d=l?` `:``,f=u?` `:``,p=s+d+r+f+c,m=s.length+d.length+r.length;n.current?n.current.setInputWithCursor(p,m):e(p),o.current=p,i.current=s+d+r},[e,t,n]),p=oG.useVoice({onTranscript:f,onError:e=>{r({key:`voice-error`,text:e,color:`error`,priority:`immediate`,timeoutMs:1e4})},enabled:l,focusMode:!1}),m=(0,aG.useMemo)(()=>{if(i.current===null||d.length===0)return null;let e=i.current,t=e.length>0&&!/\s$/.test(e)&&d.length>0,n=e.length+ +!!t;return{start:n,end:n+d.length}},[d]);return{stripTrailing:s,resetAnchor:c,handleKeyEvent:p.handleKeyEvent,interimRange:m}}function rG({voiceHandleKeyEvent:e,stripTrailing:t,resetAnchor:n,isActive:r}){let i=Kg(),a=ev(),o=he(),s=Id(),c=dM(),l=Rp(e=>e.voiceState),u=(0,aG.useMemo)(()=>{if(!o)return dG;let e=null;for(let t of o.bindings){if(t.context!==`Chat`||t.chord.length!==1)continue;let n=t.chord[0];n&&(t.action===`voice:pushToTalk`?e=n:e!==null&&ge(n,e)&&(e=null))}return e},[o]),d=u!==null&&u.key.length===1&&!u.ctrl&&!u.alt&&!u.shift&&!u.meta&&!u.super?u.key:null,f=(0,aG.useRef)(0),p=(0,aG.useRef)(0),m=(0,aG.useRef)(0),h=(0,aG.useRef)(!1),g=(0,aG.useRef)(null);(0,aG.useEffect)(()=>{l!==`recording`&&(h.current=!1,f.current=0,p.current=0,m.current=0,a(e=>e.voiceWarmingUp?{...e,voiceWarmingUp:!1}:e))},[l,a]);let _=o=>{if(!c||!r||s||u===null)return;let l;if(d!==null){if(o.ctrl||o.meta||o.shift)return;let e=d===` `?ra(o.key):o.key;if(e[0]!==d||e.length>1&&e!==d.repeat(e.length))return;l=e.length}else{if(!tG(o,u))return;l=1}let _=i().voiceState;if(h.current&&_!==`idle`){o.stopImmediatePropagation(),d!==null&&t(l,{char:d,floor:m.current}),e();return}if(_!==`idle`){d===null&&o.stopImmediatePropagation();return}let v=f.current;if(f.current+=l,d===null||f.current>=lG){o.stopImmediatePropagation(),g.current&&(clearTimeout(g.current),g.current=null),f.current=0,h.current=!0,a(e=>e.voiceWarmingUp?{...e,voiceWarmingUp:!1}:e),d===null?(t(0,{anchor:!0}),e(cG)):(m.current=t(p.current+l,{char:d,anchor:!0}),p.current=0,e()),i().voiceState===`idle`&&(h.current=!1,n());return}v>=uG?(o.stopImmediatePropagation(),t(l,{char:d,floor:p.current})):p.current+=l,f.current>=uG&&a(e=>e.voiceWarmingUp?e:{...e,voiceWarmingUp:!0}),g.current&&clearTimeout(g.current),g.current=setTimeout((e,t,n,r)=>{e.current=null,t.current=0,n.current=0,r(e=>e.voiceWarmingUp?{...e,voiceWarmingUp:!1}:e)},sG,g,f,p,a)};return je((e,t,n)=>{let r=new Ne(n.keypress);_(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()},{isActive:r}),{handleKeyDown:_}}function iG(e){return rG(e),null}var aG,oG,sG,cG,lG,uG,dG,fG=t((()=>{aG=n(oe(),1),Fs(),_o(),ap(),H(),Ag(),Zi(),pM(),oG=(hT(),e(mT)),sG=120,cG=2e3,lG=5,uG=2,dG={key:` `,ctrl:!1,alt:!1,shift:!1,meta:!1,super:!1}})),pG=r({useFrustrationDetection:()=>hG});function mG(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function hG(e,t,n,r){let[i,a]=(0,gG.useState)(`closed`),o=W(),s=Ws(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=mG(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(zB(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(Dr(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var gG,_G=t((()=>{gG=n(oe(),1),mn(),Sd(),BB()})),vG=r({useAntOrgWarningNotification:()=>yG});function yG(){}var bG=t((()=>{})),xG=r({useProactive:()=>SG});function SG(e){let t=(0,CG.useRef)(e);t.current=e,(0,CG.useEffect)(()=>{if(!ox())return;let e=null,n=!1,r=!1;function i(){sx(Date.now()+wG),e=setTimeout(()=>{if(e=null,!lx()){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 kp({basePrompt:`<${_i}>${new Date().toLocaleTimeString()}</${_i}>`,currentDir:Jr(),shouldCreate:()=>!n});if(n){await hg({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await hg({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>q(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},wG)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),sx(null)}},[ox(),ux(),cx()])}var CG,wG,TG=t((()=>{CG=n(oe(),1),ci(),qr(),Jf(),K(),wG=3e4})),EG=r({createScheduledTaskQueuedCommand:()=>DG,useScheduledTasks:()=>OG});async function DG(e,t){let n=await Ky({basePrompt:e.prompt,trigger:`scheduled-task`,rootDir:t?.rootDir,currentDir:t?.currentDir??Jr(),sourceId:e.id,sourceLabel:e.prompt,workload:ar,shouldCreate:t?.shouldCreate});return n||q(`[ScheduledTasks] skipping ${e.id}: previous run still queued or running`),n}function OG({isLoading:e,assistantMode:t=!1,setMessages:n}){let r=(0,AG.useRef)(e);r.current=e;let i=Md(),a=Zs();(0,AG.useEffect)(()=>{if(!Cb())return;let e=!1,o=async t=>{let n=await ry({basePrompt:t,trigger:`scheduled-task`,currentDir:Jr(),workload:ar,shouldCreate:()=>!e});if(n){if(e){await Wo(n.autonomy.runId,n.autonomy.rootDir);return}hm(n)}},s=VT({onFire:e=>{o(e).catch(e=>q(`[ScheduledTasks] failed to enqueue missed task prompt: ${e}`,{level:`error`}))},onFireTask:t=>{(async()=>{if(t.agentId){let n=mf(t.agentId,i.getState().tasks);if(n&&!ch(n.status)){let r=await DG(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Wo(r.autonomy.runId,r.autonomy.rootDir);return}!vm(n.id,r.value,{autonomyRunId:r.autonomy?.runId,autonomyRootDir:r.autonomy?.rootDir,origin:r.origin},a)&&r.autonomy?.runId&&await Rl(r.autonomy.runId,`Teammate ${t.agentId} exited before the scheduled message could be delivered.`,r.autonomy.rootDir);return}q(`[ScheduledTasks] teammate ${t.agentId} gone, removing orphaned cron ${t.id}`),WS([t.id]);return}let r=await DG(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Wo(r.autonomy.runId,r.autonomy.rootDir);return}let o=ds(`Running scheduled task (${kG(new Date)})`);n(e=>[...e,o]),hm(r)})().catch(e=>q(`[ScheduledTasks] failed to enqueue task ${t.id}: ${e}`,{level:`error`}))},isLoading:()=>r.current,assistantMode:t,getJitterConfig:IT,isKilled:()=>!Cb()});return s.start(),()=>{e=!0,s.stop()}},[t])}function kG(e){return e.toLocaleString(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).replace(/,? at |, /,` `).replace(/ ([AP]M)/,(e,t)=>t.toLowerCase())}var AG,jG=t((()=>{AG=n(oe(),1),tb(),xg(),Xa(),Fb(),qr(),zT(),BT(),$u(),K(),lp(),Lf(),In()}));function MG(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 NG(e){let t=Xg(e),n=MG(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
103
+ You have an active goal to work on. Continue making progress.
104
+
105
+ ## Active Goal
106
+ ${e.objective}
107
+
108
+ ## Status
109
+ - Elapsed active time: ${t}
110
+ - ${n}
111
+ - ${r}
112
+
113
+ ## Instructions
114
+
115
+ 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.
116
+
117
+ When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
118
+
119
+ ### Completion Audit
120
+ 1. Derive concrete requirements from the objective and any referenced files.
121
+ 2. Preserve the original scope — do not redefine success around what is already done.
122
+ 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
123
+ 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
124
+ 5. Treat uncertain or indirect evidence as "not achieved".
125
+ 6. The audit must PROVE completion, not merely fail to find remaining work.
126
+
127
+ ### Blocked Audit
128
+ If you encounter an obstacle you genuinely cannot overcome:
129
+ - Do NOT mark blocked on the first encounter.
130
+ - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
131
+ - "Difficult", "slow", or "partially incomplete" is NOT blocked.
132
+ - If blocked, use the GoalTool with status "blocked" and a clear reason.
133
+
134
+ Resume working now.
135
+ </goal-steering>`}function PG(e){return`<goal-steering type="budget_limit">
136
+ ## Token Budget Reached
137
+
138
+ Your token budget for this goal has been exhausted.
139
+
140
+ - Goal: ${e.objective}
141
+ - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
142
+ - Active time: ${Xg(e)}
143
+
144
+ **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
145
+
146
+ Instead, provide a brief summary:
147
+ 1. What has been accomplished so far.
148
+ 2. What remains to be done.
149
+ 3. Any blockers or issues encountered.
150
+
151
+ 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.
152
+ </goal-steering>`}var FG=t((()=>{})),IG=r({useGoalContinuation:()=>RG});function LG(e){vb(`[goal] hook: ${e}`)}function RG(e){let t=(0,zG.useRef)(e);t.current=e;let n=(0,zG.useRef)(!1),r=(0,zG.useRef)(!1);(0,zG.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){LG(`skip: queryActiveNow=true`);return}if(e.wasAborted){LG(`skip: wasAborted=true`);return}if(n.current)return;if(Io().length>0){LG(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){LG(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){LG(`skip: planMode`);return}let t=Ga();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=PG(t);vb(`[goal] hook: budget limit reached, injecting wrap-up prompt`),qu({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){LG(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){Vg()&&(Hc(),e.onMaxTurnsReached?.()),vb(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=Tm();Hc();let a=NG(t);vb(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),qu({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 zG,BG=t((()=>{zG=n(oe(),1),yb(),FG(),ms()})),VG=r({AntModelSwitchCallout:()=>HG,shouldShowModelSwitchCallout:()=>UG});function HG(e){return null}function UG(){return!1}var WG=t((()=>{})),GG=r({UndercoverAutoCallout:()=>KG});function KG({onDone:e}){return(0,qG.useEffect)(()=>{e()},[e]),null}var qG,JG=t((()=>{qG=n(oe(),1)}));Ke(),ab(),Li(),m(),H(),Fx(),hC(),Fs(),Wy(),Rx(),Jp(),K(),l(),va(),Jf(),Sx(),zg(),Ef(),Wi(),Xa(),mp(),Vd(),fb(),vs(),gm(),Pg(),Xu(),fm(),_h(),Vr(),vi(),qr(),Ap(),gy(),hs(),Wa(),mn(),Tr(),$i(),gr(),Lf(),BS(),ci(),$f(),Fv(),qS(),f_(),Yv(),Mu(),SC(),tb(),Uo(),Fp(),cm(),nx(),Wh(),xy(),Jt(),su(),fy(),lp(),Uy(),V_(),Ad(),Hg(),kg();var YG=(fG(),e(eG)).useVoiceIntegration,XG=(fG(),e(eG)).VoiceKeybindingHandler,ZG=process.env.USER_TYPE===`ant`?(_G(),e(pG)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),QG=process.env.USER_TYPE===`ant`?(bG(),e(vG)).useAntOrgWarningNotification:()=>{},$G=(Lm(),e(om)).getCoordinatorUserContext,eK=(dx(),e(fx)),tK=e=>()=>{},nK=()=>!1,rK=()=>null,iK=(e,t)=>!1,aK=(TG(),e(xG)).useProactive,oK=(jG(),e(EG)).useScheduledTasks,sK=(BG(),e(IG)).useGoalContinuation,cK=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),lK=()=>({routeToSelectedPipes:()=>!1}),uK=process.env.USER_TYPE===`ant`?(WG(),e(VG)).AntModelSwitchCallout:null,dK=process.env.USER_TYPE===`ant`?(WG(),e(VG)).shouldShowModelSwitchCallout:()=>!1,fK=process.env.USER_TYPE===`ant`?(JG(),e(GG)).UndercoverAutoCallout:null,pK=[],mK=3e3;function hK(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?Math.round((t[n-1]+t[n])/2):t[n]}function gK({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=gv(`app:toggleTranscript`,`Global`,`ctrl+o`),o=gv(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(U,{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)(z,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${h.arrowUp}${h.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{flexGrow:1}),(0,$.jsxs)(z,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{flexGrow:1}),(0,$.jsxs)(z,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function _K({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=aw({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)(U,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(z,{children:`/`}),(0,$.jsx)(z,{children:s.slice(0,f)}),(0,$.jsx)(z,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(z,{children:s.slice(f+1)}),(0,$.jsx)(U,{flexGrow:1}),l===`building`?(0,$.jsx)(z,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(z,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(z,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(z,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var vK=[`⠂`,`⠐`],yK=`✳`,bK=960;function xK({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=fe(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%vK.length),bK,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?vK[a]??yK:yK;return be(n?null:r?t:`${s} ${t}`),null}var SK=`<${hi}>`;function CK(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(SK)}function wK({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:a,initialFileHistorySnapshots:o,initialContentReplacements:s,initialAgentName:c,initialAgentColor:l,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:y=!1,mainThreadAgentDefinition:b,disableSlashCommands:x=!1,taskListId:S,remoteSessionConfig:C,directConnectConfig:w,sshSession:T,thinkingConfig:E}){let D=!!C,k=(0,Q.useMemo)(()=>u(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),A=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&u(process.env.CLAUDE_MORERIGHT),[]),j=(0,Q.useMemo)(()=>u(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>u(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(q(`[REPL:mount] REPL mounted, disabled=${y}`),()=>q(`[REPL:unmount] REPL unmounting`)),[y]);let[N,P]=(0,Q.useState)(b),F=X(e=>e.toolPermissionContext),te=X(e=>e.verbose),I=X(e=>e.mcp),L=X(e=>e.plugins),ne=X(e=>e.agentDefinitions),re=X(e=>e.fileHistory),ae=X(e=>e.initialMessage),oe=VL(),le=X(e=>e.spinnerTip),ue=X(e=>e.expandedView)===`tasks`,pe=X(e=>e.pendingWorkerRequest),R=X(e=>e.pendingSandboxRequest),me=X(e=>e.teamContext),he=X(e=>e.tasks),ge=X(e=>e.workerSandboxPermissions),_e=X(e=>e.elicitation),ve=X(e=>e.ultraplanPendingChoice),B=X(e=>e.ultraplanLaunchPending),ye=X(e=>e.viewingAgentTaskId),V=Zs(),be=ye?he[ye]:void 0,xe=e_(be)&&be.retain&&!be.diskLoaded;(0,Q.useEffect)(()=>{if(!ye||!xe)return;let e=ye;qa($h(e)).then(t=>{V(n=>{let r=n.tasks[e];if(!e_(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}}}})})},[ye,xe,V]);let Se=Md(),Ce=M(),we=xC(),[H,De]=(0,Q.useState)(t);tB(D?void 0:ct(),De);let Oe=Q.useSyncExternalStore(eK?.subscribeToProactiveChanges??tK,eK?.isProactiveActive??nK),ke=Q.useSyncExternalStore(eK?.subscribeToProactiveChanges??tK,eK?.getNextTickAt??rK),Ae=X(e=>e.isBriefOnly),Me=(0,Q.useMemo)(()=>$c(F),[F,Oe,Ae]);GV();let[Ne,Pe]=(0,Q.useState)(f),Ie=(0,Q.useCallback)(e=>{Pe(e)},[Pe]),[ze,Be]=(0,Q.useState)(`prompt`),[He,We]=(0,Q.useState)(!1),[Ge,Ke]=(0,Q.useState)(!1),[qe,Xe]=(0,Q.useState)(``),Ze=(0,Q.useRef)(0),$e=(0,Q.useRef)(void 0),tt=(0,Q.useRef)(!1),{addNotification:rt,removeNotification:it}=Ic(),at=iK,ot=Qz(d,I.clients),[gt,vt]=(0,Q.useState)(void 0),[bt,xt]=(0,Q.useState)(null),[St,Ct]=(0,Q.useState)(null),[Tt,Et]=(0,Q.useState)(!1),[Ot,kt]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`?dK():!1),[At,jt]=(0,Q.useState)(()=>PB(we)),Mt=X(e=>e.showRemoteCallout),[Nt,Pt]=(0,Q.useState)(()=>VH());EU(),AU(),wU({ideSelection:gt,mcpClients:ot,ideInstallationStatus:St}),$V({mcpClients:ot}),UH(),WH(),ZV(),ZH(we),HU(),tU(we),aU(),QG(),fV(),SV(),OV(),nH(),LU();let{recommendation:Ft,handleResponse:It}=vH(),{recommendation:Lt,handleResponse:Rt}=wH(),zt=LH(),Bt=(0,Q.useMemo)(()=>[...Me,...r],[Me,r]);YS({enabled:!D});let Vt=ih();(0,Q.useEffect)(()=>{D||qH(V)},[V,D]),AV(D?pK:ot,F.mode),Tz(V,i,{enabled:!D});let Ht=pC(Bt,I.tools,F),{tools:Ut,allowedAgentTypes:Wt}=(0,Q.useMemo)(()=>{if(!N)return{tools:Ht,allowedAgentTypes:void 0};let e=Zv(N,Ht,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[N,Ht]),Gt=eB(eB(H,L.commands),I.commands),Kt=(0,Q.useMemo)(()=>x?[]:Gt,[x,Gt]);vD(D?pK:I.clients),iB(D?pK:I.clients,vt);let[qt,Jt]=(0,Q.useState)(`responding`),Yt=(0,Q.useRef)(qt);Yt.current=qt;let[Xt,Zt]=(0,Q.useState)([]),[Qt,$t]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Qt&&!Qt.isStreaming&&Qt.streamingEndedAt){let e=3e4-(Date.now()-Qt.streamingEndedAt);if(e>0){let t=setTimeout($t,e,null);return()=>clearTimeout(t)}else $t(null)}},[Qt]);let[en,tn]=(0,Q.useState)(null),nn=(0,Q.useRef)(null);nn.current=en;let rn=(0,Q.useRef)(0),[an,on]=(0,Q.useState)(!1),sn=(0,Q.useRef)(()=>{}),cn=(0,Q.useRef)(()=>{}),ln=(0,Q.useRef)(null),un=(0,Q.useRef)(null),dn=(0,Q.useRef)(0),fn=Q.useRef(new FE).current,pn=Q.useSyncExternalStore(fn.subscribe,fn.getSnapshot),[mn,hn]=Q.useState(C?.hasInitialPrompt??!1),gn=pn||mn,[vn,yn]=Q.useState(void 0),xn=Q.useRef(0),Sn=Q.useRef(!1),Cn=Q.useRef(0),wn=Q.useRef(0),Tn=Q.useRef(null),En=Q.useCallback(()=>{Cn.current=Date.now(),wn.current=0,Tn.current=null},[]),Dn=Q.useRef(!1);pn&&!Dn.current&&En(),Dn.current=pn;let On=Q.useCallback(e=>{hn(e),e&&En()},[En]),kn=Q.useRef(null),An=Q.useRef(void 0),jn=Q.useRef(void 0),[Mn,Nn]=Q.useState(!1),[Pn,Fn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Pn?.notifications&&Pn.notifications.forEach(e=>{rt({key:`auto-updater-notification`,text:e,priority:`low`})})},[Pn,rt]),(0,Q.useEffect)(()=>{gh()&&qg().then(e=>{e&&rt({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[In,Ln]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-DRSKRoH6.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-CVCVOSrs.js`);t()&&Ln(!0)})()},[]);let[Rn,zn]=(0,Q.useState)(null),Bn=(0,Q.useRef)(null),Vn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Bn.current={...n,isLocalJSXCommand:!0},zn(n);return}if(Bn.current){if(e?.clearLocalJSX){Bn.current=null,zn(null),rn.current=Date.now();return}return}if(e?.clearLocalJSX){zn(null);return}zn(e)},[]),[Hn,Un]=(0,Q.useState)([]),[Wn,Kn]=(0,Q.useState)(null),[qn,Jn]=(0,Q.useState)([]),[Yn,Xn]=(0,Q.useState)([]),Zn=(0,Q.useRef)(new Map),Qn=X(e=>e.settings.terminalTitleFromRename)===!1?void 0:Y_(ft()),[$n,er]=(0,Q.useState)(),tr=(0,Q.useRef)((i?.length??0)>0),nr=N?.agentType,rr=Qn??nr??$n??`Claude Code`,ir=Hn.length>0||Yn.length>0||pe||R,ar=Rn?.isLocalJSXCommand===!0&&Rn?.jsx!=null,or=gn&&!ir&&!ar;(0,Q.useEffect)(()=>{if(gn&&!ir&&!ar)return OE(),()=>kE()},[gn,ir,ar]);let sr=ir||ar?`waiting`:gn?`busy`:`idle`,cr=sr===`waiting`?Hn.length>0?`approve ${Hn[0].tool.name}`:pe?`worker request`:R?`sandbox request`:ar?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Mh({status:sr,waitingFor:cr})},[sr,cr]);let lr=_n(`tengu_terminal_sidebar`,!1)&&(W().showStatusInTerminalTab??!1);O(k||!lr?null:sr),(0,Q.useEffect)(()=>(Ed(Un),()=>Ks()),[Un]);let[ur,dr]=(0,Q.useState)(i??[]),fr=(0,Q.useRef)(ur),pr=(0,Q.useRef)(!1),G=(0,Q.useCallback)(e=>{let t=fr.current,n=typeof e==`function`?e(fr.current):e;if(fr.current=n,n.length<xn.current)xn.current=0;else if(n.length>t.length&&Sn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(Ru)?Sn.current=!1:xn.current=n.length}dr(n)},[]),mr=(0,Q.useCallback)(e=>{e===void 0?Sn.current=!1:(xn.current=fr.current.length,Sn.current=!0),yn(e)},[]),{dividerIndex:hr,dividerYRef:gr,onScrollAway:_r,onRepin:vr,jumpToNew:yr,shiftDivider:br}=Cw(ur.length);bV(ur,G,gn);let[Sr,Cr]=(0,Q.useState)(null),wr=(0,Q.useRef)(null),Tr=(0,Q.useMemo)(()=>bw(ur,hr),[hr,ur.length]),Er=(0,Q.useCallback)(()=>{ln.current?.scrollToBottom(),vr(),Cr(null)},[vr,Cr]),Or=ur.at(-1),kr=Or!=null&&Ru(Or);(0,Q.useEffect)(()=>{kr&&Er()},[kr,Or,Er]);let{maybeLoadOlder:Ar}=$R({config:C,setMessages:G,scrollRef:ln,onPrepend:br}),jr=(0,Q.useCallback)((e,t)=>{dn.current=Date.now(),e?vr():(_r(t),Ar(t),V(e=>e.companionReaction===void 0?e:{...e,companionReaction:void 0}))},[vr,_r,Ar,V]),Mr=hz(a,G),Nr=(0,Q.useDeferredValue)(Q.useMemo(()=>ur.length>500?ur.slice(-500):ur,[ur])),Pr=ur.length-Nr.length;Pr>0&&q(`[useDeferredValue] Messages deferred by ${Pr} (${Nr.length}→${ur.length})`);let[Fr,Ir]=(0,Q.useState)(null),[Rr,zr]=(0,Q.useState)(()=>_T()),Br=(0,Q.useRef)(Rr);Br.current=Rr;let Vr=(0,Q.useRef)(null),Hr=(0,Q.useCallback)(e=>{at(Br.current,e)||(Br.current===``&&e!==``&&Date.now()-dn.current>=mK&&Er(),Br.current=e,zr(e),Nn(e.trim().length>0))},[Nn,Er,at]);(0,Q.useEffect)(()=>{if(Rr.trim().length===0)return;let e=setTimeout(Nn,1500,!1);return()=>clearTimeout(e)},[Rr]);let[Ur,Wr]=(0,Q.useState)(`prompt`),[K,Gr]=(0,Q.useState)(),qr=(0,Q.useCallback)(e=>{let t=new Set(e);De(e=>e.filter(e=>t.has(e.name)||od.has(e)))},[De]),[Yr,Xr]=(0,Q.useState)(new Set),Zr=(0,Q.useRef)(!1),Qr=RR({config:C,setMessages:G,setIsLoading:On,onInit:qr,setToolUseConfirmQueue:Un,tools:Bt,setStreamingToolUses:Zt,setStreamMode:Jt,setInProgressToolUseIDs:Xr}),$r=VR({config:w,setMessages:G,setIsLoading:On,setToolUseConfirmQueue:Un,tools:Bt}),ei=HR({session:T,setMessages:G,setIsLoading:On,setToolUseConfirmQueue:Un,tools:Bt}),ti=ei.isRemoteMode?ei:$r.isRemoteMode?$r:Qr,[ni,ri]=(0,Q.useState)({}),[ii,ai]=(0,Q.useState)(0),oi=(0,Q.useRef)(0),si=(0,Q.useRef)(!1),ci=(0,Q.useRef)([]),li=(0,Q.useCallback)(e=>{let t=oi.current;if(oi.current=e(t),oi.current>t){let e=ci.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=oi.current}}},[]),[ui,di]=(0,Q.useState)(null),pi=!(X(e=>e.settings.prefersReducedMotion)??!1)&&!Te(),mi=(0,Q.useCallback)(e=>{pi&&di(e)},[pi]),hi=ui&&pi&&ui.substring(0,ui.lastIndexOf(`
153
+ `)+1)||null,[gi,_i]=(0,Q.useState)(0),[vi,bi]=(0,Q.useState)(null),[xi,Si]=(0,Q.useState)(null),[Ci,wi]=(0,Q.useState)(null),[Ti,Ei]=(0,Q.useState)(!1),[Di,Oi]=(0,Q.useState)(void 0),[ki,Ai]=(0,Q.useState)(!1),[ji,Mi]=(0,Q.useState)(oE()),[Ni,Pi]=(0,Q.useState)(null),Fi=(0,Q.useRef)(!1),Li=(0,Q.useRef)(gi);Li.current=gi;let[Ri]=(0,Q.useState)(()=>({current:fl(i,s)}));Wl(()=>{Ri.current=Uh()});let[Bi,Vi]=(0,Q.useState)(W().hasAcknowledgedCostThreshold),[Hi,Ui]=(0,Q.useState)(`INSERT`),[Wi,Ki]=(0,Q.useState)(!1),[qi,Ji]=(0,Q.useState)(!1),[Yi,Xi]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{ve&&Wi&&Ki(!1)},[ve,Wi]);let Zi=fe(),Qi=(0,Q.useRef)(Zi);Qi.current=Zi;let[$i]=ce(),ea=Q.useRef(!1),ta=(0,Q.useCallback)(()=>{if(ea.current)return;ea.current=!0;let e=fr.current.slice(wa.current);for(let t of Ep(e))Ca.current.add(t);wa.current=fr.current.length,BV({theme:$i,readFileState:Sa.current,bashTools:Ca.current}).then(async e=>{if(e){let t=await e.content({theme:$i});V(e=>({...e,spinnerTip:t})),VV(e)}else V(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[V,$i]),na=(0,Q.useCallback)(()=>{On(!1),mr(void 0),oi.current=0,ci.current=[],di(null),Zt([]),bi(null),Si(null),wi(null),ta(),Wx(),uf()},[ta]),ra=(0,Q.useMemo)(()=>Wf(he).some(e=>e.status===`running`),[he]);(0,Q.useEffect)(()=>{if(!ra&&kn.current!==null){let e=Date.now()-kn.current,t=An.current;kn.current=null,An.current=void 0,G(n=>[...n,Kh(e,t,Ii(n,ud))])}},[ra,G]);let ia=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(F.mode!==`auto`){ia.current=!1;return}if(ia.current||(W().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Dr(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Ul(eH,`warning`)])},800,ia,G);return()=>clearTimeout(e)}},[F.mode,G]);let aa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(aa.current)return;let e=dh();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;aa.current=!0;let t=Math.round(e.creationDurationMs/1e3);G(e=>[...e,Ul(`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`)])},[G]);let Y=(0,Q.useMemo)(()=>{let e=ur.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`&&Yr.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[ur,Yr]),{onBeforeQuery:oa,onTurnComplete:sa,render:ca}=fz({enabled:A,setMessages:G,inputValue:Rr,setInputValue:Hr,setToolJSX:Vn}),la=(!Rn||Rn.showSpinner===!0)&&Hn.length===0&&Yn.length===0&&(gn||vn||ra||Ng()>0)&&!pe&&!Y&&(!hi||Ae),ua=Hn.length>0||Yn.length>0||qn.length>0||_e.queue.length>0||ge.queue.length>0,da=WB(ur,gn,ii,`session`,ua),fa=dz(G),pa=nW(ur,ii),ma=(0,Q.useMemo)(()=>({...da,handleSelect:e=>{Ma.current=!1;let t=da.handleSelect(e);e===`bad`&&!t&&GU(`feedback_survey_bad`)&&(ja(`feedback_survey_bad`),Ma.current=!0)}}),[da]),_a=rV(ur,gn,ua,{enabled:!D}),va=QB(ur,gn,ua,{enabled:!D}),ya=ZG(ur,gn,ua,ma.state!==`closed`||_a.state!==`closed`||va.state!==`closed`);wB({autoConnectIdeFlag:p,ideToInstallExtension:bt,setDynamicMcpConfig:Pe,setShowIdeOnboarding:Et,setIDEInstallationState:Ct}),KV(o,re,e=>V(t=>({...t,fileHistory:e})));let ba=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=mo(n.messages);{let t=(Lm(),e(om)).matchSessionMode(n.mode);if(t){let{getAgentDefinitionsWithOverrides:n,getActiveAgentsFromList:r}=(Gg(),e(Nv));n.cache.clear?.();let i=await n(Ye());V(e=>({...e,agentDefinitions:{...i,allAgents:i.allAgents,activeAgents:r(i.allAgents)}})),a.push(Ul(t,`warning`))}}let o=Bg();await Od(`resume`,{getAppState:()=>Se.getState(),setAppState:V,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await Fc(`resume`,{sessionId:t,agentType:N?.agentType,model:we});a.push(...s),r===`fork`?Py(n,Pv(t)):Vu(n,Pv(t)),oB(n,V),n.fileHistorySnapshots&&Cp(n);let{agentDefinition:c}=cB(n.agentSetting,b,ne);P(c),V(e=>({...e,agent:c?.agentType})),V(e=>({...e,standaloneAgentContext:sB(n.agentName,n.agentColor)})),Cl(n.agentName),Da(a,n.projectPath??Ye()),na(),tn(null),Mi(t);let l=bv(t);yh(),ut(),lt(Pv(t),n.fullPath?qT(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-DpHRoebc.js`);if(await u(),await Cv(),Qd(),Lg(n),n.goal){let{hydrateGoalFromTranscript:r}=(yT(),e(xT)),i=new Map;i.set(t,n.goal),r(i,t)}if(tr.current=!0,er(void 0),r!==`fork`)uB(),lB(n.worktreeSession),gc(),Kd({abortController:new AbortController,getAppState:()=>Se.getState(),setAppState:V});else{let e=dh();e&&Fm(e)}{let{saveMode:t}=(Fp(),e(ah)),{isCoordinatorMode:n}=(Lm(),e(om));t(n()?`coordinator`:`normal`)}l&&mt(l),Ri.current&&r!==`fork`&&(Ri.current=Sl(a,n.contentReplacements??[])),G(()=>a),Vn(null),Hr(``),J(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw J(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[na,V]),[xa]=(0,Q.useState)(()=>Ix(100)),Sa=(0,Q.useRef)(xa),Ca=(0,Q.useRef)(new Set),wa=(0,Q.useRef)(0),Ta=(0,Q.useRef)(new Set),Ea=(0,Q.useRef)(new Set),Da=(0,Q.useCallback)((e,t)=>{let n=My(e,t,100);Sa.current=zx(Sa.current,n);for(let t of Ep(e))Ca.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Da(i,Ye()),Kd({abortController:new AbortController,getAppState:()=>Se.getState(),setAppState:V}))},[]);let{status:Oa,reverify:ka}=gz(),[Aa,ja]=(0,Q.useState)(null),Ma=(0,Q.useRef)(!1),[Na,Pa]=(0,Q.useState)(null),[Fa,Ia]=(0,Q.useState)(!1),za=!gn&&ki;function Va(){if(Fa||Na)return;if(Ti)return`message-selector`;if(Mn)return;if(qn[0])return`sandbox-permission`;let e=!Rn||Rn.shouldContinueAnimation;if(e&&Hn[0])return`tool-permission`;if(e&&Yn[0])return`prompt`;if(e&&ge.queue[0])return`worker-sandbox-permission`;if(e&&_e.queue[0])return`elicitation`;if(e&&za)return`cost`;if(e&&Ni)return`idle-return`;if(e&&!gn&&ve)return`ultraplan-choice`;if(e&&!gn&&B)return`ultraplan-launch`;if(e&&Tt)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Ot)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&In)return`undercover-callout`;if(e&&At)return`effort-callout`;if(e&&Mt)return`remote-callout`;if(e&&Ft)return`lsp-recommendation`;if(e&&Lt)return`plugin-hint`;if(e&&zt.visible)return`search-extra-tools-hint`;if(e&&Nt)return`desktop-upsell`}let Ha=Va(),Ua=Mn&&(qn[0]||Hn[0]||Yn[0]||ge.queue[0]||_e.queue[0]||za);jn.current=Ha,(0,Q.useEffect)(()=>{if(!gn)return;let e=Ha===`tool-permission`,t=Date.now();e&&Tn.current===null?Tn.current=t:!e&&Tn.current!==null&&(wn.current+=t-Tn.current,Tn.current=null)},[Ha,gn]);let Wa=(0,Q.useRef)(Ha);(0,Q.useLayoutEffect)(()=>{Wa.current===`tool-permission`!=(Ha===`tool-permission`)&&Er(),Wa.current=Ha},[Ha,Er]);function Ga(){if(Ha!==`elicitation`){if(rn.current!==0&&Date.now()-rn.current<500){rn.current=0,q(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(rn.current=0,q(`[onCancel] focusedInputDialog=${Ha} streamMode=${qt}`),eK?.pauseProactive(),fn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ig(),e(Bp)),{persistCurrentGoal:r}=(yT(),e(xT));t()?.status===`active`&&(n(),r())}if(on(!0),fn.forceEnd(),Fi.current=!1,ui?.trim()&&G(e=>[...e,Ly({content:ui})]),na(),Je(null),Ha===`tool-permission`)Hn[0]?.onAbort(),Un([]);else if(Ha===`prompt`){for(let e of Yn)e.reject(Error(`Prompt cancelled by user`));Xn([]),en?.abort(`user-cancel`)}else ti.isRemoteMode?ti.cancelRequest():en?.abort(`user-cancel`);tn(null),sa(fr.current,!0)}}let Ka=(0,Q.useCallback)(()=>{let e=zp(Rr,0);e&&(Hr(e.text),Wr(`prompt`),e.images.length>0&&ri(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Hr,Wr,Rr,ri]),Ja={setToolUseConfirmQueue:Un,onCancel:Ga,onAgentsKilled:()=>G(e=>[...e,cy()]),isMessageSelectorVisible:Ti||!!Wi,screen:ze,abortSignal:en?.signal,popCommandFromQueue:Ka,vimMode:Hi,isLocalJSXCommand:Rn?.isLocalJSXCommand,isSearchingHistory:qi,isHelpOpen:Yi,inputMode:Ur,inputValue:Rr,streamMode:qt};(0,Q.useEffect)(()=>{wt()>=5&&!ki&&!Bi&&(J(`tengu_cost_threshold_reached`,{}),Vi(!0),bn()&&Ai(!0))},[ur,ki,Bi]);let Xa=(0,Q.useCallback)(async e=>{if(Gn()&&J_()){let t=Ev(),n=await n_(e.host,t);return new Promise(r=>{if(!n){Jn(t=>[...t,{hostPattern:e,resolvePromise:r}]);return}Ya({requestId:t,host:e.host,resolve:r}),V(n=>({...n,pendingSandboxRequest:{requestId:t,host:e.host}}))})}return new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Jn(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=Se.getState().replBridgePermissionCallbacks;if(t){let n=oE();t.sendRequest(n,HT,{host:e.host},oE(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;Jn(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=Zn.current.get(e.host);if(i){for(let e of i)e();Zn.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=Zn.current.get(e.host)??[];a.push(i),Zn.current.set(e.host,a)}}})},[V,Se]);(0,Q.useEffect)(()=>{let e=po.getSandboxUnavailableReason();if(e){if(po.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Xm(1,`other`);return}q(`sandbox disabled: ${e}`,{level:`warn`}),rt({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(z,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[rt]),po.isSandboxingEnabled()&&po.initialize(Xa).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Kr(e)}\n`),Xm(1,`other`)});let Za=(0,Q.useCallback)((e,t)=>{V(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Un)},[V,Un]);(0,Q.useEffect)(()=>(sc(Za),()=>$d()),[Za]);let Qa=Uz(Un,Za),$a=(0,Q.useCallback)((e,t,r,i)=>{let a=Se.getState(),o=()=>{let e=Se.getState(),t=dC(Bt,Ds(e.toolPermissionContext,e.mcp.tools),e.toolPermissionContext.mode);return N?Zv(N,t,!1,!0).resolvedTools:t};return{abortController:r,options:{commands:Kt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:E,mcpClients:Zz(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:St,isNonInteractiveSession:!1,dynamicMcpConfig:Ne,theme:$i,agentDefinitions:Wt?{...a.agentDefinitions,allowedAgentTypes:Wt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>Se.getState(),setAppState:V,messages:e,setMessages:G,updateFileHistoryState(e){V(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){V(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{y||Ei(!0)},onChangeAPIKey:ka,readFileState:Sa.current,setToolJSX:Vn,addNotification:rt,appendSystemMessage:e=>G(t=>[...t,e]),sendOSNotification:e=>{Dp(e,Ce)},onChangeDynamicMcpConfig:Ie,onInstallIDEExtension:xt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ea.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Ta.current,setResponseLength:li,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=oi.current;ci.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Jt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Si(`claudeBlue_FOR_SYSTEM_SPINNER`),wi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),bi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:bi(`Compacting conversation`),si.current=!0;break;case`compact_end`:bi(null),Si(null),wi(null),si.current=!1;break}},setInProgressToolUseIDs:Xr,setHasInterruptibleToolInProgress:e=>{Zr.current=e},resume:ba,setConversationId:Mi,requestPrompt:void 0,contentReplacementState:Ri.current}},[Kt,Bt,N,n,d,St,Ne,$i,Wt,Se,V,ka,rt,G,Ie,ba,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Xn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),y,h,g,Mi]),{handleBackgroundSession:eo}=EB({setMessages:G,setIsLoading:On,resetLoadingState:na,setAbortController:tn,onBackgroundQuery:(0,Q.useCallback)(()=>{en?.abort(`background`);let e=ng(e=>e.mode===`task-notification`);(async()=>{let t=$a(fr.current,[],new AbortController,we),[n,r,i]=await Promise.all([Jv(t.options.tools,we,Array.from(F.additionalWorkingDirectories.keys()),t.options.mcpClients),zc(),Ls()]),a=Gv({mainThreadAgentDefinition:N,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Pp(e).catch(()=>[])).map(uy),s=new Set;for(let e of fr.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)));cf({messages:[...fr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Qa,toolUseContext:t,querySource:$z()},description:rr,setAppState:V,agentDefinition:N})})()},[en,we,F,N,$a,h,g,Qa,V])}),to=(0,Q.useCallback)(t=>{Tc(t,t=>{if(gu(t)?(gh()?G(e=>{let n=rc(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):G(()=>[t]),Mi(oE()),eK?.setContextBlocked(!1)):t.type===`progress`&&Ro(t.data?.type)?G(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]}):G(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?eK?.setContextBlocked(!0):t.type===`assistant`&&eK?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(vo(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}=(ig(),e(Bp)),{persistCurrentGoal:r}=(yT(),e(xT));t()?.status===`active`&&(n(),r(),rt({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{li(t=>t+e.length)},Jt,Zt,e=>{G(t=>t.filter(t=>t!==e)),xu(e.uuid)},$t,e=>{let t=Date.now(),n=oi.current;ci.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},mi)},[G,li,Jt,Zt,$t,mi]),no=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=Zz(d,Se.getState().mcp.clients);Vv.handleQueryStart(e);let t=Xh(e);t&&cd(t)}if(uS(),!k&&!Qn&&!nr&&!tr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?vo(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(tr.current=!0,zS(n,new AbortController().signal).then(e=>{e?er(e):tr.current=!1},()=>{tr.current=!1}))}if(Se.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(gu)&&(Mi(oE()),eK?.setContextBlocked(!1)),na(),tn(null);return}let s=$a(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}Am(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,UV(F,V,Se.getState().fastMode),Jv(c,a,Array.from(F.additionalWorkingDirectories.keys()),l),zc(),Ls()]),m={...f,...$G(l,$o()?Lo():void 0),...eK?.isProactiveActive()&&!Qi.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Am(`query_context_loading_end`);let _=Gv({mainThreadAgentDefinition:N,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,Am(`query_query_start`),Fe(),ht(),nt();for await(let t of Vs({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:Qa,toolUseContext:s,querySource:$z()}))to(t);if(typeof globalThis.fireCompanionObserver==`function`){let e=globalThis.fireCompanionObserver;e(fr.current,e=>V(t=>t.companionReaction===e?t:{...t,companionReaction:e}))}if(Am(`query_end`),process.env.USER_TYPE===`ant`&&ci.current.length>0){let e=ci.current,t=e.map(e=>e.ttftMs),n=e.map(e=>{let t=Math.round((e.endResponseLength-e.responseLengthBaseline)/4),n=e.lastTokenTime-e.firstTokenTime;return n>0?Math.round(t/(n/1e3)):0}),r=e.length>1,i=yt(),a=et(),o=Qe(),s=_t(),c=Ve(),l=Ue(),u=Date.now()-Cn.current;G(e=>[...e,Xy({ttftMs:r?hK(t):t[0],otps:r?hK(n):n[0],isP50:r,hookDurationMs:i>0?i:void 0,hookCount:a>0?a:void 0,turnDurationMs:u>0?u:void 0,toolDurationMs:o>0?o:void 0,toolCount:s>0?s:void 0,classifierDurationMs:c>0?c:void 0,classifierCount:l>0?l:void 0,configWriteCount:xr()})])}na(),Yp(),await v?.(fr.current)},[d,na,$a,F,V,h,v,g,Qa,N,to,Qn,k]),ro=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{if(Gn()){let e=zi(),t=Gi();e&&t&&kx(e,t,!0)}let c=fn.tryStart();if(c===null)return J(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>vo(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{La({value:e,mode:`prompt`}),t===0&&J(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{jo.current=!1,on(!1),En(),G(t=>[...t,...e]),oi.current=0,Je((o?go(o):null)??Re()),ci.current=[],Zt([]),di(null);let c=fr.current;if(o&&await oa(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await no(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(fn.end(c)){on(t.signal.aborted),_i(Date.now()),Fi.current=!1,na(),await sa(fr.current,t.signal.aborted),sn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&V(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Re()!==null&&Re()>0&&!t.signal.aborted&&(e={tokens:Le(),limit:Re(),nudges:dt()}),Je(null);let n=Date.now()-Cn.current-wn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Oe&&(Wf(Se.getState().tasks).some(e=>e.status===`running`)?(kn.current===null&&(kn.current=Cn.current),e&&(An.current=e)):G(t=>[...t,Kh(n,e,Ii(t,ud))])),tn(null)}if(t.signal.reason===`user-cancel`&&!fn.isActive&&Br.current===``&&Ng()===0&&!Se.getState().viewingAgentTaskId){let e=fr.current,t=e.findLast(hD);t&&gD(e,e.lastIndexOf(t))&&(Il(),cn.current(t))}}return!0},[no,V,na,fn,oa,sa]),ao=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ae;if(!e||gn||ao.current)return;ao.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Zu():void 0,{clearConversation:n}=await import(`./conversation-BoguXZEI.js`);await n({setMessages:G,readFileState:Sa.current,discoveredSkillNames:Ta.current,loadedNestedMemoryPaths:Ea.current,getAppState:()=>Se.getState(),setAppState:V,setConversationId:Mi}),tr.current=!1,er(void 0),Ca.current.clear(),wa.current=0,t&&Ll(ft(),t)}V(t=>{let n=e.mode?iy(t.toolPermissionContext,Xk(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=Xl({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),o_()&&Gp(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Mr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)oo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Mg();tn(t),ro([e.message],t,!0,[],we)}setTimeout(e=>{e.current=!1},100,ao)}t(e)},[ae,gn,G,V,ro,we,Ut]);let oo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Er(),eK?.resumeProactive(),No(e)){let n=Ph({content:e});G(e=>[...e,n]),r?.fromKeybinding||Gy({display:UM(e,Ur),pastedContents:ni}),Hr(``),t.setCursorOffset(0),t.clearBuffer(),ri({}),Wr(`prompt`),vt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=Op(e,ni).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Kt.find(e=>Ip(e)&&(e.name===a||e.aliases?.includes(a)||Qy(e)===a));s?.name===`clear`&&pr.current&&(J(`tengu_idle_return_action`,{action:`hint_converted`,variant:pr.current,idleMinutes:Math.round((Date.now()-Li.current)/6e4),messageCount:fr.current.length,totalInputTokens:pt()}),pr.current=!1);let c=fn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Br.current.trim()&&(Hr(``),t.setCursorOffset(0),t.clearBuffer(),ri({}));let n=Ho(e).filter(e=>ni[e.id]?.type===`text`),i=n.length;J(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ni[t.id]?.content.length??0),0)}),J(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Vn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(rt({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!gh())){let e=r?.displayArgs??o;i.push(wy(ju(Qy(s),e)),wy(`<${fi}>${Zb(n)}</${fi}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Ph({content:e,isMeta:!0}))),i.length&&G(e=>[...e,...i]),K!==void 0&&(Hr(K.text),t.setCursorOffset(K.cursorOffset),ri(K.pastedContents),Gr(void 0))},r=$a(fr.current,[],Mg(),we),i=await(await s.load()).call(n,r,o);i&&!e&&Vn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(ti.isRemoteMode&&!e.trim())return;{let r=_n(`tengu_willow_mode`,`off`),i=Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),a=Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5);if(r!==`off`&&!W().idleReturnDismissed&&!Fi.current&&!n&&!e.trim().startsWith(`/`)&&Li.current>0&&pt()>=a){let n=(Date.now()-Li.current)/6e4;if(n>=i&&r===`dialog`){Pi({input:e,idleMinutes:n}),Hr(``),t.setCursorOffset(0),t.clearBuffer();return}}}r?.fromKeybinding||(Gy({display:n?e:UM(e,Ur),pastedContents:n?{}:ni}),Ur===`bash`&&DN(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!gn||n||ti.isRemoteMode;if(K!==void 0&&!i&&a?(Hr(K.text),t.setCursorOffset(K.cursorOffset),ri(K.pastedContents),Gr(void 0)):a&&(r?.fromKeybinding||(Hr(``),t.setCursorOffset(0)),ri({})),a&&(Wr(`prompt`),vt(void 0),ai(e=>e+1),t.clearBuffer(),ea.current=!1,!i&&Ur===`prompt`&&!n&&!ti.isRemoteMode&&(mr(e),En()),V(e=>({...e,attribution:tx(e.attribution,e=>{Dd(e).catch(e=>{q(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await ty(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:G,readFileState:Sa,cwd:Ye()});if(t){let e=Mg();tn(e),ro([],e,!0,[],we)}return}if(ti.isRemoteMode&&!(i&&Kt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Ip(t)&&(t.name===n||t.aliases?.includes(n)||Qy(t)===n)})?.type===`local-jsx`)){let t=Object.values(ni),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=Ph({content:i,imagePasteIds:r});G(e=>[...e,o]),await ti.sendMessage(a,{uuid:o.uuid});return}await Mr(),await Gz({input:e,helpers:t,queryGuard:fn,isExternalLoading:mn,mode:Ur,commands:Kt,onInputChange:Hr,setPastedContents:ri,setToolJSX:Vn,getToolUseContext:$a,messages:fr.current,mainLoopModel:we,pastedContents:ni,ideSelection:gt,setUserInputOnProcessing:mr,setAbortController:tn,abortController:en,onQuery:ro,setAppState:V,querySource:$z(),onBeforeQuery:_,canUseTool:Qa,addNotification:rt,setMessages:G,streamMode:Yt.current,hasInterruptibleToolInProgress:Zr.current}),(i||gn)&&K!==void 0&&(Hr(K.text),t.setCursorOffset(K.cursorOffset),ri(K.pastedContents),Gr(void 0))},[fn,gn,mn,Ur,Kt,Hr,Wr,ri,ai,vt,Vn,$a,we,ni,gt,mr,tn,rt,ro,K,Gr,V,_,Qa,Qr,G,Mr,Er]),so=(0,Q.useCallback)(async(e,t,n)=>{e_(t)?(Ch(t.id,Ph({content:e}),V),t.status===`running`?Kv(t.id,e,V):cv({agentId:t.id,prompt:e,toolUseContext:$a(fr.current,[],new AbortController,we),canUseTool:Qa}).catch(e=>{q(`resumeAgentBackground failed: ${Kr(e)}`),rt({key:`resume-agent-failed-${t.id}`,jsx:(0,$.jsxs)(z,{color:`error`,children:[`Failed to resume agent: `,Kr(e)]}),priority:`low`})})):vm(t.id,e,void 0,V),Hr(``),n.setCursorOffset(0),n.clearBuffer()},[V,Hr,$a,Qa,we,rt]),co=(0,Q.useCallback)(()=>{let e=Aa?KU(Aa):`/issue`;ja(null),oo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{q(`Auto-run ${e} failed: ${Kr(t)}`)})},[oo,Aa]),lo=(0,Q.useCallback)(()=>{ja(null)},[]),uo=(0,Q.useCallback)(()=>{oo(process.env.USER_TYPE===`ant`?`/issue`:`/feedback`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{q(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[oo]),fo=(0,Q.useRef)(oo);fo.current=oo;let ho=(0,Q.useCallback)(()=>{fo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),_o=(0,Q.useCallback)(async()=>{if(Ia(!0),io()){fE(`tmux`,[`detach-client`],{stdio:`ignore`}),Ia(!1);return}if(dh()!==null){Pa((0,$.jsx)(_w,{showWorktree:!0,onDone:()=>{},onCancel:()=>{Pa(null),Ia(!1)}}));return}let e=await(await dd.load()).call(()=>{});Pa(e),e===null&&Ia(!1)},[]),yo=(0,Q.useCallback)(()=>{Ei(e=>!e)},[]),bo=(0,Q.useCallback)(e=>{let t=fr.current,n=t.lastIndexOf(e);if(n===-1)return;J(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),G(t.slice(0,n)),Mi(oE()),vd();let r=e.permissionMode;V(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[G,V]),xo=(0,Q.useCallback)(e=>{bo(e);let t=Im(e);if(t&&(Hr(t.text),Wr(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}}}),ri(n)}}},[bo,Hr]);cn.current=xo;let So=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),xo,e)},[xo]),Co=e=>{let t=e.slice(0,24);return ur.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:wo,handlers:To}=Ba(Sr,Cr,wr,{copy:e=>void Ee(e).then(e=>{e&&process.stdout.write(e),rt({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Co(e.uuid),n=t>=0?ur[t]:void 0;if(!n||!hD(n))return;let r=!await uv(re,n.uuid),i=gD(ur,t);r&&i?(Ga(),So(n)):(Oi(n),Ei(!0))}});async function Eo(){ka();let e=await Ra();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
154
+ `);q(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else q(`No CLAUDE.md/rules files found`);for(let t of e)Sa.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})}pz(gT()),RE(ur,ur.length===i?.length);let{sendBridgeResult:Do}=iD(ur,G,nn,Kt,we);sn.current=Do,mz();let Oo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(oe.length<1){Oo.current=!1;return}Oo.current||(Oo.current=!0,Dr(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[oe.length]),Yz({executeQueuedInput:(0,Q.useCallback)(async e=>{await Gz({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:fn,commands:Kt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Vn,getToolUseContext:$a,messages:ur,mainLoopModel:we,ideSelection:gt,setUserInputOnProcessing:mr,setAbortController:tn,onQuery:ro,setAppState:V,querySource:$z(),onBeforeQuery:_,canUseTool:Qa,addNotification:rt,setMessages:G,queuedCommands:e})},[fn,Kt,Vn,$a,ur,we,gt,mr,Qa,tn,ro,rt,V,_]),hasActiveLocalJsxUI:ar,queryGuard:fn}),(0,Q.useEffect)(()=>{cs.recordUserActivity(),st(!0)},[Rr,ii]),(0,Q.useEffect)(()=>{ii===1&&FT()},[ii]),(0,Q.useEffect)(()=>{if(gn||ii===0||gi===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Dt()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=W().messageIdleNotifThresholdMs&&Dp({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},W().messageIdleNotifThresholdMs,gi,gn,Rn,jn,Ce);return()=>clearTimeout(e)},[gn,Rn,ii,gi,Ce]),(0,Q.useEffect)(()=>{if(gi===0||gn)return;let e=_n(`tengu_willow_mode`,`off`);if(e!==`hint`&&e!==`hint_v2`||W().idleReturnDismissed)return;let t=Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5);if(pt()<t)return;let n=Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75)*6e4-(Date.now()-gi),r=setTimeout((e,t,n,r,i)=>{if(n.current.length===0)return;let a=pt(),o=ha(a),s=(Date.now()-e)/6e4;t({key:`idle-return-hint`,jsx:r===`hint_v2`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{dimColor:!0,children:`new task? `}),(0,$.jsx)(z,{color:`suggestion`,children:`/clear`}),(0,$.jsx)(z,{dimColor:!0,children:` to save `}),(0,$.jsxs)(z,{color:`suggestion`,children:[o,` tokens`]})]}):(0,$.jsxs)(z,{color:`warning`,children:[`new task? /clear to save `,o,` tokens`]}),priority:`medium`,timeoutMs:2147483647}),i.current=r,J(`tengu_idle_return_action`,{action:`hint_shown`,variant:r,idleMinutes:Math.round(s),messageCount:n.current.length,totalInputTokens:a})},Math.max(0,n),gi,rt,fr,e,pr);return()=>{clearTimeout(r),it(`idle-return-hint`),pr.current=!1}},[gi,gn,rt,it]);let ko=(0,Q.useCallback)((e,t)=>{if(fn.isActive||yv().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 rh([n]),t=e.attachmentCommands[0];if(!t)return;let r=Mg();tn(r);let i=Ph({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await ro([i],r,!0,[],we)!==!1}catch(t){try{await Km({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Jr(),priority:`later`})}catch(e){yi(Lr(e))}yi(Lr(t));return}if(a)try{let t=await Km({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Jr(),priority:`later`});for(let e of t)La(e)}catch(e){yi(Lr(e))}})().catch(e=>{yi(Lr(e))}),!0},[ro,we,Se]),{relayPipeMessage:Ao,pipeReturnHadErrorRef:jo}=cK(),Mo=YG({setInputValueRaw:zr,inputValueRef:Br,insertTextRef:Vr});yB({enabled:Gn(),isLoading:gn,focusedInputDialog:Ha,onSubmitMessage:ko}),Xz({isLoading:gn,onSubmitMessage:ko}),X(e=>JS(e));let{routeToSelectedPipes:No}=lK({store:Se,setAppState:V,addNotification:rt});{let e=Se.getState().kairosEnabled;oK({isLoading:gn,assistantMode:e,setMessages:G})}process.env.USER_TYPE===`ant`&&xB({taskListId:S,isLoading:gn,onSubmitTask:ko}),aK?.({isLoading:gn||ae!==null,queuedCommandsLength:oe.length,hasActiveLocalJsxUI:ar,isInPlanMode:F.mode===`plan`,onQueueTick:e=>La(e)}),sK?.({isLoading:gn||ae!==null,wasAborted:an,queuedCommandsLength:oe.length,hasActiveLocalJsxUI:ar,isInPlanMode:F.mode===`plan`,isQueryActiveNow:fn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;G(e=>[...e,Ph({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{rt({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(!Oe){HS(null);return}if(!gn){if(ke!==null&&oe.length===0&&!ar&&F.mode!==`plan`&&ae===null){HS({enabled:!0,phase:`standby`,next_tick_at:ke,sleep_until:null});return}HS({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ae,gn,ar,Oe,ke,oe.length,F.mode]),(0,Q.useEffect)(()=>{oe.some(e=>e.priority===`now`)&&nn.current?.abort(`interrupt`)},[oe]);let Po=(0,Q.useRef)(Eo);Po.current=Eo;let Fo=(0,Q.useRef)(Vv);Fo.current=Vv,(0,Q.useEffect)(()=>(Po.current(),()=>{Fo.current.shutdown()}),[]);let{internal_eventEmitter:Io}=se(),[Bo,Vo]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
155
+ Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
156
+ Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
157
+ `)},t=()=>{Vo(e=>e+1)};return Io?.on(`suspend`,e),Io?.on(`resume`,t),()=>{Io?.off(`suspend`,e),Io?.off(`resume`,t)}},[Io]);let Uo=(0,Q.useMemo)(()=>{if(!gn)return null;let e=ur.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||ur.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=Ii(ur,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${ga(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[ur,gn]),Wo=(0,Q.useCallback)(()=>{Ir({messagesLength:ur.length,streamingToolUsesLength:Xt.length})},[ur.length,Xt.length]),Go=(0,Q.useCallback)(()=>{Ir(null)},[]),Ko=gh()&&!j,qo=(0,Q.useRef)(null),[Jo,Yo]=(0,Q.useState)(!1),[Xo,Zo]=(0,Q.useState)(``),[Qo,es]=(0,Q.useState)(0),[ts,ns]=(0,Q.useState)(0),rs=(0,Q.useCallback)((e,t)=>{es(e),ns(t)},[]);je((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){qo.current?.setAnchor(),Yo(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Qo>0){let t=r===`n`?qo.current?.nextMatch:qo.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:ze===`transcript`&&Ko&&!Jo&&!Ge});let{setQuery:is,scanElement:as,setPositions:os}=ie(),ss=ee().columns,ls=Q.useRef(ss);Q.useEffect(()=>{ls.current!==ss&&(ls.current=ss,(Xo||Jo)&&(Yo(!1),Zo(``),es(0),ns(0),qo.current?.disarmSearch(),is(``)))},[ss,Xo,Jo,is]),je((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){Go(),n.stopImmediatePropagation();return}if(e===`[`&&!Ge)Ke(!0),We(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),tt.current)return;tt.current=!0;let e=Ze.current,t=t=>{e===Ze.current&&(clearTimeout($e.current),Xe(t))};t(`rendering ${Nr.length} messages…`),(async()=>{try{let e=(await kw(Nr,Ut,Math.max(80,(process.stdout.columns??80)-6))).replace(/[ \t]+$/gm,``),n=YT(WT(),`cc-transcript-${Date.now()}.txt`);await uE(n,e),t(vC(n)?`opening ${n}`:`wrote ${n} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}tt.current=!1,e===Ze.current&&($e.current=setTimeout(e=>e(``),4e3,Xe))})()}}},{isActive:ze===`transcript`&&Ko&&!Jo});let us=ze===`transcript`&&Ko;(0,Q.useEffect)(()=>{us||(Zo(``),es(0),ns(0),Yo(!1),Ze.current++,clearTimeout($e.current),Ke(!1),Xe(``))},[us]),(0,Q.useEffect)(()=>{is(us?Xo:``),us||os(null)},[us,Xo,is,os]);let ds={screen:ze,setScreen:Be,showAllInTranscript:He,setShowAllInTranscript:We,messageCount:ur.length,onEnterTranscript:Wo,onExitTranscript:Go,virtualScrollActive:Ko,searchBarOpen:Jo},fs=Fr?Nr.slice(0,Fr.messagesLength):Nr,ps=Fr?Xt.slice(0,Fr.streamingToolUsesLength):Xt;Cz({onOpenBackgroundTasks:ar?void 0:()=>Ki(!0),onTogglePipeSelector:()=>{V(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}}),Ez();let ms=ye?he[ye]:void 0,hs=ms&&td(ms)?ms:void 0,gs=hs??(ms&&e_(ms)?ms:void 0),_s=pi||!gn,vs=gs?.messages,ys=(0,Q.useMemo)(()=>{if(!gs)return;let e=vs??[];if(!e_(gs)||gs.agentType!==`fork`||!gs.prompt)return e;let t=gs.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(CK))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=>!CK(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Ph({content:gs.prompt,timestamp:new Date(gs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[gs,vs]),bs=gs?ys??[]:_s?ur:Nr;if(ze===`transcript`){let e=gh()&&!j&&!Ge?ln:void 0,t=(0,$.jsx)(Ew,{messages:fs,tools:Ut,commands:Kt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Yr,isMessageSelectorVisible:!1,conversationId:ji,screen:ze,agentDefinitions:ne,streamingToolUses:ps,showAllInTranscript:He,onOpenRateLimitOptions:ho,isLoading:gn,hidePastThinking:!0,streamingThinking:Qt,scrollRef:e,jumpRef:qo,onSearchMatchesChange:rs,scanElement:as,setPositions:os,disableRenderCap:Ge}),n=Rn&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Rn.jsx}),r=(0,$.jsxs)(wg,{children:[(0,$.jsx)(xK,{isAnimating:or,title:rr,disabled:k,noPrefix:lr}),(0,$.jsx)(_z,{...ds}),(0,$.jsx)(XG,{voiceHandleKeyEvent:Mo.handleKeyEvent,stripTrailing:Mo.stripTrailing,resetAnchor:Mo.resetAnchor,isActive:!Rn?.isLocalJSXCommand}),(0,$.jsx)(yz,{onSubmit:oo,isActive:!Rn?.isLocalJSXCommand}),e?(0,$.jsx)(KW,{scrollRef:ln,isActive:Ha!==`ultraplan-choice`,isModal:!Jo,onScroll:()=>qo.current?.disarmSearch()}):null,(0,$.jsx)(xz,{...Ja}),e?(0,$.jsx)(ww,{scrollRef:ln,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(YV,{})]}),bottom:Jo?(0,$.jsx)(_K,{jumpRef:qo,initialQuery:``,count:Qo,current:ts,onClose:e=>{Zo(Qo>0?e:``),Yo(!1),e||(es(0),ns(0),qo.current?.setSearchQuery(``))},onCancel:()=>{Yo(!1),qo.current?.setSearchQuery(``),qo.current?.setSearchQuery(Xo),is(Xo)},setHighlight:is}):(0,$.jsx)(gK,{showAllInTranscript:He,virtualScroll:!0,status:qe||void 0,searchBadge:Xo&&Qo>0?{current:ts,count:Qo}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(YV,{}),(0,$.jsx)(gK,{showAllInTranscript:He,virtualScroll:!1,suppressShowAll:Ge,status:qe||void 0})]})]});return e?(0,$.jsx)(de,{mouseTracking:op(),children:r}):r}let xs=vn&&!gs&&bs.length<=xn.current?vn:void 0,Ss=Ha===`tool-permission`?(0,$.jsx)(_j,{onDone:()=>Un(([e,...t])=>t),onReject:Ka,toolUseConfirm:Hn[0],toolUseContext:$a(ur,ur,en??Mg(),we),verbose:te,workerBadge:Hn[0]?.workerBadge,setStickyFooter:gh()?Kn:void 0},Hn[0]?.toolUseID):null,Cs=ss<100,ws=!Rn?.shouldHidePromptInput&&!Ha&&!Wi,Ts=gh()&&Rn?.isLocalJSXCommand===!0,Es=Ts?Rn.jsx:null,Os=(0,$.jsxs)(wg,{children:[(0,$.jsx)(xK,{isAnimating:or,title:rr,disabled:k,noPrefix:lr}),(0,$.jsx)(_z,{...ds}),(0,$.jsx)(XG,{voiceHandleKeyEvent:Mo.handleKeyEvent,stripTrailing:Mo.stripTrailing,resetAnchor:Mo.resetAnchor,isActive:!Rn?.isLocalJSXCommand}),(0,$.jsx)(yz,{onSubmit:oo,isActive:!Rn?.isLocalJSXCommand}),(0,$.jsx)(KW,{scrollRef:ln,isActive:gh()&&(Es!=null||!Ha||Ha===`tool-permission`),onScroll:jr}),null,(0,$.jsx)(xz,{...Ja}),(0,$.jsx)(LB,{dynamicMcpConfig:Ne,isStrictMcpConfig:m,children:(0,$.jsx)(ww,{scrollRef:ln,overlay:Ss,bottomFloat:ws&&!Cs?(0,$.jsx)(lM,{}):void 0,modal:Es,modalScrollRef:un,dividerYRef:gr,hidePill:!!gs,hideSticky:!!hs,newMessageCount:Tr?.count??0,onPillClick:()=>{Cr(null),yr(ln.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nB,{}),(0,$.jsx)(Ew,{messages:bs,tools:Ut,commands:Kt,verbose:te,toolJSX:Rn,toolUseConfirmQueue:Hn,inProgressToolUseIDs:hs?hs.inProgressToolUseIDs??new Set:Yr,isMessageSelectorVisible:Ti,conversationId:ji,screen:ze,streamingToolUses:Xt,showAllInTranscript:He,agentDefinitions:ne,onOpenRateLimitOptions:ho,isLoading:gn,streamingText:gn&&!gs?hi:null,isBriefOnly:gs?!1:Ae,unseenDivider:gs?void 0:Tr,scrollRef:gh()?ln:void 0,trackStickyPrompt:gh()?!0:void 0,cursor:Sr,setCursor:Cr,cursorNavRef:wr}),(0,$.jsx)(XH,{}),!y&&xs&&!Es&&(0,$.jsx)(JH,{param:{text:xs,type:`text`},addMargin:!0,verbose:te}),Rn&&!(Rn.isLocalJSXCommand&&Rn.isImmediate)&&!Ts&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Rn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(JU,{}),(0,$.jsx)(U,{flexGrow:1}),la&&(0,$.jsx)(fd,{mode:qt,spinnerTip:le,responseLengthRef:oi,apiMetricsRef:ci,compactProgressActiveRef:si,overrideMessage:vi,spinnerSuffix:Uo,verbose:te,loadingStartTimeRef:Cn,totalPausedMsRef:wn,pauseStartTimeRef:Tn,overrideColor:xi,overrideShimmerColor:Ci,hasActiveTools:Yr.size>0,leaderIsIdle:!gn}),!la&&!gn&&!vn&&!ra&&Ae&&!gs&&(0,$.jsx)(zo,{})]}),bottom:(0,$.jsxs)(U,{flexDirection:Cs?`column`:`row`,width:`100%`,alignItems:Cs?void 0:`flex-end`,children:[Cs&&gh()&&ws?(0,$.jsx)(cM,{}):null,(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[gh()&&(0,$.jsx)(JL,{}),Wn,Rn?.isLocalJSXCommand&&Rn.isImmediate&&!Ts&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Rn.jsx}),!la&&!Rn?.isLocalJSXCommand&&ue&&Vt&&Vt.length>0&&(0,$.jsx)(U,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(qm,{tasks:Vt,isStandalone:!0})}),Ha===`sandbox-permission`&&(0,$.jsx)(qV,{hostPattern:qn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=qn[0];if(!r)return;let i=r.hostPattern.host;if(n){let e={type:`addRules`,rules:[{toolName:`WebFetch`,ruleContent:`domain:${i}`}],behavior:t?`allow`:`deny`,destination:`localSettings`};V(t=>({...t,toolPermissionContext:Yf(t.toolPermissionContext,e)})),Fy(e),po.refreshConfig()}Jn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=Zn.current.get(i);if(a){for(let e of a)e();Zn.current.delete(i)}}},qn[0].hostPattern.host),Ha===`prompt`&&(0,$.jsx)(Vj,{title:Yn[0].title,toolInputSummary:Yn[0].toolInputSummary,request:Yn[0].request,onRespond:e=>{let t=Yn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Xn(([,...e])=>e))},onAbort:()=>{let e=Yn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Xn(([,...e])=>e))}},Yn[0].request.prompt),pe&&(0,$.jsx)(LE,{toolName:pe.toolName,description:pe.description}),R&&(0,$.jsx)(LE,{toolName:`Network Access`,description:`Waiting for leader to approve network access to ${R.host}`}),Ha===`worker-sandbox-permission`&&(0,$.jsx)(qV,{hostPattern:{host:ge.queue[0].host,port:void 0},onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=ge.queue[0];if(!r)return;let i=r.host;if(sv(r.workerName,r.requestId,i,t,me?.teamName),n&&t){let e={type:`addRules`,rules:[{toolName:`WebFetch`,ruleContent:`domain:${i}`}],behavior:`allow`,destination:`localSettings`};V(t=>({...t,toolPermissionContext:Yf(t.toolPermissionContext,e)})),Fy(e),po.refreshConfig()}V(e=>({...e,workerSandboxPermissions:{...e.workerSandboxPermissions,queue:e.workerSandboxPermissions.queue.slice(1)}}))}},ge.queue[0].requestId),Ha===`elicitation`&&(0,$.jsx)(Rj,{event:_e.queue[0],onResponse:(e,t)=>{let n=_e.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=_e.queue[0];V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},_e.queue[0].serverName+`:`+String(_e.queue[0].requestId)),Ha===`cost`&&(0,$.jsx)(yE,{onDone:()=>{Ai(!1),Vi(!0),Dr(e=>({...e,hasAcknowledgedCostThreshold:!0})),J(`tengu_cost_threshold_acknowledged`,{})}}),Ha===`idle-return`&&Ni&&(0,$.jsx)(bE,{idleMinutes:Ni.idleMinutes,totalInputTokens:pt(),onDone:async e=>{let t=Ni;if(Pi(null),J(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:fr.current.length,totalInputTokens:pt()}),e===`dismiss`){Hr(t.input);return}if(e===`never`&&Dr(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-BoguXZEI.js`);await e({setMessages:G,readFileState:Sa.current,discoveredSkillNames:Ta.current,loadedNestedMemoryPaths:Ea.current,getAppState:()=>Se.getState(),setAppState:V,setConversationId:Mi}),tr.current=!1,er(void 0),Ca.current.clear(),wa.current=0}Fi.current=!0,fo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),Ha===`ide-onboarding`&&(0,$.jsx)(DB,{onDone:()=>Et(!1),installationStatus:St}),process.env.USER_TYPE===`ant`&&Ha===`model-switch`&&uK&&(0,$.jsx)(uK,{onDone:(e,t)=>{kt(!1),e===`switch`&&t&&V(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&Ha===`undercover-callout`&&fK&&(0,$.jsx)(fK,{onDone:()=>Ln(!1)}),Ha===`effort-callout`&&(0,$.jsx)(jB,{model:we,onDone:e=>{jt(!1),e!==`dismiss`&&V(t=>({...t,effortValue:e}))}}),Ha===`remote-callout`&&(0,$.jsx)(OC,{onDone:e=>{V(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),Na,Ha===`plugin-hint`&&Lt&&(0,$.jsx)(EH,{pluginName:Lt.pluginName,pluginDescription:Lt.pluginDescription,marketplaceName:Lt.marketplaceName,sourceCommand:Lt.sourceCommand,onResponse:Rt}),Ha===`search-extra-tools-hint`&&zt.visible&&(0,$.jsx)(OH,{tools:zt.tools,onSelect:zt.handleSelect,onDismiss:zt.handleDismiss}),Ha===`lsp-recommendation`&&Ft&&(0,$.jsx)(bH,{pluginName:Ft.pluginName,pluginDescription:Ft.pluginDescription,fileExtension:Ft.fileExtension,onResponse:It}),Ha===`desktop-upsell`&&(0,$.jsx)(HH,{onDone:()=>Pt(!1)}),Ha===`ultraplan-choice`&&ve&&(0,$.jsx)(lW,{plan:ve.plan,sessionId:ve.sessionId,taskId:ve.taskId,setMessages:G,readFileState:Sa.current,getAppState:()=>Se.getState(),setConversationId:Mi}),Ha===`ultraplan-launch`&&B&&(0,$.jsx)(yW,{onChoice:(e,t)=>{let n=B.blurb;if(V(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;G(e=>[...e,wy(ju(`ultraplan`,n))]);let r=e=>G(t=>[...t,wy(`<local-command-stdout>${Zb(e)}</local-command-stdout>`)]);X_({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>Se.getState(),setAppState:V,signal:Mg().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!fn.isActive){r(e);return}let t=fn.subscribe(()=>{fn.isActive||(t(),Se.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(yi)}}),ca(),!Rn?.shouldHidePromptInput&&!Ha&&!Fa&&!y&&!Sr&&(0,$.jsxs)($.Fragment,{children:[Aa&&(0,$.jsx)(WU,{onRun:co,onCancel:lo,reason:qU(Aa)}),_a.state===`closed`?va.state===`closed`?(0,$.jsx)(cV,{state:ma.state,lastResponse:ma.lastResponse,handleSelect:ma.handleSelect,handleTranscriptSelect:ma.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Ma.current?void 0:uo}):(0,$.jsx)(cV,{state:va.state,lastResponse:va.lastResponse,handleSelect:va.handleSelect,handleTranscriptSelect:va.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:uo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(cV,{state:_a.state,lastResponse:_a.lastResponse,handleSelect:_a.handleSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:uo}),ya.state!==`closed`&&(0,$.jsx)(cV,{state:ya.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:ya.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr}),fa.suggestion&&(0,$.jsx)(sz,{isOpen:fa.isOpen,skillName:fa.suggestion.skillName,updates:fa.suggestion.updates,handleSelect:fa.handleSelect,inputValue:Rr,setInputValue:Hr}),pa&&(0,$.jsx)(YU,{}),(0,$.jsx)(wR,{debug:n,ideSelection:gt,hasSuppressedDialogs:!!Ua,isLocalJSXCommandActive:ar,getToolUseContext:$a,toolPermissionContext:F,setToolPermissionContext:Za,apiKeyStatus:Oa,commands:Kt,agents:ne.activeAgents,isLoading:gn,onExit:_o,verbose:te,messages:ur,onAutoUpdaterResult:Fn,autoUpdaterResult:Pn,input:Rr,onInputChange:Hr,mode:Ur,onModeChange:Wr,stashedPrompt:K,setStashedPrompt:Gr,submitCount:ii,onShowMessageSelector:yo,onMessageActionsEnter:void 0,mcpClients:ot,pastedContents:ni,setPastedContents:ri,vimMode:Hi,setVimMode:Ui,showBashesDialog:Wi,setShowBashesDialog:Ki,onSubmit:oo,onAgentSubmit:so,isSearchingHistory:qi,setIsSearchingHistory:Ji,helpOpen:Yi,setHelpOpen:Xi,insertTextRef:Vr,voiceInterimRange:Mo.interimRange}),(0,$.jsx)(TB,{onBackgroundSession:eo,isLoading:gn}),(0,$.jsx)(pB,{})]}),Sr&&(0,$.jsx)(E_,{cursor:Sr}),Ha===`message-selector`&&(0,$.jsx)(cD,{messages:ur,preselectedMessage:Di,onPreRestore:Ga,onRestoreCode:async e=>{await $v(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=rc(ur),i=r.indexOf(e);if(i===-1){G(e=>[...e,Ul(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=$a(r,[],Mg(),we),o=a.getAppState(),s=await Jv(a.options.tools,a.options.mainLoopModel,Array.from(o.toolPermissionContext.additionalWorkingDirectories.keys()),a.options.mcpClients),c=Gv({mainThreadAgentDefinition:void 0,toolUseContext:a,customSystemPrompt:a.options.customSystemPrompt,defaultSystemPrompt:s,appendSystemPrompt:a.options.appendSystemPrompt}),[l,u]=await Promise.all([zc(),Ls()]),d=await Qc(r,i,a,{systemPrompt:c,userContext:l,systemContext:u,toolUseContext:a,forkContextMessages:r},t,n),f=d.messagesToKeep??[],p=n===`up_to`?[...d.summaryMessages,...f]:[...f,...d.summaryMessages],m=[d.boundaryMarker,...p,...d.attachments,...d.hookResults];if(gh()&&n===`from`?G(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...m]}):G(m),eK?.setContextBlocked(!1),Mi(oE()),qh(a.options.querySource),n===`from`){let t=Im(e);t&&(Hr(t.text),Wr(t.mode))}rt({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${z_(`app:toggleTranscript`,`Global`,`ctrl+o`)} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:So,onClose:()=>{Ei(!1),Oi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(iW,{})]}),!(Cs&&gh())&&ws?(0,$.jsx)(cM,{}):null]})})},Bo)]});return gh()?(0,$.jsx)(de,{mouseTracking:op(),children:Os}):Os}export{lB as i,sB as n,cB as r,wK as t};