claude-code-best 2.7.1 → 2.7.2

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 (413) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-C7od6sFQ.js → AddWorkspaceDirectory-V2tF7iCY.js} +1 -1
  2. package/dist/chunks/{App-EfHjElWP.js → App-DLdRpU7c.js} +1 -1
  3. package/dist/chunks/ApproveApiKey-B7_TCGwt.js +1 -0
  4. package/dist/chunks/{ApproveApiKey-CSz0291w.js → ApproveApiKey-DPws3jax.js} +1 -1
  5. package/dist/chunks/{AssistantSessionChooser-mLIhDlxW.js → AssistantSessionChooser-D6rS0OVe.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-hGlbm5z5.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-BCdft-m_.js → BypassPermissionsModeDialog-CuEpdRVd.js} +1 -1
  8. package/dist/chunks/{ClaudeInChromeOnboarding-BPlrCIo-.js → ClaudeInChromeOnboarding-CTTKMRbt.js} +1 -1
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-D8fk-Ib5.js → ClaudeMdExternalIncludesDialog-B-GkVoA_.js} +1 -1
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-DxJK9NiM.js +1 -0
  11. package/dist/chunks/ConsoleOAuthFlow-LPZ97jsm.js +1 -0
  12. package/dist/chunks/{DesktopHandoff-BQwx7qWA.js → DesktopHandoff-BjPylhOT.js} +1 -1
  13. package/dist/chunks/{DevChannelsDialog-CujM8Ivu.js → DevChannelsDialog-c4YVqBX9.js} +1 -1
  14. package/dist/chunks/{DiffDialog-Byv1UJvS.js → DiffDialog-I5wuXw2C.js} +1 -1
  15. package/dist/chunks/{Doctor-Cv7wbi6C.js → Doctor-Cr_MlSPc.js} +1 -1
  16. package/dist/chunks/Doctor-hgf3dMAW.js +1 -0
  17. package/dist/chunks/{ExitFlow-DKusdm_v.js → ExitFlow-Bz5grDWv.js} +2 -2
  18. package/dist/chunks/{Feedback-Diw8XUr-.js → Feedback-COgMI5tY.js} +1 -1
  19. package/dist/chunks/Grove-Bwmghb-e.js +1 -0
  20. package/dist/chunks/{Grove-CAi037VV.js → Grove-m57x4tY1.js} +1 -1
  21. package/dist/chunks/{HybridTransport-CP0RopXu.js → HybridTransport-Bok4-Ptt.js} +1 -1
  22. package/dist/chunks/{ITermBackend-RvD4VX7c.js → ITermBackend-BBSP-NNa.js} +1 -1
  23. package/dist/chunks/{InvalidConfigDialog-Bhlgysxl.js → InvalidConfigDialog-uTSuSBvO.js} +1 -1
  24. package/dist/chunks/{InvalidSettingsDialog-dGStgJZN.js → InvalidSettingsDialog-B-Os12-H.js} +1 -1
  25. package/dist/chunks/{MCPConnectionManager-D5a9ysw2.js → MCPConnectionManager-y97Inszc.js} +1 -1
  26. package/dist/chunks/{McpParsingWarnings-B_z9pZ_8.js → McpParsingWarnings-DMFUZw92.js} +1 -1
  27. package/dist/chunks/MessageSelector-DwdAC2io.js +3 -0
  28. package/dist/chunks/{Messages-DTmFVhRG.js → Messages-FEBcX-cT.js} +3 -3
  29. package/dist/chunks/{Onboarding-BoAtphYb.js → Onboarding-B8qMJaBh.js} +1 -1
  30. package/dist/chunks/{OverageCreditUpsell-DA7Ne7Mj.js → OverageCreditUpsell-DnFv5z-z.js} +1 -1
  31. package/dist/chunks/PluginSettings-B_xVgTTp.js +17 -0
  32. package/dist/chunks/{PromptInputHelpMenu-B__j9zE6.js → PromptInputHelpMenu-CoMkWchC.js} +1 -1
  33. package/dist/chunks/QueryEngine-C7r7O-hH.js +1 -0
  34. package/dist/chunks/{REPL-B1BS9jwx.js → REPL-CmJdJrGO.js} +36 -36
  35. package/dist/chunks/REPL-nP7H_-qa.js +1 -0
  36. package/dist/chunks/{RemoteCallout-Bwe1ESr9.js → RemoteCallout-4JOZROfT.js} +1 -1
  37. package/dist/chunks/{RemoteSessionManager-BKD4YmzY.js → RemoteSessionManager-jcPnywfY.js} +2 -2
  38. package/dist/chunks/ResumeConversation-CZ2Uedkf.js +1 -0
  39. package/dist/chunks/{SSETransport-D3e5KNL3.js → SSETransport-kEH_p4Yq.js} +1 -1
  40. package/dist/chunks/SearchExtraToolsTool-C64oVFUD.js +1 -0
  41. package/dist/chunks/SentryErrorBoundary-2E2qGV11.js +1 -0
  42. package/dist/chunks/{SentryErrorBoundary-D-YZTGQG.js → SentryErrorBoundary-97iY7Nb7.js} +1 -1
  43. package/dist/chunks/Settings-CuljH0mu.js +2 -0
  44. package/dist/chunks/{TeleportProgress-C3Ubx1Se.js → TeleportProgress-Ctdqi7iS.js} +1 -1
  45. package/dist/chunks/{TeleportRepoMismatchDialog-D_ax3xQy.js → TeleportRepoMismatchDialog-DyTBg1YD.js} +1 -1
  46. package/dist/chunks/{TeleportResumeWrapper-DeVKIXQp.js → TeleportResumeWrapper-B66clYsG.js} +1 -1
  47. package/dist/chunks/{ThemePicker-DKmIL5Ku.js → ThemePicker-WKmYvrqz.js} +1 -1
  48. package/dist/chunks/{TmuxBackend-Bm_cRJ2x.js → TmuxBackend-OKX2NP14.js} +2 -2
  49. package/dist/chunks/{TrustDialog-ClXFMKj6.js → TrustDialog-0anSIf-G.js} +1 -1
  50. package/dist/chunks/{ValidationErrorsList-SdQADfvA.js → ValidationErrorsList-CfgC1KJb.js} +1 -1
  51. package/dist/chunks/{WelcomeV2-BijS6i2Z.js → WelcomeV2-BMHXiNt3.js} +1 -1
  52. package/dist/chunks/{WindowsTerminalBackend-CGEQ5ClB.js → WindowsTerminalBackend-fCSGVe4W.js} +2 -2
  53. package/dist/chunks/{add-dir-B7kleB6k.js → add-dir-CMtuW667.js} +1 -1
  54. package/dist/chunks/{agentDisplay-Dr1XbOAu.js → agentDisplay-CgYKW3G7.js} +1 -1
  55. package/dist/chunks/{agents-CpLvvWpO.js → agents-CdqcGm9o.js} +7 -7
  56. package/dist/chunks/{agents-Dy5YOJC9.js → agents-D90TsYOf.js} +1 -1
  57. package/dist/chunks/{ant-gwf-4eGN.js → ant-DZjimiuz.js} +1 -1
  58. package/dist/chunks/{api-CDmgYrwN.js → api-CQWbpxLP.js} +1 -1
  59. package/dist/chunks/api-quOYYOhi.js +1 -0
  60. package/dist/chunks/assistant-B5_xx00q.js +1 -0
  61. package/dist/chunks/{assistant-BULedprW.js → assistant-CEmC_DlU.js} +1 -1
  62. package/dist/chunks/{assistant-1usDIXtk.js → assistant-CyVcFPIR.js} +1 -1
  63. package/dist/chunks/auth-CjtaiRtF.js +1 -0
  64. package/dist/chunks/{auth-CvHVr2A5.js → auth-DsQEVs9W.js} +1 -1
  65. package/dist/chunks/{autoMode-DSMM2seL.js → autoMode-DEbM9UaE.js} +1 -1
  66. package/dist/chunks/{autonomy-TtBO2TAe.js → autonomy-Clap6Swl.js} +1 -1
  67. package/dist/chunks/{autonomy-Dj6Nzxus.js → autonomy-lNpGnyiu.js} +3 -3
  68. package/dist/chunks/{autonomyPanel-CbmU7lPg.js → autonomyPanel-BqEvfI0e.js} +1 -1
  69. package/dist/chunks/backgroundHousekeeping-D-jt-ocx.js +1 -0
  70. package/dist/chunks/{backgroundHousekeeping-Cp2RvmEN.js → backgroundHousekeeping-KvOpP_4M.js} +2 -2
  71. package/dist/chunks/{branch-Cj5TGroO.js → branch-CSYB04xC.js} +1 -1
  72. package/dist/chunks/{bridge-CsqJAoEg.js → bridge-DDgASypO.js} +2 -2
  73. package/dist/chunks/bridgeConfig-BdZVEqhx.js +1 -0
  74. package/dist/chunks/{bridgeConfig-pjDV5Z2l.js → bridgeConfig-DjC4oig1.js} +1 -1
  75. package/dist/chunks/{bridgeEnabled-D9jI6X-w.js → bridgeEnabled-Csn6Ym3k.js} +1 -1
  76. package/dist/chunks/bridgeEnabled-DLRIH243.js +1 -0
  77. package/dist/chunks/{bridgeMain-CNmR9iDD.js → bridgeMain-B5wsmwkN.js} +11 -11
  78. package/dist/chunks/bridgeMain-BN0Sag35.js +1 -0
  79. package/dist/chunks/{bridgeMessaging-DN0X35NX.js → bridgeMessaging-ChOzzVWj.js} +1 -1
  80. package/dist/chunks/{btw-BOg0RTKl.js → btw-BgjcOoeo.js} +1 -1
  81. package/dist/chunks/{buddy-BFuPeIxM.js → buddy-C1wE3noR.js} +1 -1
  82. package/dist/chunks/{bypassPermissionsKillswitch-kxVnIVRs.js → bypassPermissionsKillswitch-C0diGLRB.js} +1 -1
  83. package/dist/chunks/{caches-BumkMuGA.js → caches-CIoVGP24.js} +2 -2
  84. package/dist/chunks/caches-DMYdTEAr.js +1 -0
  85. package/dist/chunks/{ccrClient-BI1QPLmN.js → ccrClient-C1msT1E3.js} +1 -1
  86. package/dist/chunks/changeDetector-DoOBZOt1.js +1 -0
  87. package/dist/chunks/{channelNotification-CoZSFUlb.js → channelNotification-CWlu9ZWs.js} +1 -1
  88. package/dist/chunks/channelNotification-oZ6vG5R5.js +1 -0
  89. package/dist/chunks/{chrome-C_5EZcdc.js → chrome-Bo9uNZ7s.js} +1 -1
  90. package/dist/chunks/clear-BxdX_MUP.js +1 -0
  91. package/dist/chunks/client-BSoJ_vaA.js +1 -0
  92. package/dist/chunks/color-CkzktPHt.js +1 -0
  93. package/dist/chunks/commands-hyVX9-Lh.js +1 -0
  94. package/dist/chunks/commitAttribution-BwT0TbYF.js +1 -0
  95. package/dist/chunks/{commitAttribution-iKd8bTOI.js → commitAttribution-csu3NO7Y.js} +1 -1
  96. package/dist/chunks/{compact-B6Muofhz.js → compact-DNGIVZRN.js} +3 -3
  97. package/dist/chunks/{companion-B_LrjSk5.js → companion-Diuav3lA.js} +1 -1
  98. package/dist/chunks/{config-CQd4IkXo.js → config-B25IrkTA.js} +1 -1
  99. package/dist/chunks/{config-CJd9kJ57.js → config-ODoYZY8i.js} +1 -1
  100. package/dist/chunks/{context-qAHTuazZ.js → context-CZ5enuPE.js} +1 -1
  101. package/dist/chunks/{context-noninteractive-DZsSp-ES.js → context-noninteractive-62P5EnN5.js} +1 -1
  102. package/dist/chunks/context-noninteractive-CjuzL9q5.js +1 -0
  103. package/dist/chunks/conversation-DyhWeHw2.js +1 -0
  104. package/dist/chunks/conversation-uY-V0SNK.js +1 -0
  105. package/dist/chunks/{copy-B2jhZndZ.js → copy-9JLr2-Xs.js} +1 -1
  106. package/dist/chunks/{createSSHSession-CKdoEmAg.js → createSSHSession-B1hTuDpB.js} +1 -1
  107. package/dist/chunks/createSession-Qurw-N4x.js +1 -0
  108. package/dist/chunks/{createSession-WkBw7wdn.js → createSession-fzjzy0aS.js} +1 -1
  109. package/dist/chunks/cron-DwR6OJuW.js +1 -0
  110. package/dist/chunks/{cronJitterConfig-2u6WAlti.js → cronJitterConfig-9OmmYmIT.js} +1 -1
  111. package/dist/chunks/{crossProjectResume-CjJISRBQ.js → crossProjectResume-B6efoIur.js} +3 -3
  112. package/dist/chunks/datadog-C-llbwzP.js +1 -0
  113. package/dist/chunks/{datadog-YsyhnDmr.js → datadog-SSxsxcC-.js} +1 -1
  114. package/dist/chunks/{desktop-BN9pHpK_.js → desktop-CQnMcbex.js} +1 -1
  115. package/dist/chunks/{diff-BTtUFuf-.js → diff-uAwKYa51.js} +1 -1
  116. package/dist/chunks/{doctor-BKBb426q.js → doctor-CBF0fkBF.js} +1 -1
  117. package/dist/chunks/{effort-ClhxMqY6.js → effort-F-bhAM2u.js} +1 -1
  118. package/dist/chunks/{entry-CJlJ47nP.js → entry-DHN_Gr1b.js} +3 -3
  119. package/dist/chunks/envLessBridgeConfig-CDVtIEWT.js +1 -0
  120. package/dist/chunks/{envLessBridgeConfig-C9UUbQCo.js → envLessBridgeConfig-Dg0hNsdi.js} +1 -1
  121. package/dist/chunks/{exit-DxY3yJrp.js → exit-CqcvZJwI.js} +1 -1
  122. package/dist/chunks/{export-DS2esu8D.js → export-c6WoGlsG.js} +1 -1
  123. package/dist/chunks/{exportRenderer-DX2L5fQ7.js → exportRenderer-CaegIP5N.js} +1 -1
  124. package/dist/chunks/{extra-usage-XJxfHsbe.js → extra-usage-Cj8fokgc.js} +1 -1
  125. package/dist/chunks/extra-usage-Dk-wcvAu.js +1 -0
  126. package/dist/chunks/{extra-usage-core-D84ifgBo.js → extra-usage-core-sHzc4eE1.js} +1 -1
  127. package/dist/chunks/{extra-usage-noninteractive-fxqxHnIt.js → extra-usage-noninteractive-D0kqrqsg.js} +1 -1
  128. package/dist/chunks/{extraUsage-P_NGI1-I.js → extraUsage-CbkqfG1U.js} +1 -1
  129. package/dist/chunks/extractMemories-BP8Opsbp.js +1 -0
  130. package/dist/chunks/{fast-CpN8lLnE.js → fast-DS3iQ1CH.js} +1 -1
  131. package/dist/chunks/fast-DklfqySb.js +1 -0
  132. package/dist/chunks/{feedback-CqRsOG3c.js → feedback-QJynmG5q.js} +1 -1
  133. package/dist/chunks/{firstPartyEventLogger-CM0V7Uev.js → firstPartyEventLogger-DlW8BUXq.js} +1 -1
  134. package/dist/chunks/{flushGate-DNutWuOE.js → flushGate-CK5B9-Zn.js} +1 -1
  135. package/dist/chunks/gates-6amRNsYl.js +1 -0
  136. package/dist/chunks/{gates-C4JvRq4i.js → gates-vlrMjO-X.js} +1 -1
  137. package/dist/chunks/{gemini-B0M6SQSG.js → gemini-B5ZRjDrh.js} +1 -1
  138. package/dist/chunks/{generateRecap-DhDOgXn3.js → generateRecap-SgRMdsyN.js} +1 -1
  139. package/dist/chunks/{generateSessionName-CoFR2wgK.js → generateSessionName-sZFzpwsq.js} +1 -1
  140. package/dist/chunks/{githubRepoPathMapping-DGiSNykv.js → githubRepoPathMapping-DUGvTwPB.js} +1 -1
  141. package/dist/chunks/{goal-DRb6pPAp.js → goal-Dy-GGn9r.js} +3 -3
  142. package/dist/chunks/{grok-emDua_hT.js → grok-BG4_buNt.js} +1 -1
  143. package/dist/chunks/{growthbook-COAneL48.js → growthbook-Br1dDRtd.js} +1 -1
  144. package/dist/chunks/{heapdump-CA6DHA8G.js → heapdump-B9PVKMxa.js} +1 -1
  145. package/dist/chunks/{help-XXY7deZm.js → help-BfWF7xij.js} +1 -1
  146. package/dist/chunks/hooks-BVrhxysz.js +1 -0
  147. package/dist/chunks/{hooks-C6zZYnDi.js → hooks-KK32pxq3.js} +2 -2
  148. package/dist/chunks/{hostAdapter-DZbdeXCV.js → hostAdapter-TBJav3vX.js} +1 -1
  149. package/dist/chunks/{ide-BLRNkzVx.js → ide-BU1A79BE.js} +2 -2
  150. package/dist/chunks/{inboundAttachments-60kD5Qt_.js → inboundAttachments-D4tBPCB8.js} +1 -1
  151. package/dist/chunks/inboundAttachments-DWJplT9p.js +1 -0
  152. package/dist/chunks/initReplBridge-99sUBVEk.js +1 -0
  153. package/dist/chunks/{insights-BBugI3tW.js → insights-lDHodCMG.js} +1 -1
  154. package/dist/chunks/{install-CuVHbwyW.js → install-Bg4ZgW81.js} +1 -1
  155. package/dist/chunks/{install-github-app-ByyzrlM9.js → install-github-app-RLbUq5EL.js} +2 -2
  156. package/dist/chunks/{install-slack-app-CJGtmacz.js → install-slack-app-CHmIwsbm.js} +1 -1
  157. package/dist/chunks/{instrumentation-C8zvzMg1.js → instrumentation-BCiV3SKX.js} +3 -3
  158. package/dist/chunks/{job-DBf6aPQX.js → job-xOGf0j5Q.js} +1 -1
  159. package/dist/chunks/{keybindings-Bi7SMp5-.js → keybindings-DMbReZ4p.js} +1 -1
  160. package/dist/chunks/{lang-CVDkUhjk.js → lang-A6LUGP_7.js} +1 -1
  161. package/dist/chunks/language-Bzp5KDCE.js +1 -0
  162. package/dist/chunks/{language-BYeqMX74.js → language-CGfURU2y.js} +1 -1
  163. package/dist/chunks/{launchAgentsPlatform-BKqxMFFn.js → launchAgentsPlatform-Dbpm7Jyo.js} +1 -1
  164. package/dist/chunks/{launchAutofixPr-CauX6gOB.js → launchAutofixPr-RZfqx5eM.js} +3 -3
  165. package/dist/chunks/{launchLocalMemory-Brrd_BJC.js → launchLocalMemory-DIntbsvg.js} +2 -2
  166. package/dist/chunks/{launchLocalVault-DtAn656A.js → launchLocalVault-CCUw0ayu.js} +3 -3
  167. package/dist/chunks/{launchMemoryStores-x7_Id7Yr.js → launchMemoryStores-QJTh8KSP.js} +1 -1
  168. package/dist/chunks/{launchOnboarding-DkamFByn.js → launchOnboarding--Pe30AYd.js} +1 -1
  169. package/dist/chunks/{launchSchedule-DjNQNxW4.js → launchSchedule-DjN1RbRX.js} +1 -1
  170. package/dist/chunks/{launchSkillStore-D2GUGhDD.js → launchSkillStore-CcKmVDz1.js} +1 -1
  171. package/dist/chunks/{launchTeleport-DTfhiZkf.js → launchTeleport-BKlEo0yF.js} +3 -3
  172. package/dist/chunks/{launchVault-BZ2Po4r8.js → launchVault-C7UHA-IG.js} +1 -1
  173. package/dist/chunks/{loadAgentsDir-C_wFhytF.js → loadAgentsDir-ClTeo0nk.js} +560 -560
  174. package/dist/chunks/loadAgentsDir-CshktEpX.js +1 -0
  175. package/dist/chunks/loadPluginHooks-DVZmzYLl.js +1 -0
  176. package/dist/chunks/localSearch-BtLNJRij.js +1 -0
  177. package/dist/chunks/{localSearch-B0p0_bjP.js → localSearch-Koc8naSr.js} +1 -1
  178. package/dist/chunks/login-BngE89_j.js +1 -0
  179. package/dist/chunks/{login-C1uE6Pg9.js → login-C3MZQTDL.js} +1 -1
  180. package/dist/chunks/{logoV2Utils-BJHvwGup.js → logoV2Utils-DAIIwt5R.js} +1 -1
  181. package/dist/chunks/logout-CXZBaUen.js +1 -0
  182. package/dist/chunks/{magicDocs-DPZzG7Z2.js → magicDocs-C_inI3JJ.js} +1 -1
  183. package/dist/chunks/{main-CNwSLti2.js → main-qqcmncHA.js} +36 -36
  184. package/dist/chunks/{mappers-Dxs_kNJH.js → mappers-7BSMbYvH.js} +1 -1
  185. package/dist/chunks/{mcp-CbDDqdzF.js → mcp-DRBiobrN.js} +1 -1
  186. package/dist/chunks/mcp-DV8Prhgi.js +1 -0
  187. package/dist/chunks/mcp-HQ8-nEZ1.js +6 -0
  188. package/dist/chunks/{mcpServer-BJNjQXsU.js → mcpServer-CLIYAgGs.js} +1 -1
  189. package/dist/chunks/{mcpServer-Py4Iz9Hx.js → mcpServer-DS0yRfcu.js} +1 -1
  190. package/dist/chunks/memory-Cz_JaFLF.js +1 -0
  191. package/dist/chunks/{mode-CqGusjoT.js → mode-Kx0kSZkr.js} +1 -1
  192. package/dist/chunks/model-Bwvn_acH.js +1 -0
  193. package/dist/chunks/{model-BBULcn7y.js → model-CNXtfiLg.js} +1 -1
  194. package/dist/chunks/{onChangeAppState-BkRihYau.js → onChangeAppState-C4ic-Mib.js} +1 -1
  195. package/dist/chunks/{openai-yNI_zoao.js → openai-CGGSfpPh.js} +3 -3
  196. package/dist/chunks/{overageCreditGrant-Cbh0_fbM.js → overageCreditGrant-BqW_6R5v.js} +1 -1
  197. package/dist/chunks/{panelCall-t10Sud9A.js → panelCall-DgPjuhQf.js} +1 -1
  198. package/dist/chunks/{passes-D_iS6DaC.js → passes-sYE91Vtr.js} +1 -1
  199. package/dist/chunks/{paths-Ci1iwL5Y.js → paths-DO4WOQtD.js} +2 -2
  200. package/dist/chunks/{permissions-CHvu4-yX.js → permissions-BPerbf1I.js} +3 -3
  201. package/dist/chunks/{pipeTransport-EAYXsubu.js → pipeTransport-CW9zF_UN.js} +1 -1
  202. package/dist/chunks/{plan-CP5nq_EB.js → plan-CDKBVRw6.js} +1 -1
  203. package/dist/chunks/{plugin-8apy_RBT.js → plugin-C6US4b8W.js} +1 -1
  204. package/dist/chunks/{pluginAutoupdate-ClrgF5b3.js → pluginAutoupdate-BQKtcAhC.js} +1 -1
  205. package/dist/chunks/{pluginBlocklist-B1LVo0j_.js → pluginBlocklist-B8DKXi0i.js} +1 -1
  206. package/dist/chunks/{pluginCliCommands-eqyMBWcP.js → pluginCliCommands-DWCeXYTl.js} +1 -1
  207. package/dist/chunks/{pluginFlagging-BiTDVP10.js → pluginFlagging-DFMlWw2P.js} +1 -1
  208. package/dist/chunks/{pluginOperations-gZ-iCmhu.js → pluginOperations-CKmwDC3G.js} +1 -1
  209. package/dist/chunks/{pluginStartupCheck-DCDWHam6.js → pluginStartupCheck-D6IbyWKe.js} +1 -1
  210. package/dist/chunks/pluginStartupCheck-cYnLsWOs.js +1 -0
  211. package/dist/chunks/{plugins-BAIVqfi8.js → plugins-BwZIRMh_.js} +1 -1
  212. package/dist/chunks/policyLimits-CFLBtFh3.js +1 -0
  213. package/dist/chunks/{pollConfig-_2W7bHoW.js → pollConfig-C3NjXYFc.js} +1 -1
  214. package/dist/chunks/{poor-Dii0mpOW.js → poor-BHhbua95.js} +1 -1
  215. package/dist/chunks/poorMode-CCK7Ek5w.js +1 -0
  216. package/dist/chunks/{poorMode-aDmmvJ_e.js → poorMode-mtlnXU-z.js} +1 -1
  217. package/dist/chunks/{print-BwSmcUQu.js → print-kxnXkqGc.js} +12 -12
  218. package/dist/chunks/{privacy-settings-DaAgSLKw.js → privacy-settings-DjY1annR.js} +1 -1
  219. package/dist/chunks/{processBashCommand-BZ1_JKu4.js → processBashCommand-BrqLqSva.js} +1 -1
  220. package/dist/chunks/processSlashCommand-DJGdVGbK.js +6 -0
  221. package/dist/chunks/prompt-BZjXpviP.js +1 -0
  222. package/dist/chunks/{prompt-6ZKyqv6z.js → prompt-CfM_xGPc.js} +1 -1
  223. package/dist/chunks/prompt-CusKF4-p.js +1 -0
  224. package/dist/chunks/{promptEditor-Dz41P-3I.js → promptEditor-FI_ewCpV.js} +2 -2
  225. package/dist/chunks/{protocolHandler-CHGHjfdf.js → protocolHandler-B7ybKpgJ.js} +1 -1
  226. package/dist/chunks/{rate-limit-options-BlU9av7g.js → rate-limit-options-DPJMNNou.js} +1 -1
  227. package/dist/chunks/{rcDebugLog-C42A0pX1.js → rcDebugLog-CwU_wJBE.js} +1 -1
  228. package/dist/chunks/{referral-IIcY3jkp.js → referral-Da4mpbd3.js} +1 -1
  229. package/dist/chunks/{refresh-DTGEx7X_.js → refresh-B6X4xb9r.js} +1 -1
  230. package/dist/chunks/{registerProtocol-BkNncGMI.js → registerProtocol-D8fFnceq.js} +1 -1
  231. package/dist/chunks/registry-y_z3pTg3.js +1 -0
  232. package/dist/chunks/{release-notes-BxzOD-zP.js → release-notes--tnd4K56.js} +1 -1
  233. package/dist/chunks/{releaseNotes-C8KQGZHq.js → releaseNotes-BPA229-J.js} +2 -2
  234. package/dist/chunks/{reload-plugins-gYyC6_g8.js → reload-plugins-yQ7tEUVh.js} +1 -1
  235. package/dist/chunks/{remote-env-CEJH5aJh.js → remote-env-CER5UxTX.js} +1 -1
  236. package/dist/chunks/{remoteBridgeCore-Dte7ZUAN.js → remoteBridgeCore-Bi31i8gt.js} +1 -1
  237. package/dist/chunks/{remoteControlServer-GN-eDbEz.js → remoteControlServer-oUAcWB4i.js} +1 -1
  238. package/dist/chunks/{rename-BEU6BNRp.js → rename-BTngRRZU.js} +1 -1
  239. package/dist/chunks/{resume-D36S2rXg.js → resume-DZHKfBmm.js} +2 -2
  240. package/dist/chunks/{runtimeObserver-CDMCeww2.js → runtimeObserver-B4KekIF0.js} +1 -1
  241. package/dist/chunks/{runtimeObserver-DaKaKNVW.js → runtimeObserver-BUOcYxiK.js} +2 -2
  242. package/dist/chunks/sandbox-adapter-C--j-c76.js +1 -0
  243. package/dist/chunks/{sandbox-toggle-BPO26t48.js → sandbox-toggle-DLBL7myN.js} +1 -1
  244. package/dist/chunks/searchExtraTools-CBYp5XeI.js +1 -0
  245. package/dist/chunks/{sentry-9EbPa1Xu.js → sentry-B7ZBc8fA.js} +1 -1
  246. package/dist/chunks/{session-D18B22u4.js → session-DWYQk9YN.js} +1 -1
  247. package/dist/chunks/{sessionDiscovery-B-OTvXJf.js → sessionDiscovery-BP0nv36F.js} +1 -1
  248. package/dist/chunks/sessionFileAccessHooks-DVilA3Mm.js +1 -0
  249. package/dist/chunks/sessionMemory-cMgcTxtP.js +1 -0
  250. package/dist/chunks/{sessionMemory-Ctauybzs.js → sessionMemory-pT4lc1C-.js} +1 -1
  251. package/dist/chunks/sessionMemoryUtils-BgYf2OvX.js +1 -0
  252. package/dist/chunks/sessionObserver-CzyEF7mg.js +1 -0
  253. package/dist/chunks/{sessionObserver-ardnTJ37.js → sessionObserver-D4SV0Ar3.js} +1 -1
  254. package/dist/chunks/sessionStorage-CXBgVAx-.js +1 -0
  255. package/dist/chunks/{sessionTitle-DEKvIVCK.js → sessionTitle-CkrnWEW1.js} +1 -1
  256. package/dist/chunks/{sessionTracing-CJUUEWZ4.js → sessionTracing-Caw-kvQr.js} +1 -1
  257. package/dist/chunks/{settingsSync-BWt3oUR7.js → settingsSync-Dn_lGonC.js} +1 -1
  258. package/dist/chunks/{setup-CDxkPTCq.js → setup-DGkOT4DX.js} +2 -2
  259. package/dist/chunks/{setup-BECFDOT9.js → setup-Dihjl7jo.js} +1 -1
  260. package/dist/chunks/{setup-CmCTB2T_.js → setup-II1titXI.js} +1 -1
  261. package/dist/chunks/{shadowedRuleDetection-BbALfdxE.js → shadowedRuleDetection-DASW3j9H.js} +1 -1
  262. package/dist/chunks/{sideQuestion-BHK6dd1q.js → sideQuestion-C1qbLTAL.js} +1 -1
  263. package/dist/chunks/sink-BSPyC453.js +1 -0
  264. package/dist/chunks/{sink-Do5fWbUC.js → sink-CqOAfFlL.js} +1 -1
  265. package/dist/chunks/{sinks-Dc9V7k6a.js → sinks-BT_lBY6T.js} +2 -2
  266. package/dist/chunks/sinks-CpuRIC3H.js +1 -0
  267. package/dist/chunks/{skill-learning-BHW9G3Dn.js → skill-learning-kh0HKn6u.js} +1 -1
  268. package/dist/chunks/skillChangeDetector-DQuNepIV.js +1 -0
  269. package/dist/chunks/{skillGapStore-Wa7s6orv.js → skillGapStore-B1gUQXhE.js} +2 -2
  270. package/dist/chunks/{skillGapStore-DVMbI2yy.js → skillGapStore-CFmLJlYm.js} +1 -1
  271. package/dist/chunks/{skillGenerator-CBuoIFsH.js → skillGenerator-DIAwRpPg.js} +2 -2
  272. package/dist/chunks/skillLearning-Bxu1Uzl-.js +1 -0
  273. package/dist/chunks/skillLearning-CxAbHYEk.js +1 -0
  274. package/dist/chunks/{skillPanel-2w82nkOl.js → skillPanel-B9zJLHKV.js} +3 -3
  275. package/dist/chunks/{skillSearchPanel-7BhCBkdh.js → skillSearchPanel-C1O9sxYS.js} +2 -2
  276. package/dist/chunks/{skills-D5rMEo2w.js → skills-C6_3snFY.js} +1 -1
  277. package/dist/chunks/{sprites-uNWgVZT6.js → sprites-59l7vF4l.js} +1 -1
  278. package/dist/chunks/{stats-D0CJB2HV.js → stats-BmGdg4nj.js} +1 -1
  279. package/dist/chunks/{status-nte1Arzy.js → status-KLPT7uYP.js} +1 -1
  280. package/dist/chunks/{statusNoticeHelpers-Lqf99003.js → statusNoticeHelpers-DuqyBY-N.js} +1 -1
  281. package/dist/chunks/{tag-BnvWS9HE.js → tag-0vahEnrx.js} +1 -1
  282. package/dist/chunks/{tasks-CEs-pxkC.js → tasks-zVPemGv7.js} +1 -1
  283. package/dist/chunks/teamHelpers-B83RwCCC.js +1 -0
  284. package/dist/chunks/{teamHelpers-D8R_gGLb.js → teamHelpers-CXAmvFco.js} +1 -1
  285. package/dist/chunks/teammateModeSnapshot-AdUFmPGC.js +1 -0
  286. package/dist/chunks/{teammateModeSnapshot-Bdra3VIJ.js → teammateModeSnapshot-CdiglTzv.js} +1 -1
  287. package/dist/chunks/teleport-D6PvdjPy.js +1 -0
  288. package/dist/chunks/{templateJobs-BDKGtmr3.js → templateJobs-Ox5ZTKjW.js} +1 -1
  289. package/dist/chunks/{terminalSetup-Bbvq-9Xl.js → terminalSetup-Dh70ynBX.js} +1 -1
  290. package/dist/chunks/{terminalSetup-C1X-sXwp.js → terminalSetup-hLCi-2uB.js} +1 -1
  291. package/dist/chunks/{theme-DXv6bV7f.js → theme-DxgUVq9C.js} +1 -1
  292. package/dist/chunks/thinkback-C5vFU8dM.js +1 -0
  293. package/dist/chunks/{thinkback-CMsW7mvG.js → thinkback-DWgU7Qhr.js} +1 -1
  294. package/dist/chunks/{thinkback-play-CFdkpzlj.js → thinkback-play-CDzY6Ux4.js} +1 -1
  295. package/dist/chunks/{toolEventObserver-CF7T7FBH.js → toolEventObserver-DPoMAJwr.js} +1 -1
  296. package/dist/chunks/{toolEventObserver-DDJV8cvW.js → toolEventObserver-jO6-mlFU.js} +1 -1
  297. package/dist/chunks/toolPool-BmA-BnAq.js +1 -0
  298. package/dist/chunks/{toolPool-BJv0sBnR.js → toolPool-Dgn1Clq8.js} +1 -1
  299. package/dist/chunks/{trustedDevice-C9nJhhyZ.js → trustedDevice-CYR5AgSB.js} +1 -1
  300. package/dist/chunks/{trustedDevice-C5s2au0k.js → trustedDevice-D35gYkBT.js} +1 -1
  301. package/dist/chunks/{ultrareviewCommand-BEv1_AS1.js → ultrareviewCommand-o4GjzoXK.js} +2 -2
  302. package/dist/chunks/{undercover-DPVt2WN7.js → undercover-B4xr62Ux.js} +1 -1
  303. package/dist/chunks/undercover-nakrQDLh.js +1 -0
  304. package/dist/chunks/{updateCCB-D-4naIUu.js → updateCCB-Cthn50OV.js} +1 -1
  305. package/dist/chunks/{upgrade-CSld83v7.js → upgrade-D4Id4ebd.js} +1 -1
  306. package/dist/chunks/upgrade-DJTCV8sr.js +1 -0
  307. package/dist/chunks/{upload-DVlE8SRp.js → upload-BFDXvdfb.js} +1 -1
  308. package/dist/chunks/{usage-D4Ubnttz.js → usage-Csbso5mD.js} +1 -1
  309. package/dist/chunks/{usage-B_bY46ep.js → usage-DxudeFLL.js} +1 -1
  310. package/dist/chunks/{useMainLoopModel-D3tJJC3y.js → useMainLoopModel-CEqP4HOc.js} +1 -1
  311. package/dist/chunks/{useManagePlugins-B4kcqcyY.js → useManagePlugins-BmS3Adja.js} +1 -1
  312. package/dist/chunks/{useMergedTools-CTQl4cdV.js → useMergedTools-wR6Bglqq.js} +1 -1
  313. package/dist/chunks/{useSearchInput-JPayBRPC.js → useSearchInput-BhKAGgEN.js} +1 -1
  314. package/dist/chunks/{useSettingsErrors-YTgPxnRZ.js → useSettingsErrors-CjK3P-Ki.js} +1 -1
  315. package/dist/chunks/{useVoice-CaBv3G13.js → useVoice-DP1hHBWA.js} +1 -1
  316. package/dist/chunks/{util-Q70qdjeS.js → util-CMSErQoz.js} +1 -1
  317. package/dist/chunks/utils-CAQfwbv8.js +1 -0
  318. package/dist/chunks/{validatePlugin-6lg9B564.js → validatePlugin-_g0AqWZG.js} +1 -1
  319. package/dist/chunks/{vim-zOsQBIp4.js → vim-8y-2Q09k.js} +1 -1
  320. package/dist/chunks/{voice-DBQevAhk.js → voice-BJAsr0K-.js} +1 -1
  321. package/dist/chunks/{voiceModeEnabled-CjBjjeNR.js → voiceModeEnabled-BD9GZhQ3.js} +1 -1
  322. package/dist/chunks/voiceModeEnabled-DZbxaFIg.js +1 -0
  323. package/dist/chunks/{voiceStreamSTT-B8CTbb_6.js → voiceStreamSTT-B1T-8adN.js} +1 -1
  324. package/dist/chunks/voiceStreamSTT-B39XaGOU.js +1 -0
  325. package/dist/chunks/{web-tools-CGqBqo07.js → web-tools-DVIvcP41.js} +1 -1
  326. package/dist/chunks/{workerRegistry-Bx6FvTZF.js → workerRegistry-60_UCyc3.js} +1 -1
  327. package/dist/chunks/worktree-DNK8NprA.js +1 -0
  328. package/dist/chunks/{xml-CVF7dWfi.js → xml-CTdKuU6f.js} +1 -1
  329. package/dist/cli.js +1 -1
  330. package/package.json +1 -1
  331. package/dist/chunks/ApproveApiKey-Cc5SaLqs.js +0 -1
  332. package/dist/chunks/BackgroundTasksDialog-OkUSMj0I.js +0 -2
  333. package/dist/chunks/ClaudeMdExternalIncludesDialog-BbPaorIs.js +0 -1
  334. package/dist/chunks/ConsoleOAuthFlow-Dyv4mI_o.js +0 -1
  335. package/dist/chunks/Doctor-CRrE5Sf4.js +0 -1
  336. package/dist/chunks/Grove-CgX5Fdeh.js +0 -1
  337. package/dist/chunks/MessageSelector-CEvbAZGv.js +0 -3
  338. package/dist/chunks/PluginSettings-D3bQRsge.js +0 -17
  339. package/dist/chunks/QueryEngine-CMcQGyql.js +0 -1
  340. package/dist/chunks/REPL-C9f3ToGu.js +0 -1
  341. package/dist/chunks/ResumeConversation-DxqbAKA4.js +0 -1
  342. package/dist/chunks/SearchExtraToolsTool-BVAhywUI.js +0 -1
  343. package/dist/chunks/SentryErrorBoundary-M1ipwe1n.js +0 -1
  344. package/dist/chunks/Settings-D5EWYL40.js +0 -2
  345. package/dist/chunks/api-BdbBnz5c.js +0 -1
  346. package/dist/chunks/assistant-BMviqf0l.js +0 -1
  347. package/dist/chunks/auth-ORBmEqnH.js +0 -1
  348. package/dist/chunks/backgroundHousekeeping-BAvSPaZ5.js +0 -1
  349. package/dist/chunks/bridgeConfig-B49H_B9L.js +0 -1
  350. package/dist/chunks/bridgeEnabled-DsG2JvIr.js +0 -1
  351. package/dist/chunks/bridgeMain-DYCShrcV.js +0 -1
  352. package/dist/chunks/caches-BsYvQnWV.js +0 -1
  353. package/dist/chunks/changeDetector-By54zja0.js +0 -1
  354. package/dist/chunks/channelNotification-Cx82K1CD.js +0 -1
  355. package/dist/chunks/clear-BQr2zTyP.js +0 -1
  356. package/dist/chunks/client-BbavFXJZ.js +0 -1
  357. package/dist/chunks/color-DOsgZO2n.js +0 -1
  358. package/dist/chunks/commands-CfwfGt3T.js +0 -1
  359. package/dist/chunks/commitAttribution-CH9C_hoL.js +0 -1
  360. package/dist/chunks/context-noninteractive-DCYvLxWx.js +0 -1
  361. package/dist/chunks/conversation-DYUVAAQt.js +0 -1
  362. package/dist/chunks/conversation-NrAy2em3.js +0 -1
  363. package/dist/chunks/createSession-Czx7_nf6.js +0 -1
  364. package/dist/chunks/cron-g_P3I5uT.js +0 -1
  365. package/dist/chunks/datadog-QSR9B7CZ.js +0 -1
  366. package/dist/chunks/envLessBridgeConfig-DSJqg3Ox.js +0 -1
  367. package/dist/chunks/extra-usage-DaxUQk9I.js +0 -1
  368. package/dist/chunks/extractMemories-B3cTWsph.js +0 -1
  369. package/dist/chunks/fast-CHiQGMBE.js +0 -1
  370. package/dist/chunks/gates-DvjyKZVA.js +0 -1
  371. package/dist/chunks/hooks-DOej0jqp.js +0 -1
  372. package/dist/chunks/inboundAttachments-BBYxcnvj.js +0 -1
  373. package/dist/chunks/initReplBridge-Dt2aQBia.js +0 -1
  374. package/dist/chunks/language-BoKr5ylY.js +0 -1
  375. package/dist/chunks/loadAgentsDir-whRB0phu.js +0 -1
  376. package/dist/chunks/loadPluginHooks-CYZjzxyO.js +0 -1
  377. package/dist/chunks/localSearch-DAwFmV2Y.js +0 -1
  378. package/dist/chunks/login-DOyB64Rv.js +0 -1
  379. package/dist/chunks/logout-DTPo3Myl.js +0 -1
  380. package/dist/chunks/mcp-CVnFM6nR.js +0 -6
  381. package/dist/chunks/mcp-CzfQB8BT.js +0 -1
  382. package/dist/chunks/memory-BdUqEKio.js +0 -1
  383. package/dist/chunks/model-BOc_-7m0.js +0 -1
  384. package/dist/chunks/pluginStartupCheck-EjLvCXru.js +0 -1
  385. package/dist/chunks/policyLimits-Cdp3QwZ1.js +0 -1
  386. package/dist/chunks/poorMode-DzEL0cu0.js +0 -1
  387. package/dist/chunks/processSlashCommand-v1Rvzxwn.js +0 -6
  388. package/dist/chunks/prompt-DPqKtC0b.js +0 -1
  389. package/dist/chunks/prompt-WjMHPk90.js +0 -1
  390. package/dist/chunks/registry-CBqb7wbi.js +0 -1
  391. package/dist/chunks/sandbox-adapter-DqTuhgud.js +0 -1
  392. package/dist/chunks/searchExtraTools-Brae4wmG.js +0 -1
  393. package/dist/chunks/sessionFileAccessHooks-BXsK8Dwf.js +0 -1
  394. package/dist/chunks/sessionMemory-Bv-AYifm.js +0 -1
  395. package/dist/chunks/sessionMemoryUtils-D-bzdsAT.js +0 -1
  396. package/dist/chunks/sessionObserver-j8D9hidw.js +0 -1
  397. package/dist/chunks/sessionStorage-Cw5ibYWA.js +0 -1
  398. package/dist/chunks/sink-DFWgcGHX.js +0 -1
  399. package/dist/chunks/sinks-BnkxTOU9.js +0 -1
  400. package/dist/chunks/skillChangeDetector-DwAvG835.js +0 -1
  401. package/dist/chunks/skillLearning-BI2YDG3K.js +0 -1
  402. package/dist/chunks/skillLearning-BZMJRJPp.js +0 -1
  403. package/dist/chunks/teamHelpers-D4vCj2hP.js +0 -1
  404. package/dist/chunks/teammateModeSnapshot-BDJ1JTcl.js +0 -1
  405. package/dist/chunks/teleport-RxTr4aCi.js +0 -1
  406. package/dist/chunks/thinkback-DRJBz3Is.js +0 -1
  407. package/dist/chunks/toolPool-0zCdXfEu.js +0 -1
  408. package/dist/chunks/undercover-DYa00dVv.js +0 -1
  409. package/dist/chunks/upgrade-BHj8ALep.js +0 -1
  410. package/dist/chunks/utils-Cr-x1Oyd.js +0 -1
  411. package/dist/chunks/voiceModeEnabled-DK6u8Aaj.js +0 -1
  412. package/dist/chunks/voiceStreamSTT-CCkOfmdI.js +0 -1
  413. package/dist/chunks/worktree-DPpgPLLG.js +0 -1
@@ -1,22 +1,22 @@
1
- import{a as e,n as t,o as n,r}from"./chunk-DR8-3Aex.js";import{f as i,l as a,n as o,s,u as c}from"./envUtils-BWeoiL4Y.js";import{g as l}from"./client-_sjL0I7A.js";import{n as u,t as d}from"./defineProperty-80gRi2ZW.js";import{n as f,t as p}from"./figures-gfT9mM8P.js";import{n as m,t as h}from"./axios-DhfaybwJ.js";import{Cn as g,Ln as _,un as v,vt as y,wn as b,yn as x}from"./schemas-BGAvj1T4.js";import{i as S,r as C,t as w}from"./v4-f1i_CNUT.js";import{A as T,B as E,Cn as D,Ct as O,F as k,Ft as A,I as j,In as M,K as N,Kt as P,L as ee,Ln as F,Lt as te,M as ne,O as I,Q as re,Rn as L,St as ie,T as ae,Tn as oe,Tt as se,U as ce,Ut as le,Wt as ue,Yt as de,Z as fe,at as pe,b as R,ct as me,en as z,f as B,g as he,gn as ge,h as _e,k as ve,m as ye,nt as V,ot as be,p as xe,qt as Se,t as H,tn as Ce,tt as we,v as Te,wn as Ee,wt as De,x as U,xt as Oe,z as ke,zt as Ae}from"./src-Di342QoJ.js";import{t as je}from"./jsx-runtime-D-D469L8.js";import{A as Me,Ar as Ne,Bt as Pe,Ct as Fe,Dt as Ie,Fr as Le,G as Re,Ht as ze,Jt as Be,K as Ve,Kt as He,Lt as Ue,Mr as We,Nt as Ge,Pr as Ke,Qt as qe,Rt as Je,S as Ye,Sn as Xe,U as Ze,Vt as Qe,W as $e,X as et,Xt as tt,Yt as nt,Zt as rt,an as it,bn as at,cn as ot,er as st,jn as ct,jr as lt,ln as ut,or as dt,ot as ft,qt as pt,rn as mt,sr as ht,tr as gt,tt as _t,ut as vt,vt as yt,xn as bt,y as xt,yn as St,zn as Ct,zt as wt}from"./state-sIHsFpDu.js";import{Ao as Tt,As as Et,Bc as Dt,Br as Ot,Cc as kt,Ci as At,Cs as jt,Da as Mt,Do as Nt,Dr as Pt,Ei as Ft,Et as It,Fa as Lt,Gs as Rt,Hr as zt,Hs as Bt,Ht as Vt,J as Ht,Ka as Ut,Ki as Wt,Kt as Gt,Lr as Kt,Mr as qt,Ms as Jt,Na as Yt,Oa as Xt,Os as Zt,Ot as Qt,Pr as $t,Ps as en,Pt as tn,Qa as nn,Rr as rn,S as an,Si as on,Ss as sn,St as cn,Ti as ln,Ts as un,Uc as dn,Ut as fn,Wr as pn,Xt as mn,Z as hn,_ as gn,_a as _n,a as vn,ac as W,ar as yn,bi as bn,bt as xn,cl as Sn,cn as Cn,ct as wn,d as Tn,dc as En,dn as Dn,dr as On,es as kn,fc as An,gn as jn,h as Mn,it as Nn,jr as Pn,js as Fn,ka as In,ks as Ln,kt as Rn,ll as zn,lo as Bn,mi as Vn,nl as Hn,no as Un,on as Wn,oo as Gn,or as Kn,qi as qn,rl as Jn,rt as Yn,s as Xn,tl as Zn,tn as Qn,us as $n,ut as er,vi as tr,w as nr,wi as rr,wt as ir,xi as ar,xn as or,xs as sr,ya as cr,yc as lr,yi as ur,yn as dr}from"./paths-Ci1iwL5Y.js";import{D as G,E as fr,G as pr,J as mr,O as hr,Q as K,U as gr,Z as _r,_ as vr,h as yr,j as br,l as q,p as J,x as xr,z as Sr}from"./debug-otxXY3j-.js";import{n as Cr,r as Y}from"./analytics-DqMQntaB.js";import{n as wr,t as Tr}from"./cwd--iizewsn.js";import{t as Er}from"./sdk-DEtgRZvI.js";import{F as Dr,P as Or,a as kr,f as Ar,i as jr,v as Mr}from"./git-C0IuvuIy.js";import{l as Nr,u as Pr}from"./oauth-CdZEzMww.js";import{n as Fr,t as Ir}from"./bundledMode-kSQejuY4.js";import{n as Lr,t as Rr}from"./which-BnEnzWhs.js";import{a as zr,i as Br,n as Vr}from"./env-C2A9gV_G.js";import{E as Hr,H as Ur,J as Wr,K as Gr,L as Kr,N as qr,V as Jr,W as Yr,et as Xr,o as Zr,s as Qr}from"./log-DSV4Ht5l.js";import{i as $r,o as ei}from"./platform-mh9ypxS8.js";import{n as ti,t as ni}from"./memoize-DJ1XCN-z.js";import{i as ri,n as ii,o as ai,r as oi}from"./path-BE28AJwZ.js";import{r as si,t as ci}from"./execFileNoThrow-azCkYhmF.js";import{s as li,u as ui}from"./types-KeqFPzY5.js";import{S as di,_ as fi,a as pi,b as mi,d as hi,f as gi,l as _i,n as vi,o as yi,r as bi,u as xi,v as Si,x as Ci}from"./teammate-CbskW5G9.js";import{c as wi,n as Ti,s as Ei,t as Di}from"./intl-CLeE9DsD.js";import{E as Oi,b as ki,d as Ai,f as ji,m as Mi,p as Ni,x as Pi}from"./startupProfiler-CAntGAbs.js";import{n as Fi,t as Ii}from"./lazySchema-B0QShMaQ.js";import{a as Li,c as Ri,d as zi,l as Bi,o as Vi,r as Hi,s as Ui}from"./stringUtils-KZoO4GUd.js";import{$ as Wi,$A as Gi,$D as Ki,$E as qi,$S as Ji,$d as Yi,$f as Xi,$m as Zi,$n as Qi,$p as $i,$t as ea,$u as ta,$y as na,AD as ra,AS as ia,AT as aa,Ab as oa,Ad as sa,Ah as ca,Ai as la,Ao as ua,Ar as da,Ax as fa,Ay as pa,BD as ma,BO as ha,BS as ga,Bb as _a,Bh as va,Bm as ya,Bo as ba,Bp as xa,Br as Sa,Bx as Ca,By as wa,CC as Ta,CE as Ea,CS as Da,Cb as Oa,Cg as ka,Cl as Aa,Cm as ja,Cn as Ma,Co as Na,D as Pa,DC as Fa,DO as Ia,DS as La,DT as Ra,Db as za,Dg as Ba,Dh as Va,Di as Ha,Dm as Ua,Dp as Wa,Du as Ga,Dv as Ka,Dy as qa,EC as Ja,EO as Ya,ES as Xa,ET as Za,Eb as Qa,Ed as $a,Eg as eo,Eh as to,Em as no,Eo as ro,Ex as io,F as ao,FA as oo,FC as so,FD as co,Fc as lo,Fd as uo,Fh as fo,Fj as po,Fm as mo,Fr as ho,Fu as go,Fv as _o,Fx as vo,G as yo,GD as bo,GE as xo,GO as So,GS as Co,GT as wo,Gb as To,Gc as Eo,Gf as Do,Gi as Oo,Gl as ko,Gn as Ao,Gp as jo,Gs as Mo,Gu as No,Gy as Po,HE as Fo,HO as Io,HS as Lo,Ha as Ro,Hi as zo,Hk as Bo,Hl as Vo,Hn as Ho,Hp as Uo,Hs as Wo,Hx as Go,ID as Ko,IE as qo,IO as Jo,Ib as Yo,Id as Xo,Ih as Zo,Ij as Qo,Ik as $o,Ir as es,Is as ts,Iu as ns,Ix as rs,Iy as is,J as as,JA as os,JD as ss,JE as cs,JO as ls,JS as us,Jd as ds,Jf as fs,Jg as ps,Jh as ms,Ji as hs,Jl as gs,Js as _s,Jy as vs,K as ys,KC as bs,KD as xs,KE as Ss,KO as Cs,KS as ws,Ka as Ts,Kc as Es,Kd as Ds,Kf as Os,Kl as ks,Kp as As,Ks as js,Ku as Ms,Ky as Ns,LD as Ps,LE as Fs,LO as Is,Lb as Ls,Lc as Rs,Lh as zs,Lj as Bs,Lm as Vs,Lt as Hs,Lu as Us,Ly as Ws,MA as Gs,MC as Ks,MD as qs,MS as Js,MT as Ys,Mb as Xs,Mc as Zs,Mh as Qs,Mn as $s,Mo as ec,Ms as tc,Mu as nc,Mv as rc,My as ic,N as ac,ND as oc,NS as sc,N_ as cc,Nb as lc,Nh as uc,Nj as dc,No as fc,Nu as pc,Nv as mc,Nx as hc,Ny as gc,O as _c,OC as vc,OS as yc,OT as bc,Ob as xc,Od as Sc,Og as Cc,Oi as wc,Om as Tc,Op as Ec,Ot as Dc,Ou as Oc,P as kc,PC as Ac,PD as jc,P_ as Mc,Pb as Nc,Pc,Ph as Fc,Pj as Ic,Pk as Lc,Po as Rc,Pu as zc,Q as Bc,QD as Vc,QE as Hc,QO as Uc,QS as Wc,QT as Gc,Q_ as Kc,Qf as qc,Qh as Jc,Qk as Yc,Qo as Xc,Qp as Zc,Qr as Qc,Qs as $c,Qu as el,Qy as tl,RA as nl,RD as rl,RE as il,RO as al,R_ as ol,Rc as sl,Rh as cl,Rk as ll,Rm as ul,Rn as dl,Rr as fl,S as pl,SC as ml,SD as hl,SE as gl,SS as _l,ST as vl,Sb as yl,Sd as bl,Sg as xl,Si as Sl,Sl as Cl,Sm as wl,Ss as Tl,Sx as El,TC as Dl,TS as Ol,Tb as kl,Tg as Al,Th as jl,Tj as Ml,Tk as Nl,Ts as Pl,Tt as Fl,Tx as Il,Ty as Ll,UC as Rl,UD as zl,UE as Bl,UO as Vl,US as Hl,Uf as Ul,Uk as Wl,Ul as Gl,Un as Kl,Uo as ql,Up as Jl,Us as Yl,Ux as Xl,VD as Zl,VE as Ql,VO as $l,VS as eu,Va as tu,Vb as nu,Vl as ru,Vm as iu,Vp as au,Vs as ou,Vx as su,Vy as cu,WC as lu,WD as uu,WE as du,WS as fu,Wa as pu,Wb as mu,Wc as hu,Wf as gu,Wi as _u,Wk as vu,Wl as yu,Wn as bu,Wo as xu,Wp as Su,Ws as Cu,XD as wu,XE as Tu,XO as Eu,Xd as Du,Xf as Ou,Xi as ku,Xk as Au,Xp as ju,Xv as Mu,Xw as Nu,Xy as Pu,Y as Fu,YA as Iu,YD as Lu,YO as Ru,YS as zu,Yd as Bu,Yf as Vu,Yg as Hu,Yh as Uu,Yl as Wu,Yu as Gu,Yv as Ku,Yw as qu,Yy as Ju,Z as Yu,ZD as Xu,ZE as Zu,ZO as Qu,ZT as $u,Zd as ed,Zf as td,Zi as nd,Zm as rd,Zo as id,Zp as ad,Zu as od,Zy as sd,_O as cd,_S as ld,_T as ud,__ as dd,_b as fd,_f as pd,_g as md,_i as hd,_j as gd,_o as _d,_u as vd,_y as yd,aA as bd,aC as xd,aS as Sd,aa as Cd,ab as wd,ad as Td,af as Ed,ag as Dd,ah as Od,am as kd,ao as Ad,au as jd,bC as Md,bS as Nd,bT as Pd,ba as Fd,bb as Id,bg as Ld,br as Rd,bu as zd,by as Bd,cD as Vd,cS as Hd,c_ as Ud,ca as Wd,cf as Gd,cg as Kd,ch as qd,ck as Jd,cm as Yd,cu as Xd,dC as Zd,dS as Qd,d_ as $d,db as ef,dc as tf,df as nf,dg as rf,di as af,dk as of,dm as sf,dr as cf,dt as lf,du as uf,dx as df,eC as ff,eD as pf,eO as mf,e_ as hf,ea as gf,eb as _f,ec as vf,ed as yf,ef as bf,eg as xf,eh as Sf,ej as Cf,em as wf,eo as Tf,ep as Ef,ev as Df,ey as Of,fC as kf,fS as Af,fa as jf,fb as Mf,fc as Nf,fd as Pf,ff as Ff,fg as If,fh as Lf,fk as Rf,fl as zf,fm as Bf,fo as Vf,fp as Hf,fs as Uf,ft as Wf,fy as Gf,gO as Kf,gS as qf,g_ as Jf,ga as Yf,gd as Xf,gf as Zf,gg as Qf,gi as $f,gl as ep,go as tp,gr as np,gu as rp,gy as ip,hO as ap,hS as op,h_ as sp,ha as cp,hd as lp,hg as up,hl as dp,ho as fp,hv as pp,hy as mp,iC as hp,iD as gp,i_ as _p,ib as vp,ic as yp,if as bp,ig as xp,ih as Sp,ii as Cp,ik as wp,io as Tp,is as Ep,jC as Dp,jD as Op,jS as kp,jT as Ap,jb as jp,jd as Mp,jh as Np,jl as Pp,jm as Fp,jn as Ip,jo as Lp,ju as Rp,jx as zp,jy as Bp,kD as Vp,kT as Hp,kd as Up,kg as Wp,kl as Gp,km as Kp,ko as qp,kr as Jp,ku as Yp,kx as Xp,ky as Zp,lC as X,lD as Qp,lS as $p,la as em,lb as tm,ld as nm,lf as rm,lg as im,lh as am,lm as om,lu as sm,mO as cm,mS as lm,m_ as um,ma as dm,mb as fm,md as pm,mg as mm,ml as hm,mm as gm,mn as _m,ms as vm,mv as ym,my as bm,nC as xm,nD as Sm,n_ as Cm,na as wm,nb as Tm,nf as Em,ng as Dm,nh as Om,nm as km,nn as Am,np as jm,nt as Mm,o as Nm,oA as Pm,oC as Fm,oS as Im,oa as Lm,ob as Rm,od as zm,of as Bm,og as Vm,oh as Hm,ok as Um,om as Wm,oo as Gm,os as Km,ot as qm,pD as Jm,pO as Ym,p_ as Xm,pa as Zm,pb as Qm,pd as $m,pf as eh,pg as th,ph as nh,pi as rh,pl as ih,pm as ah,po as oh,pp as sh,qA as ch,qC as lh,qD as uh,qE as dh,qO as fh,qS as ph,qT as mh,qc as hh,qd as gh,qf as _h,ql as vh,qs as yh,qt as bh,qx as xh,qy as Sh,rA as Ch,rC as wh,r_ as Th,ra as Eh,rb as Dh,rc as Oh,rf as kh,rg as Ah,rh as jh,rk as Mh,rm as Nh,rr as Ph,rt as Fh,sA as Ih,sC as Lh,sD as Rh,sS as zh,s_ as Bh,sa as Vh,sd as Hh,sf as Uh,sg as Wh,sh as Gh,sk as Kh,sm as qh,so as Jh,sr as Yh,tC as Xh,tD as Zh,tS as Qh,t_ as $h,ta as eg,tb as tg,td as ng,tf as rg,tg as ig,th as ag,tj as og,tm as sg,tp as cg,tt as lg,ty as ug,u as dg,uC as Z,uS as fg,ua as pg,ub as mg,ud as hg,uf as gg,ug as _g,um as vg,uu as yg,ux as bg,uy as xg,vO as Sg,vS as Cg,vT as wg,vb as Tg,vd as Eg,vg as Dg,vj as Og,vo as kg,vs as Ag,vu as jg,vy as Mg,w as Ng,wC as Pg,wD as Fg,wE as Ig,wO as Lg,wS as Rg,wb as zg,wd as Bg,wg as Vg,wh as Hg,wj as Ug,wm as Wg,wo as Gg,ws as Kg,x as qg,xC as Jg,xD as Yg,xS as Xg,xb as Zg,xd as Qg,xg as $g,xk as e_,xl as t_,xm as n_,xo as r_,xu as i_,xx as a_,xy as o_,yO as s_,yS as c_,ya as l_,yb as u_,yd as d_,yg as f_,yi as p_,yu as m_,zE as h_,zO as g_,z_ as __,zb as v_,zh as y_,zk as b_,zm as x_,zn as S_,zo as C_,zp as w_,zx as T_}from"./loadAgentsDir-C_wFhytF.js";import{Hn as E_,Ht as D_,J as O_,Jt as k_,Kn as A_,M as j_,Mn as M_,P as N_,Qn as P_,Rn as F_,Tt as I_,Ut as L_,V as R_,Vn as z_,Xn as B_,Zn as V_,dn as H_,fn as U_,hn as W_,qn as G_,qt as K_,zn as q_}from"./prompt-6ZKyqv6z.js";import{a as J_,n as Y_,r as X_,v as Z_}from"./companion-B_LrjSk5.js";import{r as Q_,t as $_}from"./xml-CVF7dWfi.js";import{a as ev,i as tv,r as nv}from"./shellQuote-CBjhlaFO.js";import{a as rv}from"./ripgrep-Bzwdi5-K.js";import{a as iv,o as av,s as ov}from"./fileStateCache-BhVfo23e.js";import{C as sv,N as cv,S as lv,T as uv,X as dv,b as fv,d as pv,f as mv,j as hv,w as gv,x as _v,y as vv}from"./rcDebugLog-C42A0pX1.js";import{T as yv,c as bv,r as xv,w as Sv}from"./sessionTracing-CJUUEWZ4.js";import{i as Cv,n as wv,r as Tv}from"./parser-aIWfAYnt.js";import{c as Ev,l as Dv}from"./commitAttribution-iKd8bTOI.js";import{n as Ov,t as kv}from"./poorMode-aDmmvJ_e.js";import{A as Av,E as jv,H as Mv,I as Nv,L as Pv,M as Fv,N as Iv,P as Lv,V as Rv,_ as zv,a as Bv,b as Vv,d as Hv,g as Uv,h as Wv,m as Gv,o as Kv,u as qv,x as Jv}from"./teamHelpers-D8R_gGLb.js";import{a as Yv,f as Xv,l as Zv,o as Qv}from"./api-CDmgYrwN.js";import{n as $v,t as ey}from"./browser-Bt-ckCaU.js";import{t as ty}from"./useKeybinding-DPOUuymz.js";import{t as ny}from"./useTerminalSize-Du-EamDN.js";import{c as ry,u as iy}from"./common-Da57Qwms.js";import{i as ay,m as oy,n as sy,p as cy}from"./terminalSetup-C1X-sXwp.js";import{n as ly,r as uy,t as dy}from"./useExitOnCtrlCDWithKeybindings-BHi41Ku_.js";import{a as fy,c as py,o as my,s as hy}from"./constants-BljlAJOX.js";import{n as gy,t as _y}from"./SentryErrorBoundary-D-YZTGQG.js";import{i as vy,r as yy}from"./bridgeEnabled-D9jI6X-w.js";import{i as by,n as xy,t as Sy}from"./voiceModeEnabled-CjBjjeNR.js";import{o as Cy,r as wy,s as Ty}from"./detection-95TCHkW8.js";import{n as Ey,r as Dy}from"./undercover-DPVt2WN7.js";import{t as Oy}from"./lib-Cf16LgKj.js";import{t as ky}from"./Dialog-91X6ZGg9.js";import{n as Ay,t as jy}from"./mappers-Dxs_kNJH.js";import{n as My,r as Ny}from"./sessionTitle-DEKvIVCK.js";import{t as Py}from"./bridgeMessaging-DN0X35NX.js";import{a as Fy,i as Iy,r as Ly,t as Ry}from"./pipeTransport-EAYXsubu.js";import{t as zy}from"./useManagePlugins-B4kcqcyY.js";import{c as By,n as Vy,o as Hy}from"./channelNotification-CoZSFUlb.js";import{a as Uy,c as Wy,n as Gy,o as Ky,s as qy,t as Jy}from"./MCPConnectionManager-D5a9ysw2.js";import{c as Yy,i as Xy,l as Zy,n as Qy,o as $y,r as eb,s as tb,u as nb}from"./cronJitterConfig-2u6WAlti.js";import{i as rb,n as ib}from"./toolPool-BJv0sBnR.js";import{a as ab,c as ob,i as sb,l as cb,o as lb,r as ub,t as db,u as fb}from"./MessageSelector-CEvbAZGv.js";import{n as pb,t as mb}from"./sideQuestion-BHK6dd1q.js";import{a as hb,n as gb,o as _b,r as vb,s as yb,t as bb}from"./skillChangeDetector-DwAvG835.js";import{n as xb,t as Sb}from"./refresh-DTGEx7X_.js";import{i as Cb,n as wb,r as Tb,t as Eb}from"./directoryCompletion-DqtWZsoW.js";import{r as Db,t as Ob}from"./PromptInputFooterSuggestions-DhIQ0Nge.js";import{n as kb,t as Ab}from"./useMergedTools-CTQl4cdV.js";import{a as jb,i as Mb,n as Nb,o as Pb,r as Fb,t as Ib}from"./promptEditor-Dz41P-3I.js";import{n as Lb,t as Rb}from"./useMainLoopModel-D3tJJC3y.js";import{i as zb,n as Bb,r as Vb,t as Hb}from"./PermissionDialog-_WQPRYHQ.js";import{n as Ub,t as Wb}from"./RemoteCallout-Bwe1ESr9.js";import{i as Gb,n as Kb,r as qb,t as Jb}from"./sprites-uNWgVZT6.js";import{a as Yb,n as Xb,t as Zb}from"./setup-BECFDOT9.js";import{a as Qb,c as $b,i as ex,o as tx,r as nx,s as rx}from"./caches-BumkMuGA.js";import{n as ix,t as ax}from"./conversation-DYUVAAQt.js";import{a as ox,i as sx,n as cx,o as lx,r as ux,s as dx,t as fx}from"./extraUsage-P_NGI1-I.js";import{n as px,t as mx}from"./useSearchInput-JPayBRPC.js";import{n as hx,t as gx}from"./useSettingsErrors-YTgPxnRZ.js";import{n as _x,t as vx}from"./shadowedRuleDetection-BbALfdxE.js";import{n as yx,t as bx}from"./ExitFlow-DKusdm_v.js";import{a as xx,c as Sx,i as Cx,l as wx,n as Tx,o as Ex,r as Dx,s as Ox,t as kx}from"./Messages-DTmFVhRG.js";import{n as Ax,t as jx}from"./exportRenderer-DX2L5fQ7.js";import{i as Mx,n as Nx,t as Px}from"./bypassPermissionsKillswitch-kxVnIVRs.js";import{a as Fx,i as Ix,r as Lx,t as Rx}from"./fast-CpN8lLnE.js";import{n as zx,r as Bx}from"./Feedback-Diw8XUr-.js";import{a as Vx,i as Hx,n as Ux,r as Wx,t as Gx}from"./PromptInputHelpMenu-B__j9zE6.js";import{n as Kx,r as qx}from"./language-BYeqMX74.js";import{n as Jx,r as Yx}from"./pluginAutoupdate-ClrgF5b3.js";import{n as Xx,r as Zx}from"./autoModeDenials-DlO5g6E9.js";import{n as Qx,t as $x}from"./generateSessionName-CoFR2wgK.js";import{n as eS,t as tS}from"./fuse-D3B-UE5Y.js";import{a as nS,c as rS,i as iS,l as aS,n as oS,o as sS,r as cS,s as lS,t as uS}from"./BackgroundTasksDialog-OkUSMj0I.js";import{r as dS,t as fS}from"./useVoice-CaBv3G13.js";import{n as pS}from"./fpsMetrics-DKWp7vng.js";import{t as mS}from"./earlyInput-CFYRGxau.js";import{a as hS,c as gS,f as _S,i as vS,l as yS,o as bS,r as xS,s as SS,t as CS}from"./RemoteSessionManager-BKD4YmzY.js";import{n as wS,t as TS}from"./backgroundHousekeeping-Cp2RvmEN.js";import{homedir as ES,tmpdir as DS}from"os";import*as OS from"path";import{basename as kS,dirname as AS,extname as jS,join as MS,relative as NS,sep as PS}from"path";import{dirname as FS,join as IS}from"node:path";import{watch as LS}from"fs";import{createHash as RS}from"node:crypto";import{randomUUID as zS}from"crypto";import{readFile as BS,stat as VS,writeFile as HS}from"fs/promises";import{spawn as US,spawnSync as WS}from"child_process";import{mkdir as GS,readFile as KS,rename as qS,writeFile as JS}from"node:fs/promises";s(),u(),h(),w(),F(),Ee(),O(),f(),Le(),ot(),Sn(),Cr(),wr(),_r(),Er(),gr(),fr(),vr(),q(),Or(),Pr(),Ir(),Rr(),zr(),Hn(),Xr(),Zr(),ei(),ni(),ri(),dn(),si(),Mr(),li(),lr(),Ci(),Ei(),Pi(),Rt(),Ii(),en(),sn(),$n(),Nt(),Vi(),Gn(),Lt(),In(),cr(),qn(),tr(),$t(),On(),Wn(),Qt(),ir(),Yn(),fi(),_i(),Ht(),an(),vn(),Qo(),Ml(),P_(),G_(),E_(),M_(),og(),os(),W_(),rv(),oo(),U_(),k_(),L_(),I_(),R_(),j_(),Ih(),Ch(),av(),Yc(),vu(),ll(),Nl(),of(),Jd(),wp(),Cs(),Lg(),Kf(),mf(),Vc(),Sv(),Tv(),nv(),xs(),ma(),co(),Vp(),hl(),Rh(),gp(),pf(),cv(),Tu(),Q_(),dh(),Fo(),Fs(),Lv(),Ig(),ey(),Ys(),Ap(),Hp(),Ra(),ty(),vl(),ny(),ry(),Nu(),lu(),so(),Fa(),ml(),Md(),X(),Fm(),hp(),xm(),ff(),cy(),ay(),ws(),ia(),Da(),uy(),Xg(),Cg(),lm(),Af(),zh(),Im(),Qh(),Xl(),fa(),oa(),xc(),zg(),Tg(),Vv(),py(),Bv(),wd(),na(),gc(),Bd(),xg(),Of(),pp(),Df(),sp(),Xm(),Th(),gy(),up(),im(),Dm(),Uu(),va(),Qs(),jl(),nh(),qd(),ya(),Kp(),Wg(),Nh(),$i(),ad(),As(),Su(),au(),xa(),Ec(),yy(),jm(),td(),Vu(),Os(),gu(),xy(),vv(),Qg(),lp(),zm(),ta(),No(),nc(),Yp(),i_(),m_(),bv(),Xd(),jd(),gs(),ru(),Gp(),t_(),dp(),ih(),hh(),hu(),Rs(),lo(),tf(),yp(),yh(),tc(),Kg(),Ag(),Uf(),ql(),pu(),Fd(),wm(),ho(),Ho(),Ip(),Ma(),lg(),Bc(),as(),ys(),Ng(),$y(),eb(),jb(),zb(),Bb(),mx(),Tx(),jx(),zx();var Q=n(L(),1);H(),wa();var $=je();function YS({onDone:e}){return(0,$.jsxs)(B,{title:`You've spent $5 on the Anthropic API this session.`,onCancel:e,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(re,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(Sd,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}H(),wa();function XS({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(B,{title:`You've been away ${ZS(e)} and this conversation is ${ki(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(R,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(Sd,{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 ZS(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`}mu();var QS=300,$S=240*1e3,eC=null,tC=null,nC=0,rC=!1;function iC(){nC++,nC===1&&(lC(),sC())}function aC(){nC>0&&nC--,nC===0&&(cC(),uC())}function oC(){nC=0,cC(),uC()}function sC(){process.platform===`darwin`&&tC===null&&(tC=setInterval(()=>{nC>0&&(J(`Restarting caffeinate to maintain sleep prevention`),uC(),lC())},$S),tC.unref())}function cC(){tC!==null&&(clearInterval(tC),tC=null)}function lC(){if(process.platform===`darwin`&&eC===null){rC||(rC=!0,K(async()=>{oC()}));try{eC=US(`caffeinate`,[`-i`,`-t`,String(QS)],{stdio:`ignore`}),eC.unref();let e=eC;eC.on(`error`,t=>{J(`caffeinate spawn error: ${t.message}`),eC===e&&(eC=null)}),eC.on(`exit`,()=>{eC===e&&(eC=null)}),J(`Started caffeinate to prevent sleep`)}catch{eC=null}}}function uC(){if(eC!==null){let e=eC;eC=null;try{e.kill(`SIGKILL`),J(`Stopped caffeinate, allowing sleep`)}catch{}}}var dC=class{constructor(){d(this,`_status`,`idle`),d(this,`_generation`,0),d(this,`_changed`,Ke()),d(this,`subscribe`,this._changed.subscribe),d(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()}};nu(),lc(),Oa(),u_(),tm(),vs(),Gd(),rg(),H(),ef();function fC({name:e,color:t}){return(0,$.jsx)(U,{flexDirection:`row`,gap:1,children:(0,$.jsxs)(R,{color:Mf(t),children:[Fn,` `,(0,$.jsxs)(R,{bold:!0,children:[`@`,e]})]})})}H();function pC({toolName:e,description:t}){let n=pi(),r=vi(),i=yi();return(0,$.jsxs)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:`warning`,paddingX:1,children:[(0,$.jsxs)(U,{marginBottom:1,children:[(0,$.jsx)(Ns,{}),(0,$.jsxs)(R,{color:`warning`,bold:!0,children:[` `,`Waiting for team lead approval`]})]}),r&&i&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(fC,{name:r,color:i})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Tool: `}),(0,$.jsx)(R,{children:e})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Action: `}),(0,$.jsx)(R,{children:t})]}),n&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`Permission request sent to team `,`"`,n,`"`,` leader`]})})]})}gh();function mC(e,t=!1){let n=Z(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(af(p,Nn()?{teamName:n?.teamName,agentName:n?.selfAgentName}:{},m,e).then(e=>{h===o.current&&e&&!u&&(i.current=e)}),u||l||d){let t=Ph(p,e).findLast(es);t&&(i.current=t.uuid)}r.current=e.length,a.current=s},[e,t,n?.teamName,n?.selfAgentName])}function hC(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function gC(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 _C(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&hC(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&hC(t.response)?t.response:void 0,r=gC(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function vC(t){{let{pauseProactive:t}=(vv(),e(sv));t()}t?.abort()}function yC(e,t){return e<t}function bC(e,t){return e&&t===0}function xC({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t?!0:yC(n,r)}Eg();function SC(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 CC(e,t){return e.id.localeCompare(t.id)}function wC(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(SC).sort(CC)}}function TC(e,t){return JSON.stringify(wC(e,t))}function EC(e,t){let n=wC(e,t);return{type:`task_state`,uuid:zS(),...n}}H(),X(),q();var DC=50,OC=5e3,kC=1e4,AC=3;function jC(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=kf(),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 _=Zd(),{addNotification:v}=Lh(),y=Z(e=>e.replBridgeEnabled),b=Z(e=>e.replBridgeConnected),x=Z(e=>e.replBridgeSessionActive),S=Z(e=>e.replBridgeOutboundOnly),C=Z(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)(R,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=AC){J(`[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&&(J(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,J(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),b)return;let{initReplBridge:v}=await import(`./initReplBridge-Dt2aQBia.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-DSJqg3Ox.js`),S=!1;{let{isAssistantMode:e}=await import(`./assistant-BMviqf0l.js`);S=e()}async function w(e){try{let t=Zy(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-BBYxcnvj.js`),i=t.content,a=await r(e,i);J(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),g_({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){J(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function T(e,n){if(b)return;if(r){J(`[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!==``?Ls(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?qo(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,Na(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]),gn(`tengu_bridge_system_init`,!1)&&(async()=>{try{let e=await gf(Tr());if(b)return;let t=_.getState();a.current?.writeSdkMessages([lb({tools:[],mcpClients:[],model:h.current,permissionMode:t.toolPermissionContext.mode,commands:m.current.filter(Eh),agents:t.agentDefinitions.activeAgents,skills:e,plugins:[],fastMode:t.fastMode})])}catch(e){J(`[bridge:repl] Failed to send system/init: ${Sr(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))},kC);break}}let E=new Map;function D(e){let t=e.response?.request_id;if(!t)return;let n=E.get(t);if(!n){J(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=_C(e);if(!r){J(`[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(){vC(n.current)},onSetModel(e){let t=e===`default`?null:e??null;gt(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(_c())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`&&!Pa()){let e=pl();return{ok:!1,error:e?`Cannot set permission mode to auto: ${qg(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=ao(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),setImmediate(()=>{Ds()?.(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){J(`[bridge:repl] Hook: init cancelled during flight, tearing down${k?` env=${k.environmentId}`:``}`),k&&k.teardown();return}if(!k){f.current++,J(`[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))},kC);return}if(a.current=k,d_(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}),J(`[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=qo(k.bridgeSessionId,k.sessionIngressUrl),r=k.environmentId===``?void 0:Ls(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,_d(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),J(`[bridge:repl] Hook initialized, session=${k.bridgeSessionId}`)}}catch(e){if(b)return;f.current++;let n=Sr(e);J(`[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))},kC),r||t(e=>[...e,Na(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{b=!0,clearTimeout(d.current),d.current=void 0,a.current&&(J(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,d_(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&&J(`[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&&bC(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=LS(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=Fv();c(Iv(n));try{let r=await Nv(n);if(e||a.current!==t)return;let i=TC(n,r);if(i===o&&t===s)return;t.writeSdkMessages([EC(n,r)]),o=i,s=t}catch(e){J(`[bridge:repl] Failed to publish task_state: ${Sr(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},DC),t.unref?.()};l();let d=Pv(u);return n=setInterval(()=>{l()},OC),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(bC(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||xC({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}dy(),ub();var MC=Fi(()=>b({method:v(`log_event`),params:b({eventName:_(),eventData:b({}).passthrough()})}));function NC(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Il(e);t&&t.client.setNotificationHandler(MC(),e=>{let{eventName:t,eventData:n}=e.params;Y(`tengu_ide_${t}`,n)})},[e])}ot(),H();var PC=6e3;function FC(){return Date.now()-et()}function IC(e){return FC()<e}function LC(e){return!IC(e)}function RC(e,t){let n=A();(0,Q.useEffect)(()=>{We(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{LC(6e3)&&!r&&(r=!0,clearInterval(i),To({message:e,notificationType:t},n))},PC);return()=>clearInterval(i)},[e,t,n])}Dp(),$h(),Od(),Om(),Zi(),Fb(),H(),ud();var zC={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function BC(e){return wh().syntaxHighlightingDisabled?(0,$.jsx)(HC,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(HC,{...e,highlight:null}),children:(0,$.jsx)(VC,{...e})})}function VC(e){let t=(0,Q.use)(wu());return(0,$.jsx)(HC,{...e,highlight:t})}function HC({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=k(),[s]=ae(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>um(e,s,a),[e,s,a]).split(`
2
- `),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>D(e))),g=Math.min(h+4,c),_=g-4,v=`${zC.topLeft}${zC.horizontal.repeat(g-2)}${zC.topRight}`,y=`${zC.bottomLeft}${zC.horizontal.repeat(g-2)}${zC.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${zC.horizontal.repeat(3)} \u2702 ${zC.horizontal.repeat(3)} ${e} lines hidden `,n=D(t),r=Math.max(0,g-2-n);return`${zC.teeLeft}${t}${zC.horizontal.repeat(r)}${zC.teeRight}`})():null;return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{dimColor:!0,children:v}),m.map((e,t)=>{let n=D(e)>_?wg(e,0,_):e,r=` `.repeat(Math.max(0,_-D(n)));return(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsxs)(R,{dimColor:!0,children:[zC.vertical,` `]}),(0,$.jsx)(fe,{children:n}),(0,$.jsxs)(R,{dimColor:!0,children:[r,` `,zC.vertical]})]},t)}),b&&(0,$.jsx)(R,{color:`warning`,children:b}),(0,$.jsx)(R,{dimColor:!0,children:y})]})}ny(),H(),Pi();function UC({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=k(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${p.tick} Submit `,a=i-(D(`← `)+D(` →`)+D(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+D(e)).reduce((e,t)=>e+t,0)<=a)return o;let s=4+D(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?Oi(e,c-2-2):Oi(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)(R,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?p.checkboxOn:p.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(U,{children:i?(0,$.jsxs)(R,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(R,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(U,{children:t===e.length?(0,$.jsxs)(R,{backgroundColor:`permission`,color:`inverseText`,children:[` `,p.tick,` Submit`,` `]}):(0,$.jsxs)(R,{children:[` `,p.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(R,{color:t===e.length?`inactive`:void 0,children:` →`})]})}f(),ny(),H(),X(),fa();function WC({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:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=Z(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=Mb(),D=E?T_(E):null,O=e.question,A=i[O],j=e.options,[M,N]=(0,Q.useState)(0),P=(0,Q.useRef)(O);if(P.current!==O){P.current=O;let e=A?.selectedValue,t=e?j.findIndex(t=>t.label===e):-1;N(t>=0?t:0)}let ee=j[M],F=A?.selectedValue,te=A?.textInputValue||``,ne=(0,Q.useCallback)(e=>{let t=j[e];t&&(N(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[j,O,c,l]),I=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?M>0?M-1:M:M<j.length-1?M+1:M,t>=0&&t<j.length&&N(t)},[M,j.length,S]);we(`chat:externalEditor`,async()=>{let e=A?.textInputValue||``,t=await Nb(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),V({"tabs:previous":()=>f?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let re=(0,Q.useCallback)(()=>{C(!1),u(!1),F&&l(O,F)},[F,O,l,u]),L=(0,Q.useCallback)(()=>{y(!0)},[]),ie=(0,Q.useCallback)(()=>{y(!1)},[]),ae=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?ie():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),d());return}if(S){e.key===`escape`&&(e.preventDefault(),re());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),M>0&&I(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),M===j.length-1?L():I(`down`);else if(e.key===`return`)e.preventDefault(),ne(M);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<j.length&&I(t)}},[v,b,_,S,M,j.length,ie,L,I,ne,re,h,g,d,u]),oe=ee?.preview||null,{columns:se}=k(),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)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Vb,{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:j.map((e,t)=>{let n=M===t,r=F===e.label;return(0,$.jsxs)(U,{flexDirection:`row`,children:[n?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(R,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(R,{color:`success`,children:[` `,p.tick]})]},e.label)})}),(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(BC,{content:oe||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(Qd,{value:te,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:re,onExit:re,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:te||`press n to add notes`})]})]})]}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,p.arrowUp,`/`,p.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`]})})]})]})]})}f(),H(),X(),jb(),fa(),Fb(),wa(),zb();function GC({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:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=Z(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=Mb(),A=k?T_(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),d(t)},[d]),M=(0,Q.useCallback)(()=>{w(!0)},[]),N=(0,Q.useCallback)(()=>{w(!1)},[]),P=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?N():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,N,_,v,f]),ee=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),F=e.question,te=i[F],ne=(0,Q.useCallback)(async(t,n)=>{let r=await Nb(t);r.content!==null&&r.content!==t&&(n(r.content),l(F,{textInputValue:r.content},e.multiSelect??!1))},[F,l,e.multiSelect]),I={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)}},re=[...ee,I];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(WC,{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:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(U,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:P,children:[S&&o&&(0,$.jsxs)(U,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(R,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(hf,{filePath:o})]})]}),(0,$.jsx)(U,{marginTop:-1,children:(0,$.jsx)(ye,{color:`inactive`})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Vb,{title:e.question,color:`text`}),(0,$.jsxs)(U,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(U,{marginTop:1,children:e.multiSelect?(0,$.jsx)(cu,{options:re,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:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(Sd,{options:re,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:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{color:C&&T===0?`suggestion`:void 0,children:[re.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{color:C&&T===1?`suggestion`:void 0,children:[re.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[p.arrowUp,`/`,p.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}function KC(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 ${M.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${M.bold(Tt(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?` ${M.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${M.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 qC({permissionResult:e,toolType:t}){let n=Z(e=>e.toolPermissionContext.mode),r=KC(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,JC.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[i?(0,JC.jsx)(R,{color:i,children:r.reasonString}):(0,JC.jsx)(R,{children:(0,JC.jsx)(fe,{children:r.reasonString})}),r.configString&&(0,JC.jsx)(R,{dimColor:!0,children:r.configString})]})}var JC,YC=t((()=>{L(),H(),X(),JC=je()}));f(),H(),wa(),zb(),YC();function XC({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)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Vb,{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)(R,{color:`warning`,children:[p.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)(R,{children:[p.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{color:`success`,children:[p.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(qC,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(R,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(Sd,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function ZC(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 QC={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function $C(){let[e,t]=(0,Q.useReducer)(ZC,QC),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}}xm(),ny(),H(),ty(),Cr(),X(),Vc(),sp();var ew=12,tw=40,nw=15;function rw(e){return wh().syntaxHighlightingDisabled?(0,$.jsx)(aw,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(aw,{...e,highlight:null}),children:(0,$.jsx)(iw,{...e})})}function iw(e){let t=(0,Q.use)(wu());return(0,$.jsx)(aw,{...e,highlight:t})}function aw({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>fs.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=k(),[s]=ae(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(ew,o-nw);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=um(e.preview,s,r).split(`
3
- `),i=n.length>a,c=i?a:n.length;o=Math.max(o,c+ +!!i+2);for(let e of n)t=Math.max(t,D(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,ew),n),globalContentWidth:Math.max(t,tw)}},[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};vc(s),Ks(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`),_=Z(e=>e.toolPermissionContext.mode)===`plan`,v=_?yd():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:O}=$C(),A=y<(a?.length||0)?a?.[y]:null,j=y===(a?.length||0),M=a?.every(e=>e?.question&&!!b[e.question])??!1,N=a.length===1&&!a[0]?.multiSelect,P=(0,Q.useCallback)(()=>{u&&Y(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&_h()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),ee=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
1
+ import{a as e,n as t,o as n,r}from"./chunk-DR8-3Aex.js";import{f as i,l as a,n as o,s,u as c}from"./envUtils-BWeoiL4Y.js";import{g as l}from"./client-_sjL0I7A.js";import{n as u,t as d}from"./defineProperty-80gRi2ZW.js";import{n as f,t as p}from"./figures-gfT9mM8P.js";import{n as m,t as h}from"./axios-DhfaybwJ.js";import{Cn as g,Ln as _,un as v,vt as y,wn as b,yn as x}from"./schemas-BGAvj1T4.js";import{i as S,r as C,t as w}from"./v4-f1i_CNUT.js";import{A as T,B as E,Cn as D,Ct as O,F as k,Ft as A,I as j,In as M,K as N,Kt as P,L as ee,Ln as F,Lt as te,M as ne,O as I,Q as re,Rn as L,St as ie,T as ae,Tn as oe,Tt as se,U as ce,Ut as le,Wt as ue,Yt as de,Z as fe,at as pe,b as R,ct as me,en as z,f as B,g as he,gn as ge,h as _e,k as ve,m as ye,nt as V,ot as be,p as xe,qt as Se,t as H,tn as Ce,tt as we,v as Te,wn as Ee,wt as De,x as U,xt as Oe,z as ke,zt as Ae}from"./src-Di342QoJ.js";import{t as je}from"./jsx-runtime-D-D469L8.js";import{A as Me,Ar as Ne,Bt as Pe,Ct as Fe,Dt as Ie,Fr as Le,G as Re,Ht as ze,Jt as Be,K as Ve,Kt as He,Lt as Ue,Mr as We,Nt as Ge,Pr as Ke,Qt as qe,Rt as Je,S as Ye,Sn as Xe,U as Ze,Vt as Qe,W as $e,X as et,Xt as tt,Yt as nt,Zt as rt,an as it,bn as at,cn as ot,er as st,jn as ct,jr as lt,ln as ut,or as dt,ot as ft,qt as pt,rn as mt,sr as ht,tr as gt,tt as _t,ut as vt,vt as yt,xn as bt,y as xt,yn as St,zn as Ct,zt as wt}from"./state-sIHsFpDu.js";import{Ao as Tt,As as Et,Bc as Dt,Br as Ot,Cc as kt,Ci as At,Cs as jt,Da as Mt,Do as Nt,Dr as Pt,Ei as Ft,Et as It,Fa as Lt,Gs as Rt,Hr as zt,Hs as Bt,Ht as Vt,J as Ht,Ka as Ut,Ki as Wt,Kt as Gt,Lr as Kt,Mr as qt,Ms as Jt,Na as Yt,Oa as Xt,Os as Zt,Ot as Qt,Pr as $t,Ps as en,Pt as tn,Qa as nn,Rr as rn,S as an,Si as on,Ss as sn,St as cn,Ti as ln,Ts as un,Uc as dn,Ut as fn,Wr as pn,Xt as mn,Z as hn,_ as gn,_a as _n,a as vn,ac as W,ar as yn,bi as bn,bt as xn,cl as Sn,cn as Cn,ct as wn,d as Tn,dc as En,dn as Dn,dr as On,es as kn,fc as An,gn as jn,h as Mn,it as Nn,jr as Pn,js as Fn,ka as In,ks as Ln,kt as Rn,ll as zn,lo as Bn,mi as Vn,nl as Hn,no as Un,on as Wn,oo as Gn,or as Kn,qi as qn,rl as Jn,rt as Yn,s as Xn,tl as Zn,tn as Qn,us as $n,ut as er,vi as tr,w as nr,wi as rr,wt as ir,xi as ar,xn as or,xs as sr,ya as cr,yc as lr,yi as ur,yn as dr}from"./paths-DO4WOQtD.js";import{D as G,E as fr,G as pr,J as mr,O as hr,Q as K,U as gr,Z as _r,_ as vr,h as yr,j as br,l as q,p as J,x as xr,z as Sr}from"./debug-otxXY3j-.js";import{n as Cr,r as Y}from"./analytics-DqMQntaB.js";import{n as wr,t as Tr}from"./cwd--iizewsn.js";import{t as Er}from"./sdk-DEtgRZvI.js";import{F as Dr,P as Or,a as kr,f as Ar,i as jr,v as Mr}from"./git-C0IuvuIy.js";import{l as Nr,u as Pr}from"./oauth-CdZEzMww.js";import{n as Fr,t as Ir}from"./bundledMode-kSQejuY4.js";import{n as Lr,t as Rr}from"./which-BnEnzWhs.js";import{a as zr,i as Br,n as Vr}from"./env-C2A9gV_G.js";import{E as Hr,H as Ur,J as Wr,K as Gr,L as Kr,N as qr,V as Jr,W as Yr,et as Xr,o as Zr,s as Qr}from"./log-DSV4Ht5l.js";import{i as $r,o as ei}from"./platform-mh9ypxS8.js";import{n as ti,t as ni}from"./memoize-DJ1XCN-z.js";import{i as ri,n as ii,o as ai,r as oi}from"./path-BE28AJwZ.js";import{r as si,t as ci}from"./execFileNoThrow-azCkYhmF.js";import{s as li,u as ui}from"./types-KeqFPzY5.js";import{S as di,_ as fi,a as pi,b as mi,d as hi,f as gi,l as _i,n as vi,o as yi,r as bi,u as xi,v as Si,x as Ci}from"./teammate-CbskW5G9.js";import{c as wi,n as Ti,s as Ei,t as Di}from"./intl-CLeE9DsD.js";import{E as Oi,b as ki,d as Ai,f as ji,m as Mi,p as Ni,x as Pi}from"./startupProfiler-CAntGAbs.js";import{n as Fi,t as Ii}from"./lazySchema-B0QShMaQ.js";import{a as Li,c as Ri,d as zi,l as Bi,o as Vi,r as Hi,s as Ui}from"./stringUtils-KZoO4GUd.js";import{$ as Wi,$A as Gi,$D as Ki,$E as qi,$S as Ji,$d as Yi,$f as Xi,$m as Zi,$n as Qi,$p as $i,$t as ea,$u as ta,$v as na,$y as ra,AD as ia,AS as aa,AT as oa,Ab as sa,Ah as ca,Ai as la,Ao as ua,Ar as da,Au as fa,Av as pa,Ax as ma,Ay as ha,BD as ga,BO as _a,BS as va,Bh as ya,Bm as ba,Bo as xa,Bp as Sa,Br as Ca,Bx as wa,CC as Ta,CE as Ea,CS as Da,Cb as Oa,Cg as ka,Cl as Aa,Cm as ja,Cn as Ma,Co as Na,Cy as Pa,D as Fa,DC as Ia,DO as La,DS as Ra,DT as za,Dd as Ba,Dg as Va,Dh as Ha,Di as Ua,Dm as Wa,Dp as Ga,Du as Ka,Dy as qa,EC as Ja,EO as Ya,ES as Xa,ET as Za,Eb as Qa,Ed as $a,Eg as eo,Eh as to,Em as no,Eo as ro,Eu as io,Ex as ao,F as oo,FA as so,FC as co,FD as lo,Fb as uo,Fc as fo,Fh as po,Fj as mo,Fm as ho,Fr as go,Fu as _o,Fx as vo,Fy as yo,G as bo,GD as xo,GE as So,GO as Co,GS as wo,GT as To,Gb as Eo,Gc as Do,Gd as Oo,Gf as ko,Gi as Ao,Gl as jo,Gn as Mo,Gp as No,Gs as Po,Gy as Fo,HE as Io,HO as Lo,HS as Ro,Ha as zo,Hf as Bo,Hi as Vo,Hk as Ho,Hl as Uo,Hn as Wo,Hp as Go,Hs as Ko,Hx as qo,ID as Jo,IE as Yo,IO as Xo,Ih as Zo,Ij as Qo,Ik as $o,Ir as es,Is as ts,Ix as ns,J as rs,JA as is,JD as as,JE as os,JO as ss,JS as cs,Jd as ls,Jf as us,Jg as ds,Jh as fs,Ji as ps,Jl as ms,Js as hs,Jv as gs,Jy as _s,K as vs,KC as ys,KD as bs,KE as xs,KO as Ss,KS as Cs,Ka as ws,Kc as Ts,Kd as Es,Kl as Ds,Kp as Os,Ks as ks,Ky as As,LD as js,LE as Ms,LO as Ns,Lb as Ps,Lc as Fs,Lh as Is,Lj as Ls,Lm as Rs,Lt as zs,MA as Bs,MC as Vs,MD as Hs,MS as Us,MT as Ws,Mb as Gs,Mc as Ks,Mh as qs,Mn as Js,Mo as Ys,Ms as Xs,Mu as Zs,N as Qs,ND as $s,NS as ec,N_ as tc,Nd as nc,Nh as rc,Nj as ic,No as ac,Nu as oc,Nv as sc,Nx as cc,O as lc,OC as uc,OS as dc,OT as fc,Ob as pc,Od as mc,Og as hc,Oi as gc,Om as _c,Op as vc,Ot as yc,Oy as bc,P as xc,PC as Sc,PD as Cc,P_ as wc,Pb as Tc,Pc as Ec,Pd as Dc,Ph as Oc,Pj as kc,Pk as Ac,Po as jc,Pu as Mc,Py as Nc,Q as Pc,QD as Fc,QE as Ic,QO as Lc,QS as Rc,QT as zc,Q_ as Bc,Qd as Vc,Qf as Hc,Qh as Uc,Qk as Wc,Qo as Gc,Qp as Kc,Qr as qc,Qs as Jc,Qu as Yc,Qv as Xc,Qy as Zc,RA as Qc,RD as $c,RE as el,RO as tl,R_ as nl,Rb as rl,Rc as il,Rh as al,Rk as ol,Rm as sl,Rn as cl,Rr as ll,Ry as ul,S as dl,SC as fl,SD as pl,SE as ml,SS as hl,ST as gl,Sb as _l,Sd as vl,Sg as yl,Si as bl,Sl as xl,Sm as Sl,Ss as Cl,Sx as wl,TC as Tl,TS as El,Tb as Dl,Tg as Ol,Th as kl,Tj as Al,Tk as jl,Ts as Ml,Tt as Nl,Tu as Pl,Tv as Fl,Tx as Il,Ty as Ll,UC as Rl,UD as zl,UE as Bl,UO as Vl,US as Hl,Uf as Ul,Uk as Wl,Ul as Gl,Un as Kl,Uo as ql,Up as Jl,Us as Yl,Uu as Xl,Ux as Zl,Uy as Ql,VD as $l,VE as eu,VO as tu,VS as nu,Va as ru,Vf as iu,Vl as au,Vm as ou,Vp as su,Vs as cu,Vx as lu,WC as uu,WD as du,WE as fu,WS as pu,Wa as mu,Wb as hu,Wc as gu,Wd as _u,Wf as vu,Wi as yu,Wk as bu,Wl as xu,Wn as Su,Wo as Cu,Wp as wu,Ws as Tu,Wu as Eu,Wy as Du,XD as Ou,XE as ku,XO as Au,X_ as ju,Xf as Mu,Xi as Nu,Xk as Pu,Xp as Fu,Xu as Iu,Xw as Lu,Xy as Ru,Y as zu,YA as Bu,YD as Vu,YO as Hu,YS as Uu,Yd as Wu,Yf as Gu,Yg as Ku,Yh as qu,Yl as Ju,Yu,Yw as Xu,Yy as Zu,Z as Qu,ZD as $u,ZE as ed,ZO as td,ZT as nd,Zd as rd,Zf as id,Zi as ad,Zm as od,Zo as sd,Zp as cd,Zu as ld,Zy as ud,_O as dd,_S as fd,_T as pd,__ as md,_b as hd,_d as gd,_g as _d,_i as vd,_j as yd,_o as bd,_u as xd,aA as Sd,aC as Cd,aS as wd,aa as Td,ad as Ed,af as Dd,ag as Od,ah as kd,am as Ad,ao as jd,au as Md,bC as Nd,bS as Pd,bT as Fd,ba as Id,bb as Ld,bd as Rd,bg as zd,br as Bd,cD as Vd,cS as Hd,c_ as Ud,ca as Wd,cb as Gd,cd as Kd,cf as qd,cg as Jd,ch as Yd,ck as Xd,cm as Zd,cu as Qd,cy as $d,dC as ef,dS as tf,d_ as nf,db as rf,dc as af,dd as of,df as sf,dg as cf,di as lf,dk as uf,dm as df,dr as ff,dt as pf,du as mf,dx as hf,eC as gf,eD as _f,eO as vf,e_ as yf,ea as bf,eb as xf,ec as Sf,ef as Cf,eg as wf,eh as Tf,ej as Ef,em as Df,eo as Of,ep as kf,fC as Af,fS as jf,fa as Mf,fb as Nf,fc as Pf,fd as Ff,fg as If,fh as Lf,fk as Rf,fl as zf,fm as Bf,fo as Vf,fp as Hf,fs as Uf,ft as Wf,fv as Gf,fy as Kf,gO as qf,gS as Jf,g_ as Yf,ga as Xf,gb as Zf,gd as Qf,gg as $f,gi as ep,gl as tp,go as np,gr as rp,gu as ip,gy as ap,hO as op,hS as sp,h_ as cp,ha as lp,hb as up,hf as dp,hg as fp,hl as pp,ho as mp,hu as hp,hy as gp,iC as _p,iD as vp,i_ as yp,ib as bp,ic as xp,id as Sp,if as Cp,ig as wp,ih as Tp,ii as Ep,ik as Dp,io as Op,is as kp,jC as Ap,jD as jp,jS as Mp,jT as Np,jb as Pp,jh as Fp,jl as Ip,jm as Lp,jn as Rp,jo as zp,ju as Bp,jv as Vp,jx as Hp,jy as Up,kD as Wp,kT as Gp,kb as Kp,kd as qp,kg as Jp,kl as Yp,km as Xp,ko as Zp,kr as Qp,ku as $p,kx as em,ky as tm,lC as X,lD as nm,lS as rm,la as im,lb as am,lf as om,lg as sm,lh as cm,lm,lu as um,mO as dm,mS as fm,m_ as pm,ma as mm,md as hm,mf as gm,mg as _m,ml as vm,mm as ym,mn as bm,ms as xm,mu as Sm,my as Cm,nC as wm,nD as Tm,n_ as Em,na as Dm,nb as Om,nf as km,ng as Am,nh as jm,nm as Mm,nn as Nm,np as Pm,nt as Fm,o as Im,oA as Lm,oC as Rm,oS as zm,oa as Bm,of as Vm,og as Hm,oh as Um,ok as Wm,om as Gm,oo as Km,os as qm,ot as Jm,pD as Ym,pO as Xm,p_ as Zm,pa as Qm,pd as $m,pg as eh,ph as th,pi as nh,pl as rh,pm as ih,po as ah,pp as oh,pv as sh,py as ch,qA as lh,qC as uh,qD as dh,qE as fh,qO as ph,qS as mh,qT as hh,qc as gh,qd as _h,ql as vh,qs as yh,qt as bh,qu as xh,qv as Sh,qx as Ch,qy as wh,rA as Th,rC as Eh,r_ as Dh,ra as Oh,rb as kh,rc as Ah,rd as jh,rf as Mh,rg as Nh,rh as Ph,rk as Fh,rm as Ih,rr as Lh,rt as Rh,sA as zh,sC as Bh,sD as Vh,sS as Hh,s_ as Uh,sa as Wh,sb as Gh,sd as Kh,sf as qh,sg as Jh,sh as Yh,sk as Xh,sm as Zh,so as Qh,sr as $h,tC as eg,tD as tg,tS as ng,t_ as rg,ta as ig,tb as ag,tf as og,tg as sg,th as cg,tj as lg,tm as ug,tp as dg,tt as fg,u as pg,uC as Z,uS as mg,ua as hg,ub as gg,ud as _g,uf as vg,ug as yg,um as bg,uu as xg,ux as Sg,uy as Cg,vO as wg,vS as Tg,vT as Eg,vb as Dg,vg as Og,vj as kg,vo as Ag,vs as jg,vu as Mg,vy as Ng,w as Pg,wC as Fg,wD as Ig,wE as Lg,wO as Rg,wS as zg,wb as Bg,wd as Vg,wg as Hg,wh as Ug,wj as Wg,wm as Gg,wo as Kg,ws as qg,x as Jg,xC as Yg,xD as Xg,xS as Zg,xb as Qg,xg as $g,xk as e_,xl as t_,xm as n_,xo as r_,xx as i_,yO as a_,yS as o_,ya as s_,yb as c_,yd as l_,yg as u_,yi as d_,yu as f_,yy as p_,zE as m_,zO as h_,z_ as g_,zb as __,zh as v_,zk as y_,zm as b_,zn as x_,zo as S_,zp as C_,zx as w_,zy as T_}from"./loadAgentsDir-ClTeo0nk.js";import{Hn as E_,Ht as D_,J as O_,Jt as k_,Kn as A_,M as j_,Mn as M_,P as N_,Qn as P_,Rn as F_,Tt as I_,Ut as L_,V as R_,Vn as z_,Xn as B_,Zn as V_,dn as H_,fn as U_,hn as W_,qn as G_,qt as K_,zn as q_}from"./prompt-CfM_xGPc.js";import{a as J_,n as Y_,r as X_,v as Z_}from"./companion-Diuav3lA.js";import{r as Q_,t as $_}from"./xml-CTdKuU6f.js";import{a as ev,i as tv,r as nv}from"./shellQuote-CBjhlaFO.js";import{a as rv}from"./ripgrep-Bzwdi5-K.js";import{a as iv,o as av,s as ov}from"./fileStateCache-BhVfo23e.js";import{C as sv,N as cv,S as lv,T as uv,X as dv,b as fv,d as pv,f as mv,j as hv,w as gv,x as _v,y as vv}from"./rcDebugLog-CwU_wJBE.js";import{T as yv,c as bv,r as xv,w as Sv}from"./sessionTracing-Caw-kvQr.js";import{i as Cv,n as wv,r as Tv}from"./parser-aIWfAYnt.js";import{c as Ev,l as Dv}from"./commitAttribution-csu3NO7Y.js";import{n as Ov,t as kv}from"./poorMode-mtlnXU-z.js";import{A as Av,E as jv,H as Mv,I as Nv,L as Pv,M as Fv,N as Iv,P as Lv,V as Rv,_ as zv,a as Bv,b as Vv,d as Hv,g as Uv,h as Wv,m as Gv,o as Kv,u as qv,x as Jv}from"./teamHelpers-CXAmvFco.js";import{a as Yv,f as Xv,l as Zv,o as Qv}from"./api-CQWbpxLP.js";import{n as $v,t as ey}from"./browser-Bt-ckCaU.js";import{t as ty}from"./useKeybinding-DPOUuymz.js";import{t as ny}from"./useTerminalSize-Du-EamDN.js";import{c as ry,u as iy}from"./common-Da57Qwms.js";import{i as ay,m as oy,n as sy,p as cy}from"./terminalSetup-hLCi-2uB.js";import{n as ly,r as uy,t as dy}from"./useExitOnCtrlCDWithKeybindings-BHi41Ku_.js";import{a as fy,c as py,o as my,s as hy}from"./constants-BljlAJOX.js";import{n as gy,t as _y}from"./SentryErrorBoundary-97iY7Nb7.js";import{i as vy,r as yy}from"./bridgeEnabled-Csn6Ym3k.js";import{i as by,n as xy,t as Sy}from"./voiceModeEnabled-BD9GZhQ3.js";import{o as Cy,r as wy,s as Ty}from"./detection-95TCHkW8.js";import{n as Ey,r as Dy}from"./undercover-B4xr62Ux.js";import{t as Oy}from"./lib-Cf16LgKj.js";import{t as ky}from"./Dialog-91X6ZGg9.js";import{n as Ay,t as jy}from"./mappers-7BSMbYvH.js";import{n as My,r as Ny}from"./sessionTitle-CkrnWEW1.js";import{t as Py}from"./bridgeMessaging-ChOzzVWj.js";import{a as Fy,i as Iy,r as Ly,t as Ry}from"./pipeTransport-CW9zF_UN.js";import{t as zy}from"./useManagePlugins-BmS3Adja.js";import{c as By,n as Vy,o as Hy}from"./channelNotification-CWlu9ZWs.js";import{a as Uy,c as Wy,n as Gy,o as Ky,s as qy,t as Jy}from"./MCPConnectionManager-y97Inszc.js";import{c as Yy,i as Xy,l as Zy,n as Qy,o as $y,r as eb,s as tb,u as nb}from"./cronJitterConfig-9OmmYmIT.js";import{i as rb,n as ib}from"./toolPool-Dgn1Clq8.js";import{a as ab,c as ob,i as sb,l as cb,o as lb,r as ub,t as db,u as fb}from"./MessageSelector-DwdAC2io.js";import{n as pb,t as mb}from"./sideQuestion-C1qbLTAL.js";import{a as hb,n as gb,o as _b,r as vb,s as yb,t as bb}from"./skillChangeDetector-DQuNepIV.js";import{n as xb,t as Sb}from"./refresh-B6X4xb9r.js";import{i as Cb,n as wb,r as Tb,t as Eb}from"./directoryCompletion-DqtWZsoW.js";import{r as Db,t as Ob}from"./PromptInputFooterSuggestions-DhIQ0Nge.js";import{n as kb,t as Ab}from"./useMergedTools-wR6Bglqq.js";import{a as jb,i as Mb,n as Nb,o as Pb,r as Fb,t as Ib}from"./promptEditor-FI_ewCpV.js";import{n as Lb,t as Rb}from"./useMainLoopModel-CEqP4HOc.js";import{i as zb,n as Bb,r as Vb,t as Hb}from"./PermissionDialog-_WQPRYHQ.js";import{n as Ub,t as Wb}from"./RemoteCallout-4JOZROfT.js";import{i as Gb,n as Kb,r as qb,t as Jb}from"./sprites-59l7vF4l.js";import{a as Yb,n as Xb,t as Zb}from"./setup-Dihjl7jo.js";import{a as Qb,c as $b,i as ex,o as tx,r as nx,s as rx}from"./caches-CIoVGP24.js";import{n as ix,t as ax}from"./conversation-DyhWeHw2.js";import{a as ox,i as sx,n as cx,o as lx,r as ux,s as dx,t as fx}from"./extraUsage-CbkqfG1U.js";import{n as px,t as mx}from"./useSearchInput-BhKAGgEN.js";import{n as hx,t as gx}from"./useSettingsErrors-CjK3P-Ki.js";import{n as _x,t as vx}from"./shadowedRuleDetection-DASW3j9H.js";import{n as yx,t as bx}from"./ExitFlow-Bz5grDWv.js";import{a as xx,c as Sx,i as Cx,l as wx,n as Tx,o as Ex,r as Dx,s as Ox,t as kx}from"./Messages-FEBcX-cT.js";import{n as Ax,t as jx}from"./exportRenderer-CaegIP5N.js";import{i as Mx,n as Nx,t as Px}from"./bypassPermissionsKillswitch-C0diGLRB.js";import{a as Fx,i as Ix,r as Lx,t as Rx}from"./fast-DS3iQ1CH.js";import{n as zx,r as Bx}from"./Feedback-COgMI5tY.js";import{a as Vx,i as Hx,n as Ux,r as Wx,t as Gx}from"./PromptInputHelpMenu-CoMkWchC.js";import{n as Kx,r as qx}from"./language-CGfURU2y.js";import{n as Jx,r as Yx}from"./pluginAutoupdate-BQKtcAhC.js";import{n as Xx,r as Zx}from"./autoModeDenials-DlO5g6E9.js";import{n as Qx,t as $x}from"./generateSessionName-sZFzpwsq.js";import{n as eS,t as tS}from"./fuse-D3B-UE5Y.js";import{a as nS,c as rS,i as iS,l as aS,n as oS,o as sS,r as cS,s as lS,t as uS}from"./BackgroundTasksDialog-hGlbm5z5.js";import{r as dS,t as fS}from"./useVoice-DP1hHBWA.js";import{n as pS}from"./fpsMetrics-DKWp7vng.js";import{t as mS}from"./earlyInput-CFYRGxau.js";import{a as hS,c as gS,f as _S,i as vS,l as yS,o as bS,r as xS,s as SS,t as CS}from"./RemoteSessionManager-jcPnywfY.js";import{n as wS,t as TS}from"./backgroundHousekeeping-KvOpP_4M.js";import{homedir as ES,tmpdir as DS}from"os";import*as OS from"path";import{basename as kS,dirname as AS,extname as jS,join as MS,relative as NS,sep as PS}from"path";import{dirname as FS,join as IS}from"node:path";import{watch as LS}from"fs";import{createHash as RS}from"node:crypto";import{randomUUID as zS}from"crypto";import{readFile as BS,stat as VS,writeFile as HS}from"fs/promises";import{spawn as US,spawnSync as WS}from"child_process";import{mkdir as GS,readFile as KS,rename as qS,writeFile as JS}from"node:fs/promises";s(),u(),h(),w(),F(),Ee(),O(),f(),Le(),ot(),Sn(),Cr(),wr(),_r(),Er(),gr(),fr(),vr(),q(),Or(),Pr(),Ir(),Rr(),zr(),Hn(),Xr(),Zr(),ei(),ni(),ri(),dn(),si(),Mr(),li(),lr(),Ci(),Ei(),Pi(),Rt(),Ii(),en(),sn(),$n(),Nt(),Vi(),Gn(),Lt(),In(),cr(),qn(),tr(),$t(),On(),Wn(),Qt(),ir(),Yn(),fi(),_i(),Ht(),an(),vn(),Qo(),Al(),P_(),G_(),E_(),M_(),lg(),is(),W_(),rv(),so(),U_(),k_(),L_(),I_(),R_(),j_(),zh(),Th(),av(),Wc(),bu(),ol(),jl(),uf(),Xd(),Dp(),Ss(),Rg(),qf(),vf(),Fc(),Sv(),Tv(),nv(),bs(),ga(),lo(),Wp(),pl(),Vh(),vp(),_f(),cv(),ku(),Q_(),fh(),Io(),Ms(),Lv(),Lg(),ey(),Ws(),Np(),Gp(),za(),ty(),gl(),ny(),ry(),Lu(),uu(),co(),Ia(),fl(),Nd(),X(),Rm(),_p(),wm(),gf(),cy(),ay(),Cs(),aa(),Da(),uy(),Zg(),Tg(),fm(),jf(),Hh(),zm(),ng(),Zl(),ma(),pc(),Qa(),_l(),Zf(),Vv(),py(),Bv(),kh(),ud(),Up(),Ng(),$d(),Xc(),sh(),Bc(),cp(),Zm(),Dh(),gy(),fp(),sm(),Am(),qu(),ya(),qs(),kl(),th(),Yd(),ba(),Xp(),Gg(),Ih(),$i(),cd(),Os(),wu(),su(),Sa(),vc(),yy(),Pm(),id(),Gu(),vu(),Bo(),xy(),vv(),l_(),$m(),Sp(),ld(),Xl(),fa(),Ka(),f_(),xd(),bv(),Qd(),Md(),ms(),au(),Yp(),t_(),pp(),rh(),gh(),gu(),Fs(),fo(),af(),xp(),yh(),Xs(),qg(),jg(),Uf(),ql(),mu(),Id(),Dm(),go(),Wo(),Rp(),Ma(),fg(),Pc(),rs(),vs(),Pg(),$y(),eb(),jb(),zb(),Bb(),mx(),Tx(),jx(),zx();var Q=n(L(),1);H(),ul();var $=je();function YS({onDone:e}){return(0,$.jsxs)(B,{title:`You've spent $5 on the Anthropic API this session.`,onCancel:e,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(re,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(wd,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}H(),ul();function XS({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(B,{title:`You've been away ${ZS(e)} and this conversation is ${ki(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(R,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(wd,{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 ZS(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`}hu();var QS=300,$S=240*1e3,eC=null,tC=null,nC=0,rC=!1;function iC(){nC++,nC===1&&(lC(),sC())}function aC(){nC>0&&nC--,nC===0&&(cC(),uC())}function oC(){nC=0,cC(),uC()}function sC(){process.platform===`darwin`&&tC===null&&(tC=setInterval(()=>{nC>0&&(J(`Restarting caffeinate to maintain sleep prevention`),uC(),lC())},$S),tC.unref())}function cC(){tC!==null&&(clearInterval(tC),tC=null)}function lC(){if(process.platform===`darwin`&&eC===null){rC||(rC=!0,K(async()=>{oC()}));try{eC=US(`caffeinate`,[`-i`,`-t`,String(QS)],{stdio:`ignore`}),eC.unref();let e=eC;eC.on(`error`,t=>{J(`caffeinate spawn error: ${t.message}`),eC===e&&(eC=null)}),eC.on(`exit`,()=>{eC===e&&(eC=null)}),J(`Started caffeinate to prevent sleep`)}catch{eC=null}}}function uC(){if(eC!==null){let e=eC;eC=null;try{e.kill(`SIGKILL`),J(`Stopped caffeinate, allowing sleep`)}catch{}}}var dC=class{constructor(){d(this,`_status`,`idle`),d(this,`_generation`,0),d(this,`_changed`,Ke()),d(this,`subscribe`,this._changed.subscribe),d(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()}};__(),Pp(),Qg(),hd(),Gh(),As(),Vm(),Yi(),H(),am();function fC({name:e,color:t}){return(0,$.jsx)(U,{flexDirection:`row`,gap:1,children:(0,$.jsxs)(R,{color:gg(t),children:[Fn,` `,(0,$.jsxs)(R,{bold:!0,children:[`@`,e]})]})})}H();function pC({toolName:e,description:t}){let n=pi(),r=vi(),i=yi();return(0,$.jsxs)(U,{flexDirection:`column`,borderStyle:`round`,borderColor:`warning`,paddingX:1,children:[(0,$.jsxs)(U,{marginBottom:1,children:[(0,$.jsx)(Du,{}),(0,$.jsxs)(R,{color:`warning`,bold:!0,children:[` `,`Waiting for team lead approval`]})]}),r&&i&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(fC,{name:r,color:i})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Tool: `}),(0,$.jsx)(R,{children:e})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Action: `}),(0,$.jsx)(R,{children:t})]}),n&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`Permission request sent to team `,`"`,n,`"`,` leader`]})})]})}Oo();function mC(e,t=!1){let n=Z(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(lf(p,Nn()?{teamName:n?.teamName,agentName:n?.selfAgentName}:{},m,e).then(e=>{h===o.current&&e&&!u&&(i.current=e)}),u||l||d){let t=Lh(p,e).findLast(es);t&&(i.current=t.uuid)}r.current=e.length,a.current=s},[e,t,n?.teamName,n?.selfAgentName])}function hC(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function gC(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 _C(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&hC(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&hC(t.response)?t.response:void 0,r=gC(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function vC(t){{let{pauseProactive:t}=(vv(),e(sv));t()}t?.abort()}function yC(e,t){return e<t}function bC(e,t){return e&&t===0}function xC({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t?!0:yC(n,r)}Qf();function SC(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 CC(e,t){return e.id.localeCompare(t.id)}function wC(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(SC).sort(CC)}}function TC(e,t){return JSON.stringify(wC(e,t))}function EC(e,t){let n=wC(e,t);return{type:`task_state`,uuid:zS(),...n}}H(),X(),q();var DC=50,OC=5e3,kC=1e4,AC=3;function jC(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=Af(),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 _=ef(),{addNotification:v}=Bh(),y=Z(e=>e.replBridgeEnabled),b=Z(e=>e.replBridgeConnected),x=Z(e=>e.replBridgeSessionActive),S=Z(e=>e.replBridgeOutboundOnly),C=Z(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)(R,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=AC){J(`[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&&(J(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,J(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),b)return;let{initReplBridge:v}=await import(`./initReplBridge-99sUBVEk.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-CDVtIEWT.js`),S=!1;{let{isAssistantMode:e}=await import(`./assistant-B5_xx00q.js`);S=e()}async function w(e){try{let t=Zy(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-DWJplT9p.js`),i=t.content,a=await r(e,i);J(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),h_({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){J(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function T(e,n){if(b)return;if(r){J(`[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!==``?uo(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?Yo(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,Na(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]),gn(`tengu_bridge_system_init`,!1)&&(async()=>{try{let e=await bf(Tr());if(b)return;let t=_.getState();a.current?.writeSdkMessages([lb({tools:[],mcpClients:[],model:h.current,permissionMode:t.toolPermissionContext.mode,commands:m.current.filter(Oh),agents:t.agentDefinitions.activeAgents,skills:e,plugins:[],fastMode:t.fastMode})])}catch(e){J(`[bridge:repl] Failed to send system/init: ${Sr(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))},kC);break}}let E=new Map;function D(e){let t=e.response?.request_id;if(!t)return;let n=E.get(t);if(!n){J(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=_C(e);if(!r){J(`[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(){vC(n.current)},onSetModel(e){let t=e===`default`?null:e??null;gt(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(lc())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`&&!Fa()){let e=dl();return{ok:!1,error:e?`Cannot set permission mode to auto: ${Jg(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=oo(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),setImmediate(()=>{_u()?.(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){J(`[bridge:repl] Hook: init cancelled during flight, tearing down${k?` env=${k.environmentId}`:``}`),k&&k.teardown();return}if(!k){f.current++,J(`[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))},kC);return}if(a.current=k,gd(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}),J(`[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=Yo(k.bridgeSessionId,k.sessionIngressUrl),r=k.environmentId===``?void 0:uo(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,bd(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),J(`[bridge:repl] Hook initialized, session=${k.bridgeSessionId}`)}}catch(e){if(b)return;f.current++;let n=Sr(e);J(`[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))},kC),r||t(e=>[...e,Na(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{b=!0,clearTimeout(d.current),d.current=void 0,a.current&&(J(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,gd(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&&J(`[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&&bC(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=LS(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=Fv();c(Iv(n));try{let r=await Nv(n);if(e||a.current!==t)return;let i=TC(n,r);if(i===o&&t===s)return;t.writeSdkMessages([EC(n,r)]),o=i,s=t}catch(e){J(`[bridge:repl] Failed to publish task_state: ${Sr(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},DC),t.unref?.()};l();let d=Pv(u);return n=setInterval(()=>{l()},OC),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(bC(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||xC({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}dy(),ub();var MC=Fi(()=>b({method:v(`log_event`),params:b({eventName:_(),eventData:b({}).passthrough()})}));function NC(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Il(e);t&&t.client.setNotificationHandler(MC(),e=>{let{eventName:t,eventData:n}=e.params;Y(`tengu_ide_${t}`,n)})},[e])}ot(),H();var PC=6e3;function FC(){return Date.now()-et()}function IC(e){return FC()<e}function LC(e){return!IC(e)}function RC(e,t){let n=A();(0,Q.useEffect)(()=>{We(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{LC(6e3)&&!r&&(r=!0,clearInterval(i),Eo({message:e,notificationType:t},n))},PC);return()=>clearInterval(i)},[e,t,n])}Ap(),rg(),kd(),jm(),Zi(),Fb(),H(),pd();var zC={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function BC(e){return Eh().syntaxHighlightingDisabled?(0,$.jsx)(HC,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(HC,{...e,highlight:null}),children:(0,$.jsx)(VC,{...e})})}function VC(e){let t=(0,Q.use)(Ou());return(0,$.jsx)(HC,{...e,highlight:t})}function HC({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=k(),[s]=ae(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>pm(e,s,a),[e,s,a]).split(`
2
+ `),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>D(e))),g=Math.min(h+4,c),_=g-4,v=`${zC.topLeft}${zC.horizontal.repeat(g-2)}${zC.topRight}`,y=`${zC.bottomLeft}${zC.horizontal.repeat(g-2)}${zC.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${zC.horizontal.repeat(3)} \u2702 ${zC.horizontal.repeat(3)} ${e} lines hidden `,n=D(t),r=Math.max(0,g-2-n);return`${zC.teeLeft}${t}${zC.horizontal.repeat(r)}${zC.teeRight}`})():null;return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{dimColor:!0,children:v}),m.map((e,t)=>{let n=D(e)>_?Eg(e,0,_):e,r=` `.repeat(Math.max(0,_-D(n)));return(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsxs)(R,{dimColor:!0,children:[zC.vertical,` `]}),(0,$.jsx)(fe,{children:n}),(0,$.jsxs)(R,{dimColor:!0,children:[r,` `,zC.vertical]})]},t)}),b&&(0,$.jsx)(R,{color:`warning`,children:b}),(0,$.jsx)(R,{dimColor:!0,children:y})]})}ny(),H(),Pi();function UC({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=k(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${p.tick} Submit `,a=i-(D(`← `)+D(` →`)+D(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+D(e)).reduce((e,t)=>e+t,0)<=a)return o;let s=4+D(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?Oi(e,c-2-2):Oi(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)(R,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?p.checkboxOn:p.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(U,{children:i?(0,$.jsxs)(R,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(R,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(U,{children:t===e.length?(0,$.jsxs)(R,{backgroundColor:`permission`,color:`inverseText`,children:[` `,p.tick,` Submit`,` `]}):(0,$.jsxs)(R,{children:[` `,p.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(R,{color:t===e.length?`inactive`:void 0,children:` →`})]})}f(),ny(),H(),X(),ma();function WC({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:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=Z(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=Mb(),D=E?w_(E):null,O=e.question,A=i[O],j=e.options,[M,N]=(0,Q.useState)(0),P=(0,Q.useRef)(O);if(P.current!==O){P.current=O;let e=A?.selectedValue,t=e?j.findIndex(t=>t.label===e):-1;N(t>=0?t:0)}let ee=j[M],F=A?.selectedValue,te=A?.textInputValue||``,ne=(0,Q.useCallback)(e=>{let t=j[e];t&&(N(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[j,O,c,l]),I=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?M>0?M-1:M:M<j.length-1?M+1:M,t>=0&&t<j.length&&N(t)},[M,j.length,S]);we(`chat:externalEditor`,async()=>{let e=A?.textInputValue||``,t=await Nb(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),V({"tabs:previous":()=>f?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let re=(0,Q.useCallback)(()=>{C(!1),u(!1),F&&l(O,F)},[F,O,l,u]),L=(0,Q.useCallback)(()=>{y(!0)},[]),ie=(0,Q.useCallback)(()=>{y(!1)},[]),ae=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?ie():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),d());return}if(S){e.key===`escape`&&(e.preventDefault(),re());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),M>0&&I(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),M===j.length-1?L():I(`down`);else if(e.key===`return`)e.preventDefault(),ne(M);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<j.length&&I(t)}},[v,b,_,S,M,j.length,ie,L,I,ne,re,h,g,d,u]),oe=ee?.preview||null,{columns:se}=k(),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)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Vb,{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:j.map((e,t)=>{let n=M===t,r=F===e.label;return(0,$.jsxs)(U,{flexDirection:`row`,children:[n?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(R,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(R,{color:`success`,children:[` `,p.tick]})]},e.label)})}),(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(BC,{content:oe||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(tf,{value:te,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:re,onExit:re,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:te||`press n to add notes`})]})]})]}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,p.arrowUp,`/`,p.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`]})})]})]})]})}f(),H(),X(),jb(),ma(),Fb(),ul(),zb();function GC({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:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=Z(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=Mb(),A=k?w_(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),d(t)},[d]),M=(0,Q.useCallback)(()=>{w(!0)},[]),N=(0,Q.useCallback)(()=>{w(!1)},[]),P=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?N():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,N,_,v,f]),ee=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),F=e.question,te=i[F],ne=(0,Q.useCallback)(async(t,n)=>{let r=await Nb(t);r.content!==null&&r.content!==t&&(n(r.content),l(F,{textInputValue:r.content},e.multiSelect??!1))},[F,l,e.multiSelect]),I={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)}},re=[...ee,I];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(WC,{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:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(U,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:P,children:[S&&o&&(0,$.jsxs)(U,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(R,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(yf,{filePath:o})]})]}),(0,$.jsx)(U,{marginTop:-1,children:(0,$.jsx)(ye,{color:`inactive`})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Vb,{title:e.question,color:`text`}),(0,$.jsxs)(U,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(U,{marginTop:1,children:e.multiSelect?(0,$.jsx)(T_,{options:re,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:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(wd,{options:re,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:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:ne,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{color:C&&T===0?`suggestion`:void 0,children:[re.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(U,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(R,{color:`suggestion`,children:p.pointer}):(0,$.jsx)(R,{children:` `}),(0,$.jsxs)(R,{color:C&&T===1?`suggestion`:void 0,children:[re.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[p.arrowUp,`/`,p.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}function KC(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 ${M.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${M.bold(Tt(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?` ${M.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${M.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 qC({permissionResult:e,toolType:t}){let n=Z(e=>e.toolPermissionContext.mode),r=KC(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,JC.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[i?(0,JC.jsx)(R,{color:i,children:r.reasonString}):(0,JC.jsx)(R,{children:(0,JC.jsx)(fe,{children:r.reasonString})}),r.configString&&(0,JC.jsx)(R,{dimColor:!0,children:r.configString})]})}var JC,YC=t((()=>{L(),H(),X(),JC=je()}));f(),H(),ul(),zb(),YC();function XC({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)(ye,{color:`inactive`}),(0,$.jsxs)(U,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(UC,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Vb,{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)(R,{color:`warning`,children:[p.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)(R,{children:[p.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{color:`success`,children:[p.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(qC,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(R,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(wd,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function ZC(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 QC={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function $C(){let[e,t]=(0,Q.useReducer)(ZC,QC),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}}wm(),ny(),H(),ty(),Cr(),X(),Fc(),cp();var ew=12,tw=40,nw=15;function rw(e){return Eh().syntaxHighlightingDisabled?(0,$.jsx)(aw,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(aw,{...e,highlight:null}),children:(0,$.jsx)(iw,{...e})})}function iw(e){let t=(0,Q.use)(Ou());return(0,$.jsx)(aw,{...e,highlight:t})}function aw({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>us.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=k(),[s]=ae(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(ew,o-nw);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=pm(e.preview,s,r).split(`
3
+ `),i=n.length>a,c=i?a:n.length;o=Math.max(o,c+ +!!i+2);for(let e of n)t=Math.max(t,D(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,ew),n),globalContentWidth:Math.max(t,tw)}},[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};uc(s),Vs(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`),_=Z(e=>e.toolPermissionContext.mode)===`plan`,v=_?gp():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:O}=$C(),A=y<(a?.length||0)?a?.[y]:null,j=y===(a?.length||0),M=a?.every(e=>e?.question&&!!b[e.question])??!1,N=a.length===1&&!a[0]?.multiSelect,P=(0,Q.useCallback)(()=>{u&&Y(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ko()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),ee=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
4
  This means they may have additional information, context or questions for you.
5
5
  Take their response into account and then reformulate the questions if appropriate.
6
6
  Start by asking them what they would like to clarify.
7
7
 
8
8
  Questions asked:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
- `)}`;u&&Y(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&_h()});let r=await ow(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.
9
+ `)}`;u&&Y(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ko()});let r=await ow(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.
10
10
  Stop asking clarifying questions and proceed to finish the plan with the information you have.
11
11
 
12
12
  Questions asked and answers provided:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
- `)}`;u&&Y(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&_h()});let r=await ow(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:_&&_h()});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 ow(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),ne=(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(Qr);return}E(e,i,r)},[E,a.length,b,te,d]);function I(e){if(e===`cancel`){P();return}e===`submit`&&te(b).catch(Qr)}let re=N?(a?.length||1)-1:a?.length||0,L=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),ie=(0,Q.useCallback)(()=>{y<re&&C()},[y,re,C]);return V({"tabs:previous":L,"tabs:next":ie},{context:`Tabs`,isActive:!(S&&!j)}),A?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(GC,{question:A,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:N,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:ne,onTextInputFocus:O,onCancel:P,onSubmit:C,onTabPrev:L,onTabNext:ie,onRespondToClaude:ee,onFinishPlanInterview:F,onImagePaste:(e,t,n,r,i)=>m(A.question,e,t,n,r,i),pastedContents:d[A.question]??{},onRemoveImage:e=>h(A.question,e)})}):j?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(XC,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:M,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:I})}):null}async function ow(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Rf({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var sw=[{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 cw(e){for(let{pattern:t,warning:n}of sw)if(t.test(e))return n;return null}var lw=[`http://`,`https://`,`ftp://`],uw={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},dw=e=>Array.isArray(e)?e:[e];function fw(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 pw(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(`-`)?!fw(t,n):!1}function mw(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){pw(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||fw(r,t))return r}}}async function hw(e,t,n){let r=await gw(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&&dw(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){pw(c,t[s+1],n)&&s++;continue}break}if(await _w(c,t.slice(0,s),n))break;a&&!o&&(o=fw(c,n)),i.push(c)}return i.join(` `)}async function gw(e,t,n){let r=mw(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(uw[a])return uw[a];if(uw[i])return uw[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&&dw(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=dw(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=dw(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&&dw(n.args).some(e=>e?.isDangerous)?3:2}async function _w(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=lw.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&&dw(e.args).some(e=>e?.isModule))return!1}return!0}var vw=[{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 yw(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 bw=ti(async e=>vw.find(t=>t.name===e)||await yw(e)||null,e=>e),xw=/^\d+$/,Sw=/^[A-Za-z_][A-Za-z0-9_]*=/,Cw=new Set([`nice`]),ww=e=>Array.isArray(e)?e:[e];function Tw(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Ew(e,t=0,n=0){if(n>2||t>10)return null;let r=await Cv(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=wv(a);if(!o)return{commandPrefix:null};let c=await bw(o),l=Cw.has(o)||c?.args&&ww(c.args).some(e=>e?.isCommand);l&&s[0]&&Tw(s[0],c)&&(l=!1);let u=l?await Dw(o,s,t,n):await hw(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 Dw(e,t,n,r){let i=await bw(e);if(i?.args){let a=ww(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 Ew(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(`-`)&&!Sw.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!xw.test(e)&&!Sw.test(e));if(!a)return e;let o=await Ew(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Ow(e,t){let n=Wi(e);if(n.length<=1){let t=await Ew(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Ew(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(kw(e));return a}function kw(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 Aw(e){Y(`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 jw=t((()=>{Cr()}));Nd(),Qm(),Cr(),Bc(),Nt(),X(),jw();function Mw(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=oc(e.suggestions),n=t.length>0?t.map(e=>Tt(e)).join(`, `):`none`;return`ask: ${e.message},
13
+ `)}`;u&&Y(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&ko()});let r=await ow(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:_&&ko()});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 ow(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),ne=(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(Qr);return}E(e,i,r)},[E,a.length,b,te,d]);function I(e){if(e===`cancel`){P();return}e===`submit`&&te(b).catch(Qr)}let re=N?(a?.length||1)-1:a?.length||0,L=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),ie=(0,Q.useCallback)(()=>{y<re&&C()},[y,re,C]);return V({"tabs:previous":L,"tabs:next":ie},{context:`Tabs`,isActive:!(S&&!j)}),A?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(GC,{question:A,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:N,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:ne,onTextInputFocus:O,onCancel:P,onSubmit:C,onTabPrev:L,onTabNext:ie,onRespondToClaude:ee,onFinishPlanInterview:F,onImagePaste:(e,t,n,r,i)=>m(A.question,e,t,n,r,i),pastedContents:d[A.question]??{},onRemoveImage:e=>h(A.question,e)})}):j?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(XC,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:M,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:I})}):null}async function ow(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Rf({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var sw=[{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 cw(e){for(let{pattern:t,warning:n}of sw)if(t.test(e))return n;return null}var lw=[`http://`,`https://`,`ftp://`],uw={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},dw=e=>Array.isArray(e)?e:[e];function fw(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 pw(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(`-`)?!fw(t,n):!1}function mw(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){pw(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||fw(r,t))return r}}}async function hw(e,t,n){let r=await gw(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&&dw(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){pw(c,t[s+1],n)&&s++;continue}break}if(await _w(c,t.slice(0,s),n))break;a&&!o&&(o=fw(c,n)),i.push(c)}return i.join(` `)}async function gw(e,t,n){let r=mw(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(uw[a])return uw[a];if(uw[i])return uw[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&&dw(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=dw(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=dw(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&&dw(n.args).some(e=>e?.isDangerous)?3:2}async function _w(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=lw.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&&dw(e.args).some(e=>e?.isModule))return!1}return!0}var vw=[{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 yw(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 bw=ti(async e=>vw.find(t=>t.name===e)||await yw(e)||null,e=>e),xw=/^\d+$/,Sw=/^[A-Za-z_][A-Za-z0-9_]*=/,Cw=new Set([`nice`]),ww=e=>Array.isArray(e)?e:[e];function Tw(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Ew(e,t=0,n=0){if(n>2||t>10)return null;let r=await Cv(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=wv(a);if(!o)return{commandPrefix:null};let c=await bw(o),l=Cw.has(o)||c?.args&&ww(c.args).some(e=>e?.isCommand);l&&s[0]&&Tw(s[0],c)&&(l=!1);let u=l?await Dw(o,s,t,n):await hw(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 Dw(e,t,n,r){let i=await bw(e);if(i?.args){let a=ww(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 Ew(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(`-`)&&!Sw.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!xw.test(e)&&!Sw.test(e));if(!a)return e;let o=await Ew(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Ow(e,t){let n=Wi(e);if(n.length<=1){let t=await Ew(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Ew(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(kw(e));return a}function kw(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 Aw(e){Y(`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 jw=t((()=>{Cr()}));Pd(),rf(),Cr(),Pc(),Nt(),X(),jw();function Mw(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=$s(e.suggestions),n=t.length>0?t.map(e=>Tt(e)).join(`, `):`none`;return`ask: ${e.message},
14
14
  suggestions: ${n}
15
15
  reason: ${Nw(e.decisionReason)}`}case`deny`:return`deny: ${e.message},
16
- reason: ${Nw(e.decisionReason)}`;case`passthrough`:{let t=oc(e.suggestions),n=t.length>0?t.map(e=>Tt(e)).join(`, `):`none`;return`passthrough: ${e.message},
16
+ reason: ${Nw(e.decisionReason)}`;case`passthrough`:{let t=$s(e.suggestions),n=t.length>0?t.map(e=>Tt(e)).join(`, `):`none`;return`passthrough: ${e.message},
17
17
  suggestions: ${n}
18
18
  reason: ${Nw(e.decisionReason)}`}}}function Nw(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: ${Tt(e.rule.ruleValue)}`;case`mode`:return`Mode: ${e.mode}`;case`subcommandResults`:return`Subcommand Results: ${Array.from(e.reasons.entries()).map(([e,t])=>`${e}: ${Mw(t)}`).join(`,
19
- `)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${hr(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 hr(e,null,2)}}function Pw(e,t){let n=kf(),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}})),Y(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:hn(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:Gs.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===zd.name&&t.behavior===`ask`&&!jc(t.suggestions)&&Y(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:hn(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:Gs.isSandboxingEnabled(),decisionReasonDetails:Nw(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=zd.inputSchema.safeParse(e.input);if(e.tool.name===zd.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=Wi(t.data.command)}catch{}Y(`tengu_internal_bash_tool_use_permission_request`,{parts:hr(n),input:hr(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:Nw(e.permissionResult.decisionReason)})}}Aw({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Vr.platform}})}},[e,t,n])}F(),f(),H(),X(),co(),Nt(),_x(),oo();function Fw(e){if(e.type===`classifier`)return`${M.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${M.bold(Tt(e.rule.ruleValue))} rule from ${Bt(e.rule.source)}`;case`mode`:return`${Ln(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`${M.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${M.bold(e.hookName)} hook: ${e.reason}`:`${M.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Iw({title:e,decisionReason:t}){let[n]=ae();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)(R,{children:[t.behavior===`allow`?Te(`success`,n)(p.tick):Te(`error`,n)(p.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(fe,{children:Fw(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Lw,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(R,{children:(0,$.jsx)(fe,{children:Fw(t)})})}}return(0,$.jsxs)(U,{flexDirection:`column`,children:[e&&(0,$.jsx)(R,{children:e}),r()]})}function Lw({suggestions:e}){let t=oc(e);return t.length===0?null:(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(fe,{children:t.map(e=>M.bold(Tt(e))).join(`, `)})]})}function Rw(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function zw(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Bw({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)(R,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(R,{children:`None`})]});let n=oc(e),r=Rw(e),i=zw(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)(R,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(R,{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)(R,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(R,{children:` `})]}),n.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(U,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(R,{children:[p.bullet,` `,Tt(e)]},t))})]}),r.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(U,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(R,{children:[p.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(R,{children:Ln(i)})]})]})}function Vw({permissionResult:e,toolName:t}){let n=Z(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=vx(n,{sandboxAutoAllowEnabled:Gs.isSandboxingEnabled()&&Gs.isAutoAllowBashIfSandboxedEnabled()}),r=oc(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)(R,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(R,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(R,{dimColor:!0,children:`Message `})}),(0,$.jsx)(R,{children:e.message})]}),(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(R,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(R,{children:`undefined`}):(0,$.jsx)(Iw,{decisionReason:r})]}),(0,$.jsx)(Bw,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(R,{color:`warning`,children:[p.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(U,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(R,{color:`warning`,children:Tt(e.rule.ruleValue)}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}w(),Cr(),Ht(),q(),gr(),Ii(),Zr(),kv(),ol(),fr();var Hw={LOW:1,MEDIUM:2,HIGH:3},Uw=1,Ww=2,Gw=3,Kw=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,qw={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`]}},Jw=Fi(()=>b({riskLevel:y([`LOW`,`MEDIUM`,`HIGH`]),explanation:_(),reasoning:_(),risk:_()}));function Yw(e){if(typeof e==`string`)return e;try{return hr(e,null,2)}catch{return String(e)}}function Xw(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(`
19
+ `)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${hr(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 hr(e,null,2)}}function Pw(e,t){let n=Af(),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}})),Y(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:hn(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:Bs.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===Mg.name&&t.behavior===`ask`&&!Cc(t.suggestions)&&Y(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:hn(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:Bs.isSandboxingEnabled(),decisionReasonDetails:Nw(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=Mg.inputSchema.safeParse(e.input);if(e.tool.name===Mg.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=Wi(t.data.command)}catch{}Y(`tengu_internal_bash_tool_use_permission_request`,{parts:hr(n),input:hr(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:Nw(e.permissionResult.decisionReason)})}}Aw({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Vr.platform}})}},[e,t,n])}F(),f(),H(),X(),lo(),Nt(),_x(),so();function Fw(e){if(e.type===`classifier`)return`${M.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${M.bold(Tt(e.rule.ruleValue))} rule from ${Bt(e.rule.source)}`;case`mode`:return`${Ln(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`${M.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${M.bold(e.hookName)} hook: ${e.reason}`:`${M.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Iw({title:e,decisionReason:t}){let[n]=ae();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)(R,{children:[t.behavior===`allow`?Te(`success`,n)(p.tick):Te(`error`,n)(p.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(fe,{children:Fw(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Lw,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(R,{children:(0,$.jsx)(fe,{children:Fw(t)})})}}return(0,$.jsxs)(U,{flexDirection:`column`,children:[e&&(0,$.jsx)(R,{children:e}),r()]})}function Lw({suggestions:e}){let t=$s(e);return t.length===0?null:(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(fe,{children:t.map(e=>M.bold(Tt(e))).join(`, `)})]})}function Rw(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function zw(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Bw({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)(R,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(R,{children:`None`})]});let n=$s(e),r=Rw(e),i=zw(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)(R,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(R,{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)(R,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(R,{children:` `})]}),n.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(U,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(R,{children:[p.bullet,` `,Tt(e)]},t))})]}),r.length>0&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(U,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(R,{children:[p.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(R,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(R,{children:Ln(i)})]})]})}function Vw({permissionResult:e,toolName:t}){let n=Z(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=vx(n,{sandboxAutoAllowEnabled:Bs.isSandboxingEnabled()&&Bs.isAutoAllowBashIfSandboxedEnabled()}),r=$s(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)(R,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(R,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(R,{dimColor:!0,children:`Message `})}),(0,$.jsx)(R,{children:e.message})]}),(0,$.jsxs)(U,{flexDirection:`row`,children:[(0,$.jsx)(U,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(R,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(R,{children:`undefined`}):(0,$.jsx)(Iw,{decisionReason:r})]}),(0,$.jsx)(Bw,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(R,{color:`warning`,children:[p.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(U,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(R,{color:`warning`,children:Tt(e.rule.ruleValue)}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(R,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}w(),Cr(),Ht(),q(),gr(),Ii(),Zr(),kv(),nl(),fr();var Hw={LOW:1,MEDIUM:2,HIGH:3},Uw=1,Ww=2,Gw=3,Kw=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,qw={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`]}},Jw=Fi(()=>b({riskLevel:y([`LOW`,`MEDIUM`,`HIGH`]),explanation:_(),reasoning:_(),risk:_()}));function Yw(e){if(typeof e==`string`)return e;try{return hr(e,null,2)}catch{return String(e)}}function Xw(e,t=1e3){let n=e.filter(e=>e.type===`assistant`).slice(-3),r=[],i=0;for(let e of n.reverse()){let n=(Array.isArray(e.message.content)?e.message.content:[]).filter(e=>e.type===`text`).map(e=>`text`in e?e.text:``).join(` `);if(n&&i<t){let e=t-i,a=n.length>e?n.slice(0,e)+`...`:n;r.unshift(a),i+=a.length}}return r.join(`
20
20
 
21
21
  `)}function Zw(){return En().permissionExplainerEnabled!==!1}async function Qw({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!Zw())return null;let a=Date.now();try{let o=Yw(t),s=r?.length?Xw(r):``,c=`Tool: ${e}
22
22
  ${n?`Description: ${n}\n`:``}
@@ -24,12 +24,12 @@ Input:
24
24
  ${o}
25
25
  ${s?`\nRecent conversation context:\n${s}`:``}
26
26
 
27
- Explain this command in context.`,l=await __({model:Ov()?qt():Pt(),system:Kw,messages:[{role:`user`,content:c}],tools:[qw],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;J(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){J(`Permission explainer: tool input: ${hr(d.input).slice(0,500)}`);let t=Jw().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:hn(e),risk_level:Hw[n.riskLevel],latency_ms:u}),J(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Y(`tengu_permission_explainer_error`,{tool_name:hn(e),error_type:Uw,latency_ms:u}),J(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(J(`Permission explainer: request aborted for ${e}`),null):(J(`Permission explainer error: ${Sr(t)}`),Qr(t),Y(`tengu_permission_explainer_error`,{tool_name:hn(e),error_type:t instanceof Error&&t.name===`AbortError`?Ww:Gw,latency_ms:n}),null)}}H(),ty(),Cr();var $w=`Loading explanation…`;function eT(){let[e,t]=fm(`responding`,$w,!1);return(0,$.jsx)(U,{ref:e,children:(0,$.jsx)(R,{children:$w.split(``).map((e,n)=>(0,$.jsx)(c_,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function tT(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function nT(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function rT(e){return Qw({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function iT(e){let t=Zw(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return we(`confirm:toggleExplanation`,()=>{n||(Y(`tengu_permission_explainer_shortcut_used`,{}),i||a(rT(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function aT({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(R,{children:t.explanation}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:t.reasoning})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{color:tT(t.riskLevel),children:[nT(t.riskLevel),`:`]}),(0,$.jsxs)(R,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Explanation unavailable`})})}function oT({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(eT,{})}),children:(0,$.jsx)(aT,{promise:t})})}ny(),H(),Zr(),kd(),vg();function sT(e){let[t]=(0,Q.useState)(()=>uT(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(lT,{placeholder:!0}),children:(0,$.jsx)(cT,{promise:t,file_path:e.file_path})})}function cT({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=k();return(0,$.jsx)(lT,{children:(0,$.jsx)(om,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function lT({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)(R,{dimColor:!0,children:`…`}):e})})}async function uT(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 dT(e,[r]);try{let t=await Wm(e);if(t===null)return dT(e,n);try{if(!r||r.old_string===``){let r=await qh(t);return r===null?dT(e,n):{patch:wl({filePath:e,fileContents:r,edits:n.map(e=>fT(r,e))}),firstLine:Li(r),fileContent:r}}let i=await Yd(t,r.old_string,3);if(i.truncated||i.content===``)return dT(e,[r]);let a=fT(i.content,r);return{patch:n_(wl({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Li(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Qr(t),dT(e,n)}}function dT(e,t){return{patch:t.flatMap(t=>wl({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function fT(e,t){let n=wf(e,t.old_string)||t.old_string;return{...t,old_string:n}}Bf(),Cr(),Nh(),lr(),Wg(),gr(),fa(),Zr();function pT({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)(()=>zS().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Claude Code] ${kS(n)} (${c}) ⧉`,[n,c]),u=Xp(t.options.mcpClients)&&En().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=io(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Y(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await hT(n,r,t,l);if(a.current)return;Y(`tengu_ext_diff_accepted`,{});let c=mT(n,o,s,i);if(c.length===0){Y(`tengu_ext_diff_rejected`,{});let i=Il(t.options.mcpClients);i&&await gT(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Qr(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Il(t.options.mcpClients);return e?gT(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function mT(e,t,n,r){let i=r===`single`,a=ja({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Qr(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),sg(a))}async function hT(e,t,n,r){let i=!1,a=ii(e),o=``;try{o=Jn(a)}catch(e){if(!pr(e))throw e}async function s(){if(!i){i=!0;try{await gT(r,c)}catch(e){Qr(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Il(n.options.mcpClients);try{let{updatedFile:e}=km({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;$r()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Go(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await xh(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(yT(u))return s(),{oldContent:o,newContent:u[1].text};if(_T(u))return s(),{oldContent:o,newContent:e};if(vT(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Qr(e),s(),e}}async function gT(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await xh(`close_tab`,{tab_name:e},t)}catch(e){Qr(e)}}function _T(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 vT(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 yT(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}H(),wr(),fa(),wa();function bT({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)(xe,{color:`permission`,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(R,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(R,{color:`warning`,children:NS(Tr(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),rs()&&(0,$.jsx)(R,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),(0,$.jsx)(Sd,{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)(R,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}ot(),H(),ri();function xT(e){let t=ii(e),n=ii(`${ft()}/.claude`),r=bu(t),i=bu(n);return r.startsWith(i+PS.toLowerCase())||r.startsWith(i+`/`)}function ST(e){let t=ii(e),n=MS(ES(),`.claude`),r=bu(t),i=bu(n);return r.startsWith(i+PS.toLowerCase())||r.startsWith(i+`/`)}function CT({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=aa(`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=Ao(e,t),u=xT(e),d=ST(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)(R,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(R,{bold:!0,children:[`(`,c,`)`]})]});else{let r=kS(oi(e))||`this directory`;t=n===`read`?(0,$.jsxs)(R,{children:[`Yes, allow reading from `,(0,$.jsxs)(R,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(R,{children:[`Yes, allow all edits in `,(0,$.jsxs)(R,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(R,{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}Cr(),Ht(),zr(),Ho(),jw();function wT(e,t,n,r,i){Aw({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Vr.platform,hasFeedback:i??!1}})}function TT(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;wT(`accept`,a,o,n),Y(`tengu_accept_submitted`,{toolName:hn(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 ET(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(wT(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:q_,ruleContent:t.scope===`global-claude-folder`?z_:F_}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?dl(r,l,a):[];o(),i.onAllow(i.input,u)}function DT(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;wT(`reject`,o,s,n,t?.hasFeedback),Y(`tengu_reject_submitted`,{toolName:hn(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 OT={"accept-once":TT,"accept-session":ET,reject:DT};X(),ty(),Cr(),Ht();function kT({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)(()=>CT({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=OT[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 V({"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:hn(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(),Vc(),wr(),ri(),wa();function AT({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?Xu(l):`none`),[m,l]);Pw(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=ii(l),{resolvedPath:t,isSymlink:n}=xr(yr(),e);return n?t:null},[l,d]),_=kT({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}=pT(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)(bT,{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 M=g!=null&&NS(Tr(),g).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Hb,{title:i,subtitle:a,innerPaddingX:0,workerBadge:p,children:[g?(0,$.jsx)(U,{paddingX:1,marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,children:M?`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)(R,{children:o}):o,(0,$.jsx)(Sd,{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)(R,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!T)&&` · Tab to add feedback`]})})]})}wr(),gr(),Hn(),vr(),H(),i_();function jT({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(MT,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Zn(n);return{oldContent:(await yr().readFile(n,{encoding:e})).replaceAll(`\r
27
+ Explain this command in context.`,l=await g_({model:Ov()?qt():Pt(),system:Kw,messages:[{role:`user`,content:c}],tools:[qw],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;J(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){J(`Permission explainer: tool input: ${hr(d.input).slice(0,500)}`);let t=Jw().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:hn(e),risk_level:Hw[n.riskLevel],latency_ms:u}),J(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Y(`tengu_permission_explainer_error`,{tool_name:hn(e),error_type:Uw,latency_ms:u}),J(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(J(`Permission explainer: request aborted for ${e}`),null):(J(`Permission explainer error: ${Sr(t)}`),Qr(t),Y(`tengu_permission_explainer_error`,{tool_name:hn(e),error_type:t instanceof Error&&t.name===`AbortError`?Ww:Gw,latency_ms:n}),null)}}H(),ty(),Cr();var $w=`Loading explanation…`;function eT(){let[e,t]=Nf(`responding`,$w,!1);return(0,$.jsx)(U,{ref:e,children:(0,$.jsx)(R,{children:$w.split(``).map((e,n)=>(0,$.jsx)(o_,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function tT(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function nT(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function rT(e){return Qw({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function iT(e){let t=Zw(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return we(`confirm:toggleExplanation`,()=>{n||(Y(`tengu_permission_explainer_shortcut_used`,{}),i||a(rT(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function aT({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(R,{children:t.explanation}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:t.reasoning})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{color:tT(t.riskLevel),children:[nT(t.riskLevel),`:`]}),(0,$.jsxs)(R,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Explanation unavailable`})})}function oT({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(eT,{})}),children:(0,$.jsx)(aT,{promise:t})})}ny(),H(),Zr(),Ad(),bg();function sT(e){let[t]=(0,Q.useState)(()=>uT(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(lT,{placeholder:!0}),children:(0,$.jsx)(cT,{promise:t,file_path:e.file_path})})}function cT({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=k();return(0,$.jsx)(lT,{children:(0,$.jsx)(lm,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function lT({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)(R,{dimColor:!0,children:`…`}):e})})}async function uT(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 dT(e,[r]);try{let t=await Gm(e);if(t===null)return dT(e,n);try{if(!r||r.old_string===``){let r=await Zh(t);return r===null?dT(e,n):{patch:Sl({filePath:e,fileContents:r,edits:n.map(e=>fT(r,e))}),firstLine:Li(r),fileContent:r}}let i=await Zd(t,r.old_string,3);if(i.truncated||i.content===``)return dT(e,[r]);let a=fT(i.content,r);return{patch:n_(Sl({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Li(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Qr(t),dT(e,n)}}function dT(e,t){return{patch:t.flatMap(t=>Sl({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function fT(e,t){let n=Df(e,t.old_string)||t.old_string;return{...t,old_string:n}}Bf(),Cr(),Ih(),lr(),Gg(),gr(),ma(),Zr();function pT({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)(()=>zS().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Claude Code] ${kS(n)} (${c}) ⧉`,[n,c]),u=em(t.options.mcpClients)&&En().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=ao(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Y(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await hT(n,r,t,l);if(a.current)return;Y(`tengu_ext_diff_accepted`,{});let c=mT(n,o,s,i);if(c.length===0){Y(`tengu_ext_diff_rejected`,{});let i=Il(t.options.mcpClients);i&&await gT(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Qr(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Il(t.options.mcpClients);return e?gT(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function mT(e,t,n,r){let i=r===`single`,a=ja({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Qr(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),ug(a))}async function hT(e,t,n,r){let i=!1,a=ii(e),o=``;try{o=Jn(a)}catch(e){if(!pr(e))throw e}async function s(){if(!i){i=!0;try{await gT(r,c)}catch(e){Qr(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Il(n.options.mcpClients);try{let{updatedFile:e}=Mm({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;$r()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new qo(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await Ch(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(yT(u))return s(),{oldContent:o,newContent:u[1].text};if(_T(u))return s(),{oldContent:o,newContent:e};if(vT(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Qr(e),s(),e}}async function gT(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await Ch(`close_tab`,{tab_name:e},t)}catch(e){Qr(e)}}function _T(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 vT(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 yT(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}H(),wr(),ma(),ul();function bT({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)(xe,{color:`permission`,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(R,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(R,{color:`warning`,children:NS(Tr(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),ns()&&(0,$.jsx)(R,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),(0,$.jsx)(wd,{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)(R,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}ot(),H(),ri();function xT(e){let t=ii(e),n=ii(`${ft()}/.claude`),r=Su(t),i=Su(n);return r.startsWith(i+PS.toLowerCase())||r.startsWith(i+`/`)}function ST(e){let t=ii(e),n=MS(ES(),`.claude`),r=Su(t),i=Su(n);return r.startsWith(i+PS.toLowerCase())||r.startsWith(i+`/`)}function CT({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=oa(`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=Mo(e,t),u=xT(e),d=ST(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)(R,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(R,{bold:!0,children:[`(`,c,`)`]})]});else{let r=kS(oi(e))||`this directory`;t=n===`read`?(0,$.jsxs)(R,{children:[`Yes, allow reading from `,(0,$.jsxs)(R,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(R,{children:[`Yes, allow all edits in `,(0,$.jsxs)(R,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(R,{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}Cr(),Ht(),zr(),Wo(),jw();function wT(e,t,n,r,i){Aw({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Vr.platform,hasFeedback:i??!1}})}function TT(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;wT(`accept`,a,o,n),Y(`tengu_accept_submitted`,{toolName:hn(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 ET(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(wT(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:q_,ruleContent:t.scope===`global-claude-folder`?z_:F_}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?cl(r,l,a):[];o(),i.onAllow(i.input,u)}function DT(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;wT(`reject`,o,s,n,t?.hasFeedback),Y(`tengu_reject_submitted`,{toolName:hn(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 OT={"accept-once":TT,"accept-session":ET,reject:DT};X(),ty(),Cr(),Ht();function kT({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)(()=>CT({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=OT[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 V({"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:hn(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(),Fc(),wr(),ri(),ul();function AT({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?$u(l):`none`),[m,l]);Pw(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=ii(l),{resolvedPath:t,isSymlink:n}=xr(yr(),e);return n?t:null},[l,d]),_=kT({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}=pT(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)(bT,{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 M=g!=null&&NS(Tr(),g).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Hb,{title:i,subtitle:a,innerPaddingX:0,workerBadge:p,children:[g?(0,$.jsx)(U,{paddingX:1,marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,children:M?`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)(R,{children:o}):o,(0,$.jsx)(wd,{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)(R,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!T)&&` · Tab to add feedback`]})})]})}wr(),gr(),Hn(),vr(),H(),f_();function jT({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(MT,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Zn(n);return{oldContent:(await yr().readFile(n,{encoding:e})).replaceAll(`\r
28
28
  `,`
29
- `),fileExists:!0}})().catch(e=>{if(!pr(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function MT({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Gh(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)(AT,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:NS(Tr(),r),question:(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),content:s.length>0?(0,$.jsx)(sT,{file_path:r,edits:s}):(0,$.jsx)(R,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...zd.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}}),workerBadge:n.workerBadge})}zr(),jw();function NT(e,{assistantMessage:{message:{id:t}}},n,r){Aw({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Br(),hasFeedback:r??!1}})}Cr(),Ht(),X();function PT({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=kf(),[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:hn(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}}))),NT(`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}}ot(),H();function FT(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(R,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(R,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(R,{bold:!0,children:e.slice(-1)[0]})]})}}function IT(e){return e.join(`, `).length>50?`similar`:FT(e)}function LT(e){if(e.length===0)return``;let t=e.map(e=>kS(e)||e);return t.length===1?(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS]}):t.length===2?(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS,` and `,(0,$.jsx)(R,{bold:!0,children:t[1]}),PS]}):(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS,`, `,(0,$.jsx)(R,{bold:!0,children:t[1]}),PS,` and `,e.length-2,` more`]})}function RT(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=ra(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)(R,{children:[`Yes, allow reading from `,(0,$.jsx)(R,{bold:!0,children:kS(e)||e}),PS,` from this project`]})}return(0,$.jsxs)(R,{children:[`Yes, allow reading from `,LT(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,(0,$.jsx)(R,{bold:!0,children:kS(e)||e}),PS,` from this project`]})}return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,LT(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,IT(c),` commands in `,(0,$.jsx)(R,{bold:!0,children:ft()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,LT(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(R,{children:[`Yes, and allow access to `,LT(e),` and `,IT(c),` commands`]}):(0,$.jsxs)(R,{children:[`Yes, and allow `,LT(e),` access and `,IT(c),` commands`]})}return null}Bc();function zT(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function BT(e){let{commandWithoutRedirections:t,redirections:n}=Yu(e);return n.length>0?t:e}function VT({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`}),Zl()){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=RT(e,A_,BT);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&&uh()&&i&&!o&&!zT(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(),ty(),an(),Cr(),Ht(),X(),i_(),qd(),xs(),co(),oo(),Nd(),Qm(),Bb(),YC();function HT(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o}=e,{command:s,description:c}=zd.inputSchema.parse(t.input),l=am(s);return l?(0,$.jsx)(jT,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,sedInfo:l}):(0,$.jsx)(UT,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,command:s,description:c})}function UT({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,command:o,description:s}){let[c]=ae(),l=Z(e=>e.toolPermissionContext),u=iT({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}=PT({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(!uh())return;let e=new AbortController;return uu(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=oc(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===zd.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=jg(o);if(t)return`${t}:*`;let n=vd(o);return n?`${n}:*`:o}),M=(0,Q.useRef)(!1),N=(0,Q.useCallback)(e=>{M.current=!0,j(e)},[]);(0,Q.useEffect)(()=>{if(k)return;let e=!1;return Ow(o,e=>zd.isReadOnly({command:e})).then(t=>{e||M.current||t.length>0&&j(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[o,k]);let[P]=(0,Q.useState)(!1),{destructiveWarning:ee,sandboxingEnabled:F,isSandboxed:te}=(0,Q.useMemo)(()=>{let t=gn(`tengu_destructive_command_warning`,!1)?cw(o):null,n=Gs.isSandboxingEnabled();return{destructiveWarning:t,sandboxingEnabled:n,isSandboxed:n&&Fu(e.input)}},[o,e.input]);Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ne=(0,Q.useMemo)(()=>bo(l),[l]),I=(0,Q.useMemo)(()=>VT({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,onClassifierDescriptionChange:E,classifierDescription:T,initialClassifierDescriptionEmpty:D,existingAllowDescriptions:ne,yesInputMode:d,noInputMode:f,editablePrefix:A,onEditablePrefixChange:N}),[e,T,D,ne,d,f,A,N]);we(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`}),we(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function re(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=hn(e.tool.name);if(t===`yes-prefix-edited`){let t=(A??``).trim();if(NT(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:zd.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=h.trim();NT(`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`:{NT(`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)(Hb,{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)(R,{dimColor:u.visible,children:zd.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!u.visible&&(0,$.jsx)(R,{dimColor:!0,children:e.description}),(0,$.jsx)(oT,{visible:u.visible,promise:u.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vw,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),ee&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,dimColor:!1,children:ee})}),(0,$.jsx)(R,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(Sd,{options:I,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>x(),onFocus:S,onInputModeToggle:b})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(R,{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)(R,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}ot(),H(),Cr(),X(),Os(),wa(),Bb();function WT({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let i=Z(e=>e.toolPermissionContext.mode);function a(r){r===`yes`?(Y(`tengu_plan_enter`,{interviewPhaseEnabled:_h(),entryMethod:`tool`}),mt(i,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Hb,{color:`planMode`,title:`Enter plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(R,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(R,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(R,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(R,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(R,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(R,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(Sd,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:a,onCancel:()=>a(`no`)})})]})})}f(),Fm(),Cr(),X(),ot(),Qx(),em(),H(),Yn(),jb(),fa(),Zr(),Cs(),ql(),$t(),xs(),sn(),Ng(),Os(),Bd(),Fb(),ho(),wa(),Bb(),YC(),of(),Dp();var GT=(Xi(),e(qc));function KT(e,t){let n=[{type:`setMode`,mode:Et(e),destination:`session`}];return uh()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:zl(e.prompt)})),behavior:`allow`,destination:`session`}),n}function qT(e,t,n){ut()||Un()?.cleanupPeriodDays===0||!n&&Rd(Fe())||$x([ro({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Rd(Fe()))return;let n=Fe(),r=da();await Sl(n,e,r,`auto`),await p_(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Qr)}function JT({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r,setStickyFooter:i}){let a=Z(e=>e.toolPermissionContext),o=kf(),s=Zd(),{addNotification:c}=Lh(),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)({}),m=(0,Q.useRef)(0),h=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)(()=>YT({showClearContext:h,showUltraplan:v,usedPercent:h?XT(y,b):null,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S,onFeedbackChange:u}),[h,v,y,b,x,S]);function w(e,t,n,r,i){let a=m.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};vc(o),Ks(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===H_,k=O?void 0:e.input.plan,A=O?yd():void 0,j=e.input.allowedPrompts,M=k??ip(),N=!M||M.trim()===``,[P]=(0,Q.useState)(()=>Do()??void 0),[ee,F]=(0,Q.useState)(()=>k||(ip()??`No plan found. Please write your plan to the plan file first.`)),[te,ne]=(0,Q.useState)(!1),[I,re]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(te){let e=setTimeout(ne,5e3,!1);return()=>clearTimeout(e)}},[te]);let L=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Y(`tengu_plan_external_editor_used`,{}),(async()=>{if(O&&A){let e=await Ib(A);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==ee&&re(!0),F(e.content),ne(!0))}else{let e=await Nb(ee);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==ee&&(F(e.content),ne(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),ie(h?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function ie(r){let i=l.trim(),c=i||void 0;if(r===`ultraplan`){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`ultraplan`,interviewPhaseEnabled:_h(),planStructureVariant:P}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),pg({blurb:``,seedPlan:ee,getAppState:s.getState,setAppState:s.setState,signal:new AbortController().signal}).then(e=>ha({value:e,mode:`task-notification`})).catch(Qr);return}let u=O&&!I?{}:{plan:ee};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Pa(),t=GT?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(GT?.setAutoModeActive(!1),dt(!0),o(e=>({...e,toolPermissionContext:{...ac(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`&&qT(ee,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`&&Pa()&&(i=`auto`,GT?.setAutoModeActive(!0)),Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!0,interviewPhaseEnabled:_h(),planStructureVariant:P,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: ${da()}`,s=Nn()?`\n\nIf this plan can be broken down into multiple independent tasks, consider using the ${Ql} tool to create a team and parallelize the work.`:``,l=c?`\n\nUser feedback on this plan: ${c}`:``;o(e=>({...e,initialMessage:{message:{...ro({content:`Implement the following plan:\n\n${ee}${a}${s}${l}`}),planContent:ee},clearContext:!0,mode:i,allowedPrompts:j}})),Ct(!0),ht(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Pa()){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!1,interviewPhaseEnabled:_h(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),GT?.setAutoModeActive(!0),o(e=>({...e,toolPermissionContext:kc({...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){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!1,interviewPhaseEnabled:_h(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),t(),e.onAllow(u,KT(f,j),c);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,interviewPhaseEnabled:_h(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),t(),e.onAllow(u,KT(p,j),c);return}if(r===`no`){if(!i&&!D)return;Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`no`,interviewPhaseEnabled:_h(),planStructureVariant:P});let r;D&&(r=await Promise.all(E.map(async e=>(await Rf({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=Mb(),oe=ae?T_(ae):null,se=(0,Q.useRef)(ie);se.current=ie;let ce=(0,Q.useRef)(void 0);ce.current=()=>{Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`no`,interviewPhaseEnabled:_h(),planStructureVariant:P}),t(),n(),e.onReject()};let le=!N&&!!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)(R,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(Sd,{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)(R,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(R,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,Dt(A)]}),te&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsxs)(R,{color:`success`,children:[p.tick,`Plan saved!`]})]})]})]})),()=>i(null)},[le,i,C,d,oe,O,A,te]),N){function i(r){r===`yes`?(Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:_h(),planStructureVariant:P}),(GT?.isAutoModeActive()??!1)&&(GT?.setAutoModeActive(!1),dt(!0),o(e=>({...e,toolPermissionContext:{...ac(e.toolPermissionContext),prePlanMode:void 0}}))),Ct(!0),ht(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:_h(),planStructureVariant:P}),t(),n(),e.onReject())}return(0,$.jsx)(Hb,{color:`planMode`,title:`Exit plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(R,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(Sd,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:i,onCancel:()=>{Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:_h(),planStructureVariant:P}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(U,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:L,children:[(0,$.jsx)(Hb,{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)(R,{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)($d,{children:ee})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),uh()&&j&&j.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(R,{bold:!0,children:`Requested permissions:`}),j.map((e,t)=>(0,$.jsxs)(R,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!le&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{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)(Sd,{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)(R,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(R,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,Dt(A)]})]}),te&&(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsxs)(R,{color:`success`,children:[p.tick,`Plan saved!`]})]})]})]})}function YT({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 XT(e,t){if(!e)return null;let n=Kn(Pn({permissionMode:t,mainLoopModel:Pt(),exceeds200kTokens:!1}),yt()),{used:r}=yn({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 ZT({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=kf(),[o,s]=(0,QT.useState)(``),[c,l]=(0,QT.useState)(``),[u,d]=(0,QT.useState)(!1),[f,p]=(0,QT.useState)(!1),[m,h]=(0,QT.useState)(null),[g,_]=(0,QT.useState)(!1),[v,y]=(0,QT.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,QT.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=eE[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,QT.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,QT.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]);V((0,QT.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,QT.useCallback)(()=>{Y(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$T.jsxs)(U,{flexDirection:`column`,children:[typeof r==`string`?(0,$T.jsx)(R,{children:r}):r,(0,$T.jsx)(Sd,{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,$T.jsx)(U,{marginTop:1,children:(0,$T.jsxs)(R,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var QT,$T,eE,tE=t((()=>{QT=n(L(),1),H(),ty(),Cr(),X(),Im(),$T=je(),eE={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Qv(),Ws(),Mu(),_o(),Ka(),dm(),Ny(),ot(),H(),Ht(),zr(),ma(),Vi(),jw(),Bb(),tE(),YC();function nE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ae(),o=e.tool.userFacingName(e.input),s=o.endsWith(` (MCP)`)?o.slice(0,-6):o;Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]),u=ft(),d=Zl(),f=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return d&&e.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:s}),` commands in`,` `,(0,$.jsx)(R,{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:hn(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Hb,{title:`Tool use`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(R,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:!0}),`)`,o.endsWith(` (MCP)`)?(0,$.jsx)(R,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(R,{dimColor:!0,children:zi(e.description,3)})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(ZT,{options:f,onSelect:c,onCancel:l,toolAnalyticsContext:p})]})]})}function rE(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}wr(),H();var iE={getConfig:e=>rE(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 aE(e){let t=e=>Zc.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit file`,subtitle:NS(Tr(),n),question:(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(n)}),`?`]}),content:(0,$.jsx)(sT,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:iE})}H();function oE(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 sE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i,workerBadge:a}){let[o]=ae(),s=oE(e),c=e.tool.userFacingName(e.input),l=e.tool.isReadOnly(e.input),u=`${l?`Read`:`Edit`} file`;return s?(0,$.jsx)(AT,{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)(R,{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)(nE,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r,workerBadge:a})}ny(),H(),Wg(),gm();function cE({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=k(),a=(0,Q.useMemo)(()=>n?wl({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
30
- `)[0]??null;return(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(U,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?di(a.map(t=>(0,$.jsx)(sf,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(N,{fromLeftEdge:!0,children:(0,$.jsx)(R,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ah,{code:t||`(No content)`,filePath:e})})})}H(),wr(),gr(),Hn();var lE={getConfig:e=>{let t;try{t=Jn(e.file_path)}catch(e){if(!pr(e))throw e;t=``}return rE(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function uE(e){let t=e=>ju.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:Jn(n)}}catch(e){if(!pr(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:i?`Overwrite file`:`Create file`,subtitle:NS(Tr(),n),question:(0,$.jsxs)(R,{children:[`Do you want to `,o,` `,(0,$.jsx)(R,{bold:!0,children:kS(n)}),`?`]}),content:(0,$.jsx)(cE,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:lE})}H(),Ci(),wr(),Wg(),vr(),gm(),Bf();function dE(e){let t=(0,Q.useMemo)(()=>yr().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>ui(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(fE,{...e,promise:t})})}function fE({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=Uo(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:wl({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)(R,{bold:!0,children:a?e:NS(Tr(),e)}),(0,$.jsxs)(R,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ah,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ah,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?di(u.map(t=>(0,$.jsx)(sf,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
31
- `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(N,{fromLeftEdge:!0,children:(0,$.jsx)(R,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ah,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}H(),Zr();function pE(e){let t=e=>{let t=w_.inputSchema.safeParse(e);return t.success?t.data:(Qr(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)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit notebook`,question:(0,$.jsxs)(R,{children:[`Do you want to `,s,` `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),content:(0,$.jsx)(dE,{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 mE=[{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 hE(e){for(let{pattern:t,warning:n}of mE)if(t.test(e))return n;return null}Vi(),ag();async function gE(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||Sf.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 bw(n),i=await hw(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||uw[n])?null:i}async function _E(e,t){let n=await Hm(e);if(!n.valid)return[];let r=Sp(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await gE(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await gE(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=vE(t);(n===``?0:Hi(n,` `)+1)<=1&&((await bw(e))?.subcommands?.length||uw[e])||o.push(n)}return o}function vE(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(` `)}ma();function yE({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`}),Zl()&&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=RT(e,K_);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(),ty(),an(),Cr(),Ht(),Im(),Bb(),YC();function bE(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,workerBadge:a}=e,{command:o,description:s}=rd.inputSchema.parse(t.input),[c]=ae(),l=iT({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}=PT({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:l.visible}),S=gn(`tengu_destructive_command_warning`,!1)?hE(o):null,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(o.includes(`
32
- `)?void 0:o),D=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return _E(o,e=>jh(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)},[]);Pw(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let k=(0,Q.useMemo)(()=>yE({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]);we(`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=hn(t.tool.name);if(e===`yes-prefix-edited`){let e=(T??``).trim();if(NT(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:rd.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=m.trim();NT(`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`:{NT(`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)(Hb,{workerBadge:a,title:`PowerShell command`,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(R,{dimColor:l.visible,children:rd.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!l.visible&&(0,$.jsx)(R,{dimColor:!0,children:t.description}),(0,$.jsx)(oT,{visible:l.visible,promise:l.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vw,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:t.permissionResult,toolType:`command`}),S&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,children:S})}),(0,$.jsx)(R,{children:`Do you want to proceed?`}),(0,$.jsx)(Sd,{options:k,inlineDescriptions:!0,onChange:A,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(R,{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)(R,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Zr(),ot(),H(),Ht(),zr(),ma(),jw(),Bb(),tE(),YC();function xE(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i,workerBadge:a}=e,o=(e=>{let t=ms.inputSchema.safeParse(e);return t.success?t.data.skill:(Qr(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;Pw(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=ft(),l=Zl(),u=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(l){t.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:o}),` in `,(0,$.jsx)(R,{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)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(R,{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:hn(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),f=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:D_,ruleContent:o}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}});let e=o.indexOf(` `),r=e>0?o.substring(0,e):o;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:D_,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onReject(i),r(),n();break}},[t,n,r,o]),p=(0,Q.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Hb,{title:`Use skill "${o}"?`,workerBadge:a,children:[(0,$.jsx)(R,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(R,{dimColor:!0,children:s?.description})}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(ZT,{options:u,onSelect:f,onCancel:p,toolAnalyticsContext:d})]})]})}H(),ma(),Im(),Bb(),YC();function SE(e){try{let t=Wa.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 CE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ae(),{url:o}=e.input,s=new URL(o).hostname;Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=Zl(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`}];return c&&e.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:s})]}),value:`yes-dont-ask-again-domain`}),e.push({label:(0,$.jsxs)(R,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(R,{bold:!0,children:`(esc)`})]}),value:`no`}),e},[s,c]);function u(r){switch(r){case`yes`:NT(`tool_use_single`,e,`accept`),e.onAllow(e.input,[]),t();break;case`yes-dont-ask-again-domain`:{NT(`tool_use_single`,e,`accept`);let n=SE(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`:NT(`tool_use_single`,e,`reject`),e.onReject(),n(),t();break}}return(0,$.jsxs)(Hb,{title:`Fetch`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(R,{children:Wa.renderToolUseMessage(e.input,{theme:a,verbose:r})}),(0,$.jsx)(R,{dimColor:!0,children:e.description})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(R,{children:`Do you want to allow Claude to fetch this content?`}),(0,$.jsx)(Sd,{options:l,onChange:u,onCancel:()=>u(`no`)})]})]})}var wE=r({WorkflowPermissionRequest:()=>TE});function TE({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ae(),a=fd(i),o=e.input,s=(0,EE.useMemo)(()=>Zl(),[]),c=(0,EE.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,DE.jsxs)(R,{children:[`Yes, and don`,`’`,`t ask again for `,(0,DE.jsx)(R,{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,EE.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,EE.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,DE.jsx)(Hb,{title:`Workflow`,workerBadge:r,children:(0,DE.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,DE.jsxs)(U,{flexDirection:`column`,children:[(0,DE.jsxs)(R,{bold:!0,color:a.permission,children:[`Execute workflow: `,o.workflow]}),o.args&&(0,DE.jsxs)(R,{dimColor:!0,children:[`Arguments: `,o.args]})]}),(0,DE.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),(0,DE.jsx)(ZT,{options:c,onSelect:l,onCancel:u})]})})}var EE,DE,OE=t((()=>{EE=n(L(),1),H(),zr(),ma(),jw(),Bb(),tE(),YC(),DE=je()})),kE=r({MonitorPermissionRequest:()=>AE});function AE({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ae(),a=fd(i),o=e.input,s=(0,jE.useMemo)(()=>Zl(),[]),c=(0,jE.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,ME.jsxs)(R,{children:[`Yes, and don`,`’`,`t ask again for `,(0,ME.jsx)(R,{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,jE.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,jE.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,ME.jsx)(Hb,{title:`Monitor`,workerBadge:r,children:(0,ME.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,ME.jsxs)(U,{flexDirection:`column`,children:[(0,ME.jsx)(R,{bold:!0,color:a.permission,children:o.description}),(0,ME.jsx)(R,{dimColor:!0,children:zi(o.command,5)})]}),(0,ME.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),(0,ME.jsx)(ZT,{options:c,onSelect:l,onCancel:u})]})})}var jE,ME,NE=t((()=>{jE=n(L(),1),H(),Tg(),zr(),ma(),Vi(),jw(),Bb(),tE(),YC(),ME=je()}));ty(),Vu(),i_(),$i(),ad(),xa(),Zi(),Uu(),Ec();var PE=null,FE=null,IE=(yf(),e(ng)).createWorkflowToolCore(),LE=(OE(),e(wE)).WorkflowPermissionRequest,RE=(pd(),e(Zf)).MonitorTool,zE=(NE(),e(kE)).MonitorPermissionRequest;function BE(e){switch(e){case Zc:return aE;case ju:return uE;case zd:return HT;case rd:return bE;case PE:return FE??nE;case Wa:return CE;case w_:return pE;case Ou:return JT;case Ul:return WT;case ms:return xE;case fs:return rw;case IE:return LE??nE;case RE:return zE??nE;case Jl:case jo:case Es:return sE;default:return nE}}function VE(e){let t=e.tool.userFacingName(e.input);return e.tool===Ou?`Claude Code needs your approval for the plan`:e.tool===Ul?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function HE({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o}){return we(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),RC(VE(e),`permission_prompt`),(0,$.jsx)(BE(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o})}Zr(),ql();async function UE(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=dv([`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:
29
+ `),fileExists:!0}})().catch(e=>{if(!pr(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function MT({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Yh(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)(AT,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:NS(Tr(),r),question:(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),content:s.length>0?(0,$.jsx)(sT,{file_path:r,edits:s}):(0,$.jsx)(R,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Mg.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}}),workerBadge:n.workerBadge})}zr(),jw();function NT(e,{assistantMessage:{message:{id:t}}},n,r){Aw({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Br(),hasFeedback:r??!1}})}Cr(),Ht(),X();function PT({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Af(),[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:hn(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}}))),NT(`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}}ot(),H();function FT(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(R,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(R,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(R,{bold:!0,children:e.slice(-1)[0]})]})}}function IT(e){return e.join(`, `).length>50?`similar`:FT(e)}function LT(e){if(e.length===0)return``;let t=e.map(e=>kS(e)||e);return t.length===1?(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS]}):t.length===2?(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS,` and `,(0,$.jsx)(R,{bold:!0,children:t[1]}),PS]}):(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{bold:!0,children:t[0]}),PS,`, `,(0,$.jsx)(R,{bold:!0,children:t[1]}),PS,` and `,e.length-2,` more`]})}function RT(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=ia(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)(R,{children:[`Yes, allow reading from `,(0,$.jsx)(R,{bold:!0,children:kS(e)||e}),PS,` from this project`]})}return(0,$.jsxs)(R,{children:[`Yes, allow reading from `,LT(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,(0,$.jsx)(R,{bold:!0,children:kS(e)||e}),PS,` from this project`]})}return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,LT(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,IT(c),` commands in `,(0,$.jsx)(R,{bold:!0,children:ft()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(R,{children:[`Yes, and always allow access to `,LT(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(R,{children:[`Yes, and allow access to `,LT(e),` and `,IT(c),` commands`]}):(0,$.jsxs)(R,{children:[`Yes, and allow `,LT(e),` access and `,IT(c),` commands`]})}return null}Pc();function zT(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function BT(e){let{commandWithoutRedirections:t,redirections:n}=Qu(e);return n.length>0?t:e}function VT({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`}),$l()){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=RT(e,A_,BT);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&&dh()&&i&&!o&&!zT(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(),ty(),an(),Cr(),Ht(),X(),f_(),Yd(),bs(),lo(),so(),Pd(),rf(),Bb(),YC();function HT(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o}=e,{command:s,description:c}=Mg.inputSchema.parse(t.input),l=cm(s);return l?(0,$.jsx)(jT,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,sedInfo:l}):(0,$.jsx)(UT,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,workerBadge:o,command:s,description:c})}function UT({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,command:o,description:s}){let[c]=ae(),l=Z(e=>e.toolPermissionContext),u=iT({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}=PT({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(!dh())return;let e=new AbortController;return du(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=$s(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Mg.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=ip(o);if(t)return`${t}:*`;let n=hp(o);return n?`${n}:*`:o}),M=(0,Q.useRef)(!1),N=(0,Q.useCallback)(e=>{M.current=!0,j(e)},[]);(0,Q.useEffect)(()=>{if(k)return;let e=!1;return Ow(o,e=>Mg.isReadOnly({command:e})).then(t=>{e||M.current||t.length>0&&j(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[o,k]);let[P]=(0,Q.useState)(!1),{destructiveWarning:ee,sandboxingEnabled:F,isSandboxed:te}=(0,Q.useMemo)(()=>{let t=gn(`tengu_destructive_command_warning`,!1)?cw(o):null,n=Bs.isSandboxingEnabled();return{destructiveWarning:t,sandboxingEnabled:n,isSandboxed:n&&zu(e.input)}},[o,e.input]);Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ne=(0,Q.useMemo)(()=>xo(l),[l]),I=(0,Q.useMemo)(()=>VT({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,onClassifierDescriptionChange:E,classifierDescription:T,initialClassifierDescriptionEmpty:D,existingAllowDescriptions:ne,yesInputMode:d,noInputMode:f,editablePrefix:A,onEditablePrefixChange:N}),[e,T,D,ne,d,f,A,N]);we(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`}),we(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function re(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=hn(e.tool.name);if(t===`yes-prefix-edited`){let t=(A??``).trim();if(NT(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Mg.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=h.trim();NT(`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`:{NT(`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)(Hb,{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)(R,{dimColor:u.visible,children:Mg.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!u.visible&&(0,$.jsx)(R,{dimColor:!0,children:e.description}),(0,$.jsx)(oT,{visible:u.visible,promise:u.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vw,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),ee&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,dimColor:!1,children:ee})}),(0,$.jsx)(R,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(wd,{options:I,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>x(),onFocus:S,onInputModeToggle:b})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(R,{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)(R,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}ot(),H(),Cr(),X(),vu(),ul(),Bb();function WT({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let i=Z(e=>e.toolPermissionContext.mode);function a(r){r===`yes`?(Y(`tengu_plan_enter`,{interviewPhaseEnabled:ko(),entryMethod:`tool`}),mt(i,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Hb,{color:`planMode`,title:`Enter plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(R,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(U,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(R,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(R,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(R,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(R,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(R,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(wd,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:a,onCancel:()=>a(`no`)})})]})})}f(),Rm(),Cr(),X(),ot(),Qx(),im(),H(),Yn(),jb(),ma(),Zr(),Ss(),ql(),$t(),bs(),sn(),Pg(),vu(),Ng(),Fb(),go(),ul(),Bb(),YC(),uf(),Ap();var GT=(Xi(),e(Hc));function KT(e,t){let n=[{type:`setMode`,mode:Et(e),destination:`session`}];return dh()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:zl(e.prompt)})),behavior:`allow`,destination:`session`}),n}function qT(e,t,n){ut()||Un()?.cleanupPeriodDays===0||!n&&Bd(Fe())||$x([ro({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Bd(Fe()))return;let n=Fe(),r=da();await bl(n,e,r,`auto`),await d_(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Qr)}function JT({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r,setStickyFooter:i}){let a=Z(e=>e.toolPermissionContext),o=Af(),s=ef(),{addNotification:c}=Bh(),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)({}),m=(0,Q.useRef)(0),h=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)(()=>YT({showClearContext:h,showUltraplan:v,usedPercent:h?XT(y,b):null,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S,onFeedbackChange:u}),[h,v,y,b,x,S]);function w(e,t,n,r,i){let a=m.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};uc(o),Vs(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===H_,k=O?void 0:e.input.plan,A=O?gp():void 0,j=e.input.allowedPrompts,M=k??Cm(),N=!M||M.trim()===``,[P]=(0,Q.useState)(()=>Ul()??void 0),[ee,F]=(0,Q.useState)(()=>k||(Cm()??`No plan found. Please write your plan to the plan file first.`)),[te,ne]=(0,Q.useState)(!1),[I,re]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(te){let e=setTimeout(ne,5e3,!1);return()=>clearTimeout(e)}},[te]);let L=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Y(`tengu_plan_external_editor_used`,{}),(async()=>{if(O&&A){let e=await Ib(A);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==ee&&re(!0),F(e.content),ne(!0))}else{let e=await Nb(ee);e.error&&c({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==ee&&(F(e.content),ne(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),ie(h?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function ie(r){let i=l.trim(),c=i||void 0;if(r===`ultraplan`){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`ultraplan`,interviewPhaseEnabled:ko(),planStructureVariant:P}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),hg({blurb:``,seedPlan:ee,getAppState:s.getState,setAppState:s.setState,signal:new AbortController().signal}).then(e=>_a({value:e,mode:`task-notification`})).catch(Qr);return}let u=O&&!I?{}:{plan:ee};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Fa(),t=GT?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(GT?.setAutoModeActive(!1),dt(!0),o(e=>({...e,toolPermissionContext:{...Qs(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`&&qT(ee,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`&&Fa()&&(i=`auto`,GT?.setAutoModeActive(!0)),Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!0,interviewPhaseEnabled:ko(),planStructureVariant:P,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: ${da()}`,s=Nn()?`\n\nIf this plan can be broken down into multiple independent tasks, consider using the ${eu} tool to create a team and parallelize the work.`:``,l=c?`\n\nUser feedback on this plan: ${c}`:``;o(e=>({...e,initialMessage:{message:{...ro({content:`Implement the following plan:\n\n${ee}${a}${s}${l}`}),planContent:ee},clearContext:!0,mode:i,allowedPrompts:j}})),Ct(!0),ht(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Fa()){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ko(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),GT?.setAutoModeActive(!0),o(e=>({...e,toolPermissionContext:xc({...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){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ko(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),t(),e.onAllow(u,KT(f,j),c);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:r,interviewPhaseEnabled:ko(),planStructureVariant:P,hasFeedback:!!c}),Ct(!0),ht(!0),t(),e.onAllow(u,KT(p,j),c);return}if(r===`no`){if(!i&&!D)return;Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`no`,interviewPhaseEnabled:ko(),planStructureVariant:P});let r;D&&(r=await Promise.all(E.map(async e=>(await Rf({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=Mb(),oe=ae?w_(ae):null,se=(0,Q.useRef)(ie);se.current=ie;let ce=(0,Q.useRef)(void 0);ce.current=()=>{Y(`tengu_plan_exit`,{planLengthChars:ee.length,outcome:`no`,interviewPhaseEnabled:ko(),planStructureVariant:P}),t(),n(),e.onReject()};let le=!N&&!!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)(R,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(wd,{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)(R,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(R,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,Dt(A)]}),te&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsxs)(R,{color:`success`,children:[p.tick,`Plan saved!`]})]})]})]})),()=>i(null)},[le,i,C,d,oe,O,A,te]),N){function i(r){r===`yes`?(Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:ko(),planStructureVariant:P}),(GT?.isAutoModeActive()??!1)&&(GT?.setAutoModeActive(!1),dt(!0),o(e=>({...e,toolPermissionContext:{...Qs(e.toolPermissionContext),prePlanMode:void 0}}))),Ct(!0),ht(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ko(),planStructureVariant:P}),t(),n(),e.onReject())}return(0,$.jsx)(Hb,{color:`planMode`,title:`Exit plan mode?`,workerBadge:r,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(R,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(wd,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:i,onCancel:()=>{Y(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ko(),planStructureVariant:P}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(U,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:L,children:[(0,$.jsx)(Hb,{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)(R,{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)(nf,{children:ee})}),(0,$.jsxs)(U,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),dh()&&j&&j.length>0&&(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(R,{bold:!0,children:`Requested permissions:`}),j.map((e,t)=>(0,$.jsxs)(R,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!le&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{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)(wd,{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)(R,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(R,{bold:!0,dimColor:!0,children:oe}),O&&A&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,Dt(A)]})]}),te&&(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsxs)(R,{color:`success`,children:[p.tick,`Plan saved!`]})]})]})]})}function YT({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 XT(e,t){if(!e)return null;let n=Kn(Pn({permissionMode:t,mainLoopModel:Pt(),exceeds200kTokens:!1}),yt()),{used:r}=yn({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 ZT({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Af(),[o,s]=(0,QT.useState)(``),[c,l]=(0,QT.useState)(``),[u,d]=(0,QT.useState)(!1),[f,p]=(0,QT.useState)(!1),[m,h]=(0,QT.useState)(null),[g,_]=(0,QT.useState)(!1),[v,y]=(0,QT.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,QT.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=eE[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,QT.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,QT.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]);V((0,QT.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,QT.useCallback)(()=>{Y(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$T.jsxs)(U,{flexDirection:`column`,children:[typeof r==`string`?(0,$T.jsx)(R,{children:r}):r,(0,$T.jsx)(wd,{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,$T.jsx)(U,{marginTop:1,children:(0,$T.jsxs)(R,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var QT,$T,eE,tE=t((()=>{QT=n(L(),1),H(),ty(),Cr(),X(),zm(),$T=je(),eE={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Qv(),yo(),gs(),sc(),Fl(),mm(),Ny(),ot(),H(),Ht(),zr(),ga(),Vi(),jw(),Bb(),tE(),YC();function nE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ae(),o=e.tool.userFacingName(e.input),s=o.endsWith(` (MCP)`)?o.slice(0,-6):o;Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]),u=ft(),d=$l(),f=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return d&&e.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:s}),` commands in`,` `,(0,$.jsx)(R,{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:hn(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Hb,{title:`Tool use`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(R,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:!0}),`)`,o.endsWith(` (MCP)`)?(0,$.jsx)(R,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(R,{dimColor:!0,children:zi(e.description,3)})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(ZT,{options:f,onSelect:c,onCancel:l,toolAnalyticsContext:p})]})]})}function rE(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}wr(),H();var iE={getConfig:e=>rE(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 aE(e){let t=e=>Kc.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit file`,subtitle:NS(Tr(),n),question:(0,$.jsxs)(R,{children:[`Do you want to make this edit to `,(0,$.jsx)(R,{bold:!0,children:kS(n)}),`?`]}),content:(0,$.jsx)(sT,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:iE})}H();function oE(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 sE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i,workerBadge:a}){let[o]=ae(),s=oE(e),c=e.tool.userFacingName(e.input),l=e.tool.isReadOnly(e.input),u=`${l?`Read`:`Edit`} file`;return s?(0,$.jsx)(AT,{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)(R,{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)(nE,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r,workerBadge:a})}ny(),H(),Gg(),ym();function cE({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=k(),a=(0,Q.useMemo)(()=>n?Sl({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
30
+ `)[0]??null;return(0,$.jsx)(U,{flexDirection:`column`,children:(0,$.jsx)(U,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?di(a.map(t=>(0,$.jsx)(df,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(N,{fromLeftEdge:!0,children:(0,$.jsx)(R,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ih,{code:t||`(No content)`,filePath:e})})})}H(),wr(),gr(),Hn();var lE={getConfig:e=>{let t;try{t=Jn(e.file_path)}catch(e){if(!pr(e))throw e;t=``}return rE(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function uE(e){let t=e=>Fu.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:Jn(n)}}catch(e){if(!pr(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:i?`Overwrite file`:`Create file`,subtitle:NS(Tr(),n),question:(0,$.jsxs)(R,{children:[`Do you want to `,o,` `,(0,$.jsx)(R,{bold:!0,children:kS(n)}),`?`]}),content:(0,$.jsx)(cE,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:lE})}H(),Ci(),wr(),Gg(),vr(),ym(),Bf();function dE(e){let t=(0,Q.useMemo)(()=>yr().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>ui(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(fE,{...e,promise:t})})}function fE({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=Go(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:Sl({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)(R,{bold:!0,children:a?e:NS(Tr(),e)}),(0,$.jsxs)(R,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ih,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(U,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(ih,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?di(u.map(t=>(0,$.jsx)(df,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
31
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(N,{fromLeftEdge:!0,children:(0,$.jsx)(R,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(ih,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}H(),Zr();function pE(e){let t=e=>{let t=C_.inputSchema.safeParse(e);return t.success?t.data:(Qr(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)(AT,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,workerBadge:e.workerBadge,title:`Edit notebook`,question:(0,$.jsxs)(R,{children:[`Do you want to `,s,` `,(0,$.jsx)(R,{bold:!0,children:kS(r)}),`?`]}),content:(0,$.jsx)(dE,{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 mE=[{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 hE(e){for(let{pattern:t,warning:n}of mE)if(t.test(e))return n;return null}Vi(),cg();async function gE(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||Tf.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 bw(n),i=await hw(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||uw[n])?null:i}async function _E(e,t){let n=await Um(e);if(!n.valid)return[];let r=Tp(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await gE(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await gE(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=vE(t);(n===``?0:Hi(n,` `)+1)<=1&&((await bw(e))?.subcommands?.length||uw[e])||o.push(n)}return o}function vE(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(` `)}ga();function yE({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`}),$l()&&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=RT(e,K_);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(),ty(),an(),Cr(),Ht(),zm(),Bb(),YC();function bE(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,workerBadge:a}=e,{command:o,description:s}=od.inputSchema.parse(t.input),[c]=ae(),l=iT({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}=PT({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:l.visible}),S=gn(`tengu_destructive_command_warning`,!1)?hE(o):null,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(o.includes(`
32
+ `)?void 0:o),D=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return _E(o,e=>Ph(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)},[]);Pw(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let k=(0,Q.useMemo)(()=>yE({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]);we(`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=hn(t.tool.name);if(e===`yes-prefix-edited`){let e=(T??``).trim();if(NT(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:od.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=m.trim();NT(`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`:{NT(`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)(Hb,{workerBadge:a,title:`PowerShell command`,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(R,{dimColor:l.visible,children:od.renderToolUseMessage({command:o,description:s},{theme:c,verbose:!0})}),!l.visible&&(0,$.jsx)(R,{dimColor:!0,children:t.description}),(0,$.jsx)(oT,{visible:l.visible,promise:l.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vw,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(U,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(R,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:t.permissionResult,toolType:`command`}),S&&(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{color:`warning`,children:S})}),(0,$.jsx)(R,{children:`Do you want to proceed?`}),(0,$.jsx)(wd,{options:k,inlineDescriptions:!0,onChange:A,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(U,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(R,{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)(R,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Zr(),ot(),H(),Ht(),zr(),ga(),jw(),Bb(),tE(),YC();function xE(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i,workerBadge:a}=e,o=(e=>{let t=fs.inputSchema.safeParse(e);return t.success?t.data.skill:(Qr(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;Pw(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=ft(),l=$l(),u=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(l){t.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:o}),` in `,(0,$.jsx)(R,{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)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(R,{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:hn(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),f=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:D_,ruleContent:o}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}});let e=o.indexOf(` `),r=e>0?o.substring(0,e):o;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:D_,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onReject(i),r(),n();break}},[t,n,r,o]),p=(0,Q.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Vr.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Hb,{title:`Use skill "${o}"?`,workerBadge:a,children:[(0,$.jsx)(R,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(R,{dimColor:!0,children:s?.description})}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(ZT,{options:u,onSelect:f,onCancel:p,toolAnalyticsContext:d})]})]})}H(),ga(),zm(),Bb(),YC();function SE(e){try{let t=Ga.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 CE({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,workerBadge:i}){let[a]=ae(),{url:o}=e.input,s=new URL(o).hostname;Pw(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let c=$l(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`}];return c&&e.push({label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:s})]}),value:`yes-dont-ask-again-domain`}),e.push({label:(0,$.jsxs)(R,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(R,{bold:!0,children:`(esc)`})]}),value:`no`}),e},[s,c]);function u(r){switch(r){case`yes`:NT(`tool_use_single`,e,`accept`),e.onAllow(e.input,[]),t();break;case`yes-dont-ask-again-domain`:{NT(`tool_use_single`,e,`accept`);let n=SE(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`:NT(`tool_use_single`,e,`reject`),e.onReject(),n(),t();break}}return(0,$.jsxs)(Hb,{title:`Fetch`,workerBadge:i,children:[(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(R,{children:Ga.renderToolUseMessage(e.input,{theme:a,verbose:r})}),(0,$.jsx)(R,{dimColor:!0,children:e.description})]}),(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(qC,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(R,{children:`Do you want to allow Claude to fetch this content?`}),(0,$.jsx)(wd,{options:l,onChange:u,onCancel:()=>u(`no`)})]})]})}var wE=r({WorkflowPermissionRequest:()=>TE});function TE({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ae(),a=up(i),o=e.input,s=(0,EE.useMemo)(()=>$l(),[]),c=(0,EE.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,DE.jsxs)(R,{children:[`Yes, and don`,`’`,`t ask again for `,(0,DE.jsx)(R,{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,EE.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,EE.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,DE.jsx)(Hb,{title:`Workflow`,workerBadge:r,children:(0,DE.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,DE.jsxs)(U,{flexDirection:`column`,children:[(0,DE.jsxs)(R,{bold:!0,color:a.permission,children:[`Execute workflow: `,o.workflow]}),o.args&&(0,DE.jsxs)(R,{dimColor:!0,children:[`Arguments: `,o.args]})]}),(0,DE.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),(0,DE.jsx)(ZT,{options:c,onSelect:l,onCancel:u})]})})}var EE,DE,OE=t((()=>{EE=n(L(),1),H(),zr(),ga(),jw(),Bb(),tE(),YC(),DE=je()})),kE=r({MonitorPermissionRequest:()=>AE});function AE({toolUseConfirm:e,onDone:t,onReject:n,workerBadge:r}){let[i]=ae(),a=up(i),o=e.input,s=(0,jE.useMemo)(()=>$l(),[]),c=(0,jE.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return s&&t.push({label:(0,ME.jsxs)(R,{children:[`Yes, and don`,`’`,`t ask again for `,(0,ME.jsx)(R,{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,jE.useCallback)((r,i)=>{switch(r){case`yes`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Aw({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),u=(0,jE.useCallback)(()=>{Aw({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Vr.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,ME.jsx)(Hb,{title:`Monitor`,workerBadge:r,children:(0,ME.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,ME.jsxs)(U,{flexDirection:`column`,children:[(0,ME.jsx)(R,{bold:!0,color:a.permission,children:o.description}),(0,ME.jsx)(R,{dimColor:!0,children:zi(o.command,5)})]}),(0,ME.jsx)(qC,{permissionResult:e.permissionResult,toolType:`command`}),(0,ME.jsx)(ZT,{options:c,onSelect:l,onCancel:u})]})})}var jE,ME,NE=t((()=>{jE=n(L(),1),H(),Zf(),zr(),ga(),Vi(),jw(),Bb(),tE(),YC(),ME=je()}));ty(),Gu(),f_(),$i(),cd(),Sa(),Zi(),qu(),vc();var PE=null,FE=null,IE=(Yc(),e(ta)).createWorkflowToolCore(),LE=(OE(),e(wE)).WorkflowPermissionRequest,RE=(dp(),e(gm)).MonitorTool,zE=(NE(),e(kE)).MonitorPermissionRequest;function BE(e){switch(e){case Kc:return aE;case Fu:return uE;case Mg:return HT;case od:return bE;case PE:return FE??nE;case Ga:return CE;case C_:return pE;case Mu:return JT;case iu:return WT;case fs:return xE;case us:return rw;case IE:return LE??nE;case RE:return zE??nE;case Jl:case No:case Ts:return sE;default:return nE}}function VE(e){let t=e.tool.userFacingName(e.input);return e.tool===Mu?`Claude Code needs your approval for the plan`:e.tool===iu?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function HE({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o}){return we(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),RC(VE(e),`permission_prompt`),(0,$.jsx)(BE(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,workerBadge:a,setStickyFooter:o})}Zr(),ql();async function UE(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=dv([`You are a date/time parser that converts natural language into ISO 8601 format.`,`You MUST respond with ONLY the ISO 8601 formatted string, with no explanation or additional text.`,`If the input is ambiguous, prefer future dates over past dates.`,`For times without dates, use today's date.`,`For dates without times, do not include a time component.`,`If the input is incomplete or you cannot confidently parse it into a valid date, respond with exactly "INVALID" (nothing else).`,`Examples of INVALID input: partial dates like "2025-01-", lone numbers like "13", gibberish.`,`Examples of valid natural language: "tomorrow", "next Monday", "jan 1st 2025", "in 2 hours", "yesterday".`]),d=`Current context:
33
33
  - Current date and time: ${i} (UTC)
34
34
  - Local timezone: ${c}
35
35
  - Day of week: ${l}
@@ -38,13 +38,13 @@ User input: "${e}"
38
38
 
39
39
  Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
40
40
 
41
- Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await Mm({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=qp(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 Qr(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function WE(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}w(),fr(),Vi();var GE=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function KE(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function qE(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function JE(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function YE(e,t){let n=qE(e).indexOf(t);return n>=0?JE(e)[n]??t:t}function XE(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function ZE(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function QE(e,t){let n=XE(e).indexOf(t);return n>=0?ZE(e)[n]??t:t}function $E(e){if(GE(e)){let[t,...n]=XE(e);return t?y([t,...n]):x()}if(e.type===`string`){let t=_();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Bi(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Bi(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=S({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 C();throw Error(`Unsupported schema: ${hr(e)}`)}function eD(e,t){let n=$E(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function tD(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function nD(e,t,n){let r=eD(e,t);if(r.isValid)return r;if(tD(t)&&!WE(e)){let r=await UE(e,t.format,n);if(r.success){let e=eD(r.value,t);if(e.isValid)return e}}return r}f(),ny(),H(),ty(),Vi(),Af();var rD=e=>[`string`,`number`,`integer`].includes(e.type),iD=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,aD=e=>(e+1)%10;function oD(e){e.buffer=``,e.timer=void 0}function sD(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,aD);return()=>clearInterval(e)},[]),(0,$.jsx)(R,{color:`warning`,children:iD[e]})}function cD(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 lD({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(dD,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(uD,{event:e,onResponse:t})}function uD({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(rD(n)&&n?.default!==void 0){let r=eD(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&rD(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),A=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=A.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:j,rows:M}=k(),N=h===void 0?void 0:m[h],P=N!==void 0&&rD(N.schema)&&!GE(N.schema)&&!s;fg(`elicitation`),RC(`Claude Code needs your input`,`elicitation_dialog`);let ee=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&rD(t.schema)&&!GE(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function F(e,t){if(!KE(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?I(e,`Select at least ${i} ${Bi(i,`item`)}`):a!==void 0&&n.length>a?I(e,`Select at most ${a} ${Bi(a,`item`)}`):I(e)}function te(e){N&&KE(N.schema)?(F(N.name,N.schema),w(void 0)):N&&GE(N.schema)&&w(void 0),P&&N&&(L(N.name,N.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),tD(N.schema)&&_.trim()!==``&&d[N.name]&&ie(N.name,N.schema,_));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(g(r),c(null),ee(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function ne(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`&&I(e)}function I(e,t){f(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function re(e){e&&(ne(e,void 0),I(e),v(``),b(0))}function L(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){re(e);return}if(r===``){l[e]!==void 0&&ne(e,``);return}let i=eD(n,t);ne(e,i.isValid?i.value:n),I(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)),nD(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){ne(e,t.value),I(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else I(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),N&&(L(N.name,N.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),tD(N.schema)&&e.trim()!==``&&d[N.name])){let t=N.name,n=N.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=A.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(oD,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}we(`confirm:no`,()=>{if(P&&N){let e=l[N.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!N&&!s&&!C}),Oe((e,n)=>{if(P&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&N&&KE(N.schema)){let t=N.schema,r=qE(t),i=l[N.name]??[];if(n.leftArrow||n.escape){w(void 0),F(N.name,t);return}if(n.upArrow){T===0?(w(void 0),F(N.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;ne(N.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||N.isRequired)?I(N.name,`Select at least ${a} ${Bi(a,`item`)}`):o!==void 0&&n.length>o?I(N.name,`Select at most ${o} ${Bi(o,`item`)}`):I(N.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&ne(N.name,[...i,e]),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>YE(t,e).toLowerCase()),E);return}return}if(C&&N&&GE(N.schema)){let t=N.schema,r=XE(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&&ne(N.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&ne(N.name,e),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>QE(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&&I(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||d[t.name]!==void 0);t!==-1&&(g(t),c(null),ee(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=A.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(!N)return;let{schema:r,name:i}=N,o=l[i];if(r.type===`boolean`){if(e===` `){ne(i,o===void 0?!0:!o);return}if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){re(i);return}if(e&&!n.return){se(e,[`yes`,`no`],e=>ne(i,e===0));return}return}if(GE(r)||KE(r)){if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){re(i);return}let t,a=0;if(GE(r)){let e=XE(r);t=e.map(e=>QE(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=qE(r).map(e=>YE(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&&P&&_===``){re(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((M-14)/3)),ue=(0,Q.useMemo)(()=>{let e=m.length;if(e<=le)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(le/2)),r=Math.min(n+le,e);return n=Math.max(0,r-le),{start:n,end:r}},[m.length,le,h]),de=ue.start>0,fe=ue.end<m.length;function pe(){return m.length?(0,$.jsxs)(U,{flexDirection:`column`,children:[de&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowUp,` `,ue.start,` more above`]})}),m.slice(ue.start,ue.end).map((e,t)=>{let n=ue.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),f=d[r],m=x.has(r)?(0,$.jsx)(sD,{}):f?(0,$.jsx)(R,{color:`error`,children:p.warning}):u?(0,$.jsx)(R,{color:`success`,dimColor:!o,children:p.tick}):a?(0,$.jsx)(R,{color:`error`,children:`*`}):(0,$.jsx)(R,{children:` `}),g=f?`error`:u?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(R,{color:v,bold:o,children:i.title||r}),w,E=null;if(KE(i)){let e=qE(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(R,{dimColor:!0,children:p.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=YE(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:o?p.pointer:` `}),(0,$.jsx)(R,{color:a?`success`:void 0,children:a?p.checkboxOn:p.checkboxOff}),(0,$.jsx)(R,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(R,{dimColor:!0,children:[p.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{color:v,bold:o,children:t.map(e=>YE(i,e)).join(`, `)})]}):(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(GE(i)){let e=XE(i);if(C===r&&o)w=(0,$.jsx)(R,{dimColor:!0,children:p.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=QE(i,e),r=c===e,a=t===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:a?p.pointer:` `}),(0,$.jsx)(R,{color:r?`success`:void 0,children:r?p.radioOn:p.radioOff}),(0,$.jsx)(R,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(R,{dimColor:!0,children:[p.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{color:v,bold:o,children:QE(i,c)})]}):(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(R,{color:v,bold:!0,children:c?p.checkboxOn:p.checkboxOff}):(0,$.jsx)(R,{dimColor:!0,children:p.checkboxOff}):u?(0,$.jsx)(R,{children:c?p.checkboxOn:p.checkboxOff}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`});else if(rD(i))if(o)w=(0,$.jsx)(Qd,{value:_,onChange:ae,onSubmit:oe,placeholder:`Type something…`,columns:Math.min(j-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=u&&tD(i)?cD(String(c),i):String(c);w=u?(0,$.jsx)(R,{children:e}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(R,{children:String(c)}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:g,children:o?p.pointer:` `}),m,(0,$.jsxs)(U,{children:[S,(0,$.jsx)(R,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(U,{marginLeft:6,children:(0,$.jsx)(R,{dimColor:!0,children:i.description})}),(0,$.jsx)(U,{marginLeft:6,height:1,children:f?(0,$.jsx)(R,{color:`error`,italic:!0,children:f}):(0,$.jsx)(R,{children:` `})})]},r)}),fe&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowDown,` `,m.length-ue.end,` more below`]})})]}):null}return(0,$.jsx)(B,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!N||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`↑↓`,action:`navigate`}),N&&(0,$.jsx)(he,{shortcut:`Backspace`,action:`unset`}),N&&N.schema.type===`boolean`&&(0,$.jsx)(he,{shortcut:`Space`,action:`toggle`}),N&&GE(N.schema)&&(C?(0,$.jsx)(he,{shortcut:`Space`,action:`select`}):(0,$.jsx)(he,{shortcut:`→`,action:`expand`})),N&&KE(N.schema)&&(C?(0,$.jsx)(he,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(he,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[pe(),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:s===`accept`?p.pointer:` `}),(0,$.jsx)(R,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(R,{color:`error`,children:s===`decline`?p.pointer:` `}),(0,$.jsx)(R,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function dD({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`),m=a?.showCancel??!1;RC(`Claude Code needs your input`,`elicitation_url_dialog`),fg(`elicitation-url`),u.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{$v(s),t(`accept`),l(`waiting`),u.current=`waiting`,f(`open`)},[t,s]);if(Oe((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=m?[`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`?$v(s):d===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(B,{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)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(R,{children:[_,(0,$.jsx)(R,{bold:!0,children:g}),v]})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:d===`open`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`open`,color:d===`open`?`success`:void 0,dimColor:d!==`open`,children:` Reopen URL `}),(0,$.jsx)(R,{color:`success`,children:d===`action`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`action`,color:d===`action`?`success`:void 0,dimColor:d!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:`error`,children:d===`cancel`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`cancel`,color:d===`cancel`?`error`:void 0,dimColor:d!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(B,{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)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(R,{children:[_,(0,$.jsx)(R,{bold:!0,children:g}),v]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:d===`accept`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`accept`,color:d===`accept`?`success`:void 0,dimColor:d!==`accept`,children:` Accept `}),(0,$.jsx)(R,{color:`error`,children:d===`decline`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`decline`,color:d===`decline`?`error`:void 0,dimColor:d!==`decline`,children:` Decline`})]})]})})}H(),ty(),Im(),Bb();function fD({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){we(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Hb,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(R,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(U,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(Sd,{options:a,onChange:e=>{r(e)}})})})}Cs();function pD(){return(0,Q.useSyncExternalStore)(Uc,Vl)}Zr(),w(),fa(),Ii();var mD=`at_mentioned`,hD=Fi(()=>b({method:v(mD),params:b({filePath:_(),lineStart:g().optional(),lineEnd:g().optional()})}));function gD(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Il(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(hD(),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){Qr(e)}})},[e,t])}f(),ny(),H(),X(),lr(),X_(),Jb(),Z_();var _D=1e3,vD=10,yD=3,bD=2500,xD=[0,0,0,0,1,0,0,0,-1,0,0,2,0,0,0],SD=p.heart,CD=[` ${SD} ${SD} `,` ${SD} ${SD} ${SD} `,` ${SD} ${SD} ${SD} `,`${SD} ${SD} ${SD} `,`· · · `];function wD(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 TD({text:e,color:t,fading:n,tail:r}){let i=wD(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)(R,{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)(R,{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)(R,{color:a,children:`╲ `}),(0,$.jsx)(R,{color:a,children:`╲`})]})]})}var ED=12,DD=2,OD=2,kD=36,AD=24;function jD(e){return Math.max(ED,e+DD)}function MD(e,t){let n=Y_();if(!n||En().companionMuted||e<100)return 0;let r=D(n.name),i=t&&!Rg()?kD:0;return jD(r)+OD+i}function ND(){let e=Z(e=>e.companionReaction),t=Z(e=>e.companionPetAt),n=Z(e=>e.footerSelection===`companion`),r=kf(),{columns:i}=k(),[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),_D,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}),vD*_D,r);return()=>clearTimeout(t)},[e,r]);let d=Y_();if(!d||En().companionMuted)return null;let f=J_[d.rarity],m=jD(D(d.name)),h=e?a-s.current:0,g=e!==void 0&&h>=vD-yD,_=t?a-c:1/0,v=_*_D<bD;if(i<100){let t=e&&e.length>AD?e.slice(0,AD-1)+`…`:e,r=t?`"${t}"`:n?` ${d.name} `:d.name;return(0,$.jsx)(U,{paddingX:1,alignSelf:`flex-end`,children:(0,$.jsxs)(R,{children:[v&&(0,$.jsxs)(R,{color:`autoAccept`,children:[p.heart,` `]}),(0,$.jsx)(R,{bold:!0,color:f,children:Kb(d)}),` `,(0,$.jsx)(R,{italic:!0,dimColor:!n&&!e,bold:n,inverse:n&&!e,color:e?g?`inactive`:f:n?f:void 0,children:r})]})})}let y=Gb(d.species),b=v?CD[_%CD.length]:null,x,S=!1;if(e||v)x=a%y;else{let e=xD[a%xD.length];e===-1?(x=0,S=!0):x=e%y}let C=qb(d,x).map(e=>S?e.replaceAll(d.eye,`-`):e),w=(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:0,alignItems:`center`,width:m,children:[(b?[b,...C]:C).map((e,t)=>(0,$.jsx)(R,{color:t===0&&b?`autoAccept`:f,children:e},t)),(0,$.jsx)(R,{italic:!0,bold:n,dimColor:!n,color:n?f:void 0,inverse:n,children:n?` ${d.name} `:d.name})]});return!e||Rg()?(0,$.jsx)(U,{paddingX:1,children:w}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-end`,paddingX:1,flexShrink:0,children:[(0,$.jsx)(TD,{text:e,color:f,fading:g,tail:`right`}),w]})}function PD(){let e=Z(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})),_D,r);return()=>clearInterval(t)},[e]),!e)return null;let i=Y_();return!i||En().companionMuted?null:(0,$.jsx)(TD,{text:e,color:J_[i.rarity],fading:t>=vD-yD,tail:`down`})}tu(),Lm(),Ox(),Fx(),Lx();function FD(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 ID(){let e=Z(e=>e.settings.voiceEnabled===!0),t=Z(e=>e.settings.voiceProvider),n=(0,LD.useMemo)(Sy,[Z(e=>e.authVersion)]);return t===`doubao`?e&&by():e&&n&&by()}var LD,RD=t((()=>{LD=n(L(),1),X()}));Bh(),Rb(),RD(),H();function zD({ideSelection:e,mcpClients:t}){let{status:n}=FD(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)(R,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(R,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,kS(e.filePath)]},`selection-indicator`)}var BD=1.5*1024*1024*1024,VD=2.5*1024*1024*1024;function HD(){let[e,t]=(0,Q.useState)(null);return se(()=>{let e=process.memoryUsage().heapUsed,n=e>=VD?`critical`:e>=BD?`high`:`normal`;t(t=>n===`normal`?t===null?t:null:{heapUsed:e,status:n})},1e4),e}H(),Pi();function UD(){if(process.env.USER_TYPE!==`ant`)return null;let e=HD();if(!e)return null;let{heapUsed:t,status:n}=e;if(n===`normal`)return null;let r=ji(t);return(0,$.jsx)(U,{children:(0,$.jsxs)(R,{color:n===`critical`?`error`:`warning`,wrap:`truncate`,children:[`High memory usage (`,r,`) · /heapdump`]})})}function WD(){return(0,Q.useSyncExternalStore)(Pm.subscribe,Pm.getState)}H(),an(),dd();function GD({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=zf(e,t),a=WD();if(!r||a)return null;let o=hm(),s=Jf(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(U,{flexDirection:`row`,children:o?(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(R,{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(),oo();function KD(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=bc(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Gs.isSandboxingEnabled())return;let e=Gs.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)}},[]),!Gs.isSandboxingEnabled()||e===0?null:(0,$.jsx)(U,{paddingX:0,paddingY:0,children:(0,$.jsxs)(R,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}var qD=r({VoiceIndicator:()=>JD,VoiceWarmupHint:()=>XD});function JD(e){return(0,QD.jsx)(YD,{...e})}function YD({voiceState:e}){switch(e){case`recording`:return(0,QD.jsx)(R,{dimColor:!0,children:`listening…`});case`processing`:return(0,QD.jsx)(ZD,{});case`idle`:return null}}function XD(){return(0,QD.jsx)(R,{dimColor:!0,children:`keep holding…`})}function ZD(){let e=wh().prefersReducedMotion??!1,[t,n]=E(e?null:50);if(e)return(0,QD.jsx)(R,{color:`warning`,children:`Voice: processing…`});let r=n/1e3;return(0,QD.jsx)(U,{ref:t,children:(0,QD.jsx)(R,{color:qf(op($D,eO,(Math.sin(r*Math.PI*2/tO)+1)/2)),children:`Voice: processing…`})})}var QD,$D,eO,tO,nO=t((()=>{L(),xm(),H(),QD=je(),$D={r:153,g:153,b:153},eO={r:185,g:185,b:185},tO=2}));Fm(),Cr(),X(),H(),ih(),jb(),Pi(),fa(),ql(),Fa();var rO=(nO(),e(qD)).VoiceIndicator,iO=5e3;function aO({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)(()=>b_(Rc(a)),[a]),p=Lb(),m=zf(f,p).isAboveWarningThreshold,{status:h}=FD(l),g=Z(e=>e.notifications),{addNotification:_,removeNotification:v}=Lh(),y=Ud();(0,Q.useEffect)(()=>(Gf((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Gf(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=Qn(),S=x===`team`||x===`enterprise`,C=Mb(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(Y(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(Ja,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${T_(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(_y,{children:(0,$.jsx)(U,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(oO,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})})}function oO({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:a,debug:o,verbose:s,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!mn())return;let e=setInterval(e=>{let t=Gt(),n=t>=1e4?Ai(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]);let p=Dl(e=>e.voiceState),m=ID(),h=Dl(e=>e.voiceError),g=Z(e=>e.isBriefOnly);return m&&(p===`recording`||p===`processing`)?(0,$.jsx)(rO,{voiceState:p}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zD,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(R,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(R,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(U,{children:[(0,$.jsxs)(R,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(R,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(a===`invalid`||a===`missing`)&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`error`,wrap:`truncate`,children:c(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in · Run /login`})}),o&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),a!==`invalid`&&a!==`missing`&&s&&(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),!g&&(0,$.jsx)(GD,{tokenUsage:l,model:u}),m&&h&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`error`,wrap:`truncate`,children:h})}),(0,$.jsx)(UD,{}),(0,$.jsx)(KD,{})]})}Fm(),Fa(),H();var sO=10,cO=null,lO=0,uO;async function dO(e,t){let n=Math.ceil(e/sO)*sO;if(cO&&lO>=n&&uO===t)return cO;cO&&await cO,lO=n,uO=t,cO=(async()=>{let e=[],n=0;for await(let r of fu())if(!(t&&Wc(r.display)!==t)&&(e.push(r),n++,n>=lO))break;return e})();try{return await cO}finally{cO=null,lO=0,uO=void 0}}function fO(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}=Lh(),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=Wc(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)(R,{dimColor:!0,children:(0,$.jsx)(Ja,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:iO})},[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 dO(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])}}X();function pO(){let e=Z(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(pc).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])}ff(),ws(),H(),ty();function mO(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=ph(),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(Wc(i)),n(i),l(e.value.pastedContents);let t=Ji(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=ph(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),N=(0,Q.useCallback)(()=>{if(C){let e=Wc(C.display);n(Ji(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),P=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),ee=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=Wc(C.display),n=Ji(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);we(`history:search`,j,{context:`Global`,isActive:!s}),V((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":N,"historySearch:cancel":P,"historySearch:execute":ee}),[M,N,P,ee]),{context:`HistorySearch`,isActive:s});let F=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),P())};Oe((e,t,n)=>{F(new Ae(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 hO({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(),Cr(),X();function gO({inputValue:e,isAssistantResponding:t}){let n=Z(e=>e.promptSuggestion),r=kf(),i=le(),{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)(()=>{Hc(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])}}Zo(),q(),Gc();var _O=15,vO=1e3,yO=[`|`,`||`,`&&`,`;`];function bO(e){return typeof e==`object`&&!!e&&`op`in e&&yO.includes(e.op)}function xO(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function SO(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function CO(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&bO(n)}function wO(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=ev(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:xO(t)}}let a=SO(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&bO(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=xO(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=CO(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function TO(e,t){return t===`variable`?`compgen -v ${tv([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${tv([e])} 2>/dev/null | head -${_O} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${tv([e])} 2>/dev/null`}function EO(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${tv([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${tv([e])}*(N[1,${_O}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${tv([e])}*]} 2>/dev/null`}async function DO(e,t,n,r){let i;if(e===`bash`)i=TO(t,n);else if(e===`zsh`)i=EO(t,n);else return[];return(await(await Lf(i,r,`bash`,{timeout:vO})).result).stdout.split(`
42
- `).filter(e=>e.trim()).slice(0,_O).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function OO(e,t,n){let r=$u();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=wO(e,t);return i?(await DO(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return J(`Shell completion failed: ${e}`),[]}}eS(),wm();var kO=/[:_-]/g,AO=null;function jO(e){if(AO?.commands===e)return AO.fuse;let t=new tS(e.filter(e=>!e.isHidden).map(e=>{let t=cp(e),n=t.split(kO).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>UO(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 AO={commands:e,fuse:t},t}function MO(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function NO(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 PO(e,t){if(!e)return null;let n=VO(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!MO(t.metadata))continue;let n=cp(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function FO(e){return e.startsWith(`/`)}function IO(e){return!(!FO(e)||!e.includes(` `)||e.endsWith(` `))}function LO(e){return`/${e} `}function RO(e){let t=cp(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function zO(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function BO(e,t){let n=cp(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:hs(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:RO(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function VO(e,t){if(!FO(e)||IO(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:ym(cp(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=>RO(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(RO(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)=>cp(e).localeCompare(cp(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=>BO(e))}let r=t.find(e=>e.isHidden&&cp(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&cp(e).toLowerCase()===n)&&(r=void 0);let i=jO(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`?ym(cp(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 BO(t,zO(n,t.aliases))});if(r){let e=RO(r);if(!i.some(t=>t.id===e))return[BO(r),...i]}return i}function HO(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?ku(o,n):void 0;else{if(!MO(e.metadata))return;o=cp(e.metadata),s=e.metadata}let c=LO(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function UO(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function WO(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}Tb(),ws(),q();var GO=null,KO=0,qO=6e4;async function JO(){let e=Date.now();if(GO&&e-KO<qO)return GO;let t=[],n=new Set;try{for await(let e of fu()){if(e.display&&e.display.startsWith(`!`)){let r=e.display.slice(1).trim();r&&!n.has(r)&&(n.add(r),t.push(r))}if(t.length>=50)break}}catch(e){J(`Failed to read shell history: ${e}`)}return GO=t,KO=e,t}function YO(e){if(!GO)return;let t=GO.indexOf(e);t!==-1&&GO.splice(t,1),GO.unshift(e)}async function XO(e){if(!e||e.length<2||!e.trim())return null;let t=await JO();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}q(),Ii(),Le(),fr();var ZO=`slack_search_channels`,QO=new Map,$O=new Set,ek=0,tk=Ke(),nk=tk.subscribe,rk=null,ik=null;function ak(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function ok(e,t){let n=ak(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:ZO,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?lk(ck(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
41
+ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await Fm({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Zp(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 Qr(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function WE(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}w(),fr(),Vi();var GE=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function KE(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function qE(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function JE(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function YE(e,t){let n=qE(e).indexOf(t);return n>=0?JE(e)[n]??t:t}function XE(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function ZE(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function QE(e,t){let n=XE(e).indexOf(t);return n>=0?ZE(e)[n]??t:t}function $E(e){if(GE(e)){let[t,...n]=XE(e);return t?y([t,...n]):x()}if(e.type===`string`){let t=_();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Bi(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Bi(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=S({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 C();throw Error(`Unsupported schema: ${hr(e)}`)}function eD(e,t){let n=$E(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function tD(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function nD(e,t,n){let r=eD(e,t);if(r.isValid)return r;if(tD(t)&&!WE(e)){let r=await UE(e,t.format,n);if(r.success){let e=eD(r.value,t);if(e.isValid)return e}}return r}f(),ny(),H(),ty(),Vi(),jf();var rD=e=>[`string`,`number`,`integer`].includes(e.type),iD=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,aD=e=>(e+1)%10;function oD(e){e.buffer=``,e.timer=void 0}function sD(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,aD);return()=>clearInterval(e)},[]),(0,$.jsx)(R,{color:`warning`,children:iD[e]})}function cD(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 lD({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(dD,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(uD,{event:e,onResponse:t})}function uD({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(rD(n)&&n?.default!==void 0){let r=eD(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&rD(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),A=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=A.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:j,rows:M}=k(),N=h===void 0?void 0:m[h],P=N!==void 0&&rD(N.schema)&&!GE(N.schema)&&!s;mg(`elicitation`),RC(`Claude Code needs your input`,`elicitation_dialog`);let ee=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&rD(t.schema)&&!GE(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function F(e,t){if(!KE(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?I(e,`Select at least ${i} ${Bi(i,`item`)}`):a!==void 0&&n.length>a?I(e,`Select at most ${a} ${Bi(a,`item`)}`):I(e)}function te(e){N&&KE(N.schema)?(F(N.name,N.schema),w(void 0)):N&&GE(N.schema)&&w(void 0),P&&N&&(L(N.name,N.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),tD(N.schema)&&_.trim()!==``&&d[N.name]&&ie(N.name,N.schema,_));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(g(r),c(null),ee(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function ne(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`&&I(e)}function I(e,t){f(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function re(e){e&&(ne(e,void 0),I(e),v(``),b(0))}function L(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){re(e);return}if(r===``){l[e]!==void 0&&ne(e,``);return}let i=eD(n,t);ne(e,i.isValid?i.value:n),I(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)),nD(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){ne(e,t.value),I(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else I(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),N&&(L(N.name,N.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),tD(N.schema)&&e.trim()!==``&&d[N.name])){let t=N.name,n=N.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=A.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(oD,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}we(`confirm:no`,()=>{if(P&&N){let e=l[N.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!N&&!s&&!C}),Oe((e,n)=>{if(P&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&N&&KE(N.schema)){let t=N.schema,r=qE(t),i=l[N.name]??[];if(n.leftArrow||n.escape){w(void 0),F(N.name,t);return}if(n.upArrow){T===0?(w(void 0),F(N.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;ne(N.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||N.isRequired)?I(N.name,`Select at least ${a} ${Bi(a,`item`)}`):o!==void 0&&n.length>o?I(N.name,`Select at most ${o} ${Bi(o,`item`)}`):I(N.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&ne(N.name,[...i,e]),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>YE(t,e).toLowerCase()),E);return}return}if(C&&N&&GE(N.schema)){let t=N.schema,r=XE(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&&ne(N.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&ne(N.name,e),w(void 0),te(`down`);return}if(e){se(e,r.map(e=>QE(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&&I(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||d[t.name]!==void 0);t!==-1&&(g(t),c(null),ee(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=A.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(!N)return;let{schema:r,name:i}=N,o=l[i];if(r.type===`boolean`){if(e===` `){ne(i,o===void 0?!0:!o);return}if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){re(i);return}if(e&&!n.return){se(e,[`yes`,`no`],e=>ne(i,e===0));return}return}if(GE(r)||KE(r)){if(n.return){te(`down`);return}if(n.backspace&&o!==void 0){re(i);return}let t,a=0;if(GE(r)){let e=XE(r);t=e.map(e=>QE(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=qE(r).map(e=>YE(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&&P&&_===``){re(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((M-14)/3)),ue=(0,Q.useMemo)(()=>{let e=m.length;if(e<=le)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(le/2)),r=Math.min(n+le,e);return n=Math.max(0,r-le),{start:n,end:r}},[m.length,le,h]),de=ue.start>0,fe=ue.end<m.length;function pe(){return m.length?(0,$.jsxs)(U,{flexDirection:`column`,children:[de&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowUp,` `,ue.start,` more above`]})}),m.slice(ue.start,ue.end).map((e,t)=>{let n=ue.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),f=d[r],m=x.has(r)?(0,$.jsx)(sD,{}):f?(0,$.jsx)(R,{color:`error`,children:p.warning}):u?(0,$.jsx)(R,{color:`success`,dimColor:!o,children:p.tick}):a?(0,$.jsx)(R,{color:`error`,children:`*`}):(0,$.jsx)(R,{children:` `}),g=f?`error`:u?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(R,{color:v,bold:o,children:i.title||r}),w,E=null;if(KE(i)){let e=qE(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(R,{dimColor:!0,children:p.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=YE(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:o?p.pointer:` `}),(0,$.jsx)(R,{color:a?`success`:void 0,children:a?p.checkboxOn:p.checkboxOff}),(0,$.jsx)(R,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(R,{dimColor:!0,children:[p.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{color:v,bold:o,children:t.map(e=>YE(i,e)).join(`, `)})]}):(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(GE(i)){let e=XE(i);if(C===r&&o)w=(0,$.jsx)(R,{dimColor:!0,children:p.triangleDownSmall}),E=(0,$.jsx)(U,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=QE(i,e),r=c===e,a=t===T;return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:`suggestion`,children:a?p.pointer:` `}),(0,$.jsx)(R,{color:r?`success`:void 0,children:r?p.radioOn:p.radioOff}),(0,$.jsx)(R,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(R,{dimColor:!0,children:[p.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{color:v,bold:o,children:QE(i,c)})]}):(0,$.jsxs)(R,{children:[e,(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(R,{color:v,bold:!0,children:c?p.checkboxOn:p.checkboxOff}):(0,$.jsx)(R,{dimColor:!0,children:p.checkboxOff}):u?(0,$.jsx)(R,{children:c?p.checkboxOn:p.checkboxOff}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`});else if(rD(i))if(o)w=(0,$.jsx)(tf,{value:_,onChange:ae,onSubmit:oe,placeholder:`Type something…`,columns:Math.min(j-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=u&&tD(i)?cD(String(c),i):String(c);w=u?(0,$.jsx)(R,{children:e}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(R,{children:String(c)}):(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{color:g,children:o?p.pointer:` `}),m,(0,$.jsxs)(U,{children:[S,(0,$.jsx)(R,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(U,{marginLeft:6,children:(0,$.jsx)(R,{dimColor:!0,children:i.description})}),(0,$.jsx)(U,{marginLeft:6,height:1,children:f?(0,$.jsx)(R,{color:`error`,italic:!0,children:f}):(0,$.jsx)(R,{children:` `})})]},r)}),fe&&(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowDown,` `,m.length-ue.end,` more below`]})})]}):null}return(0,$.jsx)(B,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!N||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`↑↓`,action:`navigate`}),N&&(0,$.jsx)(he,{shortcut:`Backspace`,action:`unset`}),N&&N.schema.type===`boolean`&&(0,$.jsx)(he,{shortcut:`Space`,action:`toggle`}),N&&GE(N.schema)&&(C?(0,$.jsx)(he,{shortcut:`Space`,action:`select`}):(0,$.jsx)(he,{shortcut:`→`,action:`expand`})),N&&KE(N.schema)&&(C?(0,$.jsx)(he,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(he,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[pe(),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:s===`accept`?p.pointer:` `}),(0,$.jsx)(R,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(R,{color:`error`,children:s===`decline`?p.pointer:` `}),(0,$.jsx)(R,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function dD({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`),m=a?.showCancel??!1;RC(`Claude Code needs your input`,`elicitation_url_dialog`),mg(`elicitation-url`),u.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{$v(s),t(`accept`),l(`waiting`),u.current=`waiting`,f(`open`)},[t,s]);if(Oe((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=m?[`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`?$v(s):d===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(B,{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)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(R,{children:[_,(0,$.jsx)(R,{bold:!0,children:g}),v]})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:d===`open`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`open`,color:d===`open`?`success`:void 0,dimColor:d!==`open`,children:` Reopen URL `}),(0,$.jsx)(R,{color:`success`,children:d===`action`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`action`,color:d===`action`?`success`:void 0,dimColor:d!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{children:` `}),(0,$.jsx)(R,{color:`error`,children:d===`cancel`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`cancel`,color:d===`cancel`?`error`:void 0,dimColor:d!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(B,{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)(R,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(he,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(R,{children:[_,(0,$.jsx)(R,{bold:!0,children:g}),v]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`success`,children:d===`accept`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`accept`,color:d===`accept`?`success`:void 0,dimColor:d!==`accept`,children:` Accept `}),(0,$.jsx)(R,{color:`error`,children:d===`decline`?p.pointer:` `}),(0,$.jsx)(R,{bold:d===`decline`,color:d===`decline`?`error`:void 0,dimColor:d!==`decline`,children:` Decline`})]})]})})}H(),ty(),zm(),Bb();function fD({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){we(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Hb,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(R,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(U,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(wd,{options:a,onChange:e=>{r(e)}})})})}Ss();function pD(){return(0,Q.useSyncExternalStore)(Lc,Vl)}Zr(),w(),ma(),Ii();var mD=`at_mentioned`,hD=Fi(()=>b({method:v(mD),params:b({filePath:_(),lineStart:g().optional(),lineEnd:g().optional()})}));function gD(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Il(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(hD(),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){Qr(e)}})},[e,t])}f(),ny(),H(),X(),lr(),X_(),Jb(),Z_();var _D=1e3,vD=10,yD=3,bD=2500,xD=[0,0,0,0,1,0,0,0,-1,0,0,2,0,0,0],SD=p.heart,CD=[` ${SD} ${SD} `,` ${SD} ${SD} ${SD} `,` ${SD} ${SD} ${SD} `,`${SD} ${SD} ${SD} `,`· · · `];function wD(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 TD({text:e,color:t,fading:n,tail:r}){let i=wD(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)(R,{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)(R,{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)(R,{color:a,children:`╲ `}),(0,$.jsx)(R,{color:a,children:`╲`})]})]})}var ED=12,DD=2,OD=2,kD=36,AD=24;function jD(e){return Math.max(ED,e+DD)}function MD(e,t){let n=Y_();if(!n||En().companionMuted||e<100)return 0;let r=D(n.name),i=t&&!zg()?kD:0;return jD(r)+OD+i}function ND(){let e=Z(e=>e.companionReaction),t=Z(e=>e.companionPetAt),n=Z(e=>e.footerSelection===`companion`),r=Af(),{columns:i}=k(),[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),_D,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}),vD*_D,r);return()=>clearTimeout(t)},[e,r]);let d=Y_();if(!d||En().companionMuted)return null;let f=J_[d.rarity],m=jD(D(d.name)),h=e?a-s.current:0,g=e!==void 0&&h>=vD-yD,_=t?a-c:1/0,v=_*_D<bD;if(i<100){let t=e&&e.length>AD?e.slice(0,AD-1)+`…`:e,r=t?`"${t}"`:n?` ${d.name} `:d.name;return(0,$.jsx)(U,{paddingX:1,alignSelf:`flex-end`,children:(0,$.jsxs)(R,{children:[v&&(0,$.jsxs)(R,{color:`autoAccept`,children:[p.heart,` `]}),(0,$.jsx)(R,{bold:!0,color:f,children:Kb(d)}),` `,(0,$.jsx)(R,{italic:!0,dimColor:!n&&!e,bold:n,inverse:n&&!e,color:e?g?`inactive`:f:n?f:void 0,children:r})]})})}let y=Gb(d.species),b=v?CD[_%CD.length]:null,x,S=!1;if(e||v)x=a%y;else{let e=xD[a%xD.length];e===-1?(x=0,S=!0):x=e%y}let C=qb(d,x).map(e=>S?e.replaceAll(d.eye,`-`):e),w=(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:0,alignItems:`center`,width:m,children:[(b?[b,...C]:C).map((e,t)=>(0,$.jsx)(R,{color:t===0&&b?`autoAccept`:f,children:e},t)),(0,$.jsx)(R,{italic:!0,bold:n,dimColor:!n,color:n?f:void 0,inverse:n,children:n?` ${d.name} `:d.name})]});return!e||zg()?(0,$.jsx)(U,{paddingX:1,children:w}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-end`,paddingX:1,flexShrink:0,children:[(0,$.jsx)(TD,{text:e,color:f,fading:g,tail:`right`}),w]})}function PD(){let e=Z(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})),_D,r);return()=>clearInterval(t)},[e]),!e)return null;let i=Y_();return!i||En().companionMuted?null:(0,$.jsx)(TD,{text:e,color:J_[i.rarity],fading:t>=vD-yD,tail:`down`})}ru(),Bm(),Ox(),Fx(),Lx();function FD(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 ID(){let e=Z(e=>e.settings.voiceEnabled===!0),t=Z(e=>e.settings.voiceProvider),n=(0,LD.useMemo)(Sy,[Z(e=>e.authVersion)]);return t===`doubao`?e&&by():e&&n&&by()}var LD,RD=t((()=>{LD=n(L(),1),X()}));Uh(),Rb(),RD(),H();function zD({ideSelection:e,mcpClients:t}){let{status:n}=FD(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)(R,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(R,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,kS(e.filePath)]},`selection-indicator`)}var BD=1.5*1024*1024*1024,VD=2.5*1024*1024*1024;function HD(){let[e,t]=(0,Q.useState)(null);return se(()=>{let e=process.memoryUsage().heapUsed,n=e>=VD?`critical`:e>=BD?`high`:`normal`;t(t=>n===`normal`?t===null?t:null:{heapUsed:e,status:n})},1e4),e}H(),Pi();function UD(){if(process.env.USER_TYPE!==`ant`)return null;let e=HD();if(!e)return null;let{heapUsed:t,status:n}=e;if(n===`normal`)return null;let r=ji(t);return(0,$.jsx)(U,{children:(0,$.jsxs)(R,{color:n===`critical`?`error`:`warning`,wrap:`truncate`,children:[`High memory usage (`,r,`) · /heapdump`]})})}function WD(){return(0,Q.useSyncExternalStore)(Lm.subscribe,Lm.getState)}H(),an(),md();function GD({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=zf(e,t),a=WD();if(!r||a)return null;let o=vm(),s=Yf(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(U,{flexDirection:`row`,children:o?(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(R,{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(),so();function KD(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=fc(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Bs.isSandboxingEnabled())return;let e=Bs.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)}},[]),!Bs.isSandboxingEnabled()||e===0?null:(0,$.jsx)(U,{paddingX:0,paddingY:0,children:(0,$.jsxs)(R,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}var qD=r({VoiceIndicator:()=>JD,VoiceWarmupHint:()=>XD});function JD(e){return(0,QD.jsx)(YD,{...e})}function YD({voiceState:e}){switch(e){case`recording`:return(0,QD.jsx)(R,{dimColor:!0,children:`listening…`});case`processing`:return(0,QD.jsx)(ZD,{});case`idle`:return null}}function XD(){return(0,QD.jsx)(R,{dimColor:!0,children:`keep holding…`})}function ZD(){let e=Eh().prefersReducedMotion??!1,[t,n]=E(e?null:50);if(e)return(0,QD.jsx)(R,{color:`warning`,children:`Voice: processing…`});let r=n/1e3;return(0,QD.jsx)(U,{ref:t,children:(0,QD.jsx)(R,{color:Jf(sp($D,eO,(Math.sin(r*Math.PI*2/tO)+1)/2)),children:`Voice: processing…`})})}var QD,$D,eO,tO,nO=t((()=>{L(),wm(),H(),QD=je(),$D={r:153,g:153,b:153},eO={r:185,g:185,b:185},tO=2}));Rm(),Cr(),X(),H(),rh(),jb(),Pi(),ma(),ql(),Ia();var rO=(nO(),e(qD)).VoiceIndicator,iO=5e3;function aO({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)(()=>y_(jc(a)),[a]),p=Lb(),m=zf(f,p).isAboveWarningThreshold,{status:h}=FD(l),g=Z(e=>e.notifications),{addNotification:_,removeNotification:v}=Bh(),y=Ud();(0,Q.useEffect)(()=>(Cg((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Cg(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=Qn(),S=x===`team`||x===`enterprise`,C=Mb(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(Y(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(Ja,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${w_(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(_y,{children:(0,$.jsx)(U,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(oO,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})})}function oO({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:a,debug:o,verbose:s,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!mn())return;let e=setInterval(e=>{let t=Gt(),n=t>=1e4?Ai(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]);let p=Tl(e=>e.voiceState),m=ID(),h=Tl(e=>e.voiceError),g=Z(e=>e.isBriefOnly);return m&&(p===`recording`||p===`processing`)?(0,$.jsx)(rO,{voiceState:p}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zD,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(R,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(R,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(U,{children:[(0,$.jsxs)(R,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(R,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(a===`invalid`||a===`missing`)&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`error`,wrap:`truncate`,children:c(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in · Run /login`})}),o&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),a!==`invalid`&&a!==`missing`&&s&&(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),!g&&(0,$.jsx)(GD,{tokenUsage:l,model:u}),m&&h&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{color:`error`,wrap:`truncate`,children:h})}),(0,$.jsx)(UD,{}),(0,$.jsx)(KD,{})]})}Rm(),Ia(),H();var sO=10,cO=null,lO=0,uO;async function dO(e,t){let n=Math.ceil(e/sO)*sO;if(cO&&lO>=n&&uO===t)return cO;cO&&await cO,lO=n,uO=t,cO=(async()=>{let e=[],n=0;for await(let r of pu())if(!(t&&Rc(r.display)!==t)&&(e.push(r),n++,n>=lO))break;return e})();try{return await cO}finally{cO=null,lO=0,uO=void 0}}function fO(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}=Bh(),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=Rc(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)(R,{dimColor:!0,children:(0,$.jsx)(Ja,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:iO})},[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 dO(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])}}X();function pO(){let e=Z(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Bp).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])}gf(),Cs(),H(),ty();function mO(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=mh(),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(Rc(i)),n(i),l(e.value.pastedContents);let t=Ji(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=mh(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),N=(0,Q.useCallback)(()=>{if(C){let e=Rc(C.display);n(Ji(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),P=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),ee=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=Rc(C.display),n=Ji(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);we(`history:search`,j,{context:`Global`,isActive:!s}),V((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":N,"historySearch:cancel":P,"historySearch:execute":ee}),[M,N,P,ee]),{context:`HistorySearch`,isActive:s});let F=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),P())};Oe((e,t,n)=>{F(new Ae(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 hO({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(),Cr(),X();function gO({inputValue:e,isAssistantResponding:t}){let n=Z(e=>e.promptSuggestion),r=Af(),i=le(),{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)(()=>{Ic(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])}}Zo(),q(),zc();var _O=15,vO=1e3,yO=[`|`,`||`,`&&`,`;`];function bO(e){return typeof e==`object`&&!!e&&`op`in e&&yO.includes(e.op)}function xO(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function SO(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function CO(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&bO(n)}function wO(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=ev(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:xO(t)}}let a=SO(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&bO(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=xO(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=CO(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function TO(e,t){return t===`variable`?`compgen -v ${tv([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${tv([e])} 2>/dev/null | head -${_O} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${tv([e])} 2>/dev/null`}function EO(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${tv([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${tv([e])}*(N[1,${_O}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${tv([e])}*]} 2>/dev/null`}async function DO(e,t,n,r){let i;if(e===`bash`)i=TO(t,n);else if(e===`zsh`)i=EO(t,n);else return[];return(await(await Lf(i,r,`bash`,{timeout:vO})).result).stdout.split(`
42
+ `).filter(e=>e.trim()).slice(0,_O).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function OO(e,t,n){let r=nd();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=wO(e,t);return i?(await DO(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return J(`Shell completion failed: ${e}`),[]}}eS(),Dm();var kO=/[:_-]/g,AO=null;function jO(e){if(AO?.commands===e)return AO.fuse;let t=new tS(e.filter(e=>!e.isHidden).map(e=>{let t=lp(e),n=t.split(kO).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>UO(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 AO={commands:e,fuse:t},t}function MO(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function NO(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 PO(e,t){if(!e)return null;let n=VO(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!MO(t.metadata))continue;let n=lp(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function FO(e){return e.startsWith(`/`)}function IO(e){return!(!FO(e)||!e.includes(` `)||e.endsWith(` `))}function LO(e){return`/${e} `}function RO(e){let t=lp(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function zO(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function BO(e,t){let n=lp(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:ps(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:RO(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function VO(e,t){if(!FO(e)||IO(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:Gf(lp(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=>RO(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(RO(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)=>lp(e).localeCompare(lp(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=>BO(e))}let r=t.find(e=>e.isHidden&&lp(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&lp(e).toLowerCase()===n)&&(r=void 0);let i=jO(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`?Gf(lp(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 BO(t,zO(n,t.aliases))});if(r){let e=RO(r);if(!i.some(t=>t.id===e))return[BO(r),...i]}return i}function HO(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Nu(o,n):void 0;else{if(!MO(e.metadata))return;o=lp(e.metadata),s=e.metadata}let c=LO(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function UO(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function WO(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}Tb(),Cs(),q();var GO=null,KO=0,qO=6e4;async function JO(){let e=Date.now();if(GO&&e-KO<qO)return GO;let t=[],n=new Set;try{for await(let e of pu()){if(e.display&&e.display.startsWith(`!`)){let r=e.display.slice(1).trim();r&&!n.has(r)&&(n.add(r),t.push(r))}if(t.length>=50)break}}catch(e){J(`Failed to read shell history: ${e}`)}return GO=t,KO=e,t}function YO(e){if(!GO)return;let t=GO.indexOf(e);t!==-1&&GO.splice(t,1),GO.unshift(e)}async function XO(e){if(!e||e.length<2||!e.trim())return null;let t=await JO();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}q(),Ii(),Le(),fr();var ZO=`slack_search_channels`,QO=new Map,$O=new Set,ek=0,tk=Ke(),nk=tk.subscribe,rk=null,ik=null;function ak(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function ok(e,t){let n=ak(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:ZO,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?lk(ck(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
43
43
  `))):[]}catch(e){return J(`Failed to fetch Slack channels: ${e}`),[]}}var sk=Fi(()=>b({results:_()}));function ck(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=sk().safeParse(G(t));if(e.success)return e.data.results}catch{}return e}function lk(e){let t=[],n=new Set;for(let r of e.split(`
44
- `)){let e=r.match(/^Name:\s*#?([a-z0-9][a-z0-9_-]{0,79})\s*$/);e&&!n.has(e[1])&&(n.add(e[1]),t.push(e[1]))}return t}function uk(e){return ak(e)!==void 0}function dk(){return ek}function fk(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!$O.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function pk(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function mk(e,t){let n,r=0;for(let[i,a]of QO)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function hk(e,t){if(!t)return[];let n=pk(t),r=t.toLowerCase(),i=QO.get(n)??mk(n,r);if(!i)if(rk===n&&ik)i=await ik;else{rk=n,ik=ok(e,n),i=await ik,QO.set(n,i);let t=$O.size;for(let e of i)$O.add(e);$O.size!==t&&(ek++,tk.emit()),QO.size>50&&QO.delete(QO.keys().next().value),rk===n&&(rk=null,ik=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}eS(),tx(),Pi(),Zr();function gk(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 _k=15,vk=60;function yk(e){return Oi(e,vk)}function bk(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:yk(e.whenToUse),agentType:e.agentType,color:za(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 Qr(e),[]}}async function xk(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Qb(e,r),Promise.resolve(bk(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:kS(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:yk(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,_k).map(gk);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 tS(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:_k});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,_k).map(e=>e.source).map(gk)}Fm(),H(),Cr(),O(),wm(),ff(),zh(),ty(),Ra(),X(),Yn(),Pi(),ho(),tx();var Sk=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,Ck=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,wk=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,Tk=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,Ek=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,Dk=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function Ok(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function kk(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 Ak(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function jk(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Mk(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 Nk(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 Pk=/(^|\s)@[\w-]*$/;function Fk(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 Ik=null;async function Lk(e,t){try{return Ik&&Ik.abort(),Ik=new AbortController,await OO(e,t,Ik.signal)}catch{return Y(`tengu_shell_completion_failed`,{}),[]}}function Rk(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 zk(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(Sk);if(a&&a[0].length===i.length){let r=e.substring(t).match(Ck),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?wk:Tk,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(Ck),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Bk(e){if(FO(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 Vk(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function Hk({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}=Lh(),g=bc(`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=cp(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=Z(e=>e.mcp.resources),C=Zd(),w=Z(e=>e.promptSuggestion),T=Z(e=>!!e.viewingAgentTaskId),E=pe(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=NO(i,a);if(!t)return;let n=PO(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),N=(0,Q.useRef)(``),P=(0,Q.useRef)(``),ee=(0,Q.useRef)(``),F=(0,Q.useRef)(``),te=(0,Q.useRef)(l);te.current=l;let ne=(0,Q.useRef)(null),I=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),re=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await xk(e,S,s,t);if(M.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>($b(),rx(()=>{let e=M.current;e!==null&&(M.current=null,re(e,e===``))})),[re]);let L=De(re,50),ie=De((0,Q.useCallback)(async e=>{F.current=e;let t=await hk(C.getState().mcp.clients,e);F.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:kk(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){L.cancel(),I();return}if(o===`prompt`){let n=NO(t,r);if(n&&PO(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){ee.current=t;let e=await XO(t);if(ee.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(Nn()&&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){L.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(Dk);if(e&&uk(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),I())}let a=t.substring(0,r).match(Ek),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&FO(t)&&r>0){let e=Bk(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){L.cancel(),I();return}let n=await Eb(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}L.cancel(),I();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await wc(t,{limit:10})).map(e=>{let t=Jp(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Ni(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}I();return}}let l=t.substring(0,r);if(o===`prompt`&&FO(l)&&r>0&&!Vk(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=cp(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=zs(l.slice(n+1));t=fo(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=VO(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`?(L.cancel(),I()):FO(l)&&Vk(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&I(),_===`agent`&&te.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||I()),a&&o!==`bash`){let e=zk(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=jk(e);if(Cb(t)){P.current=t;let e=await wb(t,{maxResults:10});if(P.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:kk(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;L(t,!0);return}}if(_===`file`){let e=zk(t,r,!0);if(e){let t=jk(e);if(M.current===t)return;L(t,!1)}else L.cancel(),I()}if(_===`shell`){let e=te.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(L.cancel(),I())}},[_,e,c,I,L,ie,o,f,y]);(0,Q.useEffect)(()=>{ne.current!==i&&(N.current!==i&&(N.current=i,M.current=null),ne.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=NO(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){L.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=`/${cp(e)} `;t(n+i.slice(a)),r(n.length)}I()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Ak(n);t(e),r(e.length),I()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=FO(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=Ok(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),Ok(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):I()}else{let e=zk(i,a,!0)??zk(i,a,!1);if(e){let a=Ok(n.metadata)&&n.metadata.type===`directory`,s=Rk(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)):I()}else I()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Nk(n,i,a,t,r,e?.completionType),I()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Fk(n,i,a,Pk,t,r),I())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(Fk(n,i,a,Dk,t,r),I())}else if(_===`file`&&l.length>0){let n=zk(i,a,!0);if(!n){I();return}let s=ex(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=Mk({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});nx(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(` `);nx(Mk({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),I()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Lk(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Nk(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=zk(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await xk(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,I,a,ae,S,c,s,L,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(HO(s,!0,e,t,r,n),L.cancel(),I());else if(_===`custom-title`&&u<l.length){if(s){let e=Ak(s);t(e),r(e.length),n(e,!0),L.cancel(),I()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Nk(e,i,a,t,r,n?.completionType),L.cancel(),I()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Fk(s,i,a,Pk,t,r),L.cancel(),I();else if(_===`slack-channel`&&u<l.length)s&&(Fk(s,i,a,Dk,t,r),ie.cancel(),I());else if(_===`file`&&u<l.length){let e=zk(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);nx(Mk({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),L.cancel(),I()}}else if(_===`directory`&&u<l.length&&s){if(FO(i)){L.cancel(),I();return}let e=zk(i,a,!0)??zk(i,a,!1);if(e){let n=Ok(s.metadata)&&s.metadata.type===`directory`,a=Rk(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}L.cancel(),I()}},[l,u,_,e,i,a,o,t,r,n,I,L,ie]),ce=(0,Q.useCallback)(()=>{oe()},[oe]),le=(0,Q.useCallback)(()=>{L.cancel(),ie.cancel(),I(),ne.current=i},[L,ie,I,i]),ue=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":ce,"autocomplete:dismiss":le,"autocomplete:previous":ue,"autocomplete:next":de}),[ce,le,ue,de]),me=l.length>0||!!A,z=Hd();fg(`autocomplete`,me),be(`Autocomplete`,me),V(fe,{context:`Autocomplete`,isActive:me&&!z});function B(e){let n=Wc(e);if(n!==`prompt`&&m){m(n);let i=Ji(e);t(i),r(i.length)}else t(e),r(e.length)}let he=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),B(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(),B(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(R,{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 Oe((e,t,n)=>{let r=new Ae(n.keypress);he(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:he}}rS();function Uk(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 Wk(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}}fx();var Gk={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function Kk(e){return e in Gk}Ng();function qk(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 Jk(e,t){let n=qk(e,t);return{nextMode:n,context:ao(e.mode,n,e)}}wy(),uo(),pb();var Yk=Oy();ot(),nu(),en(),zh(),H(),ty(),X(),lr();function Xk({onDone:e}){fg(`bridge-dialog`);let t=Z(e=>e.replBridgeConnected),n=Z(e=>e.replBridgeSessionActive),r=Z(e=>e.replBridgeReconnecting),i=Z(e=>e.replBridgeConnectUrl),a=Z(e=>e.replBridgeSessionUrl),o=Z(e=>e.replBridgeError),s=Z(e=>e.replBridgeExplicit),c=Z(e=>e.replBridgeEnvironmentId),l=Z(e=>e.replBridgeSessionId),u=Z(e=>e.verbose),d=kf(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=kS(ft());(0,Q.useEffect)(()=>{jr().then(_).catch(()=>{})},[]);let y=n?a:i;(0,Q.useEffect)(()=>{if(!f||!y){h(``);return}(0,Yk.toString)(y,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,y]),V({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),Oe(t=>{t===`d`&&(s&&kt(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:b,color:x}=_a({error:o,connected:t,sessionActive:n,reconnecting:r}),S=o?`×`:Jt,C=m?m.split(`
45
- `).filter(e=>e.length>0):[],w=[];v&&w.push(v),g&&w.push(g);let T=w.length>0?` · `+w.join(` · `):``,E=o?Nc:y?n?Yo(y):v_(y):void 0;return(0,$.jsx)(B,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{color:x,children:[S,` `,b]}),(0,$.jsx)(R,{dimColor:!0,children:T})]}),o&&(0,$.jsx)(R,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(R,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(R,{dimColor:!0,children:[`Session: `,l]})]}),f&&C.length>0&&(0,$.jsx)(U,{flexDirection:`column`,children:C.map((e,t)=>(0,$.jsx)(R,{children:e},t))}),E&&(0,$.jsx)(R,{dimColor:!0,children:E}),(0,$.jsx)(R,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}f(),en(),ny(),H(),X(),nc(),Pi(),cS();function Zk(e){return Object.values(e).filter(e=>zc(e)&&e.evictAfter!==0).sort((e,t)=>e.startTime-t.startTime)}function Qk(){let e=Z(e=>e.tasks),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.agentNameRegistry),r=Z(e=>e.coordinatorTaskIndex),i=Z(e=>e.footerSelection===`tasks`)?r:void 0,a=kf(),o=Zk(e),s=Object.values(e).some(zc),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))zc(n)&&(n.evictAfter??1/0)<=r&&cs(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)(eA,{isSelected:i===0,isViewed:t===void 0,onClick:()=>lS(a)}),o.map((e,n)=>(0,$.jsx)(tA,{task:e,name:u.get(e.id),isSelected:i===n+1,isViewed:t===e.id,onClick:()=>sS(e.id,a)},e.id))]})}function $k(){let e=Z(e=>e.tasks);return Q.useMemo(()=>{if(process.env.USER_TYPE!==`ant`)return 0;let t=Zk(e).length;return t>0?t+1:0},[e])}function eA({isSelected:e,isViewed:t,onClick:n}){let[r,i]=Q.useState(!1),a=e||r?p.pointer+` `:` `,o=t?Fn:p.circle;return(0,$.jsx)(U,{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:(0,$.jsxs)(R,{dimColor:!e&&!t&&!r,bold:t,children:[a,o,` main`]})})}function tA({task:e,name:t,isSelected:n,isViewed:r,onClick:i}){let{columns:a}=k(),[o,s]=Q.useState(!1),c=!iS(e.status),l=e.totalPausedMs??0,u=Ai(Math.max(0,c?Date.now()-e.startTime-l:(e.endTime??e.startTime)-e.startTime-l)),d=e.progress?.tokenCount,f=e.progress?.lastActivity?p.arrowDown:p.arrowUp,m=d!==void 0&&d>0?` · ${f} ${Mi(d)} tokens`:``,h=e.pendingMessages.length,g=h>0?` · ${h} queued`:``,_=e.progress?.summary||e.description,v=n||o,y=v?p.pointer+` `:` `,b=r?Fn:p.circle,x=!v&&!r,S=c?`▶`:`⏸`,C=t?`${t}: `:``,w=n&&!r?` · x to ${c?`stop`:`clear`}`:``,T=` ${S} ${u}${m}${g}${w}`,E=a-D(y)-D(`${b} `)-D(C)-D(T),O=ge(_,Math.max(0,E),`truncate-end`),A=(0,$.jsxs)(R,{dimColor:x,bold:r,children:[y,b,` `,t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!1,bold:!0,children:t}),`: `]}),O,` `,S,` `,u,m,h>0&&(0,$.jsx)(R,{color:`warning`,children:g}),w&&(0,$.jsx)(R,{dimColor:!0,children:w})]});return i?(0,$.jsx)(U,{onClick:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:A}):A}dx(),H(),zh(),ny(),H(),wr(),jb(),Pi(),Ho(),zh(),ws(),ny(),H(),Pi(),sx(),zh(),tx(),ny(),H(),wr(),jb(),Pi(),jd(),H(),ty(),Fa(),wa();function nA({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ly(),[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`}];we(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),we(`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)(xe,{color:`permission`,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(R,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(R,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(U,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(Sd,{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)(R,{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)(R,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(R,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}oS(),f(),O(),zh(),H(),ty(),Ra(),X(),xc(),q(),Pi(),sn(),fr(),py(),Lv(),Fy(),zg();function rA({initialTeams:e,onDone:t}){fg(`teams-dialog`);let n=kf(),[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)(()=>Iy(r.teamName),[r.teamName,s]);se(()=>{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=Z(e=>e.toolPermissionContext.isBypassPermissionsModeAvailable),f=()=>{i({type:`teammateList`,teamName:r.teamName}),o(0)};V({"confirm:cycleMode":(0,Q.useCallback)(()=>{r.type===`teammateDetail`&&u?(pA(u,r.teamName,d),c(e=>e+1)):r.type===`teammateList`&&l.length>0&&(mA(l,r.teamName,d),c(e=>e+1))},[r,u,l,d])},{context:`Confirmation`}),Oe((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&&(cA(u.tmuxPaneId,u.backendType&&Jv(u.backendType)?u.backendType:void 0),t());return}if(e===`k`){r.type===`teammateList`&&l[a]?sA(l[a].tmuxPaneId,l[a].backendType&&Jv(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&&(sA(u.tmuxPaneId,u.backendType&&Jv(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];Cc(e.name,r.teamName,`Graceful shutdown requested by team lead`)}else r.type===`teammateDetail`&&u&&(Cc(u.name,r.teamName,`Graceful shutdown requested by team lead`),f());return}if(e===`h`){let e=sa(),t=r.type===`teammateList`?l[a]:r.type===`teammateDetail`?u:null;t&&e?.supportsHideShow&&(lA(t,r.teamName).then(()=>{c(e=>e+1)}),r.type===`teammateDetail`&&f());return}if(e===`H`&&r.type===`teammateList`){if(sa()?.supportsHideShow&&l.length>0){let e=l.some(e=>!e.isHidden);Promise.all(l.map(t=>e?uA(t,r.teamName):dA(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=>sA(e.tmuxPaneId,e.backendType&&Jv(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)(iA,{teamName:r.teamName,teammates:l,selectedIndex:a,onCancel:t}):r.type===`teammateDetail`&&u?(0,$.jsx)(oA,{teammate:u,teamName:r.teamName,onCancel:f}):null}function iA({teamName:e,teammates:t,selectedIndex:n,onCancel:r}){let i=`${t.length} ${t.length===1?`teammate`:`teammates`}`,a=sa()?.supportsHideShow??!1,o=bc(`confirm:cycleMode`,`Confirmation`,`shift+tab`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{title:`Team ${e}`,subtitle:i,onCancel:r,color:`background`,hideInputGuide:!0,children:t.length===0?(0,$.jsx)(R,{dimColor:!0,children:`No teammates`}):(0,$.jsx)(U,{flexDirection:`column`,children:t.map((e,t)=>(0,$.jsx)(aA,{teammate:e,isSelected:t===n},e.agentId))})}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowUp,`/`,p.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 aA({teammate:e,isSelected:t}){let n=e.status===`idle`,r=n&&!t,i=e.mode?un(e.mode):`default`,a=Zt(i),o=sr(i);return(0,$.jsxs)(R,{color:t?`suggestion`:void 0,dimColor:r,children:[t?p.pointer+` `:` `,e.isHidden&&(0,$.jsx)(R,{dimColor:!0,children:`[hidden] `}),n&&(0,$.jsx)(R,{dimColor:!0,children:`[idle] `}),a&&(0,$.jsxs)(R,{color:o,children:[a,` `]}),`@`,e.name,e.model&&(0,$.jsxs)(R,{dimColor:!0,children:[` (`,e.model,`)`]})]})}function oA({teammate:e,teamName:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),a=bc(`confirm:cycleMode`,`Confirmation`,`shift+tab`),o=e.color?Qa[e.color]:void 0,[s,c]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let n=!1;return Nv(t).then(t=>{n||c(t.filter(t=>t.owner===e.agentId||t.owner===e.name))}),()=>{n=!0}},[t,e.agentId,e.name]),Oe(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?un(e.mode):`default`,m=Zt(f),h=sr(f);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{title:(0,$.jsxs)($.Fragment,{children:[m&&(0,$.jsxs)(R,{color:h,children:[m,` `]}),o?(0,$.jsx)(R,{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)(R,{bold:!0,children:`Tasks`}),s.map(e=>(0,$.jsxs)(R,{color:e.status===`completed`?`success`:void 0,children:[e.status===`completed`?p.tick:`◼`,` `,e.subject]},e.id))]}),e.prompt&&(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{bold:!0,children:`Prompt`}),(0,$.jsxs)(R,{children:[r?e.prompt:Oi(e.prompt,80),D(e.prompt)>80&&!r&&(0,$.jsx)(R,{dimColor:!0,children:` (p to expand)`})]})]})]}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowLeft,` back · Esc close · k kill · s shutdown`,sa()?.supportsHideShow&&` · h hide/show`,` · `,a,` cycle mode`]})})]})}async function sA(e,t,n,r,i,a){if(t)try{await Sc(),await Up(t).killPane(e,!Ty())}catch(t){J(`[TeamsDialog] Failed to kill pane ${e}: ${t}`)}else J(`[TeamsDialog] Skipping pane kill for ${e}: no backendType recorded`);qv(n,e);let{notificationMessage:o}=await Rv(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:zS(),from:`system`,text:hr({type:`teammate_terminated`,message:o}),timestamp:new Date().toISOString(),status:`pending`}]}}}),J(`[TeamsDialog] Removed ${r} from teamContext`)}async function cA(e,t){t===`iterm2`?await ci(`it2`,[`session`,`focus`,`-s`,e]):t===`windows-terminal`?J(`[TeamsDialog] viewTeammateOutput: Windows Terminal pane ${e} — manual tab switch required`):await ci(my,Ty()?[`select-pane`,`-t`,e]:[`-L`,hy(),`select-pane`,`-t`,e])}async function lA(e,t){e.isHidden?await dA(e,t):await uA(e,t)}async function uA(e,t){}async function dA(e,t){}function fA(e,t,n){Wv(t,e,n),Wp(e,{from:`team-lead`,text:hr(th({mode:n,from:`team-lead`})),timestamp:new Date().toISOString()},t),J(`[TeamsDialog] Sent mode change to ${e}: ${n}`)}function pA(e,t,n){let r=e.mode?un(e.mode):`default`,i=qk({...V_(),mode:r,isBypassPermissionsModeAvailable:n});fA(e.name,t,i)}function mA(e,t,n){if(e.length===0)return;let r=e.map(e=>e.mode?un(e.mode):`default`),i=r.every(e=>e===r[0])?qk({...V_(),mode:r[0]??`default`,isBypassPermissionsModeAvailable:n}):`default`;Uv(t,e.map(e=>({memberName:e.name,mode:i})));for(let n of e){let e=th({mode:i,from:`team-lead`});Wp(n.name,{from:`team-lead`,text:hr(e),timestamp:new Date().toISOString()},t)}J(`[TeamsDialog] Sent mode change to all ${e.length} teammates: ${i}`)}function hA(e,t,n){let r=t;for(let t=0;t<n;t++){let t=gA(e,r);if(t.equals(r))break;r=t}return r}function gA(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 _A(e){return`eE$`.includes(e)}function vA(e){return`jkG`.includes(e)||e===`gg`}var yA={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function bA(e,t,n,r){if(n===`w`)return xA(e,t,r,sc);if(n===`W`)return xA(e,t,r,e=>!Js(e));let i=yA[n];if(i){let[n,a]=i;return n===a?SA(e,t,n,r):CA(e,t,n,a,r)}return null}function xA(e,t,n,r){let i=[];for(let{segment:t,index:n}of Ti().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=>Js(o(e)),l=e=>r(o(e)),u=e=>kp(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 SA(e,t,n,r){let i=e.lastIndexOf(`
44
+ `)){let e=r.match(/^Name:\s*#?([a-z0-9][a-z0-9_-]{0,79})\s*$/);e&&!n.has(e[1])&&(n.add(e[1]),t.push(e[1]))}return t}function uk(e){return ak(e)!==void 0}function dk(){return ek}function fk(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!$O.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function pk(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function mk(e,t){let n,r=0;for(let[i,a]of QO)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function hk(e,t){if(!t)return[];let n=pk(t),r=t.toLowerCase(),i=QO.get(n)??mk(n,r);if(!i)if(rk===n&&ik)i=await ik;else{rk=n,ik=ok(e,n),i=await ik,QO.set(n,i);let t=$O.size;for(let e of i)$O.add(e);$O.size!==t&&(ek++,tk.emit()),QO.size>50&&QO.delete(QO.keys().next().value),rk===n&&(rk=null,ik=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}eS(),tx(),Pi(),Zr();function gk(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 _k=15,vk=60;function yk(e){return Oi(e,vk)}function bk(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:yk(e.whenToUse),agentType:e.agentType,color:Dl(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 Qr(e),[]}}async function xk(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Qb(e,r),Promise.resolve(bk(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:kS(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:yk(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,_k).map(gk);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 tS(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:_k});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,_k).map(e=>e.source).map(gk)}Rm(),H(),Cr(),O(),Dm(),gf(),Hh(),ty(),za(),X(),Yn(),Pi(),go(),tx();var Sk=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,Ck=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,wk=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,Tk=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,Ek=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,Dk=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function Ok(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function kk(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 Ak(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function jk(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Mk(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 Nk(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 Pk=/(^|\s)@[\w-]*$/;function Fk(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 Ik=null;async function Lk(e,t){try{return Ik&&Ik.abort(),Ik=new AbortController,await OO(e,t,Ik.signal)}catch{return Y(`tengu_shell_completion_failed`,{}),[]}}function Rk(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 zk(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(Sk);if(a&&a[0].length===i.length){let r=e.substring(t).match(Ck),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?wk:Tk,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(Ck),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Bk(e){if(FO(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 Vk(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function Hk({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}=Bh(),g=fc(`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=lp(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=Z(e=>e.mcp.resources),C=ef(),w=Z(e=>e.promptSuggestion),T=Z(e=>!!e.viewingAgentTaskId),E=pe(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=NO(i,a);if(!t)return;let n=PO(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),N=(0,Q.useRef)(``),P=(0,Q.useRef)(``),ee=(0,Q.useRef)(``),F=(0,Q.useRef)(``),te=(0,Q.useRef)(l);te.current=l;let ne=(0,Q.useRef)(null),I=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),re=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await xk(e,S,s,t);if(M.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>($b(),rx(()=>{let e=M.current;e!==null&&(M.current=null,re(e,e===``))})),[re]);let L=De(re,50),ie=De((0,Q.useCallback)(async e=>{F.current=e;let t=await hk(C.getState().mcp.clients,e);F.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:kk(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){L.cancel(),I();return}if(o===`prompt`){let n=NO(t,r);if(n&&PO(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){ee.current=t;let e=await XO(t);if(ee.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(Nn()&&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){L.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(Dk);if(e&&uk(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),I())}let a=t.substring(0,r).match(Ek),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&FO(t)&&r>0){let e=Bk(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){L.cancel(),I();return}let n=await Eb(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}L.cancel(),I();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await gc(t,{limit:10})).map(e=>{let t=Qp(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Ni(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}I();return}}let l=t.substring(0,r);if(o===`prompt`&&FO(l)&&r>0&&!Vk(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=lp(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=Is(l.slice(n+1));t=po(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=VO(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`?(L.cancel(),I()):FO(l)&&Vk(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&I(),_===`agent`&&te.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||I()),a&&o!==`bash`){let e=zk(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=jk(e);if(Cb(t)){P.current=t;let e=await wb(t,{maxResults:10});if(P.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:kk(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;L(t,!0);return}}if(_===`file`){let e=zk(t,r,!0);if(e){let t=jk(e);if(M.current===t)return;L(t,!1)}else L.cancel(),I()}if(_===`shell`){let e=te.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(L.cancel(),I())}},[_,e,c,I,L,ie,o,f,y]);(0,Q.useEffect)(()=>{ne.current!==i&&(N.current!==i&&(N.current=i,M.current=null),ne.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=NO(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){L.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=`/${lp(e)} `;t(n+i.slice(a)),r(n.length)}I()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Ak(n);t(e),r(e.length),I()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=FO(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=Ok(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),Ok(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):I()}else{let e=zk(i,a,!0)??zk(i,a,!1);if(e){let a=Ok(n.metadata)&&n.metadata.type===`directory`,s=Rk(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)):I()}else I()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Nk(n,i,a,t,r,e?.completionType),I()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Fk(n,i,a,Pk,t,r),I())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(Fk(n,i,a,Dk,t,r),I())}else if(_===`file`&&l.length>0){let n=zk(i,a,!0);if(!n){I();return}let s=ex(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=Mk({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});nx(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(` `);nx(Mk({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),I()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Lk(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Nk(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=zk(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await xk(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:kk(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,I,a,ae,S,c,s,L,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(HO(s,!0,e,t,r,n),L.cancel(),I());else if(_===`custom-title`&&u<l.length){if(s){let e=Ak(s);t(e),r(e.length),n(e,!0),L.cancel(),I()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Nk(e,i,a,t,r,n?.completionType),L.cancel(),I()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Fk(s,i,a,Pk,t,r),L.cancel(),I();else if(_===`slack-channel`&&u<l.length)s&&(Fk(s,i,a,Dk,t,r),ie.cancel(),I());else if(_===`file`&&u<l.length){let e=zk(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);nx(Mk({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),L.cancel(),I()}}else if(_===`directory`&&u<l.length&&s){if(FO(i)){L.cancel(),I();return}let e=zk(i,a,!0)??zk(i,a,!1);if(e){let n=Ok(s.metadata)&&s.metadata.type===`directory`,a=Rk(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}L.cancel(),I()}},[l,u,_,e,i,a,o,t,r,n,I,L,ie]),ce=(0,Q.useCallback)(()=>{oe()},[oe]),le=(0,Q.useCallback)(()=>{L.cancel(),ie.cancel(),I(),ne.current=i},[L,ie,I,i]),ue=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":ce,"autocomplete:dismiss":le,"autocomplete:previous":ue,"autocomplete:next":de}),[ce,le,ue,de]),me=l.length>0||!!A,z=Hd();mg(`autocomplete`,me),be(`Autocomplete`,me),V(fe,{context:`Autocomplete`,isActive:me&&!z});function B(e){let n=Rc(e);if(n!==`prompt`&&m){m(n);let i=Ji(e);t(i),r(i.length)}else t(e),r(e.length)}let he=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),B(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(),B(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(R,{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 Oe((e,t,n)=>{let r=new Ae(n.keypress);he(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:he}}rS();function Uk(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 Wk(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}}fx();var Gk={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function Kk(e){return e in Gk}Pg();function qk(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 Jk(e,t){let n=qk(e,t);return{nextMode:n,context:oo(e.mode,n,e)}}wy(),nc(),pb();var Yk=Oy();ot(),__(),en(),Hh(),H(),ty(),X(),lr();function Xk({onDone:e}){mg(`bridge-dialog`);let t=Z(e=>e.replBridgeConnected),n=Z(e=>e.replBridgeSessionActive),r=Z(e=>e.replBridgeReconnecting),i=Z(e=>e.replBridgeConnectUrl),a=Z(e=>e.replBridgeSessionUrl),o=Z(e=>e.replBridgeError),s=Z(e=>e.replBridgeExplicit),c=Z(e=>e.replBridgeEnvironmentId),l=Z(e=>e.replBridgeSessionId),u=Z(e=>e.verbose),d=Af(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=kS(ft());(0,Q.useEffect)(()=>{jr().then(_).catch(()=>{})},[]);let y=n?a:i;(0,Q.useEffect)(()=>{if(!f||!y){h(``);return}(0,Yk.toString)(y,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,y]),V({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),Oe(t=>{t===`d`&&(s&&kt(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:b,color:x}=rl({error:o,connected:t,sessionActive:n,reconnecting:r}),S=o?`×`:Jt,C=m?m.split(`
45
+ `).filter(e=>e.length>0):[],w=[];v&&w.push(v),g&&w.push(g);let T=w.length>0?` · `+w.join(` · `):``,E=o?Gs:y?n?Tc(y):Ps(y):void 0;return(0,$.jsx)(B,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(U,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(R,{children:[(0,$.jsxs)(R,{color:x,children:[S,` `,b]}),(0,$.jsx)(R,{dimColor:!0,children:T})]}),o&&(0,$.jsx)(R,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(R,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(R,{dimColor:!0,children:[`Session: `,l]})]}),f&&C.length>0&&(0,$.jsx)(U,{flexDirection:`column`,children:C.map((e,t)=>(0,$.jsx)(R,{children:e},t))}),E&&(0,$.jsx)(R,{dimColor:!0,children:E}),(0,$.jsx)(R,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}f(),en(),ny(),H(),X(),fa(),Pi(),cS();function Zk(e){return Object.values(e).filter(e=>Zs(e)&&e.evictAfter!==0).sort((e,t)=>e.startTime-t.startTime)}function Qk(){let e=Z(e=>e.tasks),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.agentNameRegistry),r=Z(e=>e.coordinatorTaskIndex),i=Z(e=>e.footerSelection===`tasks`)?r:void 0,a=Af(),o=Zk(e),s=Object.values(e).some(Zs),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))Zs(n)&&(n.evictAfter??1/0)<=r&&os(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)(eA,{isSelected:i===0,isViewed:t===void 0,onClick:()=>lS(a)}),o.map((e,n)=>(0,$.jsx)(tA,{task:e,name:u.get(e.id),isSelected:i===n+1,isViewed:t===e.id,onClick:()=>sS(e.id,a)},e.id))]})}function $k(){let e=Z(e=>e.tasks);return Q.useMemo(()=>{if(process.env.USER_TYPE!==`ant`)return 0;let t=Zk(e).length;return t>0?t+1:0},[e])}function eA({isSelected:e,isViewed:t,onClick:n}){let[r,i]=Q.useState(!1),a=e||r?p.pointer+` `:` `,o=t?Fn:p.circle;return(0,$.jsx)(U,{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:(0,$.jsxs)(R,{dimColor:!e&&!t&&!r,bold:t,children:[a,o,` main`]})})}function tA({task:e,name:t,isSelected:n,isViewed:r,onClick:i}){let{columns:a}=k(),[o,s]=Q.useState(!1),c=!iS(e.status),l=e.totalPausedMs??0,u=Ai(Math.max(0,c?Date.now()-e.startTime-l:(e.endTime??e.startTime)-e.startTime-l)),d=e.progress?.tokenCount,f=e.progress?.lastActivity?p.arrowDown:p.arrowUp,m=d!==void 0&&d>0?` · ${f} ${Mi(d)} tokens`:``,h=e.pendingMessages.length,g=h>0?` · ${h} queued`:``,_=e.progress?.summary||e.description,v=n||o,y=v?p.pointer+` `:` `,b=r?Fn:p.circle,x=!v&&!r,S=c?`▶`:`⏸`,C=t?`${t}: `:``,w=n&&!r?` · x to ${c?`stop`:`clear`}`:``,T=` ${S} ${u}${m}${g}${w}`,E=a-D(y)-D(`${b} `)-D(C)-D(T),O=ge(_,Math.max(0,E),`truncate-end`),A=(0,$.jsxs)(R,{dimColor:x,bold:r,children:[y,b,` `,t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!1,bold:!0,children:t}),`: `]}),O,` `,S,` `,u,m,h>0&&(0,$.jsx)(R,{color:`warning`,children:g}),w&&(0,$.jsx)(R,{dimColor:!0,children:w})]});return i?(0,$.jsx)(U,{onClick:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:A}):A}dx(),H(),Hh(),ny(),H(),wr(),jb(),Pi(),Wo(),Hh(),Cs(),ny(),H(),Pi(),sx(),Hh(),tx(),ny(),H(),wr(),jb(),Pi(),Md(),H(),ty(),Ia(),ul();function nA({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ly(),[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`}];we(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),we(`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)(xe,{color:`permission`,children:[(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsxs)(U,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(R,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(R,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(U,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(wd,{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)(R,{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)(R,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(R,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Ja,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}oS(),f(),O(),Hh(),H(),ty(),za(),X(),Qa(),q(),Pi(),sn(),fr(),py(),Lv(),Fy(),_l();function rA({initialTeams:e,onDone:t}){mg(`teams-dialog`);let n=Af(),[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)(()=>Iy(r.teamName),[r.teamName,s]);se(()=>{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=Z(e=>e.toolPermissionContext.isBypassPermissionsModeAvailable),f=()=>{i({type:`teammateList`,teamName:r.teamName}),o(0)};V({"confirm:cycleMode":(0,Q.useCallback)(()=>{r.type===`teammateDetail`&&u?(pA(u,r.teamName,d),c(e=>e+1)):r.type===`teammateList`&&l.length>0&&(mA(l,r.teamName,d),c(e=>e+1))},[r,u,l,d])},{context:`Confirmation`}),Oe((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&&(cA(u.tmuxPaneId,u.backendType&&Jv(u.backendType)?u.backendType:void 0),t());return}if(e===`k`){r.type===`teammateList`&&l[a]?sA(l[a].tmuxPaneId,l[a].backendType&&Jv(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&&(sA(u.tmuxPaneId,u.backendType&&Jv(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];hc(e.name,r.teamName,`Graceful shutdown requested by team lead`)}else r.type===`teammateDetail`&&u&&(hc(u.name,r.teamName,`Graceful shutdown requested by team lead`),f());return}if(e===`h`){let e=mc(),t=r.type===`teammateList`?l[a]:r.type===`teammateDetail`?u:null;t&&e?.supportsHideShow&&(lA(t,r.teamName).then(()=>{c(e=>e+1)}),r.type===`teammateDetail`&&f());return}if(e===`H`&&r.type===`teammateList`){if(mc()?.supportsHideShow&&l.length>0){let e=l.some(e=>!e.isHidden);Promise.all(l.map(t=>e?uA(t,r.teamName):dA(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=>sA(e.tmuxPaneId,e.backendType&&Jv(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)(iA,{teamName:r.teamName,teammates:l,selectedIndex:a,onCancel:t}):r.type===`teammateDetail`&&u?(0,$.jsx)(oA,{teammate:u,teamName:r.teamName,onCancel:f}):null}function iA({teamName:e,teammates:t,selectedIndex:n,onCancel:r}){let i=`${t.length} ${t.length===1?`teammate`:`teammates`}`,a=mc()?.supportsHideShow??!1,o=fc(`confirm:cycleMode`,`Confirmation`,`shift+tab`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{title:`Team ${e}`,subtitle:i,onCancel:r,color:`background`,hideInputGuide:!0,children:t.length===0?(0,$.jsx)(R,{dimColor:!0,children:`No teammates`}):(0,$.jsx)(U,{flexDirection:`column`,children:t.map((e,t)=>(0,$.jsx)(aA,{teammate:e,isSelected:t===n},e.agentId))})}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowUp,`/`,p.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 aA({teammate:e,isSelected:t}){let n=e.status===`idle`,r=n&&!t,i=e.mode?un(e.mode):`default`,a=Zt(i),o=sr(i);return(0,$.jsxs)(R,{color:t?`suggestion`:void 0,dimColor:r,children:[t?p.pointer+` `:` `,e.isHidden&&(0,$.jsx)(R,{dimColor:!0,children:`[hidden] `}),n&&(0,$.jsx)(R,{dimColor:!0,children:`[idle] `}),a&&(0,$.jsxs)(R,{color:o,children:[a,` `]}),`@`,e.name,e.model&&(0,$.jsxs)(R,{dimColor:!0,children:[` (`,e.model,`)`]})]})}function oA({teammate:e,teamName:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),a=fc(`confirm:cycleMode`,`Confirmation`,`shift+tab`),o=e.color?Bg[e.color]:void 0,[s,c]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let n=!1;return Nv(t).then(t=>{n||c(t.filter(t=>t.owner===e.agentId||t.owner===e.name))}),()=>{n=!0}},[t,e.agentId,e.name]),Oe(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?un(e.mode):`default`,m=Zt(f),h=sr(f);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{title:(0,$.jsxs)($.Fragment,{children:[m&&(0,$.jsxs)(R,{color:h,children:[m,` `]}),o?(0,$.jsx)(R,{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)(R,{bold:!0,children:`Tasks`}),s.map(e=>(0,$.jsxs)(R,{color:e.status===`completed`?`success`:void 0,children:[e.status===`completed`?p.tick:`◼`,` `,e.subject]},e.id))]}),e.prompt&&(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(R,{bold:!0,children:`Prompt`}),(0,$.jsxs)(R,{children:[r?e.prompt:Oi(e.prompt,80),D(e.prompt)>80&&!r&&(0,$.jsx)(R,{dimColor:!0,children:` (p to expand)`})]})]})]}),(0,$.jsx)(U,{marginLeft:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowLeft,` back · Esc close · k kill · s shutdown`,mc()?.supportsHideShow&&` · h hide/show`,` · `,a,` cycle mode`]})})]})}async function sA(e,t,n,r,i,a){if(t)try{await $a(),await Ba(t).killPane(e,!Ty())}catch(t){J(`[TeamsDialog] Failed to kill pane ${e}: ${t}`)}else J(`[TeamsDialog] Skipping pane kill for ${e}: no backendType recorded`);qv(n,e);let{notificationMessage:o}=await Rv(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:zS(),from:`system`,text:hr({type:`teammate_terminated`,message:o}),timestamp:new Date().toISOString(),status:`pending`}]}}}),J(`[TeamsDialog] Removed ${r} from teamContext`)}async function cA(e,t){t===`iterm2`?await ci(`it2`,[`session`,`focus`,`-s`,e]):t===`windows-terminal`?J(`[TeamsDialog] viewTeammateOutput: Windows Terminal pane ${e} — manual tab switch required`):await ci(my,Ty()?[`select-pane`,`-t`,e]:[`-L`,hy(),`select-pane`,`-t`,e])}async function lA(e,t){e.isHidden?await dA(e,t):await uA(e,t)}async function uA(e,t){}async function dA(e,t){}function fA(e,t,n){Wv(t,e,n),Jp(e,{from:`team-lead`,text:hr(eh({mode:n,from:`team-lead`})),timestamp:new Date().toISOString()},t),J(`[TeamsDialog] Sent mode change to ${e}: ${n}`)}function pA(e,t,n){let r=e.mode?un(e.mode):`default`,i=qk({...V_(),mode:r,isBypassPermissionsModeAvailable:n});fA(e.name,t,i)}function mA(e,t,n){if(e.length===0)return;let r=e.map(e=>e.mode?un(e.mode):`default`),i=r.every(e=>e===r[0])?qk({...V_(),mode:r[0]??`default`,isBypassPermissionsModeAvailable:n}):`default`;Uv(t,e.map(e=>({memberName:e.name,mode:i})));for(let n of e){let e=eh({mode:i,from:`team-lead`});Jp(n.name,{from:`team-lead`,text:hr(e),timestamp:new Date().toISOString()},t)}J(`[TeamsDialog] Sent mode change to all ${e.length} teammates: ${i}`)}function hA(e,t,n){let r=t;for(let t=0;t<n;t++){let t=gA(e,r);if(t.equals(r))break;r=t}return r}function gA(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 _A(e){return`eE$`.includes(e)}function vA(e){return`jkG`.includes(e)||e===`gg`}var yA={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function bA(e,t,n,r){if(n===`w`)return xA(e,t,r,ec);if(n===`W`)return xA(e,t,r,e=>!Us(e));let i=yA[n];if(i){let[n,a]=i;return n===a?SA(e,t,n,r):CA(e,t,n,a,r)}return null}function xA(e,t,n,r){let i=[];for(let{segment:t,index:n}of Ti().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=>Us(o(e)),l=e=>r(o(e)),u=e=>Mp(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 SA(e,t,n,r){let i=e.lastIndexOf(`
46
46
  `,t-1)+1,a=e.indexOf(`
47
- `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function CA(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}}ia(),Ei(),Vi();function wA(e,t,n,r){let i=hA(t,r.cursor,n);if(i.equals(r.cursor))return;let a=IA(r.cursor,i,t,e,n);RA(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function TA(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new yc(i.cursor.measuredText,a),s=LA(i.cursor,o,t);RA(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function EA(e,t,n,r,i){let a=bA(i.text,i.cursor.offset,n,t===`inner`);a&&(RA(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function DA(e,t,n){let r=n.text,i=r.split(`
47
+ `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function CA(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}}aa(),Ei(),Vi();function wA(e,t,n,r){let i=hA(t,r.cursor,n);if(i.equals(r.cursor))return;let a=IA(r.cursor,i,t,e,n);RA(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function TA(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new dc(i.cursor.measuredText,a),s=LA(i.cursor,o,t);RA(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function EA(e,t,n,r,i){let a=bA(i.text,i.cursor.offset,n,t===`inner`);a&&(RA(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function DA(e,t,n){let r=n.text,i=r.split(`
48
48
  `),a=Hi(r.slice(0,n.cursor.offset),`
49
49
  `),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
50
50
  `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
@@ -67,29 +67,29 @@ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, o
67
67
  `&&--a):o=n+1}else _A(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 LA(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 RA(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
68
68
  `)&&(a+=`
69
69
  `),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(wi(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 zA(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=IA(n.cursor,r,`G`,e,t);RA(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function BA(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=IA(n.cursor,r,`gg`,e,t);RA(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var VA={d:`delete`,c:`change`,y:`yank`};function HA(e){return e in VA}var UA=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),WA=new Set([`f`,`F`,`t`,`T`]),GA={i:`inner`,a:`around`};function KA(e){return e in GA}var qA=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),JA=1e4;function YA(){return{mode:`INSERT`,insertedText:``}}function XA(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function ZA(e,t,n){switch(e.type){case`idle`:return ej(t,n);case`count`:return tj(e,t,n);case`operator`:return nj(e,t,n);case`operatorCount`:return rj(e,t,n);case`operatorFind`:return ij(e,t,n);case`operatorTextObj`:return aj(e,t,n);case`find`:return oj(e,t,n);case`g`:return sj(e,t,n);case`operatorG`:return cj(e,t,n);case`replace`:return lj(e,t,n);case`indent`:return uj(e,t,n)}}function QA(e,t,n){return HA(e)?{next:{type:`operator`,op:VA[e],count:t}}:UA.has(e)?{execute:()=>{let r=hA(e,n.cursor,t);n.setOffset(r.offset)}}:WA.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:()=>AA(t,n)}:e===`x`?{execute:()=>OA(t,n)}:e===`J`?{execute:()=>jA(t,n)}:e===`p`||e===`P`?{execute:()=>MA(e===`p`,t,n)}:e===`D`?{execute:()=>wA(`delete`,`$`,1,n)}:e===`C`?{execute:()=>wA(`change`,`$`,1,n)}:e===`Y`?{execute:()=>DA(`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:()=>dj(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:()=>PA(`below`,n)}:e===`O`?{execute:()=>PA(`above`,n)}:null}function $A(e,t,n,r){return KA(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:GA[n]}}:WA.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:UA.has(n)?{execute:()=>wA(e,n,t,r)}:n===`G`?{execute:()=>zA(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function ej(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:QA(e,1,t)||{}}function tj(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),JA))}}}return QA(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function nj(e,t,n){return t===e.op[0]?{execute:()=>DA(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:$A(e.op,e.count,t,n)||{next:{type:`idle`}}}function rj(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),JA);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return $A(e.op,i,t,n)||{next:{type:`idle`}}}function ij(e,t,n){return{execute:()=>TA(e.op,e.find,t,e.count,n)}}function aj(e,t,n){return qA.has(t)?{execute:()=>EA(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function oj(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 sj(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=hA(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
70
- `),r=Math.min(e.count-1,t.length-1),i=0;for(let e=0;e<r;e++)i+=(t[e]?.length??0)+1;n.setOffset(i)}}:{execute:()=>n.setOffset(n.cursor.startOfFirstLine().offset)}:{next:{type:`idle`}}}function cj(e,t,n){return t===`j`||t===`k`?{execute:()=>wA(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>BA(e.op,e.count,n)}:{next:{type:`idle`}}}function lj(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>kA(t,e.count,n)}}function uj(e,t,n){return t===e.dir?{execute:()=>NA(e.dir,e.count,n)}:{next:{type:`idle`}}}function dj(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)}ia(),Ei();function fj(e){let t=Q.useRef(YA()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(XA()),a=_l({...e,inputFilter:void 0}),{onModeChange:o,inputFilter:s}=e,c=(0,Q.useCallback)(e=>{e!==void 0&&a.setOffset(e),t.current={mode:`INSERT`,insertedText:``},r(`INSERT`),o?.(`INSERT`)},[a,o]),l=(0,Q.useCallback)(()=>{let n=t.current;n.mode===`INSERT`&&n.insertedText&&(i.current.lastChange={type:`insert`,text:n.insertedText});let s=a.offset;s>0&&e.value[s-1]!==`
71
- `&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=yc.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`:OA(t.count,r);break;case`replace`:kA(t.char,t.count,r);break;case`toggleCase`:AA(t.count,r);break;case`indent`:NA(t.dir,t.count,r);break;case`join`:jA(t.count,r);break;case`openLine`:PA(t.direction,r);break;case`operator`:wA(t.op,t.motion,t.count,r);break;case`operatorFind`:TA(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:EA(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=yc.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,-(wi(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=ZA(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}}F(),H();function pj(e){let[t]=ae(),n=le();xd(n,!!e.onImagePaste);let r=fj({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?M.inverse:e=>e,themeText:Te(`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)(ld,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Dv(),Ey(),Dc(),Ly(),Wx(),s();function mj(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 hj(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function gj(e){let t=RS(`sha256`).update(e).digest(`hex`).slice(0,16);return IS(o(),`cache-stats`,`${t}.json`)}var _j={version:1,signature:null,lastResetAt:null,lastHitRate:null};function vj(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 yj(e){try{let t=await KS(e,`utf8`),n=JSON.parse(t);return vj(n)?n:{..._j}}catch{return{..._j}}}async function bj(e,t){await GS(FS(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await JS(n,JSON.stringify(t),`utf8`),await qS(n,e)}catch{}}var xj={signature:null,lastResetAt:null,lastHitRate:null},Sj=null;async function Cj(e){Sj=e;let t=await yj(gj(e));xj={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function wj(e){let t=hj(e),n=mj(e);return t!==xj.signature&&(xj={signature:t,lastResetAt:Date.now(),lastHitRate:n},Sj!==null&&bj(gj(Sj),{version:1,signature:t,lastResetAt:xj.lastResetAt,lastHitRate:n})),{...xj}}function Tj(){return{...xj}}H(),Pi(),ny();function Ej(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 Dj(){return(0,$.jsx)(R,{dimColor:!0,children:` │ `})}function Oj({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=k(),[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=`${ki(n)}/${ki(r)}`;return(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{children:u}),(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Context `}),(0,$.jsxs)(R,{children:[t,`%`]}),!d&&(0,$.jsxs)(R,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Session `}),(0,$.jsxs)(R,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,Ej(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(R,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,Ej(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{children:no(i)})]})]})}var kj=Q.memo(Oj);Cr(),X(),ot(),Fm(),Kp(),Rb(),xm(),H(),lr(),On(),wr(),q(),Da(),ql(),$t(),ho(),ll(),Pi();var Aj=3600*1e3;function jj(e){return String(Math.floor(e)).padStart(2,`0`)}function Mj(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${jj(t)}:${jj(n)}`}function Nj({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=$o(e),o=(0,Q.useRef)(null);if(a!==null){let e=hj(a);e!==o.current&&(o.current=e,wj(a))}let{lastResetAt:s,lastHitRate:c}=Tj(),l=s===null?null:t-s,u=l===null?null:Aj-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,Cj(Fe()))},[]);let h=a===null?c:mj(a);if(h===null&&s===null)return(0,$.jsx)(R,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:Mj(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{dimColor:!0,children:` Cache `}),(0,$.jsx)(R,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(R,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function Pj(){let{getGoal:t,formatGoalStatusLabel:n}=(ya(),e(ul)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?ki(r.tokensUsed):`${ki(r.tokensUsed)}/${ki(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(R,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(R,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(R,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(R,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(R,{children:o})}return(0,$.jsxs)(R,{children:[s,(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsx)(R,{dimColor:!0,children:i}),(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsx)(R,{children:a})]})}function Fj(e){return Ve()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function Ij(e,t,n,r,i,a,o){let s=_t(),c=Fl(),l=Pn({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=$o(r),f=Kn(l,yt()),p=yn(d,f),m=Rd(Fe()),h=Mh(),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{...Hs(),...m&&{session_name:m},model:{id:l,display_name:zt(l)},workspace:{current_dir:Tr(),project_dir:ft(),added_dirs:i},version:`2.7.1`,output_style:{name:u},cost:{total_cost_usd:Ue(),total_duration_ms:Je(),total_api_duration_ms:Ge(),total_lines_added:Pe(),total_lines_removed:Qe()},context_window:{total_input_tokens:wt(),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},...Vx()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...$e()&&{remote:{session_id:Fe()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function Lj(e){return fc(e)?.uuid??null}function Rj({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=kf(),c=wh(),{addNotification:l}=Lh(),u=Lb(),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=Lj(n);r!==g.current.messageId&&(e=Lc(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Am(Ij(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&&(Y(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&J(`Status line is configured but disableAllHooks is true`,{level:`warn`}),W()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),J(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(y(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let C=c?.statusLine?.padding??0,w=Pn({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),T=Kn(w,yt()),E=$o(e.current),D=E?E.input_tokens+E.cache_creation_input_tokens+E.cache_read_input_tokens:0,O=E?Math.round(yn(E,T).used??0):0,k=Mh(),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,M=!!c?.statusLine?.command;return(0,$.jsxs)(U,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(U,{gap:2,children:[(0,$.jsx)(kj,{modelName:zt(w),contextUsedPct:O,usedTokens:D,contextWindowSize:T,totalCostUsd:Ue(),rateLimits:A}),(0,$.jsx)(Pj,{}),(0,$.jsx)(Nj,{messages:e.current})]}),o?(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(fe,{children:o})}):M&&Ol()?(0,$.jsx)(R,{children:` `}):null]})}var zj=(0,Q.memo)(Rj);xp();function Bj(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}}f(),ny(),H(),X(),rS(),nc(),xc(),cS();function Vj({tasksSelected:e,isViewingTeammate:t,teammateFooterIndex:n=0,isLeaderIdle:r=!1,onOpenDialog:i}){let a=kf(),{columns:o}=k(),s=Z(e=>e.tasks),c=Z(e=>e.viewingAgentTaskId),l=(0,Q.useMemo)(()=>Object.values(s??{}).filter(e=>mg(e)&&!(process.env.USER_TYPE===`ant`&&zc(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]),m=(0,Q.useMemo)(()=>{let t={name:`main`,color:void 0,isIdle:r,taskId:void 0},n=f.map(e=>({name:e.identity.agentName,color:Wj(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]),h=(0,Q.useMemo)(()=>m.map((e,t)=>D(`@${e.name}`)+ +(t>0)),[m]);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}=Bj(h,Math.max(20,o-20-4),2,t>=0?t:0),d=m.slice(i,s);return(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowLeft,` `]}),d.map((e,n)=>{let i=n>0;return(0,$.jsxs)(Q.Fragment,{children:[i&&(0,$.jsx)(R,{children:` `}),(0,$.jsx)(Hj,{name:e.name,color:e.color,isSelected:t===e.idx,isViewed:r===e.idx,isIdle:e.isIdle,onClick:()=>e.taskId?sS(e.taskId,a):lS(a)})]},e.name)}),u&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,p.arrowRight]}),(0,$.jsxs)(R,{dimColor:!0,children:[` · `,(0,$.jsx)(he,{shortcut:`shift + ↓`,action:`expand`})]})]})}return nS(s??{},u)||l.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Uj,{selected:e,onClick:i,children:Ah(l)}),Dd(l)&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,p.arrowDown,` to view`]})]})}function Hj({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)(R,{backgroundColor:t,color:`inverseText`,bold:r,children:[`@`,e]}):(0,$.jsxs)(R,{color:`background`,inverse:!0,bold:r,children:[`@`,e]}):i?(0,$.jsxs)(R,{dimColor:!0,bold:r,children:[`@`,e]}):r?(0,$.jsxs)(R,{color:t,bold:!0,children:[`@`,e]}):(0,$.jsxs)(R,{color:t,dimColor:!t,children:[`@`,e]}),a?(0,$.jsx)(U,{onClick:a,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:l}):l}function Uj({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(R,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(U,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}function Wj(e){if(e&&kl.includes(e))return Qa[e]}H(),X();function Gj({teamsSelected:e,showHint:t}){let n=Z(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)(R,{dimColor:!0,children:`· `}),(0,$.jsx)(R,{dimColor:!0,children:`Enter to view`})]}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:`background`,inverse:e,children:`${r} ${r===1?`teammate`:`teammates`}`},e?`selected`:`normal`),i?(0,$.jsxs)(R,{children:[` `,i]}):null]})}H(),Af();function Kj({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Qd,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:D(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}si(),Mr(),fr();var qj=5e3;function Jj(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function Yj(){if(!await Ar())return null;let[e,t]=await Promise.all([jr(),kr()]);if(e===t)return null;let{stdout:n,code:r}=await ci(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qj,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=G(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:Jj(e.isDraft,e.reviewDecision)}}catch{return null}}ot();var Xj=6e4,Zj=4e3,Qj=60*6e4,$j={number:null,url:null,reviewState:null,lastUpdated:0};function eM(e,t=!0){let[n,r]=(0,Q.useState)($j),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=et();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=Qj)return;let l=Date.now(),u=await Yj();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>Zj){a.current=!0;return}e||(i.current=setTimeout(c,Xj))}}let l=Date.now()-o.current;return l>=Xj?c():i.current=setTimeout(c,Xj-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}H(),f(),Wx(),Ra(),sn(),tm(),nc(),Ci(),cS(),Yn(),uo(),X(),ot(),ny(),Pi(),nO(),RD(),ml(),Da(),lr(),ei(),Wh();var tM=(h_(),e(il)),nM=(vv(),e(sv)),rM=e=>()=>{},iM=()=>null,aM=3,oM=5e3,sM=1e3;function cM(){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=ji(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,oM);return()=>clearInterval(n)},[]),e}function lM(){let e=(0,Q.useSyncExternalStore)(nM?.subscribeToProactiveChanges??rM,nM?.getNextTickAt??iM,iM),[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)(R,{dimColor:!0,children:[`waiting `,Ai(t*1e3,{mostSignificantOnly:!0})]})}function uM(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),sM);return()=>clearInterval(e)},[]);let r=(ya(),e(ul)),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)(R,{color:d,children:[`goal (`,u,`)`]})}function dM({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)(R,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(u)return(0,$.jsx)(R,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let g=Vx()&&t===`INSERT`&&!d;return(0,$.jsxs)(U,{justifyContent:`flex-start`,gap:1,children:[d&&(0,$.jsx)(Kj,{value:f,onChange:p,historyFailedMatch:m}),g?(0,$.jsx)(R,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(fM,{mode:n,toolPermissionContext:r,showHint:!i&&!g,isLoading:a,tasksSelected:o,teamsSelected:s,teammateFooterIndex:l,tmuxSelected:c,onOpenTasksDialog:h})]})}function fM({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,teamsSelected:o,tmuxSelected:s,teammateFooterIndex:c,onOpenTasksDialog:l}){let{columns:u}=k(),d=bc(`chat:cycleMode`,`Chat`,`shift+tab`),f=Z(e=>e.tasks),m=Z(e=>e.teamContext),h=Zd(),[g]=(0,Q.useState)(()=>h.getState().remoteSessionUrl),_=Z(e=>e.viewSelectionMode),v=Z(e=>e.viewingAgentTaskId),y=Z(e=>e.expandedView),b=y===`teammates`,x=eM(i,mM()),S=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),C=(0,Q.useSyncExternalStore)(nM?.subscribeToProactiveChanges??rM,nM?.getNextTickAt??iM,iM),w=ID(),T=Dl(e=>e.voiceState),E=Dl(e=>e.voiceWarmingUp),D=j(),O=ee().getState,A=C!==null,M=tM?.isCoordinatorMode()===!0,N=(0,Q.useMemo)(()=>mi(Object.values(f),e=>mg(e)&&!(process.env.USER_TYPE===`ant`&&zc(e))),[f]),P=Id(),F=P!==void 0&&P.length>0,te=bc(`chat:cancel`,`Chat`,`esc`).toLowerCase(),ne=bc(`app:toggleTodos`,`Global`,`ctrl+t`),I=bc(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),L=bc(`voice:pushToTalk`,`Chat`,`Space`),[ie]=(0,Q.useState)(()=>(En().voiceFooterHintSeenCount??0)<aM),ae=ie,oe=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(!w||!ae||oe?.current)return;oe&&(oe.current=!0);let e=(En().voiceFooterHintSeenCount??0)+1;kt(t=>(t.voiceFooterHintSeenCount??0)>=e?t:{...t,voiceFooterHintSeenCount:e})}},[w,ae]);let se=Z(e=>e.notifications.current?.key===`kill-agents-confirm`),ce=cM(),le=Nn()&&!Xo()&&m!==void 0&&mi(Object.values(m.teammates),e=>e.name!==`team-lead`)>0;if(t===`bash`)return(0,$.jsx)(R,{color:`bashBorder`,children:`! for bash mode`});let ue=n?.mode,fe=!jt(ue),pe=v?f[v]:void 0,me=_===`viewing-agent`&&pe?.type===`in_process_teammate`,z=me&&pe!=null&&pe.status!==`running`,B=N>0||me,ge=(M||fe?1:0)+ +!!B+ +!!le,ve=mM()&&x.number!==null&&x.reviewState!==null&&x.url!==null&&ge<2&&(ge===0||u>=80),ye=ge<2,V=!b&&B&&Object.values(f).some(e=>e.type===`in_process_teammate`)||!b&&me,be=ue&&fe&&!$e()?(0,$.jsxs)(R,{color:sr(ue),children:[Zt(ue),` `,Ln(ue).toLowerCase(),` on`,ye&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,(0,$.jsx)(he,{shortcut:d,action:`cycle`,parens:!0})]})]},`mode`):null,xe=[...g?[(0,$.jsx)(re,{url:g,children:(0,$.jsxs)(R,{color:`ide`,children:[p.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&S?[(0,$.jsx)(TungstenPill,{selected:s},`tmux`)]:[],...Nn()&&le?[(0,$.jsx)(Gj,{teamsSelected:o,showHint:r&&!B},`teams`)]:[],...ve?[(0,$.jsx)(Vm,{number:x.number,url:x.url,reviewState:x.reviewState},`pr-status`)]:[],...ce?[(0,$.jsxs)(R,{dimColor:ce.level===`normal`,color:ce.level===`error`?`error`:ce.level===`warning`?`warning`:void 0,children:[ce.text,` · pid:`,process.pid]},`rss`)]:[],...(ya(),e(ul)).getGoal()?[(0,$.jsx)(uM,{},`goal-elapsed`)]:[]],Se=Object.values(f).some(e=>e.type===`in_process_teammate`&&e.status===`running`),H=Object.values(f).some(e=>e.type===`local_agent`&&e.status===`running`),Ce=r?pM(i,te,ne,I,F,y,Se,H,se):[];if(z?xe.push((0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:te,action:`return to team lead`})},`esc-return`)):A?xe.push((0,$.jsx)(lM,{},`proactive`)):!V&&r&&xe.push(...Ce),V){let e=[...be?[be]:[],...xe,...z?[]:Ce];return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{children:(0,$.jsx)(Vj,{tasksSelected:a,isViewingTeammate:me,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l})}),e.length>0&&(0,$.jsx)(U,{children:(0,$.jsx)(_e,{children:e})})]})}let we=process.env.USER_TYPE===`ant`&&Zk(f).length>0,Te=B&&!V&&!nS(f,b)?(0,$.jsx)(Vj,{tasksSelected:a,isViewingTeammate:me,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l}):null;xe.length===0&&!Te&&!be&&r&&xe.push((0,$.jsx)(R,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let Ee=En().copyOnSelect??!0,De=D&&(!Ee||de());if(w&&E)xe.push((0,$.jsx)(XD,{},`voice-warmup`));else if(Ol()&&De){let e=$r()===`macos`,t=e&&(O()?.lastPressHadAlt??!1);xe.push((0,$.jsx)(R,{dimColor:!0,children:(0,$.jsxs)(_e,{children:[!Ee&&(0,$.jsx)(he,{shortcut:`ctrl+c`,action:`copy`}),de()&&(t?(0,$.jsx)(R,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(he,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}else xe.length>0&&r&&w&&T===`idle`&&Ce.length===0&&ae&&xe.push((0,$.jsxs)(R,{dimColor:!0,children:[`hold `,L,` to speak`]},`voice-hint`));return(Te||we)&&r&&!le&&xe.push((0,$.jsx)(R,{dimColor:!0,children:a?(0,$.jsx)(he,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(he,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),xe.length===0&&!Te&&!be?Ol()?(0,$.jsx)(R,{children:` `}):null:(0,$.jsxs)(U,{height:1,overflow:`hidden`,children:[be&&(0,$.jsxs)(U,{flexShrink:0,children:[be,(Te||xe.length>0)&&(0,$.jsx)(R,{dimColor:!0,children:` · `})]}),Te&&(0,$.jsxs)(U,{flexShrink:0,children:[Te,xe.length>0&&(0,$.jsx)(R,{dimColor:!0,children:` · `})]}),xe.length>0&&(0,$.jsx)(R,{wrap:`truncate`,children:(0,$.jsx)(_e,{children:xe})})]})}function pM(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)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&s&&!c?[(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...u?[(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:n,action:l})},`toggle-tasks`)]:[]]}function mM(){return En().prStatusFooterEnabled??!0}nu(),xm(),ny(),H(),zh(),X(),Da(),Db(),Ux();function hM({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:A,historyFailedMatch:j,onOpenTasksDialog:M}){let N=wh(),{columns:P,rows:ee}=k(),F=(0,Q.useRef)(E);F.current=E;let te=(0,Q.useMemo)(()=>Lj(E),[E]),ne=P<80,I=Ol(),re=I&&ee<24,L=$k(),ie=Z(e=>e.coordinatorTaskIndex),ae=_&&(L===0||ie<0),oe=h||Fj(N)||D;return Sx((0,Q.useMemo)(()=>I&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[I,u,d,f])),u.length&&!I?(0,$.jsx)(U,{paddingX:2,paddingY:0,children:(0,$.jsx)(Ob,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Gx,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:ne?`column`:`row`,justifyContent:ne?`flex-start`:`space-between`,paddingX:2,gap:+!ne,children:[(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:+!ne,children:[i===`prompt`&&!re&&!n.show&&!w&&Fj(N)&&(0,$.jsx)(zj,{messagesRef:F,lastAssistantMessageId:te,vimMode:r}),(0,$.jsx)(vM,{}),(0,$.jsx)(dM,{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:A,historyFailedMatch:j,onOpenTasksDialog:M})]}),(0,$.jsxs)(U,{flexShrink:1,gap:1,children:[I?null:(0,$.jsx)(aO,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:S,mcpClients:C,isInputWrapped:T,isNarrow:ne}),process.env.USER_TYPE===`ant`&&Dy()&&(0,$.jsx)(R,{dimColor:!0,children:`undercover`}),(0,$.jsx)(_M,{bridgeSelected:y})]})]}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Qk,{})]})}var gM=(0,Q.memo)(hM);function _M({bridgeSelected:e}){let t=Z(e=>e.replBridgeEnabled),n=Z(e=>e.replBridgeConnected),r=Z(e=>e.replBridgeSessionActive),i=Z(e=>e.replBridgeReconnecting),a=Z(e=>e.replBridgeExplicit);if(!vy()||!t)return null;let o=_a({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(R,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(R,{dimColor:!0,children:` · Enter to view`})]})}function vM(){return null}f(),H(),xc(),_i(),Yn();function yM(){if(!Nn())return;let e=yi();if(e&&kl.includes(e))return Qa[e]}function bM({isLoading:e,themeColor:t}){let n=t,r=process.env.USER_TYPE===`ant`;return(0,$.jsxs)(R,{color:n??(r?`subtle`:void 0),dimColor:e,children:[p.pointer,`\xA0`]})}function xM({mode:e,isLoading:t,viewingAgentName:n,viewingAgentColor:r}){let i=yM(),a=r?Qa[r]:void 0;return(0,$.jsx)(U,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:n?(0,$.jsx)(bM,{isLoading:t,themeColor:a}):e===`bash`?(0,$.jsx)(R,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(bM,{isLoading:t,themeColor:Nn()?i:void 0})})}H(),X(),Hu(),Cs(),ql(),fr(),xf();var SM=new Set;function CM(e){try{return G(e)?.type===`idle_notification`}catch{return!1}}var wM=3;function TM(e){return`<${Yr}>
70
+ `),r=Math.min(e.count-1,t.length-1),i=0;for(let e=0;e<r;e++)i+=(t[e]?.length??0)+1;n.setOffset(i)}}:{execute:()=>n.setOffset(n.cursor.startOfFirstLine().offset)}:{next:{type:`idle`}}}function cj(e,t,n){return t===`j`||t===`k`?{execute:()=>wA(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>BA(e.op,e.count,n)}:{next:{type:`idle`}}}function lj(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>kA(t,e.count,n)}}function uj(e,t,n){return t===e.dir?{execute:()=>NA(e.dir,e.count,n)}:{next:{type:`idle`}}}function dj(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)}aa(),Ei();function fj(e){let t=Q.useRef(YA()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(XA()),a=hl({...e,inputFilter:void 0}),{onModeChange:o,inputFilter:s}=e,c=(0,Q.useCallback)(e=>{e!==void 0&&a.setOffset(e),t.current={mode:`INSERT`,insertedText:``},r(`INSERT`),o?.(`INSERT`)},[a,o]),l=(0,Q.useCallback)(()=>{let n=t.current;n.mode===`INSERT`&&n.insertedText&&(i.current.lastChange={type:`insert`,text:n.insertedText});let s=a.offset;s>0&&e.value[s-1]!==`
71
+ `&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=dc.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`:OA(t.count,r);break;case`replace`:kA(t.char,t.count,r);break;case`toggleCase`:AA(t.count,r);break;case`indent`:NA(t.dir,t.count,r);break;case`join`:jA(t.count,r);break;case`openLine`:PA(t.direction,r);break;case`operator`:wA(t.op,t.motion,t.count,r);break;case`operatorFind`:TA(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:EA(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=dc.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,-(wi(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=ZA(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}}F(),H();function pj(e){let[t]=ae(),n=le();Cd(n,!!e.onImagePaste);let r=fj({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?M.inverse:e=>e,themeText:Te(`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)(fd,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Dv(),Ey(),yc(),Ly(),Wx(),s();function mj(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 hj(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function gj(e){let t=RS(`sha256`).update(e).digest(`hex`).slice(0,16);return IS(o(),`cache-stats`,`${t}.json`)}var _j={version:1,signature:null,lastResetAt:null,lastHitRate:null};function vj(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 yj(e){try{let t=await KS(e,`utf8`),n=JSON.parse(t);return vj(n)?n:{..._j}}catch{return{..._j}}}async function bj(e,t){await GS(FS(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await JS(n,JSON.stringify(t),`utf8`),await qS(n,e)}catch{}}var xj={signature:null,lastResetAt:null,lastHitRate:null},Sj=null;async function Cj(e){Sj=e;let t=await yj(gj(e));xj={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function wj(e){let t=hj(e),n=mj(e);return t!==xj.signature&&(xj={signature:t,lastResetAt:Date.now(),lastHitRate:n},Sj!==null&&bj(gj(Sj),{version:1,signature:t,lastResetAt:xj.lastResetAt,lastHitRate:n})),{...xj}}function Tj(){return{...xj}}H(),Pi(),ny();function Ej(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 Dj(){return(0,$.jsx)(R,{dimColor:!0,children:` │ `})}function Oj({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=k(),[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=`${ki(n)}/${ki(r)}`;return(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{children:u}),(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Context `}),(0,$.jsxs)(R,{children:[t,`%`]}),!d&&(0,$.jsxs)(R,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Session `}),(0,$.jsxs)(R,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,Ej(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(R,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,Ej(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dj,{}),(0,$.jsx)(R,{children:no(i)})]})]})}var kj=Q.memo(Oj);Cr(),X(),ot(),Rm(),Xp(),Rb(),wm(),H(),lr(),On(),wr(),q(),Da(),ql(),$t(),go(),ol(),Pi();var Aj=3600*1e3;function jj(e){return String(Math.floor(e)).padStart(2,`0`)}function Mj(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${jj(t)}:${jj(n)}`}function Nj({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=$o(e),o=(0,Q.useRef)(null);if(a!==null){let e=hj(a);e!==o.current&&(o.current=e,wj(a))}let{lastResetAt:s,lastHitRate:c}=Tj(),l=s===null?null:t-s,u=l===null?null:Aj-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,Cj(Fe()))},[]);let h=a===null?c:mj(a);if(h===null&&s===null)return(0,$.jsx)(R,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:Mj(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{dimColor:!0,children:` Cache `}),(0,$.jsx)(R,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(R,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function Pj(){let{getGoal:t,formatGoalStatusLabel:n}=(ba(),e(sl)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?ki(r.tokensUsed):`${ki(r.tokensUsed)}/${ki(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(R,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(R,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(R,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(R,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(R,{children:o})}return(0,$.jsxs)(R,{children:[s,(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsx)(R,{dimColor:!0,children:i}),(0,$.jsx)(R,{dimColor:!0,children:` · `}),(0,$.jsx)(R,{children:a})]})}function Fj(e){return Ve()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function Ij(e,t,n,r,i,a,o){let s=_t(),c=Nl(),l=Pn({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=$o(r),f=Kn(l,yt()),p=yn(d,f),m=Bd(Fe()),h=Fh(),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{...zs(),...m&&{session_name:m},model:{id:l,display_name:zt(l)},workspace:{current_dir:Tr(),project_dir:ft(),added_dirs:i},version:`2.7.2`,output_style:{name:u},cost:{total_cost_usd:Ue(),total_duration_ms:Je(),total_api_duration_ms:Ge(),total_lines_added:Pe(),total_lines_removed:Qe()},context_window:{total_input_tokens:wt(),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},...Vx()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...$e()&&{remote:{session_id:Fe()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function Lj(e){return ac(e)?.uuid??null}function Rj({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=Af(),c=Eh(),{addNotification:l}=Bh(),u=Lb(),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=Lj(n);r!==g.current.messageId&&(e=Ac(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Nm(Ij(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&&(Y(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&J(`Status line is configured but disableAllHooks is true`,{level:`warn`}),W()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),J(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(y(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let C=c?.statusLine?.padding??0,w=Pn({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),T=Kn(w,yt()),E=$o(e.current),D=E?E.input_tokens+E.cache_creation_input_tokens+E.cache_read_input_tokens:0,O=E?Math.round(yn(E,T).used??0):0,k=Fh(),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,M=!!c?.statusLine?.command;return(0,$.jsxs)(U,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(U,{gap:2,children:[(0,$.jsx)(kj,{modelName:zt(w),contextUsedPct:O,usedTokens:D,contextWindowSize:T,totalCostUsd:Ue(),rateLimits:A}),(0,$.jsx)(Pj,{}),(0,$.jsx)(Nj,{messages:e.current})]}),o?(0,$.jsx)(R,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(fe,{children:o})}):M&&El()?(0,$.jsx)(R,{children:` `}):null]})}var zj=(0,Q.memo)(Rj);wp();function Bj(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}}f(),ny(),H(),X(),rS(),fa(),Qa(),cS();function Vj({tasksSelected:e,isViewingTeammate:t,teammateFooterIndex:n=0,isLeaderIdle:r=!1,onOpenDialog:i}){let a=Af(),{columns:o}=k(),s=Z(e=>e.tasks),c=Z(e=>e.viewingAgentTaskId),l=(0,Q.useMemo)(()=>Object.values(s??{}).filter(e=>Gd(e)&&!(process.env.USER_TYPE===`ant`&&Zs(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]),m=(0,Q.useMemo)(()=>{let t={name:`main`,color:void 0,isIdle:r,taskId:void 0},n=f.map(e=>({name:e.identity.agentName,color:Wj(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]),h=(0,Q.useMemo)(()=>m.map((e,t)=>D(`@${e.name}`)+ +(t>0)),[m]);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}=Bj(h,Math.max(20,o-20-4),2,t>=0?t:0),d=m.slice(i,s);return(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsxs)(R,{dimColor:!0,children:[p.arrowLeft,` `]}),d.map((e,n)=>{let i=n>0;return(0,$.jsxs)(Q.Fragment,{children:[i&&(0,$.jsx)(R,{children:` `}),(0,$.jsx)(Hj,{name:e.name,color:e.color,isSelected:t===e.idx,isViewed:r===e.idx,isIdle:e.isIdle,onClick:()=>e.taskId?sS(e.taskId,a):lS(a)})]},e.name)}),u&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,p.arrowRight]}),(0,$.jsxs)(R,{dimColor:!0,children:[` · `,(0,$.jsx)(he,{shortcut:`shift + ↓`,action:`expand`})]})]})}return nS(s??{},u)||l.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Uj,{selected:e,onClick:i,children:Nh(l)}),Od(l)&&(0,$.jsxs)(R,{dimColor:!0,children:[` · `,p.arrowDown,` to view`]})]})}function Hj({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)(R,{backgroundColor:t,color:`inverseText`,bold:r,children:[`@`,e]}):(0,$.jsxs)(R,{color:`background`,inverse:!0,bold:r,children:[`@`,e]}):i?(0,$.jsxs)(R,{dimColor:!0,bold:r,children:[`@`,e]}):r?(0,$.jsxs)(R,{color:t,bold:!0,children:[`@`,e]}):(0,$.jsxs)(R,{color:t,dimColor:!t,children:[`@`,e]}),a?(0,$.jsx)(U,{onClick:a,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:l}):l}function Uj({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(R,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(U,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}function Wj(e){if(e&&Oa.includes(e))return Bg[e]}H(),X();function Gj({teamsSelected:e,showHint:t}){let n=Z(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)(R,{dimColor:!0,children:`· `}),(0,$.jsx)(R,{dimColor:!0,children:`Enter to view`})]}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:`background`,inverse:e,children:`${r} ${r===1?`teammate`:`teammates`}`},e?`selected`:`normal`),i?(0,$.jsxs)(R,{children:[` `,i]}):null]})}H(),jf();function Kj({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(U,{gap:1,children:[(0,$.jsx)(R,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(tf,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:D(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}si(),Mr(),fr();var qj=5e3;function Jj(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function Yj(){if(!await Ar())return null;let[e,t]=await Promise.all([jr(),kr()]);if(e===t)return null;let{stdout:n,code:r}=await ci(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qj,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=G(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:Jj(e.isDraft,e.reviewDecision)}}catch{return null}}ot();var Xj=6e4,Zj=4e3,Qj=60*6e4,$j={number:null,url:null,reviewState:null,lastUpdated:0};function eM(e,t=!0){let[n,r]=(0,Q.useState)($j),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=et();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=Qj)return;let l=Date.now(),u=await Yj();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>Zj){a.current=!0;return}e||(i.current=setTimeout(c,Xj))}}let l=Date.now()-o.current;return l>=Xj?c():i.current=setTimeout(c,Xj-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}H(),f(),Wx(),za(),sn(),Gh(),fa(),Ci(),cS(),Yn(),nc(),X(),ot(),ny(),Pi(),nO(),RD(),fl(),Da(),lr(),ei(),Jh();var tM=(m_(),e(el)),nM=(vv(),e(sv)),rM=e=>()=>{},iM=()=>null,aM=3,oM=5e3,sM=1e3;function cM(){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=ji(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,oM);return()=>clearInterval(n)},[]),e}function lM(){let e=(0,Q.useSyncExternalStore)(nM?.subscribeToProactiveChanges??rM,nM?.getNextTickAt??iM,iM),[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)(R,{dimColor:!0,children:[`waiting `,Ai(t*1e3,{mostSignificantOnly:!0})]})}function uM(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),sM);return()=>clearInterval(e)},[]);let r=(ba(),e(sl)),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)(R,{color:d,children:[`goal (`,u,`)`]})}function dM({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)(R,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(u)return(0,$.jsx)(R,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let g=Vx()&&t===`INSERT`&&!d;return(0,$.jsxs)(U,{justifyContent:`flex-start`,gap:1,children:[d&&(0,$.jsx)(Kj,{value:f,onChange:p,historyFailedMatch:m}),g?(0,$.jsx)(R,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(fM,{mode:n,toolPermissionContext:r,showHint:!i&&!g,isLoading:a,tasksSelected:o,teamsSelected:s,teammateFooterIndex:l,tmuxSelected:c,onOpenTasksDialog:h})]})}function fM({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,teamsSelected:o,tmuxSelected:s,teammateFooterIndex:c,onOpenTasksDialog:l}){let{columns:u}=k(),d=fc(`chat:cycleMode`,`Chat`,`shift+tab`),f=Z(e=>e.tasks),m=Z(e=>e.teamContext),h=ef(),[g]=(0,Q.useState)(()=>h.getState().remoteSessionUrl),_=Z(e=>e.viewSelectionMode),v=Z(e=>e.viewingAgentTaskId),y=Z(e=>e.expandedView),b=y===`teammates`,x=eM(i,mM()),S=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),C=(0,Q.useSyncExternalStore)(nM?.subscribeToProactiveChanges??rM,nM?.getNextTickAt??iM,iM),w=ID(),T=Tl(e=>e.voiceState),E=Tl(e=>e.voiceWarmingUp),D=j(),O=ee().getState,A=C!==null,M=tM?.isCoordinatorMode()===!0,N=(0,Q.useMemo)(()=>mi(Object.values(f),e=>Gd(e)&&!(process.env.USER_TYPE===`ant`&&Zs(e))),[f]),P=Dg(),F=P!==void 0&&P.length>0,te=fc(`chat:cancel`,`Chat`,`esc`).toLowerCase(),ne=fc(`app:toggleTodos`,`Global`,`ctrl+t`),I=fc(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),L=fc(`voice:pushToTalk`,`Chat`,`Space`),[ie]=(0,Q.useState)(()=>(En().voiceFooterHintSeenCount??0)<aM),ae=ie,oe=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(!w||!ae||oe?.current)return;oe&&(oe.current=!0);let e=(En().voiceFooterHintSeenCount??0)+1;kt(t=>(t.voiceFooterHintSeenCount??0)>=e?t:{...t,voiceFooterHintSeenCount:e})}},[w,ae]);let se=Z(e=>e.notifications.current?.key===`kill-agents-confirm`),ce=cM(),le=Nn()&&!Dc()&&m!==void 0&&mi(Object.values(m.teammates),e=>e.name!==`team-lead`)>0;if(t===`bash`)return(0,$.jsx)(R,{color:`bashBorder`,children:`! for bash mode`});let ue=n?.mode,fe=!jt(ue),pe=v?f[v]:void 0,me=_===`viewing-agent`&&pe?.type===`in_process_teammate`,z=me&&pe!=null&&pe.status!==`running`,B=N>0||me,ge=(M||fe?1:0)+ +!!B+ +!!le,ve=mM()&&x.number!==null&&x.reviewState!==null&&x.url!==null&&ge<2&&(ge===0||u>=80),ye=ge<2,V=!b&&B&&Object.values(f).some(e=>e.type===`in_process_teammate`)||!b&&me,be=ue&&fe&&!$e()?(0,$.jsxs)(R,{color:sr(ue),children:[Zt(ue),` `,Ln(ue).toLowerCase(),` on`,ye&&(0,$.jsxs)(R,{dimColor:!0,children:[` `,(0,$.jsx)(he,{shortcut:d,action:`cycle`,parens:!0})]})]},`mode`):null,xe=[...g?[(0,$.jsx)(re,{url:g,children:(0,$.jsxs)(R,{color:`ide`,children:[p.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&S?[(0,$.jsx)(TungstenPill,{selected:s},`tmux`)]:[],...Nn()&&le?[(0,$.jsx)(Gj,{teamsSelected:o,showHint:r&&!B},`teams`)]:[],...ve?[(0,$.jsx)(Hm,{number:x.number,url:x.url,reviewState:x.reviewState},`pr-status`)]:[],...ce?[(0,$.jsxs)(R,{dimColor:ce.level===`normal`,color:ce.level===`error`?`error`:ce.level===`warning`?`warning`:void 0,children:[ce.text,` · pid:`,process.pid]},`rss`)]:[],...(ba(),e(sl)).getGoal()?[(0,$.jsx)(uM,{},`goal-elapsed`)]:[]],Se=Object.values(f).some(e=>e.type===`in_process_teammate`&&e.status===`running`),H=Object.values(f).some(e=>e.type===`local_agent`&&e.status===`running`),Ce=r?pM(i,te,ne,I,F,y,Se,H,se):[];if(z?xe.push((0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:te,action:`return to team lead`})},`esc-return`)):A?xe.push((0,$.jsx)(lM,{},`proactive`)):!V&&r&&xe.push(...Ce),V){let e=[...be?[be]:[],...xe,...z?[]:Ce];return(0,$.jsxs)(U,{flexDirection:`column`,children:[(0,$.jsx)(U,{children:(0,$.jsx)(Vj,{tasksSelected:a,isViewingTeammate:me,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l})}),e.length>0&&(0,$.jsx)(U,{children:(0,$.jsx)(_e,{children:e})})]})}let we=process.env.USER_TYPE===`ant`&&Zk(f).length>0,Te=B&&!V&&!nS(f,b)?(0,$.jsx)(Vj,{tasksSelected:a,isViewingTeammate:me,teammateFooterIndex:c,isLeaderIdle:!i,onOpenDialog:l}):null;xe.length===0&&!Te&&!be&&r&&xe.push((0,$.jsx)(R,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let Ee=En().copyOnSelect??!0,De=D&&(!Ee||de());if(w&&E)xe.push((0,$.jsx)(XD,{},`voice-warmup`));else if(El()&&De){let e=$r()===`macos`,t=e&&(O()?.lastPressHadAlt??!1);xe.push((0,$.jsx)(R,{dimColor:!0,children:(0,$.jsxs)(_e,{children:[!Ee&&(0,$.jsx)(he,{shortcut:`ctrl+c`,action:`copy`}),de()&&(t?(0,$.jsx)(R,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(he,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}else xe.length>0&&r&&w&&T===`idle`&&Ce.length===0&&ae&&xe.push((0,$.jsxs)(R,{dimColor:!0,children:[`hold `,L,` to speak`]},`voice-hint`));return(Te||we)&&r&&!le&&xe.push((0,$.jsx)(R,{dimColor:!0,children:a?(0,$.jsx)(he,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(he,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),xe.length===0&&!Te&&!be?El()?(0,$.jsx)(R,{children:` `}):null:(0,$.jsxs)(U,{height:1,overflow:`hidden`,children:[be&&(0,$.jsxs)(U,{flexShrink:0,children:[be,(Te||xe.length>0)&&(0,$.jsx)(R,{dimColor:!0,children:` · `})]}),Te&&(0,$.jsxs)(U,{flexShrink:0,children:[Te,xe.length>0&&(0,$.jsx)(R,{dimColor:!0,children:` · `})]}),xe.length>0&&(0,$.jsx)(R,{wrap:`truncate`,children:(0,$.jsx)(_e,{children:xe})})]})}function pM(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)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&s&&!c?[(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...u?[(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:n,action:l})},`toggle-tasks`)]:[]]}function mM(){return En().prStatusFooterEnabled??!0}__(),wm(),ny(),H(),Hh(),X(),Da(),Db(),Ux();function hM({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:A,historyFailedMatch:j,onOpenTasksDialog:M}){let N=Eh(),{columns:P,rows:ee}=k(),F=(0,Q.useRef)(E);F.current=E;let te=(0,Q.useMemo)(()=>Lj(E),[E]),ne=P<80,I=El(),re=I&&ee<24,L=$k(),ie=Z(e=>e.coordinatorTaskIndex),ae=_&&(L===0||ie<0),oe=h||Fj(N)||D;return Sx((0,Q.useMemo)(()=>I&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[I,u,d,f])),u.length&&!I?(0,$.jsx)(U,{paddingX:2,paddingY:0,children:(0,$.jsx)(Ob,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Gx,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{flexDirection:ne?`column`:`row`,justifyContent:ne?`flex-start`:`space-between`,paddingX:2,gap:+!ne,children:[(0,$.jsxs)(U,{flexDirection:`column`,flexShrink:+!ne,children:[i===`prompt`&&!re&&!n.show&&!w&&Fj(N)&&(0,$.jsx)(zj,{messagesRef:F,lastAssistantMessageId:te,vimMode:r}),(0,$.jsx)(vM,{}),(0,$.jsx)(dM,{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:A,historyFailedMatch:j,onOpenTasksDialog:M})]}),(0,$.jsxs)(U,{flexShrink:1,gap:1,children:[I?null:(0,$.jsx)(aO,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:S,mcpClients:C,isInputWrapped:T,isNarrow:ne}),process.env.USER_TYPE===`ant`&&Dy()&&(0,$.jsx)(R,{dimColor:!0,children:`undercover`}),(0,$.jsx)(_M,{bridgeSelected:y})]})]}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Qk,{})]})}var gM=(0,Q.memo)(hM);function _M({bridgeSelected:e}){let t=Z(e=>e.replBridgeEnabled),n=Z(e=>e.replBridgeConnected),r=Z(e=>e.replBridgeSessionActive),i=Z(e=>e.replBridgeReconnecting),a=Z(e=>e.replBridgeExplicit);if(!vy()||!t)return null;let o=rl({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(R,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(R,{dimColor:!0,children:` · Enter to view`})]})}function vM(){return null}f(),H(),Qa(),_i(),Yn();function yM(){if(!Nn())return;let e=yi();if(e&&Oa.includes(e))return Bg[e]}function bM({isLoading:e,themeColor:t}){let n=t,r=process.env.USER_TYPE===`ant`;return(0,$.jsxs)(R,{color:n??(r?`subtle`:void 0),dimColor:e,children:[p.pointer,`\xA0`]})}function xM({mode:e,isLoading:t,viewingAgentName:n,viewingAgentColor:r}){let i=yM(),a=r?Bg[r]:void 0;return(0,$.jsx)(U,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:n?(0,$.jsx)(bM,{isLoading:t,themeColor:a}):e===`bash`?(0,$.jsx)(R,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(bM,{isLoading:t,themeColor:Nn()?i:void 0})})}H(),X(),Ku(),Ss(),ql(),fr(),wf();var SM=new Set;function CM(e){try{return G(e)?.type===`idle_notification`}catch{return!1}}var wM=3;function TM(e){return`<${Yr}>
72
72
  <${Ur}>+${e} more tasks completed</${Ur}>
73
73
  <${Jr}>completed</${Jr}>
74
- </${Yr}>`}function EM(e){let t=e.filter(e=>typeof e.value!=`string`||!CM(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=wM)return[...r,...n];let i=n.slice(0,wM-1),a={value:TM(n.length-(wM-1)),mode:`task-notification`};return[...r,...i,a]}function DM(){let e=pD(),t=Z(e=>!!e.viewingAgentTaskId),n=Z(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(ls);return t.length===0?null:id(EM(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),ro({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(U,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(ps,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(Jc,{message:e,lookups:Tf,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:SM,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var OM=Q.memo(DM);rf(),f(),H();function kM({hasStash:e}){return e?(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}ws();var AM=1e4,jM=1e3;function MM(e,t){if(e.length<=AM)return{truncatedText:e,placeholderContent:``};let n=Math.floor(jM/2),r=Math.floor(jM/2),i=e.slice(0,n),a=e.slice(-r),o=e.slice(n,-r);return{truncatedText:i+NM(t,Co(o))+a,placeholderContent:o}}function NM(e,t){return`[...Truncated text #${e} +${t} lines...]`}function PM(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=MM(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function FM({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}=PM(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}X(),lr(),Cs();var IM=(vv(),e(sv)),LM=3,RM=20;function zM({input:e,submitCount:t,viewingAgentName:n}){let r=pD(),i=Z(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n)return`Message @${n.length>RM?n.slice(0,RM-3)+`...`:n}…`;if(r.some(fh)&&(En().queuedCommandUpHintCount||0)<LM)return`Press up to edit queued messages`;if(t<1&&i&&!IM?.isProactiveActive())return yS()}},[e,r,t,i,n])}var BM=5e3,VM=!1;function HM(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(VM||!e)return;VM=!0,n(!0);let t=setTimeout(n,BM,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}_i();function UM(e){if(!pi())return e.standaloneAgentContext?.name}X(),xc(),wy(),uo(),py(),_i();function WM(){let e=Z(e=>e.teamContext),t=Z(e=>e.standaloneAgentContext),n=Z(e=>e.agent);Z(e=>e.viewingAgentTaskId);let r=Zd(),[i,a]=Q.useState(null);Q.useEffect(()=>{Cy().then(a)},[]);let o=r.getState();if(gi()&&!Si()){let t=vi();if(t&&pi())return{text:`@${t}`,bgColor:GM(e?.selfAgentColor??yi())}}if(e?.teamName&&e.teammates&&Object.keys(e.teammates).length>0){let e=tl(o),t=GM(e?.identity.color),n=Xo(),r=Mp(),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 ${hy()} a\``,bgColor:t};if((i===!0||n||a)&&e)return{text:`@${e.identity.agentName}`,bgColor:t}}let s=sd(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:za(e.agentType)??`cyan_FOR_SUBAGENTS_ONLY`}}let c=UM(o),l=t?.color;return c||l?{text:c??``,bgColor:GM(l)}:n?{text:n,bgColor:GM(o.agentDefinitions.activeAgents.find(e=>e.agentType===n)?.color,`promptBorder`)}:null}function GM(e,t=`cyan_FOR_SUBAGENTS_ONLY`){return e&&kl.includes(e)?Qa[e]:t}F(),Fm(),Cr(),X(),wr(),Cs(),wm(),zh(),Ox(),ws(),Rb(),ny(),H(),Hp(),Ap(),ty(),pf(),na(),rS(),nc(),tm(),xc(),Yn(),Ci(),ia(),lr(),q(),zr(),gr(),Da(),Dp(),Zr(),$t(),ei(),Fb(),uo(),Bv(),_i(),fi(),up(),Fa(),Af(),cS(),ff(),Wx();var KM=5,qM=3;function JM({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:O,onExit:A,getToolUseContext:j,onSubmit:M,onAgentSubmit:N,isSearchingHistory:P,setIsSearchingHistory:ee,onDismissSideQuestion:F,isSideQuestionVisible:te,helpOpen:I,setHelpOpen:re,hasSuppressedDialogs:L,isLocalJSXCommandActive:ie=!1,insertTextRef:ae,voiceInterimRange:se}){let ce=Lb(),le=Hd()||ie,[ue,de]=(0,Q.useState)(!1),[fe,me]=(0,Q.useState)({show:!1}),[z,B]=(0,Q.useState)(f.length),he=Q.useRef(f);f!==he.current&&(B(f.length),he.current=f);let ge=Q.useCallback(e=>{he.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:z,insert:e=>{let t=z===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,z)+t+f.slice(z);he.current=n,p(n),B(z+t.length)},setInputWithCursor:(e,t)=>{he.current=e,p(e),B(t)}});let _e=Zd(),ve=kf(),ye=Z(e=>e.tasks),be=Z(e=>e.replBridgeConnected),xe=Z(e=>e.replBridgeExplicit),Se=Z(e=>e.replBridgeReconnecting),H=be&&(xe||Se),Ce=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Te=process.env.USER_TYPE===`ant`&&Ce,Ee=Z(e=>!1),De=Z(e=>e.teamContext),ke=pD(),Ae=Z(e=>e.promptSuggestion),je=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}=En(),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=>ar()?e.fastMode:!1),We=Z(e=>e.effortValue),Ge=tl(_e.getState()),Ke=Ge?.identity.agentName,qe=Ge?.identity.color&&kl.includes(Ge.identity.color)?Ge.identity.color:void 0,Je=(0,Q.useMemo)(()=>vp(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}=mO(e=>{C(e.pastedContents),Hn(e.display)},f,ge,B,z,h,m,P,ee,C,S),tt=(0,Q.useRef)(-1);tt.current===-1&&(tt.current=YM(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=>ve(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[ve]),ft=(0,Q.useCallback)(e=>ve(t=>{let n=typeof e==`function`?e(t.coordinatorTaskIndex):e;return n===t.coordinatorTaskIndex?t:{...t,coordinatorTaskIndex:n}}),[ve]),pt=$k(),mt=(0,Q.useMemo)(()=>Object.values(ye).some(e=>mg(e)&&!(process.env.USER_TYPE===`ant`&&zc(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),[At,jt]=(0,Q.useState)(!1),Mt=(0,Q.useMemo)(()=>{let e=f.indexOf(`
74
+ </${Yr}>`}function EM(e){let t=e.filter(e=>typeof e.value!=`string`||!CM(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=wM)return[...r,...n];let i=n.slice(0,wM-1),a={value:TM(n.length-(wM-1)),mode:`task-notification`};return[...r,...i,a]}function DM(){let e=pD(),t=Z(e=>!!e.viewingAgentTaskId),n=Z(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(ss);return t.length===0?null:sd(EM(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),ro({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(U,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(ds,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(Uc,{message:e,lookups:Of,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:SM,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var OM=Q.memo(DM);cf(),f(),H();function kM({hasStash:e}){return e?(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[p.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Cs();var AM=1e4,jM=1e3;function MM(e,t){if(e.length<=AM)return{truncatedText:e,placeholderContent:``};let n=Math.floor(jM/2),r=Math.floor(jM/2),i=e.slice(0,n),a=e.slice(-r),o=e.slice(n,-r);return{truncatedText:i+NM(t,wo(o))+a,placeholderContent:o}}function NM(e,t){return`[...Truncated text #${e} +${t} lines...]`}function PM(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=MM(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function FM({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}=PM(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}X(),lr(),Ss();var IM=(vv(),e(sv)),LM=3,RM=20;function zM({input:e,submitCount:t,viewingAgentName:n}){let r=pD(),i=Z(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n)return`Message @${n.length>RM?n.slice(0,RM-3)+`...`:n}…`;if(r.some(ph)&&(En().queuedCommandUpHintCount||0)<LM)return`Press up to edit queued messages`;if(t<1&&i&&!IM?.isProactiveActive())return yS()}},[e,r,t,i,n])}var BM=5e3,VM=!1;function HM(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(VM||!e)return;VM=!0,n(!0);let t=setTimeout(n,BM,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}_i();function UM(e){if(!pi())return e.standaloneAgentContext?.name}X(),Qa(),wy(),nc(),py(),_i();function WM(){let e=Z(e=>e.teamContext),t=Z(e=>e.standaloneAgentContext),n=Z(e=>e.agent);Z(e=>e.viewingAgentTaskId);let r=ef(),[i,a]=Q.useState(null);Q.useEffect(()=>{Cy().then(a)},[]);let o=r.getState();if(gi()&&!Si()){let t=vi();if(t&&pi())return{text:`@${t}`,bgColor:GM(e?.selfAgentColor??yi())}}if(e?.teamName&&e.teammates&&Object.keys(e.teammates).length>0){let e=Ru(o),t=GM(e?.identity.color),n=Dc(),r=qp(),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 ${hy()} a\``,bgColor:t};if((i===!0||n||a)&&e)return{text:`@${e.identity.agentName}`,bgColor:t}}let s=Zu(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:Dl(e.agentType)??`cyan_FOR_SUBAGENTS_ONLY`}}let c=UM(o),l=t?.color;return c||l?{text:c??``,bgColor:GM(l)}:n?{text:n,bgColor:GM(o.agentDefinitions.activeAgents.find(e=>e.agentType===n)?.color,`promptBorder`)}:null}function GM(e,t=`cyan_FOR_SUBAGENTS_ONLY`){return e&&Oa.includes(e)?Bg[e]:t}F(),Rm(),Cr(),X(),wr(),Ss(),Dm(),Hh(),Ox(),Cs(),Rb(),ny(),H(),Gp(),Np(),ty(),_f(),ud(),rS(),fa(),Gh(),Qa(),Yn(),Ci(),aa(),lr(),q(),zr(),gr(),Da(),Ap(),Zr(),$t(),ei(),Fb(),nc(),Bv(),_i(),fi(),fp(),Ia(),jf(),cS(),gf(),Wx();var KM=5,qM=3;function JM({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:O,onExit:A,getToolUseContext:j,onSubmit:M,onAgentSubmit:N,isSearchingHistory:P,setIsSearchingHistory:ee,onDismissSideQuestion:F,isSideQuestionVisible:te,helpOpen:I,setHelpOpen:re,hasSuppressedDialogs:L,isLocalJSXCommandActive:ie=!1,insertTextRef:ae,voiceInterimRange:se}){let ce=Lb(),le=Hd()||ie,[ue,de]=(0,Q.useState)(!1),[fe,me]=(0,Q.useState)({show:!1}),[z,B]=(0,Q.useState)(f.length),he=Q.useRef(f);f!==he.current&&(B(f.length),he.current=f);let ge=Q.useCallback(e=>{he.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:z,insert:e=>{let t=z===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,z)+t+f.slice(z);he.current=n,p(n),B(z+t.length)},setInputWithCursor:(e,t)=>{he.current=e,p(e),B(t)}});let _e=ef(),ve=Af(),ye=Z(e=>e.tasks),be=Z(e=>e.replBridgeConnected),xe=Z(e=>e.replBridgeExplicit),Se=Z(e=>e.replBridgeReconnecting),H=be&&(xe||Se),Ce=Z(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Te=process.env.USER_TYPE===`ant`&&Ce,Ee=Z(e=>!1),De=Z(e=>e.teamContext),ke=pD(),Ae=Z(e=>e.promptSuggestion),je=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}=En(),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=>ar()?e.fastMode:!1),We=Z(e=>e.effortValue),Ge=Ru(_e.getState()),Ke=Ge?.identity.agentName,qe=Ge?.identity.color&&Oa.includes(Ge.identity.color)?Ge.identity.color:void 0,Je=(0,Q.useMemo)(()=>Om(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}=mO(e=>{C(e.pastedContents),Hn(e.display)},f,ge,B,z,h,m,P,ee,C,S),tt=(0,Q.useRef)(-1);tt.current===-1&&(tt.current=YM(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=>ve(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[ve]),ft=(0,Q.useCallback)(e=>ve(t=>{let n=typeof e==`function`?e(t.coordinatorTaskIndex):e;return n===t.coordinatorTaskIndex?t:{...t,coordinatorTaskIndex:n}}),[ve]),pt=$k(),mt=(0,Q.useMemo)(()=>Object.values(ye).some(e=>Gd(e)&&!(process.env.USER_TYPE===`ant`&&Zs(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),[At,jt]=(0,Q.useState)(!1),Mt=(0,Q.useMemo)(()=>{let e=f.indexOf(`
75
75
  `);return e===-1?!0:z<=e},[f,z]),Nt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
76
- `);return e===-1?!0:z>e},[f,z]),Pt=(0,Q.useMemo)(()=>{if(!Nn()||Xo()||!De)return[];let e=mi(Object.values(De.teammates),e=>e.name!==`team-lead`);return[{name:De.teamName,memberCount:e,runningCount:0,idleCount:0}]},[De]),Ft=((0,Q.useMemo)(()=>mi(Object.values(ye),e=>e.status===`running`),[ye])>0||process.env.USER_TYPE===`ant`&&pt>0)&&!nS(ye,Fe),It=Pt.length>0,Lt=pO(),Rt=Lt.length>0,zt=(0,Q.useMemo)(()=>[Rt&&`bg_agent`,Ft&&`tasks`,Te&&`tmux`,Ee&&`bagel`,It&&`teams`,H&&`bridge`,Re&&`companion`].filter(Boolean),[Rt,Ft,Te,Ee,It,H,Re]),Bt=Z(e=>e.footerSelection),Vt=Bt&&zt.includes(Bt)?Bt:null;(0,Q.useEffect)(()=>{Bt&&!Vt&&ve(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[Bt,Vt,ve]);let Ht=Vt===`tasks`,Ut=Vt===`tmux`,Wt=Vt===`teams`,Gt=Vt===`bridge`,qt=Vt===`bg_agent`;function Jt(e){ve(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`tasks`&&(ct(0),ft(mt)),e===`bg_agent`&&dt(-1)}function Yt(e,t=!1){let n=zt[(Vt?zt.indexOf(Vt):-1)+e];return n?(Jt(n),!0):e<0&&t?(Jt(null),!0):!1}let{suggestion:Xt,markAccepted:Zt,logOutcomeAtSubmission:Qt,markShown:$t}=gO({inputValue:f,isAssistantResponding:s}),en=(0,Q.useMemo)(()=>P&&$e?Ji(typeof $e==`string`?$e:$e.display):f,[P,$e,f]),tn=(0,Q.useMemo)(()=>Ic(en),[en]),nn=Z(e=>e.ultraplanSessionUrl),an=Z(e=>e.ultraplanLaunching),sn=(0,Q.useMemo)(()=>!nn&&!an?cb(en):[],[en,nn,an]),cn=(0,Q.useMemo)(()=>Ro()?fb(en):[],[en]),ln=(0,Q.useMemo)(()=>mb(en),[en]),un=(0,Q.useMemo)(()=>Cd(en),[en]),dn=(0,Q.useMemo)(()=>WO(en).filter(e=>eg(en.slice(e.start+1,e.end),a)),[en,a]),fn=(0,Q.useMemo)(()=>vh(en),[en]),pn=(0,Q.useMemo)(()=>uk(_e.getState().mcp.clients)?fk(en):[],[en,(0,Q.useSyncExternalStore)(nk,dk)]),mn=(0,Q.useMemo)(()=>{if(!Nn()||!De?.teammates)return[];let e=[],t=De.teammates;if(!t)return e;let n=/(^|\s)@([\w-]+)/g,r=Object.values(t),i;for(;(i=n.exec(en))!==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=Qa[s.color];t&&e.push({start:n,end:n+a.length,themeColor:t})}}return e},[en,De]),hn=(0,Q.useMemo)(()=>us(en).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[en]),gn=hn.some(e=>e.start===z);(0,Q.useEffect)(()=>{let e=hn.find(e=>z>e.start&&z<e.end);e&&B(z<(e.start+e.end)/2?e.start:e.end)},[z,hn,B]);let _n=(0,Q.useMemo)(()=>{let e=[];for(let t of hn)z===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});P&&$e&&!et&&e.push({start:z,end:z+Ze.length,color:`warning`,priority:20});for(let t of ln)e.push({start:t.start,end:t.end,color:`warning`,priority:15});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:`suggestion`,priority:5});for(let t of pn)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of mn)e.push({start:t.start,end:t.end,color:t.themeColor,priority:5});if(se&&e.push({start:se.start,end:se.end,color:void 0,dimColor:!0,priority:1}),Bs())for(let t of tn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:po(n-t.start),shimmerColor:po(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:po(n-t.start),shimmerColor:po(n-t.start,!0),priority:10});for(let t of cn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:po(n-t.start),shimmerColor:po(n-t.start,!0),priority:10});for(let t of un)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:po(n-t.start),shimmerColor:po(n-t.start,!0),priority:10});return e},[P,Ze,$e,et,z,ln,hn,mn,dn,fn,pn,en,se,tn,sn,cn,un]),{addNotification:vn,removeNotification:W}=Lh();(0,Q.useEffect)(()=>{tn.length&&Bs()?vn({key:`ultrathink-active`,text:`Effort set to high for this turn`,priority:`immediate`,timeoutMs:5e3}):W(`ultrathink-active`)},[vn,W,tn.length]),(0,Q.useEffect)(()=>{sn.length?vn({key:`ultraplan-active`,text:`This prompt will launch an ultraplan session in Claude Code on the web`,priority:`immediate`,timeoutMs:5e3}):W(`ultraplan-active`)},[vn,W,sn.length]),(0,Q.useEffect)(()=>{Ro()&&cn.length&&vn({key:`ultrareview-active`,text:`Run /ultrareview after Claude finishes to review these changes in the cloud`,priority:`immediate`,timeoutMs:5e3})},[vn,cn.length]);let yn=(0,Q.useRef)(f.length),xn=(0,Q.useRef)(f.length),Sn=(0,Q.useCallback)(()=>{W(`stash-hint`)},[W]);(0,Q.useEffect)(()=>{let e=yn.current,t=xn.current,n=f.length;if(yn.current=n,n>t){xn.current=n;return}if(n===0){xn.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(En().hasUsedStash||vn({key:`stash-hint`,jsx:(0,$.jsxs)(R,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Ja,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:iO}),xn.current=n)},[f.length,vn]);let{pushToBuffer:Cn,undo:wn,canUndo:Tn,clearBuffer:Dn}=hO({maxBufferSize:50,debounceMs:1e3});FM({input:f,pastedContents:S,onInputChange:ge,setCursorOffset:B,setPastedContents:C});let On=zM({input:f,submitCount:v,viewingAgentName:Ke}),kn=(0,Q.useCallback)(e=>{if(e===`?`){Y(`tengu_help_toggled`,{}),re(e=>!e);return}re(!1),Sn(),Yg(),Hc(ve);let t=e.length===f.length+1,n=z===0,r=Wc(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Ji(e).replaceAll(` `,` `);Cn(f,z,S),ge(t),B(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Cn(f,z,S),ve(e=>e.footerSelection===null?e:{...e,footerSelection:null}),ge(i)},[ge,h,f,z,Cn,S,Sn,ve]),{resetHistory:An,onHistoryUp:jn,onHistoryDown:Mn,dismissSearchHint:Pn,historyIndex:Fn}=fO((e,t,n)=>{kn(e),h(t),C(n)},f,S,B,m);(0,Q.useEffect)(()=>{P&&Pn()},[P,Pn]);function In(){if(!(Un.length>1)&&Mt){if(ke.some(fh)){er();return}jn()}}function Ln(){if(!(Un.length>1)&&Nt&&Mn()&&zt.length>0){let e=zt[0];Jt(e),e===`tasks`&&!En().hasSeenTasksHint&&kt(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[Rn,zn]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Bn=(0,Q.useCallback)(e=>{zn(t=>typeof e==`function`?e(t):e)},[]),Hn=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=_e.getState();if(n.footerSelection&&zt.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=Ae.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(je.status===`active`){Zt(),Qt(i,{skipReset:!0}),M(i,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An},{state:je,speculationSessionTimeSavedMs:Me,setAppState:ve});return}Ae.shownAt>0&&(Zt(),e=i)}if(Nn()){let t=Uk(e);if(t){let e=await Wk(t.recipientName,t.message,De,Wp);if(e.success){vn({key:`direct-message-sent`,text:`Sent to @${e.recipientName}`,priority:`immediate`,timeoutMs:3e3}),ge(``),B(0),Dn(),An();return}else !e.success&&e.error}}if(e.trim()===``&&!r)return;let a=Rn.suggestions.length>0&&Rn.suggestions.every(e=>e.description===`directory`);if(Rn.suggestions.length>0&&!t&&!a){J(`[onSubmit] early return: suggestions showing (count=${Rn.suggestions.length})`);return}Ae.text&&Ae.shownAt>0&&Qt(e),W(`stash-hint`);let o=sd(_e.getState());if(o.type!==`leader`&&N){Y(`tengu_transcript_input_to_teammate`,{}),await N(e,o.task,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An});return}await M(e,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An})},[Ae,je,Me,De,_e,zt,Rn.suggestions,M,N,Dn,An,Qt,ve,Zt,S,W]),{suggestions:Un,selectedSuggestion:Wn,commandArgumentHint:Gn,inlineGhostText:Kn,maxColumnWidth:qn}=Hk({commands:a,onInputChange:ge,onSubmit:Hn,setCursorOffset:B,input:f,cursorOffset:z,mode:m,agents:o,setSuggestionsState:Bn,suggestionsState:Rn,suppressSuggestions:P||Fn>0,markAccepted:Zt,onModeChange:h}),Jn=m===`prompt`&&Un.length===0&&Xt&&!Ne;Jn&&$t(),Ae.text&&!Xt&&Ae.shownAt===0&&!Ne&&(Fg(`timing`,Ae.text),ve(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function Yn(e,t,n,r,i){Y(`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};vc(o),Ks(o),C(e=>({...e,[a]:o})),Qn((nt.current?` `:``)+Lo(a)),nt.current=!0}(0,Q.useEffect)(()=>{let e=new Set(us(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 Xn(e){nt.current=!1;let t=oe(e).replace(/\r/g,`
77
- `).replaceAll(` `,` `);if(f.length===0){let e=Wc(t);e!==`prompt`&&(h(e),t=Ji(t))}let n=Co(t),r=Math.min(vr-10,2);if(t.length>800||n>r){let e=tt.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),Qn(Hl(e,n))}else Qn(t)}let Zn=(0,Q.useCallback)((e,t)=>nt.current?(nt.current=!1,Hx(e,t)?` `+e:e):e,[]);function Qn(e){Cn(f,z,S),ge(f.slice(0,z)+e+f.slice(z)),B(z+e.length)}let $n=ne(()=>{},()=>y()),er=(0,Q.useCallback)(()=>{let e=Eu(f,z);return e?(ge(e.text),h(`prompt`),B(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},[ge,h,f,z,C]);gD(x,function(e){Y(`tengu_ext_at_mentioned`,{});let t,n=OS.relative(Tr(),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[z-1]??` `;/\s/.test(r)||(t=` ${t}`),Qn(t)});let tr=(0,Q.useCallback)(()=>{if(Tn){let e=wn();e&&(ge(e.text),B(e.cursorOffset),C(e.pastedContents))}},[Tn,wn,ge,C]),nr=(0,Q.useCallback)(()=>{Cn(f,z,S),ge(f.slice(0,z)+`
78
- `+f.slice(z)),B(z+1)},[f,z,ge,B,Cn,S]),rr=(0,Q.useCallback)(async()=>{Y(`tengu_external_editor_used`,{}),vt(!0);try{let e=await Nb(f,S);e.error&&vn({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Cn(f,z,S),ge(e.content),B(e.content.length))}catch(e){e instanceof Error&&Qr(e),vn({key:`external-editor-error`,text:`External editor failed: ${Sr(e)}`,color:`warning`,priority:`high`})}finally{vt(!1)}},[f,z,S,Cn,ge,vn]),ir=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(ge(g.text),B(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:z,pastedContents:S}),ge(``),B(0),C({}),kt(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,z,g,ge,_,S,C]),or=(0,Q.useCallback)(()=>{bt(e=>!e),I&&re(!1)},[I]),sr=(0,Q.useCallback)(()=>{Ot(e=>!e),I&&re(!1)},[I]),cr=(0,Q.useCallback)(()=>{jt(e=>!e),I&&re(!1)},[I]),lr=(0,Q.useCallback)(()=>{if(Nn()&&Ge&&Ne){let e=qk({...n,mode:Ge.permissionMode},void 0);Y(`tengu_mode_cycle`,{to:e});let t=Ne;ve(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&&re(!1);return}J(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=qk(n,De),{context:t}=Jk(n,De);Y(`tengu_mode_cycle`,{to:e}),e===`plan`&&kt(e=>({...e,lastPlanModeUse:Date.now()})),ve(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),zv(e,De?.teamName),I&&re(!1)},[n,De,Ge,ve,r,I]),dr=(0,Q.useCallback)(()=>{Ac().then(e=>{if(e)Yn(e.base64,e.mediaType);else{let e=aa(`chat:imagePaste`,`Chat`,`ctrl+v`);vn({key:`no-image-in-clipboard`,text:Vr.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})}})},[vn,Yn]),G=pe();(0,Q.useEffect)(()=>{if(!(!G||le))return G.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Hn(f)}})},[G,le,Hn,f]),V((0,Q.useMemo)(()=>({"chat:undo":tr,"chat:newline":nr,"chat:externalEditor":rr,"chat:stash":ir,"chat:modelPicker":or,"chat:thinkingToggle":cr,"chat:cycleMode":lr,"chat:imagePaste":dr}),[tr,nr,rr,ir,or,cr,lr,dr]),{context:`Chat`,isActive:!le}),we(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!le&&!P}),we(`chat:fastMode`,sr,{context:`Chat`,isActive:!le&&ar()&&ur()}),we(`help:dismiss`,()=>{re(!1)},{context:`Help`,isActive:I}),we(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),we(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),we(`history:search`,()=>{},{context:`Global`,isActive:!1}),we(`app:interrupt`,()=>{Hc(ve)},{context:`Global`,isActive:!s&&je.status===`active`}),V({"footer:up":()=>{if(qt){ut>-1?dt(e=>e-1):Jt(null);return}if(Ht&&process.env.USER_TYPE===`ant`&&pt>0&&lt>mt){ft(e=>e-1);return}Yt(-1,!0)},"footer:down":()=>{if(qt){ut<Lt.length-1&&dt(e=>e+1);return}if(Ht&&process.env.USER_TYPE===`ant`&&pt>0){lt<pt-1&&ft(e=>e+1);return}if(Ht&&!Ye){O(!0),Jt(null);return}Yt(1)},"footer:next":()=>{if(Ht&&Ye){let e=1+Je.length;ct(t=>(t+1)%e);return}Yt(1)},"footer:previous":()=>{if(Ht&&Ye){let e=1+Je.length;ct(t=>(t-1+e)%e);return}Yt(-1)},"footer:openSelected":()=>{if(Pe!==`selecting-agent`)switch(Vt){case`companion`:Jt(null),Hn(`/buddy`);break;case`tasks`:if(Ye)if(st===0)lS(ve);else{let e=Je[st-1];e&&sS(e.id,ve)}else if(lt===0&&pt>0)lS(ve);else{let e=Zk(ye)[lt-1]?.id;e?sS(e,ve):(O(!0),Jt(null))}break;case`tmux`:process.env.USER_TYPE===`ant`&&ve(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`teams`:it(!0),Jt(null);break;case`bridge`:ot(!0),Jt(null);break;case`bg_agent`:if(ut===-1)lS(ve);else{let e=Lt[ut];e&&sS(e.agentId,ve)}break}},"footer:clearSelection":()=>{Jt(null)},"footer:close":()=>{if(Ht&&lt>=1){let e=Zk(ye)[lt-1];if(!e)return!1;if(Pe===`viewing-agent`&&e.id===Ne){kn(f.slice(0,z)+`x`+f.slice(z)),B(z+1);return}aS(e.id,ve),e.status!==`running`&&ft(e=>Math.max(mt,e-1));return}return!1}},{context:`Footer`,isActive:!!Vt&&!le}),Oe((e,t)=>{if(!(rt||xt||Ct||Tt)){if($r()===`macos`&&Kk(e)){let t=Gk[e],n=sy();vn({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(R,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(R,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(R,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(Vt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){kn(f.slice(0,z)+e+f.slice(z)),B(z+e.length);return}if(z===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),re(!1)),I&&f===``&&(t.backspace||t.delete)&&re(!1),t.escape){if(je.status===`active`){Hc(ve);return}if(te&&F){F();return}if(I){re(!1);return}if(Vt)return;if(ke.some(fh)){er();return}l.length>0&&!f&&!s&&$n()}t.return&&I&&re(!1)}});let fr=WM(),pr=ar()?bn():!1,mr=ar()?Ue&&(ur()||pr):!1,hr=HM(mr??!1),K=ze?void 0:lx(We,ce);(0,Q.useEffect)(()=>{if(!K){W(`effort-level`);return}vn({key:`effort-level`,text:K,priority:`high`,timeoutMs:12e3})},[K,vn,W]),Vh();let gr=Z(e=>e.companionReaction)!==void 0,{columns:_r,rows:vr}=k(),yr=_r-3-MD(_r,gr),br=Ol()?Math.max(qM,Math.floor(vr/2)-KM):void 0,q=(0,Q.useCallback)(e=>{if(!f||P)return;let t=yc.fromText(f,yr,z),n=t.getViewportStartLine(br);B(t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol}))},[f,yr,P,z,br]),xr=(0,Q.useCallback)(e=>O(e??!0),[O]),Cr=Jn&&Xt?Xt:On,wr=(0,Q.useMemo)(()=>f.includes(`
79
- `),[f]),Er=(0,Q.useCallback)((e,t)=>{let n=!1;ve(t=>(n=ar()&&!on(e)&&!!t.fastMode,{...t,mainLoopModel:e,mainLoopModelForSession:null,...n&&{fastMode:!1}})),bt(!1);let r=(Ue??!1)&&!n,i=`Model set to ${rn(e)}`;cx(e,r,Kt())&&(i+=` · Billed as extra usage`),n&&(i+=` · Fast mode OFF`),vn({key:`model-switched`,jsx:(0,$.jsx)(R,{children:i}),priority:`immediate`,timeoutMs:3e3}),Y(`tengu_model_picker_hotkey`,{model:e})},[ve,vn,Ue]),Dr=(0,Q.useCallback)(()=>{bt(!1)},[]),Or=(0,Q.useMemo)(()=>yt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(ux,{initial:Be,sessionModel:Ve,onSelect:Er,onCancel:Dr,isStandaloneCommand:!0,showFastModeNotice:ar()&&Ue&&on(Be)&&ur()})}):null,[yt,Be,Ve,Er,Dr]),kr=(0,Q.useCallback)(e=>{Ot(!1),e&&vn({key:`fast-mode-toggled`,jsx:(0,$.jsx)(R,{children:e}),priority:`immediate`,timeoutMs:3e3})},[vn]),Ar=(0,Q.useMemo)(()=>Dt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Rx,{onDone:kr,unavailableReason:Vn()})}):null,[Dt,kr]),jr=(0,Q.useCallback)(e=>{ve(t=>({...t,thinkingEnabled:e})),jt(!1),Y(`tengu_thinking_toggled_hotkey`,{enabled:e}),vn({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(R,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[ve,vn]),Mr=(0,Q.useCallback)(()=>{jt(!1)},[]),Nr=(0,Q.useMemo)(()=>At?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(nA,{currentValue:He??!0,onSelect:jr,onCancel:Mr,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[At,He,jr,Mr,l.length]);if(wx(null),E)return(0,$.jsx)(uS,{onDone:()=>O(!1),toolUseContext:j(l,[],new AbortController,ce),initialDetailTaskId:typeof E==`string`?E:void 0});if(Nn()&&rt)return(0,$.jsx)(rA,{initialTeams:Pt,onDone:()=>{it(!1)}});if(Or)return Or;if(Ar)return Ar;if(Nr)return Nr;if(at)return(0,$.jsx)(Xk,{onDone:()=>{ot(!1),Jt(null)}});let Pr={multiline:!0,onSubmit:Hn,onChange:kn,value:$e?Ji(typeof $e==`string`?$e:$e.display):f,onHistoryUp:In,onHistoryDown:Ln,onHistoryReset:An,placeholder:Cr,onExit:A,onExitMessage:(e,t)=>me({show:e,key:t}),onImagePaste:Yn,columns:yr,maxVisibleLines:br,disableCursorMovementForUpDownKeys:Un.length>0||!!Vt,disableEscapeDoublePress:Un.length>0,cursorOffset:z,onChangeCursorOffset:B,onPaste:Xn,onIsPastingChange:gt,focus:!P&&!le&&!Vt,showCursor:!Vt&&!P&&!gn,argumentHint:Gn,onUndo:Tn?()=>{let e=wn();e&&(ge(e.text),B(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:_n,inlineGhostText:Kn,inputFilter:Zn},Fr=()=>{let e={bash:`bashBorder`};if(e[m])return e[m];if(Si())return`promptBorder`;let t=yi();return t&&kl.includes(t)?Qa[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)(R,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Ir=Vx()?(0,$.jsx)(pj,{...Pr,initialMode:w,onModeChange:T}):(0,$.jsx)(Qd,{...Pr});return(0,$.jsxs)(U,{flexDirection:`column`,marginTop:+!ze,children:[!Ol()&&(0,$.jsx)(OM,{}),L&&(0,$.jsx)(U,{marginTop:1,marginLeft:2,children:(0,$.jsx)(R,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(kM,{hasStash:g!==void 0}),fr?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:fr.bgColor,children:fr.text?(0,$.jsxs)($.Fragment,{children:[`─`.repeat(Math.max(0,_r-D(fr.text)-4)),(0,$.jsxs)(R,{backgroundColor:fr.bgColor,color:`inverseText`,children:[` `,fr.text,` `]}),`──`]}):`─`.repeat(_r)}),(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,children:[(0,$.jsx)(xM,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:q,children:Ir})]}),(0,$.jsx)(R,{color:fr.bgColor,children:`─`.repeat(_r)})]}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Fr(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:XM(mr??!1,hr,pr),children:[(0,$.jsx)(xM,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:q,children:Ir})]}),(0,$.jsx)(gM,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:Vx()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:ue,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:de,suggestions:Un,selectedSuggestion:Wn,maxColumnWidth:qn,toolPermissionContext:Xe,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:Ht,teamsSelected:Wt,bridgeSelected:Gt,tmuxSelected:Ut,teammateFooterIndex:st,ideSelection:t,mcpClients:x,isPasting:ht,isInputWrapped:wr,messages:l,isSearching:P,historyQuery:Ze,setHistoryQuery:Qe,historyFailedMatch:et,onOpenTasksDialog:Ol()?xr:void 0}),Ol()?(0,$.jsx)(U,{position:`absolute`,marginTop:ze?-2:-1,height:+(Un.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(aO,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:ue,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:de,ideSelection:t,mcpClients:x,isInputWrapped:wr})}):null]})}function YM(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=us(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function XM(e,t,n){if(e)return{content:` ${t?`${Ix(!0,n)} ${M.dim(`/fast`)}`:Ix(!0,n)} `,position:`top`,align:`end`,offset:0}}var ZM=Q.memo(JM);fr();function QM(e,t){return{type:`assistant`,uuid:zS(),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 $M(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:hr(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}q(),Ay(),ql();function eN(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function tN(e){return{type:`stream_event`,event:e.event}}function nN(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 rN(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function iN(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 aN(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 oN(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:jy(e.compact_metadata)}}function sN(e,t){switch(e.type){case`assistant`:return{type:`message`,message:eN(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:ro({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:tN(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:nN(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:rN(t)};if(t.subtype===`status`){let t=iN(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:oN(e)}:(J(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:aN(e)};case`auth_status`:return J(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return J(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return J(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return J(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return J(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function cN(e){return e.type===`result`}X(),P_(),q(),Pi(),ql();var lN=6e4,uN=18e4;function dN({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=kf(),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 Py(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;J(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new CS(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(J(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){J(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;J(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(cN(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=sN(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?ba(l.event,e=>t(t=>[...t,e]),()=>{},s,o):J(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{J(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=B_(y.current,e.tool_name)??$M(e.tool_name),o=QM(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{J(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{J(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{J(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{J(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{J(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{J(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let b=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return J(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:qp(r,` `);n&&My(n,new AbortController().signal).then(e=>{Xv(t,e??Oi(n,75))})}if(!e?.viewerOnly){let e=h.current?uN:lN;m.current=setTimeout((e,t)=>{J(`[useRemoteSession] Response timeout - attempting reconnect`);let n=Na(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),x=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:b,cancelRequest:x,disconnect:S}),[l,b,x,S])}q(),fr(),u();function fN(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var pN=class{constructor(e,t){d(this,`ws`,null),d(this,`config`,void 0),d(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(`
76
+ `);return e===-1?!0:z>e},[f,z]),Pt=(0,Q.useMemo)(()=>{if(!Nn()||Dc()||!De)return[];let e=mi(Object.values(De.teammates),e=>e.name!==`team-lead`);return[{name:De.teamName,memberCount:e,runningCount:0,idleCount:0}]},[De]),Ft=((0,Q.useMemo)(()=>mi(Object.values(ye),e=>e.status===`running`),[ye])>0||process.env.USER_TYPE===`ant`&&pt>0)&&!nS(ye,Fe),It=Pt.length>0,Lt=pO(),Rt=Lt.length>0,zt=(0,Q.useMemo)(()=>[Rt&&`bg_agent`,Ft&&`tasks`,Te&&`tmux`,Ee&&`bagel`,It&&`teams`,H&&`bridge`,Re&&`companion`].filter(Boolean),[Rt,Ft,Te,Ee,It,H,Re]),Bt=Z(e=>e.footerSelection),Vt=Bt&&zt.includes(Bt)?Bt:null;(0,Q.useEffect)(()=>{Bt&&!Vt&&ve(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[Bt,Vt,ve]);let Ht=Vt===`tasks`,Ut=Vt===`tmux`,Wt=Vt===`teams`,Gt=Vt===`bridge`,qt=Vt===`bg_agent`;function Jt(e){ve(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`tasks`&&(ct(0),ft(mt)),e===`bg_agent`&&dt(-1)}function Yt(e,t=!1){let n=zt[(Vt?zt.indexOf(Vt):-1)+e];return n?(Jt(n),!0):e<0&&t?(Jt(null),!0):!1}let{suggestion:Xt,markAccepted:Zt,logOutcomeAtSubmission:Qt,markShown:$t}=gO({inputValue:f,isAssistantResponding:s}),en=(0,Q.useMemo)(()=>P&&$e?Ji(typeof $e==`string`?$e:$e.display):f,[P,$e,f]),tn=(0,Q.useMemo)(()=>kc(en),[en]),nn=Z(e=>e.ultraplanSessionUrl),an=Z(e=>e.ultraplanLaunching),sn=(0,Q.useMemo)(()=>!nn&&!an?cb(en):[],[en,nn,an]),cn=(0,Q.useMemo)(()=>zo()?fb(en):[],[en]),ln=(0,Q.useMemo)(()=>mb(en),[en]),un=(0,Q.useMemo)(()=>Td(en),[en]),dn=(0,Q.useMemo)(()=>WO(en).filter(e=>ig(en.slice(e.start+1,e.end),a)),[en,a]),fn=(0,Q.useMemo)(()=>vh(en),[en]),pn=(0,Q.useMemo)(()=>uk(_e.getState().mcp.clients)?fk(en):[],[en,(0,Q.useSyncExternalStore)(nk,dk)]),mn=(0,Q.useMemo)(()=>{if(!Nn()||!De?.teammates)return[];let e=[],t=De.teammates;if(!t)return e;let n=/(^|\s)@([\w-]+)/g,r=Object.values(t),i;for(;(i=n.exec(en))!==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=Bg[s.color];t&&e.push({start:n,end:n+a.length,themeColor:t})}}return e},[en,De]),hn=(0,Q.useMemo)(()=>cs(en).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[en]),gn=hn.some(e=>e.start===z);(0,Q.useEffect)(()=>{let e=hn.find(e=>z>e.start&&z<e.end);e&&B(z<(e.start+e.end)/2?e.start:e.end)},[z,hn,B]);let _n=(0,Q.useMemo)(()=>{let e=[];for(let t of hn)z===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});P&&$e&&!et&&e.push({start:z,end:z+Ze.length,color:`warning`,priority:20});for(let t of ln)e.push({start:t.start,end:t.end,color:`warning`,priority:15});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:`suggestion`,priority:5});for(let t of pn)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of mn)e.push({start:t.start,end:t.end,color:t.themeColor,priority:5});if(se&&e.push({start:se.start,end:se.end,color:void 0,dimColor:!0,priority:1}),Ls())for(let t of tn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mo(n-t.start),shimmerColor:mo(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:mo(n-t.start),shimmerColor:mo(n-t.start,!0),priority:10});for(let t of cn)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mo(n-t.start),shimmerColor:mo(n-t.start,!0),priority:10});for(let t of un)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:mo(n-t.start),shimmerColor:mo(n-t.start,!0),priority:10});return e},[P,Ze,$e,et,z,ln,hn,mn,dn,fn,pn,en,se,tn,sn,cn,un]),{addNotification:vn,removeNotification:W}=Bh();(0,Q.useEffect)(()=>{tn.length&&Ls()?vn({key:`ultrathink-active`,text:`Effort set to high for this turn`,priority:`immediate`,timeoutMs:5e3}):W(`ultrathink-active`)},[vn,W,tn.length]),(0,Q.useEffect)(()=>{sn.length?vn({key:`ultraplan-active`,text:`This prompt will launch an ultraplan session in Claude Code on the web`,priority:`immediate`,timeoutMs:5e3}):W(`ultraplan-active`)},[vn,W,sn.length]),(0,Q.useEffect)(()=>{zo()&&cn.length&&vn({key:`ultrareview-active`,text:`Run /ultrareview after Claude finishes to review these changes in the cloud`,priority:`immediate`,timeoutMs:5e3})},[vn,cn.length]);let yn=(0,Q.useRef)(f.length),xn=(0,Q.useRef)(f.length),Sn=(0,Q.useCallback)(()=>{W(`stash-hint`)},[W]);(0,Q.useEffect)(()=>{let e=yn.current,t=xn.current,n=f.length;if(yn.current=n,n>t){xn.current=n;return}if(n===0){xn.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(En().hasUsedStash||vn({key:`stash-hint`,jsx:(0,$.jsxs)(R,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Ja,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:iO}),xn.current=n)},[f.length,vn]);let{pushToBuffer:Cn,undo:wn,canUndo:Tn,clearBuffer:Dn}=hO({maxBufferSize:50,debounceMs:1e3});FM({input:f,pastedContents:S,onInputChange:ge,setCursorOffset:B,setPastedContents:C});let On=zM({input:f,submitCount:v,viewingAgentName:Ke}),kn=(0,Q.useCallback)(e=>{if(e===`?`){Y(`tengu_help_toggled`,{}),re(e=>!e);return}re(!1),Sn(),Xg(),Ic(ve);let t=e.length===f.length+1,n=z===0,r=Rc(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Ji(e).replaceAll(` `,` `);Cn(f,z,S),ge(t),B(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Cn(f,z,S),ve(e=>e.footerSelection===null?e:{...e,footerSelection:null}),ge(i)},[ge,h,f,z,Cn,S,Sn,ve]),{resetHistory:An,onHistoryUp:jn,onHistoryDown:Mn,dismissSearchHint:Pn,historyIndex:Fn}=fO((e,t,n)=>{kn(e),h(t),C(n)},f,S,B,m);(0,Q.useEffect)(()=>{P&&Pn()},[P,Pn]);function In(){if(!(Un.length>1)&&Mt){if(ke.some(ph)){er();return}jn()}}function Ln(){if(!(Un.length>1)&&Nt&&Mn()&&zt.length>0){let e=zt[0];Jt(e),e===`tasks`&&!En().hasSeenTasksHint&&kt(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[Rn,zn]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Bn=(0,Q.useCallback)(e=>{zn(t=>typeof e==`function`?e(t):e)},[]),Hn=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=_e.getState();if(n.footerSelection&&zt.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=Ae.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(je.status===`active`){Zt(),Qt(i,{skipReset:!0}),M(i,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An},{state:je,speculationSessionTimeSavedMs:Me,setAppState:ve});return}Ae.shownAt>0&&(Zt(),e=i)}if(Nn()){let t=Uk(e);if(t){let e=await Wk(t.recipientName,t.message,De,Jp);if(e.success){vn({key:`direct-message-sent`,text:`Sent to @${e.recipientName}`,priority:`immediate`,timeoutMs:3e3}),ge(``),B(0),Dn(),An();return}else !e.success&&e.error}}if(e.trim()===``&&!r)return;let a=Rn.suggestions.length>0&&Rn.suggestions.every(e=>e.description===`directory`);if(Rn.suggestions.length>0&&!t&&!a){J(`[onSubmit] early return: suggestions showing (count=${Rn.suggestions.length})`);return}Ae.text&&Ae.shownAt>0&&Qt(e),W(`stash-hint`);let o=Zu(_e.getState());if(o.type!==`leader`&&N){Y(`tengu_transcript_input_to_teammate`,{}),await N(e,o.task,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An});return}await M(e,{setCursorOffset:B,clearBuffer:Dn,resetHistory:An})},[Ae,je,Me,De,_e,zt,Rn.suggestions,M,N,Dn,An,Qt,ve,Zt,S,W]),{suggestions:Un,selectedSuggestion:Wn,commandArgumentHint:Gn,inlineGhostText:Kn,maxColumnWidth:qn}=Hk({commands:a,onInputChange:ge,onSubmit:Hn,setCursorOffset:B,input:f,cursorOffset:z,mode:m,agents:o,setSuggestionsState:Bn,suggestionsState:Rn,suppressSuggestions:P||Fn>0,markAccepted:Zt,onModeChange:h}),Jn=m===`prompt`&&Un.length===0&&Xt&&!Ne;Jn&&$t(),Ae.text&&!Xt&&Ae.shownAt===0&&!Ne&&(Ig(`timing`,Ae.text),ve(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function Yn(e,t,n,r,i){Y(`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};uc(o),Vs(o),C(e=>({...e,[a]:o})),Qn((nt.current?` `:``)+Ro(a)),nt.current=!0}(0,Q.useEffect)(()=>{let e=new Set(cs(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 Xn(e){nt.current=!1;let t=oe(e).replace(/\r/g,`
77
+ `).replaceAll(` `,` `);if(f.length===0){let e=Rc(t);e!==`prompt`&&(h(e),t=Ji(t))}let n=wo(t),r=Math.min(vr-10,2);if(t.length>800||n>r){let e=tt.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),Qn(Hl(e,n))}else Qn(t)}let Zn=(0,Q.useCallback)((e,t)=>nt.current?(nt.current=!1,Hx(e,t)?` `+e:e):e,[]);function Qn(e){Cn(f,z,S),ge(f.slice(0,z)+e+f.slice(z)),B(z+e.length)}let $n=ne(()=>{},()=>y()),er=(0,Q.useCallback)(()=>{let e=Au(f,z);return e?(ge(e.text),h(`prompt`),B(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},[ge,h,f,z,C]);gD(x,function(e){Y(`tengu_ext_at_mentioned`,{});let t,n=OS.relative(Tr(),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[z-1]??` `;/\s/.test(r)||(t=` ${t}`),Qn(t)});let tr=(0,Q.useCallback)(()=>{if(Tn){let e=wn();e&&(ge(e.text),B(e.cursorOffset),C(e.pastedContents))}},[Tn,wn,ge,C]),nr=(0,Q.useCallback)(()=>{Cn(f,z,S),ge(f.slice(0,z)+`
78
+ `+f.slice(z)),B(z+1)},[f,z,ge,B,Cn,S]),rr=(0,Q.useCallback)(async()=>{Y(`tengu_external_editor_used`,{}),vt(!0);try{let e=await Nb(f,S);e.error&&vn({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Cn(f,z,S),ge(e.content),B(e.content.length))}catch(e){e instanceof Error&&Qr(e),vn({key:`external-editor-error`,text:`External editor failed: ${Sr(e)}`,color:`warning`,priority:`high`})}finally{vt(!1)}},[f,z,S,Cn,ge,vn]),ir=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(ge(g.text),B(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:z,pastedContents:S}),ge(``),B(0),C({}),kt(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,z,g,ge,_,S,C]),or=(0,Q.useCallback)(()=>{bt(e=>!e),I&&re(!1)},[I]),sr=(0,Q.useCallback)(()=>{Ot(e=>!e),I&&re(!1)},[I]),cr=(0,Q.useCallback)(()=>{jt(e=>!e),I&&re(!1)},[I]),lr=(0,Q.useCallback)(()=>{if(Nn()&&Ge&&Ne){let e=qk({...n,mode:Ge.permissionMode},void 0);Y(`tengu_mode_cycle`,{to:e});let t=Ne;ve(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&&re(!1);return}J(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=qk(n,De),{context:t}=Jk(n,De);Y(`tengu_mode_cycle`,{to:e}),e===`plan`&&kt(e=>({...e,lastPlanModeUse:Date.now()})),ve(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),zv(e,De?.teamName),I&&re(!1)},[n,De,Ge,ve,r,I]),dr=(0,Q.useCallback)(()=>{Sc().then(e=>{if(e)Yn(e.base64,e.mediaType);else{let e=oa(`chat:imagePaste`,`Chat`,`ctrl+v`);vn({key:`no-image-in-clipboard`,text:Vr.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})}})},[vn,Yn]),G=pe();(0,Q.useEffect)(()=>{if(!(!G||le))return G.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Hn(f)}})},[G,le,Hn,f]),V((0,Q.useMemo)(()=>({"chat:undo":tr,"chat:newline":nr,"chat:externalEditor":rr,"chat:stash":ir,"chat:modelPicker":or,"chat:thinkingToggle":cr,"chat:cycleMode":lr,"chat:imagePaste":dr}),[tr,nr,rr,ir,or,cr,lr,dr]),{context:`Chat`,isActive:!le}),we(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!le&&!P}),we(`chat:fastMode`,sr,{context:`Chat`,isActive:!le&&ar()&&ur()}),we(`help:dismiss`,()=>{re(!1)},{context:`Help`,isActive:I}),we(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),we(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),we(`history:search`,()=>{},{context:`Global`,isActive:!1}),we(`app:interrupt`,()=>{Ic(ve)},{context:`Global`,isActive:!s&&je.status===`active`}),V({"footer:up":()=>{if(qt){ut>-1?dt(e=>e-1):Jt(null);return}if(Ht&&process.env.USER_TYPE===`ant`&&pt>0&&lt>mt){ft(e=>e-1);return}Yt(-1,!0)},"footer:down":()=>{if(qt){ut<Lt.length-1&&dt(e=>e+1);return}if(Ht&&process.env.USER_TYPE===`ant`&&pt>0){lt<pt-1&&ft(e=>e+1);return}if(Ht&&!Ye){O(!0),Jt(null);return}Yt(1)},"footer:next":()=>{if(Ht&&Ye){let e=1+Je.length;ct(t=>(t+1)%e);return}Yt(1)},"footer:previous":()=>{if(Ht&&Ye){let e=1+Je.length;ct(t=>(t-1+e)%e);return}Yt(-1)},"footer:openSelected":()=>{if(Pe!==`selecting-agent`)switch(Vt){case`companion`:Jt(null),Hn(`/buddy`);break;case`tasks`:if(Ye)if(st===0)lS(ve);else{let e=Je[st-1];e&&sS(e.id,ve)}else if(lt===0&&pt>0)lS(ve);else{let e=Zk(ye)[lt-1]?.id;e?sS(e,ve):(O(!0),Jt(null))}break;case`tmux`:process.env.USER_TYPE===`ant`&&ve(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`teams`:it(!0),Jt(null);break;case`bridge`:ot(!0),Jt(null);break;case`bg_agent`:if(ut===-1)lS(ve);else{let e=Lt[ut];e&&sS(e.agentId,ve)}break}},"footer:clearSelection":()=>{Jt(null)},"footer:close":()=>{if(Ht&&lt>=1){let e=Zk(ye)[lt-1];if(!e)return!1;if(Pe===`viewing-agent`&&e.id===Ne){kn(f.slice(0,z)+`x`+f.slice(z)),B(z+1);return}aS(e.id,ve),e.status!==`running`&&ft(e=>Math.max(mt,e-1));return}return!1}},{context:`Footer`,isActive:!!Vt&&!le}),Oe((e,t)=>{if(!(rt||xt||Ct||Tt)){if($r()===`macos`&&Kk(e)){let t=Gk[e],n=sy();vn({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(R,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(R,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(R,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(Vt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){kn(f.slice(0,z)+e+f.slice(z)),B(z+e.length);return}if(z===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),re(!1)),I&&f===``&&(t.backspace||t.delete)&&re(!1),t.escape){if(je.status===`active`){Ic(ve);return}if(te&&F){F();return}if(I){re(!1);return}if(Vt)return;if(ke.some(ph)){er();return}l.length>0&&!f&&!s&&$n()}t.return&&I&&re(!1)}});let fr=WM(),pr=ar()?bn():!1,mr=ar()?Ue&&(ur()||pr):!1,hr=HM(mr??!1),K=ze?void 0:lx(We,ce);(0,Q.useEffect)(()=>{if(!K){W(`effort-level`);return}vn({key:`effort-level`,text:K,priority:`high`,timeoutMs:12e3})},[K,vn,W]),Wh();let gr=Z(e=>e.companionReaction)!==void 0,{columns:_r,rows:vr}=k(),yr=_r-3-MD(_r,gr),br=El()?Math.max(qM,Math.floor(vr/2)-KM):void 0,q=(0,Q.useCallback)(e=>{if(!f||P)return;let t=dc.fromText(f,yr,z),n=t.getViewportStartLine(br);B(t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol}))},[f,yr,P,z,br]),xr=(0,Q.useCallback)(e=>O(e??!0),[O]),Cr=Jn&&Xt?Xt:On,wr=(0,Q.useMemo)(()=>f.includes(`
79
+ `),[f]),Er=(0,Q.useCallback)((e,t)=>{let n=!1;ve(t=>(n=ar()&&!on(e)&&!!t.fastMode,{...t,mainLoopModel:e,mainLoopModelForSession:null,...n&&{fastMode:!1}})),bt(!1);let r=(Ue??!1)&&!n,i=`Model set to ${rn(e)}`;cx(e,r,Kt())&&(i+=` · Billed as extra usage`),n&&(i+=` · Fast mode OFF`),vn({key:`model-switched`,jsx:(0,$.jsx)(R,{children:i}),priority:`immediate`,timeoutMs:3e3}),Y(`tengu_model_picker_hotkey`,{model:e})},[ve,vn,Ue]),Dr=(0,Q.useCallback)(()=>{bt(!1)},[]),Or=(0,Q.useMemo)(()=>yt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(ux,{initial:Be,sessionModel:Ve,onSelect:Er,onCancel:Dr,isStandaloneCommand:!0,showFastModeNotice:ar()&&Ue&&on(Be)&&ur()})}):null,[yt,Be,Ve,Er,Dr]),kr=(0,Q.useCallback)(e=>{Ot(!1),e&&vn({key:`fast-mode-toggled`,jsx:(0,$.jsx)(R,{children:e}),priority:`immediate`,timeoutMs:3e3})},[vn]),Ar=(0,Q.useMemo)(()=>Dt?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Rx,{onDone:kr,unavailableReason:Vn()})}):null,[Dt,kr]),jr=(0,Q.useCallback)(e=>{ve(t=>({...t,thinkingEnabled:e})),jt(!1),Y(`tengu_thinking_toggled_hotkey`,{enabled:e}),vn({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(R,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[ve,vn]),Mr=(0,Q.useCallback)(()=>{jt(!1)},[]),Nr=(0,Q.useMemo)(()=>At?(0,$.jsx)(U,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(nA,{currentValue:He??!0,onSelect:jr,onCancel:Mr,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[At,He,jr,Mr,l.length]);if(wx(null),E)return(0,$.jsx)(uS,{onDone:()=>O(!1),toolUseContext:j(l,[],new AbortController,ce),initialDetailTaskId:typeof E==`string`?E:void 0});if(Nn()&&rt)return(0,$.jsx)(rA,{initialTeams:Pt,onDone:()=>{it(!1)}});if(Or)return Or;if(Ar)return Ar;if(Nr)return Nr;if(at)return(0,$.jsx)(Xk,{onDone:()=>{ot(!1),Jt(null)}});let Pr={multiline:!0,onSubmit:Hn,onChange:kn,value:$e?Ji(typeof $e==`string`?$e:$e.display):f,onHistoryUp:In,onHistoryDown:Ln,onHistoryReset:An,placeholder:Cr,onExit:A,onExitMessage:(e,t)=>me({show:e,key:t}),onImagePaste:Yn,columns:yr,maxVisibleLines:br,disableCursorMovementForUpDownKeys:Un.length>0||!!Vt,disableEscapeDoublePress:Un.length>0,cursorOffset:z,onChangeCursorOffset:B,onPaste:Xn,onIsPastingChange:gt,focus:!P&&!le&&!Vt,showCursor:!Vt&&!P&&!gn,argumentHint:Gn,onUndo:Tn?()=>{let e=wn();e&&(ge(e.text),B(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:_n,inlineGhostText:Kn,inputFilter:Zn},Fr=()=>{let e={bash:`bashBorder`};if(e[m])return e[m];if(Si())return`promptBorder`;let t=yi();return t&&Oa.includes(t)?Bg[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)(R,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Ir=Vx()?(0,$.jsx)(pj,{...Pr,initialMode:w,onModeChange:T}):(0,$.jsx)(tf,{...Pr});return(0,$.jsxs)(U,{flexDirection:`column`,marginTop:+!ze,children:[!El()&&(0,$.jsx)(OM,{}),L&&(0,$.jsx)(U,{marginTop:1,marginLeft:2,children:(0,$.jsx)(R,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(kM,{hasStash:g!==void 0}),fr?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:fr.bgColor,children:fr.text?(0,$.jsxs)($.Fragment,{children:[`─`.repeat(Math.max(0,_r-D(fr.text)-4)),(0,$.jsxs)(R,{backgroundColor:fr.bgColor,color:`inverseText`,children:[` `,fr.text,` `]}),`──`]}):`─`.repeat(_r)}),(0,$.jsxs)(U,{flexDirection:`row`,width:`100%`,children:[(0,$.jsx)(xM,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:q,children:Ir})]}),(0,$.jsx)(R,{color:fr.bgColor,children:`─`.repeat(_r)})]}):(0,$.jsxs)(U,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Fr(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:XM(mr??!1,hr,pr),children:[(0,$.jsx)(xM,{mode:m,isLoading:s,viewingAgentName:Ke,viewingAgentColor:qe}),(0,$.jsx)(U,{flexGrow:1,flexShrink:1,onClick:q,children:Ir})]}),(0,$.jsx)(gM,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:Vx()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:ue,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:de,suggestions:Un,selectedSuggestion:Wn,maxColumnWidth:qn,toolPermissionContext:Xe,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:Ht,teamsSelected:Wt,bridgeSelected:Gt,tmuxSelected:Ut,teammateFooterIndex:st,ideSelection:t,mcpClients:x,isPasting:ht,isInputWrapped:wr,messages:l,isSearching:P,historyQuery:Ze,setHistoryQuery:Qe,historyFailedMatch:et,onOpenTasksDialog:El()?xr:void 0}),El()?(0,$.jsx)(U,{position:`absolute`,marginTop:ze?-2:-1,height:+(Un.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(aO,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:ue,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:de,ideSelection:t,mcpClients:x,isInputWrapped:wr})}):null]})}function YM(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=cs(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function XM(e,t,n){if(e)return{content:` ${t?`${Ix(!0,n)} ${M.dim(`/fast`)}`:Ix(!0,n)} `,position:`top`,align:`end`,offset:0}}var ZM=Q.memo(JM);fr();function QM(e,t){return{type:`assistant`,uuid:zS(),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 $M(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:hr(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}q(),Ay(),ql();function eN(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function tN(e){return{type:`stream_event`,event:e.event}}function nN(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 rN(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function iN(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 aN(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 oN(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:jy(e.compact_metadata)}}function sN(e,t){switch(e.type){case`assistant`:return{type:`message`,message:eN(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:ro({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:tN(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:nN(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:rN(t)};if(t.subtype===`status`){let t=iN(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:oN(e)}:(J(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:aN(e)};case`auth_status`:return J(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return J(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return J(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return J(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return J(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function cN(e){return e.type===`result`}X(),P_(),q(),Pi(),ql();var lN=6e4,uN=18e4;function dN({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Af(),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 Py(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;J(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new CS(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(J(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){J(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;J(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(cN(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=sN(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?xa(l.event,e=>t(t=>[...t,e]),()=>{},s,o):J(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{J(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=B_(y.current,e.tool_name)??$M(e.tool_name),o=QM(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{J(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{J(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{J(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{J(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{J(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{J(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let b=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return J(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:Zp(r,` `);n&&My(n,new AbortController().signal).then(e=>{Xv(t,e??Oi(n,75))})}if(!e?.viewerOnly){let e=h.current?uN:lN;m.current=setTimeout((e,t)=>{J(`[useRemoteSession] Response timeout - attempting reconnect`);let n=Na(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),x=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:b,cancelRequest:x,disconnect:S}),[l,b,x,S])}q(),fr(),u();function fN(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var pN=class{constructor(e,t){d(this,`ws`,null),d(this,`config`,void 0),d(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
80
80
  `).filter(e=>e.trim());for(let e of t){let t;try{t=G(e)}catch{continue}if(!fN(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(J(`[DirectConnect] Unsupported control request subtype: ${n.request.subtype}`),this.sendErrorResponse(n.request_id,`Unsupported control request subtype: ${n.request.subtype}`));continue}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.callbacks.onMessage(n)}}),this.ws.addEventListener(`close`,()=>{this.callbacks.onDisconnected?.()}),this.ws.addEventListener(`error`,()=>{this.callbacks.onError?.(Error(`WebSocket connection error`))})}sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;let t=hr({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=hr({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=hr({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=hr({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}};P_(),q();function mN({config:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new pN(e,{onMessage:e=>{if(cN(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=sN(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=B_(l.current,e.tool_name)??$M(e.tool_name),o=QM(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a,o,s){let c={behavior:`allow`,updatedInput:a};i.respondToPermissionRequest(t,c),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let a={behavior:`deny`,message:n??`User denied permission`};i.respondToPermissionRequest(t,a),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{J(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
81
81
  Server disconnected.
82
- `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,gl(1),n(!1)},onError:e=>{J(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}P_(),q(),Ig();function hN({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(cN(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=sN(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useSSHSession] permission request: ${e.tool_name}`);let a=B_(l.current,e.tool_name)??$M(e.tool_name),o=QM(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{J(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:zS(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{J(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal `+e.proc.signalCode}):\n${t}`),gl(1,`other`,{finalMessage:a})},onError:e=>{J(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}q(),Qv();async function gN(e){let{accessToken:t,orgUUID:n}=await Zv();return{baseUrl:`${Nr().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...Yv(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function _N(e,t,n){let r=await m.get(e.baseUrl,{headers:e.headers,params:t,timeout:15e3,validateStatus:()=>!0}).catch(()=>null);return!r||r.status!==200?(J(`[${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 vN(e,t=100){return _N(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function yN(e,t,n=100){return _N(e,{limit:n,before_id:t},`fetchOlderEvents`)}q();var bN=40,xN=10,SN=`loading older messages…`,CN=`failed to load older messages — scroll up to retry`,wN=`start of session`;function TN(e){let t=[];for(let n of e.events){let e=sN(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function EN({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)(zS());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=TN(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(wN);t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return o?[o,...i,...t]:[...i,...t]}),J(`[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 gN(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await vN(n);t||!r||(l.current=xN,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(SN),...t]});try{let r=await yN(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(CN),...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();J(`[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()<bN&&p()},[p])}}Vi();var DN=400;function ON({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=DN}){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=Ui(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 kN=[`0`,`1`,`2`,`3`],AN={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},jN=e=>kN.includes(e),MN=`How is Claude doing this session? (optional)`;function NN({onSelect:e,inputValue:t,setInputValue:n,message:r=MN}){return ON({inputValue:t,setInputValue:n,isValidDigit:jN,onDigit:t=>e(AN[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(R,{bold:!0,children:r})]}),(0,$.jsxs)(U,{marginLeft:2,children:[(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}en(),H(),Vi();function PN({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!jN(i)?null:(0,$.jsx)(LN,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var FN=[`0`,`1`];function IN(e){return FN.includes(e)}function LN({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=Ui(r.slice(-1));IN(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)(R,{color:`ansi:cyan`,children:[Fn,` `]}),(0,$.jsxs)(R,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(U,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(R,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(U,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(U,{width:12,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(U,{width:14,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Cr(),X(),ql();function RN(e){let t=Z(e=>e.skillImprovement.suggestion),n=kf(),[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&&wS(r.skillName,r.updates).then(()=>{e(e=>[...e,Na(`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 zN(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}pm(),Pf(),Wf(),Kp();function BN(e){(0,Q.useEffect)(()=>{let t=()=>{Xt()&&process.stdout.write(`
83
- `+Ua()+`
84
- `),Fp(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function VN(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&c(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function HN(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])}ot(),lg(),Wn();function UN(){let[e,t]=(0,Q.useState)(()=>{if(!Cn()||Dn())return`valid`;let{key:e,source:t}=Vt({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Cn()||Dn()){t(`valid`);return}await fn(Ze());let{key:e,source:n}=Vt();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 qm(e,!1)?`valid`:`invalid`);return}catch(e){r(e),t(`error`);return}},[]),error:n}}ot(),H(),wr(),q(),H(),ty(),an(),Cr(),X(),Ci();function WN({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=Z(e=>e.expandedView),d=kf(),f=(0,Q.useCallback)(()=>{Y(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(t=>{let{getAllInProcessTeammateTasks:n}=(wd(),e(tg));if(mi(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=Z(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(sh(),e(Hf));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}=(sh(),e(Hf));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]);we(`app:toggleTodos`,f,{context:`Global`}),we(`app:toggleTranscript`,m,{context:`Global`}),we(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),we(`app:toggleTeammatePreview`,()=>{d(e=>({...e,showTeammateMessagePreview:!e.showTeammateMessagePreview}))},{context:`Global`}),we(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),we(`app:redraw`,(0,Q.useCallback)(()=>{te.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return we(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),we(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}zh(),Hp(),ty();var GN={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function KN({onSubmit:e,isActive:t=!0}){let n=pe(),r=Hd(),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 V((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,GN,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Cr(),X(),Wx(),Fm(),zh(),Ap(),ty(),rS(),nc(),Cs();var qN=3e3;function JN(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=Zd(),g=kf(),_=pD().length,{addNotification:v,removeNotification:y}=Lh(),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){Y(`tengu_cancel`,e),t(()=>[]),n();return}if(So()&&s){s();return}Y(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),C=$p(),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&&!(Vx()&&c===`INSERT`),k=O&&(w||T)&&!E&&!D,A=O&&(w||T||D);we(`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;go(e,g);let n=[];for(let[e,r]of t)ns(e,g),n.push(r.description),hv(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return ha({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 we(`app:interrupt`,(0,Q.useCallback)(()=>{D&&(j(),lS(g)),(w||T)&&S()},[D,j,g,w,T,S]),{context:`Global`,isActive:A}),we(`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<=qN){b.current=0,y(`kill-agents-confirm`),Y(`tengu_cancel`,{source:`kill_agents`}),Jo(),j();return}b.current=t,v({key:`kill-agents-confirm`,text:`Press ${aa(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`)} again to stop background agents`,priority:`immediate`,timeoutMs:qN})},[h,v,y,j]),{context:`Chat`}),null}H(),X(),rS(),wd(),tm();function YN(e,t){t(t=>{let n=vp(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 XN(e){let t=Z(e=>e.tasks),n=Z(e=>e.viewSelectionMode),r=Z(e=>e.viewingAgentTaskId),i=Z(e=>e.selectedIPAgentIndex),a=Z(e=>e.pipeIpc),o=kf(),s=vp(t),c=s.length,l=Object.values(t).some(e=>mg(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=vp(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(jp(n)&&n.status===`running`){n.currentWorkAbortController?.abort();return}}lS(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?YN(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&&sS(e.taskId,o);return}if(s.key===`return`&&n===`selecting-agent`){if(s.preventDefault(),i===-1)lS(o);else if(i>=c)o(e=>({...e,expandedView:`none`,viewSelectionMode:`none`,selectedIPAgentIndex:-1}));else{let e=d();e&&sS(e.taskId,o)}return}if(s.key===`k`&&n===`selecting-agent`&&i>=0){s.preventDefault();let e=d();e&&e.task.status===`running`&&_f.kill(e.taskId,o);return}};return Oe((e,t,n)=>{f(new Ae(n.keypress))}),{handleKeyDown:f}}q(),co(),fr(),_i(),up(),Bv();function ZN(e,t,n){let{teamName:r,agentId:i,agentName:a}=n,o=Kv(r);if(!o){J(`[TeammateInit] Team file not found for team: ${r}`);return}let s=o.leadAgentId;if(o.teamAllowedPaths&&o.teamAllowedPaths.length>0){J(`[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}/**`;J(`[TeammateInit] Applying team permission: ${t.toolName} allowed in ${t.path} (rule: ${n})`),e(e=>({...e,toolPermissionContext:Op(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){J(`[TeammateInit] This agent is the team leader - skipping idle notification hook`);return}J(`[TeammateInit] Registering Stop hook for teammate ${a} to notify leader ${c}`),Kc(e,t,`Stop`,``,async(e,t)=>(Gv(r,a,!1),await Wp(c,{from:a,text:hr(If(a,{idleReason:`available`,summary:mm(e)})),timestamp:new Date().toISOString(),color:yi()}),J(`[TeammateInit] Sent idle notification to leader ${c}`),!0),`Failed to send idle notification to team leader`,{timeout:1e4})}ot(),Yn(),Bv(),_i();function QN(e,t,{enabled:n=!0}={}){(0,Q.useEffect)(()=>{if(n&&Nn()){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){_S(e,r,i);let t=Kv(r)?.members.find(e=>e.name===i);t&&ZN(e,Fe(),{teamName:r,agentId:t.agentId,agentName:i})}else{let t=bi?.();t?.teamName&&t?.agentId&&t?.agentName&&ZN(e,Fe(),{teamName:t.teamName,agentId:t.agentId,agentName:t.agentName})}}},[e,t,n])}X(),rS(),oa();function $N(){let e=kf(),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.viewingAgentTaskId?e.tasks[e.viewingAgentTaskId]:void 0),r=n&&jp(n)?n:void 0,i=r?.status,a=r?.error,o=n!==void 0;(0,Q.useEffect)(()=>{if(t){if(!o){lS(e);return}if(r&&(i===`killed`||i===`failed`||a||i!==`running`&&i!==`completed`&&i!==`pending`)){lS(e);return}}},[t,o,r,i,a,e])}Xx(),Zr();async function eP(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?Qr(e):Qr(Error(`Automated permission check failed: ${String(e)}`))}return null}By(),Ky();var tP=new Map,nP=null,rP=!1;function iP(){return nP??null}function aP(e,t){if(rP)return null;let n=iP();if(!n)return null;let r=zS(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return tP.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function oP(e){e&&tP.delete(e)}function sP(e,t){if(!e||rP)return;let n=iP();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Cr(),Ht(),m_(),q(),Ma(),ql(),co(),ss();function cP(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 lP(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){Lu({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Y(`tengu_tool_use_cancelled`,{messageID:s,toolName:hn(e.name)})},async persistPermissions(e){return e.length===0?!1:(Ps(e),a(qs(n.getAppState().toolPermissionContext,e)),e.some(e=>rl(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?Jh:Ad}${t}`:a?Gm:Tp,s=a?o:Km(o);return(r||!t&&!i?.length&&!a)&&(J(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of bh(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(J(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function uP(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))}}}Xr(),q(),ot(),H(),m_(),Th(),gr();function dP(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(`
85
- `):``}function fP(e){let t=e.match(RegExp(`<${Hr}\\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 pP(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=fP(dP(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 mP(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o,channelCallbacks:s}=e,{resolve:c,isResolved:l,claim:u}=cP(t),d,f,p=o?zS():void 0,m,h=Date.now(),g=i.updatedInput??n.input,_=null;function v(e){sP(_,e),oP(_),_=null}function y(){oP(_),_=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||Cm(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 yo(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),_=aP(b,e=>{u()&&(y(),Cm(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),Cm(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=qy(n.toolUseID),t=xt(),i=Uy(n.toolUseContext.getAppState().mcp.clients,e=>Hy(e,t)!==void 0);if(i.length>0){let t={request_id:e,tool_name:n.tool.name,description:r,input_preview:Wy(g)},a=pP(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:Vy,params:t}).catch(t=>{J(`Channel permission_request failed for ${e.name}: ${Sr(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?.(),Cm(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))})()}Yn(),gr(),Zr();async function hP(e){if(!Nn()||!rm())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}=cP(r),s=Bm({toolName:t.tool.name,toolUseId:t.toolUseID,input:t.input,description:n,permissionSuggestions:i});bp({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)))}}),gg(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 Qr(mr(e)),null}}Cr(),Ht(),H(),m_(),Th(),q(),gr(),Zr(),ys(),fr(),ss();function gP(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let u=lP(n,r,i,a,o,t,uP(e));if(!u.resolveIfAborted(c))return(s===void 0?yo(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Y(`tengu_internal_tool_permission_decision`,{toolName:hn(n.name),behavior:e.behavior,input:hr(r),messageID:u.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(u.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&_p(o,e.decisionReason.reason),u.logDecision({decision:`accept`,source:`config`}),c(u.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(!u.resolveIfAborted(c))switch(e.behavior){case`deny`:Lu({tool:n,input:r,toolUseContext:i,messageId:u.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Zx({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)(R,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:{if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await eP({ctx:u,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(u.resolveIfAborted(c))return;let n=await hP({ctx:u,description:a,updatedInput:e.updatedInput,suggestions:e.suggestions});if(n){c(n);return}mP({ctx:u,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks,channelCallbacks:t.channelPermissionCallbacks},c);return}}}).catch(e=>{e instanceof br||e instanceof l?(J(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),u.logCancelled(),c(u.cancelAndAbort(void 0,!0))):(Qr(e),c(u.cancelAndAbort(void 0,!0)))}).finally(()=>{Cm(o)})}),[e,t])}pv(),Cr(),wm(),ws(),wr(),q(),Ig(),gr(),Zr(),Cs(),$t();function _P(){Ea(0)}async function vP(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){uf(),await yP({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(us(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(Eo);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?vP({...e,input:`/exit`}):_P();return}let j=eu(T,k),M=us(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Y(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Yf(e)&&(e.name===f||e.aliases?.includes(f)||cp(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Y(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Ki(),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?g_({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(J(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Y(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),g_({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}uf(),await yP({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 yP(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=Ki();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),yg(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await cm(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 Rn(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await ob({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(yg(`query_process_user_input_end`),qa()&&(yg(`query_file_history_snapshot_start`),s.filter(ab).forEach(e=>{pa(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),yg(`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?pn(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?g_({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 ap({commands:e,outcome:{type:`failed`,error:A},currentDir:Tr(),priority:`later`,workload:O})}catch(e){Qr(mr(e))}else try{let t=await ap({commands:e,outcome:{type:`completed`},currentDir:Tr(),priority:`later`,workload:O});for(let e of t)g_(e)}catch(e){Qr(mr(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}Cs();function bP(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 xP({executeInput:e}){let t=e=>e.agentId===void 0,n=Ru(t);if(!n)return{processed:!1};if(bP(n)||n.mode===`bash`)return e([Is(t)]),{processed:!0};let r=n.mode,i=al(e=>t(e)&&!bP(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Cs();function SP({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Uc,Vl);(0,Q.useEffect)(()=>{r||t||i.length!==0&&xP({executeInput:e})},[i,r,e,t,n])}function CP({isLoading:e,onSubmitMessage:t}){let n=Jg();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function wP(e,t){return e&&t&&t.length>0?zn([...e,...t],`name`):e||[]}function TP(e,t){return(0,Q.useMemo)(()=>wP(e,t),[e,t])}du(),ib(),Ab(),Sn();function EP(e,t){return(0,Q.useMemo)(()=>t.length>0?zn([...e,...t],`name`):e,[e,t])}wm(),an(),Zr();function DP(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Oo(),t(await nd(e))}catch(e){e instanceof Error&&Qr(e)}},[e,t]);(0,Q.useEffect)(()=>bb.subscribe(n),[n]);let r=(0,Q.useCallback)(async()=>{if(e)try{_u(),t(await nd(e))}catch(e){e instanceof Error&&Qr(e)}},[e,t]);(0,Q.useEffect)(()=>nr(r),[r])}H(),ef(),X(),na();function OP(){let e=Z(e=>tl(e));if(!e)return null;let t=Mf(e.identity.color);return(0,$.jsx)(ig,{children:(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{children:`Viewing `}),(0,$.jsxs)(R,{color:t,bold:!0,children:[`@`,e.identity.agentName]}),(0,$.jsxs)(R,{dimColor:!0,children:[` · `,(0,$.jsx)(he,{shortcut:`esc`,action:`return`})]})]}),(0,$.jsx)(R,{dimColor:!0,children:e.prompt})]})})}Zr(),w(),fa(),Ii();var kP=Fi(()=>b({method:v(`selection_changed`),params:b({selection:b({start:b({line:g(),character:g()}),end:b({line:g(),character:g()})}).nullable().optional(),text:_().optional(),filePath:_().optional()})}));function AP(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Il(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(kP(),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){Qr(e)}}),n.current=!0},[e,t])}cc(),nm(),H(),Ju(),X(),Pi();function jP({task:e,selected:t}){let n=Pu(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)(R,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(R,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(R,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(U,{flexShrink:0,children:(0,$.jsxs)(R,{dimColor:!0,children:[n,` · ↓ `,ki(r),` tokens`]})})]})}function MP(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 NP(){let e=pO(),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.footerSelection),r=Z(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)(R,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(R,{dimColor:!0,children:MP(i,s)})]}),e.map(e=>(0,$.jsx)(jP,{task:e,selected:e.agentId===a},e.agentId))]})}O(),Xr(),H(),mu(),X(),P_(),oa(),q(),ql(),sn(),co(),fr(),wy(),uo(),py(),gh(),Gd(),Bv(),Lv(),_i(),fi(),up(),rg();function PP(e){if(!Si()){if(gi())return vi();if(hi(e.teamContext)){let t=e.teamContext.leadAgentId;return e.teamContext.teammates[t]?.name||`team-lead`}}}var FP=1e3;function IP({enabled:e,isLoading:t,focusedInputDialog:n,onSubmitMessage:r}){let i=r,a=Zd(),o=kf(),s=Z(e=>e.inbox.messages.length),c=A(),l=(0,Q.useCallback)(async()=>{if(!e)return;let r=a.getState(),s=PP(r);if(!s)return;let l=await Ba(s,r.teamContext?.teamName);if(l.length===0)return;if(J(`[InboxPoller] Found ${l.length} unread message(s)`),gi()&&xi())for(let e of l){let t=Ld(e.text);if(t&&e.from===`team-lead`)if(J(`[InboxPoller] Received plan approval response from team-lead: approved=${t.approved}`),t.approved){let e=t.permissionMode??`default`;o(t=>({...t,toolPermissionContext:Op(t.toolPermissionContext,{type:`setMode`,mode:Et(e),destination:`session`})})),J(`[InboxPoller] Plan approved by team lead, exited plan mode to ${e}`)}else J(`[InboxPoller] Plan rejected by team lead: ${t.feedback||`No feedback provided`}`);else t&&J(`[InboxPoller] Ignoring plan approval response from non-team-lead: ${e.from}`)}let u=()=>{eo(s,r.teamContext?.teamName)},d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=[],b=[];for(let e of l){let t=md(e.text),n=Dg(e.text),r=$g(e.text),i=xl(e.text),a=Vg(e.text),o=ka(e.text),s=Al(e.text),c=Qf(e.text),l=f_(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&&hi(r.teamContext)){J(`[InboxPoller] Found ${d.length} permission request(s)`);let e=Ds(),i=r.teamContext?.teamName;for(let t of d){let n=md(t.text);if(n)if(e){let t=B_(od(),n.tool_name);if(!t){J(`[InboxPoller] Unknown tool ${n.tool_name}, skipping permission request`);continue}let r={assistantMessage:fp({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(){nf(n.agent_id,{decision:`rejected`,resolvedBy:`leader`},n.request_id,i)},onAllow(e,t){nf(n.agent_id,{decision:`approved`,resolvedBy:`leader`,updatedInput:e,permissionUpdates:t},n.request_id,i)},onReject(e){nf(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 J(`[InboxPoller] ToolUseConfirmQueue unavailable, dropping permission request from ${n.agent_id}`)}let a=md(d[0]?.text??``);a&&!t&&!n&&To({message:`${a.agent_id} needs permission for ${a.tool_name}`,notificationType:`worker_permission_prompt`},c)}if(f.length>0&&gi()){J(`[InboxPoller] Found ${f.length} permission response(s)`);for(let e of f){let t=Dg(e.text);t&&Yi(t.request_id)&&(J(`[InboxPoller] Processing permission response for ${t.request_id}: ${t.subtype}`),t.subtype===`success`?Em({requestId:t.request_id,decision:`approved`,updatedInput:t.response?.updated_input,permissionUpdates:t.response?.permission_updates}):Em({requestId:t.request_id,decision:`rejected`,feedback:t.error}))}}if(p.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${p.length} sandbox permission request(s)`);let e=[];for(let t of p){let n=$g(t.text);if(n){if(!n.hostPattern?.host){J(`[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&&To({message:`${r.workerName} needs network access to ${r.host}`,notificationType:`worker_permission_prompt`},c)}}if(m.length>0&&gi()){J(`[InboxPoller] Found ${m.length} sandbox permission response(s)`);for(let e of m){let t=xl(e.text);t&&bf(t.requestId)&&(J(`[InboxPoller] Processing sandbox permission response for ${t.requestId}: allow=${t.allow}`),kh({requestId:t.requestId,host:t.host,allow:t.allow}),o(e=>({...e,pendingSandboxRequest:null})))}}if(_.length>0&&gi()){J(`[InboxPoller] Found ${_.length} team permission update(s)`);for(let e of _){let t=Al(e.text);if(!t){J(`[InboxPoller] Failed to parse team permission update: ${e.text.substring(0,100)}`);continue}if(!t.permissionUpdate?.rules||!t.permissionUpdate?.behavior){J(`[InboxPoller] Invalid team permission update: missing permissionUpdate.rules or permissionUpdate.behavior`);continue}J(`[InboxPoller] Applying team permission update: ${t.toolName} allowed in ${t.directoryPath}`),J(`[InboxPoller] Permission update rules: ${hr(t.permissionUpdate.rules)}`),o(e=>{let n=Op(e.toolPermissionContext,{type:`addRules`,rules:t.permissionUpdate.rules,behavior:t.permissionUpdate.behavior,destination:`session`});return J(`[InboxPoller] Updated session allow rules: ${hr(n.alwaysAllowRules.session)}`),{...e,toolPermissionContext:n}})}}if(v.length>0&&gi()){J(`[InboxPoller] Found ${v.length} mode set request(s)`);for(let e of v){if(e.from!==`team-lead`){J(`[InboxPoller] Ignoring mode set request from non-team-lead: ${e.from}`);continue}let t=Qf(e.text);if(!t){J(`[InboxPoller] Failed to parse mode set request: ${e.text.substring(0,100)}`);continue}let n=un(t.mode);J(`[InboxPoller] Applying mode change from team-lead: ${n}`),o(e=>({...e,toolPermissionContext:Op(e.toolPermissionContext,{type:`setMode`,mode:Et(n),destination:`session`})}));let i=r.teamContext?.teamName,a=vi();i&&a&&Wv(i,a,n)}}if(y.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${y.length} plan approval request(s), auto-approving`);let e=r.teamContext?.teamName,t=Et(r.toolPermissionContext.mode),n=t===`plan`?`default`:t;for(let t of y){let i=f_(t.text);if(!i)continue;let a={type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n};Wp(t.from,{from:fy,text:hr(a),timestamp:new Date().toISOString()},e);let s=Ef(t.from,r);s&&cg(s,{type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n},o),J(`[InboxPoller] Auto-approved plan from ${t.from} (request ${i.requestId})`),b.push(t)}}if(h.length>0&&gi()){J(`[InboxPoller] Found ${h.length} shutdown request(s)`);for(let e of h)b.push(e)}if(g.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${g.length} shutdown approval(s)`);for(let e of g){let t=ka(e.text);if(!t)continue;t.paneId&&t.backendType&&(async()=>{try{await Sc();let e=await Cy(),n=await Up(t.backendType)?.killPane(t.paneId,!e);J(`[InboxPoller] Killed pane ${t.paneId} for ${t.from}: ${n}`)}catch(e){J(`[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&&Hv(t,{agentId:e,name:n});let{notificationMessage:i}=t?await Rv(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))jp(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:zS(),from:`system`,text:hr({type:`teammate_terminated`,message:i}),timestamp:new Date().toISOString(),status:`pending`}]}}}),J(`[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`<${Gr} teammate_id="${e.from}"${t}${n}>\n${r}\n</${Gr}>`}).join(`
82
+ `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,ml(1),n(!1)},onError:e=>{J(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}P_(),q(),Lg();function hN({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(cN(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=sN(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useSSHSession] permission request: ${e.tool_name}`);let a=B_(l.current,e.tool_name)??$M(e.tool_name),o=QM(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{J(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:zS(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{J(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal `+e.proc.signalCode}):\n${t}`),ml(1,`other`,{finalMessage:a})},onError:e=>{J(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}q(),Qv();async function gN(e){let{accessToken:t,orgUUID:n}=await Zv();return{baseUrl:`${Nr().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...Yv(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function _N(e,t,n){let r=await m.get(e.baseUrl,{headers:e.headers,params:t,timeout:15e3,validateStatus:()=>!0}).catch(()=>null);return!r||r.status!==200?(J(`[${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 vN(e,t=100){return _N(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function yN(e,t,n=100){return _N(e,{limit:n,before_id:t},`fetchOlderEvents`)}q();var bN=40,xN=10,SN=`loading older messages…`,CN=`failed to load older messages — scroll up to retry`,wN=`start of session`;function TN(e){let t=[];for(let n of e.events){let e=sN(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function EN({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)(zS());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=TN(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(wN);t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return o?[o,...i,...t]:[...i,...t]}),J(`[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 gN(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await vN(n);t||!r||(l.current=xN,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(SN),...t]});try{let r=await yN(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(CN),...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();J(`[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()<bN&&p()},[p])}}Vi();var DN=400;function ON({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=DN}){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=Ui(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 kN=[`0`,`1`,`2`,`3`],AN={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},jN=e=>kN.includes(e),MN=`How is Claude doing this session? (optional)`;function NN({onSelect:e,inputValue:t,setInputValue:n,message:r=MN}){return ON({inputValue:t,setInputValue:n,isValidDigit:jN,onDigit:t=>e(AN[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(R,{bold:!0,children:r})]}),(0,$.jsxs)(U,{marginLeft:2,children:[(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}en(),H(),Vi();function PN({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!jN(i)?null:(0,$.jsx)(LN,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var FN=[`0`,`1`];function IN(e){return FN.includes(e)}function LN({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=Ui(r.slice(-1));IN(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)(R,{color:`ansi:cyan`,children:[Fn,` `]}),(0,$.jsxs)(R,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(U,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(R,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(U,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(U,{width:12,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(U,{width:14,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Cr(),X(),ql();function RN(e){let t=Z(e=>e.skillImprovement.suggestion),n=Af(),[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&&wS(r.skillName,r.updates).then(()=>{e(e=>[...e,Na(`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 zN(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Ff(),_g(),Wf(),Xp();function BN(e){(0,Q.useEffect)(()=>{let t=()=>{Xt()&&process.stdout.write(`
83
+ `+Wa()+`
84
+ `),Lp(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function VN(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&c(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function HN(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])}ot(),fg(),Wn();function UN(){let[e,t]=(0,Q.useState)(()=>{if(!Cn()||Dn())return`valid`;let{key:e,source:t}=Vt({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Cn()||Dn()){t(`valid`);return}await fn(Ze());let{key:e,source:n}=Vt();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 Jm(e,!1)?`valid`:`invalid`);return}catch(e){r(e),t(`error`);return}},[]),error:n}}ot(),H(),wr(),q(),H(),ty(),an(),Cr(),X(),Ci();function WN({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=Z(e=>e.expandedView),d=Af(),f=(0,Q.useCallback)(()=>{Y(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(t=>{let{getAllInProcessTeammateTasks:n}=(kh(),e(ra));if(mi(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=Z(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(oh(),e(Hf));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}=(oh(),e(Hf));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]);we(`app:toggleTodos`,f,{context:`Global`}),we(`app:toggleTranscript`,m,{context:`Global`}),we(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),we(`app:toggleTeammatePreview`,()=>{d(e=>({...e,showTeammateMessagePreview:!e.showTeammateMessagePreview}))},{context:`Global`}),we(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),we(`app:redraw`,(0,Q.useCallback)(()=>{te.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return we(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),we(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Hh(),Gp(),ty();var GN={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function KN({onSubmit:e,isActive:t=!0}){let n=pe(),r=Hd(),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 V((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,GN,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Cr(),X(),Wx(),Rm(),Hh(),Np(),ty(),rS(),fa(),Ss();var qN=3e3;function JN(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=ef(),g=Af(),_=pD().length,{addNotification:v,removeNotification:y}=Bh(),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){Y(`tengu_cancel`,e),t(()=>[]),n();return}if(Co()&&s){s();return}Y(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),C=rm(),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&&!(Vx()&&c===`INSERT`),k=O&&(w||T)&&!E&&!D,A=O&&(w||T||D);we(`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;oc(e,g);let n=[];for(let[e,r]of t)Mc(e,g),n.push(r.description),hv(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return _a({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 we(`app:interrupt`,(0,Q.useCallback)(()=>{D&&(j(),lS(g)),(w||T)&&S()},[D,j,g,w,T,S]),{context:`Global`,isActive:A}),we(`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<=qN){b.current=0,y(`kill-agents-confirm`),Y(`tengu_cancel`,{source:`kill_agents`}),Xo(),j();return}b.current=t,v({key:`kill-agents-confirm`,text:`Press ${oa(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`)} again to stop background agents`,priority:`immediate`,timeoutMs:qN})},[h,v,y,j]),{context:`Chat`}),null}H(),X(),rS(),kh(),Gh();function YN(e,t){t(t=>{let n=Om(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 XN(e){let t=Z(e=>e.tasks),n=Z(e=>e.viewSelectionMode),r=Z(e=>e.viewingAgentTaskId),i=Z(e=>e.selectedIPAgentIndex),a=Z(e=>e.pipeIpc),o=Af(),s=Om(t),c=s.length,l=Object.values(t).some(e=>Gd(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=Om(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(Kp(n)&&n.status===`running`){n.currentWorkAbortController?.abort();return}}lS(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?YN(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&&sS(e.taskId,o);return}if(s.key===`return`&&n===`selecting-agent`){if(s.preventDefault(),i===-1)lS(o);else if(i>=c)o(e=>({...e,expandedView:`none`,viewSelectionMode:`none`,selectedIPAgentIndex:-1}));else{let e=d();e&&sS(e.taskId,o)}return}if(s.key===`k`&&n===`selecting-agent`&&i>=0){s.preventDefault();let e=d();e&&e.task.status===`running`&&Zc.kill(e.taskId,o);return}};return Oe((e,t,n)=>{f(new Ae(n.keypress))}),{handleKeyDown:f}}q(),lo(),fr(),_i(),fp(),Bv();function ZN(e,t,n){let{teamName:r,agentId:i,agentName:a}=n,o=Kv(r);if(!o){J(`[TeammateInit] Team file not found for team: ${r}`);return}let s=o.leadAgentId;if(o.teamAllowedPaths&&o.teamAllowedPaths.length>0){J(`[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}/**`;J(`[TeammateInit] Applying team permission: ${t.toolName} allowed in ${t.path} (rule: ${n})`),e(e=>({...e,toolPermissionContext:jp(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){J(`[TeammateInit] This agent is the team leader - skipping idle notification hook`);return}J(`[TeammateInit] Registering Stop hook for teammate ${a} to notify leader ${c}`),ju(e,t,`Stop`,``,async(e,t)=>(Gv(r,a,!1),await Jp(c,{from:a,text:hr(If(a,{idleReason:`available`,summary:_m(e)})),timestamp:new Date().toISOString(),color:yi()}),J(`[TeammateInit] Sent idle notification to leader ${c}`),!0),`Failed to send idle notification to team leader`,{timeout:1e4})}ot(),Yn(),Bv(),_i();function QN(e,t,{enabled:n=!0}={}){(0,Q.useEffect)(()=>{if(n&&Nn()){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){_S(e,r,i);let t=Kv(r)?.members.find(e=>e.name===i);t&&ZN(e,Fe(),{teamName:r,agentId:t.agentId,agentName:i})}else{let t=bi?.();t?.teamName&&t?.agentId&&t?.agentName&&ZN(e,Fe(),{teamName:t.teamName,agentId:t.agentId,agentName:t.agentName})}}},[e,t,n])}X(),rS(),pc();function $N(){let e=Af(),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.viewingAgentTaskId?e.tasks[e.viewingAgentTaskId]:void 0),r=n&&Kp(n)?n:void 0,i=r?.status,a=r?.error,o=n!==void 0;(0,Q.useEffect)(()=>{if(t){if(!o){lS(e);return}if(r&&(i===`killed`||i===`failed`||a||i!==`running`&&i!==`completed`&&i!==`pending`)){lS(e);return}}},[t,o,r,i,a,e])}Xx(),Zr();async function eP(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?Qr(e):Qr(Error(`Automated permission check failed: ${String(e)}`))}return null}By(),Ky();var tP=new Map,nP=null,rP=!1;function iP(){return nP??null}function aP(e,t){if(rP)return null;let n=iP();if(!n)return null;let r=zS(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return tP.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function oP(e){e&&tP.delete(e)}function sP(e,t){if(!e||rP)return;let n=iP();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Cr(),Ht(),xd(),q(),Ma(),ql(),lo(),as();function cP(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 lP(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(){Y(`tengu_tool_use_cancelled`,{messageID:s,toolName:hn(e.name)})},async persistPermissions(e){return e.length===0?!1:(js(e),a(Hs(n.getAppState().toolPermissionContext,e)),e.some(e=>$c(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?Qh:jd}${t}`:a?Km:Op,s=a?o:qm(o);return(r||!t&&!i?.length&&!a)&&(J(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of bh(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(J(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function uP(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))}}}Xr(),q(),ot(),H(),xd(),Dh(),gr();function dP(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(`
85
+ `):``}function fP(e){let t=e.match(RegExp(`<${Hr}\\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 pP(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=fP(dP(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 mP(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o,channelCallbacks:s}=e,{resolve:c,isResolved:l,claim:u}=cP(t),d,f,p=o?zS():void 0,m,h=Date.now(),g=i.updatedInput??n.input,_=null;function v(e){sP(_,e),oP(_),_=null}function y(){oP(_),_=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||Em(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 bo(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),_=aP(b,e=>{u()&&(y(),Em(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),Em(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=qy(n.toolUseID),t=xt(),i=Uy(n.toolUseContext.getAppState().mcp.clients,e=>Hy(e,t)!==void 0);if(i.length>0){let t={request_id:e,tool_name:n.tool.name,description:r,input_preview:Wy(g)},a=pP(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:Vy,params:t}).catch(t=>{J(`Channel permission_request failed for ${e.name}: ${Sr(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?.(),Em(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))})()}Yn(),gr(),Zr();async function hP(e){if(!Nn()||!qh())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}=cP(r),s=Cp({toolName:t.tool.name,toolUseId:t.toolUseID,input:t.input,description:n,permissionSuggestions:i});km({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)))}}),qd(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 Qr(mr(e)),null}}Cr(),Ht(),H(),xd(),Dh(),q(),gr(),Zr(),vs(),fr(),as();function gP(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let u=lP(n,r,i,a,o,t,uP(e));if(!u.resolveIfAborted(c))return(s===void 0?bo(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Y(`tengu_internal_tool_permission_decision`,{toolName:hn(n.name),behavior:e.behavior,input:hr(r),messageID:u.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(u.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&yp(o,e.decisionReason.reason),u.logDecision({decision:`accept`,source:`config`}),c(u.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(!u.resolveIfAborted(c))switch(e.behavior){case`deny`:Vu({tool:n,input:r,toolUseContext:i,messageId:u.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Zx({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)(R,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:{if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await eP({ctx:u,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(u.resolveIfAborted(c))return;let n=await hP({ctx:u,description:a,updatedInput:e.updatedInput,suggestions:e.suggestions});if(n){c(n);return}mP({ctx:u,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks,channelCallbacks:t.channelPermissionCallbacks},c);return}}}).catch(e=>{e instanceof br||e instanceof l?(J(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),u.logCancelled(),c(u.cancelAndAbort(void 0,!0))):(Qr(e),c(u.cancelAndAbort(void 0,!0)))}).finally(()=>{Em(o)})}),[e,t])}pv(),Cr(),Dm(),Cs(),wr(),q(),Lg(),gr(),Zr(),Ss(),$t();function _P(){Ea(0)}async function vP(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){mf(),await yP({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(cs(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(Do);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?vP({...e,input:`/exit`}):_P();return}let j=nu(T,k),M=cs(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Y(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Xf(e)&&(e.name===f||e.aliases?.includes(f)||lp(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Y(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Ki(),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?h_({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(J(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Y(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),h_({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}mf(),await yP({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 yP(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=Ki();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),xg(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await dm(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 Rn(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await ob({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(xg(`query_process_user_input_end`),Ll()&&(xg(`query_file_history_snapshot_start`),s.filter(ab).forEach(e=>{bc(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),xg(`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?pn(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?h_({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 op({commands:e,outcome:{type:`failed`,error:A},currentDir:Tr(),priority:`later`,workload:O})}catch(e){Qr(mr(e))}else try{let t=await op({commands:e,outcome:{type:`completed`},currentDir:Tr(),priority:`later`,workload:O});for(let e of t)h_(e)}catch(e){Qr(mr(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}Ss();function bP(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 xP({executeInput:e}){let t=e=>e.agentId===void 0,n=Hu(t);if(!n)return{processed:!1};if(bP(n)||n.mode===`bash`)return e([Ns(t)]),{processed:!0};let r=n.mode,i=tl(e=>t(e)&&!bP(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Ss();function SP({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Lc,Vl);(0,Q.useEffect)(()=>{r||t||i.length!==0&&xP({executeInput:e})},[i,r,e,t,n])}function CP({isLoading:e,onSubmitMessage:t}){let n=Yg();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function wP(e,t){return e&&t&&t.length>0?zn([...e,...t],`name`):e||[]}function TP(e,t){return(0,Q.useMemo)(()=>wP(e,t),[e,t])}fu(),ib(),Ab(),Sn();function EP(e,t){return(0,Q.useMemo)(()=>t.length>0?zn([...e,...t],`name`):e,[e,t])}Dm(),an(),Zr();function DP(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Ao(),t(await ad(e))}catch(e){e instanceof Error&&Qr(e)}},[e,t]);(0,Q.useEffect)(()=>bb.subscribe(n),[n]);let r=(0,Q.useCallback)(async()=>{if(e)try{yu(),t(await ad(e))}catch(e){e instanceof Error&&Qr(e)}},[e,t]);(0,Q.useEffect)(()=>nr(r),[r])}H(),am(),X(),ud();function OP(){let e=Z(e=>Ru(e));if(!e)return null;let t=gg(e.identity.color);return(0,$.jsx)(sg,{children:(0,$.jsxs)(U,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{children:`Viewing `}),(0,$.jsxs)(R,{color:t,bold:!0,children:[`@`,e.identity.agentName]}),(0,$.jsxs)(R,{dimColor:!0,children:[` · `,(0,$.jsx)(he,{shortcut:`esc`,action:`return`})]})]}),(0,$.jsx)(R,{dimColor:!0,children:e.prompt})]})})}Zr(),w(),ma(),Ii();var kP=Fi(()=>b({method:v(`selection_changed`),params:b({selection:b({start:b({line:g(),character:g()}),end:b({line:g(),character:g()})}).nullable().optional(),text:_().optional(),filePath:_().optional()})}));function AP(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Il(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(kP(),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){Qr(e)}}),n.current=!0},[e,t])}tc(),Kh(),H(),wh(),X(),Pi();function jP({task:e,selected:t}){let n=_s(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)(R,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(R,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(R,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(U,{flexShrink:0,children:(0,$.jsxs)(R,{dimColor:!0,children:[n,` · ↓ `,ki(r),` tokens`]})})]})}function MP(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 NP(){let e=pO(),t=Z(e=>e.viewingAgentTaskId),n=Z(e=>e.footerSelection),r=Z(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)(R,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(R,{dimColor:!0,children:MP(i,s)})]}),e.map(e=>(0,$.jsx)(jP,{task:e,selected:e.agentId===a},e.agentId))]})}O(),Xr(),H(),hu(),X(),P_(),pc(),q(),ql(),sn(),lo(),fr(),wy(),nc(),py(),Oo(),Vm(),Bv(),Lv(),_i(),fi(),fp(),Yi();function PP(e){if(!Si()){if(gi())return vi();if(hi(e.teamContext)){let t=e.teamContext.leadAgentId;return e.teamContext.teammates[t]?.name||`team-lead`}}}var FP=1e3;function IP({enabled:e,isLoading:t,focusedInputDialog:n,onSubmitMessage:r}){let i=r,a=ef(),o=Af(),s=Z(e=>e.inbox.messages.length),c=A(),l=(0,Q.useCallback)(async()=>{if(!e)return;let r=a.getState(),s=PP(r);if(!s)return;let l=await Va(s,r.teamContext?.teamName);if(l.length===0)return;if(J(`[InboxPoller] Found ${l.length} unread message(s)`),gi()&&xi())for(let e of l){let t=zd(e.text);if(t&&e.from===`team-lead`)if(J(`[InboxPoller] Received plan approval response from team-lead: approved=${t.approved}`),t.approved){let e=t.permissionMode??`default`;o(t=>({...t,toolPermissionContext:jp(t.toolPermissionContext,{type:`setMode`,mode:Et(e),destination:`session`})})),J(`[InboxPoller] Plan approved by team lead, exited plan mode to ${e}`)}else J(`[InboxPoller] Plan rejected by team lead: ${t.feedback||`No feedback provided`}`);else t&&J(`[InboxPoller] Ignoring plan approval response from non-team-lead: ${e.from}`)}let u=()=>{eo(s,r.teamContext?.teamName)},d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=[],b=[];for(let e of l){let t=_d(e.text),n=Og(e.text),r=$g(e.text),i=yl(e.text),a=Hg(e.text),o=ka(e.text),s=Ol(e.text),c=$f(e.text),l=u_(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&&hi(r.teamContext)){J(`[InboxPoller] Found ${d.length} permission request(s)`);let e=_u(),i=r.teamContext?.teamName;for(let t of d){let n=_d(t.text);if(n)if(e){let t=B_(Yu(),n.tool_name);if(!t){J(`[InboxPoller] Unknown tool ${n.tool_name}, skipping permission request`);continue}let r={assistantMessage:mp({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(){om(n.agent_id,{decision:`rejected`,resolvedBy:`leader`},n.request_id,i)},onAllow(e,t){om(n.agent_id,{decision:`approved`,resolvedBy:`leader`,updatedInput:e,permissionUpdates:t},n.request_id,i)},onReject(e){om(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 J(`[InboxPoller] ToolUseConfirmQueue unavailable, dropping permission request from ${n.agent_id}`)}let a=_d(d[0]?.text??``);a&&!t&&!n&&Eo({message:`${a.agent_id} needs permission for ${a.tool_name}`,notificationType:`worker_permission_prompt`},c)}if(f.length>0&&gi()){J(`[InboxPoller] Found ${f.length} permission response(s)`);for(let e of f){let t=Og(e.text);t&&rd(t.request_id)&&(J(`[InboxPoller] Processing permission response for ${t.request_id}: ${t.subtype}`),t.subtype===`success`?Cf({requestId:t.request_id,decision:`approved`,updatedInput:t.response?.updated_input,permissionUpdates:t.response?.permission_updates}):Cf({requestId:t.request_id,decision:`rejected`,feedback:t.error}))}}if(p.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${p.length} sandbox permission request(s)`);let e=[];for(let t of p){let n=$g(t.text);if(n){if(!n.hostPattern?.host){J(`[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&&Eo({message:`${r.workerName} needs network access to ${r.host}`,notificationType:`worker_permission_prompt`},c)}}if(m.length>0&&gi()){J(`[InboxPoller] Found ${m.length} sandbox permission response(s)`);for(let e of m){let t=yl(e.text);t&&Vc(t.requestId)&&(J(`[InboxPoller] Processing sandbox permission response for ${t.requestId}: allow=${t.allow}`),og({requestId:t.requestId,host:t.host,allow:t.allow}),o(e=>({...e,pendingSandboxRequest:null})))}}if(_.length>0&&gi()){J(`[InboxPoller] Found ${_.length} team permission update(s)`);for(let e of _){let t=Ol(e.text);if(!t){J(`[InboxPoller] Failed to parse team permission update: ${e.text.substring(0,100)}`);continue}if(!t.permissionUpdate?.rules||!t.permissionUpdate?.behavior){J(`[InboxPoller] Invalid team permission update: missing permissionUpdate.rules or permissionUpdate.behavior`);continue}J(`[InboxPoller] Applying team permission update: ${t.toolName} allowed in ${t.directoryPath}`),J(`[InboxPoller] Permission update rules: ${hr(t.permissionUpdate.rules)}`),o(e=>{let n=jp(e.toolPermissionContext,{type:`addRules`,rules:t.permissionUpdate.rules,behavior:t.permissionUpdate.behavior,destination:`session`});return J(`[InboxPoller] Updated session allow rules: ${hr(n.alwaysAllowRules.session)}`),{...e,toolPermissionContext:n}})}}if(v.length>0&&gi()){J(`[InboxPoller] Found ${v.length} mode set request(s)`);for(let e of v){if(e.from!==`team-lead`){J(`[InboxPoller] Ignoring mode set request from non-team-lead: ${e.from}`);continue}let t=$f(e.text);if(!t){J(`[InboxPoller] Failed to parse mode set request: ${e.text.substring(0,100)}`);continue}let n=un(t.mode);J(`[InboxPoller] Applying mode change from team-lead: ${n}`),o(e=>({...e,toolPermissionContext:jp(e.toolPermissionContext,{type:`setMode`,mode:Et(n),destination:`session`})}));let i=r.teamContext?.teamName,a=vi();i&&a&&Wv(i,a,n)}}if(y.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${y.length} plan approval request(s), auto-approving`);let e=r.teamContext?.teamName,t=Et(r.toolPermissionContext.mode),n=t===`plan`?`default`:t;for(let t of y){let i=u_(t.text);if(!i)continue;let a={type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n};Jp(t.from,{from:fy,text:hr(a),timestamp:new Date().toISOString()},e);let s=kf(t.from,r);s&&dg(s,{type:`plan_approval_response`,requestId:i.requestId,approved:!0,timestamp:new Date().toISOString(),permissionMode:n},o),J(`[InboxPoller] Auto-approved plan from ${t.from} (request ${i.requestId})`),b.push(t)}}if(h.length>0&&gi()){J(`[InboxPoller] Found ${h.length} shutdown request(s)`);for(let e of h)b.push(e)}if(g.length>0&&hi(r.teamContext)){J(`[InboxPoller] Found ${g.length} shutdown approval(s)`);for(let e of g){let t=ka(e.text);if(!t)continue;t.paneId&&t.backendType&&(async()=>{try{await $a();let e=await Cy(),n=await Ba(t.backendType)?.killPane(t.paneId,!e);J(`[InboxPoller] Killed pane ${t.paneId} for ${t.from}: ${n}`)}catch(e){J(`[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&&Hv(t,{agentId:e,name:n});let{notificationMessage:i}=t?await Rv(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))Kp(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:zS(),from:`system`,text:hr({type:`teammate_terminated`,message:i}),timestamp:new Date().toISOString(),status:`pending`}]}}}),J(`[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`<${Gr} teammate_id="${e.from}"${t}${n}>\n${r}\n</${Gr}>`}).join(`
86
86
 
87
87
  `),S=()=>{o(e=>({...e,inbox:{messages:[...e.inbox.messages,...b.map(e=>({id:zS(),from:e.from,text:e.text,timestamp:e.timestamp,status:`pending`,color:e.color,summary:e.summary}))]}}))};!t&&!n?(J(`[InboxPoller] Session idle, submitting immediately`),i(x)||(J(`[InboxPoller] Submission rejected, queuing for later delivery`),S())):(J(`[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(!PP(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){J(`[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(J(`[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(`
88
88
 
89
- `))){let e=new Set(s.map(e=>e.id));o(t=>({...t,inbox:{messages:t.inbox.messages.filter(t=>!e.has(t.id))}}))}else J(`[InboxPoller] Submission rejected, keeping messages queued`)},[e,t,n,i,o,s,a]),se(()=>void l(),e&&PP(a.getState())?FP:null);let u=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{e&&(u.current||PP(a.getState())&&(u.current=!0,l()))},[e,l,a])}q(),Lv();var LP=1e3;function RP({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 Nv(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)J(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=zP(t);if(!n)return;J(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await jv(e,n.id,c);if(!i.success){J(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=BP(n);J(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(J(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await Mv(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;Av(e);let t=Iv(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),LP,l)};u.current=r;try{n=LS(t,r),n.unref(),J(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){J(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function zP(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 BP(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}lr(),s(),fa();function VP({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:i}){(0,Q.useEffect)(()=>{function o(r){r&&(En().autoConnectIde||e||vo()||process.env.CLAUDE_CODE_SSE_PORT||t||c(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!a(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`}})}zp(o,t,()=>r(!0),e=>i(e))},[e,t,n,r,i])}yx(),uy(),H(),ty(),Ra(),X(),lr(),zr(),s();function HP({onBackgroundSession:e,isLoading:t}){let n=kf(),r=Zd(),[i,a]=(0,Q.useState)(!1),o=ne(a,e,()=>{}),s=(0,Q.useCallback)(()=>{c(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Oc(r.getState())?(Ga(()=>r.getState(),n),En().hasUsedBackgroundTask||kt(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):c(`false`)&&t&&o())},[n,r,t,o]),l=Z(Oc),u=c(`false`);we(`task:background`,s,{context:`Task`,isActive:l||u&&t});let d=bc(`task:background`,`Task`,`ctrl+b`),f=Vr.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:f,action:`background`})})})}X();function UP({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=Z(e=>e.foregroundedTaskId),o=Z(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=kf(),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}}su(),H(),Wn(),lr(),$t(),Gn(),Im(),dx(),Bb();var WP=3e4;function GP({model:e,onDone:t}){let n=Ug(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{YP()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,WP);return()=>clearTimeout(e)},[i]);let a=Og(e),o=a?gd(a):`high`,s=(0,Q.useCallback)(e=>{Bn(`userSettings`,{effortLevel:dc(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(qP,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(qP,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(qP,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(Hb,{title:n.dialogTitle,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(R,{children:n.dialogDescription})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[(0,$.jsx)(KP,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(KP,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(KP,{level:`high`}),` high`]})}),(0,$.jsx)(Sd,{options:c,onChange:s,onCancel:i})]})})}function KP({level:e}){return(0,$.jsx)(R,{color:`suggestion`,children:ox(e)})}function qP({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(KP,{level:e}),` `,t]})}function JP(e){if(!Ot(e).toLowerCase().includes(`opus-4-6`))return!1;let t=En();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(YP(),!1):dr()?t.effortCalloutDismissed?(YP(),!1):Ug().enabled:jn()||or()?Ug().enabled:(YP(),!1)}function YP(){kt(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}Gy(),Ub(),an();function XP(e,t){let[n,r]=Q.useState(t);return Q.useEffect(()=>{Mn(e,t).then(r)},[e,t]),n}async function ZP(e,t,n){try{J(`Collecting transcript for sharing`,{level:`info`});let r=Xc(e),i=await Qc(cf(e)),a;try{let e=da(),{size:t}=await VS(e);t<=52428800?a=await BS(e,`utf-8`):J(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=Bx(hr({trigger:t,version:`2.7.1`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await tn();let s=xn();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":cn(),...s.headers},l=await m.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return J(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return J(Sr(e),{level:`error`}),{success:!1}}}var QP=t((()=>{h(),Wn(),q(),gr(),ql(),ho(),fr()}));wn(),QP();function $P({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)(zS()),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=zS(),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])}}Cr(),lr(),s(),ql(),$t(),Gn();var eF={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},tF={probability:0};function nF(e,t,n,r=`session`,i=!1){let a=(0,Q.useRef)(`unknown`);a.current=fc(e)?.message?.id||`unknown`;let[o,s]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=XP(`tengu_feedback_survey_config`,eF),u=XP(`tengu_bad_survey_transcript_ask_config`,tF),d=XP(`tengu_good_survey_transcript_ask_config`,tF),f=Ut().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}),En().feedbackSurveyState?.lastShownTime!==e&&kt(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Y(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Y(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:a.current,survey_type:r}),yv(`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`||En().transcriptShareDismissed||!Ts(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Y(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:n}),yv(`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(Y(`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`&&kt(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await ZP(g.current,i,e);return Y(`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}=$P({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Pt(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!o.timeLastShown)return!0;if(!j||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||er()||!Ts(`allow_product_feedback`))return!1;if(o.timeLastShown){if(Date.now()-o.timeLastShown<l.minTimeBetweenFeedbackMs||o.submitCountAtLastAppearance!==null&&n<o.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=En().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,o.timeLastShown,o.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}wn(),an(),Cr(),pu(),lr(),s(),ql(),Sv(),QP();var rF=3e3,iF=`tengu_dunwich_bell`,aF=`tengu_memory_survey_event`,oF=.2,sF=`memory_survey`,cF=/\bmemor(?:y|ies)\b/i;function lF(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`&&Ms(e.file_path))return!0}}return!1}function uF(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:l,open:u,handleSelect:d,handleTranscriptSelect:f}=$P({hideThanksAfterMs:rF,onOpen:(0,Q.useCallback)(e=>{Y(aF,{event_type:`appeared`,appearance_id:e}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Y(aF,{event_type:`responded`,appearance_id:e,response:t}),yv(`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`||En().transcriptShareDismissed||!Ts(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Y(aF,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:sF}),yv(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Y(aF,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:sF}),t===`dont_ask_again`&&kt(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await ZP(o.current,sF,e);return Y(aF,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:sF}),t.success}return!1},[])}),p=(0,Q.useMemo)(()=>fc(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||!gn(iF,!1)||!Xn()||er()||!Ts(`allow_product_feedback`)||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||!p||i.current.has(p.uuid))return;let o=qp(Array.isArray(p.message.content)?p.message.content:[],` `);cF.test(o)&&(i.current.add(p.uuid),a.current||(a.current=lF(e)),a.current&&Math.random()<oF&&u())},[r,s,t,n,p,e,u]),{state:s,lastResponse:l,handleSelect:d,handleTranscriptSelect:f}}wn(),an(),Cr(),s(),ql(),Sv();var dF=3e3,fF=`tengu_post_compact_survey`,pF=.2;function mF(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 hF(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:l,lastResponse:u,open:d,handleSelect:f}=$P({hideThanksAfterMs:dF,onOpen:(0,Q.useCallback)(e=>{Y(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:ep()}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Y(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:ep()}),yv(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&a(Tn(fF))},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>xu(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||er()||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(s.current!==null&&mF(e,s.current)){s.current=null,Math.random()<pF&&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,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}en(),H();var gF=[`1`,`2`,`3`],_F={1:`yes`,2:`no`,3:`dont_ask_again`},vF=e=>gF.includes(e);function yF({onSelect:e,inputValue:t,setInputValue:n}){return ON({inputValue:t,setInputValue:n,isValidDigit:vF,onDigit:t=>e(_F[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsxs)(R,{color:`ansi:cyan`,children:[Fn,` `]}),(0,$.jsx)(R,{bold:!0,children:`Can Anthropic look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsx)(R,{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)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Cr(),H();function bF({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(SF,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(yF,{onSelect:r,inputValue:i,setInputValue:a}):i&&!jN(i)?null:(0,$.jsx)(NN,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var xF=e=>e===`1`;function SF({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;ON({inputValue:t,setInputValue:n,isValidDigit:xF,enabled:!!i,once:!0,onDigit:()=>{Y(`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)(R,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(R,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(R,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(R,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}mh(),bg(),ot(),Fm(),Zr();function CF(e){let{addNotification:t}=Lh(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{$e()||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(Qr))},[t])}function wF(){CF(async()=>(await df()).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`}}))}Er(),P_(),q(),ql(),$t(),Jd(),qx(),lg(),ot();var TF=30,EF=`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.`,DF=`用户离开后回来了。用中文写 1-3 句话。先说明用户在做什么(高层目标,不是实现细节),然后说明下一步具体操作。不要写状态报告或提交总结。`;function OF(e){return`${e?`Session memory (broader context):\n${e}\n\n`:``}${Kx()===`zh`?DF:EF}`}async function kF(e,t){if(e.length===0)return null;let n=qt(),r=Jm()?Vd({sessionId:Fe(),model:n,provider:Yt(),name:`away-summary`}):null;try{let i=await e_(),a=e.slice(-TF);a.push(ro({content:OF(i)}));let o=await Fh({messages:a,systemPrompt:dv([]),thinkingConfig:{type:`disabled`},tools:[],signal:t,options:{getToolPermissionContext:async()=>V_(),model:n,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,agents:[],querySource:`away_summary`,mcpTools:[],skipCacheWrite:!0,langfuseTrace:r}});return o.isApiErrorMessage?(J(`[awaySummary] API error: ${Lp(o)}`),Qp(r,void 0,`error`),null):(Qp(r),Lp(o))}catch(e){return e instanceof l||t.aborted?null:(J(`[awaySummary] generation failed: ${e}`),Qp(r,void 0,`error`),null)}}H(),an(),ql();var AF=5*6e4;function jF(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 MF(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=gn(`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,jF(a.current))return;n();let e=new AbortController;i.current=e;let r=await kF(a.current,e.signal);e.signal.aborted||r===null||t(e=>[...e,tp(r)])}function d(){if(r.current=null,o.current){s.current=!0;return}u()}function f(){let t=ue();t===`blurred`||t===`unknown`?(e(),r.current=setTimeout(d,AF)):t===`focused`&&(e(),n(),s.current=!1)}let p=P(f);return f(),c.current=u,()=>{p(),e(),n(),c.current=null}},[l,t]),(0,Q.useEffect)(()=>{if(n||!s.current)return;let e=ue();e!==`blurred`&&e!==`unknown`||c.current?.()},[n]),(0,Q.useEffect)(()=>{ue()===`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?.()},AF)))},[n,l])}H(),Wn(),Zb(),s();function NF(){if(process.argv.includes(`--chrome`))return!0;if(process.argv.includes(`--no-chrome`))return!1}function PF(){CF(async()=>{let e=NF();return Yb(e)?process.env.USER_TYPE!==`ant`&&!Dn()?{key:`chrome-requires-subscription`,jsx:(0,$.jsx)(R,{color:`error`,children:`Claude in Chrome requires a claude.ai subscription`}),priority:`immediate`,timeoutMs:5e3}:!await Xb()&&!i()?{key:`chrome-extension-not-detected`,jsx:(0,$.jsx)(R,{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})}an(),Cr(),lr(),q(),s(),gr(),Zr();function FF(){return c(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var IF={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function LF(e){let t=IF.INITIAL_DELAY_MS*IF.BACKOFF_MULTIPLIER**e;return Math.min(t,IF.MAX_DELAY_MS)}function RF(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>=IF.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function zF(){let e=En();if(!RF(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return J(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(FF())return J(`Official marketplace auto-install disabled via env var, skipping`),kt(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 _s())[`claude-plugins-official`])return J(`Official marketplace '${Gi}' already installed, skipping`),kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Nf(Cf))return J(`Official marketplace blocked by enterprise policy, skipping`),kt(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=Mo(),n=MS(t,Gi);if(await Oh(n,t)!==null){let e=await _s();return e[Gi]={source:Cf,installLocation:n,lastUpdated:new Date().toISOString()},await vf(e),kt(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(!gn(`tengu_plugin_official_mkt_git_fallback`,!0)){J(`Official marketplace GCS failed; git fallback disabled by flag — skipping install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+LF(t);return kt(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 ch()){J(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+LF(t),i=!1;try{kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Qr(mr(e)),J(`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}}J(`Attempting to auto-install official marketplace`),await ou(Cf),J(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return kt(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 Iu(),J(`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`};J(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Qr(mr(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+LF(r),o=!1;try{kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Qr(mr(e)),J(`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(),q();function BF(){CF(async()=>{let e=await zF(),t=[];return e.configSaveFailed&&(J(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(R,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(J(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(R,{color:`success`,children:`✓ Anthropic marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(J(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(R,{color:`warning`,children:`Failed to install Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Zr(),w(),Ii(),Cs();var VF=Fi(()=>b({method:v(`notifications/message`),params:b({prompt:_(),image:b({type:v(`base64`),media_type:y([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]),data:_()}).optional(),tabId:g().optional()})}));function HF(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(process.env.USER_TYPE!==`ant`)return;let t=UF(e);n.current!==t&&(n.current=t),t&&t.client.setNotificationHandler(VF(),e=>{if(n.current!==t)return;let{tabId:r,prompt:i,image:a}=e.params;if(!(typeof r!=`number`||!iy(r)))try{ha(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){Qr(e)}})},[e]),(0,Q.useEffect)(()=>{let n=UF(e);n&&xh(`set_permission_mode`,{mode:t===`bypassPermissions`?`skip_all_permission_checks`:`ask`},n)},[e,t])}function UF(e){return e.find(e=>e.type===`connected`&&e.name===`claude-in-chrome`)}Gn(),Cr();function WF(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vS(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function GF(e){if(Un().spinnerTipsEnabled===!1)return;let t=await xS(e);if(t.length!==0)return WF(t)}function KF(e){hS(e.id),Y(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}Nx(),gc();function qF(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!qa()||r.current||(r.current=!0,e&&Bp(e,n))},[t,e,n])}H(),oo(),Cr(),Im(),Bb();function JF({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`},...nl()?[]:[{label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(R,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(R,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Hb,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(Sd,{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(),oo(),ei();function YF(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function XF(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Gs.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Gs.isSandboxingEnabled()||$r()===`linux`||n===0?null:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(U,{marginLeft:0,children:(0,$.jsxs)(R,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[YF(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}gx(),Fm(),ot(),H();var ZF=[];function QF({mcpClients:e=ZF}){let{addNotification:t}=Lh();(0,Q.useEffect)(()=>{if($e())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`&&qu(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`&&qu(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)(R,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}H(),Gn(),wa();var $F=`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.`;O(),ot(),Fm(),H(),X(),q(),s();var eI=5e3;function tI(){let{addNotification:e}=Lh(),t=kf(),[n,r]=Q.useState(()=>c(`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),J(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),o=Q.useCallback(()=>{if($e()||Re())return;let e=cl();if(e.status===`failed`){a(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=y_();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&a(t,n.lastError.message)}},[a]);se(o,n?eI:null),Q.useEffect(()=>{$e()||!n||o()},[o,n])}q();var nI=new Map;async function rI(e){if(!e||!e.trim())return J(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=nI.get(t);if(n!==void 0)return J(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Lr(t).catch(()=>null)&&(r=!0),nI.set(t,r),J(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}lr(),q(),yh();var iI=5;function aI(e){return kn.has(e.toLowerCase())}function oI(e){if(!e)return null;if(typeof e==`string`)return J(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=cI(t);if(e)return e}return null}return cI(e)}function sI(e){return typeof e==`object`&&!!e}function cI(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!sI(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(sI(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function lI(){let e=new Map;try{let t=await _s();for(let n of Object.keys(t))try{let t=await Cu(n),r=aI(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=oI(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){J(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){J(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function uI(e){if(pI())return J(`[lspRecommendation] Recommendations are disabled`),[];let t=jS(e).toLowerCase();if(!t)return J(`[lspRecommendation] No file extension found`),[];J(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await lI(),r=En().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){J(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(ts(e)){J(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await rI(e.command)?(a.push({info:e,pluginId:t}),J(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):J(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function dI(e){kt(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),J(`[lspRecommendation] Added ${e} to never suggest`)}function fI(){kt(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),J(`[lspRecommendation] Incremented ignored count`)}function pI(){let e=En();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=iI}f(),ot(),H(),Zr(),yh();function mI(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{$e()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Qr).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function hI(e,t,n,r,i){try{let a=await js(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(R,{color:`success`,children:[p.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Qr(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(R,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}ot(),Fm(),X(),lr(),q(),Zr(),Gn();var gI=28e3;function _I(){let e=Z(e=>e.fileHistory.trackedFiles),{addNotification:t}=Lh(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=mI();return Q.useEffect(()=>{a(async()=>{if(it())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 uI(e))[0];if(t)return J(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),st(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:jS(e),shownAt:Date.now()}}catch(e){Qr(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(J(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:hI(n,a,`lsp-plugin`,t,async e=>{J(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?MS(e.marketplaceInstallLocation,e.entry.source):void 0;await Tl(n,e.entry,`user`,void 0,t),Bn(`userSettings`,{enabledPlugins:{...nn(`userSettings`)?.enabledPlugins,[n]:!0}}),J(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=gI&&(J(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),fI());break}case`never`:dI(n);break;case`disable`:kt(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}H(),Im(),Bb();var vI=3e4;function yI({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`),vI,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)(Hb,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,children:t})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(R,{children:[` `,n,` files`]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(Sd,{options:[{label:(0,$.jsxs)(R,{children:[`Yes, install `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(R,{children:[`Never for `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Fm(),Cr(),q(),Kg();function bI(){let e=Q.useSyncExternalStore(Fc,Np),{addNotification:t}=Lh(),{recommendation:n,clearRecommendation:r,tryResolve:i}=mI();return Q.useEffect(()=>{e&&i(async()=>{let t=await Va(e);return t&&(J(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),uc()),Np()===e&&ca(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(to(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;hI(e,r,`hint-plugin`,t,async t=>{let n=await Pl({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`:Hg();break;case`no`:break}r()}},[n,t,r])}}H(),Im(),Bb();var xI=3e4;function SI({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`),xI,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)(Hb,{title:`Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`The `,(0,$.jsx)(R,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(R,{children:[` `,n]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,children:t})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Would you like to install it?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(Sd,{options:[{label:(0,$.jsxs)(R,{children:[`Yes, install `,(0,$.jsx)(R,{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`)})})]})})}Im(),Bb();var CI=3e4;function wI({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(),CI,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)(Hb,{title:`Tool Recommendation`,children:(0,$.jsx)(Sd,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}ko();var TI=.15,EI=3;function DI(){let e=Q.useSyncExternalStore(ks,yu),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,EI).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)>=TI,handleSelect:Q.useCallback(e=>{Gl()},[]),handleDismiss:Q.useCallback(()=>{Gl()},[])}}ot(),Fm(),H(),X(),q(),Vi();function OI(){let{addNotification:e}=Lh(),t=Z(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(!$e()){if(!t){J(`No installation status to monitor`);return}n!==0&&(J(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(J(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[n,` `,Bi(n,`plugin`),` failed to install`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}ot(),Fm(),H(),q(),Jx();function kI(){let{addNotification:e}=Lh(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!$e())return Yx(e=>{J(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if($e()||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)(R,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(R,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),J(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}q(),Zr(),yh(),Sb(),Cr();function AI(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 jI(e){J(`performBackgroundPluginInstallations called`);try{let t=tb(Yl(),await _s().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;J(`Installing ${n.length} marketplace(s) in background`);let r=await Yy({onProgress:t=>{switch(t.type){case`installing`:AI(e,t.name,`installing`);break;case`installed`:AI(e,t.name,`installed`);break;case`failed`:AI(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),Dr(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Wo(),J(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await xb(e)}catch(t){Qr(t),J(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),vm(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Wo(),vm(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Qr(e)}}lr(),q(),yh(),Ag();async function MI(e){if(J(`performStartupChecks called`),!W()){J(`Trust not accepted for current directory - skipping plugin installations`);return}try{J(`Starting background plugin installations`),await $c()&&(Wo(),vm(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await jI(e)}catch(e){J(`Error initiating background plugin installations: ${e}`)}}H();var NI=/https?:\/\/\S+/;function PI(){let[e,t]=(0,Q.useState)(Wt.getInstance().getStatus());return(0,Q.useEffect)(()=>Wt.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)(R,{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(NI);if(!n)return(0,$.jsx)(R,{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)(R,{dimColor:!0,children:[a,(0,$.jsx)(re,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{color:`error`,children:e.error})})]})}Fm(),H(),wp(),Bh(),Wn(),In(),ot();function FI(e){let{addNotification:t}=Lh(),n=Ud(),r=(0,Q.useMemo)(()=>Um(n,e),[n,e]),i=(0,Q.useMemo)(()=>Kh(n),[n]),a=(0,Q.useRef)(null),o=Qn(),s=Mt(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{$e()||(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)(()=>{$e()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(R,{children:(0,$.jsx)(R,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Fm(),ot();function II(e){let{addNotification:t}=Lh(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if($e())return;let r=gS(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var LI=``;function RI(){CF(async()=>Fr()||c(process.env.DISABLE_INSTALLATION_CHECKS)||await wo()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:LI,color:`warning`,priority:`high`})}Fm(),H(),lr(),fa(),ot();var zI=5;function BI({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Lh(),{status:a,ideName:o}=FD(t),s=(0,Q.useRef)(!1),c=n?hc(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($e())return;if(vo()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(En().ideHintShownCount??0)>=zI)return;let e=setTimeout((e,t)=>{El(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,kt(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(R,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(R,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!$e()){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(!$e()){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(!$e()){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])}lr();var VI=[e=>{if(UI(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(UI(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 HI(){CF(()=>{let e=En(),t=[];for(let n of VI){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function UI(e){return e!==void 0&&Date.now()-e<3e3}Wn(),H(),Cr(),lr();var WI=3;function GI(){CF(async()=>{if((En().subscriptionNoticeCount??0)>=WI)return null;let e=await KI();return e===null?null:(kt(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Y(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(R,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`,(0,$.jsxs)(R,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function KI(){if(Dn())return null;let e=await _n();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}ot(),Fm(),X(),oa();function qI(e){if(!(`text`in e))return 1;let t=e.text.match(/^(\d+)/);return t?.[1]?parseInt(t[1],10):1}function JI(e,t){return YI(qI(e)+1)}function YI(e){return{key:`teammate-spawn`,text:e===1?`1 agent spawned`:`${e} agents spawned`,priority:`low`,timeoutMs:5e3,fold:JI}}function XI(e,t){return ZI(qI(e)+1)}function ZI(e){return{key:`teammate-shutdown`,text:e===1?`1 agent shut down`:`${e} agents shut down`,priority:`low`,timeoutMs:5e3,fold:XI}}function QI(){let e=Z(e=>e.tasks),{addNotification:t}=Lh(),n=(0,Q.useRef)(new Set),r=(0,Q.useRef)(new Set);(0,Q.useEffect)(()=>{if(!$e())for(let[i,a]of Object.entries(e))jp(a)&&(a.status===`running`&&!n.current.has(i)&&(n.current.add(i),t(YI(1))),a.status===`completed`&&!r.current.has(i)&&(r.current.add(i),t(ZI(1))))},[e,t])}Fm(),X(),tr(),Pi(),ot();var $I=`fast-mode-cooldown-started`,eL=`fast-mode-cooldown-expired`,tL=`fast-mode-org-changed`,nL=`fast-mode-overage-rejected`;function rL(){let{addNotification:e}=Lh(),t=Z(e=>e.fastMode),n=kf();(0,Q.useEffect)(()=>{if(!$e()&&ar())return Ft(r=>{r?e({key:tL,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:tL,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!$e()&&ar())return ln(t=>{n(e=>({...e,fastMode:!1})),e({key:nL,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if($e()||!t)return;let n=rr((t,n)=>{let r=iL(n,Ai(t-Date.now(),{hideTrailingZeros:!0}));e({key:$I,invalidates:[eL],text:r,color:`warning`,priority:`immediate`})}),r=At(()=>{e({key:eL,invalidates:[$I],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function iL(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(),ty();function aL({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return we(`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)(R,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,children:[`Press `,(0,$.jsx)(he,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,children:[`Reason: `,n]})})]})}function oL(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 sL(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function cL(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 lL=()=>null;en(),H();function uL(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(U,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(U,{minWidth:2,children:(0,$.jsx)(R,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(R,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(R,{dimColor:!0,children:` /issue to report it`})]})]}):null}G_(),ql();var dL=[/\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/],fL=[/^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 pL(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(dL.some(t=>t.test(e)))return!1}}}return!0}function mL(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=C_(n);if(r)return fL.some(e=>e.test(r))}return!1}var hL=3,gL=1800*1e3;function _L(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>pL(e)&&mL(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<gL||t<hL||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}ot(),H();function vL(){return process.env.USER_TYPE===`ant`}function yL(){let[e,t]=(0,Q.useState)(Ie);return ke(()=>{t(Ie())},vL()?500:null),!vL()||e.length===0?null:(0,$.jsxs)(R,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}f(),H(),ny(),Im(),ky(),X(),ot(),ix(),ql(),Cs(),Tu(),wr(),ri(),ho(),zh();var bL=24,xL=11;function SL(){return new Date().toISOString().split(`T`)[0]}function CL({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){fg(`ultraplan-choice`);let l=kf(),{rows:u,columns:d}=k(),f=Q.useMemo(()=>Math.min(bL,Math.max(1,Math.floor(u/2)-xL)),[u]),m=Q.useMemo(()=>ge(e,Math.max(1,d-4),`wrap`).split(`
89
+ `))){let e=new Set(s.map(e=>e.id));o(t=>({...t,inbox:{messages:t.inbox.messages.filter(t=>!e.has(t.id))}}))}else J(`[InboxPoller] Submission rejected, keeping messages queued`)},[e,t,n,i,o,s,a]),se(()=>void l(),e&&PP(a.getState())?FP:null);let u=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{e&&(u.current||PP(a.getState())&&(u.current=!0,l()))},[e,l,a])}q(),Lv();var LP=1e3;function RP({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 Nv(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)J(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=zP(t);if(!n)return;J(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await jv(e,n.id,c);if(!i.success){J(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=BP(n);J(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(J(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await Mv(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;Av(e);let t=Iv(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),LP,l)};u.current=r;try{n=LS(t,r),n.unref(),J(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){J(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function zP(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 BP(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}lr(),s(),ma();function VP({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:i}){(0,Q.useEffect)(()=>{function o(r){r&&(En().autoConnectIde||e||vo()||process.env.CLAUDE_CODE_SSE_PORT||t||c(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!a(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`}})}Hp(o,t,()=>r(!0),e=>i(e))},[e,t,n,r,i])}yx(),uy(),H(),ty(),za(),X(),lr(),zr(),s();function HP({onBackgroundSession:e,isLoading:t}){let n=Af(),r=ef(),[i,a]=(0,Q.useState)(!1),o=ne(a,e,()=>{}),s=(0,Q.useCallback)(()=>{c(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(io(r.getState())?(Pl(()=>r.getState(),n),En().hasUsedBackgroundTask||kt(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):c(`false`)&&t&&o())},[n,r,t,o]),l=Z(io),u=c(`false`);we(`task:background`,s,{context:`Task`,isActive:l||u&&t});let d=fc(`task:background`,`Task`,`ctrl+b`),f=Vr.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsx)(R,{dimColor:!0,children:(0,$.jsx)(he,{shortcut:f,action:`background`})})})}X();function UP({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=Z(e=>e.foregroundedTaskId),o=Z(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Af(),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}}lu(),H(),Wn(),lr(),$t(),Gn(),zm(),dx(),Bb();var WP=3e4;function GP({model:e,onDone:t}){let n=Wg(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{YP()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,WP);return()=>clearTimeout(e)},[i]);let a=kg(e),o=a?yd(a):`high`,s=(0,Q.useCallback)(e=>{Bn(`userSettings`,{effortLevel:ic(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(qP,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(qP,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(qP,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(Hb,{title:n.dialogTitle,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(R,{children:n.dialogDescription})}),(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[(0,$.jsx)(KP,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(KP,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(KP,{level:`high`}),` high`]})}),(0,$.jsx)(wd,{options:c,onChange:s,onCancel:i})]})})}function KP({level:e}){return(0,$.jsx)(R,{color:`suggestion`,children:ox(e)})}function qP({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(KP,{level:e}),` `,t]})}function JP(e){if(!Ot(e).toLowerCase().includes(`opus-4-6`))return!1;let t=En();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(YP(),!1):dr()?t.effortCalloutDismissed?(YP(),!1):Wg().enabled:jn()||or()?Wg().enabled:(YP(),!1)}function YP(){kt(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}Gy(),Ub(),an();function XP(e,t){let[n,r]=Q.useState(t);return Q.useEffect(()=>{Mn(e,t).then(r)},[e,t]),n}async function ZP(e,t,n){try{J(`Collecting transcript for sharing`,{level:`info`});let r=Gc(e),i=await qc(ff(e)),a;try{let e=da(),{size:t}=await VS(e);t<=52428800?a=await BS(e,`utf-8`):J(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=Bx(hr({trigger:t,version:`2.7.2`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await tn();let s=xn();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":cn(),...s.headers},l=await m.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return J(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return J(Sr(e),{level:`error`}),{success:!1}}}var QP=t((()=>{h(),Wn(),q(),gr(),ql(),go(),fr()}));wn(),QP();function $P({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)(zS()),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=zS(),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])}}Cr(),lr(),s(),ql(),$t(),Gn();var eF={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},tF={probability:0};function nF(e,t,n,r=`session`,i=!1){let a=(0,Q.useRef)(`unknown`);a.current=ac(e)?.message?.id||`unknown`;let[o,s]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=XP(`tengu_feedback_survey_config`,eF),u=XP(`tengu_bad_survey_transcript_ask_config`,tF),d=XP(`tengu_good_survey_transcript_ask_config`,tF),f=Ut().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}),En().feedbackSurveyState?.lastShownTime!==e&&kt(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Y(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Y(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:a.current,survey_type:r}),yv(`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`||En().transcriptShareDismissed||!ws(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Y(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:n}),yv(`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(Y(`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`&&kt(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await ZP(g.current,i,e);return Y(`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}=$P({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Pt(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!o.timeLastShown)return!0;if(!j||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||er()||!ws(`allow_product_feedback`))return!1;if(o.timeLastShown){if(Date.now()-o.timeLastShown<l.minTimeBetweenFeedbackMs||o.submitCountAtLastAppearance!==null&&n<o.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=En().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,o.timeLastShown,o.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}wn(),an(),Cr(),mu(),lr(),s(),ql(),Sv(),QP();var rF=3e3,iF=`tengu_dunwich_bell`,aF=`tengu_memory_survey_event`,oF=.2,sF=`memory_survey`,cF=/\bmemor(?:y|ies)\b/i;function lF(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`&&Eu(e.file_path))return!0}}return!1}function uF(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:l,open:u,handleSelect:d,handleTranscriptSelect:f}=$P({hideThanksAfterMs:rF,onOpen:(0,Q.useCallback)(e=>{Y(aF,{event_type:`appeared`,appearance_id:e}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Y(aF,{event_type:`responded`,appearance_id:e,response:t}),yv(`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`||En().transcriptShareDismissed||!ws(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Y(aF,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:sF}),yv(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Y(aF,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:sF}),t===`dont_ask_again`&&kt(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await ZP(o.current,sF,e);return Y(aF,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:sF}),t.success}return!1},[])}),p=(0,Q.useMemo)(()=>ac(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||!gn(iF,!1)||!Xn()||er()||!ws(`allow_product_feedback`)||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||!p||i.current.has(p.uuid))return;let o=Zp(Array.isArray(p.message.content)?p.message.content:[],` `);cF.test(o)&&(i.current.add(p.uuid),a.current||(a.current=lF(e)),a.current&&Math.random()<oF&&u())},[r,s,t,n,p,e,u]),{state:s,lastResponse:l,handleSelect:d,handleTranscriptSelect:f}}wn(),an(),Cr(),s(),ql(),Sv();var dF=3e3,fF=`tengu_post_compact_survey`,pF=.2;function mF(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 hF(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:l,lastResponse:u,open:d,handleSelect:f}=$P({hideThanksAfterMs:dF,onOpen:(0,Q.useCallback)(e=>{Y(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:tp()}),yv(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Y(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:tp()}),yv(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&a(Tn(fF))},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Cu(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||er()||c(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(s.current!==null&&mF(e,s.current)){s.current=null,Math.random()<pF&&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,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}en(),H();var gF=[`1`,`2`,`3`],_F={1:`yes`,2:`no`,3:`dont_ask_again`},vF=e=>gF.includes(e);function yF({onSelect:e,inputValue:t,setInputValue:n}){return ON({inputValue:t,setInputValue:n,isValidDigit:vF,onDigit:t=>e(_F[t])}),(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsxs)(R,{color:`ansi:cyan`,children:[Fn,` `]}),(0,$.jsx)(R,{bold:!0,children:`Can Anthropic look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(U,{marginLeft:2,children:(0,$.jsx)(R,{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)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(U,{width:10,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Cr(),H();function bF({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(SF,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(U,{marginTop:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(yF,{onSelect:r,inputValue:i,setInputValue:a}):i&&!jN(i)?null:(0,$.jsx)(NN,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var xF=e=>e===`1`;function SF({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;ON({inputValue:t,setInputValue:n,isValidDigit:xF,enabled:!!i,once:!0,onDigit:()=>{Y(`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)(R,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(R,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(R,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(R,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(R,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}hh(),Sg(),ot(),Rm(),Zr();function CF(e){let{addNotification:t}=Bh(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{$e()||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(Qr))},[t])}function wF(){CF(async()=>(await hf()).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`}}))}Er(),P_(),q(),ql(),$t(),Xd(),qx(),fg(),ot();var TF=30,EF=`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.`,DF=`用户离开后回来了。用中文写 1-3 句话。先说明用户在做什么(高层目标,不是实现细节),然后说明下一步具体操作。不要写状态报告或提交总结。`;function OF(e){return`${e?`Session memory (broader context):\n${e}\n\n`:``}${Kx()===`zh`?DF:EF}`}async function kF(e,t){if(e.length===0)return null;let n=qt(),r=Ym()?Vd({sessionId:Fe(),model:n,provider:Yt(),name:`away-summary`}):null;try{let i=await e_(),a=e.slice(-TF);a.push(ro({content:OF(i)}));let o=await Rh({messages:a,systemPrompt:dv([]),thinkingConfig:{type:`disabled`},tools:[],signal:t,options:{getToolPermissionContext:async()=>V_(),model:n,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,agents:[],querySource:`away_summary`,mcpTools:[],skipCacheWrite:!0,langfuseTrace:r}});return o.isApiErrorMessage?(J(`[awaySummary] API error: ${zp(o)}`),nm(r,void 0,`error`),null):(nm(r),zp(o))}catch(e){return e instanceof l||t.aborted?null:(J(`[awaySummary] generation failed: ${e}`),nm(r,void 0,`error`),null)}}H(),an(),ql();var AF=5*6e4;function jF(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 MF(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=gn(`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,jF(a.current))return;n();let e=new AbortController;i.current=e;let r=await kF(a.current,e.signal);e.signal.aborted||r===null||t(e=>[...e,np(r)])}function d(){if(r.current=null,o.current){s.current=!0;return}u()}function f(){let t=ue();t===`blurred`||t===`unknown`?(e(),r.current=setTimeout(d,AF)):t===`focused`&&(e(),n(),s.current=!1)}let p=P(f);return f(),c.current=u,()=>{p(),e(),n(),c.current=null}},[l,t]),(0,Q.useEffect)(()=>{if(n||!s.current)return;let e=ue();e!==`blurred`&&e!==`unknown`||c.current?.()},[n]),(0,Q.useEffect)(()=>{ue()===`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?.()},AF)))},[n,l])}H(),Wn(),Zb(),s();function NF(){if(process.argv.includes(`--chrome`))return!0;if(process.argv.includes(`--no-chrome`))return!1}function PF(){CF(async()=>{let e=NF();return Yb(e)?process.env.USER_TYPE!==`ant`&&!Dn()?{key:`chrome-requires-subscription`,jsx:(0,$.jsx)(R,{color:`error`,children:`Claude in Chrome requires a claude.ai subscription`}),priority:`immediate`,timeoutMs:5e3}:!await Xb()&&!i()?{key:`chrome-extension-not-detected`,jsx:(0,$.jsx)(R,{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})}an(),Cr(),lr(),q(),s(),gr(),Zr();function FF(){return c(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var IF={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function LF(e){let t=IF.INITIAL_DELAY_MS*IF.BACKOFF_MULTIPLIER**e;return Math.min(t,IF.MAX_DELAY_MS)}function RF(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>=IF.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function zF(){let e=En();if(!RF(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return J(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(FF())return J(`Official marketplace auto-install disabled via env var, skipping`),kt(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 hs())[`claude-plugins-official`])return J(`Official marketplace '${Gi}' already installed, skipping`),kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Pf(Ef))return J(`Official marketplace blocked by enterprise policy, skipping`),kt(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=Po(),n=MS(t,Gi);if(await Ah(n,t)!==null){let e=await hs();return e[Gi]={source:Ef,installLocation:n,lastUpdated:new Date().toISOString()},await Sf(e),kt(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(!gn(`tengu_plugin_official_mkt_git_fallback`,!0)){J(`Official marketplace GCS failed; git fallback disabled by flag — skipping install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+LF(t);return kt(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 lh()){J(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+LF(t),i=!1;try{kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Qr(mr(e)),J(`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}}J(`Attempting to auto-install official marketplace`),await cu(Ef),J(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return kt(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 Bu(),J(`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`};J(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Qr(mr(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+LF(r),o=!1;try{kt(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Qr(mr(e)),J(`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(),q();function BF(){CF(async()=>{let e=await zF(),t=[];return e.configSaveFailed&&(J(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(R,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(J(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(R,{color:`success`,children:`✓ Anthropic marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(J(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(R,{color:`warning`,children:`Failed to install Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Zr(),w(),Ii(),Ss();var VF=Fi(()=>b({method:v(`notifications/message`),params:b({prompt:_(),image:b({type:v(`base64`),media_type:y([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]),data:_()}).optional(),tabId:g().optional()})}));function HF(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(process.env.USER_TYPE!==`ant`)return;let t=UF(e);n.current!==t&&(n.current=t),t&&t.client.setNotificationHandler(VF(),e=>{if(n.current!==t)return;let{tabId:r,prompt:i,image:a}=e.params;if(!(typeof r!=`number`||!iy(r)))try{_a(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){Qr(e)}})},[e]),(0,Q.useEffect)(()=>{let n=UF(e);n&&Ch(`set_permission_mode`,{mode:t===`bypassPermissions`?`skip_all_permission_checks`:`ask`},n)},[e,t])}function UF(e){return e.find(e=>e.type===`connected`&&e.name===`claude-in-chrome`)}Gn(),Cr();function WF(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vS(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function GF(e){if(Un().spinnerTipsEnabled===!1)return;let t=await xS(e);if(t.length!==0)return WF(t)}function KF(e){hS(e.id),Y(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}Nx(),Up();function qF(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!Ll()||r.current||(r.current=!0,e&&tm(e,n))},[t,e,n])}H(),so(),Cr(),zm(),Bb();function JF({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`},...Qc()?[]:[{label:(0,$.jsxs)(R,{children:[`Yes, and don't ask again for `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(R,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(R,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Hb,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(wd,{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(),so(),ei();function YF(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function XF(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Bs.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Bs.isSandboxingEnabled()||$r()===`linux`||n===0?null:(0,$.jsxs)(U,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(U,{marginLeft:0,children:(0,$.jsxs)(R,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[YF(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(U,{paddingLeft:2,children:(0,$.jsxs)(R,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}gx(),Rm(),ot(),H();var ZF=[];function QF({mcpClients:e=ZF}){let{addNotification:t}=Bh();(0,Q.useEffect)(()=>{if($e())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`&&Xu(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`&&Xu(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)(R,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}H(),Gn(),ul();var $F=`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.`;O(),ot(),Rm(),H(),X(),q(),s();var eI=5e3;function tI(){let{addNotification:e}=Bh(),t=Af(),[n,r]=Q.useState(()=>c(`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),J(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),o=Q.useCallback(()=>{if($e()||Re())return;let e=al();if(e.status===`failed`){a(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=v_();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&a(t,n.lastError.message)}},[a]);se(o,n?eI:null),Q.useEffect(()=>{$e()||!n||o()},[o,n])}q();var nI=new Map;async function rI(e){if(!e||!e.trim())return J(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=nI.get(t);if(n!==void 0)return J(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Lr(t).catch(()=>null)&&(r=!0),nI.set(t,r),J(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}lr(),q(),yh();var iI=5;function aI(e){return kn.has(e.toLowerCase())}function oI(e){if(!e)return null;if(typeof e==`string`)return J(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=cI(t);if(e)return e}return null}return cI(e)}function sI(e){return typeof e==`object`&&!!e}function cI(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!sI(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(sI(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function lI(){let e=new Map;try{let t=await hs();for(let n of Object.keys(t))try{let t=await Tu(n),r=aI(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=oI(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){J(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){J(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function uI(e){if(pI())return J(`[lspRecommendation] Recommendations are disabled`),[];let t=jS(e).toLowerCase();if(!t)return J(`[lspRecommendation] No file extension found`),[];J(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await lI(),r=En().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){J(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(ts(e)){J(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await rI(e.command)?(a.push({info:e,pluginId:t}),J(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):J(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function dI(e){kt(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),J(`[lspRecommendation] Added ${e} to never suggest`)}function fI(){kt(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),J(`[lspRecommendation] Incremented ignored count`)}function pI(){let e=En();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=iI}f(),ot(),H(),Zr(),yh();function mI(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{$e()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Qr).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function hI(e,t,n,r,i){try{let a=await ks(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(R,{color:`success`,children:[p.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Qr(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(R,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}ot(),Rm(),X(),lr(),q(),Zr(),Gn();var gI=28e3;function _I(){let e=Z(e=>e.fileHistory.trackedFiles),{addNotification:t}=Bh(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=mI();return Q.useEffect(()=>{a(async()=>{if(it())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 uI(e))[0];if(t)return J(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),st(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:jS(e),shownAt:Date.now()}}catch(e){Qr(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(J(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:hI(n,a,`lsp-plugin`,t,async e=>{J(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?MS(e.marketplaceInstallLocation,e.entry.source):void 0;await Cl(n,e.entry,`user`,void 0,t),Bn(`userSettings`,{enabledPlugins:{...nn(`userSettings`)?.enabledPlugins,[n]:!0}}),J(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=gI&&(J(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),fI());break}case`never`:dI(n);break;case`disable`:kt(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}H(),zm(),Bb();var vI=3e4;function yI({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`),vI,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)(Hb,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsx)(R,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,children:t})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(R,{children:[` `,n,` files`]})]}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(wd,{options:[{label:(0,$.jsxs)(R,{children:[`Yes, install `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(R,{children:[`Never for `,(0,$.jsx)(R,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Rm(),Cr(),q(),qg();function bI(){let e=Q.useSyncExternalStore(Oc,Fp),{addNotification:t}=Bh(),{recommendation:n,clearRecommendation:r,tryResolve:i}=mI();return Q.useEffect(()=>{e&&i(async()=>{let t=await Ha(e);return t&&(J(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),rc()),Fp()===e&&ca(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(to(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;hI(e,r,`hint-plugin`,t,async t=>{let n=await Ml({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`:Ug();break;case`no`:break}r()}},[n,t,r])}}H(),zm(),Bb();var xI=3e4;function SI({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`),xI,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)(Hb,{title:`Plugin Recommendation`,children:(0,$.jsxs)(U,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(U,{marginBottom:1,children:(0,$.jsxs)(R,{dimColor:!0,children:[`The `,(0,$.jsx)(R,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(R,{children:[` `,e]})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(R,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(R,{children:[` `,n]})]}),t&&(0,$.jsx)(U,{children:(0,$.jsx)(R,{dimColor:!0,children:t})}),(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{children:`Would you like to install it?`})}),(0,$.jsx)(U,{children:(0,$.jsx)(wd,{options:[{label:(0,$.jsxs)(R,{children:[`Yes, install `,(0,$.jsx)(R,{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`)})})]})})}zm(),Bb();var CI=3e4;function wI({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(),CI,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)(Hb,{title:`Tool Recommendation`,children:(0,$.jsx)(wd,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}jo();var TI=.15,EI=3;function DI(){let e=Q.useSyncExternalStore(Ds,xu),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,EI).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)>=TI,handleSelect:Q.useCallback(e=>{Gl()},[]),handleDismiss:Q.useCallback(()=>{Gl()},[])}}ot(),Rm(),H(),X(),q(),Vi();function OI(){let{addNotification:e}=Bh(),t=Z(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(!$e()){if(!t){J(`No installation status to monitor`);return}n!==0&&(J(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(J(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{color:`error`,children:[n,` `,Bi(n,`plugin`),` failed to install`]}),(0,$.jsx)(R,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}ot(),Rm(),H(),q(),Jx();function kI(){let{addNotification:e}=Bh(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!$e())return Yx(e=>{J(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if($e()||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)(R,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(R,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),J(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}q(),Zr(),yh(),Sb(),Cr();function AI(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 jI(e){J(`performBackgroundPluginInstallations called`);try{let t=tb(Yl(),await hs().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;J(`Installing ${n.length} marketplace(s) in background`);let r=await Yy({onProgress:t=>{switch(t.type){case`installing`:AI(e,t.name,`installing`);break;case`installed`:AI(e,t.name,`installed`);break;case`failed`:AI(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),Dr(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Ko(),J(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await xb(e)}catch(t){Qr(t),J(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),xm(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Ko(),xm(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Qr(e)}}lr(),q(),yh(),jg();async function MI(e){if(J(`performStartupChecks called`),!W()){J(`Trust not accepted for current directory - skipping plugin installations`);return}try{J(`Starting background plugin installations`),await Jc()&&(Ko(),xm(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await jI(e)}catch(e){J(`Error initiating background plugin installations: ${e}`)}}H();var NI=/https?:\/\/\S+/;function PI(){let[e,t]=(0,Q.useState)(Wt.getInstance().getStatus());return(0,Q.useEffect)(()=>Wt.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)(R,{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(NI);if(!n)return(0,$.jsx)(R,{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)(R,{dimColor:!0,children:[a,(0,$.jsx)(re,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(U,{marginTop:1,children:(0,$.jsx)(R,{color:`error`,children:e.error})})]})}Rm(),H(),Dp(),Uh(),Wn(),In(),ot();function FI(e){let{addNotification:t}=Bh(),n=Ud(),r=(0,Q.useMemo)(()=>Wm(n,e),[n,e]),i=(0,Q.useMemo)(()=>Xh(n),[n]),a=(0,Q.useRef)(null),o=Qn(),s=Mt(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{$e()||(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)(()=>{$e()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(R,{children:(0,$.jsx)(R,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Rm(),ot();function II(e){let{addNotification:t}=Bh(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if($e())return;let r=gS(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var LI=``;function RI(){CF(async()=>Fr()||c(process.env.DISABLE_INSTALLATION_CHECKS)||await To()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:LI,color:`warning`,priority:`high`})}Rm(),H(),lr(),ma(),ot();var zI=5;function BI({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Bh(),{status:a,ideName:o}=FD(t),s=(0,Q.useRef)(!1),c=n?cc(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($e())return;if(vo()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(En().ideHintShownCount??0)>=zI)return;let e=setTimeout((e,t)=>{wl(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,kt(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(R,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(R,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!$e()){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(!$e()){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(!$e()){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])}lr();var VI=[e=>{if(UI(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(UI(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 HI(){CF(()=>{let e=En(),t=[];for(let n of VI){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function UI(e){return e!==void 0&&Date.now()-e<3e3}Wn(),H(),Cr(),lr();var WI=3;function GI(){CF(async()=>{if((En().subscriptionNoticeCount??0)>=WI)return null;let e=await KI();return e===null?null:(kt(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Y(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(R,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`,(0,$.jsxs)(R,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function KI(){if(Dn())return null;let e=await _n();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}ot(),Rm(),X(),pc();function qI(e){if(!(`text`in e))return 1;let t=e.text.match(/^(\d+)/);return t?.[1]?parseInt(t[1],10):1}function JI(e,t){return YI(qI(e)+1)}function YI(e){return{key:`teammate-spawn`,text:e===1?`1 agent spawned`:`${e} agents spawned`,priority:`low`,timeoutMs:5e3,fold:JI}}function XI(e,t){return ZI(qI(e)+1)}function ZI(e){return{key:`teammate-shutdown`,text:e===1?`1 agent shut down`:`${e} agents shut down`,priority:`low`,timeoutMs:5e3,fold:XI}}function QI(){let e=Z(e=>e.tasks),{addNotification:t}=Bh(),n=(0,Q.useRef)(new Set),r=(0,Q.useRef)(new Set);(0,Q.useEffect)(()=>{if(!$e())for(let[i,a]of Object.entries(e))Kp(a)&&(a.status===`running`&&!n.current.has(i)&&(n.current.add(i),t(YI(1))),a.status===`completed`&&!r.current.has(i)&&(r.current.add(i),t(ZI(1))))},[e,t])}Rm(),X(),tr(),Pi(),ot();var $I=`fast-mode-cooldown-started`,eL=`fast-mode-cooldown-expired`,tL=`fast-mode-org-changed`,nL=`fast-mode-overage-rejected`;function rL(){let{addNotification:e}=Bh(),t=Z(e=>e.fastMode),n=Af();(0,Q.useEffect)(()=>{if(!$e()&&ar())return Ft(r=>{r?e({key:tL,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:tL,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!$e()&&ar())return ln(t=>{n(e=>({...e,fastMode:!1})),e({key:nL,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if($e()||!t)return;let n=rr((t,n)=>{let r=iL(n,Ai(t-Date.now(),{hideTrailingZeros:!0}));e({key:$I,invalidates:[eL],text:r,color:`warning`,priority:`immediate`})}),r=At(()=>{e({key:eL,invalidates:[$I],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function iL(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(),ty();function aL({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return we(`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)(R,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,children:[`Press `,(0,$.jsx)(he,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(U,{children:(0,$.jsxs)(R,{dimColor:!0,children:[`Reason: `,n]})})]})}function oL(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 sL(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function cL(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 lL=()=>null;en(),H();function uL(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(U,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(U,{minWidth:2,children:(0,$.jsx)(R,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(R,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(R,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(R,{dimColor:!0,children:` /issue to report it`})]})]}):null}G_(),ql();var dL=[/\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/],fL=[/^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 pL(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(dL.some(t=>t.test(e)))return!1}}}return!0}function mL(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=S_(n);if(r)return fL.some(e=>e.test(r))}return!1}var hL=3,gL=1800*1e3;function _L(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>pL(e)&&mL(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<gL||t<hL||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}ot(),H();function vL(){return process.env.USER_TYPE===`ant`}function yL(){let[e,t]=(0,Q.useState)(Ie);return ke(()=>{t(Ie())},vL()?500:null),!vL()||e.length===0?null:(0,$.jsxs)(R,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}f(),H(),ny(),zm(),ky(),X(),ot(),ix(),ql(),Ss(),ku(),wr(),ri(),go(),Hh();var bL=24,xL=11;function SL(){return new Date().toISOString().split(`T`)[0]}function CL({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){mg(`ultraplan-choice`);let l=Af(),{rows:u,columns:d}=k(),f=Q.useMemo(()=>Math.min(bL,Math.max(1,Math.floor(u/2)-xL)),[u]),m=Q.useMemo(()=>ge(e,Math.max(1,d-4),`wrap`).split(`
90
90
  `),[e,d]),h=Math.max(0,m.length-f),[g,_]=Q.useState(0);Q.useEffect(()=>{_(e=>Math.min(e,h))},[h]);let v=m.length>f;Oe((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,h))}else if(t.ctrl&&e===`u`||t.wheelUp){let e=t.wheelUp?3:n;_(t=>Math.max(t-e,0))}});let y=m.slice(g,g+f).join(`
91
- `),b=g>0,x=g<h,S=Q.useCallback(async a=>{switch(a){case`here`:ha({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(`
92
- `),mode:`task-notification`});break;case`fresh`:let t=Fe(),n=await VS(da()).then(()=>!0,()=>!1);await ax({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,Na(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),ha({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=MS(Tr(),`${SL()}-ultraplan.md`);await HS(t,e,{encoding:`utf-8`}),r(e=>[...e,Na(`Ultraplan rejected · Plan saved to ${ai(t)}`,`suggestion`)]);break}}Zu(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),mc(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)(B,{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)(R,{children:y}),v&&(0,$.jsxs)(R,{dimColor:!0,children:[b?p.arrowUp:` `,x?p.arrowDown:` `,` `,g+1,`–`,Math.min(g+f,m.length),` of `,m.length,` · ctrl+u/ctrl+d to scroll`]})]}),(0,$.jsx)(Sd,{options:C,onChange:e=>void S(e)})]})})}H(),Im(),ky(),X(),lr(),em();function wL(){return!En().hasSeenUltraplanTerms}function TL(){return Zm()}function EL({onChoice:e}){let[t]=Q.useState(wL),[n]=Q.useState(TL),r=Q.useMemo(()=>jf(n),[n]),i=Z(e=>e.replBridgeEnabled),a=kf(),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&&kt(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)(B,{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)(R,{dimColor:!0,children:r.dialogBody}),t?(0,$.jsxs)(R,{dimColor:!0,children:[`For more information on Claude Code on the web:`,(0,$.jsx)(re,{url:Wd,children:Wd})]}):null]}),(0,$.jsx)(R,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(Sd,{options:c,onChange:o})]})})}xx(),H(),lr(),Tg();function DL(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||!(En().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function OL(e){let[t]=ae();(0,Q.useEffect)(()=>{e.setSelectionBgColor(fd(t).selectionBg)},[e,t])}Fm(),H(),ty(),q();var kL=40,AL=.3,jL=6,ML=200,NL=15,PL=15,FL=3,IL=1500,LL=150,RL=5,zL=5,BL=80,VL=3,HL=6,UL=500;function WL(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 GL(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 KL(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>IL&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>ML)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<zL)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/LL),n=Math.max(PL,e.base*2),i=1+(e.mult-1)*t+NL*t;return e.mult=Math.min(n,i,e.mult+FL),Math.floor(e.mult)}if(r>kL)e.mult=e.base;else{let t=Math.max(jL,e.base*2);e.mult=Math.min(t,e.mult+AL)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<zL)return 1;if(!i||r>UL)e.mult=2,e.frac=0;else{let t=.5**(r/LL);e.mult=Math.min(r>=BL?VL:HL,1+(e.mult-1)*t+RL*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function qL(){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 JL(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function YL(){let e=de(),t=qL();return J(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),JL(e,t)}var XL=2,ZL=50,QL=200;function $L({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ee(),{addNotification:a}=Lh(),o=(0,Q.useRef)(null);function s(e){let t=z(),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 V({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=nR(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=nR(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=YL()),iR(t,KL(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=YL());let r=rR(t,KL(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}),V({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=nR(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=nR(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=nR(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=nR(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),Oe((t,r,i)=>{let a=e.current;if(!a)return;let o=oR(a,aR(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),Oe((e,t,n)=>{if(!i.hasSelection())return;if(t.escape){i.clearSelection(),n.stopImmediatePropagation();return}if(t.ctrl&&!t.shift&&!t.meta&&e===`c`){c(),n.stopImmediatePropagation();return}let r=GL(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}WL(t)&&i.clearSelection()},{isActive:t}),eR(e,i,t,n),DL(i,t,s),OL(i),null}function eR(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>QL){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(XL,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-XL)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(XL,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(XL)}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,ZL)))}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=tR(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 tR(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 nR(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 rR(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 iR(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function aR(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 oR(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),nR(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),nR(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),nR(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 sR=r({VoiceKeybindingHandler:()=>dR,useVoiceIntegration:()=>lR,useVoiceKeybindingHandler:()=>uR});function cR(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 lR({setInputValueRaw:e,inputValueRef:t,insertTextRef:n}){let{addNotification:r}=Lh(),i=(0,fR.useRef)(null),a=(0,fR.useRef)(``),o=(0,fR.useRef)(null),s=(0,fR.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===` `?Ri(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,fR.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=ID(),u=Dl(e=>e.voiceState),d=Dl(e=>e.voiceInterimTranscript);(0,fR.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,fR.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,fR.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=pR.useVoice({onTranscript:f,onError:e=>{r({key:`voice-error`,text:e,color:`error`,priority:`immediate`,timeoutMs:1e4})},enabled:l,focusMode:!1}),m=(0,fR.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 uR({voiceHandleKeyEvent:e,stripTrailing:t,resetAnchor:n,isActive:r}){let i=Ta(),a=Pg(),o=pe(),s=Hd(),c=ID(),l=Dl(e=>e.voiceState),u=(0,fR.useMemo)(()=>{if(!o)return vR;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&&me(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,fR.useRef)(0),p=(0,fR.useRef)(0),m=(0,fR.useRef)(0),h=(0,fR.useRef)(!1),g=(0,fR.useRef)(null);(0,fR.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===` `?Ri(o.key):o.key;if(e[0]!==d||e.length>1&&e!==d.repeat(e.length))return;l=e.length}else{if(!cR(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>=gR){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(hR)):(m.current=t(p.current+l,{char:d,anchor:!0}),p.current=0,e()),i().voiceState===`idle`&&(h.current=!1,n());return}v>=_R?(o.stopImmediatePropagation(),t(l,{char:d,floor:p.current})):p.current+=l,f.current>=_R&&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)},mR,g,f,p,a)};return Oe((e,t,n)=>{let r=new Ae(n.keypress);_(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()},{isActive:r}),{handleKeyDown:_}}function dR(e){return uR(e),null}var fR,pR,mR,hR,gR,_R,vR,yR=t((()=>{fR=n(L(),1),Fm(),zh(),ml(),H(),Hp(),Vi(),RD(),pR=(fS(),e(dS)),mR=120,hR=2e3,gR=5,_R=2,vR={key:` `,ctrl:!1,alt:!1,shift:!1,meta:!1,super:!1}})),bR=r({useFrustrationDetection:()=>SR});function xR(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function SR(e,t,n,r){let[i,a]=(0,CR.useState)(`closed`),o=En(),s=Ts(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=xR(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(ZP(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(kt(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var CR,wR=t((()=>{CR=n(L(),1),lr(),pu(),QP()})),TR=r({useAntOrgWarningNotification:()=>ER});function ER(){}var DR=t((()=>{})),OR=r({useProactive:()=>kR});function kR(e){let t=(0,AR.useRef)(e);t.current=e,(0,AR.useEffect)(()=>{if(!_v())return;let e=null,n=!1,r=!1;function i(){gv(Date.now()+jR),e=setTimeout(()=>{if(e=null,!uv()){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 s_({basePrompt:`<${Wr}>${new Date().toLocaleTimeString()}</${Wr}>`,currentDir:Tr(),shouldCreate:()=>!n});if(n){await Ym({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await Ym({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>J(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},jR)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),gv(null)}},[_v(),lv(),fv()])}var AR,jR,MR=t((()=>{AR=n(L(),1),Xr(),wr(),Kf(),q(),jR=3e4})),NR=r({createScheduledTaskQueuedCommand:()=>PR,useScheduledTasks:()=>FR});async function PR(e,t){let n=await Sg({basePrompt:e.prompt,trigger:`scheduled-task`,rootDir:t?.rootDir,currentDir:t?.currentDir??Tr(),sourceId:e.id,sourceLabel:e.prompt,workload:It,shouldCreate:t?.shouldCreate});return n||J(`[ScheduledTasks] skipping ${e.id}: previous run still queued or running`),n}function FR({isLoading:e,assistantMode:t=!1,setMessages:n}){let r=(0,LR.useRef)(e);r.current=e;let i=Zd(),a=kf();(0,LR.useEffect)(()=>{if(!N_())return;let e=!1,o=async t=>{let n=await cd({basePrompt:t,trigger:`scheduled-task`,currentDir:Tr(),workload:It,shouldCreate:()=>!e});if(n){if(e){await Ya(n.autonomy.runId,n.autonomy.rootDir);return}ha(n)}},s=Xy({onFire:e=>{o(e).catch(e=>J(`[ScheduledTasks] failed to enqueue missed task prompt: ${e}`,{level:`error`}))},onFireTask:t=>{(async()=>{if(t.agentId){let n=Tm(t.agentId,i.getState().tasks);if(n&&!$s(n.status)){let r=await PR(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Ya(r.autonomy.runId,r.autonomy.rootDir);return}!Rm(n.id,r.value,{autonomyRunId:r.autonomy?.runId,autonomyRootDir:r.autonomy?.rootDir,origin:r.origin},a)&&r.autonomy?.runId&&await Ia(r.autonomy.runId,`Teammate ${t.agentId} exited before the scheduled message could be delivered.`,r.autonomy.rootDir);return}J(`[ScheduledTasks] teammate ${t.agentId} gone, removing orphaned cron ${t.id}`),O_([t.id]);return}let r=await PR(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Ya(r.autonomy.runId,r.autonomy.rootDir);return}let o=r_(`Running scheduled task (${IR(new Date)})`);n(e=>[...e,o]),ha(r)})().catch(e=>J(`[ScheduledTasks] failed to enqueue task ${t.id}: ${e}`,{level:`error`}))},isLoading:()=>r.current,assistantMode:t,getJitterConfig:Qy,isKilled:()=>!N_()});return s.start(),()=>{e=!0,s.stop()}},[t])}function IR(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 LR,RR=t((()=>{LR=n(L(),1),X(),wd(),wr(),Lg(),q(),Cs(),ql(),Qt()}));function zR(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 BR(e){let t=mo(e),n=zR(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
91
+ `),b=g>0,x=g<h,S=Q.useCallback(async a=>{switch(a){case`here`:_a({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(`
92
+ `),mode:`task-notification`});break;case`fresh`:let t=Fe(),n=await VS(da()).then(()=>!0,()=>!1);await ax({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,Na(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),_a({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=MS(Tr(),`${SL()}-ultraplan.md`);await HS(t,e,{encoding:`utf-8`}),r(e=>[...e,Na(`Ultraplan rejected · Plan saved to ${ai(t)}`,`suggestion`)]);break}}ed(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),Vp(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)(B,{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)(R,{children:y}),v&&(0,$.jsxs)(R,{dimColor:!0,children:[b?p.arrowUp:` `,x?p.arrowDown:` `,` `,g+1,`–`,Math.min(g+f,m.length),` of `,m.length,` · ctrl+u/ctrl+d to scroll`]})]}),(0,$.jsx)(wd,{options:C,onChange:e=>void S(e)})]})})}H(),zm(),ky(),X(),lr(),im();function wL(){return!En().hasSeenUltraplanTerms}function TL(){return Qm()}function EL({onChoice:e}){let[t]=Q.useState(wL),[n]=Q.useState(TL),r=Q.useMemo(()=>Mf(n),[n]),i=Z(e=>e.replBridgeEnabled),a=Af(),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&&kt(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)(B,{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)(R,{dimColor:!0,children:r.dialogBody}),t?(0,$.jsxs)(R,{dimColor:!0,children:[`For more information on Claude Code on the web:`,(0,$.jsx)(re,{url:Wd,children:Wd})]}):null]}),(0,$.jsx)(R,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(wd,{options:c,onChange:o})]})})}xx(),H(),lr(),Zf();function DL(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||!(En().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function OL(e){let[t]=ae();(0,Q.useEffect)(()=>{e.setSelectionBgColor(up(t).selectionBg)},[e,t])}Rm(),H(),ty(),q();var kL=40,AL=.3,jL=6,ML=200,NL=15,PL=15,FL=3,IL=1500,LL=150,RL=5,zL=5,BL=80,VL=3,HL=6,UL=500;function WL(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 GL(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 KL(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>IL&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>ML)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<zL)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/LL),n=Math.max(PL,e.base*2),i=1+(e.mult-1)*t+NL*t;return e.mult=Math.min(n,i,e.mult+FL),Math.floor(e.mult)}if(r>kL)e.mult=e.base;else{let t=Math.max(jL,e.base*2);e.mult=Math.min(t,e.mult+AL)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<zL)return 1;if(!i||r>UL)e.mult=2,e.frac=0;else{let t=.5**(r/LL);e.mult=Math.min(r>=BL?VL:HL,1+(e.mult-1)*t+RL*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function qL(){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 JL(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function YL(){let e=de(),t=qL();return J(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),JL(e,t)}var XL=2,ZL=50,QL=200;function $L({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ee(),{addNotification:a}=Bh(),o=(0,Q.useRef)(null);function s(e){let t=z(),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 V({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=nR(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=nR(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=YL()),iR(t,KL(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=YL());let r=rR(t,KL(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}),V({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=nR(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=nR(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=nR(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=nR(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),Oe((t,r,i)=>{let a=e.current;if(!a)return;let o=oR(a,aR(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),Oe((e,t,n)=>{if(!i.hasSelection())return;if(t.escape){i.clearSelection(),n.stopImmediatePropagation();return}if(t.ctrl&&!t.shift&&!t.meta&&e===`c`){c(),n.stopImmediatePropagation();return}let r=GL(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}WL(t)&&i.clearSelection()},{isActive:t}),eR(e,i,t,n),DL(i,t,s),OL(i),null}function eR(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>QL){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(XL,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-XL)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(XL,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(XL)}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,ZL)))}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=tR(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 tR(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 nR(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 rR(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 iR(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function aR(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 oR(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),nR(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),nR(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),nR(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 sR=r({VoiceKeybindingHandler:()=>dR,useVoiceIntegration:()=>lR,useVoiceKeybindingHandler:()=>uR});function cR(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 lR({setInputValueRaw:e,inputValueRef:t,insertTextRef:n}){let{addNotification:r}=Bh(),i=(0,fR.useRef)(null),a=(0,fR.useRef)(``),o=(0,fR.useRef)(null),s=(0,fR.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===` `?Ri(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,fR.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=ID(),u=Tl(e=>e.voiceState),d=Tl(e=>e.voiceInterimTranscript);(0,fR.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,fR.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,fR.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=pR.useVoice({onTranscript:f,onError:e=>{r({key:`voice-error`,text:e,color:`error`,priority:`immediate`,timeoutMs:1e4})},enabled:l,focusMode:!1}),m=(0,fR.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 uR({voiceHandleKeyEvent:e,stripTrailing:t,resetAnchor:n,isActive:r}){let i=Ta(),a=Fg(),o=pe(),s=Hd(),c=ID(),l=Tl(e=>e.voiceState),u=(0,fR.useMemo)(()=>{if(!o)return vR;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&&me(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,fR.useRef)(0),p=(0,fR.useRef)(0),m=(0,fR.useRef)(0),h=(0,fR.useRef)(!1),g=(0,fR.useRef)(null);(0,fR.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===` `?Ri(o.key):o.key;if(e[0]!==d||e.length>1&&e!==d.repeat(e.length))return;l=e.length}else{if(!cR(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>=gR){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(hR)):(m.current=t(p.current+l,{char:d,anchor:!0}),p.current=0,e()),i().voiceState===`idle`&&(h.current=!1,n());return}v>=_R?(o.stopImmediatePropagation(),t(l,{char:d,floor:p.current})):p.current+=l,f.current>=_R&&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)},mR,g,f,p,a)};return Oe((e,t,n)=>{let r=new Ae(n.keypress);_(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()},{isActive:r}),{handleKeyDown:_}}function dR(e){return uR(e),null}var fR,pR,mR,hR,gR,_R,vR,yR=t((()=>{fR=n(L(),1),Rm(),Hh(),fl(),H(),Gp(),Vi(),RD(),pR=(fS(),e(dS)),mR=120,hR=2e3,gR=5,_R=2,vR={key:` `,ctrl:!1,alt:!1,shift:!1,meta:!1,super:!1}})),bR=r({useFrustrationDetection:()=>SR});function xR(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function SR(e,t,n,r){let[i,a]=(0,CR.useState)(`closed`),o=En(),s=ws(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=xR(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(ZP(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(kt(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var CR,wR=t((()=>{CR=n(L(),1),lr(),mu(),QP()})),TR=r({useAntOrgWarningNotification:()=>ER});function ER(){}var DR=t((()=>{})),OR=r({useProactive:()=>kR});function kR(e){let t=(0,AR.useRef)(e);t.current=e,(0,AR.useEffect)(()=>{if(!_v())return;let e=null,n=!1,r=!1;function i(){gv(Date.now()+jR),e=setTimeout(()=>{if(e=null,!uv()){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 a_({basePrompt:`<${Wr}>${new Date().toLocaleTimeString()}</${Wr}>`,currentDir:Tr(),shouldCreate:()=>!n});if(n){await Xm({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await Xm({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>J(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},jR)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),gv(null)}},[_v(),lv(),fv()])}var AR,jR,MR=t((()=>{AR=n(L(),1),Xr(),wr(),qf(),q(),jR=3e4})),NR=r({createScheduledTaskQueuedCommand:()=>PR,useScheduledTasks:()=>FR});async function PR(e,t){let n=await wg({basePrompt:e.prompt,trigger:`scheduled-task`,rootDir:t?.rootDir,currentDir:t?.currentDir??Tr(),sourceId:e.id,sourceLabel:e.prompt,workload:It,shouldCreate:t?.shouldCreate});return n||J(`[ScheduledTasks] skipping ${e.id}: previous run still queued or running`),n}function FR({isLoading:e,assistantMode:t=!1,setMessages:n}){let r=(0,LR.useRef)(e);r.current=e;let i=ef(),a=Af();(0,LR.useEffect)(()=>{if(!N_())return;let e=!1,o=async t=>{let n=await dd({basePrompt:t,trigger:`scheduled-task`,currentDir:Tr(),workload:It,shouldCreate:()=>!e});if(n){if(e){await Ya(n.autonomy.runId,n.autonomy.rootDir);return}_a(n)}},s=Xy({onFire:e=>{o(e).catch(e=>J(`[ScheduledTasks] failed to enqueue missed task prompt: ${e}`,{level:`error`}))},onFireTask:t=>{(async()=>{if(t.agentId){let n=xf(t.agentId,i.getState().tasks);if(n&&!Js(n.status)){let r=await PR(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Ya(r.autonomy.runId,r.autonomy.rootDir);return}!bp(n.id,r.value,{autonomyRunId:r.autonomy?.runId,autonomyRootDir:r.autonomy?.rootDir,origin:r.origin},a)&&r.autonomy?.runId&&await La(r.autonomy.runId,`Teammate ${t.agentId} exited before the scheduled message could be delivered.`,r.autonomy.rootDir);return}J(`[ScheduledTasks] teammate ${t.agentId} gone, removing orphaned cron ${t.id}`),O_([t.id]);return}let r=await PR(t,{shouldCreate:()=>!e});if(!r)return;if(e){await Ya(r.autonomy.runId,r.autonomy.rootDir);return}let o=r_(`Running scheduled task (${IR(new Date)})`);n(e=>[...e,o]),_a(r)})().catch(e=>J(`[ScheduledTasks] failed to enqueue task ${t.id}: ${e}`,{level:`error`}))},isLoading:()=>r.current,assistantMode:t,getJitterConfig:Qy,isKilled:()=>!N_()});return s.start(),()=>{e=!0,s.stop()}},[t])}function IR(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 LR,RR=t((()=>{LR=n(L(),1),X(),kh(),wr(),Rg(),q(),Ss(),ql(),Qt()}));function zR(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 BR(e){let t=ho(e),n=zR(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
93
93
  You have an active goal to work on. Continue making progress.
94
94
 
95
95
  ## Active Goal
@@ -129,7 +129,7 @@ Your token budget for this goal has been exhausted.
129
129
 
130
130
  - Goal: ${e.objective}
131
131
  - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
132
- - Active time: ${mo(e)}
132
+ - Active time: ${ho(e)}
133
133
 
134
134
  **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
135
135
 
@@ -139,9 +139,9 @@ Instead, provide a brief summary:
139
139
  3. Any blockers or issues encountered.
140
140
 
141
141
  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.
142
- </goal-steering>`}var HR=t((()=>{})),UR=r({useGoalContinuation:()=>GR});function WR(e){J(`[goal] hook: ${e}`)}function GR(e){let t=(0,KR.useRef)(e);t.current=e;let n=(0,KR.useRef)(!1),r=(0,KR.useRef)(!1);(0,KR.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){WR(`skip: queryActiveNow=true`);return}if(e.wasAborted){WR(`skip: wasAborted=true`);return}if(n.current)return;if(Vl().length>0){WR(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){WR(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){WR(`skip: planMode`);return}let t=Vs();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=VR(t);J(`[goal] hook: budget limit reached, injecting wrap-up prompt`),g_({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){WR(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){iu()&&(Hh(),e.onMaxTurnsReached?.()),J(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=x_();Hh();let a=BR(t);J(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),g_({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 KR,qR=t((()=>{KR=n(L(),1),q(),ya(),HR(),Cs()})),JR=r({AntModelSwitchCallout:()=>YR,shouldShowModelSwitchCallout:()=>XR});function YR(e){return null}function XR(){return!1}var ZR=t((()=>{})),QR=r({UndercoverAutoCallout:()=>$R});function $R({onDone:e}){return(0,ez.useEffect)(()=>{e()},[e]),null}var ez,tz=t((()=>{ez=n(L(),1)}));ot(),gs(),Ci(),f(),H(),ny(),jb(),Fm(),mu(),q(),s(),Pi(),Kf(),Bv(),Gd(),rg(),_i(),wd(),nc(),gh(),wm(),ub(),vs(),Kp(),ws(),ff(),Ra(),Ap(),gr(),Zr(),wr(),co(),Ng(),Ho(),m_(),lr(),In(),Cr(),an(),ql(),Ny(),Xr(),Ig(),Xd(),Ly(),u_(),Ma(),ta(),Rb(),X(),Bd(),ho(),gc(),oa(),Yn(),fa(),Dc(),Cs(),pf(),mf(),oo(),em(),Da();var nz=(yR(),e(sR)).useVoiceIntegration,rz=(yR(),e(sR)).VoiceKeybindingHandler,iz=process.env.USER_TYPE===`ant`?(wR(),e(bR)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),az=process.env.USER_TYPE===`ant`?(DR(),e(TR)).useAntOrgWarningNotification:()=>{},oz=(h_(),e(il)).getCoordinatorUserContext,sz=(vv(),e(sv)),cz=e=>()=>{},lz=()=>!1,uz=()=>null,dz=(e,t)=>!1,fz=(MR(),e(OR)).useProactive,pz=(RR(),e(NR)).useScheduledTasks,mz=(qR(),e(UR)).useGoalContinuation,hz=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),gz=()=>({routeToSelectedPipes:()=>!1}),_z=process.env.USER_TYPE===`ant`?(ZR(),e(JR)).AntModelSwitchCallout:null,vz=process.env.USER_TYPE===`ant`?(ZR(),e(JR)).shouldShowModelSwitchCallout:()=>!1,yz=process.env.USER_TYPE===`ant`?(tz(),e(QR)).UndercoverAutoCallout:null,bz=[],xz=3e3;function Sz(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 Cz({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=bc(`app:toggleTranscript`,`Global`,`ctrl+o`),o=bc(`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)(R,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${p.arrowUp}${p.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)(R,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{flexGrow:1}),(0,$.jsxs)(R,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function wz({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=px({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)(R,{children:`/`}),(0,$.jsx)(R,{children:s.slice(0,f)}),(0,$.jsx)(R,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(R,{children:s.slice(f+1)}),(0,$.jsx)(U,{flexGrow:1}),l===`building`?(0,$.jsx)(R,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(R,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(R,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(R,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var Tz=[`⠂`,`⠐`],Ez=`✳`,Dz=960;function Oz({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=le(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%Tz.length),Dz,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?Tz[a]??Ez:Ez;return ve(n?null:r?t:`${s} ${t}`),null}var kz=`<${qr}>`;function Az(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(kz)}function jz({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:a,initialFileHistorySnapshots:o,initialContentReplacements:s,initialAgentName:l,initialAgentColor:u,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:E,thinkingConfig:D}){let O=!!C,j=(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),M=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&c(process.env.CLAUDE_MORERIGHT),[]),N=(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(J(`[REPL:mount] REPL mounted, disabled=${y}`),()=>J(`[REPL:unmount] REPL unmounting`)),[y]);let[P,ee]=(0,Q.useState)(b),F=Z(e=>e.toolPermissionContext),te=Z(e=>e.verbose),ne=Z(e=>e.mcp),re=Z(e=>e.plugins),L=Z(e=>e.agentDefinitions),oe=Z(e=>e.fileHistory),se=Z(e=>e.initialMessage),ue=pD(),de=Z(e=>e.spinnerTip),fe=Z(e=>e.expandedView)===`tasks`,pe=Z(e=>e.pendingWorkerRequest),me=Z(e=>e.pendingSandboxRequest),z=Z(e=>e.teamContext),B=Z(e=>e.tasks),he=Z(e=>e.workerSandboxPermissions),ge=Z(e=>e.elicitation),_e=Z(e=>e.ultraplanPendingChoice),ve=Z(e=>e.ultraplanLaunchPending),ye=Z(e=>e.viewingAgentTaskId),V=kf(),be=ye?B[ye]:void 0,xe=pc(be)&&be.retain&&!be.diskLoaded;(0,Q.useEffect)(()=>{if(!ye||!xe)return;let e=ye;np(xo(e)).then(t=>{V(n=>{let r=n.tasks[e];if(!pc(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 H=Zd(),we=A(),Te=Lb(),[Ee,De]=(0,Q.useState)(t);DP(O?void 0:vt(),De);let ke=Q.useSyncExternalStore(sz?.subscribeToProactiveChanges??cz,sz?.isProactiveActive??lz),Ae=Q.useSyncExternalStore(sz?.subscribeToProactiveChanges??cz,sz?.getNextTickAt??uz),je=Z(e=>e.isBriefOnly),Pe=(0,Q.useMemo)(()=>el(F),[F,ke,je]);Mx();let[Ie,Le]=(0,Q.useState)(f),Re=(0,Q.useCallback)(e=>{Le(e)},[Le]),[ze,Ve]=(0,Q.useState)(`prompt`),[Ge,Ke]=(0,Q.useState)(!1),[Je,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(``),it=(0,Q.useRef)(0),ot=(0,Q.useRef)(void 0),st=(0,Q.useRef)(!1),{addNotification:ut,removeNotification:dt}=Lh(),mt=dz,ht=TP(d,ne.clients),[gt,_t]=(0,Q.useState)(void 0),[yt,xt]=(0,Q.useState)(null),[Ct,Tt]=(0,Q.useState)(null),[Et,Dt]=(0,Q.useState)(!1),[Ot,At]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`?vz():!1),[jt,Mt]=(0,Q.useState)(()=>JP(Te)),Nt=Z(e=>e.showRemoteCallout),[Pt,Ft]=(0,Q.useState)(()=>SS());HI(),GI(),BI({ideSelection:gt,mcpClients:ht,ideInstallationStatus:Ct}),QF({mcpClients:ht}),OI(),kI(),hx(),FI(Te),rL(),II(Te),RI(),az(),wF(),PF(),BF(),tI(),QI();let{recommendation:It,handleResponse:Lt}=_I(),{recommendation:Rt,handleResponse:zt}=bI(),Bt=DI(),Vt=(0,Q.useMemo)(()=>[...Pe,...r],[Pe,r]);zy({enabled:!O});let Ht=Zg();(0,Q.useEffect)(()=>{O||MI(V)},[V,O]),HF(O?bz:ht,F.mode),QN(V,i,{enabled:!O});let Ut=kb(Vt,ne.tools,F),{tools:Wt,allowedAgentTypes:Gt}=(0,Q.useMemo)(()=>{if(!P)return{tools:Ut,allowedAgentTypes:void 0};let e=Mc(P,Ut,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[P,Ut]),Kt=EP(EP(Ee,re.commands),ne.commands),qt=(0,Q.useMemo)(()=>x?[]:Kt,[x,Kt]);NC(O?bz:ne.clients),AP(O?bz:ne.clients,_t);let[Jt,Yt]=(0,Q.useState)(`responding`),Zt=(0,Q.useRef)(Jt);Zt.current=Jt;let[Qt,$t]=(0,Q.useState)([]),[en,tn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(en&&!en.isStreaming&&en.streamingEndedAt){let e=3e4-(Date.now()-en.streamingEndedAt);if(e>0){let t=setTimeout(tn,e,null);return()=>clearTimeout(t)}else tn(null)}},[en]);let[nn,rn]=(0,Q.useState)(null),an=(0,Q.useRef)(null);an.current=nn;let on=(0,Q.useRef)(0),[sn,cn]=(0,Q.useState)(!1),ln=(0,Q.useRef)(()=>{}),un=(0,Q.useRef)(()=>{}),dn=(0,Q.useRef)(null),fn=(0,Q.useRef)(null),pn=(0,Q.useRef)(0),mn=Q.useRef(new dC).current,hn=Q.useSyncExternalStore(mn.subscribe,mn.getSnapshot),[_n,vn]=Q.useState(C?.hasInitialPrompt??!1),W=hn||_n,[yn,bn]=Q.useState(void 0),xn=Q.useRef(0),Sn=Q.useRef(!1),Cn=Q.useRef(0),wn=Q.useRef(0),Tn=Q.useRef(null),Dn=Q.useCallback(()=>{Cn.current=Date.now(),wn.current=0,Tn.current=null},[]),On=Q.useRef(!1);hn&&!On.current&&Dn(),On.current=hn;let kn=Q.useCallback(e=>{vn(e),e&&Dn()},[Dn]),jn=Q.useRef(null),Mn=Q.useRef(void 0),Pn=Q.useRef(void 0),[Fn,In]=Q.useState(!1),[Ln,Rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Ln?.notifications&&Ln.notifications.forEach(e=>{ut({key:`auto-updater-notification`,text:e,priority:`low`})})},[Ln,ut]),(0,Q.useEffect)(()=>{Ol()&&La().then(e=>{e&&ut({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[zn,Bn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-CH9C_hoL.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-DYa00dVv.js`);t()&&Bn(!0)})()},[]);let[Vn,Hn]=(0,Q.useState)(null),Un=(0,Q.useRef)(null),Wn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Un.current={...n,isLocalJSXCommand:!0},Hn(n);return}if(Un.current){if(e?.clearLocalJSX){Un.current=null,Hn(null),on.current=Date.now();return}return}if(e?.clearLocalJSX){Hn(null);return}Hn(e)},[]),[Gn,Kn]=(0,Q.useState)([]),[qn,Jn]=(0,Q.useState)(null),[Yn,Xn]=(0,Q.useState)([]),[Zn,Qn]=(0,Q.useState)([]),$n=(0,Q.useRef)(new Map),er=Z(e=>e.settings.terminalTitleFromRename)===!1?void 0:Rd(Fe()),[tr,nr]=(0,Q.useState)(),rr=(0,Q.useRef)((i?.length??0)>0),ir=P?.agentType,ar=er??ir??tr??`Claude Code`,or=Gn.length>0||Zn.length>0||pe||me,sr=Vn?.isLocalJSXCommand===!0&&Vn?.jsx!=null,cr=W&&!or&&!sr;(0,Q.useEffect)(()=>{if(W&&!or&&!sr)return iC(),()=>aC()},[W,or,sr]);let lr=or||sr?`waiting`:W?`busy`:`idle`,ur=lr===`waiting`?Gn.length>0?`approve ${Gn[0].tool.name}`:pe?`worker request`:me?`sandbox request`:sr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Bg({status:lr,waitingFor:ur})},[lr,ur]);let dr=gn(`tengu_terminal_sidebar`,!1)&&(En().showStatusInTerminalTab??!1);T(j||!dr?null:lr),(0,Q.useEffect)(()=>(Bu(Kn),()=>ed()),[Kn]);let[G,fr]=(0,Q.useState)(i??[]),pr=(0,Q.useRef)(G),hr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=pr.current,n=typeof e==`function`?e(pr.current):e;if(pr.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(sl)?Sn.current=!1:xn.current=n.length}fr(n)},[]),gr=(0,Q.useCallback)(e=>{e===void 0?Sn.current=!1:(xn.current=pr.current.length,Sn.current=!0),bn(e)},[]),{dividerIndex:_r,dividerYRef:vr,onScrollAway:yr,onRepin:br,jumpToNew:q,shiftDivider:xr}=Ex(G.length);MF(G,K,W);let[Cr,wr]=(0,Q.useState)(null),Er=(0,Q.useRef)(null),Dr=(0,Q.useMemo)(()=>Cx(G,_r),[_r,G.length]),Or=(0,Q.useCallback)(()=>{dn.current?.scrollToBottom(),br(),wr(null)},[br,wr]),kr=G.at(-1),Ar=kr!=null&&sl(kr);(0,Q.useEffect)(()=>{Ar&&Or()},[Ar,kr,Or]);let{maybeLoadOlder:jr}=EN({config:C,setMessages:K,scrollRef:dn,onPrepend:xr}),Mr=(0,Q.useCallback)((e,t)=>{pn.current=Date.now(),e?br():(yr(t),jr(t),V(e=>e.companionReaction===void 0?e:{...e,companionReaction:void 0}))},[br,yr,jr,V]),Nr=HN(a,K),Pr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),Fr=G.length-Pr.length;Fr>0&&J(`[useDeferredValue] Messages deferred by ${Fr} (${Pr.length}→${G.length})`);let[Ir,Lr]=(0,Q.useState)(null),[Rr,zr]=(0,Q.useState)(()=>mS()),Br=(0,Q.useRef)(Rr);Br.current=Rr;let Vr=(0,Q.useRef)(null),Hr=(0,Q.useCallback)(e=>{mt(Br.current,e)||(Br.current===``&&e!==``&&Date.now()-pn.current>=xz&&Or(),Br.current=e,zr(e),In(e.trim().length>0))},[In,Or,mt]);(0,Q.useEffect)(()=>{if(Rr.trim().length===0)return;let e=setTimeout(In,1500,!1);return()=>clearTimeout(e)},[Rr]);let[Ur,Wr]=(0,Q.useState)(`prompt`),[Gr,qr]=(0,Q.useState)(),Jr=(0,Q.useCallback)(e=>{let t=new Set(e);De(e=>e.filter(e=>t.has(e.name)||zo.has(e)))},[De]),[Yr,Xr]=(0,Q.useState)(new Set),Zr=(0,Q.useRef)(!1),$r=dN({config:C,setMessages:K,setIsLoading:kn,onInit:Jr,setToolUseConfirmQueue:Kn,tools:Vt,setStreamingToolUses:$t,setStreamMode:Yt,setInProgressToolUseIDs:Xr}),ei=mN({config:w,setMessages:K,setIsLoading:kn,setToolUseConfirmQueue:Kn,tools:Vt}),ti=hN({session:E,setMessages:K,setIsLoading:kn,setToolUseConfirmQueue:Kn,tools:Vt}),ni=ti.isRemoteMode?ti:ei.isRemoteMode?ei:$r,[ri,ii]=(0,Q.useState)({}),[ai,oi]=(0,Q.useState)(0),si=(0,Q.useRef)(0),ci=(0,Q.useRef)([]),li=(0,Q.useCallback)(e=>{let t=si.current;if(si.current=e(t),si.current>t){let e=ci.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=si.current}}},[]),[ui,di]=(0,Q.useState)(null),fi=!(Z(e=>e.settings.prefersReducedMotion)??!1)&&!Se(),hi=(0,Q.useCallback)(e=>{fi&&di(e)},[fi]),gi=ui&&fi&&ui.substring(0,ui.lastIndexOf(`
143
- `)+1)||null,[_i,yi]=(0,Q.useState)(0),[bi,xi]=(0,Q.useState)(null),[Si,Ci]=(0,Q.useState)(null),[wi,Ti]=(0,Q.useState)(null),[Ei,Di]=(0,Q.useState)(!1),[Ai,ji]=(0,Q.useState)(void 0),[Mi,Ni]=(0,Q.useState)(!1),[Pi,Fi]=(0,Q.useState)(zS()),[Ii,Li]=(0,Q.useState)(null),Ri=(0,Q.useRef)(!1),zi=(0,Q.useRef)(_i);zi.current=_i;let[Bi]=(0,Q.useState)(()=>({current:bs(i,s)}));Cl(()=>{Bi.current=Rl()});let[Vi,Hi]=(0,Q.useState)(En().hasAcknowledgedCostThreshold),[Ui,Wi]=(0,Q.useState)(`INSERT`),[Gi,Ji]=(0,Q.useState)(!1),[Yi,Xi]=(0,Q.useState)(!1),[Zi,$i]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_e&&Gi&&Ji(!1)},[_e,Gi]);let ta=le(),na=(0,Q.useRef)(ta);na.current=ta;let[ra]=ae(),ia=Q.useRef(!1),oa=(0,Q.useCallback)(()=>{if(ia.current)return;ia.current=!0;let e=pr.current.slice(Ba.current);for(let t of Zh(e))za.current.add(t);Ba.current=pr.current.length,GF({theme:ra,readFileState:Ra.current,bashTools:za.current}).then(async e=>{if(e){let t=await e.content({theme:ra});V(e=>({...e,spinnerTip:t})),KF(e)}else V(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[V,ra]),sa=(0,Q.useCallback)(()=>{kn(!1),gr(void 0),si.current=0,ci.current=[],di(null),$t([]),xi(null),Ci(null),Ti(null),oa(),xv(),rp()},[oa]),ca=(0,Q.useMemo)(()=>Dh(B).some(e=>e.status===`running`),[B]);(0,Q.useEffect)(()=>{if(!ca&&jn.current!==null){let e=Date.now()-jn.current,t=Mn.current;jn.current=null,Mn.current=void 0,K(n=>[...n,Gg(e,t,mi(n,Sa))])}},[ca,K]);let da=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(F.mode!==`auto`){da.current=!1;return}if(da.current||(En().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,kt(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Na($F,`warning`)])},800,da,K);return()=>clearTimeout(e)}},[F.mode,K]);let fa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(fa.current)return;let e=Fl();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;fa.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,Na(`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`)])},[K]);let ma=(0,Q.useMemo)(()=>{let e=G.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`)},[G,Yr]),{onBeforeQuery:ha,onTurnComplete:_a,render:va}=zN({enabled:M,setMessages:K,inputValue:Rr,setInputValue:Hr,setToolJSX:Wn}),xa=(!Vn||Vn.showSpinner===!0)&&Gn.length===0&&Zn.length===0&&(W||yn||ca||Io()>0)&&!pe&&!ma&&(!gi||je),wa=Gn.length>0||Zn.length>0||Yn.length>0||ge.queue.length>0||he.queue.length>0,Ta=nF(G,W,ai,`session`,wa),Da=RN(K),Oa=_L(G,ai),ka=(0,Q.useMemo)(()=>({...Ta,handleSelect:e=>{Qa.current=!1;let t=Ta.handleSelect(e);e===`bad`&&!t&&oL(`feedback_survey_bad`)&&(Ya(`feedback_survey_bad`),Qa.current=!0)}}),[Ta]),ja=hF(G,W,wa,{enabled:!O}),Ma=uF(G,W,wa,{enabled:!O}),Pa=iz(G,W,wa,ka.state!==`closed`||ja.state!==`closed`||Ma.state!==`closed`);VP({autoConnectIdeFlag:p,ideToInstallExtension:yt,setDynamicMcpConfig:Le,setShowIdeOnboarding:Dt,setIDEInstallationState:Tt}),qF(o,oe,e=>V(t=>({...t,fileHistory:e})));let Fa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Ku(n.messages);{let t=(h_(),e(il)).matchSessionMode(n.mode);if(t){let{getAgentDefinitionsWithOverrides:n,getActiveAgentsFromList:r}=(Nm(),e(dg));n.cache.clear?.();let i=await n(ft());V(e=>({...e,agentDefinitions:{...i,allAgents:i.allAgents,activeAgents:r(i.allAgents)}})),a.push(Na(t,`warning`))}}let o=_m();await ea(`resume`,{getAppState:()=>H.getState(),setAppState:V,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await ug(`resume`,{sessionId:t,agentType:P?.agentType,model:Te});a.push(...s),r===`fork`?bm(n,Ss(t)):mp(n,Ss(t)),_b(n,V),n.fileHistorySnapshots&&Ll(n);let{agentDefinition:c}=hb(n.agentSetting,b,L);ee(c),V(e=>({...e,agent:c?.agentType})),V(e=>({...e,standaloneAgentContext:gb(n.agentName,n.agentColor)})),$a(n.agentName),Wa(a,n.projectPath??ft()),sa(),rn(null),Fi(t);let l=Tc(t);Fp(),St(),lt(Ss(t),n.fullPath?AS(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-DA6TudSH.js`);if(await u(),await $f(),Yh(),hd(n),n.goal){let{hydrateGoalFromTranscript:r}=(zm(),e(Td)),i=new Map;i.set(t,n.goal),r(i,t)}if(rr.current=!0,nr(void 0),r!==`fork`)vb(),yb(n.worktreeSession),Qi(),rc({abortController:new AbortController,getAppState:()=>H.getState(),setAppState:V});else{let e=Fl();e&&Ha(e)}{let{saveMode:t}=(ho(),e(la)),{isCoordinatorMode:n}=(h_(),e(il));t(n()?`coordinator`:`normal`)}l&&ct(l),Bi.current&&r!==`fork`&&(Bi.current=lh(a,n.contentReplacements??[])),K(()=>a),Wn(null),Hr(``),Y(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Y(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[sa,V]),[Ia]=(0,Q.useState)(()=>iv(100)),Ra=(0,Q.useRef)(Ia),za=(0,Q.useRef)(new Set),Ba=(0,Q.useRef)(0),Va=(0,Q.useRef)(new Set),Ua=(0,Q.useRef)(new Set),Wa=(0,Q.useCallback)((e,t)=>{let n=Sm(e,t,100);Ra.current=ov(Ra.current,n);for(let t of Zh(e))za.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Wa(i,ft()),rc({abortController:new AbortController,getAppState:()=>H.getState(),setAppState:V}))},[]);let{status:Ga,reverify:Ka}=UN(),[Ja,Ya]=(0,Q.useState)(null),Qa=(0,Q.useRef)(!1),[eo,to]=(0,Q.useState)(null),[no,io]=(0,Q.useState)(!1),ao=!W&&Mi;function oo(){if(no||eo)return;if(Ei)return`message-selector`;if(Fn)return;if(Yn[0])return`sandbox-permission`;let e=!Vn||Vn.shouldContinueAnimation;if(e&&Gn[0])return`tool-permission`;if(e&&Zn[0])return`prompt`;if(e&&he.queue[0])return`worker-sandbox-permission`;if(e&&ge.queue[0])return`elicitation`;if(e&&ao)return`cost`;if(e&&Ii)return`idle-return`;if(e&&!W&&_e)return`ultraplan-choice`;if(e&&!W&&ve)return`ultraplan-launch`;if(e&&Et)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Ot)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&zn)return`undercover-callout`;if(e&&jt)return`effort-callout`;if(e&&Nt)return`remote-callout`;if(e&&It)return`lsp-recommendation`;if(e&&Rt)return`plugin-hint`;if(e&&Bt.visible)return`search-extra-tools-hint`;if(e&&Pt)return`desktop-upsell`}let so=oo(),co=Fn&&(Yn[0]||Gn[0]||Zn[0]||he.queue[0]||ge.queue[0]||ao);Pn.current=so,(0,Q.useEffect)(()=>{if(!W)return;let e=so===`tool-permission`,t=Date.now();e&&Tn.current===null?Tn.current=t:!e&&Tn.current!==null&&(wn.current+=t-Tn.current,Tn.current=null)},[so,W]);let lo=(0,Q.useRef)(so);(0,Q.useLayoutEffect)(()=>{lo.current===`tool-permission`!=(so===`tool-permission`)&&Or(),lo.current=so},[so,Or]);function uo(){if(so!==`elicitation`){if(on.current!==0&&Date.now()-on.current<500){on.current=0,J(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(on.current=0,J(`[onCancel] focusedInputDialog=${so} streamMode=${Jt}`),sz?.pauseProactive(),mn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ya(),e(ul)),{persistCurrentGoal:r}=(zm(),e(Td));t()?.status===`active`&&(n(),r())}if(cn(!0),mn.forceEnd(),Ri.current=!1,ui?.trim()&&K(e=>[...e,fp({content:ui})]),sa(),Ne(null),so===`tool-permission`)Gn[0]?.onAbort(),Kn([]);else if(so===`prompt`){for(let e of Zn)e.reject(Error(`Prompt cancelled by user`));Qn([]),nn?.abort(`user-cancel`)}else ni.isRemoteMode?ni.cancelRequest():nn?.abort(`user-cancel`);rn(null),_a(pr.current,!0)}}let fo=(0,Q.useCallback)(()=>{let e=Eu(Rr,0);e&&(Hr(e.text),Wr(`prompt`),e.images.length>0&&ii(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Hr,Wr,Rr,ii]),po={setToolUseConfirmQueue:Kn,onCancel:uo,onAgentsKilled:()=>K(e=>[...e,Vf()]),isMessageSelectorVisible:Ei||!!Gi,screen:ze,abortSignal:nn?.signal,popCommandFromQueue:fo,vimMode:Ui,isLocalJSXCommand:Vn?.isLocalJSXCommand,isSearchingHistory:Yi,isHelpOpen:Zi,inputMode:Ur,inputValue:Rr,streamMode:Jt};(0,Q.useEffect)(()=>{Ue()>=5&&!Mi&&!Vi&&(Y(`tengu_cost_threshold_reached`,{}),Hi(!0),Xt()&&Ni(!0))},[G,Mi,Vi]);let mo=(0,Q.useCallback)(async e=>{if(Nn()&&rm()){let t=Uh(),n=await Ff(e.host,t);return new Promise(r=>{if(!n){Xn(t=>[...t,{hostPattern:e,resolvePromise:r}]);return}Ed({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))}Xn(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=H.getState().replBridgePermissionCallbacks;if(t){let n=zS();t.sendRequest(n,nb,{host:e.host},zS(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;Xn(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=$n.current.get(e.host);if(i){for(let e of i)e();$n.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=$n.current.get(e.host)??[];a.push(i),$n.current.set(e.host,a)}}})},[V,H]);(0,Q.useEffect)(()=>{let e=Gs.getSandboxUnavailableReason();if(e){if(Gs.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Ea(1,`other`);return}J(`sandbox disabled: ${e}`,{level:`warn`}),ut({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(R,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[ut]),Gs.isSandboxingEnabled()&&Gs.initialize(mo).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Sr(e)}\n`),Ea(1,`other`)});let go=(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))},Kn)},[V,Kn]);(0,Q.useEffect)(()=>(ds(go),()=>Du()),[go]);let _o=gP(Kn,go),vo=(0,Q.useCallback)((e,t,r,i)=>{let a=H.getState(),o=()=>{let e=H.getState(),t=rb(Vt,Gu(e.toolPermissionContext,e.mcp.tools),e.toolPermissionContext.mode);return P?Mc(P,t,!1,!0).resolvedTools:t};return{abortController:r,options:{commands:qt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:D,mcpClients:wP(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:Ct,isNonInteractiveSession:!1,dynamicMcpConfig:Ie,theme:ra,agentDefinitions:Gt?{...a.agentDefinitions,allowedAgentTypes:Gt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>H.getState(),setAppState:V,messages:e,setMessages:K,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||Di(!0)},onChangeAPIKey:Ka,readFileState:Ra.current,setToolJSX:Wn,addNotification:ut,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{To(e,we)},onChangeDynamicMcpConfig:Re,onInstallIDEExtension:xt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ua.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Va.current,setResponseLength:li,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=si.current;ci.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Yt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Ci(`claudeBlue_FOR_SYSTEM_SPINNER`),Ti(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),xi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:xi(`Compacting conversation`);break;case`compact_end`:xi(null),Ci(null),Ti(null);break}},setInProgressToolUseIDs:Xr,setHasInterruptibleToolInProgress:e=>{Zr.current=e},resume:Fa,setConversationId:Fi,requestPrompt:void 0,contentReplacementState:Bi.current}},[qt,Vt,P,n,d,Ct,Ie,ra,Gt,H,V,Ka,ut,K,Re,Fa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Qn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),y,h,g,Fi]),{handleBackgroundSession:yo}=UP({setMessages:K,setIsLoading:kn,resetLoadingState:sa,setAbortController:rn,onBackgroundQuery:(0,Q.useCallback)(()=>{nn?.abort(`background`);let e=Qu(e=>e.mode===`task-notification`);(async()=>{let t=vo(pr.current,[],new AbortController,Te),[n,r,i]=await Promise.all([lf(t.options.tools,Te,Array.from(F.additionalWorkingDirectories.keys()),t.options.mcpClients),Wl(),Bo()]),a=$m({mainThreadAgentDefinition:P,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Pc(e).catch(()=>[])).map(Zs),s=new Set;for(let e of pr.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)));Xf({messages:[...pr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:_o,toolUseContext:t,querySource:Bl()},description:ar,setAppState:V,agentDefinition:P})})()},[nn,Te,F,P,vo,h,g,_o,V])}),bo=(0,Q.useCallback)(t=>{ba(t,t=>{if(xu(t)?(Ol()?K(e=>{let n=Rc(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),Fi(zS()),sz?.setContextBlocked(!1)):t.type===`progress`&&fl(t.data?.type)?K(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]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?sz?.setContextBlocked(!0):t.type===`assistant`&&sz?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(ec(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}=(ya(),e(ul)),{persistCurrentGoal:r}=(zm(),e(Td));t()?.status===`active`&&(n(),r(),ut({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)},Yt,$t,e=>{K(t=>t.filter(t=>t!==e)),rh(e.uuid)},tn,e=>{let t=Date.now(),n=si.current;ci.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},hi)},[K,li,Yt,$t,tn,hi]),So=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=wP(d,H.getState().mcp.clients);Kd.handleQueryStart(e);let t=Il(e);t&&a_(t)}if(oy(),!j&&!er&&!ir&&!rr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?ec(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(rr.current=!0,My(n,new AbortController().signal).then(e=>{e?nr(e):rr.current=!1},()=>{rr.current=!1}))}if(H.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(xu)&&(Fi(zS()),sz?.setContextBlocked(!1)),sa(),rn(null);return}let s=vo(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}yg(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,Px(F,V,H.getState().fastMode),lf(c,a,Array.from(F.additionalWorkingDirectories.keys()),l),Wl(),Bo()]),m={...f,...oz(l,Kl()?S_():void 0),...sz?.isProactiveActive()&&!na.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};yg(`query_context_loading_end`);let _=$m({mainThreadAgentDefinition:P,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,yg(`query_query_start`),bt(),Xe(),at();for await(let t of Vo({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:_o,toolUseContext:s,querySource:Bl()}))bo(t);if(typeof globalThis.fireCompanionObserver==`function`){let e=globalThis.fireCompanionObserver;e(pr.current,e=>V(t=>t.companionReaction===e?t:{...t,companionReaction:e}))}if(yg(`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=nt(),a=Be(),o=qe(),s=rt(),c=pt(),l=He(),u=Date.now()-Cn.current;K(e=>[...e,oh({ttftMs:r?Sz(t):t[0],otps:r?Sz(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:An()})])}sa(),sm(),await v?.(pr.current)},[d,sa,vo,F,V,h,v,g,_o,P,bo,er,j]),Co=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{if(Nn()){let e=pi(),t=vi();e&&t&&Gv(e,t,!0)}let c=mn.tryStart();if(c===null)return Y(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>ec(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{g_({value:e,mode:`prompt`}),t===0&&Y(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Qo.current=!1,cn(!1),Dn(),K(t=>[...t,...e]),si.current=0,Ne((o?Wu(o):null)??Me()),ci.current=[],$t([]),di(null);let c=pr.current;if(o&&await ha(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await So(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(mn.end(c)){cn(t.signal.aborted),yi(Date.now()),Ri.current=!1,sa(),await _a(pr.current,t.signal.aborted),ln.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&V(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Me()!==null&&Me()>0&&!t.signal.aborted&&(e={tokens:tt(),limit:Me(),nudges:Ye()}),Ne(null);let n=Date.now()-Cn.current-wn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!ke&&(Dh(H.getState().tasks).some(e=>e.status===`running`)?(jn.current===null&&(jn.current=Cn.current),e&&(Mn.current=e)):K(t=>[...t,Gg(n,e,mi(t,Sa))])),rn(null)}if(t.signal.reason===`user-cancel`&&!mn.isActive&&Br.current===``&&Io()===0&&!H.getState().viewingAgentTaskId){let e=pr.current,t=e.findLast(ab);t&&sb(e,e.lastIndexOf(t))&&(zu(),un.current(t))}}return!0},[So,V,sa,mn,ha,_a]),wo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=se;if(!e||W||wo.current)return;wo.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Mg():void 0,{clearConversation:n}=await import(`./conversation-NrAy2em3.js`);await n({setMessages:K,readFileState:Ra.current,discoveredSkillNames:Va.current,loadedNestedMemoryPaths:Ua.current,getAppState:()=>H.getState(),setAppState:V,setConversationId:Fi}),rr.current=!1,nr(void 0),za.current.clear(),Ba.current=0,t&&o_(Fe(),t)}V(t=>{let n=e.mode?qs(t.toolPermissionContext,KT(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=kc({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),qa()&&pa(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Nr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Eo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Ki();rn(t),Co([e.message],t,!0,[],Te)}setTimeout(e=>{e.current=!1},100,wo)}t(e)},[se,W,K,V,Co,Te,Wt]);let Eo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Or(),sz?.resumeProactive(),es(e)){let n=ro({content:e});K(e=>[...e,n]),r?.fromKeybinding||ga({display:Xh(e,Ur),pastedContents:ri}),Hr(``),t.setCursorOffset(0),t.clearBuffer(),ii({}),Wr(`prompt`),_t(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=eu(e,ri).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=qt.find(e=>Yf(e)&&(e.name===a||e.aliases?.includes(a)||cp(e)===a));s?.name===`clear`&&hr.current&&(Y(`tengu_idle_return_action`,{action:`hint_converted`,variant:hr.current,idleMinutes:Math.round((Date.now()-zi.current)/6e4),messageCount:pr.current.length,totalInputTokens:wt()}),hr.current=!1);let c=mn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Br.current.trim()&&(Hr(``),t.setCursorOffset(0),t.clearBuffer(),ii({}));let n=us(e).filter(e=>ri[e.id]?.type===`text`),i=n.length;Y(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ri[t.id]?.content.length??0),0)}),Y(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Wn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(ut({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Ol())){let e=r?.displayArgs??o;i.push(kg(ua(cp(s),e)),kg(`<${Kr}>${$_(n)}</${Kr}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>ro({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),Gr!==void 0&&(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0))},r=vo(pr.current,[],Ki(),Te),i=await(await s.load()).call(n,r,o);i&&!e&&Wn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(ni.isRemoteMode&&!e.trim())return;{let r=gn(`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`&&!En().idleReturnDismissed&&!Ri.current&&!n&&!e.trim().startsWith(`/`)&&zi.current>0&&wt()>=a){let n=(Date.now()-zi.current)/6e4;if(n>=i&&r===`dialog`){Li({input:e,idleMinutes:n}),Hr(``),t.setCursorOffset(0),t.clearBuffer();return}}}r?.fromKeybinding||(ga({display:n?e:Xh(e,Ur),pastedContents:n?{}:ri}),Ur===`bash`&&YO(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||ni.isRemoteMode;if(Gr!==void 0&&!i&&a?(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0)):a&&(r?.fromKeybinding||(Hr(``),t.setCursorOffset(0)),ii({})),a&&(Wr(`prompt`),_t(void 0),oi(e=>e+1),t.clearBuffer(),ia.current=!1,!i&&Ur===`prompt`&&!n&&!ni.isRemoteMode&&(gr(e),Dn()),V(e=>({...e,attribution:Ev(e.attribution,e=>{Cp(e).catch(e=>{J(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await qi(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:Ra,cwd:ft()});if(t){let e=Ki();rn(e),Co([],e,!0,[],Te)}return}if(ni.isRemoteMode&&!(i&&qt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Yf(t)&&(t.name===n||t.aliases?.includes(n)||cp(t)===n)})?.type===`local-jsx`)){let t=Object.values(ri),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=ro({content:i,imagePasteIds:r});K(e=>[...e,o]),await ni.sendMessage(a,{uuid:o.uuid});return}await Nr(),await vP({input:e,helpers:t,queryGuard:mn,isExternalLoading:_n,mode:Ur,commands:qt,onInputChange:Hr,setPastedContents:ii,setToolJSX:Wn,getToolUseContext:vo,messages:pr.current,mainLoopModel:Te,pastedContents:ri,ideSelection:gt,setUserInputOnProcessing:gr,setAbortController:rn,abortController:nn,onQuery:Co,setAppState:V,querySource:Bl(),onBeforeQuery:_,canUseTool:_o,addNotification:ut,setMessages:K,streamMode:Zt.current,hasInterruptibleToolInProgress:Zr.current}),(i||W)&&Gr!==void 0&&(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0))},[mn,W,_n,Ur,qt,Hr,Wr,ii,oi,_t,Wn,vo,Te,ri,gt,gr,rn,ut,Co,Gr,qr,V,_,_o,$r,K,Nr,Or]),Do=(0,Q.useCallback)(async(e,t,n)=>{pc(t)?(Rp(t.id,ro({content:e}),V),t.status===`running`?Us(t.id,e,V):hg({agentId:t.id,prompt:e,toolUseContext:vo(pr.current,[],new AbortController,Te),canUseTool:_o}).catch(e=>{J(`resumeAgentBackground failed: ${Sr(e)}`),ut({key:`resume-agent-failed-${t.id}`,jsx:(0,$.jsxs)(R,{color:`error`,children:[`Failed to resume agent: `,Sr(e)]}),priority:`low`})})):Rm(t.id,e,void 0,V),Hr(``),n.setCursorOffset(0),n.clearBuffer()},[V,Hr,vo,_o,Te,ut]),Oo=(0,Q.useCallback)(()=>{let e=Ja?sL(Ja):`/issue`;Ya(null),Eo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{J(`Auto-run ${e} failed: ${Sr(t)}`)})},[Eo,Ja]),ko=(0,Q.useCallback)(()=>{Ya(null)},[]),Ao=(0,Q.useCallback)(()=>{Eo(process.env.USER_TYPE===`ant`?`/issue`:`/feedback`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{J(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Eo]),jo=(0,Q.useRef)(Eo);jo.current=Eo;let Mo=(0,Q.useCallback)(()=>{jo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),No=(0,Q.useCallback)(async()=>{if(io(!0),bl()){WS(`tmux`,[`detach-client`],{stdio:`ignore`}),io(!1);return}if(Fl()!==null){to((0,$.jsx)(bx,{showWorktree:!0,onDone:()=>{},onCancel:()=>{to(null),io(!1)}}));return}let e=await(await l_.load()).call(()=>{});to(e),e===null&&io(!1)},[]),Fo=(0,Q.useCallback)(()=>{Di(e=>!e)},[]),Lo=(0,Q.useCallback)(e=>{let t=pr.current,n=t.lastIndexOf(e);if(n===-1)return;Y(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),Fi(zS()),bd();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}}))},[K,V]),Ro=(0,Q.useCallback)(e=>{Lo(e);let t=Ep(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}}}),ii(n)}}},[Lo,Hr]);un.current=Ro;let Ho=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Ro,e)},[Ro]),Uo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Wo,handlers:Go}=Za(Cr,wr,Er,{copy:e=>void Ce(e).then(e=>{e&&process.stdout.write(e),ut({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Uo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!ab(n))return;let r=!await Zp(oe,n.uuid),i=sb(G,t);r&&i?(uo(),Ho(n)):(ji(n),Di(!0))}});async function qo(){Ka();let e=await Au();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
144
- `);J(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else J(`No CLAUDE.md/rules files found`);for(let t of e)Ra.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})}BN(pS()),mC(G,G.length===i?.length);let{sendBridgeResult:Jo}=jC(G,K,an,qt,Te);ln.current=Jo,VN();let Yo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ue.length<1){Yo.current=!1;return}Yo.current||(Yo.current=!0,kt(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[ue.length]),SP({executeQueuedInput:(0,Q.useCallback)(async e=>{await vP({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:mn,commands:qt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Wn,getToolUseContext:vo,messages:G,mainLoopModel:Te,ideSelection:gt,setUserInputOnProcessing:gr,setAbortController:rn,onQuery:Co,setAppState:V,querySource:Bl(),onBeforeQuery:_,canUseTool:_o,addNotification:ut,setMessages:K,queuedCommands:e})},[mn,qt,Wn,vo,G,Te,gt,gr,_o,rn,Co,ut,V,_]),hasActiveLocalJsxUI:sr,queryGuard:mn}),(0,Q.useEffect)(()=>{Xs.recordUserActivity(),We(!0)},[Rr,ai]),(0,Q.useEffect)(()=>{ai===1&&TS()},[ai]),(0,Q.useEffect)(()=>{if(W||ai===0||_i===0)return;let e=setTimeout((e,t,n,r,i)=>{if(et()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=En().messageIdleNotifThresholdMs&&To({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},En().messageIdleNotifThresholdMs,_i,W,Vn,Pn,we);return()=>clearTimeout(e)},[W,Vn,ai,_i,we]),(0,Q.useEffect)(()=>{if(_i===0||W)return;let e=gn(`tengu_willow_mode`,`off`);if(e!==`hint`&&e!==`hint_v2`||En().idleReturnDismissed)return;let t=Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5);if(wt()<t)return;let n=Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75)*6e4-(Date.now()-_i),r=setTimeout((e,t,n,r,i)=>{if(n.current.length===0)return;let a=wt(),o=ki(a),s=(Date.now()-e)/6e4;t({key:`idle-return-hint`,jsx:r===`hint_v2`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!0,children:`new task? `}),(0,$.jsx)(R,{color:`suggestion`,children:`/clear`}),(0,$.jsx)(R,{dimColor:!0,children:` to save `}),(0,$.jsxs)(R,{color:`suggestion`,children:[o,` tokens`]})]}):(0,$.jsxs)(R,{color:`warning`,children:[`new task? /clear to save `,o,` tokens`]}),priority:`medium`,timeoutMs:2147483647}),i.current=r,Y(`tengu_idle_return_action`,{action:`hint_shown`,variant:r,idleMinutes:Math.round(s),messageCount:n.current.length,totalInputTokens:a})},Math.max(0,n),_i,ut,pr,e,hr);return()=>{clearTimeout(r),dt(`idle-return-hint`),hr.current=!1}},[_i,W,ut,dt]);let Xo=(0,Q.useCallback)((e,t)=>{if(mn.isActive||$l().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 cm([n]),t=e.attachmentCommands[0];if(!t)return;let r=Ki();rn(r);let i=ro({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await Co([i],r,!0,[],Te)!==!1}catch(t){try{await ap({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Tr(),priority:`later`})}catch(e){Qr(mr(e))}Qr(mr(t));return}if(a)try{let t=await ap({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Tr(),priority:`later`});for(let e of t)g_(e)}catch(e){Qr(mr(e))}})().catch(e=>{Qr(mr(e))}),!0},[Co,Te,H]),{relayPipeMessage:Zo,pipeReturnHadErrorRef:Qo}=hz(),$o=nz({setInputValueRaw:zr,inputValueRef:Br,insertTextRef:Vr});IP({enabled:Nn(),isLoading:W,focusedInputDialog:so,onSubmitMessage:Xo}),CP({isLoading:W,onSubmitMessage:Xo}),Z(e=>Ry(e));let{routeToSelectedPipes:es}=gz({store:H,setAppState:V,addNotification:ut});{let e=H.getState().kairosEnabled;pz({isLoading:W,assistantMode:e,setMessages:K})}process.env.USER_TYPE===`ant`&&RP({taskListId:S,isLoading:W,onSubmitTask:Xo}),fz?.({isLoading:W||se!==null,queuedCommandsLength:ue.length,hasActiveLocalJsxUI:sr,isInPlanMode:F.mode===`plan`,onQueueTick:e=>g_(e)}),mz?.({isLoading:W||se!==null,wasAborted:sn,queuedCommandsLength:ue.length,hasActiveLocalJsxUI:sr,isInPlanMode:F.mode===`plan`,isQueryActiveNow:mn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;K(e=>[...e,ro({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{ut({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(!ke){mv(null);return}if(!W){if(Ae!==null&&ue.length===0&&!sr&&F.mode!==`plan`&&se===null){mv({enabled:!0,phase:`standby`,next_tick_at:Ae,sleep_until:null});return}mv({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[se,W,sr,ke,Ae,ue.length,F.mode]),(0,Q.useEffect)(()=>{ue.some(e=>e.priority===`now`)&&an.current?.abort(`interrupt`)},[ue]);let ts=(0,Q.useRef)(qo);ts.current=qo;let ns=(0,Q.useRef)(Kd);ns.current=Kd,(0,Q.useEffect)(()=>(ts.current(),()=>{ns.current.shutdown()}),[]);let{internal_eventEmitter:rs}=ie(),[as,os]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
142
+ </goal-steering>`}var HR=t((()=>{})),UR=r({useGoalContinuation:()=>GR});function WR(e){J(`[goal] hook: ${e}`)}function GR(e){let t=(0,KR.useRef)(e);t.current=e;let n=(0,KR.useRef)(!1),r=(0,KR.useRef)(!1);(0,KR.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){WR(`skip: queryActiveNow=true`);return}if(e.wasAborted){WR(`skip: wasAborted=true`);return}if(n.current)return;if(Vl().length>0){WR(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){WR(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){WR(`skip: planMode`);return}let t=Rs();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=VR(t);J(`[goal] hook: budget limit reached, injecting wrap-up prompt`),h_({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){WR(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){ou()&&(Ed(),e.onMaxTurnsReached?.()),J(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=b_();Ed();let a=BR(t);J(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),h_({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 KR,qR=t((()=>{KR=n(L(),1),q(),ba(),HR(),Ss()})),JR=r({AntModelSwitchCallout:()=>YR,shouldShowModelSwitchCallout:()=>XR});function YR(e){return null}function XR(){return!1}var ZR=t((()=>{})),QR=r({UndercoverAutoCallout:()=>$R});function $R({onDone:e}){return(0,ez.useEffect)(()=>{e()},[e]),null}var ez,tz=t((()=>{ez=n(L(),1)}));ot(),ms(),Ci(),f(),H(),ny(),jb(),Rm(),hu(),q(),s(),Pi(),qf(),Bv(),Vm(),Yi(),_i(),kh(),fa(),Oo(),Dm(),ub(),As(),Xp(),Cs(),gf(),za(),Np(),gr(),Zr(),wr(),lo(),Pg(),Wo(),xd(),lr(),In(),Cr(),an(),ql(),Ny(),Xr(),Lg(),Qd(),Ly(),hd(),Ma(),ld(),Rb(),X(),Ng(),go(),Up(),pc(),Yn(),ma(),yc(),Ss(),_f(),vf(),so(),im(),Da();var nz=(yR(),e(sR)).useVoiceIntegration,rz=(yR(),e(sR)).VoiceKeybindingHandler,iz=process.env.USER_TYPE===`ant`?(wR(),e(bR)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),az=process.env.USER_TYPE===`ant`?(DR(),e(TR)).useAntOrgWarningNotification:()=>{},oz=(m_(),e(el)).getCoordinatorUserContext,sz=(vv(),e(sv)),cz=e=>()=>{},lz=()=>!1,uz=()=>null,dz=(e,t)=>!1,fz=(MR(),e(OR)).useProactive,pz=(RR(),e(NR)).useScheduledTasks,mz=(qR(),e(UR)).useGoalContinuation,hz=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),gz=()=>({routeToSelectedPipes:()=>!1}),_z=process.env.USER_TYPE===`ant`?(ZR(),e(JR)).AntModelSwitchCallout:null,vz=process.env.USER_TYPE===`ant`?(ZR(),e(JR)).shouldShowModelSwitchCallout:()=>!1,yz=process.env.USER_TYPE===`ant`?(tz(),e(QR)).UndercoverAutoCallout:null,bz=[],xz=3e3;function Sz(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 Cz({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=fc(`app:toggleTranscript`,`Global`,`ctrl+o`),o=fc(`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)(R,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${p.arrowUp}${p.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)(R,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{flexGrow:1}),(0,$.jsxs)(R,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function wz({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=px({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)(R,{children:`/`}),(0,$.jsx)(R,{children:s.slice(0,f)}),(0,$.jsx)(R,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(R,{children:s.slice(f+1)}),(0,$.jsx)(U,{flexGrow:1}),l===`building`?(0,$.jsx)(R,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(R,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(R,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(R,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var Tz=[`⠂`,`⠐`],Ez=`✳`,Dz=960;function Oz({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=le(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%Tz.length),Dz,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?Tz[a]??Ez:Ez;return ve(n?null:r?t:`${s} ${t}`),null}var kz=`<${qr}>`;function Az(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(kz)}function jz({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:a,initialFileHistorySnapshots:o,initialContentReplacements:s,initialAgentName:l,initialAgentColor:u,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:E,thinkingConfig:D}){let O=!!C,j=(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),M=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&c(process.env.CLAUDE_MORERIGHT),[]),N=(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>c(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(J(`[REPL:mount] REPL mounted, disabled=${y}`),()=>J(`[REPL:unmount] REPL unmounting`)),[y]);let[P,ee]=(0,Q.useState)(b),F=Z(e=>e.toolPermissionContext),te=Z(e=>e.verbose),ne=Z(e=>e.mcp),re=Z(e=>e.plugins),L=Z(e=>e.agentDefinitions),oe=Z(e=>e.fileHistory),se=Z(e=>e.initialMessage),ue=pD(),de=Z(e=>e.spinnerTip),fe=Z(e=>e.expandedView)===`tasks`,pe=Z(e=>e.pendingWorkerRequest),me=Z(e=>e.pendingSandboxRequest),z=Z(e=>e.teamContext),B=Z(e=>e.tasks),he=Z(e=>e.workerSandboxPermissions),ge=Z(e=>e.elicitation),_e=Z(e=>e.ultraplanPendingChoice),ve=Z(e=>e.ultraplanLaunchPending),ye=Z(e=>e.viewingAgentTaskId),V=Af(),be=ye?B[ye]:void 0,xe=Bp(be)&&be.retain&&!be.diskLoaded;(0,Q.useEffect)(()=>{if(!ye||!xe)return;let e=ye;rp(So(e)).then(t=>{V(n=>{let r=n.tasks[e];if(!Bp(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 H=ef(),we=A(),Te=Lb(),[Ee,De]=(0,Q.useState)(t);DP(O?void 0:vt(),De);let ke=Q.useSyncExternalStore(sz?.subscribeToProactiveChanges??cz,sz?.isProactiveActive??lz),Ae=Q.useSyncExternalStore(sz?.subscribeToProactiveChanges??cz,sz?.getNextTickAt??uz),je=Z(e=>e.isBriefOnly),Pe=(0,Q.useMemo)(()=>Iu(F),[F,ke,je]);Mx();let[Ie,Le]=(0,Q.useState)(f),Re=(0,Q.useCallback)(e=>{Le(e)},[Le]),[ze,Ve]=(0,Q.useState)(`prompt`),[Ge,Ke]=(0,Q.useState)(!1),[Je,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(``),it=(0,Q.useRef)(0),ot=(0,Q.useRef)(void 0),st=(0,Q.useRef)(!1),{addNotification:ut,removeNotification:dt}=Bh(),mt=dz,ht=TP(d,ne.clients),[gt,_t]=(0,Q.useState)(void 0),[yt,xt]=(0,Q.useState)(null),[Ct,Tt]=(0,Q.useState)(null),[Et,Dt]=(0,Q.useState)(!1),[Ot,At]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`?vz():!1),[jt,Mt]=(0,Q.useState)(()=>JP(Te)),Nt=Z(e=>e.showRemoteCallout),[Pt,Ft]=(0,Q.useState)(()=>SS());HI(),GI(),BI({ideSelection:gt,mcpClients:ht,ideInstallationStatus:Ct}),QF({mcpClients:ht}),OI(),kI(),hx(),FI(Te),rL(),II(Te),RI(),az(),wF(),PF(),BF(),tI(),QI();let{recommendation:It,handleResponse:Lt}=_I(),{recommendation:Rt,handleResponse:zt}=bI(),Bt=DI(),Vt=(0,Q.useMemo)(()=>[...Pe,...r],[Pe,r]);zy({enabled:!O});let Ht=c_();(0,Q.useEffect)(()=>{O||MI(V)},[V,O]),HF(O?bz:ht,F.mode),QN(V,i,{enabled:!O});let Ut=kb(Vt,ne.tools,F),{tools:Wt,allowedAgentTypes:Gt}=(0,Q.useMemo)(()=>{if(!P)return{tools:Ut,allowedAgentTypes:void 0};let e=wc(P,Ut,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[P,Ut]),Kt=EP(EP(Ee,re.commands),ne.commands),qt=(0,Q.useMemo)(()=>x?[]:Kt,[x,Kt]);NC(O?bz:ne.clients),AP(O?bz:ne.clients,_t);let[Jt,Yt]=(0,Q.useState)(`responding`),Zt=(0,Q.useRef)(Jt);Zt.current=Jt;let[Qt,$t]=(0,Q.useState)([]),[en,tn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(en&&!en.isStreaming&&en.streamingEndedAt){let e=3e4-(Date.now()-en.streamingEndedAt);if(e>0){let t=setTimeout(tn,e,null);return()=>clearTimeout(t)}else tn(null)}},[en]);let[nn,rn]=(0,Q.useState)(null),an=(0,Q.useRef)(null);an.current=nn;let on=(0,Q.useRef)(0),[sn,cn]=(0,Q.useState)(!1),ln=(0,Q.useRef)(()=>{}),un=(0,Q.useRef)(()=>{}),dn=(0,Q.useRef)(null),fn=(0,Q.useRef)(null),pn=(0,Q.useRef)(0),mn=Q.useRef(new dC).current,hn=Q.useSyncExternalStore(mn.subscribe,mn.getSnapshot),[_n,vn]=Q.useState(C?.hasInitialPrompt??!1),W=hn||_n,[yn,bn]=Q.useState(void 0),xn=Q.useRef(0),Sn=Q.useRef(!1),Cn=Q.useRef(0),wn=Q.useRef(0),Tn=Q.useRef(null),Dn=Q.useCallback(()=>{Cn.current=Date.now(),wn.current=0,Tn.current=null},[]),On=Q.useRef(!1);hn&&!On.current&&Dn(),On.current=hn;let kn=Q.useCallback(e=>{vn(e),e&&Dn()},[Dn]),jn=Q.useRef(null),Mn=Q.useRef(void 0),Pn=Q.useRef(void 0),[Fn,In]=Q.useState(!1),[Ln,Rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Ln?.notifications&&Ln.notifications.forEach(e=>{ut({key:`auto-updater-notification`,text:e,priority:`low`})})},[Ln,ut]),(0,Q.useEffect)(()=>{El()&&Ra().then(e=>{e&&ut({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[zn,Bn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-BwT0TbYF.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-nakrQDLh.js`);t()&&Bn(!0)})()},[]);let[Vn,Hn]=(0,Q.useState)(null),Un=(0,Q.useRef)(null),Wn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Un.current={...n,isLocalJSXCommand:!0},Hn(n);return}if(Un.current){if(e?.clearLocalJSX){Un.current=null,Hn(null),on.current=Date.now();return}return}if(e?.clearLocalJSX){Hn(null);return}Hn(e)},[]),[Gn,Kn]=(0,Q.useState)([]),[qn,Jn]=(0,Q.useState)(null),[Yn,Xn]=(0,Q.useState)([]),[Zn,Qn]=(0,Q.useState)([]),$n=(0,Q.useRef)(new Map),er=Z(e=>e.settings.terminalTitleFromRename)===!1?void 0:Bd(Fe()),[tr,nr]=(0,Q.useState)(),rr=(0,Q.useRef)((i?.length??0)>0),ir=P?.agentType,ar=er??ir??tr??`Claude Code`,or=Gn.length>0||Zn.length>0||pe||me,sr=Vn?.isLocalJSXCommand===!0&&Vn?.jsx!=null,cr=W&&!or&&!sr;(0,Q.useEffect)(()=>{if(W&&!or&&!sr)return iC(),()=>aC()},[W,or,sr]);let lr=or||sr?`waiting`:W?`busy`:`idle`,ur=lr===`waiting`?Gn.length>0?`approve ${Gn[0].tool.name}`:pe?`worker request`:me?`sandbox request`:sr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{vl({status:lr,waitingFor:ur})},[lr,ur]);let dr=gn(`tengu_terminal_sidebar`,!1)&&(En().showStatusInTerminalTab??!1);T(j||!dr?null:lr),(0,Q.useEffect)(()=>(_h(Kn),()=>Wu()),[Kn]);let[G,fr]=(0,Q.useState)(i??[]),pr=(0,Q.useRef)(G),hr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=pr.current,n=typeof e==`function`?e(pr.current):e;if(pr.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(il)?Sn.current=!1:xn.current=n.length}fr(n)},[]),gr=(0,Q.useCallback)(e=>{e===void 0?Sn.current=!1:(xn.current=pr.current.length,Sn.current=!0),bn(e)},[]),{dividerIndex:_r,dividerYRef:vr,onScrollAway:yr,onRepin:br,jumpToNew:q,shiftDivider:xr}=Ex(G.length);MF(G,K,W);let[Cr,wr]=(0,Q.useState)(null),Er=(0,Q.useRef)(null),Dr=(0,Q.useMemo)(()=>Cx(G,_r),[_r,G.length]),Or=(0,Q.useCallback)(()=>{dn.current?.scrollToBottom(),br(),wr(null)},[br,wr]),kr=G.at(-1),Ar=kr!=null&&il(kr);(0,Q.useEffect)(()=>{Ar&&Or()},[Ar,kr,Or]);let{maybeLoadOlder:jr}=EN({config:C,setMessages:K,scrollRef:dn,onPrepend:xr}),Mr=(0,Q.useCallback)((e,t)=>{pn.current=Date.now(),e?br():(yr(t),jr(t),V(e=>e.companionReaction===void 0?e:{...e,companionReaction:void 0}))},[br,yr,jr,V]),Nr=HN(a,K),Pr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),Fr=G.length-Pr.length;Fr>0&&J(`[useDeferredValue] Messages deferred by ${Fr} (${Pr.length}→${G.length})`);let[Ir,Lr]=(0,Q.useState)(null),[Rr,zr]=(0,Q.useState)(()=>mS()),Br=(0,Q.useRef)(Rr);Br.current=Rr;let Vr=(0,Q.useRef)(null),Hr=(0,Q.useCallback)(e=>{mt(Br.current,e)||(Br.current===``&&e!==``&&Date.now()-pn.current>=xz&&Or(),Br.current=e,zr(e),In(e.trim().length>0))},[In,Or,mt]);(0,Q.useEffect)(()=>{if(Rr.trim().length===0)return;let e=setTimeout(In,1500,!1);return()=>clearTimeout(e)},[Rr]);let[Ur,Wr]=(0,Q.useState)(`prompt`),[Gr,qr]=(0,Q.useState)(),Jr=(0,Q.useCallback)(e=>{let t=new Set(e);De(e=>e.filter(e=>t.has(e.name)||Vo.has(e)))},[De]),[Yr,Xr]=(0,Q.useState)(new Set),Zr=(0,Q.useRef)(!1),$r=dN({config:C,setMessages:K,setIsLoading:kn,onInit:Jr,setToolUseConfirmQueue:Kn,tools:Vt,setStreamingToolUses:$t,setStreamMode:Yt,setInProgressToolUseIDs:Xr}),ei=mN({config:w,setMessages:K,setIsLoading:kn,setToolUseConfirmQueue:Kn,tools:Vt}),ti=hN({session:E,setMessages:K,setIsLoading:kn,setToolUseConfirmQueue:Kn,tools:Vt}),ni=ti.isRemoteMode?ti:ei.isRemoteMode?ei:$r,[ri,ii]=(0,Q.useState)({}),[ai,oi]=(0,Q.useState)(0),si=(0,Q.useRef)(0),ci=(0,Q.useRef)([]),li=(0,Q.useCallback)(e=>{let t=si.current;if(si.current=e(t),si.current>t){let e=ci.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=si.current}}},[]),[ui,di]=(0,Q.useState)(null),fi=!(Z(e=>e.settings.prefersReducedMotion)??!1)&&!Se(),hi=(0,Q.useCallback)(e=>{fi&&di(e)},[fi]),gi=ui&&fi&&ui.substring(0,ui.lastIndexOf(`
143
+ `)+1)||null,[_i,yi]=(0,Q.useState)(0),[bi,xi]=(0,Q.useState)(null),[Si,Ci]=(0,Q.useState)(null),[wi,Ti]=(0,Q.useState)(null),[Ei,Di]=(0,Q.useState)(!1),[Ai,ji]=(0,Q.useState)(void 0),[Mi,Ni]=(0,Q.useState)(!1),[Pi,Fi]=(0,Q.useState)(zS()),[Ii,Li]=(0,Q.useState)(null),Ri=(0,Q.useRef)(!1),zi=(0,Q.useRef)(_i);zi.current=_i;let[Bi]=(0,Q.useState)(()=>({current:ys(i,s)}));xl(()=>{Bi.current=Rl()});let[Vi,Hi]=(0,Q.useState)(En().hasAcknowledgedCostThreshold),[Ui,Wi]=(0,Q.useState)(`INSERT`),[Gi,Ji]=(0,Q.useState)(!1),[Yi,Xi]=(0,Q.useState)(!1),[Zi,$i]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_e&&Gi&&Ji(!1)},[_e,Gi]);let ta=le(),ra=(0,Q.useRef)(ta);ra.current=ta;let[ia]=ae(),aa=Q.useRef(!1),ca=(0,Q.useCallback)(()=>{if(aa.current)return;aa.current=!0;let e=pr.current.slice(Ga.current);for(let t of tg(e))Wa.current.add(t);Ga.current=pr.current.length,GF({theme:ia,readFileState:Ha.current,bashTools:Wa.current}).then(async e=>{if(e){let t=await e.content({theme:ia});V(e=>({...e,spinnerTip:t})),KF(e)}else V(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[V,ia]),da=(0,Q.useCallback)(()=>{kn(!1),gr(void 0),si.current=0,ci.current=[],di(null),$t([]),xi(null),Ci(null),Ti(null),ca(),xv(),Sm()},[ca]),fa=(0,Q.useMemo)(()=>ag(B).some(e=>e.status===`running`),[B]);(0,Q.useEffect)(()=>{if(!fa&&jn.current!==null){let e=Date.now()-jn.current,t=Mn.current;jn.current=null,Mn.current=void 0,K(n=>[...n,Kg(e,t,mi(n,Ca))])}},[fa,K]);let ma=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(F.mode!==`auto`){ma.current=!1;return}if(ma.current||(En().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,kt(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Na($F,`warning`)])},800,ma,K);return()=>clearTimeout(e)}},[F.mode,K]);let ga=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ga.current)return;let e=Nl();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ga.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,Na(`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`)])},[K]);let _a=(0,Q.useMemo)(()=>{let e=G.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`)},[G,Yr]),{onBeforeQuery:ya,onTurnComplete:Sa,render:Ta}=zN({enabled:M,setMessages:K,inputValue:Rr,setInputValue:Hr,setToolJSX:Wn}),Da=(!Vn||Vn.showSpinner===!0)&&Gn.length===0&&Zn.length===0&&(W||yn||fa||Lo()>0)&&!pe&&!_a&&(!gi||je),Oa=Gn.length>0||Zn.length>0||Yn.length>0||ge.queue.length>0||he.queue.length>0,ka=nF(G,W,ai,`session`,Oa),ja=RN(K),Ma=_L(G,ai),Fa=(0,Q.useMemo)(()=>({...ka,handleSelect:e=>{no.current=!1;let t=ka.handleSelect(e);e===`bad`&&!t&&oL(`feedback_survey_bad`)&&(to(`feedback_survey_bad`),no.current=!0)}}),[ka]),Ia=hF(G,W,Oa,{enabled:!O}),La=uF(G,W,Oa,{enabled:!O}),za=iz(G,W,Oa,Fa.state!==`closed`||Ia.state!==`closed`||La.state!==`closed`);VP({autoConnectIdeFlag:p,ideToInstallExtension:yt,setDynamicMcpConfig:Le,setShowIdeOnboarding:Dt,setIDEInstallationState:Tt}),qF(o,oe,e=>V(t=>({...t,fileHistory:e})));let Ba=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Sh(n.messages);{let t=(m_(),e(el)).matchSessionMode(n.mode);if(t){let{getAgentDefinitionsWithOverrides:n,getActiveAgentsFromList:r}=(Im(),e(pg));n.cache.clear?.();let i=await n(ft());V(e=>({...e,agentDefinitions:{...i,allAgents:i.allAgents,activeAgents:r(i.allAgents)}})),a.push(Na(t,`warning`))}}let o=bm();await ea(`resume`,{getAppState:()=>H.getState(),setAppState:V,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await na(`resume`,{sessionId:t,agentType:P?.agentType,model:Te});a.push(...s),r===`fork`?Kf(n,xs(t)):ch(n,xs(t)),_b(n,V),n.fileHistorySnapshots&&Pa(n);let{agentDefinition:c}=hb(n.agentSetting,b,L);ee(c),V(e=>({...e,agent:c?.agentType})),V(e=>({...e,standaloneAgentContext:gb(n.agentName,n.agentColor)})),Vg(n.agentName),Ya(a,n.projectPath??ft()),da(),rn(null),Fi(t);let l=_c(t);Lp(),St(),lt(xs(t),n.fullPath?AS(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-DA6TudSH.js`);if(await u(),await ep(),$h(),vd(n),n.goal){let{hydrateGoalFromTranscript:r}=(Sp(),e(jh)),i=new Map;i.set(t,n.goal),r(i,t)}if(rr.current=!0,nr(void 0),r!==`fork`)vb(),yb(n.worktreeSession),Qi(),pa({abortController:new AbortController,getAppState:()=>H.getState(),setAppState:V});else{let e=Nl();e&&Ua(e)}{let{saveMode:t}=(go(),e(la)),{isCoordinatorMode:n}=(m_(),e(el));t(n()?`coordinator`:`normal`)}l&&ct(l),Bi.current&&r!==`fork`&&(Bi.current=uh(a,n.contentReplacements??[])),K(()=>a),Wn(null),Hr(``),Y(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Y(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[da,V]),[Va]=(0,Q.useState)(()=>iv(100)),Ha=(0,Q.useRef)(Va),Wa=(0,Q.useRef)(new Set),Ga=(0,Q.useRef)(0),Ka=(0,Q.useRef)(new Set),Ja=(0,Q.useRef)(new Set),Ya=(0,Q.useCallback)((e,t)=>{let n=Tm(e,t,100);Ha.current=ov(Ha.current,n);for(let t of tg(e))Wa.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Ya(i,ft()),pa({abortController:new AbortController,getAppState:()=>H.getState(),setAppState:V}))},[]);let{status:Qa,reverify:$a}=UN(),[eo,to]=(0,Q.useState)(null),no=(0,Q.useRef)(!1),[io,ao]=(0,Q.useState)(null),[oo,so]=(0,Q.useState)(!1),co=!W&&Mi;function lo(){if(oo||io)return;if(Ei)return`message-selector`;if(Fn)return;if(Yn[0])return`sandbox-permission`;let e=!Vn||Vn.shouldContinueAnimation;if(e&&Gn[0])return`tool-permission`;if(e&&Zn[0])return`prompt`;if(e&&he.queue[0])return`worker-sandbox-permission`;if(e&&ge.queue[0])return`elicitation`;if(e&&co)return`cost`;if(e&&Ii)return`idle-return`;if(e&&!W&&_e)return`ultraplan-choice`;if(e&&!W&&ve)return`ultraplan-launch`;if(e&&Et)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Ot)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&zn)return`undercover-callout`;if(e&&jt)return`effort-callout`;if(e&&Nt)return`remote-callout`;if(e&&It)return`lsp-recommendation`;if(e&&Rt)return`plugin-hint`;if(e&&Bt.visible)return`search-extra-tools-hint`;if(e&&Pt)return`desktop-upsell`}let uo=lo(),fo=Fn&&(Yn[0]||Gn[0]||Zn[0]||he.queue[0]||ge.queue[0]||co);Pn.current=uo,(0,Q.useEffect)(()=>{if(!W)return;let e=uo===`tool-permission`,t=Date.now();e&&Tn.current===null?Tn.current=t:!e&&Tn.current!==null&&(wn.current+=t-Tn.current,Tn.current=null)},[uo,W]);let po=(0,Q.useRef)(uo);(0,Q.useLayoutEffect)(()=>{po.current===`tool-permission`!=(uo===`tool-permission`)&&Or(),po.current=uo},[uo,Or]);function mo(){if(uo!==`elicitation`){if(on.current!==0&&Date.now()-on.current<500){on.current=0,J(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(on.current=0,J(`[onCancel] focusedInputDialog=${uo} streamMode=${Jt}`),sz?.pauseProactive(),mn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ba(),e(sl)),{persistCurrentGoal:r}=(Sp(),e(jh));t()?.status===`active`&&(n(),r())}if(cn(!0),mn.forceEnd(),Ri.current=!1,ui?.trim()&&K(e=>[...e,mp({content:ui})]),da(),Ne(null),uo===`tool-permission`)Gn[0]?.onAbort(),Kn([]);else if(uo===`prompt`){for(let e of Zn)e.reject(Error(`Prompt cancelled by user`));Qn([]),nn?.abort(`user-cancel`)}else ni.isRemoteMode?ni.cancelRequest():nn?.abort(`user-cancel`);rn(null),Sa(pr.current,!0)}}let ho=(0,Q.useCallback)(()=>{let e=Au(Rr,0);e&&(Hr(e.text),Wr(`prompt`),e.images.length>0&&ii(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Hr,Wr,Rr,ii]),vo={setToolUseConfirmQueue:Kn,onCancel:mo,onAgentsKilled:()=>K(e=>[...e,Vf()]),isMessageSelectorVisible:Ei||!!Gi,screen:ze,abortSignal:nn?.signal,popCommandFromQueue:ho,vimMode:Ui,isLocalJSXCommand:Vn?.isLocalJSXCommand,isSearchingHistory:Yi,isHelpOpen:Zi,inputMode:Ur,inputValue:Rr,streamMode:Jt};(0,Q.useEffect)(()=>{Ue()>=5&&!Mi&&!Vi&&(Y(`tengu_cost_threshold_reached`,{}),Hi(!0),Xt()&&Ni(!0))},[G,Mi,Vi]);let yo=(0,Q.useCallback)(async e=>{if(Nn()&&qh()){let t=Dd(),n=await vg(e.host,t);return new Promise(r=>{if(!n){Xn(t=>[...t,{hostPattern:e,resolvePromise:r}]);return}Mh({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))}Xn(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=H.getState().replBridgePermissionCallbacks;if(t){let n=zS();t.sendRequest(n,nb,{host:e.host},zS(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;Xn(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=$n.current.get(e.host);if(i){for(let e of i)e();$n.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=$n.current.get(e.host)??[];a.push(i),$n.current.set(e.host,a)}}})},[V,H]);(0,Q.useEffect)(()=>{let e=Bs.getSandboxUnavailableReason();if(e){if(Bs.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Ea(1,`other`);return}J(`sandbox disabled: ${e}`,{level:`warn`}),ut({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(R,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[ut]),Bs.isSandboxingEnabled()&&Bs.initialize(yo).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Sr(e)}\n`),Ea(1,`other`)});let bo=(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))},Kn)},[V,Kn]);(0,Q.useEffect)(()=>(Es(bo),()=>ls()),[bo]);let xo=gP(Kn,bo),Co=(0,Q.useCallback)((e,t,r,i)=>{let a=H.getState(),o=()=>{let e=H.getState(),t=rb(Vt,xh(e.toolPermissionContext,e.mcp.tools),e.toolPermissionContext.mode);return P?wc(P,t,!1,!0).resolvedTools:t};return{abortController:r,options:{commands:qt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:D,mcpClients:wP(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:Ct,isNonInteractiveSession:!1,dynamicMcpConfig:Ie,theme:ia,agentDefinitions:Gt?{...a.agentDefinitions,allowedAgentTypes:Gt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>H.getState(),setAppState:V,messages:e,setMessages:K,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||Di(!0)},onChangeAPIKey:$a,readFileState:Ha.current,setToolJSX:Wn,addNotification:ut,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{Eo(e,we)},onChangeDynamicMcpConfig:Re,onInstallIDEExtension:xt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ja.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Ka.current,setResponseLength:li,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=si.current;ci.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Yt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Ci(`claudeBlue_FOR_SYSTEM_SPINNER`),Ti(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),xi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:xi(`Compacting conversation`);break;case`compact_end`:xi(null),Ci(null),Ti(null);break}},setInProgressToolUseIDs:Xr,setHasInterruptibleToolInProgress:e=>{Zr.current=e},resume:Ba,setConversationId:Fi,requestPrompt:void 0,contentReplacementState:Bi.current}},[qt,Vt,P,n,d,Ct,Ie,ia,Gt,H,V,$a,ut,K,Re,Ba,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Qn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),y,h,g,Fi]),{handleBackgroundSession:wo}=UP({setMessages:K,setIsLoading:kn,resetLoadingState:da,setAbortController:rn,onBackgroundQuery:(0,Q.useCallback)(()=>{nn?.abort(`background`);let e=td(e=>e.mode===`task-notification`);(async()=>{let t=Co(pr.current,[],new AbortController,Te),[n,r,i]=await Promise.all([pf(t.options.tools,Te,Array.from(F.additionalWorkingDirectories.keys()),t.options.mcpClients),Wl(),Ho()]),a=of({mainThreadAgentDefinition:P,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Ec(e).catch(()=>[])).map(Ks),s=new Set;for(let e of pr.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)));hm({messages:[...pr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:xo,toolUseContext:t,querySource:Bl()},description:ar,setAppState:V,agentDefinition:P})})()},[nn,Te,F,P,Co,h,g,xo,V])}),To=(0,Q.useCallback)(t=>{xa(t,t=>{if(Cu(t)?(El()?K(e=>{let n=jc(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),Fi(zS()),sz?.setContextBlocked(!1)):t.type===`progress`&&ll(t.data?.type)?K(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]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?sz?.setContextBlocked(!0):t.type===`assistant`&&sz?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Ys(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}=(ba(),e(sl)),{persistCurrentGoal:r}=(Sp(),e(jh));t()?.status===`active`&&(n(),r(),ut({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)},Yt,$t,e=>{K(t=>t.filter(t=>t!==e)),nh(e.uuid)},tn,e=>{let t=Date.now(),n=si.current;ci.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},hi)},[K,li,Yt,$t,tn,hi]),Do=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=wP(d,H.getState().mcp.clients);Jd.handleQueryStart(e);let t=Il(e);t&&i_(t)}if(oy(),!j&&!er&&!ir&&!rr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Ys(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(rr.current=!0,My(n,new AbortController().signal).then(e=>{e?nr(e):rr.current=!1},()=>{rr.current=!1}))}if(H.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(Cu)&&(Fi(zS()),sz?.setContextBlocked(!1)),da(),rn(null);return}let s=Co(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}xg(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,Px(F,V,H.getState().fastMode),pf(c,a,Array.from(F.additionalWorkingDirectories.keys()),l),Wl(),Ho()]),m={...f,...oz(l,Kl()?x_():void 0),...sz?.isProactiveActive()&&!ra.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};xg(`query_context_loading_end`);let _=of({mainThreadAgentDefinition:P,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,xg(`query_query_start`),bt(),Xe(),at();for await(let t of Uo({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:xo,toolUseContext:s,querySource:Bl()}))To(t);if(typeof globalThis.fireCompanionObserver==`function`){let e=globalThis.fireCompanionObserver;e(pr.current,e=>V(t=>t.companionReaction===e?t:{...t,companionReaction:e}))}if(xg(`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=nt(),a=Be(),o=qe(),s=rt(),c=pt(),l=He(),u=Date.now()-Cn.current;K(e=>[...e,ah({ttftMs:r?Sz(t):t[0],otps:r?Sz(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:An()})])}da(),um(),await v?.(pr.current)},[d,da,Co,F,V,h,v,g,xo,P,To,er,j]),Oo=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{if(Nn()){let e=pi(),t=vi();e&&t&&Gv(e,t,!0)}let c=mn.tryStart();if(c===null)return Y(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Ys(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{h_({value:e,mode:`prompt`}),t===0&&Y(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{ns.current=!1,cn(!1),Dn(),K(t=>[...t,...e]),si.current=0,Ne((o?Ju(o):null)??Me()),ci.current=[],$t([]),di(null);let c=pr.current;if(o&&await ya(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await Do(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(mn.end(c)){cn(t.signal.aborted),yi(Date.now()),Ri.current=!1,da(),await Sa(pr.current,t.signal.aborted),ln.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&V(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Me()!==null&&Me()>0&&!t.signal.aborted&&(e={tokens:tt(),limit:Me(),nudges:Ye()}),Ne(null);let n=Date.now()-Cn.current-wn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!ke&&(ag(H.getState().tasks).some(e=>e.status===`running`)?(jn.current===null&&(jn.current=Cn.current),e&&(Mn.current=e)):K(t=>[...t,Kg(n,e,mi(t,Ca))])),rn(null)}if(t.signal.reason===`user-cancel`&&!mn.isActive&&Br.current===``&&Lo()===0&&!H.getState().viewingAgentTaskId){let e=pr.current,t=e.findLast(ab);t&&sb(e,e.lastIndexOf(t))&&(Uu(),un.current(t))}}return!0},[Do,V,da,mn,ya,Sa]),ko=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=se;if(!e||W||ko.current)return;ko.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?ap():void 0,{clearConversation:n}=await import(`./conversation-uY-V0SNK.js`);await n({setMessages:K,readFileState:Ha.current,discoveredSkillNames:Ka.current,loadedNestedMemoryPaths:Ja.current,getAppState:()=>H.getState(),setAppState:V,setConversationId:Fi}),rr.current=!1,nr(void 0),Wa.current.clear(),Ga.current=0,t&&p_(Fe(),t)}V(t=>{let n=e.mode?Hs(t.toolPermissionContext,KT(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=xc({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),Ll()&&bc(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Nr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Ao(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Ki();rn(t),Oo([e.message],t,!0,[],Te)}setTimeout(e=>{e.current=!1},100,ko)}t(e)},[se,W,K,V,Oo,Te,Wt]);let Ao=(0,Q.useCallback)(async(e,t,n,r)=>{if(Or(),sz?.resumeProactive(),is(e)){let n=ro({content:e});K(e=>[...e,n]),r?.fromKeybinding||va({display:eg(e,Ur),pastedContents:ri}),Hr(``),t.setCursorOffset(0),t.clearBuffer(),ii({}),Wr(`prompt`),_t(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=nu(e,ri).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=qt.find(e=>Xf(e)&&(e.name===a||e.aliases?.includes(a)||lp(e)===a));s?.name===`clear`&&hr.current&&(Y(`tengu_idle_return_action`,{action:`hint_converted`,variant:hr.current,idleMinutes:Math.round((Date.now()-zi.current)/6e4),messageCount:pr.current.length,totalInputTokens:wt()}),hr.current=!1);let c=mn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Br.current.trim()&&(Hr(``),t.setCursorOffset(0),t.clearBuffer(),ii({}));let n=cs(e).filter(e=>ri[e.id]?.type===`text`),i=n.length;Y(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ri[t.id]?.content.length??0),0)}),Y(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Wn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(ut({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!El())){let e=r?.displayArgs??o;i.push(Ag(ua(lp(s),e)),Ag(`<${Kr}>${$_(n)}</${Kr}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>ro({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),Gr!==void 0&&(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0))},r=Co(pr.current,[],Ki(),Te),i=await(await s.load()).call(n,r,o);i&&!e&&Wn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(ni.isRemoteMode&&!e.trim())return;{let r=gn(`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`&&!En().idleReturnDismissed&&!Ri.current&&!n&&!e.trim().startsWith(`/`)&&zi.current>0&&wt()>=a){let n=(Date.now()-zi.current)/6e4;if(n>=i&&r===`dialog`){Li({input:e,idleMinutes:n}),Hr(``),t.setCursorOffset(0),t.clearBuffer();return}}}r?.fromKeybinding||(va({display:n?e:eg(e,Ur),pastedContents:n?{}:ri}),Ur===`bash`&&YO(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||ni.isRemoteMode;if(Gr!==void 0&&!i&&a?(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0)):a&&(r?.fromKeybinding||(Hr(``),t.setCursorOffset(0)),ii({})),a&&(Wr(`prompt`),_t(void 0),oi(e=>e+1),t.clearBuffer(),aa.current=!1,!i&&Ur===`prompt`&&!n&&!ni.isRemoteMode&&(gr(e),Dn()),V(e=>({...e,attribution:Ev(e.attribution,e=>{Ep(e).catch(e=>{J(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await qi(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:Ha,cwd:ft()});if(t){let e=Ki();rn(e),Oo([],e,!0,[],Te)}return}if(ni.isRemoteMode&&!(i&&qt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Xf(t)&&(t.name===n||t.aliases?.includes(n)||lp(t)===n)})?.type===`local-jsx`)){let t=Object.values(ri),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=ro({content:i,imagePasteIds:r});K(e=>[...e,o]),await ni.sendMessage(a,{uuid:o.uuid});return}await Nr(),await vP({input:e,helpers:t,queryGuard:mn,isExternalLoading:_n,mode:Ur,commands:qt,onInputChange:Hr,setPastedContents:ii,setToolJSX:Wn,getToolUseContext:Co,messages:pr.current,mainLoopModel:Te,pastedContents:ri,ideSelection:gt,setUserInputOnProcessing:gr,setAbortController:rn,abortController:nn,onQuery:Oo,setAppState:V,querySource:Bl(),onBeforeQuery:_,canUseTool:xo,addNotification:ut,setMessages:K,streamMode:Zt.current,hasInterruptibleToolInProgress:Zr.current}),(i||W)&&Gr!==void 0&&(Hr(Gr.text),t.setCursorOffset(Gr.cursorOffset),ii(Gr.pastedContents),qr(void 0))},[mn,W,_n,Ur,qt,Hr,Wr,ii,oi,_t,Wn,Co,Te,ri,gt,gr,rn,ut,Oo,Gr,qr,V,_,xo,$r,K,Nr,Or]),jo=(0,Q.useCallback)(async(e,t,n)=>{Bp(t)?($p(t.id,ro({content:e}),V),t.status===`running`?_o(t.id,e,V):Kd({agentId:t.id,prompt:e,toolUseContext:Co(pr.current,[],new AbortController,Te),canUseTool:xo}).catch(e=>{J(`resumeAgentBackground failed: ${Sr(e)}`),ut({key:`resume-agent-failed-${t.id}`,jsx:(0,$.jsxs)(R,{color:`error`,children:[`Failed to resume agent: `,Sr(e)]}),priority:`low`})})):bp(t.id,e,void 0,V),Hr(``),n.setCursorOffset(0),n.clearBuffer()},[V,Hr,Co,xo,Te,ut]),Mo=(0,Q.useCallback)(()=>{let e=eo?sL(eo):`/issue`;to(null),Ao(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{J(`Auto-run ${e} failed: ${Sr(t)}`)})},[Ao,eo]),No=(0,Q.useCallback)(()=>{to(null)},[]),Po=(0,Q.useCallback)(()=>{Ao(process.env.USER_TYPE===`ant`?`/issue`:`/feedback`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{J(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Ao]),Io=(0,Q.useRef)(Ao);Io.current=Ao;let Ro=(0,Q.useCallback)(()=>{Io.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),zo=(0,Q.useCallback)(async()=>{if(so(!0),Rd()){WS(`tmux`,[`detach-client`],{stdio:`ignore`}),so(!1);return}if(Nl()!==null){ao((0,$.jsx)(bx,{showWorktree:!0,onDone:()=>{},onCancel:()=>{ao(null),so(!1)}}));return}let e=await(await s_.load()).call(()=>{});ao(e),e===null&&so(!1)},[]),Bo=(0,Q.useCallback)(()=>{Di(e=>!e)},[]),Wo=(0,Q.useCallback)(e=>{let t=pr.current,n=t.lastIndexOf(e);if(n===-1)return;Y(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),Fi(zS()),Sd();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}}))},[K,V]),Go=(0,Q.useCallback)(e=>{Wo(e);let t=kp(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}}}),ii(n)}}},[Wo,Hr]);un.current=Go;let Ko=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Go,e)},[Go]),qo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Yo,handlers:Xo}=Za(Cr,wr,Er,{copy:e=>void Ce(e).then(e=>{e&&process.stdout.write(e),ut({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=qo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!ab(n))return;let r=!await qa(oe,n.uuid),i=sb(G,t);r&&i?(mo(),Ko(n)):(ji(n),Di(!0))}});async function Zo(){$a();let e=await Pu();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
144
+ `);J(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else J(`No CLAUDE.md/rules files found`);for(let t of e)Ha.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})}BN(pS()),mC(G,G.length===i?.length);let{sendBridgeResult:Qo}=jC(G,K,an,qt,Te);ln.current=Qo,VN();let $o=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ue.length<1){$o.current=!1;return}$o.current||($o.current=!0,kt(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[ue.length]),SP({executeQueuedInput:(0,Q.useCallback)(async e=>{await vP({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:mn,commands:qt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Wn,getToolUseContext:Co,messages:G,mainLoopModel:Te,ideSelection:gt,setUserInputOnProcessing:gr,setAbortController:rn,onQuery:Oo,setAppState:V,querySource:Bl(),onBeforeQuery:_,canUseTool:xo,addNotification:ut,setMessages:K,queuedCommands:e})},[mn,qt,Wn,Co,G,Te,gt,gr,xo,rn,Oo,ut,V,_]),hasActiveLocalJsxUI:sr,queryGuard:mn}),(0,Q.useEffect)(()=>{sa.recordUserActivity(),We(!0)},[Rr,ai]),(0,Q.useEffect)(()=>{ai===1&&TS()},[ai]),(0,Q.useEffect)(()=>{if(W||ai===0||_i===0)return;let e=setTimeout((e,t,n,r,i)=>{if(et()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=En().messageIdleNotifThresholdMs&&Eo({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},En().messageIdleNotifThresholdMs,_i,W,Vn,Pn,we);return()=>clearTimeout(e)},[W,Vn,ai,_i,we]),(0,Q.useEffect)(()=>{if(_i===0||W)return;let e=gn(`tengu_willow_mode`,`off`);if(e!==`hint`&&e!==`hint_v2`||En().idleReturnDismissed)return;let t=Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5);if(wt()<t)return;let n=Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75)*6e4-(Date.now()-_i),r=setTimeout((e,t,n,r,i)=>{if(n.current.length===0)return;let a=wt(),o=ki(a),s=(Date.now()-e)/6e4;t({key:`idle-return-hint`,jsx:r===`hint_v2`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{dimColor:!0,children:`new task? `}),(0,$.jsx)(R,{color:`suggestion`,children:`/clear`}),(0,$.jsx)(R,{dimColor:!0,children:` to save `}),(0,$.jsxs)(R,{color:`suggestion`,children:[o,` tokens`]})]}):(0,$.jsxs)(R,{color:`warning`,children:[`new task? /clear to save `,o,` tokens`]}),priority:`medium`,timeoutMs:2147483647}),i.current=r,Y(`tengu_idle_return_action`,{action:`hint_shown`,variant:r,idleMinutes:Math.round(s),messageCount:n.current.length,totalInputTokens:a})},Math.max(0,n),_i,ut,pr,e,hr);return()=>{clearTimeout(r),dt(`idle-return-hint`),hr.current=!1}},[_i,W,ut,dt]);let es=(0,Q.useCallback)((e,t)=>{if(mn.isActive||tu().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 dm([n]),t=e.attachmentCommands[0];if(!t)return;let r=Ki();rn(r);let i=ro({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await Oo([i],r,!0,[],Te)!==!1}catch(t){try{await op({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Tr(),priority:`later`})}catch(e){Qr(mr(e))}Qr(mr(t));return}if(a)try{let t=await op({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Tr(),priority:`later`});for(let e of t)h_(e)}catch(e){Qr(mr(e))}})().catch(e=>{Qr(mr(e))}),!0},[Oo,Te,H]),{relayPipeMessage:ts,pipeReturnHadErrorRef:ns}=hz(),rs=nz({setInputValueRaw:zr,inputValueRef:Br,insertTextRef:Vr});IP({enabled:Nn(),isLoading:W,focusedInputDialog:uo,onSubmitMessage:es}),CP({isLoading:W,onSubmitMessage:es}),Z(e=>Ry(e));let{routeToSelectedPipes:is}=gz({store:H,setAppState:V,addNotification:ut});{let e=H.getState().kairosEnabled;pz({isLoading:W,assistantMode:e,setMessages:K})}process.env.USER_TYPE===`ant`&&RP({taskListId:S,isLoading:W,onSubmitTask:es}),fz?.({isLoading:W||se!==null,queuedCommandsLength:ue.length,hasActiveLocalJsxUI:sr,isInPlanMode:F.mode===`plan`,onQueueTick:e=>h_(e)}),mz?.({isLoading:W||se!==null,wasAborted:sn,queuedCommandsLength:ue.length,hasActiveLocalJsxUI:sr,isInPlanMode:F.mode===`plan`,isQueryActiveNow:mn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;K(e=>[...e,ro({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{ut({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(!ke){mv(null);return}if(!W){if(Ae!==null&&ue.length===0&&!sr&&F.mode!==`plan`&&se===null){mv({enabled:!0,phase:`standby`,next_tick_at:Ae,sleep_until:null});return}mv({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[se,W,sr,ke,Ae,ue.length,F.mode]),(0,Q.useEffect)(()=>{ue.some(e=>e.priority===`now`)&&an.current?.abort(`interrupt`)},[ue]);let as=(0,Q.useRef)(Zo);as.current=Zo;let os=(0,Q.useRef)(Jd);os.current=Jd,(0,Q.useEffect)(()=>(as.current(),()=>{os.current.shutdown()}),[]);let{internal_eventEmitter:ss}=ie(),[us,ds]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
145
145
  Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
146
146
  Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
147
- `)},t=()=>{os(e=>e+1)};return rs?.on(`suspend`,e),rs?.on(`resume`,t),()=>{rs?.off(`suspend`,e),rs?.off(`resume`,t)}},[rs]);let ss=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.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||G.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=mi(G,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?` '${Oi(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}`},[G,W]),cs=(0,Q.useCallback)(()=>{Lr({messagesLength:G.length,streamingToolUsesLength:Qt.length})},[G.length,Qt.length]),ls=(0,Q.useCallback)(()=>{Lr(null)},[]),fs=Ol()&&!N,ps=(0,Q.useRef)(null),[ms,hs]=(0,Q.useState)(!1),[gs,_s]=(0,Q.useState)(``),[vs,ys]=(0,Q.useState)(0),[xs,Cs]=(0,Q.useState)(0),ws=(0,Q.useCallback)((e,t)=>{ys(e),Cs(t)},[]);Oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){ps.current?.setAnchor(),hs(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&vs>0){let t=r===`n`?ps.current?.nextMatch:ps.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:ze===`transcript`&&fs&&!ms&&!Je});let{setQuery:Ts,scanElement:Es,setPositions:Ds}=I(),Os=k().columns,ks=Q.useRef(Os);Q.useEffect(()=>{ks.current!==Os&&(ks.current=Os,(gs||ms)&&(hs(!1),_s(``),ys(0),Cs(0),ps.current?.disarmSearch(),Ts(``)))},[Os,gs,ms,Ts]),Oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ls(),n.stopImmediatePropagation();return}if(e===`[`&&!Je)Ze(!0),Ke(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),st.current)return;st.current=!0;let e=it.current,t=t=>{e===it.current&&(clearTimeout(ot.current),$e(t))};t(`rendering ${Pr.length} messages…`),(async()=>{try{let e=(await Ax(Pr,Wt,Math.max(80,(process.stdout.columns??80)-6))).replace(/[ \t]+$/gm,``),n=MS(DS(),`cc-transcript-${Date.now()}.txt`);await HS(n,e),t(Pb(n)?`opening ${n}`:`wrote ${n} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}st.current=!1,e===it.current&&(ot.current=setTimeout(e=>e(``),4e3,$e))})()}}},{isActive:ze===`transcript`&&fs&&!ms});let As=ze===`transcript`&&fs;(0,Q.useEffect)(()=>{As||(_s(``),ys(0),Cs(0),hs(!1),it.current++,clearTimeout(ot.current),Ze(!1),$e(``))},[As]),(0,Q.useEffect)(()=>{Ts(As?gs:``),As||Ds(null)},[As,gs,Ts,Ds]);let js={screen:ze,setScreen:Ve,showAllInTranscript:Ge,setShowAllInTranscript:Ke,messageCount:G.length,onEnterTranscript:cs,onExitTranscript:ls,virtualScrollActive:fs,searchBarOpen:ms},Ms=Ir?Pr.slice(0,Ir.messagesLength):Pr,Ns=Ir?Qt.slice(0,Ir.streamingToolUsesLength):Qt;XN({onOpenBackgroundTasks:sr?void 0:()=>Ji(!0),onTogglePipeSelector:()=>{V(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}}),$N();let Ps=ye?B[ye]:void 0,Fs=Ps&&jp(Ps)?Ps:void 0,Is=Fs??(Ps&&pc(Ps)?Ps:void 0),Ls=fi||!W,Rs=Is?.messages,zs=(0,Q.useMemo)(()=>{if(!Is)return;let e=Rs??[];if(!pc(Is)||Is.agentType!==`fork`||!Is.prompt)return e;let t=Is.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(Az))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=>!Az(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=ro({content:Is.prompt,timestamp:new Date(Is.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Is,Rs]),Bs=Is?zs??[]:Ls?G:Pr;if(ze===`transcript`){let e=Ol()&&!N&&!Je?dn:void 0,t=(0,$.jsx)(kx,{messages:Ms,tools:Wt,commands:qt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Yr,isMessageSelectorVisible:!1,conversationId:Pi,screen:ze,agentDefinitions:L,streamingToolUses:Ns,showAllInTranscript:Ge,onOpenRateLimitOptions:Mo,isLoading:W,hidePastThinking:!0,streamingThinking:en,scrollRef:e,jumpRef:ps,onSearchMatchesChange:ws,scanElement:Es,setPositions:Ds,disableRenderCap:Je}),n=Vn&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),r=(0,$.jsxs)(is,{children:[(0,$.jsx)(Oz,{isAnimating:cr,title:ar,disabled:j,noPrefix:dr}),(0,$.jsx)(WN,{...js}),(0,$.jsx)(rz,{voiceHandleKeyEvent:$o.handleKeyEvent,stripTrailing:$o.stripTrailing,resetAnchor:$o.resetAnchor,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)(KN,{onSubmit:Eo,isActive:!Vn?.isLocalJSXCommand}),e?(0,$.jsx)($L,{scrollRef:dn,isActive:so!==`ultraplan-choice`,isModal:!ms,onScroll:()=>ps.current?.disarmSearch()}):null,(0,$.jsx)(JN,{...po}),e?(0,$.jsx)(Dx,{scrollRef:dn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(XF,{})]}),bottom:ms?(0,$.jsx)(wz,{jumpRef:ps,initialQuery:``,count:vs,current:xs,onClose:e=>{_s(vs>0?e:``),hs(!1),e||(ys(0),Cs(0),ps.current?.setSearchQuery(``))},onCancel:()=>{hs(!1),ps.current?.setSearchQuery(``),ps.current?.setSearchQuery(gs),Ts(gs)},setHighlight:Ts}):(0,$.jsx)(Cz,{showAllInTranscript:Ge,virtualScroll:!0,status:Qe||void 0,searchBadge:gs&&vs>0?{current:xs,count:vs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(XF,{}),(0,$.jsx)(Cz,{showAllInTranscript:Ge,virtualScroll:!1,suppressShowAll:Je,status:Qe||void 0})]})]});return e?(0,$.jsx)(ce,{mouseTracking:Xa(),children:r}):r}let Vs=yn&&!Is&&Bs.length<=xn.current?yn:void 0,Hs=so===`tool-permission`?(0,$.jsx)(HE,{onDone:()=>Kn(([e,...t])=>t),onReject:fo,toolUseConfirm:Gn[0],toolUseContext:vo(G,G,nn??Ki(),Te),verbose:te,workerBadge:Gn[0]?.workerBadge,setStickyFooter:Ol()?Jn:void 0},Gn[0]?.toolUseID):null,Ws=Os<100,Ks=!Vn?.shouldHidePromptInput&&!so&&!Gi,Js=Ol()&&Vn?.isLocalJSXCommand===!0,Ys=Js?Vn.jsx:null,Qs=(0,$.jsxs)(is,{children:[(0,$.jsx)(Oz,{isAnimating:cr,title:ar,disabled:j,noPrefix:dr}),(0,$.jsx)(WN,{...js}),(0,$.jsx)(rz,{voiceHandleKeyEvent:$o.handleKeyEvent,stripTrailing:$o.stripTrailing,resetAnchor:$o.resetAnchor,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)(KN,{onSubmit:Eo,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)($L,{scrollRef:dn,isActive:Ol()&&(Ys!=null||!so||so===`tool-permission`),onScroll:Mr}),null,(0,$.jsx)(JN,{...po}),(0,$.jsx)(Jy,{dynamicMcpConfig:Ie,isStrictMcpConfig:m,children:(0,$.jsx)(Dx,{scrollRef:dn,overlay:Hs,bottomFloat:Ks&&!Ws?(0,$.jsx)(PD,{}):void 0,modal:Ys,modalScrollRef:fn,dividerYRef:vr,hidePill:!!Is,hideSticky:!!Fs,newMessageCount:Dr?.count??0,onPillClick:()=>{wr(null),q(dn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(OP,{}),(0,$.jsx)(kx,{messages:Bs,tools:Wt,commands:qt,verbose:te,toolJSX:Vn,toolUseConfirmQueue:Gn,inProgressToolUseIDs:Fs?Fs.inProgressToolUseIDs??new Set:Yr,isMessageSelectorVisible:Ei,conversationId:Pi,screen:ze,streamingToolUses:Qt,showAllInTranscript:Ge,agentDefinitions:L,onOpenRateLimitOptions:Mo,isLoading:W,streamingText:W&&!Is?gi:null,isBriefOnly:Is?!1:je,unseenDivider:Is?void 0:Dr,scrollRef:Ol()?dn:void 0,trackStickyPrompt:Ol()?!0:void 0,cursor:Cr,setCursor:wr,cursorNavRef:Er}),(0,$.jsx)(PI,{}),!y&&Vs&&!Ys&&(0,$.jsx)(_g,{param:{text:Vs,type:`text`},addMargin:!0,verbose:te}),Vn&&!(Vn.isLocalJSXCommand&&Vn.isImmediate)&&!Js&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(lL,{}),(0,$.jsx)(U,{flexGrow:1}),xa&&(0,$.jsx)(Sh,{mode:Jt,spinnerTip:de,responseLengthRef:si,apiMetricsRef:ci,overrideMessage:bi,spinnerSuffix:ss,verbose:te,loadingStartTimeRef:Cn,totalPausedMsRef:wn,pauseStartTimeRef:Tn,overrideColor:Si,overrideShimmerColor:wi,hasActiveTools:Yr.size>0,leaderIsIdle:!W}),!xa&&!W&&!yn&&!ca&&je&&!Is&&(0,$.jsx)(Po,{})]}),bottom:(0,$.jsxs)(U,{flexDirection:Ws?`column`:`row`,width:`100%`,alignItems:Ws?void 0:`flex-end`,children:[Ws&&Ol()&&Ks?(0,$.jsx)(ND,{}):null,(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[Ol()&&(0,$.jsx)(OM,{}),qn,Vn?.isLocalJSXCommand&&Vn.isImmediate&&!Js&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),!xa&&!Vn?.isLocalJSXCommand&&fe&&Ht&&Ht.length>0&&(0,$.jsx)(U,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(yl,{tasks:Ht,isStandalone:!0})}),so===`sandbox-permission`&&(0,$.jsx)(JF,{hostPattern:Yn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Yn[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:Op(t.toolPermissionContext,e)})),Ko(e),Gs.refreshConfig()}Xn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=$n.current.get(i);if(a){for(let e of a)e();$n.current.delete(i)}}},Yn[0].hostPattern.host),so===`prompt`&&(0,$.jsx)(fD,{title:Zn[0].title,toolInputSummary:Zn[0].toolInputSummary,request:Zn[0].request,onRespond:e=>{let t=Zn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Qn(([,...e])=>e))},onAbort:()=>{let e=Zn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Qn(([,...e])=>e))}},Zn[0].request.prompt),pe&&(0,$.jsx)(pC,{toolName:pe.toolName,description:pe.description}),me&&(0,$.jsx)(pC,{toolName:`Network Access`,description:`Waiting for leader to approve network access to ${me.host}`}),so===`worker-sandbox-permission`&&(0,$.jsx)(JF,{hostPattern:{host:he.queue[0].host,port:void 0},onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=he.queue[0];if(!r)return;let i=r.host;if(eh(r.workerName,r.requestId,i,t,z?.teamName),n&&t){let e={type:`addRules`,rules:[{toolName:`WebFetch`,ruleContent:`domain:${i}`}],behavior:`allow`,destination:`localSettings`};V(t=>({...t,toolPermissionContext:Op(t.toolPermissionContext,e)})),Ko(e),Gs.refreshConfig()}V(e=>({...e,workerSandboxPermissions:{...e.workerSandboxPermissions,queue:e.workerSandboxPermissions.queue.slice(1)}}))}},he.queue[0].requestId),so===`elicitation`&&(0,$.jsx)(lD,{event:ge.queue[0],onResponse:(e,t)=>{let n=ge.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=ge.queue[0];V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},ge.queue[0].serverName+`:`+String(ge.queue[0].requestId)),so===`cost`&&(0,$.jsx)(YS,{onDone:()=>{Ni(!1),Hi(!0),kt(e=>({...e,hasAcknowledgedCostThreshold:!0})),Y(`tengu_cost_threshold_acknowledged`,{})}}),so===`idle-return`&&Ii&&(0,$.jsx)(XS,{idleMinutes:Ii.idleMinutes,totalInputTokens:wt(),onDone:async e=>{let t=Ii;if(Li(null),Y(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:pr.current.length,totalInputTokens:wt()}),e===`dismiss`){Hr(t.input);return}if(e===`never`&&kt(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-NrAy2em3.js`);await e({setMessages:K,readFileState:Ra.current,discoveredSkillNames:Va.current,loadedNestedMemoryPaths:Ua.current,getAppState:()=>H.getState(),setAppState:V,setConversationId:Fi}),rr.current=!1,nr(void 0),za.current.clear(),Ba.current=0}Ri.current=!0,jo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),so===`ide-onboarding`&&(0,$.jsx)(Ca,{onDone:()=>Dt(!1),installationStatus:Ct}),process.env.USER_TYPE===`ant`&&so===`model-switch`&&_z&&(0,$.jsx)(_z,{onDone:(e,t)=>{At(!1),e===`switch`&&t&&V(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&so===`undercover-callout`&&yz&&(0,$.jsx)(yz,{onDone:()=>Bn(!1)}),so===`effort-callout`&&(0,$.jsx)(GP,{model:Te,onDone:e=>{Mt(!1),e!==`dismiss`&&V(t=>({...t,effortValue:e}))}}),so===`remote-callout`&&(0,$.jsx)(Wb,{onDone:e=>{V(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),eo,so===`plugin-hint`&&Rt&&(0,$.jsx)(SI,{pluginName:Rt.pluginName,pluginDescription:Rt.pluginDescription,marketplaceName:Rt.marketplaceName,sourceCommand:Rt.sourceCommand,onResponse:zt}),so===`search-extra-tools-hint`&&Bt.visible&&(0,$.jsx)(wI,{tools:Bt.tools,onSelect:Bt.handleSelect,onDismiss:Bt.handleDismiss}),so===`lsp-recommendation`&&It&&(0,$.jsx)(yI,{pluginName:It.pluginName,pluginDescription:It.pluginDescription,fileExtension:It.fileExtension,onResponse:Lt}),so===`desktop-upsell`&&(0,$.jsx)(bS,{onDone:()=>Ft(!1)}),so===`ultraplan-choice`&&_e&&(0,$.jsx)(CL,{plan:_e.plan,sessionId:_e.sessionId,taskId:_e.taskId,setMessages:K,readFileState:Ra.current,getAppState:()=>H.getState(),setConversationId:Fi}),so===`ultraplan-launch`&&ve&&(0,$.jsx)(EL,{onChoice:(e,t)=>{let n=ve.blurb;if(V(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,kg(ua(`ultraplan`,n))]);let r=e=>K(t=>[...t,kg(`<local-command-stdout>${$_(e)}</local-command-stdout>`)]);pg({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>H.getState(),setAppState:V,signal:Ki().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!mn.isActive){r(e);return}let t=mn.subscribe(()=>{mn.isActive||(t(),H.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(Qr)}}),va(),!Vn?.shouldHidePromptInput&&!so&&!no&&!y&&!Cr&&(0,$.jsxs)($.Fragment,{children:[Ja&&(0,$.jsx)(aL,{onRun:Oo,onCancel:ko,reason:cL(Ja)}),ja.state===`closed`?Ma.state===`closed`?(0,$.jsx)(bF,{state:ka.state,lastResponse:ka.lastResponse,handleSelect:ka.handleSelect,handleTranscriptSelect:ka.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Qa.current?void 0:Ao}):(0,$.jsx)(bF,{state:Ma.state,lastResponse:Ma.lastResponse,handleSelect:Ma.handleSelect,handleTranscriptSelect:Ma.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Ao,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(bF,{state:ja.state,lastResponse:ja.lastResponse,handleSelect:ja.handleSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Ao}),Pa.state!==`closed`&&(0,$.jsx)(bF,{state:Pa.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Pa.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr}),Da.suggestion&&(0,$.jsx)(PN,{isOpen:Da.isOpen,skillName:Da.suggestion.skillName,updates:Da.suggestion.updates,handleSelect:Da.handleSelect,inputValue:Rr,setInputValue:Hr}),Oa&&(0,$.jsx)(uL,{}),(0,$.jsx)(ZM,{debug:n,ideSelection:gt,hasSuppressedDialogs:!!co,isLocalJSXCommandActive:sr,getToolUseContext:vo,toolPermissionContext:F,setToolPermissionContext:go,apiKeyStatus:Ga,commands:qt,agents:L.activeAgents,isLoading:W,onExit:No,verbose:te,messages:G,onAutoUpdaterResult:Rn,autoUpdaterResult:Ln,input:Rr,onInputChange:Hr,mode:Ur,onModeChange:Wr,stashedPrompt:Gr,setStashedPrompt:qr,submitCount:ai,onShowMessageSelector:Fo,onMessageActionsEnter:void 0,mcpClients:ht,pastedContents:ri,setPastedContents:ii,vimMode:Ui,setVimMode:Wi,showBashesDialog:Gi,setShowBashesDialog:Ji,onSubmit:Eo,onAgentSubmit:Do,isSearchingHistory:Yi,setIsSearchingHistory:Xi,helpOpen:Zi,setHelpOpen:$i,insertTextRef:Vr,voiceInterimRange:$o.interimRange}),(0,$.jsx)(HP,{onBackgroundSession:yo,isLoading:W}),(0,$.jsx)(NP,{})]}),Cr&&(0,$.jsx)(Pd,{cursor:Cr}),so===`message-selector`&&(0,$.jsx)(db,{messages:G,preselectedMessage:Ai,onPreRestore:uo,onRestoreCode:async e=>{await ic(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=Rc(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,Na(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=vo(r,[],Ki(),Te),o=a.getAppState(),s=await lf(a.options.tools,a.options.mainLoopModel,Array.from(o.toolPermissionContext.additionalWorkingDirectories.keys()),a.options.mcpClients),c=$m({mainThreadAgentDefinition:void 0,toolUseContext:a,customSystemPrompt:a.options.customSystemPrompt,defaultSystemPrompt:s,appendSystemPrompt:a.options.appendSystemPrompt}),[l,u]=await Promise.all([Wl(),Bo()]),d=await Pp(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(Ol()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...m]}):K(m),sz?.setContextBlocked(!1),Fi(zS()),Aa(a.options.querySource),n===`from`){let t=Ep(e);t&&(Hr(t.text),Wr(t.mode))}ut({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${aa(`app:toggleTranscript`,`Global`,`ctrl+o`)} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Ho,onClose:()=>{Di(!1),ji(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(yL,{})]}),!(Ws&&Ol())&&Ks?(0,$.jsx)(ND,{}):null]})})},as)]});return Ol()?(0,$.jsx)(ce,{mouseTracking:Xa(),children:Qs}):Qs}export{jz as t};
147
+ `)},t=()=>{ds(e=>e+1)};return ss?.on(`suspend`,e),ss?.on(`resume`,t),()=>{ss?.off(`suspend`,e),ss?.off(`resume`,t)}},[ss]);let fs=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.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||G.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=mi(G,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?` '${Oi(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}`},[G,W]),ps=(0,Q.useCallback)(()=>{Lr({messagesLength:G.length,streamingToolUsesLength:Qt.length})},[G.length,Qt.length]),ms=(0,Q.useCallback)(()=>{Lr(null)},[]),hs=El()&&!N,gs=(0,Q.useRef)(null),[_s,vs]=(0,Q.useState)(!1),[bs,Ss]=(0,Q.useState)(``),[Cs,ws]=(0,Q.useState)(0),[Ts,Ds]=(0,Q.useState)(0),Os=(0,Q.useCallback)((e,t)=>{ws(e),Ds(t)},[]);Oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){gs.current?.setAnchor(),vs(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Cs>0){let t=r===`n`?gs.current?.nextMatch:gs.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:ze===`transcript`&&hs&&!_s&&!Je});let{setQuery:ks,scanElement:As,setPositions:js}=I(),Ms=k().columns,Ns=Q.useRef(Ms);Q.useEffect(()=>{Ns.current!==Ms&&(Ns.current=Ms,(bs||_s)&&(vs(!1),Ss(``),ws(0),Ds(0),gs.current?.disarmSearch(),ks(``)))},[Ms,bs,_s,ks]),Oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ms(),n.stopImmediatePropagation();return}if(e===`[`&&!Je)Ze(!0),Ke(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),st.current)return;st.current=!0;let e=it.current,t=t=>{e===it.current&&(clearTimeout(ot.current),$e(t))};t(`rendering ${Pr.length} messages…`),(async()=>{try{let e=(await Ax(Pr,Wt,Math.max(80,(process.stdout.columns??80)-6))).replace(/[ \t]+$/gm,``),n=MS(DS(),`cc-transcript-${Date.now()}.txt`);await HS(n,e),t(Pb(n)?`opening ${n}`:`wrote ${n} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}st.current=!1,e===it.current&&(ot.current=setTimeout(e=>e(``),4e3,$e))})()}}},{isActive:ze===`transcript`&&hs&&!_s});let Ps=ze===`transcript`&&hs;(0,Q.useEffect)(()=>{Ps||(Ss(``),ws(0),Ds(0),vs(!1),it.current++,clearTimeout(ot.current),Ze(!1),$e(``))},[Ps]),(0,Q.useEffect)(()=>{ks(Ps?bs:``),Ps||js(null)},[Ps,bs,ks,js]);let Fs={screen:ze,setScreen:Ve,showAllInTranscript:Ge,setShowAllInTranscript:Ke,messageCount:G.length,onEnterTranscript:ps,onExitTranscript:ms,virtualScrollActive:hs,searchBarOpen:_s},Is=Ir?Pr.slice(0,Ir.messagesLength):Pr,Ls=Ir?Qt.slice(0,Ir.streamingToolUsesLength):Qt;XN({onOpenBackgroundTasks:sr?void 0:()=>Ji(!0),onTogglePipeSelector:()=>{V(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}}),$N();let Rs=ye?B[ye]:void 0,zs=Rs&&Kp(Rs)?Rs:void 0,Vs=zs??(Rs&&Bp(Rs)?Rs:void 0),Us=fi||!W,Ws=Vs?.messages,Gs=(0,Q.useMemo)(()=>{if(!Vs)return;let e=Ws??[];if(!Bp(Vs)||Vs.agentType!==`fork`||!Vs.prompt)return e;let t=Vs.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(Az))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=>!Az(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=ro({content:Vs.prompt,timestamp:new Date(Vs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Vs,Ws]),qs=Vs?Gs??[]:Us?G:Pr;if(ze===`transcript`){let e=El()&&!N&&!Je?dn:void 0,t=(0,$.jsx)(kx,{messages:Is,tools:Wt,commands:qt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Yr,isMessageSelectorVisible:!1,conversationId:Pi,screen:ze,agentDefinitions:L,streamingToolUses:Ls,showAllInTranscript:Ge,onOpenRateLimitOptions:Ro,isLoading:W,hidePastThinking:!0,streamingThinking:en,scrollRef:e,jumpRef:gs,onSearchMatchesChange:Os,scanElement:As,setPositions:js,disableRenderCap:Je}),n=Vn&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),r=(0,$.jsxs)(Nc,{children:[(0,$.jsx)(Oz,{isAnimating:cr,title:ar,disabled:j,noPrefix:dr}),(0,$.jsx)(WN,{...Fs}),(0,$.jsx)(rz,{voiceHandleKeyEvent:rs.handleKeyEvent,stripTrailing:rs.stripTrailing,resetAnchor:rs.resetAnchor,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)(KN,{onSubmit:Ao,isActive:!Vn?.isLocalJSXCommand}),e?(0,$.jsx)($L,{scrollRef:dn,isActive:uo!==`ultraplan-choice`,isModal:!_s,onScroll:()=>gs.current?.disarmSearch()}):null,(0,$.jsx)(JN,{...vo}),e?(0,$.jsx)(Dx,{scrollRef:dn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(XF,{})]}),bottom:_s?(0,$.jsx)(wz,{jumpRef:gs,initialQuery:``,count:Cs,current:Ts,onClose:e=>{Ss(Cs>0?e:``),vs(!1),e||(ws(0),Ds(0),gs.current?.setSearchQuery(``))},onCancel:()=>{vs(!1),gs.current?.setSearchQuery(``),gs.current?.setSearchQuery(bs),ks(bs)},setHighlight:ks}):(0,$.jsx)(Cz,{showAllInTranscript:Ge,virtualScroll:!0,status:Qe||void 0,searchBadge:bs&&Cs>0?{current:Ts,count:Cs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(XF,{}),(0,$.jsx)(Cz,{showAllInTranscript:Ge,virtualScroll:!1,suppressShowAll:Je,status:Qe||void 0})]})]});return e?(0,$.jsx)(ce,{mouseTracking:Xa(),children:r}):r}let Js=yn&&!Vs&&qs.length<=xn.current?yn:void 0,Xs=uo===`tool-permission`?(0,$.jsx)(HE,{onDone:()=>Kn(([e,...t])=>t),onReject:ho,toolUseConfirm:Gn[0],toolUseContext:Co(G,G,nn??Ki(),Te),verbose:te,workerBadge:Gn[0]?.workerBadge,setStickyFooter:El()?Jn:void 0},Gn[0]?.toolUseID):null,Zs=Ms<100,Qs=!Vn?.shouldHidePromptInput&&!uo&&!Gi,$s=El()&&Vn?.isLocalJSXCommand===!0,ec=$s?Vn.jsx:null,tc=(0,$.jsxs)(Nc,{children:[(0,$.jsx)(Oz,{isAnimating:cr,title:ar,disabled:j,noPrefix:dr}),(0,$.jsx)(WN,{...Fs}),(0,$.jsx)(rz,{voiceHandleKeyEvent:rs.handleKeyEvent,stripTrailing:rs.stripTrailing,resetAnchor:rs.resetAnchor,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)(KN,{onSubmit:Ao,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)($L,{scrollRef:dn,isActive:El()&&(ec!=null||!uo||uo===`tool-permission`),onScroll:Mr}),null,(0,$.jsx)(JN,{...vo}),(0,$.jsx)(Jy,{dynamicMcpConfig:Ie,isStrictMcpConfig:m,children:(0,$.jsx)(Dx,{scrollRef:dn,overlay:Xs,bottomFloat:Qs&&!Zs?(0,$.jsx)(PD,{}):void 0,modal:ec,modalScrollRef:fn,dividerYRef:vr,hidePill:!!Vs,hideSticky:!!zs,newMessageCount:Dr?.count??0,onPillClick:()=>{wr(null),q(dn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(OP,{}),(0,$.jsx)(kx,{messages:qs,tools:Wt,commands:qt,verbose:te,toolJSX:Vn,toolUseConfirmQueue:Gn,inProgressToolUseIDs:zs?zs.inProgressToolUseIDs??new Set:Yr,isMessageSelectorVisible:Ei,conversationId:Pi,screen:ze,streamingToolUses:Qt,showAllInTranscript:Ge,agentDefinitions:L,onOpenRateLimitOptions:Ro,isLoading:W,streamingText:W&&!Vs?gi:null,isBriefOnly:Vs?!1:je,unseenDivider:Vs?void 0:Dr,scrollRef:El()?dn:void 0,trackStickyPrompt:El()?!0:void 0,cursor:Cr,setCursor:wr,cursorNavRef:Er}),(0,$.jsx)(PI,{}),!y&&Js&&!ec&&(0,$.jsx)(yg,{param:{text:Js,type:`text`},addMargin:!0,verbose:te}),Vn&&!(Vn.isLocalJSXCommand&&Vn.isImmediate)&&!$s&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(lL,{}),(0,$.jsx)(U,{flexGrow:1}),Da&&(0,$.jsx)(Fo,{mode:Jt,spinnerTip:de,responseLengthRef:si,apiMetricsRef:ci,overrideMessage:bi,spinnerSuffix:fs,verbose:te,loadingStartTimeRef:Cn,totalPausedMsRef:wn,pauseStartTimeRef:Tn,overrideColor:Si,overrideShimmerColor:wi,hasActiveTools:Yr.size>0,leaderIsIdle:!W}),!Da&&!W&&!yn&&!fa&&je&&!Vs&&(0,$.jsx)(Ql,{})]}),bottom:(0,$.jsxs)(U,{flexDirection:Zs?`column`:`row`,width:`100%`,alignItems:Zs?void 0:`flex-end`,children:[Zs&&El()&&Qs?(0,$.jsx)(ND,{}):null,(0,$.jsxs)(U,{flexDirection:`column`,flexGrow:1,children:[El()&&(0,$.jsx)(OM,{}),qn,Vn?.isLocalJSXCommand&&Vn.isImmediate&&!$s&&(0,$.jsx)(U,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),!Da&&!Vn?.isLocalJSXCommand&&fe&&Ht&&Ht.length>0&&(0,$.jsx)(U,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Ld,{tasks:Ht,isStandalone:!0})}),uo===`sandbox-permission`&&(0,$.jsx)(JF,{hostPattern:Yn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Yn[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:jp(t.toolPermissionContext,e)})),Jo(e),Bs.refreshConfig()}Xn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=$n.current.get(i);if(a){for(let e of a)e();$n.current.delete(i)}}},Yn[0].hostPattern.host),uo===`prompt`&&(0,$.jsx)(fD,{title:Zn[0].title,toolInputSummary:Zn[0].toolInputSummary,request:Zn[0].request,onRespond:e=>{let t=Zn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Qn(([,...e])=>e))},onAbort:()=>{let e=Zn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Qn(([,...e])=>e))}},Zn[0].request.prompt),pe&&(0,$.jsx)(pC,{toolName:pe.toolName,description:pe.description}),me&&(0,$.jsx)(pC,{toolName:`Network Access`,description:`Waiting for leader to approve network access to ${me.host}`}),uo===`worker-sandbox-permission`&&(0,$.jsx)(JF,{hostPattern:{host:he.queue[0].host,port:void 0},onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=he.queue[0];if(!r)return;let i=r.host;if(sf(r.workerName,r.requestId,i,t,z?.teamName),n&&t){let e={type:`addRules`,rules:[{toolName:`WebFetch`,ruleContent:`domain:${i}`}],behavior:`allow`,destination:`localSettings`};V(t=>({...t,toolPermissionContext:jp(t.toolPermissionContext,e)})),Jo(e),Bs.refreshConfig()}V(e=>({...e,workerSandboxPermissions:{...e.workerSandboxPermissions,queue:e.workerSandboxPermissions.queue.slice(1)}}))}},he.queue[0].requestId),uo===`elicitation`&&(0,$.jsx)(lD,{event:ge.queue[0],onResponse:(e,t)=>{let n=ge.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=ge.queue[0];V(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},ge.queue[0].serverName+`:`+String(ge.queue[0].requestId)),uo===`cost`&&(0,$.jsx)(YS,{onDone:()=>{Ni(!1),Hi(!0),kt(e=>({...e,hasAcknowledgedCostThreshold:!0})),Y(`tengu_cost_threshold_acknowledged`,{})}}),uo===`idle-return`&&Ii&&(0,$.jsx)(XS,{idleMinutes:Ii.idleMinutes,totalInputTokens:wt(),onDone:async e=>{let t=Ii;if(Li(null),Y(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:pr.current.length,totalInputTokens:wt()}),e===`dismiss`){Hr(t.input);return}if(e===`never`&&kt(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-uY-V0SNK.js`);await e({setMessages:K,readFileState:Ha.current,discoveredSkillNames:Ka.current,loadedNestedMemoryPaths:Ja.current,getAppState:()=>H.getState(),setAppState:V,setConversationId:Fi}),rr.current=!1,nr(void 0),Wa.current.clear(),Ga.current=0}Ri.current=!0,Io.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),uo===`ide-onboarding`&&(0,$.jsx)(wa,{onDone:()=>Dt(!1),installationStatus:Ct}),process.env.USER_TYPE===`ant`&&uo===`model-switch`&&_z&&(0,$.jsx)(_z,{onDone:(e,t)=>{At(!1),e===`switch`&&t&&V(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&uo===`undercover-callout`&&yz&&(0,$.jsx)(yz,{onDone:()=>Bn(!1)}),uo===`effort-callout`&&(0,$.jsx)(GP,{model:Te,onDone:e=>{Mt(!1),e!==`dismiss`&&V(t=>({...t,effortValue:e}))}}),uo===`remote-callout`&&(0,$.jsx)(Wb,{onDone:e=>{V(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),io,uo===`plugin-hint`&&Rt&&(0,$.jsx)(SI,{pluginName:Rt.pluginName,pluginDescription:Rt.pluginDescription,marketplaceName:Rt.marketplaceName,sourceCommand:Rt.sourceCommand,onResponse:zt}),uo===`search-extra-tools-hint`&&Bt.visible&&(0,$.jsx)(wI,{tools:Bt.tools,onSelect:Bt.handleSelect,onDismiss:Bt.handleDismiss}),uo===`lsp-recommendation`&&It&&(0,$.jsx)(yI,{pluginName:It.pluginName,pluginDescription:It.pluginDescription,fileExtension:It.fileExtension,onResponse:Lt}),uo===`desktop-upsell`&&(0,$.jsx)(bS,{onDone:()=>Ft(!1)}),uo===`ultraplan-choice`&&_e&&(0,$.jsx)(CL,{plan:_e.plan,sessionId:_e.sessionId,taskId:_e.taskId,setMessages:K,readFileState:Ha.current,getAppState:()=>H.getState(),setConversationId:Fi}),uo===`ultraplan-launch`&&ve&&(0,$.jsx)(EL,{onChoice:(e,t)=>{let n=ve.blurb;if(V(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,Ag(ua(`ultraplan`,n))]);let r=e=>K(t=>[...t,Ag(`<local-command-stdout>${$_(e)}</local-command-stdout>`)]);hg({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>H.getState(),setAppState:V,signal:Ki().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!mn.isActive){r(e);return}let t=mn.subscribe(()=>{mn.isActive||(t(),H.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(Qr)}}),Ta(),!Vn?.shouldHidePromptInput&&!uo&&!oo&&!y&&!Cr&&(0,$.jsxs)($.Fragment,{children:[eo&&(0,$.jsx)(aL,{onRun:Mo,onCancel:No,reason:cL(eo)}),Ia.state===`closed`?La.state===`closed`?(0,$.jsx)(bF,{state:Fa.state,lastResponse:Fa.lastResponse,handleSelect:Fa.handleSelect,handleTranscriptSelect:Fa.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:no.current?void 0:Po}):(0,$.jsx)(bF,{state:La.state,lastResponse:La.lastResponse,handleSelect:La.handleSelect,handleTranscriptSelect:La.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Po,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(bF,{state:Ia.state,lastResponse:Ia.lastResponse,handleSelect:Ia.handleSelect,inputValue:Rr,setInputValue:Hr,onRequestFeedback:Po}),za.state!==`closed`&&(0,$.jsx)(bF,{state:za.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:za.handleTranscriptSelect,inputValue:Rr,setInputValue:Hr}),ja.suggestion&&(0,$.jsx)(PN,{isOpen:ja.isOpen,skillName:ja.suggestion.skillName,updates:ja.suggestion.updates,handleSelect:ja.handleSelect,inputValue:Rr,setInputValue:Hr}),Ma&&(0,$.jsx)(uL,{}),(0,$.jsx)(ZM,{debug:n,ideSelection:gt,hasSuppressedDialogs:!!fo,isLocalJSXCommandActive:sr,getToolUseContext:Co,toolPermissionContext:F,setToolPermissionContext:bo,apiKeyStatus:Qa,commands:qt,agents:L.activeAgents,isLoading:W,onExit:zo,verbose:te,messages:G,onAutoUpdaterResult:Rn,autoUpdaterResult:Ln,input:Rr,onInputChange:Hr,mode:Ur,onModeChange:Wr,stashedPrompt:Gr,setStashedPrompt:qr,submitCount:ai,onShowMessageSelector:Bo,onMessageActionsEnter:void 0,mcpClients:ht,pastedContents:ri,setPastedContents:ii,vimMode:Ui,setVimMode:Wi,showBashesDialog:Gi,setShowBashesDialog:Ji,onSubmit:Ao,onAgentSubmit:jo,isSearchingHistory:Yi,setIsSearchingHistory:Xi,helpOpen:Zi,setHelpOpen:$i,insertTextRef:Vr,voiceInterimRange:rs.interimRange}),(0,$.jsx)(HP,{onBackgroundSession:wo,isLoading:W}),(0,$.jsx)(NP,{})]}),Cr&&(0,$.jsx)(Fd,{cursor:Cr}),uo===`message-selector`&&(0,$.jsx)(db,{messages:G,preselectedMessage:Ai,onPreRestore:mo,onRestoreCode:async e=>{await ha(e=>{V(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=jc(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,Na(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Co(r,[],Ki(),Te),o=a.getAppState(),s=await pf(a.options.tools,a.options.mainLoopModel,Array.from(o.toolPermissionContext.additionalWorkingDirectories.keys()),a.options.mcpClients),c=of({mainThreadAgentDefinition:void 0,toolUseContext:a,customSystemPrompt:a.options.customSystemPrompt,defaultSystemPrompt:s,appendSystemPrompt:a.options.appendSystemPrompt}),[l,u]=await Promise.all([Wl(),Ho()]),d=await Ip(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(El()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...m]}):K(m),sz?.setContextBlocked(!1),Fi(zS()),Aa(a.options.querySource),n===`from`){let t=kp(e);t&&(Hr(t.text),Wr(t.mode))}ut({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${oa(`app:toggleTranscript`,`Global`,`ctrl+o`)} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Ko,onClose:()=>{Di(!1),ji(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(yL,{})]}),!(Zs&&El())&&Qs?(0,$.jsx)(ND,{}):null]})})},us)]});return El()?(0,$.jsx)(ce,{mouseTracking:Xa(),children:tc}):tc}export{jz as t};