@readmagic/workmate 0.0.6 → 0.0.7

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 (409) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-ClHi-Dr6.js → AddWorkspaceDirectory-CFrrXnt9.js} +1 -1
  2. package/dist/chunks/{App-BP06lHmf.js → App-Buad9Llp.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-Bsy8kr2a.js → ApproveApiKey-B2HJUD7h.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-BQbHdvc3.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-CcocKoTJ.js → AssistantSessionChooser-4lm4eXQ8.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-D4qA0M5O.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-BKj_3Idm.js → BypassPermissionsModeDialog-DllL8dxU.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--ywODh81.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BD-7yAZh.js → ClaudeMdExternalIncludesDialog-BZSyRqeq.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-Wkfw7Ts-.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-BmPmCfT3.js → DesktopHandoff-DaP4Riar.js} +1 -1
  12. package/dist/chunks/{DiffDialog-C4XSSjvV.js → DiffDialog-B7hx8i_Y.js} +2 -2
  13. package/dist/chunks/Doctor-89OgoAUA.js +1 -0
  14. package/dist/chunks/Doctor-CuKJ-nGt.js +3 -0
  15. package/dist/chunks/ExitFlow-DnPydE17.js +2 -0
  16. package/dist/chunks/{Feedback-BaYA8-SU.js → Feedback-SmGiR3mf.js} +2 -2
  17. package/dist/chunks/{Grove-BJziCbZH.js → Grove-CjN9DO47.js} +1 -1
  18. package/dist/chunks/Grove-Cq88VBmM.js +1 -0
  19. package/dist/chunks/{HybridTransport-B8V6O6rM.js → HybridTransport-rK83Qijz.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-CHzBSJDf.js → InvalidConfigDialog-DdO0AxyF.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-BKenH3bD.js → InvalidSettingsDialog-s1G0DwXF.js} +1 -1
  22. package/dist/chunks/MCPConnectionManager-NRfIjdlj.js +1 -0
  23. package/dist/chunks/{McpParsingWarnings-Bj2-YL8o.js → McpParsingWarnings-Du5IxZos.js} +1 -1
  24. package/dist/chunks/MessageSelector-iIroHvXo.js +3 -0
  25. package/dist/chunks/Messages-D4Hm4gaY.js +11 -0
  26. package/dist/chunks/{Onboarding-BrAJp0aL.js → Onboarding-BiZByBK-.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-Ds1cB7RC.js → OverageCreditUpsell-BM7szLgm.js} +1 -1
  28. package/dist/chunks/PluginSettings-uY5KTCtK.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-egs9VvUs.js → PromptInputFooterSuggestions-BmsFdOu9.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-SieM5NoY.js → PromptInputHelpMenu-DX-0wEDo.js} +1 -1
  31. package/dist/chunks/QueryEngine-CGYaShXD.js +1 -0
  32. package/dist/chunks/REPL-CRJB2t2z.js +142 -0
  33. package/dist/chunks/REPL-u4Yq29Du.js +1 -0
  34. package/dist/chunks/{RemoteCallout-Cs-ro8_i.js → RemoteCallout-B-tyvQOe.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-B740Dp6m.js → RemoteSessionManager-DCd0O5_l.js} +2 -2
  36. package/dist/chunks/ResumeConversation-DAAXlOCd.js +1 -0
  37. package/dist/chunks/{SSETransport-DtpMDekF.js → SSETransport-5VK5okFv.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-B-7Bworf.js +1 -0
  39. package/dist/chunks/Settings-CUjWlncb.js +2 -0
  40. package/dist/chunks/{TeleportProgress-rYaHIEfe.js → TeleportProgress-DxN0bQL2.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-DY97YZMB.js → TeleportRepoMismatchDialog-A5Ss0kuk.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-jaQzyTCh.js → TeleportResumeWrapper-Bz14mUqR.js} +1 -1
  43. package/dist/chunks/{ThemePicker-BViWzLp3.js → ThemePicker-CVSRqTzW.js} +1 -1
  44. package/dist/chunks/TrustDialog-CY8an_Tg.js +1 -0
  45. package/dist/chunks/{ValidationErrorsList-B8pRiGuy.js → ValidationErrorsList-BYsDtAvX.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-DqnbSdIu.js → WelcomeV2-C1BfrqC5.js} +1 -1
  47. package/dist/chunks/{add-dir-C2Hu3oE4.js → add-dir-DfLYgwox.js} +1 -1
  48. package/dist/chunks/{agentDisplay-XoDJhr03.js → agentDisplay-CMmHIl86.js} +1 -1
  49. package/dist/chunks/{agents-C4QXeHIJ.js → agents-DE_4mAHG.js} +1 -1
  50. package/dist/chunks/agents-DJtPfvnL.js +103 -0
  51. package/dist/chunks/allErrors-CQE2k0zO.js +1 -0
  52. package/dist/chunks/{ant-B6k6cBts.js → ant-ClQkuQjZ.js} +1 -1
  53. package/dist/chunks/{api-gqTA-D7n.js → api-2cdIPaeq.js} +1 -1
  54. package/dist/chunks/api-CG-lhKe-.js +1 -0
  55. package/dist/chunks/{assistant-DJ9hd4uC.js → assistant-Bje16tQx.js} +1 -1
  56. package/dist/chunks/auth-DMfEiQrC.js +1 -0
  57. package/dist/chunks/auth-D_cGl8WD.js +1 -0
  58. package/dist/chunks/{auth-BnSrKyJe.js → auth-DqcKPbw8.js} +1 -1
  59. package/dist/chunks/{autoMode-BNukrVAB.js → autoMode-ZW70mpr0.js} +5 -5
  60. package/dist/chunks/{autonomy-BEmI7WVW.js → autonomy-CwbWsCnv.js} +1 -1
  61. package/dist/chunks/autonomy-Oui8yK8G.js +15 -0
  62. package/dist/chunks/{autonomyPanel-fhge09AG.js → autonomyPanel-Mq50H7iM.js} +1 -1
  63. package/dist/chunks/backgroundHousekeeping-BpLtI45r.js +1 -0
  64. package/dist/chunks/backgroundHousekeeping-DtJNx4Ja.js +17 -0
  65. package/dist/chunks/{branch-Bpe-gocq.js → branch-DU5O9KZ0.js} +1 -1
  66. package/dist/chunks/{bridge-D12Shbkj.js → bridge-DNNxtPlz.js} +2 -2
  67. package/dist/chunks/{bridgeConfig-BhxRF2vm.js → bridgeConfig-CE6dMsiJ.js} +1 -1
  68. package/dist/chunks/bridgeConfig-DP9dD1Cv.js +1 -0
  69. package/dist/chunks/{bridgeEnabled-SbB-6zdY.js → bridgeEnabled-Cc0mGlTb.js} +1 -1
  70. package/dist/chunks/bridgeEnabled-D8wP3DWQ.js +1 -0
  71. package/dist/chunks/bridgeMain-CwxMa_pd.js +1 -0
  72. package/dist/chunks/bridgeMain-D11t1BYQ.js +68 -0
  73. package/dist/chunks/{bridgeMessaging-DHc5dOhB.js → bridgeMessaging-DdvApEqW.js} +1 -1
  74. package/dist/chunks/{bridgePointer-MqLe5Asm.js → bridgePointer-DqHMHa2B.js} +1 -1
  75. package/dist/chunks/{btw-D9hMM5d2.js → btw-CejSEdNl.js} +1 -1
  76. package/dist/chunks/{caches-UeVVM3T0.js → caches-5HVQSevy.js} +2 -2
  77. package/dist/chunks/caches-B-nJoHLM.js +1 -0
  78. package/dist/chunks/{ccrClient-Iza0L8Zw.js → ccrClient-BFyfO67b.js} +1 -1
  79. package/dist/chunks/{claudeDesktop-Cx31Ugjp.js → claudeDesktop-Fe-QL-sN.js} +1 -1
  80. package/dist/chunks/{clear-B4d38ssF.js → clear-D8m2utXW.js} +1 -1
  81. package/dist/chunks/client-C6MbjvOB.js +17 -0
  82. package/dist/chunks/client-DKXCfdde.js +1 -0
  83. package/dist/chunks/client-xxikkAoZ.js +1 -0
  84. package/dist/chunks/{color-D8VOyoYl.js → color-DWhgZH7A.js} +1 -1
  85. package/dist/chunks/commands-CxJpmEKF.js +1 -0
  86. package/dist/chunks/commitAttribution-DM6SBMwl.js +1 -0
  87. package/dist/chunks/{commitAttribution-ChAgixdj.js → commitAttribution-DPnHHKSA.js} +1 -1
  88. package/dist/chunks/compact-CblM7306.js +2 -0
  89. package/dist/chunks/config-BLVBFi5v.js +1 -0
  90. package/dist/chunks/config-CMnqm6Se.js +1 -0
  91. package/dist/chunks/{config-DmomySWC.js → config-DRDuVyzE.js} +2 -2
  92. package/dist/chunks/{context-Cl6BJ2vm.js → context-CdSMMM-0.js} +1 -1
  93. package/dist/chunks/context-noninteractive-CPkf2vB9.js +1 -0
  94. package/dist/chunks/{context-noninteractive-9hELVC29.js → context-noninteractive-DNury4JI.js} +5 -5
  95. package/dist/chunks/conversation-DCMw_rsE.js +1 -0
  96. package/dist/chunks/conversation-pUtvc-cE.js +1 -0
  97. package/dist/chunks/{createSSHSession-BM-5pbv6.js → createSSHSession-BOdTAX3N.js} +1 -1
  98. package/dist/chunks/{createSession-Cvl1Q50F.js → createSession-8Ei-Lj7V.js} +1 -1
  99. package/dist/chunks/createSession-CjqxVh_Q.js +1 -0
  100. package/dist/chunks/crossProjectResume-Bj_Pe8oe.js +40 -0
  101. package/dist/chunks/{datadog-CpqEQbHa.js → datadog-DqHxqiwY.js} +1 -1
  102. package/dist/chunks/{desktop-B_L6T6jI.js → desktop-Z5FAfunZ.js} +1 -1
  103. package/dist/chunks/{diff-CVzOodeg.js → diff-CJEKvOA5.js} +1 -1
  104. package/dist/chunks/doctor-BA2ZLDTl.js +1 -0
  105. package/dist/chunks/{entry-DHVYCR26.js → entry-DE0uMIf0.js} +4 -4
  106. package/dist/chunks/envLessBridgeConfig-B-LKYNvv.js +1 -0
  107. package/dist/chunks/envLessBridgeConfig-DyD9XCda.js +1 -0
  108. package/dist/chunks/{esm-D5q6s4l8.js → esm-5w3xFBnt.js} +1 -1
  109. package/dist/chunks/exit-Dt9kHtJO.js +1 -0
  110. package/dist/chunks/{extra-usage-zDHVtWKZ.js → extra-usage-C7E2Z1p1.js} +1 -1
  111. package/dist/chunks/extra-usage-D0Kkjp-2.js +1 -0
  112. package/dist/chunks/{extra-usage-core-BFOolqoi.js → extra-usage-core-DjdaD1qO.js} +1 -1
  113. package/dist/chunks/{extra-usage-noninteractive-cUGZy0en.js → extra-usage-noninteractive-BnD1RhKK.js} +1 -1
  114. package/dist/chunks/{extraUsage-Dq66zzqR.js → extraUsage-CpgRTcMk.js} +1 -1
  115. package/dist/chunks/extractMemories-DhUprYa7.js +1 -0
  116. package/dist/chunks/{fast-MS7WZpD8.js → fast-C4ZevUNL.js} +1 -1
  117. package/dist/chunks/fast-CChxlAAF.js +1 -0
  118. package/dist/chunks/{feedback-Fw4m28ZC.js → feedback-BIhBhV6n.js} +1 -1
  119. package/dist/chunks/{firstPartyEventLogger-CoSUd0a1.js → firstPartyEventLogger-BXY1IJ2D.js} +2 -2
  120. package/dist/chunks/firstPartyEventLogger-CnkGSojw.js +1 -0
  121. package/dist/chunks/{flushGate-De-yppeo.js → flushGate-CgHq81Gw.js} +1 -1
  122. package/dist/chunks/{gemini-BPziscyN.js → gemini-C1J-x1g7.js} +1 -1
  123. package/dist/chunks/generateRecap-C0jjCg0Z.js +1 -0
  124. package/dist/chunks/generateSessionName-w0BMtwS7.js +1 -0
  125. package/dist/chunks/{githubRepoPathMapping-qAoiyj6P.js → githubRepoPathMapping-8D0kpsif.js} +1 -1
  126. package/dist/chunks/{goal-CFx4eRkf.js → goal-B4GsR54_.js} +3 -3
  127. package/dist/chunks/grok-ffNyU3Lt.js +1 -0
  128. package/dist/chunks/{grove-CpqjcGCb.js → grove-BQisE2JM.js} +1 -1
  129. package/dist/chunks/{heapdump-C4kPlqGt.js → heapdump-DiCjAPR3.js} +1 -1
  130. package/dist/chunks/{help-B1h-faJ3.js → help-2hn8VK2-.js} +1 -1
  131. package/dist/chunks/hooks-CBmrBO-J.js +1 -0
  132. package/dist/chunks/{hooks-X6J03MnA.js → hooks-CkA9bhHl.js} +2 -2
  133. package/dist/chunks/inboundAttachments-C5K3XPTC.js +1 -0
  134. package/dist/chunks/{inboundAttachments-CUJE3KaU.js → inboundAttachments-IH-g95jo.js} +1 -1
  135. package/dist/chunks/initReplBridge-C-P4dgAG.js +1 -0
  136. package/dist/chunks/{install-D5YORIJL.js → install-Dzlm4u58.js} +1 -1
  137. package/dist/chunks/{instrumentation-Bw3CxPQf.js → instrumentation-Yt31gxWN.js} +3 -3
  138. package/dist/chunks/{job-DOWtcltx.js → job-BXujwZNa.js} +1 -1
  139. package/dist/chunks/{keybindings-BLw5J-Zj.js → keybindings-D8FXoO89.js} +2 -2
  140. package/dist/chunks/language-Baosud0X.js +1 -0
  141. package/dist/chunks/{language-C6Fq-XOZ.js → language-Ca4B018X.js} +1 -1
  142. package/dist/chunks/{launchAgentsPlatform-jWWf-Lk9.js → launchAgentsPlatform-D6DmNuDt.js} +1 -1
  143. package/dist/chunks/{launchLocalMemory-kHeD0I0y.js → launchLocalMemory-C0FzUq7x.js} +2 -2
  144. package/dist/chunks/{launchLocalVault-DLqkOjmb.js → launchLocalVault-DkYAre4O.js} +3 -3
  145. package/dist/chunks/{launchMemoryStores-Ct7AVXrO.js → launchMemoryStores-D2rKWAPs.js} +1 -1
  146. package/dist/chunks/{launchOnboarding-Cc6WwPX9.js → launchOnboarding-gOVAFEFp.js} +1 -1
  147. package/dist/chunks/{launchSchedule-ZyvuvjgU.js → launchSchedule-IZdFstT_.js} +1 -1
  148. package/dist/chunks/{launchSkillStore-BejQnLog.js → launchSkillStore-B7LamM1d.js} +1 -1
  149. package/dist/chunks/{launchTeleport-8CuYUfIR.js → launchTeleport-C2BQMfYP.js} +3 -3
  150. package/dist/chunks/{launchVault-DIvIOuPh.js → launchVault-C60WUcCI.js} +1 -1
  151. package/dist/chunks/{lazySchema-DcIJE_0i.js → lazySchema-DULtBUCI.js} +1 -1
  152. package/dist/chunks/loadAgentsDir-B9c3Emvg.js +1 -0
  153. package/dist/chunks/{loadAgentsDir-D206qwP3.js → loadAgentsDir-x3rlgED4.js} +690 -692
  154. package/dist/chunks/loadPluginHooks-BhNdAjeY.js +1 -0
  155. package/dist/chunks/localSearch-BLCGsdyM.js +1 -0
  156. package/dist/chunks/{localSearch-CzrbOklu.js → localSearch-DtplGF-l.js} +1 -1
  157. package/dist/chunks/{logoV2Utils-8M56V7oN.js → logoV2Utils-gGK9gErT.js} +1 -1
  158. package/dist/chunks/{magicDocs-DWjL2k7P.js → magicDocs-qdDB_mKb.js} +2 -2
  159. package/dist/chunks/{main-BohPzJFF.js → main-OWFSddRx.js} +82 -82
  160. package/dist/chunks/managedEnv-Aq5BXfY7.js +1 -0
  161. package/dist/chunks/managedEnv-BHoeDjpS.js +1 -0
  162. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +1 -0
  163. package/dist/chunks/{mappers-BDMZFgKx.js → mappers-04gNXJ3w.js} +1 -1
  164. package/dist/chunks/mcp-BSNdwbxR.js +1 -0
  165. package/dist/chunks/mcp-CMnDNI-4.js +6 -0
  166. package/dist/chunks/mcp-D1yA9E56.js +2 -0
  167. package/dist/chunks/memory-D1zbyjxN.js +1 -0
  168. package/dist/chunks/{mode-CUkHFkju.js → mode-DY087x_x.js} +2 -2
  169. package/dist/chunks/{model-CKkOnnnx.js → model-CZViyZnE.js} +1 -1
  170. package/dist/chunks/{model-BY3auM2c.js → model-D0EfJBuw.js} +1 -1
  171. package/dist/chunks/model-DLLkVV6S.js +1 -0
  172. package/dist/chunks/{nativeInstaller-CA5d6_G7.js → nativeInstaller-yj81F75v.js} +1 -1
  173. package/dist/chunks/onChangeAppState-DhGKPG9g.js +1 -0
  174. package/dist/chunks/{openai-Cbomn0Ws.js → openai-EYRnUsco.js} +3 -3
  175. package/dist/chunks/{overageCreditGrant-DsUrmeBh.js → overageCreditGrant-Du3dOYVu.js} +1 -1
  176. package/dist/chunks/{panelCall-BsVoL1uF.js → panelCall-dMvRPAGE.js} +1 -1
  177. package/dist/chunks/{partition-BAakXjvj.js → partition-C4FWzYVm.js} +1 -1
  178. package/dist/chunks/{passes-CLRt7Cvm.js → passes-Daz-ARWD.js} +1 -1
  179. package/dist/chunks/permissions-DF8tAmDF.js +3 -0
  180. package/dist/chunks/{pidLock-D5rUnDB-.js → pidLock-CbC_il6r.js} +2 -2
  181. package/dist/chunks/{plan-SYZ4DXR8.js → plan-rsb_83Fo.js} +1 -1
  182. package/dist/chunks/{plugin-Bfjzhmrk.js → plugin-Cm31-nej.js} +1 -1
  183. package/dist/chunks/pluginAutoupdate-0k03PVff.js +1 -0
  184. package/dist/chunks/pluginBlocklist-wPFCUPdm.js +1 -0
  185. package/dist/chunks/pluginCliCommands-DhL9LbH0.js +1 -0
  186. package/dist/chunks/{pluginFlagging-D9HKAGBC.js → pluginFlagging-CAdaFV_D.js} +1 -1
  187. package/dist/chunks/pluginOperations-Cs_Z4C6O.js +2 -0
  188. package/dist/chunks/pluginStartupCheck-BRXGKGjG.js +1 -0
  189. package/dist/chunks/pluginStartupCheck-KeU0efTj.js +1 -0
  190. package/dist/chunks/{plugins-Dn6ceWrT.js → plugins-CQNKZmjP.js} +4 -4
  191. package/dist/chunks/policyLimits-D2s8M8P2.js +1 -0
  192. package/dist/chunks/{pollConfig-DH2oCtFS.js → pollConfig-2nFzv6Hy.js} +1 -1
  193. package/dist/chunks/{poor-j-y-bv8o.js → poor-DXumVTR4.js} +1 -1
  194. package/dist/chunks/{poorMode-DhzFKpPl.js → poorMode-CBOtooa0.js} +1 -1
  195. package/dist/chunks/poorMode-yNZL5uYf.js +1 -0
  196. package/dist/chunks/print-uxCF5ka5.js +23 -0
  197. package/dist/chunks/{privacy-settings-DHMJREbb.js → privacy-settings-BncbJCV0.js} +1 -1
  198. package/dist/chunks/processBashCommand-CGdwvPmD.js +1 -0
  199. package/dist/chunks/processSlashCommand-DQarepEb.js +5 -0
  200. package/dist/chunks/prompt-BgOdcHkd.js +1 -0
  201. package/dist/chunks/{prompt-BNHtszmZ.js → prompt-CE3sFmZV.js} +5 -5
  202. package/dist/chunks/prompt-CLJKFebn.js +1 -0
  203. package/dist/chunks/{promptEditor-DeMrXUir.js → promptEditor-CyTzyjwG.js} +2 -2
  204. package/dist/chunks/{protocolHandler-BHxBy84Z.js → protocolHandler-JR8pASdH.js} +1 -1
  205. package/dist/chunks/rate-limit-options-C-EqWjeI.js +1 -0
  206. package/dist/chunks/{rcDebugLog-CUy1_F23.js → rcDebugLog-DBB9r8aw.js} +1 -1
  207. package/dist/chunks/reconciler-CYD_XpG4.js +4 -0
  208. package/dist/chunks/{referral-CUaIo_vT.js → referral-CKmHHxj_.js} +1 -1
  209. package/dist/chunks/refresh-ZqZdmLK5.js +1 -0
  210. package/dist/chunks/{registerProtocol-B7Fzdofu.js → registerProtocol-wZv2uiW_.js} +1 -1
  211. package/dist/chunks/{release-notes-fbfv2DC0.js → release-notes-B5K7wVqZ.js} +1 -1
  212. package/dist/chunks/{releaseNotes-CxAHFLPl.js → releaseNotes-B8gbyFFJ.js} +2 -2
  213. package/dist/chunks/{reload-plugins-B9IT9CFA.js → reload-plugins-B9ApSp2m.js} +1 -1
  214. package/dist/chunks/{remote-env-BOklGlll.js → remote-env-CAt1dHIS.js} +1 -1
  215. package/dist/chunks/{remoteBridgeCore-j0bG1zjv.js → remoteBridgeCore-Bk3UdSLJ.js} +1 -1
  216. package/dist/chunks/remoteManagedSettings-bswzAB6W.js +1 -0
  217. package/dist/chunks/rename-CE_U6KE6.js +1 -0
  218. package/dist/chunks/{resume-y7MCTZHJ.js → resume-BicEjsPd.js} +2 -2
  219. package/dist/chunks/{runtimeObserver-CyzLASla.js → runtimeObserver-BrGF5QWX.js} +4 -4
  220. package/dist/chunks/{runtimeObserver-BZcJ1FbH.js → runtimeObserver-CiwnPFjK.js} +1 -1
  221. package/dist/chunks/sandbox-adapter-BtMiHImm.js +1 -0
  222. package/dist/chunks/{sandbox-toggle-CWpBO228.js → sandbox-toggle-D8eebdyI.js} +1 -1
  223. package/dist/chunks/searchExtraTools-hLLPuh7c.js +1 -0
  224. package/dist/chunks/{session-DL4cA_8l.js → session-BZIlR9Gc.js} +2 -2
  225. package/dist/chunks/{sessionDiscovery-DAfNKqp1.js → sessionDiscovery-DfDqTrF1.js} +1 -1
  226. package/dist/chunks/sessionFileAccessHooks-Bm8wiqwe.js +1 -0
  227. package/dist/chunks/sessionMemory-D37S0-jX.js +1 -0
  228. package/dist/chunks/sessionMemory-DmlAG3jq.js +1 -0
  229. package/dist/chunks/sessionMemoryUtils-6EWDHSGU.js +1 -0
  230. package/dist/chunks/sessionObserver-BUw2rzKl.js +1 -0
  231. package/dist/chunks/{sessionObserver-ShbCwJ8x.js → sessionObserver-KgquhGWw.js} +1 -1
  232. package/dist/chunks/sessionStorage-CucBSK5Q.js +1 -0
  233. package/dist/chunks/{sessionTitle-coed9IuJ.js → sessionTitle-DAnM73S0.js} +2 -2
  234. package/dist/chunks/{sessionTracing-D9rUyiq0.js → sessionTracing-_Hh5VXxt.js} +1 -1
  235. package/dist/chunks/settings-BeLFUeie.js +19 -0
  236. package/dist/chunks/settings-Cl16Haug.js +1 -0
  237. package/dist/chunks/settingsSync-BNvFYH3c.js +1 -0
  238. package/dist/chunks/setup-D8kXv3ts.js +3 -0
  239. package/dist/chunks/{shadowedRuleDetection-D1wsAdpp.js → shadowedRuleDetection-C6R5zOUe.js} +1 -1
  240. package/dist/chunks/{sideQuestion-wSi38p81.js → sideQuestion-hUhxls9r.js} +3 -3
  241. package/dist/chunks/{sinks-C_Dl1p4K.js → sinks-BuE17DeZ.js} +2 -2
  242. package/dist/chunks/sinks-FevoYQqP.js +1 -0
  243. package/dist/chunks/{skill-learning-B5tmc7EX.js → skill-learning-CMdxGtxr.js} +1 -1
  244. package/dist/chunks/skillChangeDetector-C65ZLSYV.js +1 -0
  245. package/dist/chunks/{skillGapStore-Df5BWAk5.js → skillGapStore-D18LRJAM.js} +2 -2
  246. package/dist/chunks/{skillGapStore-D-kQKVDZ.js → skillGapStore-Ep62R-2_.js} +1 -1
  247. package/dist/chunks/{skillGenerator-DbcdpAkw.js → skillGenerator-Bc7WwNT8.js} +2 -2
  248. package/dist/chunks/{skillLearning-ClRiDcJH.js → skillLearning-Cs9fJgkV.js} +1 -1
  249. package/dist/chunks/skillLearning-duPZl69A.js +1 -0
  250. package/dist/chunks/{skillPanel-LBd4E-MM.js → skillPanel-Cyzby746.js} +3 -3
  251. package/dist/chunks/{skillSearchPanel-CErRnUwo.js → skillSearchPanel-Cll9ccA5.js} +4 -4
  252. package/dist/chunks/{skills-CBKhfg_a.js → skills-BPPeYBy7.js} +1 -1
  253. package/dist/chunks/{stats-BY4dskVg.js → stats-CqfF4Axp.js} +1 -1
  254. package/dist/chunks/{status-DU-B4SMW.js → status-CC9Q-2Yn.js} +1 -1
  255. package/dist/chunks/{status-BnJIXtKl.js → status-D4IQpsNK.js} +2 -2
  256. package/dist/chunks/statusNoticeHelpers-CEGvdm5d.js +1 -0
  257. package/dist/chunks/syncCache-CANQZ9mQ.js +1 -0
  258. package/dist/chunks/{tag-B-wVW9Aj.js → tag-DDbNqBMu.js} +2 -2
  259. package/dist/chunks/{tasks-CBVL005y.js → tasks-CZvWJYGr.js} +1 -1
  260. package/dist/chunks/teleport-Dk5j03Ix.js +1 -0
  261. package/dist/chunks/{templateJobs-D6998LcG.js → templateJobs-D1BdhZsv.js} +1 -1
  262. package/dist/chunks/{terminalSetup-CuV-qU6v.js → terminalSetup-3JNy6i_J.js} +5 -5
  263. package/dist/chunks/{terminalSetup-0SBdyKF5.js → terminalSetup-Cn6jeYw1.js} +1 -1
  264. package/dist/chunks/{theme-p0AooruD.js → theme-Cg4GNOoQ.js} +1 -1
  265. package/dist/chunks/thinkback-p-vKIRW_.js +1 -0
  266. package/dist/chunks/thinkback-play-DnPTDE8B.js +1 -0
  267. package/dist/chunks/{thinkback-DI2NpvG-.js → thinkback-rFA1do6F.js} +1 -1
  268. package/dist/chunks/{toolEventObserver-DlH73w-S.js → toolEventObserver-CzsCuUMc.js} +1 -1
  269. package/dist/chunks/{toolEventObserver-DTccwC3c.js → toolEventObserver-SFwURL5F.js} +1 -1
  270. package/dist/chunks/toolPool-BR27AMJO.js +1 -0
  271. package/dist/chunks/trustedDevice-BYt39fui.js +1 -0
  272. package/dist/chunks/{trustedDevice-BTYoQCkC.js → trustedDevice-CKedohmT.js} +1 -1
  273. package/dist/chunks/{types-C-MRCL8J.js → types-Dut4311z.js} +2 -2
  274. package/dist/chunks/{ultrareviewCommand-BDFUS3hf.js → ultrareviewCommand-C_4OSBTW.js} +2 -2
  275. package/dist/chunks/{undercover-vuTpCnQJ.js → undercover-D30rKimg.js} +1 -1
  276. package/dist/chunks/undercover-DRSwLozU.js +1 -0
  277. package/dist/chunks/{updateCCB-DFL5Wt_I.js → updateCCB-C2G-U-qA.js} +1 -1
  278. package/dist/chunks/upgrade-Bi-bIz7R.js +1 -0
  279. package/dist/chunks/{upgrade-D5qwcaWQ.js → upgrade-Chs-OQFd.js} +1 -1
  280. package/dist/chunks/{upload-B_yADHX9.js → upload-D8FWMSQx.js} +1 -1
  281. package/dist/chunks/{usage-C0SnnC-i.js → usage-BxVeUt60.js} +1 -1
  282. package/dist/chunks/usage-DUO7Yy1f.js +1 -0
  283. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DKIqRraH.js → useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js} +1 -1
  284. package/dist/chunks/useMainLoopModel-Gy1Vv4Qr.js +1 -0
  285. package/dist/chunks/useManagePlugins-B11_87VN.js +1 -0
  286. package/dist/chunks/useMergedTools-CR56my9t.js +1 -0
  287. package/dist/chunks/{useSearchInput-D1Vr2Js1.js → useSearchInput-C5OzQnX6.js} +1 -1
  288. package/dist/chunks/{useSettingsErrors-B7BXHchG.js → useSettingsErrors-B9vOZL41.js} +1 -1
  289. package/dist/chunks/{util-BaDs-wL5.js → util-8EHwfg4A.js} +1 -1
  290. package/dist/chunks/validatePlugin-6q1qmnAC.js +1 -0
  291. package/dist/chunks/{vim-C-icQDz1.js → vim-CNDzwoTd.js} +1 -1
  292. package/dist/chunks/{workerRegistry-ChqPPIaO.js → workerRegistry-CvyHvwx-.js} +1 -1
  293. package/dist/chunks/worktree-ogmNCIpz.js +1 -0
  294. package/dist/cli.js +1 -1
  295. package/package.json +1 -1
  296. package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +0 -1
  297. package/dist/chunks/BackgroundTasksDialog-DNeBhGCf.js +0 -2
  298. package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +0 -1
  299. package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +0 -1
  300. package/dist/chunks/Doctor-BhD-ZzZm.js +0 -1
  301. package/dist/chunks/Doctor-DEQe2q16.js +0 -3
  302. package/dist/chunks/ExitFlow-BttnAv-O.js +0 -2
  303. package/dist/chunks/Grove-sWm-oLBf.js +0 -1
  304. package/dist/chunks/MCPConnectionManager-CNh9dNlk.js +0 -1
  305. package/dist/chunks/MessageSelector-DdR6wJhh.js +0 -3
  306. package/dist/chunks/Messages-Ch6cboMV.js +0 -11
  307. package/dist/chunks/PluginSettings-CGqEzejq.js +0 -17
  308. package/dist/chunks/QueryEngine-CZZMl3PB.js +0 -1
  309. package/dist/chunks/REPL-CG2N7E4Q.js +0 -142
  310. package/dist/chunks/REPL-DvA910N_.js +0 -1
  311. package/dist/chunks/ResumeConversation-DzV2zmuX.js +0 -1
  312. package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +0 -1
  313. package/dist/chunks/Settings-XKw6FI_m.js +0 -2
  314. package/dist/chunks/TrustDialog-DGJ_BisZ.js +0 -1
  315. package/dist/chunks/agents-BIHTGDYh.js +0 -103
  316. package/dist/chunks/allErrors-1896uQA1.js +0 -1
  317. package/dist/chunks/api-BsFW57_Q.js +0 -1
  318. package/dist/chunks/auth-8Vd3_U8t.js +0 -1
  319. package/dist/chunks/auth-DRTjfnGy.js +0 -1
  320. package/dist/chunks/autonomy-DGcy5Rml.js +0 -15
  321. package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +0 -1
  322. package/dist/chunks/backgroundHousekeeping-BVMf_Tjn.js +0 -17
  323. package/dist/chunks/bridgeConfig-CqIQ_rvD.js +0 -1
  324. package/dist/chunks/bridgeEnabled-D0XC5kNh.js +0 -1
  325. package/dist/chunks/bridgeMain-DHUpZFgL.js +0 -68
  326. package/dist/chunks/bridgeMain-DUbQjgCp.js +0 -1
  327. package/dist/chunks/caches-CWzT7e6Y.js +0 -1
  328. package/dist/chunks/client-BzKQTXzF.js +0 -1
  329. package/dist/chunks/commands-DDamMmo4.js +0 -1
  330. package/dist/chunks/commitAttribution-CgohL8vD.js +0 -1
  331. package/dist/chunks/compact-IFHwxjZ9.js +0 -2
  332. package/dist/chunks/config-DY5-_kk_.js +0 -1
  333. package/dist/chunks/config-WxgxrQoP.js +0 -1
  334. package/dist/chunks/context-noninteractive-Beij5MfU.js +0 -1
  335. package/dist/chunks/conversation-BBB91hEw.js +0 -1
  336. package/dist/chunks/conversation-BWVTM40Y.js +0 -1
  337. package/dist/chunks/createSession-CoQtL5Rj.js +0 -1
  338. package/dist/chunks/crossProjectResume-BasMLl2n.js +0 -40
  339. package/dist/chunks/doctor-1L0TFuGw.js +0 -1
  340. package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +0 -1
  341. package/dist/chunks/envLessBridgeConfig-Ck2-KMq0.js +0 -1
  342. package/dist/chunks/exit-Bm1S_f3i.js +0 -1
  343. package/dist/chunks/extra-usage-UHAWtypK.js +0 -1
  344. package/dist/chunks/extractMemories-BcaklA33.js +0 -1
  345. package/dist/chunks/fast-DALAHO3d.js +0 -1
  346. package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +0 -1
  347. package/dist/chunks/generateRecap-jGDLI_wU.js +0 -1
  348. package/dist/chunks/generateSessionName-hDJ6HBJ1.js +0 -1
  349. package/dist/chunks/grok-Byblph7F.js +0 -1
  350. package/dist/chunks/hooks-DPLIIpAD.js +0 -1
  351. package/dist/chunks/inboundAttachments-BekVc0W-.js +0 -1
  352. package/dist/chunks/initReplBridge-JQ-afRx9.js +0 -1
  353. package/dist/chunks/language-Cqw5gYJR.js +0 -1
  354. package/dist/chunks/loadAgentsDir-TZjwTqdr.js +0 -1
  355. package/dist/chunks/loadPluginHooks-Ddhsyn0_.js +0 -1
  356. package/dist/chunks/localSearch-DrOAL6f4.js +0 -1
  357. package/dist/chunks/mcp-Bt1ITh-Z.js +0 -1
  358. package/dist/chunks/mcp-CwJ-AIpt.js +0 -6
  359. package/dist/chunks/mcp-W0LFoyFR.js +0 -2
  360. package/dist/chunks/memory-3wV7m7UU.js +0 -1
  361. package/dist/chunks/model-DRXcJyU9.js +0 -1
  362. package/dist/chunks/onChangeAppState-DBmy2Ow_.js +0 -1
  363. package/dist/chunks/permissions-BVSFuwNP.js +0 -3
  364. package/dist/chunks/pluginAutoupdate-reO2PgtQ.js +0 -1
  365. package/dist/chunks/pluginBlocklist-C3H2afWG.js +0 -1
  366. package/dist/chunks/pluginCliCommands-lqdxdkQp.js +0 -1
  367. package/dist/chunks/pluginOperations-EN3EKLux.js +0 -2
  368. package/dist/chunks/pluginStartupCheck-BY73BMT2.js +0 -1
  369. package/dist/chunks/pluginStartupCheck-CwWOlveD.js +0 -1
  370. package/dist/chunks/policyLimits-CkTI5KEt.js +0 -1
  371. package/dist/chunks/poorMode-V11s-3cf.js +0 -1
  372. package/dist/chunks/print-Db_VXmfO.js +0 -23
  373. package/dist/chunks/processBashCommand-BcM_fhV9.js +0 -1
  374. package/dist/chunks/processSlashCommand-DEVo3GPX.js +0 -5
  375. package/dist/chunks/prompt-CrX31AGm.js +0 -1
  376. package/dist/chunks/prompt-IAvMxKDl.js +0 -1
  377. package/dist/chunks/rate-limit-options-DIudL9fb.js +0 -1
  378. package/dist/chunks/reconciler-BXpPyfSY.js +0 -4
  379. package/dist/chunks/refresh-CuaVBIQ0.js +0 -1
  380. package/dist/chunks/remoteManagedSettings-Cq994lyc.js +0 -1
  381. package/dist/chunks/rename-Iev7wQsI.js +0 -1
  382. package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +0 -1
  383. package/dist/chunks/searchExtraTools-BUOUds7p.js +0 -1
  384. package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +0 -1
  385. package/dist/chunks/sessionMemory-BS8_TbKj.js +0 -1
  386. package/dist/chunks/sessionMemory-D5fSHXvZ.js +0 -1
  387. package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +0 -1
  388. package/dist/chunks/sessionObserver-ChfQtK2m.js +0 -1
  389. package/dist/chunks/sessionStorage-Cf5wmnyB.js +0 -1
  390. package/dist/chunks/settings-BovzmwMP.js +0 -19
  391. package/dist/chunks/settingsSync-PqU9XGJq.js +0 -1
  392. package/dist/chunks/setup-B_FOvNpp.js +0 -3
  393. package/dist/chunks/sinks-BpcRrN_T.js +0 -1
  394. package/dist/chunks/skillChangeDetector-DNqohXxz.js +0 -1
  395. package/dist/chunks/skillLearning-C5cXZE6_.js +0 -1
  396. package/dist/chunks/statusNoticeHelpers-CzTuGNuC.js +0 -1
  397. package/dist/chunks/teleport-dtqQXM4x.js +0 -1
  398. package/dist/chunks/thinkback-Catprqs_.js +0 -1
  399. package/dist/chunks/thinkback-play-CqrIRx2o.js +0 -1
  400. package/dist/chunks/toolPool-B64V-jmK.js +0 -1
  401. package/dist/chunks/trustedDevice-CiwjT_Y6.js +0 -1
  402. package/dist/chunks/undercover-XYapZ_SS.js +0 -1
  403. package/dist/chunks/upgrade-DIg3j929.js +0 -1
  404. package/dist/chunks/usage-CYJKE8N6.js +0 -1
  405. package/dist/chunks/useMainLoopModel-XetDUXd-.js +0 -1
  406. package/dist/chunks/useManagePlugins-B2KhKiu5.js +0 -1
  407. package/dist/chunks/useMergedTools-CKvwz_Zt.js +0 -1
  408. package/dist/chunks/validatePlugin-DtiYlXby.js +0 -1
  409. package/dist/chunks/worktree-DAn8ooa1.js +0 -1
@@ -0,0 +1,142 @@
1
+ import{a as e,n as t,o as n,r}from"./rolldown-runtime-DaDcL9Zw.js";import{c as i,l as a,n as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{n as u,t as d}from"./figures-5ThXQEtq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{C as m,D as h,Ft as g,Gr as _,Gt as v,H as y,I as b,Kr as x,Kt as S,Lt as C,Mr as w,P as T,Pn as E,Rn as D,T as O,Tt as k,Vn as ee,Wt as A,Xn as j,Xt as M,Y as te,Yt as N,Z as P,Zn as F,_n as ne,bn as re,ct as I,di as L,dr as ie,et as R,fi as z,ft as ae,hn as oe,ir as se,j as ce,lr as le,lt as ue,ot as de,q as fe,qr as pe,t as B,tr as V,ui as H,vn as me,x as he,y as ge,yn as U,yt as _e}from"./src-CDCSSo0U2.js";import{t as ve}from"./jsx-runtime-Bb4Xn-E0.js";import{C as ye,D as be,E as xe,N as Se,T as Ce,c as we,f as Te,n as Ee,o as De,r as Oe,t as ke}from"./lazySchema-DULtBUCI.js";import{At as Ae,B as je,Bt as Me,D as Ne,Dn as Pe,H as Fe,Hn as Ie,Ht as Le,Jn as Re,K as ze,Mt as Be,Nt as Ve,Pt as He,Rt as Ue,Sr as We,Tt as Ge,Un as Ke,Ut as qe,V as Je,Vt as Ye,Wt as Xe,Yn as Ze,Yt as Qe,Z as $e,Zt as et,_r as tt,b as nt,bn as rt,dn as it,en as at,fn as ot,ht as st,jt as ct,kt as lt,nt as ut,ot as dt,pn as ft,pt,tn as mt,un as ht,vr as gt,xr as _t,yr as vt,yt,z as bt,zt as xt}from"./state-ix0xIunV.js";import{$C as St,$S as Ct,$b as wt,$c as Tt,$f as Et,$o as Dt,$s as Ot,$u as kt,$w as At,$x as jt,$y as Mt,AC as Nt,AE as Pt,AT as Ft,Ab as It,Ad as Lt,Af as Rt,Ag as zt,Al as Bt,Am as Vt,Ap as Ht,As as Ut,Aw as Wt,Ax as Gt,BC as Kt,BD as qt,BE as Jt,BT as Yt,B_ as Xt,Bb as Zt,Bf as Qt,Bl as $t,Bn as en,Bo as tn,Bx as nn,C as rn,CC as an,CE as on,CS as sn,Cb as cn,Cf as ln,Cg as un,Ch as dn,Ci as fn,Co as pn,Cp as mn,Cr as hn,Cs as gn,Ct as _n,Cu as vn,Cw as yn,D as bn,DC as W,DT as xn,Db as Sn,Dd as Cn,Df as wn,Dg as Tn,Dh as En,Dl as Dn,Dm as On,Dp as kn,Du as An,Dw as jn,Dx as Mn,E as Nn,EC as Pn,ET as Fn,Eb as In,Ed as Ln,Ef as Rn,Eg as zn,El as Bn,Ep as Vn,Er as Hn,Et as Un,Eu as Wn,Ew as Gn,Ex as Kn,FC as qn,FS as G,Fd as Jn,Ff as Yn,Fg as Xn,Fl as Zn,Fm as Qn,Fs as $n,Ft as er,Fw as tr,Fx as nr,G as rr,GD as ir,GT as ar,Ga as or,Gb as sr,Gd as cr,Gf as lr,Gm as ur,Go as dr,Gs as fr,Gt as pr,Gu as mr,HC as hr,HT as K,Hb as gr,Hu as _r,Hx as vr,I as yr,IC as q,IS as br,IT as xr,Ia as Sr,Ib as Cr,Id as wr,If as Tr,Il as Er,Im as Dr,Ip as Or,Ir as kr,Iu as Ar,Iw as jr,Ix as Mr,J as Nr,JS as Pr,Jf as Fr,Jh as Ir,Jn as Lr,Jp as Rr,Jr as zr,KD as Br,KT as Vr,Kb as Hr,Kd as Ur,Kf as Wr,Ki as Gr,Km as Kr,LC as qr,LE as Jr,LS as Yr,LT as Xr,Lb as Zr,Ld as Qr,Lf as $r,Lg as ei,Ll as ti,Lm as ni,Ln as ri,Lp as ii,Lu as ai,Lx as oi,Ly as si,M as ci,MC as li,ME as ui,MS as di,Ma as fi,Mc as pi,Mf as mi,Ml as hi,Mm as gi,Mo as _i,Mp as vi,Mr as yi,Ms as bi,Mw as xi,Mx as Si,My as Ci,N as wi,NS as Ti,Nc as Ei,Nd as Di,Nf as Oi,Nm as ki,No as Ai,Np as ji,Ns as Mi,Nw as Ni,Nx as Pi,Ny as Fi,OC as Ii,OT as Li,Ob as Ri,Od as zi,Of as Bi,Og as Vi,Oh as Hi,Om as Ui,Oo as Wi,Op as Gi,Os as Ki,Ow as qi,Ox as Ji,P as Yi,PC as Xi,PS as J,Pa as Zi,Pc as Qi,Pd as $i,Pf as ea,Pg as ta,Pl as na,Pm as ra,Pn as ia,Pr as aa,Ps as oa,Pu as sa,Pw as ca,Px as la,Q as ua,QC as da,QS as fa,Qa as pa,Qb as ma,Qd as ha,Qf as ga,Qi as _a,Qn as va,Qs as ya,Qw as ba,Qx as xa,Qy as Sa,RC as Ca,RD as wa,Rb as Ta,Rd as Ea,Rf as Da,Rg as Oa,Ri as ka,Rl as Aa,Rm as ja,Ru as Ma,Ry as Na,SC as Pa,SE as Fa,ST as Ia,Sc as La,Sg as Ra,Sh as za,Sm as Ba,So as Va,Sw as Ha,TC as Ua,TD as Wa,TT as Ga,Tb as Ka,Tc as qa,Tf as Ja,Tp as Ya,Tu as Xa,Tw as Za,Tx as Qa,Um as $a,Ut as eo,Uu as to,VE as no,V_ as ro,Vb as io,Vf as ao,Vi as oo,Vl as so,Vo as co,Vs as lo,Vx as uo,W as fo,WD as po,Wi as mo,Wm as ho,Ws as go,Wu as _o,X as vo,XS as yo,Xa as bo,Xb as xo,Xf as So,Xm as Co,Xp as wo,Xu as To,Xw as Eo,Xx as Do,YS as Oo,Ya as ko,Yb as Ao,Yp as jo,Yu as Mo,Yw as No,Yx as Po,Yy as Fo,Z as Io,ZC as Lo,ZS as Ro,Za as zo,Zd as Bo,Zf as Vo,Zi as Ho,Zl as Uo,Zm as Wo,Zp as Go,Zt as Ko,Zu as qo,Zw as Jo,Zx as Yo,Zy as Xo,_C as Zo,_S as Qo,_T as $o,_a as es,_f as ts,_g as ns,_u as rs,_w as is,_x as as,aE as os,aa as ss,ah as cs,am as ls,ap as us,as as ds,ax as fs,b as ps,bT as ms,bb as hs,bu as gs,bw as _s,bx as vs,cS as ys,ca as bs,cb as xs,cl as Ss,cm as Cs,co as ws,cp as Ts,cu as Es,cv as Ds,cx as Os,dS as ks,dg as As,dn as js,dp as Ms,ds as Ns,du as Ps,dw as Fs,dx as Is,eS as Ls,eb as Rs,ed as zs,eh as Bs,ei as Vs,el as Hs,em as Us,en as Ws,et as Gs,eu as Ks,ew as qs,ex as Js,ey as Ys,fS as Xs,fb as Zs,ff as Qs,fi as $s,fo as ec,fs as tc,fv as nc,fw as rc,fx as ic,gD as ac,gE as oc,gS as sc,gT as cc,gb as lc,gf as uc,gl as dc,gw as fc,gx as pc,gy as mc,hC as hc,hS as gc,hT as _c,hb as vc,hf as yc,hi as bc,hl as xc,ho as Sc,hw as Cc,hx as wc,hy as Tc,iS as Ec,iT as Dc,ib as Oc,ih as kc,im as Ac,io as jc,it as Mc,iv as Nc,iw as Pc,ix as Fc,jC as Ic,jS as Lc,jT as Rc,ja as zc,jc as Bc,jm as Vc,jp as Hc,jr as Uc,js as Wc,jw as Gc,jx as Kc,kC as qc,kT as Jc,kb as Yc,kd as Xc,kf as Zc,kg as Qc,kl as $c,km as el,ko as tl,kp as nl,ks as rl,kw as il,kx as al,lS as ol,li as sl,ll as cl,lm as ll,lp as ul,ls as dl,lt as fl,lu as pl,lx as ml,mE as hl,mS as gl,ma as _l,mb as vl,mf as yl,mg as bl,mr as xl,mw as Sl,mx as Cl,nS as wl,na as Tl,nh as El,nl as Dl,nm as Ol,nr as kl,nu as Al,oa as jl,oh as Ml,om as Nl,oo as Pl,or as Fl,ou as Il,ov as Ll,ow as Rl,ox as zl,pC as Bl,pD as Vl,pS as Hl,pa as Ul,pb as Wl,pf as Gl,pg as Kl,pi as ql,po as Jl,px as Yl,py as Xl,q as Zl,qb as Ql,qf as $l,qi as eu,qm as tu,qo as nu,qy as ru,rS as iu,ra as au,rb as ou,rh as su,rl as cu,rm as lu,ro as uu,ru as du,rv as fu,rw as pu,rx as mu,sS as hu,sa as gu,si as _u,sm as vu,so as yu,sp as bu,su as xu,tS as Su,ta as Cu,tb as wu,tl as Tu,tm as Eu,tp as Du,ts as Ou,tt as ku,tu as Au,ty as ju,uD as Mu,uS as Nu,ua as Pu,ub as Fu,ug as Iu,ul as Lu,um as Ru,up as zu,ur as Bu,ut as Vu,uu as Hu,ux as Uu,vC as Wu,vE as Gu,vS as Ku,vT as qu,vf as Ju,vg as Yu,vi as Xu,vm as Zu,vo as Qu,vu as $u,vy as ed,wC as td,wD as nd,wE as rd,wT as id,wc as ad,wf as od,wi as sd,wm as cd,wp as ld,wu as ud,x as dd,xC as fd,xS as pd,xT as md,xc as hd,xg as gd,xo as _d,xp as vd,xu as yd,xx as bd,yC as xd,yE as Sd,yT as Cd,yb as wd,yc as Td,yf as Ed,yg as Dd,ym as Od,yn as kd,yo as Ad,ys as jd,yu as Md,yw as Nd,zC as Pd,zD as Fd,zE as Id,zT as Ld,zb as Rd,zf as zd,zl as Bd,zn as Vd,zs as Hd,zu as Ud,zx as Wd}from"./loadAgentsDir-x3rlgED4.js";import{n as Gd,t as Kd}from"./cwd-CYmmnQVS.js";import{C as qd,D as Jd,F as Yd,G as Xd,Q as Zd,S as Qd,V as $d,W as ef,_ as tf,a as nf,d as rf,l as Y,nt as af,p as of,rt as sf,w as cf,z as lf}from"./debug-BrXObCdR.js";import{$t as uf,Gt as df,H as ff,Ht as pf,It as mf,Jt as hf,Kt as gf,Lt as _f,Qt as vf,Rt as yf,Ut as bf,Wt as xf,Xt as Sf,bn as Cf,c as wf,f as Tf,g as Ef,mt as Df,n as Of,pn as kf,un as Af,vn as jf,wt as Mf,x as Nf,yn as Pf,z as Ff}from"./settings-BeLFUeie.js";import{P as If,b as Lf,c as Rf,g as zf,l as Bf,n as Vf}from"./config-DRDuVyzE.js";import{M as Hf,_ as Uf,a as Wf,d as Gf,i as Kf,j as qf}from"./git-Do0wJvux.js";import{r as Jf,t as Yf}from"./execFileNoThrow-D244NytW.js";import{B as Xf,L as Zf,N as Qf,R as $f,U as ep,Y as tp,k as np,o as rp,s as X}from"./log-BMCygSzM.js";import{n as ip,t as ap}from"./memoize-B0zhbT8Z.js";import{n as op,t as sp}from"./which-CKQnSouy.js";import{i as cp,o as lp}from"./platform-BrYefG_2.js";import{i as up,n as dp,o as fp,r as pp}from"./path-D5U-tm91.js";import{D as mp,E as hp,T as gp,f as _p,l as vp}from"./file-DcZWPH2V.js";import{s as yp,u as bp}from"./types-Dut4311z.js";import{n as xp,r as Z}from"./analytics-BotDBGh0.js";import{c as Sp,n as Cp,s as wp,t as Tp}from"./intl-cKc-V6Mq.js";import{T as Ep,b as Dp,d as Op,f as kp,u as Ap,y as jp}from"./startupProfiler-xa3NmN7Z.js";import{l as Mp,u as Np}from"./oauth-BqJqV-2M.js";import{n as Pp,t as Fp}from"./bundledMode--fG1S62b.js";import{a as Ip,d as Lp,l as Rp,o as zp,r as Bp,s as Vp}from"./stringUtils-DGLPkqJ4.js";import{$n as Hp,At as Up,Bn as Wp,Bt as Gp,Ct as Kp,D as qp,Et as Jp,Ft as Yp,Gr as Xp,Gt as Zp,Ht as Qp,Kn as $p,St as em,T as tm,Vn as nm,X as rm,_ as im,at as am,b as om,bi as sm,br as cm,ct as lm,et as um,h as dm,it as fm,m as pm,mt as mm,ni as hm,nt as gm,ot as _m,qr as vm,ri as ym,rr as bm,rt as xm,st as Sm,ti as Cm,tr as wm,tt as Tm,u as Em,x as Dm,xi as Om,xr as km}from"./model-CZViyZnE.js";import{At as Am,Cn as jm,Et as Mm,Ht as Nm,Tn as Pm,Tt as Fm,Ut as Im,an as Lm,bn as Rm,dn as zm,fn as Bm,hn as Vm,jt as Hm,mn as Um,st as Wm,yn as Gm}from"./prompt-CE3sFmZV.js";import{et as Km,rt as qm}from"./esm-5w3xFBnt.js";import{a as Jm,i as Ym,r as Xm}from"./shellQuote-DkSy9MYE.js";import{a as Zm}from"./ripgrep-BXmXjAzA.js";import{a as Qm,o as $m,s as eh}from"./fileStateCache-DDW5toIs.js";import{C as th,N as nh,S as rh,T as ih,b as ah,d as oh,f as sh,j as ch,st as lh,w as uh,x as dh,y as fh}from"./rcDebugLog-DBB9r8aw.js";import{T as ph,c as mh,r as hh,w as gh}from"./sessionTracing-_Hh5VXxt.js";import{i as _h,n as vh,r as yh}from"./parser-DFwaTGf7.js";import{c as bh,l as xh}from"./commitAttribution-DPnHHKSA.js";import{n as Sh,t as Ch}from"./poorMode-CBOtooa0.js";import{a as wh,f as Th,l as Eh,o as Dh}from"./api-2cdIPaeq.js";import{f as Oh,m as kh}from"./firstPartyEventLogger-BXY1IJ2D.js";import{l as Ah,u as jh}from"./referral-CKmHHxj_.js";import{i as Mh,m as Nh,n as Ph,p as Fh}from"./terminalSetup-3JNy6i_J.js";import{n as Ih,t as Lh}from"./browser-BmZuQom6.js";import{i as Rh,r as zh}from"./bridgeEnabled-Cc0mGlTb.js";import{n as Bh,r as Vh}from"./undercover-D30rKimg.js";import{t as Hh}from"./Dialog-vfLXEPed.js";import{t as Uh}from"./lib-BlVGipXx.js";import{n as Wh,t as Gh}from"./mappers-04gNXJ3w.js";import{n as Kh,r as qh}from"./sessionTitle-DAnM73S0.js";import{t as Jh}from"./bridgeMessaging-DdvApEqW.js";import{C as Yh,S as Xh,d as Zh,l as Qh}from"./pidLock-CbC_il6r.js";import{n as $h,t as eg}from"./nativeInstaller-yj81F75v.js";import{r as tg,t as ng}from"./pipeTransport-CqCnc-Ys.js";import{t as rg}from"./useManagePlugins-B11_87VN.js";import{n as ig,t as ag}from"./MCPConnectionManager-NRfIjdlj.js";import{i as og,n as sg,r as cg,t as lg}from"./reconciler-CYD_XpG4.js";import{n as ug,t as dg}from"./toolPool-BR27AMJO.js";import{a as fg,c as pg,i as mg,l as hg,r as gg,t as _g,u as vg}from"./MessageSelector-iIroHvXo.js";import{n as yg,t as bg}from"./useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js";import{n as xg,t as Sg}from"./sideQuestion-hUhxls9r.js";import{a as Cg,n as wg,o as Tg,r as Eg,s as Dg,t as Og}from"./skillChangeDetector-C65ZLSYV.js";import{n as kg,t as Ag}from"./refresh-ZqZdmLK5.js";import{i as jg,n as Mg,r as Ng,t as Pg}from"./directoryCompletion-CW2ckkQg.js";import{r as Fg,t as Ig}from"./PromptInputFooterSuggestions-BmsFdOu9.js";import{n as Lg,t as Rg}from"./useMergedTools-CR56my9t.js";import{a as zg,i as Bg,n as Vg,o as Hg,r as Ug,t as Wg}from"./promptEditor-CyTzyjwG.js";import{n as Gg,t as Kg}from"./useMainLoopModel-Gy1Vv4Qr.js";import{i as qg,n as Jg,r as Yg,t as Xg}from"./PermissionDialog-0ya1CU5k.js";import{n as Zg,t as Qg}from"./RemoteCallout-B-tyvQOe.js";import{a as $g,c as e_,i as t_,o as n_,r as r_,s as i_}from"./caches-5HVQSevy.js";import{i as a_,n as o_,r as s_,t as c_}from"./conversation-DCMw_rsE.js";import{i as l_,n as u_,r as d_,t as f_}from"./extraUsage-CpgRTcMk.js";import{n as p_,t as m_}from"./useSearchInput-C5OzQnX6.js";import{n as h_,t as g_}from"./staticRender-BIxpgNUq.js";import{n as __,t as v_}from"./useSettingsErrors-B9vOZL41.js";import{n as y_,t as b_}from"./shadowedRuleDetection-C6R5zOUe.js";import{n as x_,t as S_}from"./ExitFlow-DnPydE17.js";import{a as C_,i as w_,r as T_,t as E_}from"./fast-C4ZevUNL.js";import{n as D_,r as O_}from"./Feedback-SmGiR3mf.js";import{a as k_,i as A_,n as j_,r as M_,t as N_}from"./PromptInputHelpMenu-DX-0wEDo.js";import{n as P_,r as F_}from"./pluginAutoupdate-0k03PVff.js";import{n as I_,r as L_}from"./autoModeDenials-BxNzGJdR.js";import{n as R_,t as z_}from"./generateSessionName-w0BMtwS7.js";import{a as B_,c as V_,d as H_,i as U_,l as W_,n as G_,o as K_,r as q_,s as J_,t as Y_,u as X_}from"./Messages-D4Hm4gaY.js";import{a as Z_,i as Q_,n as $_,o as ev,r as tv,t as nv}from"./BackgroundTasksDialog-D4qA0M5O.js";import{n as rv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as iv}from"./earlyInput-BTC_Wucv.js";import{a as av,c as ov,i as sv,l as cv,o as lv,r as uv,s as dv,t as fv}from"./RemoteSessionManager-DCd0O5_l.js";import{n as pv,t as mv}from"./backgroundHousekeeping-DtJNx4Ja.js";import{n as hv}from"./language-Ca4B018X.js";import{homedir as gv,tmpdir as _v}from"os";import*as vv from"path";import{basename as yv,dirname as bv,extname as xv,join as Sv,relative as Cv,sep as wv}from"path";import{dirname as Tv,join as Ev}from"node:path";import{watch as Dv}from"fs";import{createHash as Ov}from"node:crypto";import{randomUUID as kv}from"crypto";import{readFile as Av,stat as jv,writeFile as Mv}from"fs/promises";import{spawn as Nv,spawnSync as Pv}from"child_process";import{mkdir as Fv,readFile as Iv,rename as Lv,writeFile as Rv}from"node:fs/promises";s(),c(),p(),L(),me(),u(),B(),Oe(),We(),at(),Gd(),af(),Xd(),lf(),Qd(),of(),nf(),qf(),tp(),rp(),Jf(),ap(),sp(),Uf(),lp(),up(),hp(),Pf(),xp(),_p(),yp(),wp(),Dp(),kf(),ke(),Np(),Fp(),uf(),hf(),_f(),Mf(),Ff(),zp(),Ef(),If(),sm(),Pm(),zf(),Rm(),Vm(),ym(),vm(),km(),bm(),$p(),Gp(),um(),im(),Lm(),Km(),Br(),Fd(),nd(),Zm(),Vl(),Im(),Hm(),Mm(),Wm(),no(),Jr(),$m(),ui(),rd(),Gu(),os(),ar(),K(),Xr(),Ga(),Dc(),ba(),jr(),gh(),yh(),Xm(),qi(),Ha(),is(),Fs(),Pc(),St(),hr(),Ca(),nh(),Xi(),li(),Nt(),Ua(),xd(),Ct(),yo(),jh(),Pr(),Lc(),Ku(),sc(),Hl(),ks(),ol(),Fh(),Mh(),Su(),Wd(),Pi(),Ah(),Kc(),Ji(),Kn(),Cl(),Yl(),fs(),Zr(),lc(),ou(),ru(),si(),ju(),Lh(),ro(),Xn(),zt(),Yu(),Kr(),ra(),Vt(),Od(),Ru(),Ol(),jo(),ii(),vi(),zu(),Et(),Fr(),Rt(),Rn(),od(),Ed(),ts(),yl(),Gl(),zh(),wr(),$i(),Xc(),Cn(),fh(),To(),to(),sa(),vn(),gs(),Md(),Ps(),pl(),mh(),Ks(),Uo(),$t(),$c(),Bn(),xc(),Ss(),Dl(),Hs(),Qi(),Bc(),ad(),La(),ya(),fr(),oa(),jd(),Ns(),ds(),Dt(),_i(),Zi(),_l(),_a(),Uc(),ri(),kd(),Gs(),Io(),Zl(),rr(),rn(),qg(),Jg(),m_(),D_();var Q=n(z(),1);x(),G_(),pc(),pd(),J(),g_();var $=ve();function zv({children:e}){let{bindings:t}=sn(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(S,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Bv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Vv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>h_((0,$.jsx)(Ti,{children:(0,$.jsx)(zv,{children:(0,$.jsx)(Y_,{messages:e,tools:t,commands:[],verbose:i,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:`export`,screen:`prompt`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:n})})}),r),c=a;for(let t of e)c+=Bv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(pe(t).trim()===``)break;await n(t),o?.(e+a)}}async function Hv(e,t=[],n){let r=[];return await Vv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}ca(),Ds(),kc(),El(),zg(),mu();function Uv({onDone:e}){return(0,$.jsxs)(ge,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(C,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(Fc,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),mu();function Wv({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${Gv(e)} and this conversation is ${jp(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(T,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(Fc,{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 Gv(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`}async function Kv(e,t){let n=Rf().preferredNotifChannel;await eo(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await Jv(n,e,t),term:Sf.terminal})}var qv=`Work Mate`;async function Jv(e,t,n){let r=t.title||qv;try{switch(e){case`auto`:return Yv(t,n);case`iterm2`:return n.notifyITerm2(t),`iterm2`;case`iterm2_with_bell`:return n.notifyITerm2(t),n.notifyBell(),`iterm2_with_bell`;case`kitty`:return n.notifyKitty({...t,title:r,id:Xv()}),`kitty`;case`ghostty`:return n.notifyGhostty({...t,title:r}),`ghostty`;case`terminal_bell`:return n.notifyBell(),`terminal_bell`;case`notifications_disabled`:return`disabled`;default:return`none`}}catch{return`error`}}async function Yv(e,t){let n=e.title||qv;switch(Sf.terminal){case`Apple_Terminal`:return await Zv()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:Xv()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function Xv(){return Math.floor(Math.random()*1e4)}async function Zv(){try{if(Sf.terminal!==`Apple_Terminal`)return!1;let e=(await Yf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Yf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return X(e),!1}}var Qv=300,$v=240*1e3,ey=null,ty=null,ny=0,ry=!1;function iy(){ny++,ny===1&&(ly(),sy())}function ay(){ny>0&&ny--,ny===0&&(cy(),uy())}function oy(){ny=0,cy(),uy()}function sy(){process.platform===`darwin`&&ty===null&&(ty=setInterval(()=>{ny>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),uy(),ly())},$v),ty.unref())}function cy(){ty!==null&&(clearInterval(ty),ty=null)}function ly(){if(process.platform===`darwin`&&ey===null){ry||(ry=!0,sf(async()=>{oy()}));try{ey=Nv(`caffeinate`,[`-i`,`-t`,String(Qv)],{stdio:`ignore`}),ey.unref();let e=ey;ey.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),ey===e&&(ey=null)}),ey.on(`exit`,()=>{ey===e&&(ey=null)}),Y(`Started caffeinate to prevent sleep`)}catch{ey=null}}}function uy(){if(ey!==null){let e=ey;ey=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var dy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,_t()),l(this,`subscribe`,this._changed.subscribe),l(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function fy(e,t=!1){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(void 0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let o=e[0]?.uuid,s=n.current,c=i.current===void 0,l=o!==void 0&&!c&&o===i.current&&s<=e.length,u=o!==void 0&&!c&&o===i.current&&s>e.length,d=l?s:0;if(d===e.length)return;let f=d===0?e:e.slice(d),p=l?r.current:void 0,m=++a.current;if(_u(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=va(f,e).findLast(yi);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function py(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function my(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 hy(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&py(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&py(t.response)?t.response:void 0,r=my(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function gy(t){{let{pauseProactive:t}=(fh(),e(th));t()}t?.abort()}function _y(e,t){return e<t}function vy(e,t){return e&&t===0}function yy({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||_y(n,r)}Js(),s_();function by(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 xy(e,t){return e.id.localeCompare(t.id)}function Sy(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(by).sort(xy)}}function Cy(e,t){return JSON.stringify(Sy(e,t))}function wy(e,t){let n=Sy(e,t);return{type:`task_state`,uuid:kv(),...n}}B(),J(),nf();var Ty=50,Ey=5e3,Dy=1e4,Oy=3;function ky(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=Yr(),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 _=br(),{addNotification:v}=di(),y=G(e=>e.replBridgeEnabled),b=G(e=>e.replBridgeConnected),x=G(e=>e.replBridgeSessionActive),S=G(e=>e.replBridgeOutboundOnly),C=G(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)(T,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=Oy){Y(`[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 m=!1,h=e.length;return(async()=>{try{if(o.current&&(Y(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,Y(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),m)return;let{initReplBridge:v}=await import(`./initReplBridge-C-P4dgAG.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-DyD9XCda.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-z2o4-UJe.js`);b=e()}async function x(e){try{let t=cg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-C5K3XPTC.js`),i=t.content,a=await r(e,i);Y(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),qu({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){Y(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function S(e,n){if(m)return;if(r){Y(`[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!==``?xo(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?td(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,ec(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]);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(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Dy);break}}let w=new Map;function T(e){let t=e.response?.request_id;if(!t)return;let n=w.get(t);if(!n){Y(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=hy(e);if(!r){Y(`[bridge:repl] Ignoring unrecognized control_response request_id=${t}`);return}w.delete(t),n(r)}let E=await v({outboundOnly:r,tags:r?[`ccr-mirror`]:void 0,onInboundMessage:x,onPermissionResponse:T,onInterrupt(){gy(n.current)},onSetModel(e){let t=e==="default"?null:e??null;Ke(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(bn())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`&&!Nn()){let e=dd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${ps(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Yi(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),{ok:!0}},onStateChange:S,initialMessages:e.length>0?e:void 0,getMessages:()=>g.current,previouslyFlushedUUIDs:u.current,initialName:C,perpetual:b}),D=E?{...E,markTranscriptReset(){l.current=!0,c.current=!1,s.current=0}}:null;if(m){Y(`[bridge:repl] Hook: init cancelled during flight, tearing down${D?` env=${D.environmentId}`:``}`),D&&D.teardown();return}if(!D){f.current++,Y(`[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(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Dy);return}if(a.current=D,a_(D),f.current=0,s.current=h,r)p(e=>e.replBridgeConnected&&e.replBridgeSessionId===D.bridgeSessionId?e:{...e,replBridgeConnected:!0,replBridgeSessionId:D.bridgeSessionId,replBridgeSessionUrl:void 0,replBridgeConnectUrl:void 0,replBridgeError:void 0}),Y(`[bridge:repl] Mirror initialized, session=${D.bridgeSessionId}`);else{let e={sendRequest(e,t,n,r,i,a,o){D.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};D.sendControlResponse({type:`control_response`,response:{subtype:`success`,request_id:e,response:n}})},cancelRequest(e){D.sendControlCancelRequest(e)},onResponse(e,t){return w.set(e,t),()=>{w.delete(e)}}};p(t=>({...t,replBridgePermissionCallbacks:e}));let n=td(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:xo(D.environmentId,D.sessionIngressUrl);p(e=>e.replBridgeConnected&&e.replBridgeSessionUrl===n?e:{...e,replBridgeConnected:!0,replBridgeSessionUrl:n,replBridgeConnectUrl:r??e.replBridgeConnectUrl,replBridgeEnvironmentId:D.environmentId,replBridgeSessionId:D.bridgeSessionId,replBridgeError:void 0});let i=!b&&await y().catch(()=>!1);if(m)return;t(e=>[...e,yu(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),Y(`[bridge:repl] Hook initialized, session=${D.bridgeSessionId}`)}}catch(e){if(m)return;f.current++;let n=Yd(e);Y(`[bridge:repl] Init failed: ${n}; consecutive failures: ${f.current}`),clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Dy),r||t(e=>[...e,ec(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{m=!0,clearTimeout(d.current),d.current=void 0,a.current&&(Y(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,a_(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&&Y(`[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&&vy(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=Dv(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=Zo();c(Wu(n));try{let r=await fd(n);if(e||a.current!==t)return;let i=Cy(n,r);if(i===o&&t===s)return;t.writeSdkMessages([wy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${Yd(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},Ty),t.unref?.()};l();let d=Pa(u);return n=setInterval(()=>{l()},Ey),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(vy(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||yy({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}Hr(),gr(),Ta(),Sn(),In(),bg(),gg(),xp();var Ay=Ee(()=>be({method:ye(`log_event`),params:be({eventName:Se(),eventData:be({}).passthrough()})}));function jy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Kl(e);t&&t.client.setNotificationHandler(Ay(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}at(),B();var My=6e3;function Ny(){return Date.now()-ze()}function Py(e){return Ny()<e}function Fy(e){return!Py(e)}function Iy(e,t){let n=E();(0,Q.useEffect)(()=>{vt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Fy(6e3)&&!r&&(r=!0,clearInterval(i),Kv({message:e,notificationType:t},n))},My);return()=>clearInterval(i)},[e,t,n])}vs(),ho(),nl(),Vn(),mn(),Ug(),B(),fu();var Ly={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Ry(e){return Xs().syntaxHighlightingDisabled?(0,$.jsx)(By,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(By,{...e,highlight:null}),children:(0,$.jsx)(zy,{...e})})}function zy(e){let t=(0,Q.use)(xi());return(0,$.jsx)(By,{...e,highlight:t})}function By({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=de(),[s]=y(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>su(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=>_(e))),v=Math.min(h+4,c),x=v-4,S=`${Ly.topLeft}${Ly.horizontal.repeat(v-2)}${Ly.topRight}`,C=`${Ly.bottomLeft}${Ly.horizontal.repeat(v-2)}${Ly.bottomRight}`,w=d?(()=>{let e=u.length-l,t=`${Ly.horizontal.repeat(3)} \u2702 ${Ly.horizontal.repeat(3)} ${e} lines hidden `,n=_(t),r=Math.max(0,v-2-n);return`${Ly.teeLeft}${t}${Ly.horizontal.repeat(r)}${Ly.teeRight}`})():null;return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:S}),m.map((e,t)=>{let n=_(e)>x?Nc(e,0,x):e,r=` `.repeat(Math.max(0,x-_(n)));return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[Ly.vertical,` `]}),(0,$.jsx)(g,{children:n}),(0,$.jsxs)(T,{dimColor:!0,children:[r,` `,Ly.vertical]})]},t)}),w&&(0,$.jsx)(T,{color:`warning`,children:w}),(0,$.jsx)(T,{dimColor:!0,children:C})]})}yo(),B(),Dp();function Vy({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${d.tick} Submit `,a=_(`← `)+_(` →`)+_(n),o=i-a;if(o<=0)return e.map((e,n)=>{let r=e?.header||`Q${n+1}`;return n===t?r.slice(0,3):``});let s=e.map((e,t)=>e?.header||`Q${t+1}`);if(s.map(e=>4+_(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+_(s[t]||``),l=Math.min(c,o/2),u=o-l,f=e.length-1,p=Math.max(6,Math.floor(u/Math.max(f,1)));return s.map((e,n)=>n===t?Ep(e,l-2-2):Ep(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(b,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(T,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?d.checkboxOn:d.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(b,{children:i?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(T,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(b,{children:t===e.length?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,d.tick,` Submit`,` `]}):(0,$.jsxs)(T,{children:[` `,d.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(T,{color:t===e.length?`inactive`:void 0,children:` →`})]})}u(),yo(),B(),J(),Yu();function Hy({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:u,onCancel:f,onTabPrev:p,onTabNext:h,onRespondToClaude:g,onFinishPlanInterview:_}){let y=G(e=>e.toolPermissionContext.mode)===`plan`,[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(0),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),ee=Bg(),j=ee?zn(ee):null,M=e.question,te=i[M],N=e.options,[P,F]=(0,Q.useState)(0),ne=(0,Q.useRef)(M);if(ne.current!==M){ne.current=M;let e=te?.selectedValue,t=e?N.findIndex(t=>t.label===e):-1;F(t>=0?t:0)}let re=N[P],I=te?.selectedValue,L=te?.textInputValue||``,ie=(0,Q.useCallback)(e=>{let t=N[e];t&&(F(e),c(M,{selectedValue:t.label},!1),l(M,t.label))},[N,M,c,l]),R=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?P>0?P-1:P:P<N.length-1?P+1:P,t>=0&&t<N.length&&F(t)},[P,N.length,E]);A(`chat:externalEditor`,async()=>{let e=te?.textInputValue||``,t=await Vg(e);t.content!==null&&t.content!==e&&c(M,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!ee}),v({"tabs:previous":()=>p?.(),"tabs:next":()=>h?.()},{context:`Tabs`,isActive:!E&&!x});let z=(0,Q.useCallback)(()=>{D(!1),u(!1),I&&l(M,I)},[I,M,l,u]),ae=(0,Q.useCallback)(()=>{S(!0)},[]),oe=(0,Q.useCallback)(()=>{S(!1)},[]),se=(0,Q.useCallback)(e=>{if(x){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),C===0?oe():w(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),y&&C===0&&w(1);return}if(e.key===`return`){e.preventDefault(),C===0?g():_();return}e.key===`escape`&&(e.preventDefault(),f());return}if(E){e.key===`escape`&&(e.preventDefault(),z());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),P>0&&R(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),P===N.length-1?ae():R(`down`);else if(e.key===`return`)e.preventDefault(),ie(P);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),D(!0),u(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<N.length&&R(t)}},[x,C,y,E,P,N.length,oe,ae,R,ie,z,g,_,f,u]),ce=re?.preview||null,{columns:le}=de(),ue=le-30-4,fe=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:se,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Vy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Yg,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(b,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(b,{flexDirection:`column`,width:30,children:N.map((e,t)=>{let n=P===t,r=I===e.label;return(0,$.jsxs)(b,{flexDirection:`row`,children:[n?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(T,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(T,{color:`success`,children:[` `,d.tick]})]},e.label)})}),(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(Ry,{content:ce||`No preview available`,maxLines:fe,minWidth:s,maxWidth:ue}),(0,$.jsxs)(b,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:`Notes:`}),E?(0,$.jsx)(Qa,{value:L,placeholder:`Add notes on this design…`,onChange:e=>{c(M,{textInputValue:e},!1)},onSubmit:z,onExit:z,focus:!0,showCursor:!0,columns:60,cursorOffset:O,onChangeCursorOffset:k}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:L||`press n to add notes`})]})]})]}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[x&&C===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:x&&C===0?`suggestion`:void 0,children:`Chat about this`})]}),y&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[x&&C===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:x&&C===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,d.arrowUp,`/`,d.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),E&&j&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,j]}),` · Esc to cancel`]})})]})]})]})}u(),B(),J(),zg(),Yu(),Ug(),mu(),qg();function Uy({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onSubmit:h,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y,onImagePaste:x,pastedContents:S,onRemoveImage:C}){let w=G(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[ee,A]=(0,Q.useState)(!1),j=Bg(),M=j?zn(j):null,te=(0,Q.useCallback)(e=>{let t=e===`__other__`;A(t),f(t)},[f]),N=(0,Q.useCallback)(()=>{D(!0)},[]),P=(0,Q.useCallback)(()=>{D(!1)},[]),F=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?P():k(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),w&&O===0&&k(1);return}if(e.key===`return`){e.preventDefault(),O===0?v():y();return}e.key===`escape`&&(e.preventDefault(),p())}},[E,O,w,P,v,y,p]),ne=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),re=e.question,I=i[re],L=(0,Q.useCallback)(async(t,n)=>{let r=await Vg(t);r.content!==null&&r.content!==t&&(n(r.content),l(re,{textInputValue:r.content},e.multiSelect??!1))},[re,l,e.multiSelect]),ie={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:I?.textInputValue??``,onChange:t=>{l(re,{textInputValue:t},e.multiSelect??!1)}},R=[...ne,ie];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Hy,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y}):(0,$.jsxs)(b,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:F,children:[w&&o&&(0,$.jsxs)(b,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(T,{color:`inactive`,children:[`Planning: `,(0,$.jsx)($a,{filePath:o})]})]}),(0,$.jsx)(b,{marginTop:-1,children:(0,$.jsx)(m,{color:`inactive`})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Vy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Yg,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(b,{marginTop:1,children:e.multiSelect?(0,$.jsx)(zl,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[re]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(re,n,void 0,!1)},onFocus:te,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:N,isDisabled:E,onOpenEditor:L,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question):(0,$.jsx)(Fc,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!1);let t=e===`__other__`?i[re]?.textInputValue:void 0;u(re,e,t)},onFocus:te,onCancel:p,onDownFromLastItem:N,isDisabled:E,layout:`compact-vertical`,onOpenEditor:L,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question)}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[E&&O===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===0?`suggestion`:void 0,children:[R.length+1,`. Chat about this`]})]}),w&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[E&&O===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===1?`suggestion`:void 0,children:[R.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[d.arrowUp,`/`,d.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,ee&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}function Wy(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 ${H.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${H.bold(ff(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?` ${H.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${H.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 Gy({permissionResult:e,toolType:t}){let n=G(e=>e.toolPermissionContext.mode),r=Wy(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,Ky.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[i?(0,Ky.jsx)(T,{color:i,children:r.reasonString}):(0,Ky.jsx)(T,{children:(0,Ky.jsx)(g,{children:r.reasonString})}),r.configString&&(0,Ky.jsx)(T,{dimColor:!0,children:r.configString})]})}var Ky,qy=t((()=>{z(),B(),J(),Ky=ve()}));u(),B(),mu(),qg(),qy();function Jy({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Vy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Yg,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(b,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(b,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(T,{children:[d.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{color:`success`,children:[d.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(Gy,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(T,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Fc,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Yy(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 Xy={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Zy(){let[e,t]=(0,Q.useReducer)(Yy,Xy),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}}ks(),yo(),B(),jh(),xp(),J(),ca(),rp(),kc();var Qy=12,$y=40,eb=15;function tb(e){return Xs().syntaxHighlightingDisabled?(0,$.jsx)(rb,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(rb,{...e,highlight:null}),children:(0,$.jsx)(nb,{...e})})}function nb(e){let t=(0,Q.use)(xi());return(0,$.jsx)(rb,{...e,highlight:t})}function rb({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Di.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=de(),[s]=y(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Qy,o-eb);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=su(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,_(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,Qy),n),globalContentWidth:Math.max(t,$y)}},[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};as(s),bd(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`),b=G(e=>e.toolPermissionContext.mode)===`plan`,x=b?Rs():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:ee}=Zy(),A=S<(a?.length||0)?a?.[S]:null,j=S===(a?.length||0),M=a?.every(e=>e?.question&&!!C[e.question])??!1,te=a.length===1&&!a[0]?.multiSelect,N=(0,Q.useCallback)(()=>{u&&Z(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&Lt()}),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),P=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
+ This means they may have additional information, context or questions for you.
5
+ Take their response into account and then reformulate the questions if appropriate.
6
+ Start by asking them what they would like to clarify.
7
+
8
+ Questions asked:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
+ `)}`;u&&Z(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&Lt()});let r=await ib(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,g]),F=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
10
+ Stop asking clarifying questions and proceed to finish the plan with the information you have.
11
+
12
+ Questions asked and answers provided:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
+ `)}`;u&&Z(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&Lt()});let r=await ib(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,g]),ne=(0,Q.useCallback)(async n=>{u&&Z(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:b,interviewPhaseEnabled:b&&Lt()});let r={};for(let e of a){let t=n[e.question],i=w[e.question]?.textInputValue,a=(t?e.options.find(e=>e.label===t):void 0)?.preview;(a||i?.trim())&&(r[e.question]={...a&&{preview:a},...i?.trim()&&{notes:i.trim()}})}let i={...e.input,answers:n,...Object.keys(r).length>0&&{annotations:r}},o=await ib(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,w,b,g]),re=(0,Q.useCallback)((e,t,n,r=!0)=>{let i,o=Array.isArray(t);i=o?t.join(`, `):n?Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`${n} (Image attached)`:n:t===`__other__`&&Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`(Image attached)`:t;let s=a.length===1;if(!o&&s&&r){let t={...C,[e]:i};ne(t).catch(X);return}k(e,i,r)},[k,a.length,C,ne,d]);function I(e){if(e===`cancel`){N();return}e===`submit`&&ne(C).catch(X)}let L=te?(a?.length||1)-1:a?.length||0,ie=(0,Q.useCallback)(()=>{S>0&&D()},[S,D]),R=(0,Q.useCallback)(()=>{S<L&&E()},[S,L,E]);return v({"tabs:previous":ie,"tabs:next":R},{context:`Tabs`,isActive:!(T&&!j)}),A?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Uy,{question:A,questions:a,currentQuestionIndex:S,answers:C,questionStates:w,hideSubmitTab:te,minContentHeight:c,minContentWidth:l,planFilePath:x,onUpdateQuestionState:O,onAnswer:re,onTextInputFocus:ee,onCancel:N,onSubmit:E,onTabPrev:ie,onTabNext:R,onRespondToClaude:P,onFinishPlanInterview:F,onImagePaste:(e,t,n,r,i)=>m(A.question,e,t,n,r,i),pastedContents:d[A.question]??{},onRemoveImage:e=>h(A.question,e)})}):j?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Jy,{questions:a,currentQuestionIndex:S,answers:C,allQuestionsAnswered:M,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:I})}):null}async function ib(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Vr({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var ab=[`http://`,`https://`,`ftp://`],ob={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},sb=e=>Array.isArray(e)?e:[e];function cb(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 lb(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(`-`)?!cb(t,n):!1}function ub(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){lb(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||cb(r,t))return r}}}async function db(e,t,n){let r=await fb(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&&sb(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){lb(c,t[s+1],n)&&s++;continue}break}if(await pb(c,t.slice(0,s),n))break;a&&!o&&(o=cb(c,n)),i.push(c)}return i.join(` `)}async function fb(e,t,n){let r=ub(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(ob[a])return ob[a];if(ob[i])return ob[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&&sb(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=sb(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=sb(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&&sb(n.args).some(e=>e?.isDangerous)?3:2}async function pb(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=ab.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&&sb(e.args).some(e=>e?.isModule))return!1}return!0}var mb=[{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 hb(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 gb=ip(async e=>mb.find(t=>t.name===e)||await hb(e)||null,e=>e),_b=/^\d+$/,vb=/^[A-Za-z_][A-Za-z0-9_]*=/,yb=new Set([`nice`]),bb=e=>Array.isArray(e)?e:[e];function xb(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Sb(e,t=0,n=0){if(n>2||t>10)return null;let r=await _h(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=vh(a);if(!o)return{commandPrefix:null};let c=await gb(o),l=yb.has(o)||c?.args&&bb(c.args).some(e=>e?.isCommand);l&&s[0]&&xb(s[0],c)&&(l=!1);let u=l?await Cb(o,s,t,n):await db(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 Cb(e,t,n,r){let i=await gb(e);if(i?.args){let a=bb(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 Sb(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(`-`)&&!vb.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!_b.test(e)&&!vb.test(e));if(!a)return e;let o=await Sb(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function wb(e,t){let n=ua(e);if(n.length<=1){let t=await Sb(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Sb(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(Tb(e));return a}function Tb(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 Eb(e){Z(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}var Db=t((()=>{xp()}));Gt(),Yc(),xp(),Io(),Ff(),J(),uf(),Db();function Ob(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=Cc(e.suggestions),n=t.length>0?t.map(e=>ff(e)).join(`, `):`none`;return`ask: ${e.message},
14
+ suggestions: ${n}
15
+ reason: ${kb(e.decisionReason)}`}case`deny`:return`deny: ${e.message},
16
+ reason: ${kb(e.decisionReason)}`;case`passthrough`:{let t=Cc(e.suggestions),n=t.length>0?t.map(e=>ff(e)).join(`, `):`none`;return`passthrough: ${e.message},
17
+ suggestions: ${n}
18
+ reason: ${kb(e.decisionReason)}`}}}function kb(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: ${ff(e.rule.ruleValue)}`;case`mode`:return`Mode: ${e.mode}`;case`subcommandResults`:return`Subcommand Results: ${Array.from(e.reasons.entries()).map(([e,t])=>`${e}: ${Ob(t)}`).join(`,
19
+ `)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${cf(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 cf(e,null,2)}}function Ab(e,t){let n=Yr(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(r.current!==e.toolUseID){if(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),Z(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:qm(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:Mu.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===Hu.name&&t.behavior===`ask`&&!fc(t.suggestions)&&Z(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:qm(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:Mu.isSandboxingEnabled(),decisionReasonDetails:kb(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=Hu.inputSchema.safeParse(e.input);if(e.tool.name===Hu.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=ua(t.data.command)}catch{}Z(`tengu_internal_bash_tool_use_permission_request`,{parts:cf(n),input:cf(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:kb(e.permissionResult.decisionReason)})}}Eb({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Sf.platform}})}},[e,t,n])}L(),u(),B(),J(),is(),Ff(),y_(),Vl();function jb(e){if(e.type===`classifier`)return`${H.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${H.bold(ff(e.rule.ruleValue))} rule from ${Af(e.rule.source)}`;case`mode`:return`${bf(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`${H.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${H.bold(e.hookName)} hook: ${e.reason}`:`${H.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Mb({title:e,decisionReason:t}){let[n]=y();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(b,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[t.behavior===`allow`?ce(`success`,n)(d.tick):ce(`error`,n)(d.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(g,{children:jb(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Nb,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(T,{children:(0,$.jsx)(g,{children:jb(t)})})}}return(0,$.jsxs)(b,{flexDirection:`column`,children:[e&&(0,$.jsx)(T,{children:e}),r()]})}function Nb({suggestions:e}){let t=Cc(e);return t.length===0?null:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(g,{children:t.map(e=>H.bold(ff(e))).join(`, `)})]})}function Pb(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Fb(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Ib({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:`None`})]});let n=Cc(e),r=Pb(e),i=Fb(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(T,{children:`None`})]}):(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:` `})]}),n.length>0&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(b,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,ff(e)]},t))})]}),r.length>0&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(b,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(T,{children:bf(i)})]})]})}function Lb({permissionResult:e,toolName:t}){let n=G(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=Mu.isSandboxingEnabled()&&Mu.isAutoAllowBashIfSandboxedEnabled(),r=b_(n,{sandboxAutoAllowEnabled:e}),a=Cc(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(T,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Message `})}),(0,$.jsx)(T,{children:e.message})]}),(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(T,{children:`undefined`}):(0,$.jsx)(Mb,{decisionReason:r})]}),(0,$.jsx)(Ib,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(b,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(T,{color:`warning`,children:ff(e.rule.ruleValue)}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Oe(),xp(),Km(),zf(),nf(),lf(),ke(),rp(),Ch(),En(),Qd();var Rb={LOW:1,MEDIUM:2,HIGH:3},zb=1,Bb=2,Vb=3,Hb=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Ub={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`]}},Wb=Ee(()=>be({riskLevel:Te([`LOW`,`MEDIUM`,`HIGH`]),explanation:Se(),reasoning:Se(),risk:Se()}));function Gb(e){if(typeof e==`string`)return e;try{return cf(e,null,2)}catch{return String(e)}}function Kb(e,t=1e3){let n=e.filter(e=>e.type===`assistant`).slice(-3),r=[],i=0;for(let e of n.reverse()){let n=(Array.isArray(e.message.content)?e.message.content:[]).filter(e=>e.type===`text`).map(e=>`text`in e?e.text:``).join(` `);if(n&&i<t){let e=t-i,a=n.length>e?n.slice(0,e)+`...`:n;r.unshift(a),i+=a.length}}return r.join(`
20
+
21
+ `)}function qb(){return Rf().permissionExplainerEnabled!==!1}async function Jb({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!qb())return null;let a=Date.now();try{let o=Gb(t),s=r?.length?Kb(r):``,c=`Tool: ${e}
22
+ ${n?`Description: ${n}\n`:``}
23
+ Input:
24
+ ${o}
25
+ ${s?`\nRecent conversation context:\n${s}`:``}
26
+
27
+ Explain this command in context.`,l=await Hi({model:Sh()?dm():Em(),system:Hb,messages:[{role:`user`,content:c}],tools:[Ub],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;Y(`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`){Y(`Permission explainer: tool input: ${cf(d.input).slice(0,500)}`);let t=Wb().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return Z(`tengu_permission_explainer_generated`,{tool_name:qm(e),risk_level:Rb[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Z(`tengu_permission_explainer_error`,{tool_name:qm(e),error_type:zb,latency_ms:u}),Y(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${Yd(t)}`),X(t),Z(`tengu_permission_explainer_error`,{tool_name:qm(e),error_type:t instanceof Error&&t.name===`AbortError`?Bb:Vb,latency_ms:n}),null)}}B(),jh(),xp();var Yb=`Loading explanation…`;function Xb(){let[e,t]=It(`responding`,Yb,!1);return(0,$.jsx)(b,{ref:e,children:(0,$.jsx)(T,{children:Yb.split(``).map((e,n)=>(0,$.jsx)(al,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Zb(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Qb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function $b(e){return Jb({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function ex(e){let t=qb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return A(`confirm:toggleExplanation`,()=>{n||(Z(`tengu_permission_explainer_shortcut_used`,{}),i||a($b(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function tx({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(T,{children:t.explanation}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:t.reasoning})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:Zb(t.riskLevel),children:[Qb(t.riskLevel),`:`]}),(0,$.jsxs)(T,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Explanation unavailable`})})}function nx({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Xb,{})}),children:(0,$.jsx)(tx,{promise:t})})}yo(),B(),rp(),mi(),$r();function rx(e){let[t]=(0,Q.useState)(()=>ox(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ax,{placeholder:!0}),children:(0,$.jsx)(ix,{promise:t,file_path:e.file_path})})}function ix({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=de();return(0,$.jsx)(ax,{children:(0,$.jsx)(Tr,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function ax({children:e,placeholder:t}){return(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(T,{dimColor:!0,children:`…`}):e})})}async function ox(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 sx(e,[r]);try{let t=await Oi(e);if(t===null)return sx(e,n);try{if(!r||r.old_string===``){let r=await ea(t);return r===null?sx(e,n):{patch:Wr({filePath:e,fileContents:r,edits:n.map(e=>cx(r,e))}),firstLine:Ip(r),fileContent:r}}let i=await Yn(t,r.old_string,3);if(i.truncated||i.content===``)return sx(e,[r]);let a=cx(i.content,r);return{patch:lr(Wr({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Ip(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return X(t),sx(e,n)}}function sx(e,t){return{patch:t.flatMap(t=>Wr({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function cx(e,t){let n=wn(e,t.old_string)||t.old_string;return{...t,old_string:n}}zd(),xp(),Rt(),zf(),Fr(),lf(),Yu(),rp();function lx({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)(()=>kv().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${yv(n)} (${c}) ⧉`,[n,c]),u=ns(t.options.mcpClients)&&Rf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=bl(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Z(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await dx(n,r,t,l);if(a.current)return;Z(`tengu_ext_diff_accepted`,{});let c=ux(n,o,s,i);if(c.length===0){Z(`tengu_ext_diff_rejected`,{});let i=Kl(t.options.mcpClients);i&&await fx(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){X(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Kl(t.options.mcpClients);return e?fx(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function ux(e,t,n,r){let i=r===`single`,a=$l({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&X(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),Bi(a))}async function dx(e,t,n,r){let i=!1,a=dp(e),o=``;try{o=mp(a)}catch(e){if(!$d(e))throw e}async function s(){if(!i){i=!0;try{await fx(r,c)}catch(e){X(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Kl(n.options.mcpClients);try{let{updatedFile:e}=Zc({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;cp()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Qc(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await Ir(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(hx(u))return s(),{oldContent:o,newContent:u[1].text};if(px(u))return s(),{oldContent:o,newContent:e};if(mx(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw X(e),s(),e}}async function fx(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await Ir(`close_tab`,{tab_name:e},t)}catch(e){X(e)}}function px(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 mx(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 hx(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}B(),Gd(),Yu(),mu();function gx({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)(he,{color:`permission`,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(T,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(T,{color:`warning`,children:Cv(Kd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),un()&&(0,$.jsx)(T,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:yv(r)}),`?`]}),(0,$.jsx)(Fc,{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)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}at(),B(),up();function _x(e){let t=dp(e),n=dp(`${ut()}/.claude`),r=Vd(t),i=Vd(n);return r.startsWith(i+wv.toLowerCase())||r.startsWith(i+`/`)}function vx(e){let t=dp(e),n=Sv(gv(),`.claude`),r=Vd(t),i=Vd(n);return r.startsWith(i+wv.toLowerCase())||r.startsWith(i+`/`)}function yx({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Qo(`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=en(e,t),u=_x(e),d=vx(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .claude/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(T,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]});else{let r=yv(pp(e))||`this directory`;t=n===`read`?(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(T,{children:[`Yes, allow all edits in `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}xp(),Km(),uf(),ri(),Db();function bx(e,t,n,r,i){Eb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Sf.platform,hasFeedback:i??!1}})}function xx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;bx(`accept`,a,o,n),Z(`tengu_accept_submitted`,{toolName:qm(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 Sx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(bx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Bm,ruleContent:t.scope===`global-claude-folder`?Um:zm}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?ia(r,l,a):[];o(),i.onAllow(i.input,u)}function Cx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;bx(`reject`,o,s,n,t?.hasFeedback),Z(`tengu_reject_submitted`,{toolName:qm(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 wx={"accept-once":xx,"accept-session":Sx,reject:Cx};J(),jh(),xp(),Km();function Tx({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=G(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),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>yx({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),T=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=wx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?b:S,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,b,S]);return v({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=w.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);T(e.option,t)}},[w,o,r.input,T])},{context:`Confirmation`}),{options:w,onChange:T,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&y(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:qm(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),Z(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),x(!0),Z(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(y(!1),Z(`tengu_reject_feedback_mode_collapsed`,t)):(y(!0),C(!0),Z(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}B(),ca(),Gd(),up(),mu();function Ex({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?Ni(l):`none`),[p,l]);Ab(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=dp(l),{resolvedPath:t,isSymlink:n}=tf(rf(),e);return n?t:null},[l,d]),g=Tx({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:x,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E}=g,D=u(e.input),O=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:k,showingDiffInIDE:ee,ideName:A}=lx(O?{onChange:(e,t)=>{let n=f.applyChanges(D,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:O.filePath,edits:(O.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:O.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),j=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(ee&&O&&l)return(0,$.jsx)(gx,{onChange:(e,t,n)=>j(e,n),options:_,filePath:l,input:D,ideName:A,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E});let M=h!=null&&Cv(Kd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Xg,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(b,{paddingX:1,marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,children:M?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(T,{children:o}):o,(0,$.jsx)(Fc,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();j(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();j(t.option,e||void 0);return}j(t.option)}},onCancel:()=>j({type:`reject`}),onFocus:e=>x(e),onInputModeToggle:S})]})]}),(0,$.jsx)(b,{paddingX:1,marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!E)&&` · Tab to add feedback`]})})]})}Gd(),lf(),hp(),of(),B(),Ps();function Dx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ox,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=gp(n);return{oldContent:(await rf().readFile(n,{encoding:e})).replaceAll(`\r
28
+ `,`
29
+ `),fileExists:!0}})().catch(e=>{if(!$d(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Ox({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Hc(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)(Ex,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:Cv(Kd(),r),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:yv(r)}),`?`]}),content:s.length>0?(0,$.jsx)(rx,{file_path:r,edits:s}):(0,$.jsx)(T,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Hu.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}uf(),Db();function kx(e,{assistantMessage:{message:{id:t}}},n,r){Eb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:vf(),hasFeedback:r??!1}})}xp(),Km(),J();function Ax({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Yr(),[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:qm(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),Z(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),Z(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),Z(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),Z(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(Z(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),kx(`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}}at(),B();function jx(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(T,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(T,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(T,{bold:!0,children:e.slice(-1)[0]})]})}}function Mx(e){return e.join(`, `).length>50?`similar`:jx(e)}function Nx(e){if(e.length===0)return``;let t=e.map(e=>yv(e)||e);return t.length===1?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),wv]}):t.length===2?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),wv,` and `,(0,$.jsx)(T,{bold:!0,children:t[1]}),wv]}):(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),wv,`, `,(0,$.jsx)(T,{bold:!0,children:t[1]}),wv,` and `,e.length-2,` more`]})}function Px(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=rc(e.ruleContent)??e.ruleContent;return n?n(t):t}))],l=o.length>0,u=s.length>0,d=c.length>0;if(u&&!l&&!d){if(s.length===1){let e=s[0];return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsx)(T,{bold:!0,children:yv(e)||e}),wv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,Nx(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,(0,$.jsx)(T,{bold:!0,children:yv(e)||e}),wv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Nx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,Mx(c),` commands in `,(0,$.jsx)(T,{bold:!0,children:ut()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Nx(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(T,{children:[`Yes, and allow access to `,Nx(e),` and `,Mx(c),` commands`]}):(0,$.jsxs)(T,{children:[`Yes, and allow `,Nx(e),` access and `,Mx(c),` commands`]})}return null}Io();function Fx(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function Ix(e){let{commandWithoutRedirections:t,redirections:n}=vo(e);return n.length>0?t:e}function Lx({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`}),yn()){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=Px(e,Gm,Ix);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&&il()&&i&&!o&&!Fx(a??``,s)&&t?.type!==`classifier`&&f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-classifier-reviewed`,placeholder:`describe what to allow...`,initialValue:a??``,onChange:i,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0})}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}B(),jh(),xp(),Km(),J(),Ps(),vi(),qi(),is(),Vl(),Gt(),Yc(),Jg(),qy();function Rx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Hu.inputSchema.parse(t.input),c=ji(o);return c?(0,$.jsx)(Dx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(zx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function zx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=y(),c=G(e=>e.toolPermissionContext),l=ex({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:x,handleReject:S,handleFocus:C}=Ax({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(o||``),[k,ee]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!il())return;let e=new AbortController;return Gn(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(O(t),ee(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let j=e.permissionResult.decisionReason?.type===`subcommandResults`,[M,te]=(0,Q.useState)(()=>{if(j){let t=Cc(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Hu.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Es(a);if(t)return`${t}:*`;let n=xu(a);return n?`${n}:*`:a}),N=(0,Q.useRef)(!1),P=(0,Q.useCallback)(e=>{N.current=!0,te(e)},[]);(0,Q.useEffect)(()=>{if(j)return;let e=!1;return wb(a,e=>Hu.isReadOnly({command:e})).then(t=>{e||N.current||t.length>0&&te(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,j]);let[F]=(0,Q.useState)(!1),{destructiveWarning:ne,sandboxingEnabled:re,isSandboxed:I}=(0,Q.useMemo)(()=>{let t=Mu.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Nr(e.input)}},[a,e.input]);Ab(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let L=(0,Q.useMemo)(()=>jn(c),[c]),ie=(0,Q.useMemo)(()=>Lx({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:O,classifierDescription:D,initialClassifierDescriptionEmpty:k,existingAllowDescriptions:L,yesInputMode:u,noInputMode:d,editablePrefix:M,onEditablePrefixChange:P}),[e,D,k,L,u,d,M,P]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{E(e=>!e)},[]),{context:`Confirmation`}),A(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function R(t){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=qm(e.tool.name);if(t===`yes-prefix-edited`){let t=(M??``).trim();if(kx(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Hu.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();kx(`tool_use_single`,e,`accept`),Z(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{kx(`tool_use_single`,e,`accept`);let t=`suggestions`in e.permissionResult&&e.permissionResult.suggestions||[];e.onAllow(e.input,t),n();break}case`no`:{let t=h.trim();Z(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),S(t||void 0);break}}}return(0,$.jsxs)(Xg,{title:re&&!I?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:l.visible,children:Hu.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(T,{dimColor:!0,children:e.description}),(0,$.jsx)(nx,{visible:l.visible,promise:l.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Lb,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(b,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Gy,{permissionResult:e.permissionResult,toolType:`command`}),ne&&(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,dimColor:!1,children:ne})}),(0,$.jsx)(T,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(Fc,{options:ie,isDisabled:!1,inlineDescriptions:!0,onChange:R,onCancel:()=>S(),onFocus:C,onInputModeToggle:x})]}),(0,$.jsxs)(b,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}at(),B(),xp(),J(),Xc(),mu(),Jg();function Bx({toolUseConfirm:e,onDone:t,onReject:n}){let r=G(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(Z(`tengu_plan_enter`,{interviewPhaseEnabled:Lt(),entryMethod:`tool`}),Qe(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Xg,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(T,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(b,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(T,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(T,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(T,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(T,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Fc,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),Lc(),xp(),J(),at(),R_(),Tl(),B(),zg(),Yu(),rp(),Ga(),_i(),im(),qi(),_f(),rn(),Xc(),ou(),Ug(),Uc(),mu(),Jg(),qy(),ar(),vs();var Vx=(Ea(),e(Qr));function Hx(e,t){let n=[{type:`setMode`,mode:xf(e),destination:`session`}];return il()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Za(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Ux(e,t,n){mt()||Tf()?.cleanupPeriodDays===0||!n&&xl(st())||z_([Sc({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||xl(st()))return;let n=st(),r=Hn();await Xu(n,e,r,`auto`),await bc(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(X)}function Wx({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=G(e=>e.toolPermissionContext),a=Yr(),o=br(),{addNotification:s}=di(),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0),m=G(e=>e.settings.showClearContextOnPlanAccept)??!1,h=G(e=>e.ultraplanSessionUrl),g=G(e=>e.ultraplanLaunching),_=!h&&!g,v=e.assistantMessage.message.usage,{mode:y,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S}=i,C=(0,Q.useMemo)(()=>Gx({showClearContext:m,showUltraplan:_,usedPercent:m?Kx(v,y):null,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S,onFeedbackChange:l}),[m,_,v,y,x,S]);function w(e,t,n,r,i){let a=p.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};as(o),bd(o),f(e=>({...e,[a]:o}))}let E=(0,Q.useCallback)(e=>{f(t=>{let n={...t};return delete n[e],n})},[]),D=Object.values(u).filter(e=>e.type===`image`),O=D.length>0,k=e.tool.name===Nm,ee=k?void 0:e.input.plan,A=k?Rs():void 0,j=e.input.allowedPrompts,M=ee??Mt(),te=!M||M.trim()===``,[N]=(0,Q.useState)(()=>zi()??void 0),[P,F]=(0,Q.useState)(()=>ee||(Mt()??`No plan found. Please write your plan to the plan file first.`)),[ne,re]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(ne){let e=setTimeout(re,5e3,!1);return()=>clearTimeout(e)}},[ne]);let ie=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Z(`tengu_plan_external_editor_used`,{}),(async()=>{if(k&&A){let e=await Wg(A);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==P&&L(!0),F(e.content),re(!0))}else{let e=await Vg(P);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==P&&(F(e.content),re(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),R(m?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function R(r){let s=c.trim(),l=s||void 0;if(r===`ultraplan`){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`ultraplan`,interviewPhaseEnabled:Lt(),planStructureVariant:N}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),au({blurb:``,seedPlan:P,getAppState:o.getState,setAppState:o.setState,signal:new AbortController().signal}).then(e=>Cd({value:e,mode:`task-notification`})).catch(X);return}let u=k&&!I?{}:{plan:P};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Nn(),t=Vx?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Vx?.setAutoModeActive(!1),Re(!0),a(e=>({...e,toolPermissionContext:{...ci(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`&&Ux(P,a,!d),r!==`no`&&!d){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&Nn()&&(i=`auto`,Vx?.setAutoModeActive(!0)),Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!0,interviewPhaseEnabled:Lt(),planStructureVariant:N,hasFeedback:!!l});let o=`\n\nIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ${Hn()}`,s=l?`\n\nUser feedback on this plan: ${l}`:``;a(e=>({...e,initialMessage:{message:{...Sc({content:`Implement the following plan:\n\n${P}${o}${s}`}),planContent:P},clearContext:!0,mode:i,allowedPrompts:j}})),Pe(!0),Ze(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Nn()){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Lt(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),Vx?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:wi({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(u,[],l);return}let f={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(f){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Lt(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),t(),e.onAllow(u,Hx(f,j),l);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,interviewPhaseEnabled:Lt(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),t(),e.onAllow(u,Hx(p,j),l);return}if(r===`no`){if(!s&&!O)return;Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:Lt(),planStructureVariant:N});let r;O&&(r=await Promise.all(D.map(async e=>(await Vr({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(s||(O?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let z=Bg(),ae=z?zn(z):null,oe=(0,Q.useRef)(R);oe.current=R;let se=(0,Q.useRef)(void 0);se.current=()=>{Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:Lt(),planStructureVariant:N}),t(),n(),e.onReject()};let ce=!te&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ce)return r((0,$.jsxs)(b,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Fc,{options:C,onChange:e=>void oe.current(e),onCancel:()=>se.current?.(),onImagePaste:w,pastedContents:u,onRemoveImage:E})}),ae&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:ae}),k&&A&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,vp(A)]}),ne&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ce,r,C,u,ae,k,A,ne]),te){function r(r){r===`yes`?(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:Lt(),planStructureVariant:N}),(Vx?.isAutoModeActive()??!1)&&(Vx?.setAutoModeActive(!1),Re(!0),a(e=>({...e,toolPermissionContext:{...ci(e.toolPermissionContext),prePlanMode:void 0}}))),Pe(!0),Ze(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Lt(),planStructureVariant:N}),t(),n(),e.onReject())}return(0,$.jsx)(Xg,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(T,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Fc,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Lt(),planStructureVariant:N}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(b,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:[(0,$.jsx)(Xg,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:`Here is Claude's plan:`})}),(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Bs,{children:P})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(Gy,{permissionResult:e.permissionResult,toolType:`tool`}),il()&&j&&j.length>0&&(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{bold:!0,children:`Requested permissions:`}),j.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ce&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Fc,{options:C,onChange:R,onCancel:()=>se.current?.(),onImagePaste:w,pastedContents:u,onRemoveImage:E})})]})]})]})}),!ce&&ae&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:ae}),k&&A&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,vp(A)]})]}),ne&&(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function Gx({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 Kx(e,t){if(!e)return null;let n=nm(pm({permissionMode:t,mainLoopModel:Em(),exceeds200kTokens:!1}),pt()),{used:r}=Wp({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 qx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Yr(),[o,s]=(0,Jx.useState)(``),[c,l]=(0,Jx.useState)(``),[u,d]=(0,Jx.useState)(!1),[f,p]=(0,Jx.useState)(!1),[m,h]=(0,Jx.useState)(null),[g,_]=(0,Jx.useState)(!1),[y,x]=(0,Jx.useState)(!1),S=e.find(e=>e.value===m)?.feedbackConfig?.type,C=S===`accept`&&!u||S===`reject`&&!f,w=(0,Jx.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=Xx[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),E=(0,Jx.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),Z(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),Z(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),Z(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),x(!0),Z(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),D=(0,Jx.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:y};r.feedbackConfig.type===`accept`?Z(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&Z(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,y]);v((0,Jx.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>D(n.value));return t},[e,D]),{context:`Confirmation`});let O=(0,Jx.useCallback)(()=>{Z(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,Yx.jsxs)(b,{flexDirection:`column`,children:[typeof r==`string`?(0,Yx.jsx)(T,{children:r}):r,(0,Yx.jsx)(Fc,{options:w,inlineDescriptions:!0,onChange:D,onCancel:O,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:E}),(0,Yx.jsx)(b,{marginTop:1,children:(0,Yx.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,C&&` · Tab to amend`]})})]})}var Jx,Yx,Xx,Zx=t((()=>{Jx=n(z(),1),B(),jh(),xp(),J(),fs(),Yx=ve(),Xx={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Dh(),hs(),Fi(),ed(),Xl(),gu(),qh(),at(),B(),Km(),uf(),Ha(),zp(),Db(),Jg(),Zx(),qy();function Qx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=y(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Ab(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Sf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Sf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Sf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Sf.platform}}),e.onReject(),n(),t()},[e,t,n]),l=ut(),u=yn(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:l})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[o,l,u]),f=(0,Q.useMemo)(()=>({toolName:qm(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Xg,{title:`Tool use`,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(T,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(T,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(T,{dimColor:!0,children:Lp(e.description,3)})]}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Gy,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(qx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function $x(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}Gd(),B();var eS={getConfig:e=>$x(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 tS(e){let t=e=>Ja.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Ex,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:Cv(Kd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:yv(n)}),`?`]}),content:(0,$.jsx)(rx,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:eS})}B();function nS(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 rS({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=y(),o=nS(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Ex,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(T,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:r}),`)`]})}),path:o,parseInput:e=>e,operationType:c?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(Qx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}yo(),B(),Fr(),ao();function iS({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>n?Wr({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)(b,{flexDirection:`column`,children:(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?Cf(a.map(t=>(0,$.jsx)(Da,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Qt,{code:t||`(No content)`,filePath:e})})})}B(),Gd(),lf(),hp();var aS={getConfig:e=>{let t;try{t=mp(e.file_path)}catch(e){if(!$d(e))throw e;t=``}return $x(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function oS(e){let t=e=>ln.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:mp(n)}}catch(e){if(!$d(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Ex,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:Cv(Kd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to `,o,` `,(0,$.jsx)(T,{bold:!0,children:yv(n)}),`?`]}),content:(0,$.jsx)(iS,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:aS})}B(),Pf(),Gd(),Fr(),of(),ao(),zd();function sS(e){let t=(0,Q.useMemo)(()=>rf().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>bp(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(cS,{...e,promise:t})})}function cS({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=yc(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:Wr({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)(b,{flexDirection:`column`,children:(0,$.jsxs)(b,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(b,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{bold:!0,children:a?e:Cv(Kd(),e)}),(0,$.jsxs)(T,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(b,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Qt,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(b,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Qt,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Cf(u.map(t=>(0,$.jsx)(Da,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
31
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Qt,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}B(),rp();function lS(e){let t=e=>{let t=Qs.inputSchema.safeParse(e);return t.success?t.data:(X(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)(Ex,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(T,{children:[`Do you want to `,s,` `,(0,$.jsx)(T,{bold:!0,children:yv(r)}),`?`]}),content:(0,$.jsx)(sS,{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})}zp(),Ya();async function uS(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||ld.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 gb(n),i=await db(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||ob[n])?null:i}async function dS(e,t){let n=await Ht(e);if(!n.valid)return[];let r=Gi(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await uS(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await uS(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=fS(t);(n===``?0:Bp(n,` `)+1)<=1&&((await gb(e))?.subcommands?.length||ob[e])||o.push(n)}return o}function fS(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(` `)}Ha();function pS({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`}),yn()&&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=Px(e,Am);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}B(),jh(),xp(),Km(),fs(),Jg(),qy();function mS(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=vd.inputSchema.parse(t.input),[s]=y(),c=ex({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:h,setRejectFeedback:g,focusedOption:_,handleInputModeToggle:v,handleReject:x,handleFocus:S}=Ax({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[C,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(a.includes(`
32
+ `)?void 0:a),O=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return dS(a,e=>kn(e,e.text)).then(t=>{e||O.current||t.length>0&&D(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let k=(0,Q.useCallback)(e=>{O.current=!0,D(e)},[]);Ab(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ee=(0,Q.useMemo)(()=>pS({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:E,onEditablePrefixChange:k}),[t,l,u,E,k]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`});function j(e){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=qm(t.tool.name);if(e===`yes-prefix-edited`){let e=(E??``).trim();if(kx(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:vd.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();kx(`tool_use_single`,t,`accept`),Z(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{kx(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();Z(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),x(e||void 0);break}}}return(0,$.jsxs)(Xg,{title:`PowerShell command`,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:c.visible,children:vd.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(T,{dimColor:!0,children:t.description}),(0,$.jsx)(nx,{visible:c.visible,promise:c.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Lb,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(b,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Gy,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(T,{children:`Do you want to proceed?`}),(0,$.jsx)(Fc,{options:ee,inlineDescriptions:!0,onChange:j,onCancel:()=>x(),onFocus:S,onInputModeToggle:v})]}),(0,$.jsxs)(b,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(_===`yes`&&!l||_===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}rp(),at(),B(),Km(),uf(),Ha(),Db(),Jg(),Zx(),qy();function hS(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=Zu.inputSchema.safeParse(e);return t.success?t.data.skill:(X(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),o=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;Ab(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=ut(),c=yn(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:a}),` in `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-exact`});let e=a.indexOf(` `);if(e>0){let n=a.substring(0,e);t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[a,s,c]),u=(0,Q.useMemo)(()=>({toolName:qm(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Sf.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Sf.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Fm,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Sf.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Fm,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Sf.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Sf.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Xg,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(T,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(T,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Gy,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(qx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}var gS=r({WorkflowPermissionRequest:()=>_S});function _S({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=y(),i=Cr(r),a=e.input,o=(0,vS.useMemo)(()=>yn(),[]),s=(0,vS.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,yS.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,yS.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,vS.useCallback)((r,i)=>{switch(r){case`yes`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,vS.useCallback)(()=>{Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,yS.jsx)(Xg,{title:`Workflow`,children:(0,yS.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,yS.jsxs)(b,{flexDirection:`column`,children:[(0,yS.jsxs)(T,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,yS.jsxs)(T,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,yS.jsx)(Gy,{permissionResult:e.permissionResult,toolType:`command`}),(0,yS.jsx)(qx,{options:s,onSelect:c,onCancel:l})]})})}var vS,yS,bS=t((()=>{vS=n(z(),1),B(),uf(),Ha(),Db(),Jg(),Zx(),qy(),yS=ve()})),xS=r({MonitorPermissionRequest:()=>SS});function SS({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=y(),i=Cr(r),a=e.input,o=(0,CS.useMemo)(()=>yn(),[]),s=(0,CS.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,wS.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,wS.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,CS.useCallback)((r,i)=>{switch(r){case`yes`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Eb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,CS.useCallback)(()=>{Eb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Sf.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,wS.jsx)(Xg,{title:`Monitor`,children:(0,wS.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,wS.jsxs)(b,{flexDirection:`column`,children:[(0,wS.jsx)(T,{bold:!0,color:i.permission,children:a.description}),(0,wS.jsx)(T,{dimColor:!0,children:Lp(a.command,5)})]}),(0,wS.jsx)(Gy,{permissionResult:e.permissionResult,toolType:`command`}),(0,wS.jsx)(qx,{options:s,onSelect:c,onCancel:l})]})})}var CS,wS,TS=t((()=>{CS=n(z(),1),B(),Zr(),uf(),Ha(),zp(),Db(),Jg(),Zx(),qy(),wS=ve()}));jh(),$i(),Ps(),Rn(),od(),Gl(),mn(),Od();var ES=(_o(),e(mr)).createWorkflowToolCore(),DS=(bS(),e(gS)).WorkflowPermissionRequest,OS=(zs(),e(kt)).MonitorTool,kS=(TS(),e(xS)).MonitorPermissionRequest;function AS(e){switch(e){case Ja:return tS;case ln:return oS;case Hu:return Rx;case vd:return mS;case Qs:return lS;case Jn:return Wx;case Ln:return Bx;case Zu:return hS;case Di:return tb;case ES:return DS??Qx;case OS:return kS??Qx;case uc:case Ju:case Ei:return rS;default:return Qx}}function jS(e){let t=e.tool.userFacingName(e.input);return e.tool===Jn?`Claude Code needs your approval for the plan`:e.tool===Ln?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function MS({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return A(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Iy(jS(e),`permission_prompt`),(0,$.jsx)(AS(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Os(),rp(),_i();async function NS(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=lh([`You are a date/time parser that converts natural language into ISO 8601 format.`,`You MUST respond with ONLY the ISO 8601 formatted string, with no explanation or additional text.`,`If the input is ambiguous, prefer future dates over past dates.`,`For times without dates, use today's date.`,`For dates without times, do not include a time component.`,`If the input is incomplete or you cannot confidently parse it into a valid date, respond with exactly "INVALID" (nothing else).`,`Examples of INVALID input: partial dates like "2025-01-", lone numbers like "13", gibberish.`,`Examples of valid natural language: "tomorrow", "next Monday", "jan 1st 2025", "in 2 hours", "yesterday".`]),d=`Current context:
33
+ - Current date and time: ${i} (UTC)
34
+ - Local timezone: ${c}
35
+ - Day of week: ${l}
36
+
37
+ User input: "${e}"
38
+
39
+ Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
40
+
41
+ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await ku({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Qu(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 X(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function PS(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}Oe(),Qd(),zp();var FS=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function IS(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function LS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function RS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function zS(e,t){let n=LS(e).indexOf(t);return n>=0?RS(e)[n]??t:t}function BS(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function VS(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function HS(e,t){let n=BS(e).indexOf(t);return n>=0?VS(e)[n]??t:t}function US(e){if(FS(e)){let[t,...n]=BS(e);return t?Te([t,...n]):Ce()}if(e.type===`string`){let t=Se();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Rp(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Rp(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=we({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 De();throw Error(`Unsupported schema: ${cf(e)}`)}function WS(e,t){let n=US(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function GS(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function KS(e,t,n){let r=WS(e,t);if(r.isValid)return r;if(GS(t)&&!PS(e)){let r=await NS(e,t.format,n);if(r.success){let e=WS(r.value,t);if(e.isValid)return e}}return r}u(),yo(),B(),jh(),zp(),Kn();var qS=e=>[`string`,`number`,`integer`].includes(e.type),JS=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,YS=e=>(e+1)%10;function XS(e){e.buffer=``,e.timer=void 0}function ZS(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,YS);return()=>clearInterval(e)},[]),(0,$.jsx)(T,{color:`warning`,children:JS[e]})}function QS(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 $S({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(tC,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(eC,{event:e,onResponse:t})}function eC({event:e,onResponse:t}){let{serverName:n,signal:r}=e,{message:i,requestedSchema:a}=e.params,o=Object.keys(a.properties).length>0,[s,c]=(0,Q.useState)(o?null:`accept`),[l,u]=(0,Q.useState)(()=>{let e={};if(a.properties)for(let[t,n]of Object.entries(a.properties))typeof n==`object`&&n&&n.default!==void 0&&(e[t]=n.default);return e}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(qS(n)&&n?.default!==void 0){let r=WS(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]),[g,_]=(0,Q.useState)(o?0:void 0),[v,y]=(0,Q.useState)(()=>{let e=m[0];if(e&&qS(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[x,S]=(0,Q.useState)(v.length),[C,w]=(0,Q.useState)(()=>new Set),[E,D]=(0,Q.useState)(),[k,ee]=(0,Q.useState)(0),j=(0,Q.useRef)(void 0),M=(0,Q.useRef)(new Map),te=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{j.current!==void 0&&clearTimeout(j.current);let e=te.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of M.current.values())e.abort();M.current.clear()},[]);let{columns:N,rows:P}=de(),F=g===void 0?void 0:m[g],ne=F!==void 0&&qS(F.schema)&&!FS(F.schema)&&!s;Is(`elicitation`),Iy(`Claude Code needs your input`,`elicitation_dialog`);let re=(0,Q.useCallback)(e=>{if(e===void 0){y(``),S(0);return}let t=m[e];if(t&&qS(t.schema)&&!FS(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);y(n),S(n.length)}},[m,l]);function I(e,t){if(!IS(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?R(e,`Select at least ${i} ${Rp(i,`item`)}`):a!==void 0&&n.length>a?R(e,`Select at most ${a} ${Rp(a,`item`)}`):R(e)}function L(e){F&&IS(F.schema)?(I(F.name,F.schema),D(void 0)):F&&FS(F.schema)&&D(void 0),ne&&F&&(ae(F.name,F.schema,v),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),GS(F.schema)&&v.trim()!==``&&f[F.name]&&se(F.name,F.schema,v));let t=m.length+2,n=g??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(_(r),c(null),re(r)):(_(void 0),c(r===m.length?`accept`:`decline`),y(``))}function ie(e,t){u(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&R(e)}function R(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function z(e){e&&(ie(e,void 0),R(e),y(``),S(0))}function ae(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){z(e);return}if(r===``){l[e]!==void 0&&ie(e,``);return}let i=WS(n,t);ie(e,i.isValid?i.value:n),R(e,i.isValid?void 0:i.error)}function se(e,t,n){if(!r)return;let i=M.current.get(e);i&&i.abort();let a=new AbortController;M.current.set(e,a),w(t=>new Set(t).add(e)),KS(n,t,a.signal).then(t=>{if(M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){ie(e,t.value),R(e);let r=String(t.value);y(e=>e===n?(S(r.length),r):e)}else R(e,t.error)},()=>{M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n})})}function ce(e){if(y(e),F&&(ae(F.name,F.schema,e),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),GS(F.schema)&&e.trim()!==``&&f[F.name])){let t=F.name,n=F.schema;j.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,j,se,t,n,e)}}function le(){L(`down`)}function ue(e,t,n){let r=te.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(XS,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}A(`confirm:no`,()=>{if(ne&&F){let e=l[F.name];y(e===void 0?``:String(e)),S(0)}t(`cancel`)},{context:`Settings`,isActive:!!F&&!s&&!E}),oe((e,n)=>{if(ne&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(E&&F&&IS(F.schema)){let t=F.schema,r=LS(t),i=l[F.name]??[];if(n.leftArrow||n.escape){D(void 0),I(F.name,t);return}if(n.upArrow){k===0?(D(void 0),I(F.name,t)):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;ie(F.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||F.isRequired)?R(F.name,`Select at least ${a} ${Rp(a,`item`)}`):o!==void 0&&n.length>o?R(F.name,`Select at most ${o} ${Rp(o,`item`)}`):R(F.name)}return}if(n.return){let e=r[k];e!==void 0&&!i.includes(e)&&ie(F.name,[...i,e]),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>zS(t,e).toLowerCase()),ee);return}return}if(E&&F&&FS(F.schema)){let t=F.schema,r=BS(t);if(n.leftArrow||n.escape){D(void 0);return}if(n.upArrow){k===0?D(void 0):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0);return}if(n.return){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>HS(t,e).toLowerCase()),ee);return}return}if(n.return&&s===`accept`){if(fe()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&R(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(_(t),c(null),re(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=te.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),L(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!F)return;let{schema:r,name:i}=F,o=l[i];if(r.type===`boolean`){if(e===` `){ie(i,o===void 0||!o);return}if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}if(e&&!n.return){ue(e,[`yes`,`no`],e=>ie(i,e===0));return}return}if(FS(r)||IS(r)){if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}let t,a=0;if(FS(r)){let e=BS(r);t=e.map(e=>HS(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=LS(r).map(e=>zS(r,e).toLowerCase());if(n.rightArrow){D(i),ee(a);return}if(e&&!n.leftArrow){ue(e,t,e=>{D(i),ee(e)});return}return}if(n.backspace&&ne&&v===``){z(i);return}},{isActive:!0});function fe(){let e=a.required||[];for(let t of e){let e=l[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let pe=Math.max(2,Math.floor((P-14)/3)),B=(0,Q.useMemo)(()=>{let e=m.length;if(e<=pe)return{start:0,end:e};let t=g??e-1,n=Math.max(0,t-Math.floor(pe/2)),r=Math.min(n+pe,e);return n=Math.max(0,r-pe),{start:n,end:r}},[m.length,pe,g]),V=B.start>0,H=B.end<m.length;function me(){return m.length?(0,$.jsxs)(b,{flexDirection:`column`,children:[V&&(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowUp,` `,B.start,` more above`]})}),m.slice(B.start,B.end).map((e,t)=>{let n=B.start+t,{name:r,schema:i,isRequired:a}=e,o=n===g&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=C.has(r)?(0,$.jsx)(ZS,{}):p?(0,$.jsx)(T,{color:`error`,children:d.warning}):u?(0,$.jsx)(T,{color:`success`,dimColor:!o,children:d.tick}):a?(0,$.jsx)(T,{color:`error`,children:`*`}):(0,$.jsx)(T,{children:` `}),h=p?`error`:u?`success`:a?`error`:`suggestion`,_=o?h:void 0,y=(0,$.jsx)(T,{color:_,bold:o,children:i.title||r}),w,D=null;if(IS(i)){let e=LS(i),t=c??[];if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(b,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=zS(i,e),a=t.includes(e),o=n===k;return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:o?d.pointer:` `}),(0,$.jsx)(T,{color:a?`success`:void 0,children:a?d.checkboxOn:d.checkboxOff}),(0,$.jsx)(T,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:t.map(e=>zS(i,e)).join(`, `)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(FS(i)){let e=BS(i);if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(b,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=HS(i,e),r=c===e,a=t===k;return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:a?d.pointer:` `}),(0,$.jsx)(T,{color:r?`success`:void 0,children:r?d.radioOn:d.radioOff}),(0,$.jsx)(T,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:HS(i,c)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(T,{color:_,bold:!0,children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,children:d.checkboxOff}):u?(0,$.jsx)(T,{children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});else if(qS(i))if(o)w=(0,$.jsx)(Qa,{value:v,onChange:ce,onSubmit:le,placeholder:`Type something…`,columns:Math.min(N-20,60),cursorOffset:x,onChangeCursorOffset:S,focus:!0,showCursor:!0});else{let e=u&&GS(i)?QS(String(c),i):String(c);w=u?(0,$.jsx)(T,{children:e}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(T,{children:String(c)}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:h,children:o?d.pointer:` `}),m,(0,$.jsxs)(b,{children:[y,(0,$.jsx)(T,{color:_,children:`: `}),w]})]}),D,i.description&&(0,$.jsx)(b,{marginLeft:6,children:(0,$.jsx)(T,{dimColor:!0,children:i.description})}),(0,$.jsx)(b,{marginLeft:6,height:1,children:p?(0,$.jsx)(T,{color:`error`,italic:!0,children:p}):(0,$.jsx)(T,{children:` `})})]},r)}),H&&(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowDown,` `,m.length-B.end,` more below`]})})]}):null}return(0,$.jsx)(ge,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!F||!!s)&&!E,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(ic,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`↑↓`,action:`navigate`}),F&&(0,$.jsx)(h,{shortcut:`Backspace`,action:`unset`}),F&&F.schema.type===`boolean`&&(0,$.jsx)(h,{shortcut:`Space`,action:`toggle`}),F&&FS(F.schema)&&(E?(0,$.jsx)(h,{shortcut:`Space`,action:`select`}):(0,$.jsx)(h,{shortcut:`→`,action:`expand`})),F&&IS(F.schema)&&(E?(0,$.jsx)(h,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(h,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[me(),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:s===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:s===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function tC({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,l]=(0,Q.useState)(`prompt`),u=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Iy(`Claude Code needs your input`,`elicitation_url_dialog`),Is(`elicitation-url`),u.current=c;let g=(0,Q.useRef)(n);g.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?g.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let _=``,v=``,y=``;try{_=new URL(s).hostname;let e=s.indexOf(_);v=s.slice(0,e),y=s.slice(e+_.length)}catch{_=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let x=(0,Q.useCallback)(()=>{Ih(s),t(`accept`),l(`waiting`),u.current=`waiting`,p(`open`)},[t,s]);if(oe((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?x():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?Ih(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ge,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(ic,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:f===`open`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(T,{color:`success`,children:f===`action`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:`error`,children:f===`cancel`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ge,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(ic,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:f===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:f===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}B(),jh(),fs(),Jg();function nC({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){A(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Xg,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(T,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(b,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(Fc,{options:a,onChange:e=>{r(e)}})})})}Ga();function rC(){return(0,Q.useSyncExternalStore)(Rc,Ia)}rp(),Oe(),Yu(),ke();var iC=`at_mentioned`,aC=Ee(()=>be({method:ye(iC),params:be({filePath:Se(),lineStart:xe().optional(),lineEnd:xe().optional()})}));function oC(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Kl(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(aC(),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){X(e)}})},[e,t])}zc(),C_(),T_(),J_();function sC(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])}Co(),Kg(),B();function cC({ideSelection:e,mcpClients:t}){let{status:n}=sC(t),r=n===`connected`&&(e?.filePath||e?.text&&e.lineCount>0);if(n===null||!r||!e)return null;if(e.text&&e.lineCount>0)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,yv(e.filePath)]},`selection-indicator`)}var lC=1.5*1024*1024*1024,uC=2.5*1024*1024*1024;function dC(){let[e,t]=(0,Q.useState)(null);return re(()=>{let e=process.memoryUsage().heapUsed,n=e>=uC?`critical`:e>=lC?`high`:`normal`;t(t=>n===`normal`?t===null?t:null:{heapUsed:e,status:n})},1e4),e}B(),Dp();function fC(){if(process.env.USER_TYPE!==`ant`)return null;let e=dC();if(!e)return null;let{heapUsed:t,status:n}=e;if(n===`normal`)return null;let r=Op(t);return(0,$.jsx)(b,{children:(0,$.jsxs)(T,{color:n===`critical`?`error`:`warning`,wrap:`truncate`,children:[`High memory usage (`,r,`) · /heapdump`]})})}function pC(){return(0,Q.useSyncExternalStore)(Jt.subscribe,Jt.getState)}B(),Ml();function mC({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Tt(e,t),a=pC();if(!r||a)return null;let o=Tu(),s=cs(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(b,{flexDirection:`row`,children:o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(T,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}B(),Vl();function hC(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=wc(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Mu.isSandboxingEnabled())return;let e=Mu.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)}},[]),!Mu.isSandboxingEnabled()||e===0?null:(0,$.jsx)(b,{paddingX:0,paddingY:0,children:(0,$.jsxs)(T,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Lc(),xp(),J(),B(),Hs(),zg(),Dp(),Yu(),_i(),Yl();var gC=5e3;function _C({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)(()=>Sd(pn(a)),[a]),p=Gg(),m=Tt(f,p).isAboveWarningThreshold,{status:h}=sC(l),g=G(e=>e.notifications),{addNotification:_,removeNotification:v}=di(),y=Wo();(0,Q.useEffect)(()=>(Fo((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Fo(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let x=y.isUsingOverage,S=Yp(),C=S===`team`||S===`enterprise`,w=Bg(),E=u&&!m&&e!==`invalid`&&e!==`missing`&&w!==void 0;return(0,Q.useEffect)(()=>{E&&w?(Z(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(ic,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${zn(w)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[E,w,_,v]),(0,$.jsx)(b,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(vC,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:x??!1,isTeamOrEnterprise:C,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function vC({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:o,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!Up())return;let e=setInterval(e=>{let t=Jp(),n=t>=1e4?Ap(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]);let p=G(e=>e.isBriefOnly);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cC,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(T,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(T,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),!p&&(0,$.jsx)(mC,{tokenUsage:l,model:u}),(0,$.jsx)(fC,{}),(0,$.jsx)(hC,{})]})}Lc(),Yl(),B();var yC=10,bC=null,xC=0,SC;async function CC(e,t){let n=Math.ceil(e/yC)*yC;if(bC&&xC>=n&&SC===t)return bC;bC&&await bC,xC=n,SC=t,bC=(async()=>{let e=[],n=0;for await(let r of jt())if(!(t&&hu(r.display)!==t)&&(e.push(r),n++,n>=xC))break;return e})();try{return await bC}finally{bC=null,xC=0,SC=void 0}}function wC(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}=di(),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=hu(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(ic,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:gC})},[u]);return{historyIndex:a,setHistoryIndex:o,onHistoryUp:(0,Q.useCallback)(()=>{let e=m.current;m.current++;let t=g.current,n=_.current,r=v.current;if(e===0){h.current=r===`bash`?r:void 0;let e=t.trim()!==``;c(e?{display:t,pastedContents:n,mode:r}:void 0)}let i=h.current;(async()=>{let t=e+1;if(p.current!==i&&(f.current=[],p.current=i,m.current=0),f.current.length<t){let e=await CC(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])}}J();function TC(){let e=G(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(ud).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])}ol(),Su(),B(),jh();function EC(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)(``),[_,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(`prompt`),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(void 0),E=(0,Q.useRef)(void 0),D=(0,Q.useRef)(new Set),O=(0,Q.useRef)(null),k=(0,Q.useCallback)(()=>{E.current&&(E.current.return(void 0),E.current=void 0)},[]),j=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),y(0),x(`prompt`),C({}),T(void 0),k(),D.current.clear()},[c,k]),M=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){k(),D.current.clear(),T(void 0),m(!1),n(h),r(_),a(b),l(S);return}if(e||(k(),E.current=wl(),D.current.clear()),E.current)for(;;){if(t?.aborted)return;let e=await E.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!D.current.has(i)){D.current.add(i),T(e.value),m(!1),a(hu(i)),n(i),l(e.value.pastedContents);let t=ys(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,k,n,r,a,l,h,_,b,S]),te=(0,Q.useCallback)(()=>{c(!0),g(t),y(i),x(o),C(u),E.current=wl(),D.current.clear()},[c,t,i,o,u]),N=(0,Q.useCallback)(()=>{M(!0)},[M]),P=(0,Q.useCallback)(()=>{if(w){let e=hu(w.display);n(ys(w.display)),a(e),l(w.pastedContents)}else l(S);j()},[w,n,a,l,S,j]),F=(0,Q.useCallback)(()=>{n(h),r(_),l(S),j()},[n,r,l,h,_,S,j]),ne=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:S});else if(w){let t=hu(w.display),n=ys(w.display);a(t),e({display:n,pastedContents:w.pastedContents})}j()},[d,w,e,a,h,S,j]);A(`history:search`,te,{context:`Global`,isActive:!s}),v((0,Q.useMemo)(()=>({"historySearch:next":N,"historySearch:accept":P,"historySearch:cancel":F,"historySearch:execute":ne}),[N,P,F,ne]),{context:`HistorySearch`,isActive:s});let re=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),F())};oe((e,t,n)=>{re(new ee(n.keypress))},{isActive:s});let I=(0,Q.useRef)(M);return I.current=M,(0,Q.useEffect)(()=>{O.current?.abort();let e=new AbortController;return O.current=e,I.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:w,historyFailedMatch:p,handleKeyDown:re}}function DC({maxBufferSize:e,debounceMs:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(-1),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null),c=(0,Q.useCallback)((l,u,d={})=>{let f=Date.now();if(s.current&&(clearTimeout(s.current),s.current=null),f-o.current<t){s.current=setTimeout(c,t,l,u,d);return}o.current=f,r(t=>{let n=i>=0?t.slice(0,i+1):t,r=n[n.length-1];if(r&&r.text===l)return n;let a=[...n,{text:l,cursorOffset:u,pastedContents:d,timestamp:f}];return a.length>e?a.slice(-e):a}),a(t=>{let r=t>=0?t+1:n.length;return Math.min(r,e-1)})},[t,e,i,n.length]),l=(0,Q.useCallback)(()=>{if(i<0||n.length===0)return;let e=Math.max(0,i-1),t=n[e];if(t)return a(e),t},[n,i]),u=(0,Q.useCallback)(()=>{r([]),a(-1),o.current=0,s.current&&(clearTimeout(s.current),s.current=null)},[o,s]);return{pushToBuffer:c,undo:l,canUndo:i>0&&n.length>1,clearBuffer:u}}B(),xp(),J();function OC({inputValue:e,isAssistantResponding:t}){let n=G(e=>e.promptSuggestion),r=Yr(),i=j(),{text:a,promptId:o,shownAt:s,acceptedAt:c,generationRequestId:l}=n,u=t||e.length>0?null:a,d=a&&s>0,f=(0,Q.useRef)(0),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(0);s>0&&s!==m.current?(m.current=s,p.current=i,f.current=0):s===0&&(m.current=0),e.length>0&&f.current===0&&d&&(f.current=Date.now());let h=(0,Q.useCallback)(()=>{q(r),r(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[r]);return{suggestion:u,markAccepted:(0,Q.useCallback)(()=>{d&&r(e=>({...e,promptSuggestion:{...e.promptSuggestion,acceptedAt:Date.now()}}))},[d,r]),markShown:(0,Q.useCallback)(()=>{r(e=>e.promptSuggestion.shownAt!==0||!e.promptSuggestion.text?e:{...e,promptSuggestion:{...e.promptSuggestion,shownAt:Date.now()}})},[r]),logOutcomeAtSubmission:(0,Q.useCallback)((e,t)=>{if(!d)return;let n=c>s,r=n||e===a,i=r&&c||Date.now();Z(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100,...process.env.USER_TYPE===`ant`&&{suggestion:a,userInput:e}}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}Nl(),nf(),Yh();var kC=15,AC=1e3,jC=[`|`,`||`,`&&`,`;`];function MC(e){return typeof e==`object`&&!!e&&`op`in e&&jC.includes(e.op)}function NC(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function PC(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function FC(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&MC(n)}function IC(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=Jm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:NC(t)}}let a=PC(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&MC(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=NC(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=FC(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function LC(e,t){return t===`variable`?`compgen -v ${Ym([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${Ym([e])} 2>/dev/null | head -${kC} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${Ym([e])} 2>/dev/null`}function RC(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${Ym([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${Ym([e])}*(N[1,${kC}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${Ym([e])}*]} 2>/dev/null`}async function zC(e,t,n,r){let i;if(e===`bash`)i=LC(t,n);else if(e===`zsh`)i=RC(t,n);else return[];return(await(await Or(i,r,`bash`,{timeout:AC})).result).stdout.split(`
42
+ `).filter(e=>e.trim()).slice(0,kC).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function BC(e,t,n){let r=Xh();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=IC(e,t);return i?(await zC(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return Y(`Shell completion failed: ${e}`),[]}}H_(),_a();var VC=/[:_-]/g,HC=null;function UC(e){if(HC?.commands===e)return HC.fuse;let t=new X_(e.filter(e=>!e.isHidden).map(e=>{let t=bs(e),n=t.split(VC).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>tw(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 HC={commands:e,fuse:t},t}function WC(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function GC(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 KC(e,t){if(!e)return null;let n=$C(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!WC(t.metadata))continue;let n=bs(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function qC(e){return e.startsWith(`/`)}function JC(e){return!(!qC(e)||!e.includes(` `)||e.endsWith(` `))}function YC(e){return`/${e} `}function XC(e){let t=bs(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function ZC(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function QC(e,t){let n=bs(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:mo(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:XC(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function $C(e,t){if(!qC(e)||JC(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:Ys(bs(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=>XC(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(XC(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)=>bs(e).localeCompare(bs(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=>QC(e))}let r=t.find(e=>e.isHidden&&bs(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&bs(e).toLowerCase()===n)&&(r=void 0);let i=UC(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`?Ys(bs(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 QC(t,ZC(n,t.aliases))});if(r){let e=XC(r);if(!i.some(t=>t.id===e))return[QC(r),...i]}return i}function ew(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Gr(o,n):void 0;else{if(!WC(e.metadata))return;o=bs(e.metadata),s=e.metadata}let c=YC(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function tw(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function nw(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}Ng(),Su(),nf();var rw=null,iw=0,aw=6e4;async function ow(){let e=Date.now();if(rw&&e-iw<aw)return rw;let t=[],n=new Set;try{for await(let e of jt()){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){Y(`Failed to read shell history: ${e}`)}return rw=t,iw=e,t}function sw(e){if(!rw)return;let t=rw.indexOf(e);t!==-1&&rw.splice(t,1),rw.unshift(e)}async function cw(e){if(!e||e.length<2||!e.trim())return null;let t=await ow();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}es(),nf(),ke(),We(),Qd();var lw=`slack_search_channels`,uw=new Map,dw=new Set,fw=0,pw=_t(),mw=pw.subscribe,hw=null,gw=null;function _w(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function vw(e,t){let n=_w(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:lw,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?xw(bw(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
43
+ `))):[]}catch(e){return Y(`Failed to fetch Slack channels: ${e}`),[]}}var yw=Ee(()=>be({results:Se()}));function bw(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=yw().safeParse(qd(t));if(e.success)return e.data.results}catch{}return e}function xw(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 Sw(e){return _w(e)!==void 0}function Cw(){return fw}function ww(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!dw.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function Tw(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function Ew(e,t){let n,r=0;for(let[i,a]of uw)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function Dw(e,t){if(!t)return[];let n=Tw(t),r=t.toLowerCase(),i=uw.get(n)??Ew(n,r);if(!i)if(hw===n&&gw)i=await gw;else{hw=n,gw=vw(e,n),i=await gw,uw.set(n,i);let t=dw.size;for(let e of i)dw.add(e);dw.size!==t&&(fw++,pw.emit()),uw.size>50&&uw.delete(uw.keys().next().value),hw===n&&(hw=null,gw=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}H_(),n_(),Ur(),Dp(),rp();function Ow(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 kw=15,Aw=60;function jw(e){return Ep(e,Aw)}function Mw(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:jw(e.whenToUse),agentType:e.agentType,color:cr(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 X(e),[]}}async function Nw(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([$g(e,r),Promise.resolve(Mw(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:yv(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:jw(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,kw).map(Ow);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 X_(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:kw});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,kw).map(e=>e.source).map(Ow)}Lc(),B(),xp(),me(),_a(),ol(),Os(),pc(),jh(),Cl(),J(),Dp(),Uc(),n_();var Pw=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,Fw=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,Iw=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,Lw=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,Rw=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,zw=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function Bw(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function Vw(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 Hw(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function Uw(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Ww(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 Gw(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 Kw=/(^|\s)@[\w-]*$/;function qw(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 Jw=null;async function Yw(e,t){try{return Jw&&Jw.abort(),Jw=new AbortController,await BC(e,t,Jw.signal)}catch{return Z(`tengu_shell_completion_failed`,{}),[]}}function Xw(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 Zw(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(Pw);if(a&&a[0].length===i.length){let r=e.substring(t).match(Fw),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?Iw:Lw,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(Fw),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Qw(e){if(qC(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 $w(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function eT({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}=di(),g=wc(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,y]=(0,Q.useState)(`none`),b=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=bs(e);return t?t.length:0}))+6},[e]),[x,S]=(0,Q.useState)(void 0),C=G(e=>e.mcp.resources),w=br(),E=G(e=>e.promptSuggestion),D=G(e=>!!e.viewingAgentTaskId),O=N(),[k,A]=(0,Q.useState)(void 0),j=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=GC(i,a);if(!t)return;let n=KC(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),te=f?void 0:o===`prompt`?j:k,P=(0,Q.useRef)(a);P.current=a;let F=(0,Q.useRef)(null),ne=(0,Q.useRef)(``),re=(0,Q.useRef)(``),I=(0,Q.useRef)(``),L=(0,Q.useRef)(``),ie=(0,Q.useRef)(l);ie.current=l;let R=(0,Q.useRef)(null),z=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0),A(void 0)},[c]),ae=(0,Q.useCallback)(async(e,t=!1)=>{F.current=e;let n=await Nw(e,C,s,t);if(F.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,n)})),y(n.length>0?`file`:`none`),S(void 0)}},[C,c,y,S,s]);(0,Q.useEffect)(()=>(e_(),i_(()=>{let e=F.current;e!==null&&(F.current=null,ae(e,e===``))})),[ae]);let se=U(ae,50),ce=U((0,Q.useCallback)(async e=>{L.current=e;let t=await Dw(w.getState().mcp.clients,e);L.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,t)})),y(t.length>0?`slack-channel`:`none`),S(void 0))},[c]),150),le=(0,Q.useCallback)(async(t,n)=>{let r=n??P.current;if(f){se.cancel(),z();return}if(o===`prompt`){let n=GC(t,r);if(n&&KC(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}}if(o===`bash`&&t.trim()){I.current=t;let e=await cw(t);if(I.current!==t)return;if(e){A({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}else A(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=w.getState(),n=[],r=new Set;for(let[i,a]of t.agentNameRegistry){if(r.has(i)||!i.toLowerCase().startsWith(e))continue;let o=t.tasks[a]?.status;n.push({id:`dm-${i}`,displayText:`@${i}`,description:o?`send message · ${o}`:`send message`})}if(n.length>0){se.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,n)})),y(`agent`),S(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(zw);if(e&&Sw(w.getState().mcp.clients)){ce(e[2]);return}else _===`slack-channel`&&(ce.cancel(),z())}let a=t.substring(0,r).match(Rw),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&qC(t)&&r>0){let e=Qw(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){se.cancel(),z();return}let n=await Pg(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`directory`);return}se.cancel(),z();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await sd(t,{limit:10})).map(e=>{let t=hn(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:kp(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`custom-title`);return}z();return}}let l=t.substring(0,r);if(o===`prompt`&&qC(l)&&r>0&&!$w(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=bs(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=vu(l.slice(n+1));t=ls(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}}}let n=$C(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),y(n.length>0?`command`:`none`),n.length>0&&S(b);return}if(_===`command`?(se.cancel(),z()):qC(l)&&$w(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&z(),_===`agent`&&ie.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||z()),a&&o!==`bash`){let e=Zw(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=Uw(e);if(jg(t)){re.current=t;let e=await Mg(t,{maxResults:10});if(re.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:Vw(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),y(`directory`);return}}if(F.current===t)return;se(t,!0);return}}if(_===`file`){let e=Zw(t,r,!0);if(e){let t=Uw(e);if(F.current===t)return;se(t,!1)}else se.cancel(),z()}if(_===`shell`){let e=ie.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(se.cancel(),z())}},[_,e,c,z,se,ce,o,f,b]);(0,Q.useEffect)(()=>{R.current!==i&&(ne.current!==i&&(ne.current=i,F.current=null),R.current=null,le(i))},[i,le]);let ue=(0,Q.useCallback)(async()=>{if(te){if(o===`bash`){t(te.fullCommand),r(te.fullCommand.length),A(void 0);return}let e=GC(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=n+`/`+te.fullCommand+` `+a,s=e.startPos+1+te.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){se.cancel(),ce.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${bs(e)} `;t(n+i.slice(a)),r(n.length)}z()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Hw(n);t(e),r(e.length),z()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=qC(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=Bw(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),Bw(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),le(o,o.length)):z()}else{let e=Zw(i,a,!0)??Zw(i,a,!1);if(e){let a=Bw(n.metadata)&&n.metadata.type===`directory`,s=Xw(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),le(o,s.cursorPos)):z()}else z()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Gw(n,i,a,t,r,e?.completionType),z()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(qw(n,i,a,Kw,t,r),z())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(qw(n,i,a,zw,t,r),z())}else if(_===`file`&&l.length>0){let n=Zw(i,a,!0);if(!n){z();return}let s=t_(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=Ww({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});r_(e,i,n.token,n.startPos,t,r),le(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);r_(Ww({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),z()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Yw(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Gw(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=Zw(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await Nw(e?t.token.substring(1):t.token,C,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Vw(e.suggestions,e.selectedSuggestion,n)})),y(e),S(void 0))}},[l,u,i,_,e,o,t,r,n,z,a,le,C,c,s,se,ce,te]),de=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(ew(s,!0,e,t,r,n),se.cancel(),z());else if(_===`custom-title`&&u<l.length){if(s){let e=Hw(s);t(e),r(e.length),n(e,!0),se.cancel(),z()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Gw(e,i,a,t,r,n?.completionType),se.cancel(),z()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))qw(s,i,a,Kw,t,r),se.cancel(),z();else if(_===`slack-channel`&&u<l.length)s&&(qw(s,i,a,zw,t,r),ce.cancel(),z());else if(_===`file`&&u<l.length){let e=Zw(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);r_(Ww({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),se.cancel(),z()}}else if(_===`directory`&&u<l.length&&s){if(qC(i)){se.cancel(),z();return}let e=Zw(i,a,!0)??Zw(i,a,!1);if(e){let n=Bw(s.metadata)&&s.metadata.type===`directory`,a=Xw(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}se.cancel(),z()}},[l,u,_,e,i,a,o,t,r,n,z,se,ce]),fe=(0,Q.useCallback)(()=>{ue()},[ue]),pe=(0,Q.useCallback)(()=>{se.cancel(),ce.cancel(),z(),R.current=i},[se,ce,z,i]),B=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),V=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),H=(0,Q.useMemo)(()=>({"autocomplete:accept":fe,"autocomplete:dismiss":pe,"autocomplete:previous":B,"autocomplete:next":V}),[fe,pe,B,V]),me=l.length>0||!!te,he=ml();Is(`autocomplete`,me),M(`Autocomplete`,me),v(H,{context:`Autocomplete`,isActive:me&&!he});function ge(e){let n=hu(e);if(n!==`prompt`&&m){m(n);let i=ys(e);t(i),r(i.length)}else t(e),r(e.length)}let _e=e=>{if(e.key===`right`&&!D){let t=E.text,n=E.shownAt;if(t&&n>0&&i===``){p(),ge(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||te)return;let t=E.text,n=E.shownAt;if(t&&n>0&&i===``&&!D){e.preventDefault(),p(),ge(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=O?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),V();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),B();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),de())};return oe((e,t,n)=>{let r=new ee(n.keypress);_e(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:x,commandArgumentHint:d,inlineGhostText:te,handleKeyDown:_e}}f_();var tT={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function nT(e){return e in tT}rn();function rT(e){switch(e.mode){case`default`:return`acceptEdits`;case`acceptEdits`:return`plan`;case`plan`:return`auto`;case`auto`:return e.isBypassPermissionsModeAvailable?`bypassPermissions`:`default`;case`bypassPermissions`:return`default`;case`dontAsk`:return`default`;default:return`default`}}function iT(e){let t=rT(e);return{nextMode:t,context:Yi(e.mode,t,e)}}xg();var aT=Uh();at(),Js(),Os(),B(),jh(),J(),zf();function oT({onDone:e}){Is(`bridge-dialog`);let t=G(e=>e.replBridgeConnected),n=G(e=>e.replBridgeSessionActive),r=G(e=>e.replBridgeReconnecting),i=G(e=>e.replBridgeConnectUrl),a=G(e=>e.replBridgeSessionUrl),o=G(e=>e.replBridgeError),s=G(e=>e.replBridgeExplicit),c=G(e=>e.replBridgeEnvironmentId),l=G(e=>e.replBridgeSessionId),u=G(e=>e.verbose),d=Yr(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),y=yv(ut());(0,Q.useEffect)(()=>{Kf().then(_).catch(()=>{})},[]);let x=n?a:i;(0,Q.useEffect)(()=>{if(!f||!x){h(``);return}(0,aT.toString)(x,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,x]),v({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),oe(t=>{t===`d`&&(s&&Lf(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:S,color:C}=wt({error:o,connected:t,sessionActive:n,reconnecting:r}),w=o?`×`:gf,E=m?m.split(`
45
+ `).filter(e=>e.length>0):[],D=[];y&&D.push(y),g&&D.push(g);let O=D.length>0?` · `+D.join(` · `):``,k=o?Ql:x?n?Ao(x):ma(x):void 0;return(0,$.jsx)(ge,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:C,children:[w,` `,S]}),(0,$.jsx)(T,{dimColor:!0,children:O})]}),o&&(0,$.jsx)(T,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(T,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(T,{dimColor:!0,children:[`Session: `,l]})]}),f&&E.length>0&&(0,$.jsx)(b,{flexDirection:`column`,children:E.map((e,t)=>(0,$.jsx)(T,{children:e},t))}),k&&(0,$.jsx)(T,{dimColor:!0,children:k}),(0,$.jsx)(T,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}B(),Os(),yo(),B(),Gd(),zg(),Dp(),ri(),Os(),Su(),yo(),B(),Dp(),l_(),Os(),n_(),yo(),B(),Gd(),zg(),Dp(),Uo(),B(),jh(),Yl(),mu();function sT({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=yg(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Claude will think before responding`},{value:`false`,label:`Disabled`,description:`Claude will respond without extended thinking`}];A(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),A(`confirm:yes`,()=>{a!==null&&t(a)},{context:`Confirmation`,isActive:a!==null});function c(n){let i=n===`true`;r&&i!==e?o(i):t(i)}return(0,$.jsxs)(he,{color:`permission`,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(T,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(b,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(Fc,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(T,{color:`warning`,children:`Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results, set this at the start of a session.`}),(0,$.jsx)(T,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(T,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ic,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ic,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}tv(),$_();function cT(e,t,n){let r=t;for(let t=0;t<n;t++){let t=lT(e,r);if(t.equals(r))break;r=t}return r}function lT(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 uT(e){return`eE$`.includes(e)}function dT(e){return`jkG`.includes(e)||e===`gg`}var fT={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function pT(e,t,n,r){if(n===`w`)return mT(e,t,r,vr);if(n===`W`)return mT(e,t,r,e=>!uo(e));let i=fT[n];if(i){let[n,a]=i;return n===a?hT(e,t,n,r):gT(e,t,n,a,r)}return null}function mT(e,t,n,r){let i=[];for(let{segment:t,index:n}of Cp().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=>uo(o(e)),l=e=>r(o(e)),u=e=>nn(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 hT(e,t,n,r){let i=e.lastIndexOf(`
46
+ `,t-1)+1,a=e.indexOf(`
47
+ `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function gT(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}}Wd(),wp(),zp();function _T(e,t,n,r){let i=cT(t,r.cursor,n);if(i.equals(r.cursor))return;let a=kT(r.cursor,i,t,e,n);jT(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function vT(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new oi(i.cursor.measuredText,a),s=AT(i.cursor,o,t);jT(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function yT(e,t,n,r,i){let a=pT(i.text,i.cursor.offset,n,t===`inner`);a&&(jT(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function bT(e,t,n){let r=n.text,i=r.split(`
48
+ `),a=Bp(r.slice(0,n.cursor.offset),`
49
+ `),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
50
+ `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
51
+ `)||(l+=`
52
+ `),n.setRegister(l,!0),e===`yank`)n.setOffset(s);else if(e===`delete`){let e=s,t=c;t===r.length&&e>0&&r[e-1]===`
53
+ `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(Sp(i).length||1));n.setOffset(Math.min(e,a))}else if(e===`change`)if(i.length===1)n.setText(``),n.enterInsert(0);else{let e=i.slice(0,a),t=i.slice(a+o),r=[...e,``,...t].join(`
54
+ `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function xT(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.cursor;for(let t=0;t<e&&!r.isAtEnd();t++)r=r.right();let i=r.offset,a=t.text.slice(n,i),o=t.text.slice(0,n)+t.text.slice(i);t.setRegister(a,!1),t.setText(o);let s=Math.max(0,o.length-(Sp(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function ST(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Tp(i.slice(r)).length||1;i=i.slice(0,r)+e+i.slice(r+t),r+=e.length}n.setText(i),n.setOffset(Math.max(0,r-e.length)),n.recordChange({type:`replace`,char:e,count:t})}function CT(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.text,i=n,a=0;for(;i<r.length&&a<e;){let e=Tp(r.slice(i)),t=e.length,n=e===e.toUpperCase()?e.toLowerCase():e.toUpperCase();r=r.slice(0,i)+n+r.slice(i+t),i+=n.length,a++}t.setText(r),t.setOffset(i),t.recordChange({type:`toggleCase`,count:e})}function wT(e,t){let n=t.text.split(`
55
+ `),{line:r}=t.cursor.getPosition();if(r>=n.length-1)return;let i=Math.min(e,n.length-r-1),a=n[r],o=a.length;for(let e=1;e<=i;e++){let t=(n[r+e]??``).trimStart();t.length>0&&(!a.endsWith(` `)&&a.length>0&&(a+=` `),a+=t)}let s=[...n.slice(0,r),a,...n.slice(r+i+1)],c=s.join(`
56
+ `);t.setText(c),t.setOffset(OT(s,r)+o),t.recordChange({type:`join`,count:e})}function TT(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
57
+ `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
58
+ `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
59
+ `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
60
+ `);n.setText(u),n.setOffset(OT(l,o))}else{let r=a.repeat(t),i=e&&n.cursor.offset<n.text.length?n.cursor.measuredText.nextOffset(n.cursor.offset):n.cursor.offset,o=n.text.slice(0,i)+r+n.text.slice(i),s=Sp(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function ET(e,t,n){let r=n.text.split(`
61
+ `),{line:i}=n.cursor.getPosition(),a=Math.min(t,r.length-i);for(let t=0;t<a;t++){let n=i+t,a=r[n]??``;if(e===`>`)r[n]=` `+a;else if(a.startsWith(` `))r[n]=a.slice(2);else if(a.startsWith(` `))r[n]=a.slice(1);else{let e=0,t=0;for(;t<a.length&&e<2&&/\s/.test(a[t]);)e++,t++;r[n]=a.slice(t)}}let o=r.join(`
62
+ `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(OT(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function DT(e,t){let n=t.text.split(`
63
+ `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
64
+ `);t.setText(o),t.enterInsert(OT(a,i)),t.recordChange({type:`openLine`,direction:e})}function OT(e,t){return e.slice(0,t).join(`
65
+ `).length+ +(t>0)}function kT(e,t,n,r,i){let a=Math.min(e.offset,t.offset),o=Math.max(e.offset,t.offset),s=!1;if(r===`change`&&(n===`w`||n===`W`)){let t=e;for(let e=0;e<i-1;e++)t=n===`w`?t.nextVimWord():t.nextWORD();let r=n===`w`?t.endOfVimWord():t.endOfWORD();o=e.measuredText.nextOffset(r.offset)}else if(dT(n)){s=!0;let t=e.text,n=t.indexOf(`
66
+ `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
67
+ `&&--a):o=n+1}else uT(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 AT(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 jT(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
68
+ `)&&(a+=`
69
+ `),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(Sp(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 MT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=kT(n.cursor,r,`G`,e,t);jT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function NT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=kT(n.cursor,r,`gg`,e,t);jT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var PT={d:`delete`,c:`change`,y:`yank`};function FT(e){return e in PT}var IT=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),LT=new Set([`f`,`F`,`t`,`T`]),RT={i:`inner`,a:`around`};function zT(e){return e in RT}var BT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),VT=1e4;function HT(){return{mode:`INSERT`,insertedText:``}}function UT(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function WT(e,t,n){switch(e.type){case`idle`:return qT(t,n);case`count`:return JT(e,t,n);case`operator`:return YT(e,t,n);case`operatorCount`:return XT(e,t,n);case`operatorFind`:return ZT(e,t,n);case`operatorTextObj`:return QT(e,t,n);case`find`:return $T(e,t,n);case`g`:return eE(e,t,n);case`operatorG`:return tE(e,t,n);case`replace`:return nE(e,t,n);case`indent`:return rE(e,t,n)}}function GT(e,t,n){return FT(e)?{next:{type:`operator`,op:PT[e],count:t}}:IT.has(e)?{execute:()=>{let r=cT(e,n.cursor,t);n.setOffset(r.offset)}}:LT.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:()=>CT(t,n)}:e===`x`?{execute:()=>xT(t,n)}:e===`J`?{execute:()=>wT(t,n)}:e===`p`||e===`P`?{execute:()=>TT(e===`p`,t,n)}:e===`D`?{execute:()=>_T(`delete`,`$`,1,n)}:e===`C`?{execute:()=>_T(`change`,`$`,1,n)}:e===`Y`?{execute:()=>bT(`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:()=>iE(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:()=>DT(`below`,n)}:e===`O`?{execute:()=>DT(`above`,n)}:null}function KT(e,t,n,r){return zT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:RT[n]}}:LT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:IT.has(n)?{execute:()=>_T(e,n,t,r)}:n===`G`?{execute:()=>MT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function qT(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:GT(e,1,t)||{}}function JT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),VT))}}}return GT(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function YT(e,t,n){return t===e.op[0]?{execute:()=>bT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:KT(e.op,e.count,t,n)||{next:{type:`idle`}}}function XT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),VT);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return KT(e.op,i,t,n)||{next:{type:`idle`}}}function ZT(e,t,n){return{execute:()=>vT(e.op,e.find,t,e.count,n)}}function QT(e,t,n){return BT.has(t)?{execute:()=>yT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function $T(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 eE(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=cT(`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 tE(e,t,n){return t===`j`||t===`k`?{execute:()=>_T(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>NT(e.op,e.count,n)}:{next:{type:`idle`}}}function nE(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>ST(t,e.count,n)}}function rE(e,t,n){return t===e.dir?{execute:()=>ET(e.dir,e.count,n)}:{next:{type:`idle`}}}function iE(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)}Wd(),wp();function aE(e){let t=Q.useRef(HT()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(UT()),a=Si({...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=oi.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`:xT(t.count,r);break;case`replace`:ST(t.char,t.count,r);break;case`toggleCase`:CT(t.count,r);break;case`indent`:ET(t.dir,t.count,r);break;case`join`:wT(t.count,r);break;case`openLine`:DT(t.direction,r);break;case`operator`:_T(t.op,t.motion,t.count,r);break;case`operatorFind`:vT(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:yT(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=oi.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,-(Sp(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=WT(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}L(),B();function oE(e){let[t]=y(),n=j();gl(n,!!e.onImagePaste);let r=aE({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?H.inverse:e=>e,themeText:ce(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(Mn,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}xh(),Bh(),Un(),tg(),M_(),s();function sE(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 cE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function lE(e){let t=Ov(`sha256`).update(e).digest(`hex`).slice(0,16);return Ev(o(),`cache-stats`,`${t}.json`)}var uE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function dE(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 fE(e){try{let t=await Iv(e,`utf8`),n=JSON.parse(t);return dE(n)?n:{...uE}}catch{return{...uE}}}async function pE(e,t){await Fv(Tv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Rv(n,JSON.stringify(t),`utf8`),await Lv(n,e)}catch{}}var mE={signature:null,lastResetAt:null,lastHitRate:null},hE=null;async function gE(e){hE=e;let t=await fE(lE(e));mE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function _E(e){let t=cE(e),n=sE(e);return t!==mE.signature&&(mE={signature:t,lastResetAt:Date.now(),lastHitRate:n},hE!==null&&pE(lE(hE),{version:1,signature:t,lastResetAt:mE.lastResetAt,lastHitRate:n})),{...mE}}function vE(){return{...mE}}B(),Dp(),yo();function yE(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 bE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function xE({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=de(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${jp(n)}/${jp(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(bE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Context `}),(0,$.jsxs)(T,{children:[t,`%`]}),!d&&(0,$.jsxs)(T,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Session `}),(0,$.jsxs)(T,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,yE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(T,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,yE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bE,{}),(0,$.jsx)(T,{children:So(i)})]})]})}var SE=Q.memo(xE);xp(),J(),at(),Lc(),Et(),Kg(),ks(),B(),zf(),$p(),Gd(),nf(),kd(),_i(),im(),Uc(),Gu(),Dp();var CE=3600*1e3;function wE(e){return String(Math.floor(e)).padStart(2,`0`)}function TE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${wE(t)}:${wE(n)}`}function EE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=oc(e),o=(0,Q.useRef)(null);if(a!==null){let e=cE(a);e!==o.current&&(o.current=e,_E(a))}let{lastResetAt:s,lastHitRate:c}=vE(),l=s===null?null:t-s,u=l===null?null:CE-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,gE(st()))},[]);let h=a===null?c:sE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:TE(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:` Cache `}),(0,$.jsx)(T,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(T,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function DE(){let{getGoal:t,formatGoalStatusLabel:n}=(zu(),e(Ts)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?jp(r.tokensUsed):`${jp(r.tokensUsed)}/${jp(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(T,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(T,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(T,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(T,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(T,{children:o})}return(0,$.jsxs)(T,{children:[s,(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{dimColor:!0,children:i}),(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{children:a})]})}function OE(e){return Fe()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function kE(e,t,n,r,i,a,o){let s=$e(),c=_n(),l=pm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=oc(r),f=nm(l,pt()),p=Wp(d,f),m=xl(st()),h=xr(),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{...er(),...m&&{session_name:m},model:{id:l,display_name:tm(l)},workspace:{current_dir:Kd(),project_dir:ut(),added_dirs:i},version:`0.0.7`,output_style:{name:u},cost:{total_cost_usd:lt(),total_duration_ms:Ae(),total_api_duration_ms:Ge(),total_lines_added:Be(),total_lines_removed:Ve()},context_window:{total_input_tokens:ct(),total_output_tokens:He(),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},...k_()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...je()&&{remote:{session_id:st()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function AE(e){return Va(e)?.uuid??null}function jE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=G(e=>e.toolPermissionContext.mode),a=G(e=>e.toolPermissionContext.additionalWorkingDirectories),o=G(e=>e.statusLineText),s=Yr(),c=Xs(),{addNotification:l}=di(),u=Gg(),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 _=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),v=(0,Q.useRef)(void 0),y=(0,Q.useRef)(!0),x=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=y.current;if(y.current=!1,d.current?.statusLine?.command)try{let e=_.current.exceeds200kTokens,r=AE(n);r!==_.current.messageId&&(e=hl(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await Ws(kE(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),S=(0,Q.useCallback)(()=>{v.current!==void 0&&clearTimeout(v.current),v.current=setTimeout((e,t)=>{e.current=void 0,t()},300,v,x)},[x]);(0,Q.useEffect)(()=>{(t!==_.current.messageId||i!==_.current.permissionMode||n!==_.current.vimMode||u!==_.current.mainLoopModel)&&(_.current.permissionMode=i,_.current.vimMode=n,_.current.mainLoopModel=u,S())},[t,i,n,u,S]);let C=c?.statusLine?.command,w=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(w.current){w.current=!1;return}y.current=!0,x()},[C,x]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(Z(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Vf()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),Y(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(x(),()=>{r.current?.abort(),v.current!==void 0&&clearTimeout(v.current)}),[]);let E=c?.statusLine?.padding??0,D=pm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=nm(D,pt()),k=oc(e.current),ee=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,A=k?Math.round(Wp(k,O).used??0):0,j=xr(),M={...j.five_hour&&{five_hour:{utilization:j.five_hour.utilization,resets_at:j.five_hour.resets_at}},...j.seven_day&&{seven_day:{utilization:j.seven_day.utilization,resets_at:j.seven_day.resets_at}}},te=c?.statusLineEnabled===!0,N=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[te&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(SE,{modelName:tm(D),contextUsedPct:A,usedTokens:ee,contextWindowSize:O,totalCostUsd:lt(),rateLimits:M}),(0,$.jsx)(DE,{}),(0,$.jsx)(EE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):N&&la()?(0,$.jsx)(T,{children:` `}):null]})}var ME=(0,Q.memo)(jE);u(),J(),vn(),Ui(),B();function NE({tasksSelected:e,onOpenDialog:t}){let n=G(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>Ri(e)&&!(process.env.USER_TYPE===`ant`&&Xa(e))),[n]);return Q_(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(PE,{selected:e,onClick:t,children:On(r)}),el(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function PE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(T,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(b,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}B(),Kn();function FE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Qa,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Jf(),Uf(),Qd();var IE=5e3;function LE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function RE(){if(!await Gf())return null;let[e,t]=await Promise.all([Kf(),Wf()]);if(e===t)return null;let{stdout:n,code:r}=await Yf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:IE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=qd(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:LE(e.isDraft,e.reviewDecision)}}catch{return null}}at();var zE=6e4,BE=4e3,VE=60*6e4,HE={number:null,url:null,reviewState:null,lastUpdated:0};function UE(e,t=!0){let[n,r]=(0,Q.useState)(HE),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=ze();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=VE)return;let l=Date.now(),u=await RE();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>BE){a.current=!0;return}e||(i.current=setTimeout(c,zE))}}let l=Date.now()-o.current;return l>=zE?c():i.current=setTimeout(c,zE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),M_(),Cl(),_f(),Sn(),vn(),Pf(),tv(),J(),at(),yo(),Dp(),Pi(),zf(),lp(),gi();var WE=(fh(),e(th)),GE=e=>()=>{},KE=()=>null,qE=5e3,JE=1e3;function YE(){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=Op(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,qE);return()=>clearInterval(n)},[]),e}function XE(){let e=(0,Q.useSyncExternalStore)(WE?.subscribeToProactiveChanges??GE,WE?.getNextTickAt??KE,KE),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(T,{dimColor:!0,children:[`waiting `,Ap(t*1e3,{mostSignificantOnly:!0})]})}function ZE(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),JE);return()=>clearInterval(e)},[]);let r=(zu(),e(Ts)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(T,{color:d,children:[`goal (`,u,`)`]})}function QE({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(T,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=k_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(FE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)($E,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function $E({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=wc(`chat:cycleMode`,`Chat`,`shift+tab`),u=G(e=>e.tasks),f=br(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=UE(i,tD()),g=G(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(WE?.subscribeToProactiveChanges??GE,WE?.getNextTickAt??KE,KE),v=I(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>jf(Object.values(u),e=>Ri(e)&&!(process.env.USER_TYPE===`ant`&&Xa(e))),[u]),w=Rd(),E=w!==void 0&&w.length>0,D=wc(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=wc(`app:toggleTodos`,`Global`,`ctrl+t`),ee=wc(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),A=G(e=>e.notifications.current?.key===`kill-agents-confirm`),j=YE();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let M=n?.mode,te=!yf(M),N=S>0,P=+!!te+ +!!N,F=tD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&P<2&&(P===0||c>=80),ne=P<2,re=M&&te&&!je()?(0,$.jsxs)(T,{color:mf(M),children:[pf(M),` `,bf(M).toLowerCase(),` on`,ne&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,L=[...p?[(0,$.jsx)(C,{url:p,children:(0,$.jsxs)(T,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&g?[(0,$.jsx)(TungstenPill,{selected:o},`tmux`)]:[],...F?[(0,$.jsx)(Vc,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...j?[(0,$.jsxs)(T,{dimColor:j.level===`normal`,color:j.level===`error`?`error`:j.level===`warning`?`warning`:void 0,children:[j.text,` · pid:`,process.pid]},`rss`)]:[],...(zu(),e(Ts)).getGoal()?[(0,$.jsx)(ZE,{},`goal-elapsed`)]:[]],ie=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),R=r?eD(i,D,k,ee,E,ie,A):[];x?L.push((0,$.jsx)(XE,{},`proactive`)):r&&L.push(...R);let z=N&&!Q_(u,!1)?(0,$.jsx)(NE,{tasksSelected:a,onOpenDialog:s}):null;L.length===0&&!z&&!re&&r&&L.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Rf().copyOnSelect??!0,oe=v&&(!ae||se());if(la()&&oe){let e=cp()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);L.push((0,$.jsx)(T,{dimColor:!0,children:(0,$.jsxs)(O,{children:[!ae&&(0,$.jsx)(h,{shortcut:`ctrl+c`,action:`copy`}),se()&&(t?(0,$.jsx)(T,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(h,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return z&&r&&L.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),L.length===0&&!z&&!re?la()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[re&&(0,$.jsxs)(b,{flexShrink:0,children:[re,(z||L.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,L.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),L.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:L})})]})}function eD(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function tD(){return Rf().prStatusFooterEnabled??!0}Js(),ks(),yo(),B(),Os(),J(),Pi(),Fg(),j_();function nD({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:x,mcpClients:S,isPasting:C=!1,isInputWrapped:w=!1,messages:E,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:ee,onOpenTasksDialog:A}){let j=Xs(),{columns:M,rows:te}=de(),N=(0,Q.useRef)(E);N.current=E;let P=(0,Q.useMemo)(()=>AE(E),[E]),F=M<80,ne=la(),re=ne&&te<24,I=_,L=h||OE(j)||D;return V_((0,Q.useMemo)(()=>ne&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[ne,u,d,f])),u.length&&!ne?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Ig,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(N_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:F?`column`:`row`,justifyContent:F?`flex-start`:`space-between`,paddingX:2,gap:+!F,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!F,children:[i===`prompt`&&!re&&!n.show&&!C&&OE(j)&&(0,$.jsx)(ME,{messagesRef:N,lastAssistantMessageId:P,vimMode:r}),(0,$.jsx)(aD,{}),(0,$.jsx)(QE,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:L,isLoading:g,tasksSelected:I,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:ee,onOpenTasksDialog:A})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[ne?null:(0,$.jsx)(_C,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:F}),process.env.USER_TYPE===`ant`&&Vh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(iD,{bridgeSelected:v})]})]})})}var rD=(0,Q.memo)(nD);function iD({bridgeSelected:e}){let t=G(e=>e.replBridgeEnabled),n=G(e=>e.replBridgeConnected),r=G(e=>e.replBridgeSessionActive),i=G(e=>e.replBridgeReconnecting),a=G(e=>e.replBridgeExplicit);if(!Rh()||!t)return null;let o=wt({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(T,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(T,{dimColor:!0,children:` · Enter to view`})]})}function aD(){return null}u(),B();function oD({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function sD({mode:e,isLoading:t}){return(0,$.jsx)(b,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(T,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(oD,{isLoading:t})})}B(),J(),ja(),Ga(),_i(),Qd(),cd();var cD=new Set;function lD(e){try{return qd(e)?.type===`idle_notification`}catch{return!1}}var uD=3;function dD(e){return`<${Xf}>
72
+ <${$f}>+${e} more tasks completed</${$f}>
73
+ <${Zf}>completed</${Zf}>
74
+ </${Xf}>`}function fD(e){let t=e.filter(e=>typeof e.value!=`string`||!lD(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=uD)return[...r,...n];let i=n.slice(0,uD-1),a={value:dD(n.length-(uD-1)),mode:`task-notification`};return[...r,...i,a]}function pD(){let e=rC(),t=G(e=>!!e.viewingAgentTaskId),n=G(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(xn);return t.length===0?null:tn(fD(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Sc({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(b,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(ni,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(Ba,{message:e,lookups:or,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:cD,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var mD=Q.memo(pD);Dr(),u(),B();function hD({hasStash:e}){return e?(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Su();var gD=1e4,_D=1e3;function vD(e,t){if(e.length<=gD)return{truncatedText:e,placeholderContent:``};let n=Math.floor(_D/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+yD(t,Ls(a))+i,placeholderContent:a}}function yD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function bD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=vD(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function xD({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}=bD(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}J(),zf(),Ga();var SD=(fh(),e(th)),CD=3;function wD({input:e,submitCount:t}){let n=rC(),r=G(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Fn)&&(Rf().queuedCommandUpHintCount||0)<CD)return`Press up to edit queued messages`;if(t<1&&r&&!SD?.isProactiveActive())return cv()}},[e,n,t,r])}var TD=5e3,ED=!1;function DD(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(ED||!e)return;ED=!0,n(!0);let t=setTimeout(n,TD,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}L(),Lc(),xp(),J(),Gd(),Ga(),x(),_a(),Os(),J_(),Su(),Kg(),yo(),B(),pc(),Ku(),jh(),Ca(),Pf(),Wd(),zf(),nf(),uf(),lf(),Pi(),vs(),rp(),im(),lp(),Ug(),Yl(),Kn(),tv(),ol(),M_();var OD=5,kD=3;function AD({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:y,onShowMessageSelector:x,onMessageActionsEnter:S,mcpClients:C,pastedContents:w,setPastedContents:E,vimMode:D,setVimMode:O,showBashesDialog:k,setShowBashesDialog:ee,onExit:j,getToolUseContext:M,onSubmit:te,isSearchingHistory:P,setIsSearchingHistory:F,onDismissSideQuestion:ne,isSideQuestionVisible:re,helpOpen:I,setHelpOpen:L,hasSuppressedDialogs:ie,isLocalJSXCommandActive:z=!1,insertTextRef:ae}){let se=Gg(),ce=ml()||z,[le,ue]=(0,Q.useState)(!1),[fe,B]=(0,Q.useState)({show:!1}),[V,H]=(0,Q.useState)(f.length),me=Q.useRef(f);f!==me.current&&(H(f.length),me.current=f);let he=Q.useCallback(e=>{me.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:V,insert:e=>{let t=V===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,V)+t+f.slice(V);me.current=n,p(n),H(V+t.length)},setInputWithCursor:(e,t)=>{me.current=e,p(e),H(t)}});let ge=br(),U=Yr(),_e=G(e=>e.tasks),ve=G(e=>e.replBridgeConnected),ye=G(e=>e.replBridgeExplicit),be=G(e=>e.replBridgeReconnecting),xe=ve&&(ye||be),Se=G(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Ce=process.env.USER_TYPE===`ant`&&Se,we=G(e=>!1),Te=rC(),Ee=G(e=>e.promptSuggestion),De=G(e=>e.speculation),Oe=G(e=>e.speculationSessionTimeSavedMs),ke=G(e=>e.isBriefOnly),Ae=G(e=>e.mainLoopModel),je=G(e=>e.mainLoopModelForSession),Me=G(e=>e.thinkingEnabled),Ne=G(e=>xm()?e.fastMode:!1),Pe=G(e=>e.viewingAgentTaskId);G(e=>e.viewSelectionMode);let{historyQuery:Fe,setHistoryQuery:Ie,historyMatch:Le,historyFailedMatch:Re}=EC(e=>{E(e.pastedContents),on(e.display)},f,he,H,V,h,m,P,F,E,w),ze=(0,Q.useRef)(-1);ze.current===-1&&(ze.current=jD(l));let Be=(0,Q.useRef)(!1),[Ve,He]=(0,Q.useState)(!1),Ue=G(e=>e.selectedBgAgentIndex),We=(0,Q.useCallback)(e=>U(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[U]),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(!1),[Ye,Xe]=(0,Q.useState)(!1),[Ze,Qe]=(0,Q.useState)(!1),[$e,et]=(0,Q.useState)(!1),[tt,nt]=(0,Q.useState)(!1),[rt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),st=(0,Q.useMemo)(()=>{let e=f.indexOf(`
75
+ `);return e===-1||V<=e},[f,V]),ct=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
76
+ `);return e===-1||V>e},[f,V]),lt=(0,Q.useMemo)(()=>jf(Object.values(_e),e=>e.status===`running`),[_e])>0&&!Q_(_e,!1),ut=TC(),dt=ut.length>0,ft=(0,Q.useMemo)(()=>[dt&&`bg_agent`,lt&&`tasks`,Ce&&`tmux`,we&&`bagel`,xe&&`bridge`].filter(Boolean),[dt,lt,Ce,we,xe]),pt=G(e=>e.footerSelection),mt=pt&&ft.includes(pt)?pt:null;(0,Q.useEffect)(()=>{pt&&!mt&&U(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[pt,mt,U]);let ht=mt===`tasks`,gt=mt===`tmux`,_t=mt===`bridge`,vt=mt===`bg_agent`;function yt(e){U(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&We(-1)}function bt(e,t=!1){let n=mt?ft.indexOf(mt):-1,r=ft[n+e];return r?(yt(r),!0):e<0&&t?(yt(null),!0):!1}let{suggestion:xt,markAccepted:St,logOutcomeAtSubmission:Ct,markShown:wt}=OC({inputValue:f,isAssistantResponding:s}),Tt=(0,Q.useMemo)(()=>P&&Le?ys(typeof Le==`string`?Le:Le.display):f,[P,Le,f]),Et=(0,Q.useMemo)(()=>Lo(Tt),[Tt]),Dt=G(e=>e.ultraplanSessionUrl),Ot=G(e=>e.ultraplanLaunching),kt=(0,Q.useMemo)(()=>!Dt&&!Ot?hg(Tt):[],[Tt,Dt,Ot]),At=(0,Q.useMemo)(()=>fi()?vg(Tt):[],[Tt]),jt=(0,Q.useMemo)(()=>Sg(Tt),[Tt]),Mt=(0,Q.useMemo)(()=>nw(Tt).filter(e=>Ho(Tt.slice(e.start+1,e.end),a)),[Tt,a]),Nt=(0,Q.useMemo)(()=>Bd(Tt),[Tt]),Pt=(0,Q.useMemo)(()=>Sw(ge.getState().mcp.clients)?ww(Tt):[],[Tt,(0,Q.useSyncExternalStore)(mw,Cw)]),Ft=(0,Q.useMemo)(()=>iu(Tt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[Tt]),It=Ft.some(e=>e.start===V);(0,Q.useEffect)(()=>{let e=Ft.find(e=>V>e.start&&V<e.end);if(e){let t=(e.start+e.end)/2;H(V<t?e.start:e.end)}},[V,Ft,H]);let Lt=(0,Q.useMemo)(()=>{let e=[];for(let t of Ft)V===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});P&&Le&&!Re&&e.push({start:V,end:V+Fe.length,color:`warning`,priority:20});for(let t of jt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of Mt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Nt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Pt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(qs())for(let t of Et)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:da(n-t.start),shimmerColor:da(n-t.start,!0),priority:10});for(let t of kt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:da(n-t.start),shimmerColor:da(n-t.start,!0),priority:10});for(let t of At)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:da(n-t.start),shimmerColor:da(n-t.start,!0),priority:10});return e},[P,Fe,Le,Re,V,jt,Ft,Mt,Nt,Pt,Tt,Et,kt,At]),{addNotification:Rt,removeNotification:zt}=di();(0,Q.useEffect)(()=>{Et.length&&qs()?Rt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):zt(`ultrathink-active`)},[Rt,zt,Et.length]),(0,Q.useEffect)(()=>{kt.length?Rt({key:`ultraplan-active`,text:`This prompt will launch an ultraplan session in Claude Code on the web`,priority:`immediate`,timeoutMs:5e3}):zt(`ultraplan-active`)},[Rt,zt,kt.length]),(0,Q.useEffect)(()=>{fi()&&At.length&&Rt({key:`ultrareview-active`,text:`Run /ultrareview after Claude finishes to review these changes in the cloud`,priority:`immediate`,timeoutMs:5e3})},[Rt,At.length]);let Bt=(0,Q.useRef)(f.length),Vt=(0,Q.useRef)(f.length),Ht=(0,Q.useCallback)(()=>{zt(`stash-hint`)},[zt]);(0,Q.useEffect)(()=>{let e=Bt.current,t=Vt.current,n=f.length;if(Bt.current=n,n>t){Vt.current=n;return}if(n===0){Vt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(Rf().hasUsedStash||Rt({key:`stash-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(ic,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:gC}),Vt.current=n)},[f.length,Rt]);let{pushToBuffer:Ut,undo:Wt,canUndo:Gt,clearBuffer:Kt}=DC({maxBufferSize:50,debounceMs:1e3});xD({input:f,pastedContents:w,onInputChange:he,setCursorOffset:H,setPastedContents:E});let qt=wD({input:f,submitCount:y}),Jt=(0,Q.useCallback)(e=>{if(e===`?`){Z(`tengu_help_toggled`,{}),L(e=>!e);return}L(!1),Ht(),pu(),q(U);let t=e.length===f.length+1,n=V===0,r=hu(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=ys(e).replaceAll(` `,` `);Ut(f,V,w),he(t),H(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Ut(f,V,w),U(e=>e.footerSelection===null?e:{...e,footerSelection:null}),he(i)},[he,h,f,V,Ut,w,Ht,U]),{resetHistory:Yt,onHistoryUp:Xt,onHistoryDown:Zt,dismissSearchHint:Qt,historyIndex:$t}=wC((e,t,n)=>{Jt(e),h(t),E(n)},f,w,H,m);(0,Q.useEffect)(()=>{P&&Qt()},[P,Qt]);function en(){if(!(sn.length>1)&&st){if(Te.some(Fn)){vn();return}Xt()}}function tn(){if(!(sn.length>1)&&ct&&Zt()&&ft.length>0){let e=ft[0];yt(e),e===`tasks`&&!Rf().hasSeenTasksHint&&Lf(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[nn,rn]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),an=(0,Q.useCallback)(e=>{rn(t=>typeof e==`function`?e(t):e)},[]),on=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=ge.getState();if(n.footerSelection&&ft.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(w).some(e=>e.type===`image`),i=Ee.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(De.status===`active`){St(),Ct(i,{skipReset:!0}),te(i,{setCursorOffset:H,clearBuffer:Kt,resetHistory:Yt},{state:De,speculationSessionTimeSavedMs:Oe,setAppState:U});return}Ee.shownAt>0&&(St(),e=i)}if(e.trim()===``&&!r)return;let a=nn.suggestions.length>0&&nn.suggestions.every(e=>e.description===`directory`);if(nn.suggestions.length>0&&!t&&!a){Y(`[onSubmit] early return: suggestions showing (count=${nn.suggestions.length})`);return}Ee.text&&Ee.shownAt>0&&Ct(e),zt(`stash-hint`),await te(e,{setCursorOffset:H,clearBuffer:Kt,resetHistory:Yt})},[Ee,De,Oe,ge,ft,nn.suggestions,te,Kt,Yt,Ct,U,St,w,zt]),{suggestions:sn,selectedSuggestion:cn,commandArgumentHint:ln,inlineGhostText:un,maxColumnWidth:dn}=eT({commands:a,onInputChange:he,onSubmit:on,setCursorOffset:H,input:f,cursorOffset:V,mode:m,agents:o,setSuggestionsState:an,suggestionsState:nn,suppressSuggestions:P||$t>0,markAccepted:St,onModeChange:h}),fn=m===`prompt`&&sn.length===0&&xt&&!Pe;fn&&wt(),Ee.text&&!xt&&Ee.shownAt===0&&!Pe&&(Rl(`timing`,Ee.text),U(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function pn(e,t,n,r,i){Z(`tengu_paste_image`,{}),h(`prompt`);let a=ze.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};as(o),bd(o),E(e=>({...e,[a]:o})),gn((Be.current?` `:``)+Yo(a)),Be.current=!0}(0,Q.useEffect)(()=>{let e=new Set(iu(f).map(e=>e.id));E(t=>{let n=Object.values(t).filter(t=>t.type===`image`&&!e.has(t.id));if(n.length===0)return t;let r={...t};for(let e of n)delete r[e.id];return r})},[f,E]);function mn(e){Be.current=!1;let t=pe(e).replace(/\r/g,`
77
+ `).replaceAll(` `,` `);if(f.length===0){let e=hu(t);e!==`prompt`&&(h(e),t=ys(t))}let n=Ls(t),r=Math.min(Mn-10,2);if(t.length>800||n>r){let e=ze.current++,r={id:e,type:`text`,content:t};E(t=>({...t,[e]:r})),gn(xa(e,n))}else gn(t)}let hn=(0,Q.useCallback)((e,t)=>Be.current?(Be.current=!1,A_(e,t)?` `+e:e):e,[]);function gn(e){Ut(f,V,w);let t=f.slice(0,V)+e+f.slice(V);he(t),H(V+e.length)}let _n=R(()=>{},()=>x()),vn=(0,Q.useCallback)(()=>{let e=Jc(f,V);return e?(he(e.text),h(`prompt`),H(e.cursorOffset),e.images.length>0&&E(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[he,h,f,V,E]);oC(C,function(e){Z(`tengu_ext_at_mentioned`,{});let t,n=vv.relative(Kd(),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[V-1]??` `;/\s/.test(r)||(t=` ${t}`),gn(t)});let yn=(0,Q.useCallback)(()=>{if(Gt){let e=Wt();e&&(he(e.text),H(e.cursorOffset),E(e.pastedContents))}},[Gt,Wt,he,E]),bn=(0,Q.useCallback)(()=>{Ut(f,V,w);let e=f.slice(0,V)+`
78
+ `+f.slice(V);he(e),H(V+1)},[f,V,he,H,Ut,w]),W=(0,Q.useCallback)(async()=>{Z(`tengu_external_editor_used`,{}),Je(!0);try{let e=await Vg(f,w);e.error&&Rt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Ut(f,V,w),he(e.content),H(e.content.length))}catch(e){e instanceof Error&&X(e),Rt({key:`external-editor-error`,text:`External editor failed: ${Yd(e)}`,color:`warning`,priority:`high`})}finally{Je(!1)}},[f,V,w,Ut,he,Rt]),xn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(he(g.text),H(g.cursorOffset),E(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:V,pastedContents:w}),he(``),H(0),E({}),Lf(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,V,g,he,_,w,E]),Sn=(0,Q.useCallback)(()=>{Xe(e=>!e),I&&L(!1)},[I]),Cn=(0,Q.useCallback)(()=>{it(e=>!e),I&&L(!1)},[I]),wn=(0,Q.useCallback)(()=>{ot(e=>!e),I&&L(!1)},[I]),Tn=(0,Q.useCallback)(()=>{Y(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=rT(n),{context:t}=iT(n);Z(`tengu_mode_cycle`,{to:e}),e===`plan`&&Lf(e=>({...e,lastPlanModeUse:Date.now()})),U(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),I&&L(!1)},[n,U,r,I]),En=(0,Q.useCallback)(()=>{gc().then(e=>{if(e)pn(e.base64,e.mediaType);else{let e=Qo(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Sf.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;Rt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[Rt,pn]),Dn=N();(0,Q.useEffect)(()=>{if(!(!Dn||ce))return Dn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{on(f)}})},[Dn,ce,on,f]),v((0,Q.useMemo)(()=>({"chat:undo":yn,"chat:newline":bn,"chat:externalEditor":W,"chat:stash":xn,"chat:modelPicker":Sn,"chat:thinkingToggle":wn,"chat:cycleMode":Tn,"chat:imagePaste":En}),[yn,bn,W,xn,Sn,wn,Tn,En]),{context:`Chat`,isActive:!ce}),A(`chat:messageActions`,()=>S?.(),{context:`Chat`,isActive:!ce&&!P}),A(`chat:fastMode`,Cn,{context:`Chat`,isActive:!ce&&xm()&&Tm()}),A(`help:dismiss`,()=>{L(!1)},{context:`Help`,isActive:I}),A(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),A(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),A(`history:search`,()=>{},{context:`Global`,isActive:!1}),A(`app:interrupt`,()=>{q(U)},{context:`Global`,isActive:!s&&De.status===`active`}),v({"footer:up":()=>{if(vt){Ue>-1?We(e=>e-1):yt(null);return}bt(-1,!0)},"footer:down":()=>{if(vt){Ue<ut.length-1&&We(e=>e+1);return}if(ht){ee(!0),yt(null);return}bt(1)},"footer:next":()=>{bt(1)},"footer:previous":()=>{bt(-1)},"footer:openSelected":()=>{switch(mt){case`tasks`:ee(!0),yt(null);break;case`tmux`:process.env.USER_TYPE===`ant`&&U(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`bridge`:He(!0),yt(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{yt(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!mt&&!ce}),oe((e,t)=>{if(!(Ze||$e||tt)){if(cp()===`macos`&&nT(e)){let t=tT[e],n=Ph();Rt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(T,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(mt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Jt(f.slice(0,V)+e+f.slice(V)),H(V+e.length);return}if(V===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),L(!1)),I&&f===``&&(t.backspace||t.delete)&&L(!1),t.escape){if(De.status===`active`){q(U);return}if(re&&ne){ne();return}if(I){L(!1);return}if(mt)return;if(Te.some(Fn)){vn();return}l.length>0&&!f&&!s&&_n()}t.return&&I&&L(!1)}});let On=xm()?gm():!1,kn=xm()?Ne&&(Tm()||On):!1,An=DD(kn??!1),{columns:jn,rows:Mn}=de(),Nn=jn-3,Pn=la()?Math.max(kD,Math.floor(Mn/2)-OD):void 0,In=(0,Q.useCallback)(e=>{if(!f||P)return;let t=oi.fromText(f,Nn,V),n=t.getViewportStartLine(Pn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});H(r)},[f,Nn,P,V,Pn]),Ln=(0,Q.useCallback)(e=>ee(e??!0),[ee]),Rn=fn&&xt?xt:qt,zn=(0,Q.useMemo)(()=>f.includes(`
79
+ `),[f]),Bn=(0,Q.useCallback)(e=>{let t=!1;U(n=>(t=xm()&&!fm(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Xe(!1);let n=(Ne??!1)&&!t,r=`Model set to ${Dm(e)}`;u_(e,n,om())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),Rt({key:`model-switched`,jsx:(0,$.jsx)(T,{children:r}),priority:`immediate`,timeoutMs:3e3}),Z(`tengu_model_picker_hotkey`,{model:e})},[U,Rt,Ne]),Vn=(0,Q.useCallback)(()=>{Xe(!1)},[]),Hn=(0,Q.useMemo)(()=>Ye?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(d_,{initial:Ae,sessionModel:je,onSelect:Bn,onCancel:Vn,isStandaloneCommand:!0,showFastModeNotice:xm()&&Ne&&fm(Ae)&&Tm()})}):null,[Ye,Ae,je,Bn,Vn]),Un=(0,Q.useCallback)(e=>{it(!1),e&&Rt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(T,{children:e}),priority:`immediate`,timeoutMs:3e3})},[Rt]),Wn=(0,Q.useMemo)(()=>rt?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(E_,{onDone:Un,unavailableReason:rm()})}):null,[rt,Un]),Gn=(0,Q.useCallback)(e=>{U(t=>({...t,thinkingEnabled:e})),ot(!1),Z(`tengu_thinking_toggled_hotkey`,{enabled:e}),Rt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(T,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[U,Rt]),Kn=(0,Q.useCallback)(()=>{ot(!1)},[]),qn=(0,Q.useMemo)(()=>at?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(sT,{currentValue:Me??!0,onSelect:Gn,onCancel:Kn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[at,Me,Gn,Kn,l.length]);if(W_(null),k)return(0,$.jsx)(nv,{onDone:()=>ee(!1),toolUseContext:M(l,[],new AbortController,se),initialDetailTaskId:typeof k==`string`?k:void 0});if(Hn)return Hn;if(Wn)return Wn;if(qn)return qn;if(Ve)return(0,$.jsx)(oT,{onDone:()=>{He(!1),yt(null)}});let Jn={multiline:!0,onSubmit:on,onChange:Jt,value:Le?ys(typeof Le==`string`?Le:Le.display):f,onHistoryUp:en,onHistoryDown:tn,onHistoryReset:Yt,placeholder:Rn,onExit:j,onExitMessage:(e,t)=>B({show:e,key:t}),onImagePaste:pn,columns:Nn,maxVisibleLines:Pn,disableCursorMovementForUpDownKeys:sn.length>0||!!mt,disableEscapeDoublePress:sn.length>0,cursorOffset:V,onChangeCursorOffset:H,onPaste:mn,onIsPastingChange:Ke,focus:!P&&!ce&&!mt,showCursor:!mt&&!P&&!It,argumentHint:ln,onUndo:Gt?()=>{let e=Wt();e&&(he(e.text),H(e.cursorOffset),E(e.pastedContents))}:void 0,highlights:Lt,inlineGhostText:un,inputFilter:hn},Yn=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(qe)return(0,$.jsx)(b,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Yn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Xn=k_()?(0,$.jsx)(oE,{...Jn,initialMode:D,onModeChange:O}):(0,$.jsx)(Qa,{...Jn});return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:+!ke,children:[!la()&&(0,$.jsx)(mD,{}),ie&&(0,$.jsx)(b,{marginTop:1,marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(hD,{hasStash:g!==void 0}),(0,$.jsxs)(b,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Yn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:MD(kn??!1,An,On),children:[(0,$.jsx)(sD,{mode:m,isLoading:s}),(0,$.jsx)(b,{flexGrow:1,flexShrink:1,onClick:In,children:Xn})]}),(0,$.jsx)(rD,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:k_()?D:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:le,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:ue,suggestions:sn,selectedSuggestion:cn,maxColumnWidth:dn,toolPermissionContext:n,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:ht,bridgeSelected:_t,tmuxSelected:gt,ideSelection:t,mcpClients:C,isPasting:Ge,isInputWrapped:zn,messages:l,isSearching:P,historyQuery:Fe,setHistoryQuery:Ie,historyFailedMatch:Re,onOpenTasksDialog:la()?Ln:void 0}),la()?(0,$.jsx)(b,{position:`absolute`,marginTop:ke?-2:-1,height:+(sn.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(_C,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:le,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:ue,ideSelection:t,mcpClients:C,isInputWrapped:zn})}):null]})}function jD(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=iu(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function MD(e,t,n){if(e)return{content:` ${t?`${w_(!0,n)} ${H.dim(`/fast`)}`:w_(!0,n)} `,position:`top`,align:`end`,offset:0}}var ND=Q.memo(AD);Qd();function PD(e,t){return{type:`assistant`,uuid:kv(),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 FD(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:cf(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}nf(),Wh(),_i();function ID(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function LD(e){return{type:`stream_event`,event:e.event}}function RD(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 zD(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function BD(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 VD(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 HD(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:Gh(e.compact_metadata)}}function UD(e,t){switch(e.type){case`assistant`:return{type:`message`,message:ID(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:Sc({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:LD(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:RD(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:zD(t)};if(t.subtype===`status`){let t=BD(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:HD(e)}:(Y(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:VD(e)};case`auth_status`:return Y(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return Y(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return Y(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return Y(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return Y(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function WD(e){return e.type===`result`}J(),nf(),Dp(),_i();var GD=6e4,KD=18e4;function qD({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Yr(),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 Jh(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;Y(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new fv(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(Y(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){Y(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;Y(`[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(WD(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=UD(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?tl(l.event,e=>t(t=>[...t,e]),()=>{},s,o):Y(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{Y(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=jm(y.current,e.tool_name)??FD(e.tool_name),o=PD(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)=>{Y(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{Y(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{Y(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{Y(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{Y(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{Y(`[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 Y(`[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:Qu(r,` `);n&&Kh(n,new AbortController().signal).then(e=>{Th(t,e??Ep(n,75))})}if(!e?.viewerOnly){let e=h.current?KD:GD;m.current=setTimeout((e,t)=>{Y(`[useRemoteSession] Response timeout - attempting reconnect`);let n=ec(`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])}nf(),Qd(),c();function JD(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var YD=class{constructor(e,t){l(this,`ws`,null),l(this,`config`,void 0),l(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
80
+ `).filter(e=>e.trim());for(let e of t){let t;try{t=qd(e)}catch{continue}if(!JD(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(Y(`[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=cf({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=cf({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=cf({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=cf({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}};Pm(),nf();function XD({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,Y(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new YD(e,{onMessage:e=>{if(WD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=UD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=jm(l.current,e.tool_name)??FD(e.tool_name),o=PD(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:()=>{Y(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{Y(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
81
+ Server disconnected.
82
+ `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,Ro(1),n(!1)},onError:e=>{Y(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{Y(`[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])}Pm(),nf(),Ct();function ZD({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,Y(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(WD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=UD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useSSHSession] permission request: ${e.tool_name}`);let a=jm(l.current,e.tool_name)??FD(e.tool_name),o=PD(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:()=>{Y(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{Y(`[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:kv(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{Y(`[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}`),Ro(1,`other`,{finalMessage:a})},onError:e=>{Y(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{Y(`[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])}nf(),Dh();async function QD(e){let{accessToken:t,orgUUID:n}=await Eh();return{baseUrl:`${Mp().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...wh(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function $D(e,t,n){let r=await f.get(e.baseUrl,{headers:e.headers,params:t,timeout:15e3,validateStatus:()=>!0}).catch(()=>null);return!r||r.status!==200?(Y(`[${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 eO(e,t=100){return $D(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function tO(e,t,n=100){return $D(e,{limit:n,before_id:t},`fetchOlderEvents`)}nf();var nO=40,rO=10,iO=`loading older messages…`,aO=`failed to load older messages — scroll up to retry`,oO=`start of session`;function sO(e){let t=[];for(let n of e.events){let e=UD(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function cO({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)(kv());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=sO(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(oO);t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return o?[o,...i,...t]:[...i,...t]}),Y(`[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 QD(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await eO(n);t||!r||(l.current=rO,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(iO),...t]});try{let r=await tO(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(aO),...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();Y(`[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()<nO&&p()},[p])}}zp();var lO=400;function uO({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=lO}){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=Vp(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}B();var dO=[`0`,`1`,`2`,`3`],fO={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},pO=e=>dO.includes(e),mO=`How is Claude doing this session? (optional)`;function hO({onSelect:e,inputValue:t,setInputValue:n,message:r=mO}){return uO({inputValue:t,setInputValue:n,isValidDigit:pO,onDigit:t=>e(fO[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(T,{bold:!0,children:r})]}),(0,$.jsxs)(b,{marginLeft:2,children:[(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}hf(),B(),zp();function gO({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!pO(i)?null:(0,$.jsx)(yO,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var _O=[`0`,`1`];function vO(e){return _O.includes(e)}function yO({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=Vp(r.slice(-1));vO(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[df,` `]}),(0,$.jsxs)(T,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(b,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(b,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(b,{width:12,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(b,{width:14,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}xp(),J(),_i();function bO(e){let t=G(e=>e.skillImprovement.suggestion),n=Yr(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,Z(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;Z(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&pv(r.skillName,r.updates).then(()=>{e(e=>[...e,ec(`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 xO(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Ma(),Ar(),Vu(),Et();function SO(e){(0,Q.useEffect)(()=>{let t=()=>{hm()&&process.stdout.write(`
83
+ `+Vo()+`
84
+ `),Du(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function CO(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function wO(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])}at(),Gs(),Gp();function TO(){let[e,t]=(0,Q.useState)(()=>{if(!Qp()||Zp())return`valid`;let{key:e,source:t}=em({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Qp()||Zp()){t(`valid`);return}await Kp(bt());let{key:e,source:n}=em();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await Mc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}at(),B(),Gd(),nf(),B(),jh(),xp(),J();function EO({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=G(e=>e.expandedView),d=Yr(),f=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[u,d]),p=G(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(ha(),e(Bo));if(!n()&&p&&t!==`transcript`){d(e=>e.isBriefOnly?{...e,isBriefOnly:!1}:e);return}}let c=t!==`transcript`;Z(`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)(()=>{Z(`tengu_transcript_toggle_show_all`,{is_expanding:!r,message_count:a}),i(e=>!e)},[r,i,a]),g=(0,Q.useCallback)(()=>{Z(`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}=(ha(),e(Bo));if(!t()&&!p)return;let n=!p;Z(`tengu_brief_mode_toggled`,{enabled:n,gated:!1,source:`keybinding`}),d(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n})}},[p,d]);A(`app:toggleTodos`,f,{context:`Global`}),A(`app:toggleTranscript`,m,{context:`Global`}),A(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),A(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),A(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return A(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),A(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Os(),pc(),jh();var DO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function OO({onSubmit:e,isActive:t=!0}){let n=N(),r=ml(),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}`,DO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}xp(),J(),M_(),Lc(),Os(),Ku(),jh(),vn(),Ga();var kO=3e3;function AO(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=br(),g=Yr(),_=rC().length,{addNotification:v,removeNotification:y}=di(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){Z(`tengu_cancel`,e),t(()=>[]),n();return}if(id()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Uu(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(k_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);A(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;Wn(e,g);let n=[];for(let[e,r]of t)An(e,g),n.push(r.description),ch(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Cd({value:n.length===1?`Background agent "${n[0]}" was stopped by the user.`:`${n.length} background agents were stopped by the user: ${n.map(e=>`"${e}"`).join(`, `)}.`,mode:`task-notification`}),r(),!0},[h,g,r]);return A(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),A(`chat:killAgents`,(0,Q.useCallback)(()=>{let e=h.getState().tasks;if(!Object.values(e).some(e=>e.type===`local_agent`&&e.status===`running`)){v({key:`kill-agents-none`,text:`No background agents running`,priority:`immediate`,timeoutMs:2e3});return}let t=Date.now();if(t-b.current<=kO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),_c(),k();return}b.current=t;let n=Qo(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:kO})},[h,v,y,k]),{context:`Chat`}),null}B(),J(),Sn();function jO(e){let t=G(e=>e.tasks),n=G(e=>e.pipeIpc),r=Object.values(t).some(Ri),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return oe((e,t,n)=>{i(new ee(n.keypress))}),{handleKeyDown:i}}I_(),rp();async function MO(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?X(e):X(Error(`Automated permission check failed: ${String(e)}`))}return null}var NO=new Map,PO=null;function FO(){return PO??null}function IO(e,t){let n=FO();if(!n)return null;let r=kv(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return NO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function LO(e){e&&NO.delete(e)}function RO(e,t){if(!e)return;let n=FO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}xp(),Km(),pl(),nf(),kd(),_i(),is(),Wt();function zO(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 BO(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){Gc({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:qm(e.name)})},async persistPermissions(e){return e.length===0?!1:(Nd(e),a(Sl(n.getAppState().toolPermissionContext,e)),e.some(e=>_s(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?pa:bo}${t}`:a?zo:ko,s=a?o:nu(o);return(r||!t&&!i?.length&&!a)&&(Y(`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 pr(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&&(Y(`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 VO(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))}}}nf(),B(),pl(),Kr(),lf();function HO(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=zO(t),u,d,f=o?kv():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){RO(h,e),LO(h),h=null}function _(){LO(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||ur(n.toolUseID)},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await fo(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=IO(v,e=>{l()&&(_(),ur(n.toolUseID),n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),ur(n.toolUseID),n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}xp(),Km(),B(),pl(),Kr(),nf(),lf(),rp(),rr(),Qd(),Wt();function UO(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=BO(n,r,i,a,o,t,VO(e));if(!l.resolveIfAborted(c))return(s===void 0?fo(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:qm(n.name),behavior:e.behavior,input:cf(r),messageID:l.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&tu(o,e.decisionReason.reason),l.logDecision({decision:`accept`,source:`config`}),c(l.buildAllow(e.updatedInput??r,{decisionReason:e.decisionReason}));return}let t=i.getAppState(),a=await n.description(r,{isNonInteractiveSession:i.options.isNonInteractiveSession,toolPermissionContext:t.toolPermissionContext,tools:i.options.tools});if(!l.resolveIfAborted(c))switch(e.behavior){case`deny`:Gc({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(L_({toolName:n.name,display:a,reason:e.decisionReason.reason??``,timestamp:Date.now()}),i.addNotification?.({key:`auto-mode-denied`,priority:`immediate`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await MO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;HO({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof Jd||e instanceof Zd?(Y(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(X(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{ur(o)})}),[e,t])}oh(),xp(),_a(),Su(),Gd(),nf(),Ct(),lf(),rp(),Ga(),im();function WO(){fa(0)}async function GO(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){du(),await KO({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(iu(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),ee=Object.values(k).some(pi);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?GO({...e,input:`/exit`}):WO();return}let A=Do(T,k),j=iu(T).filter(e=>k[e.id]?.type===`text`),M=j.length;if(Z(`tengu_paste_text`,{pastedTextCount:M,pastedTextBytes:j.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&A.trim().startsWith(`/`)){let t=A.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Pu(e)&&(e.name===f||e.aliases?.includes(f)||bs(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Z(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],tr(),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?qu({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&&(Y(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Z(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),qu({value:A.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:ee?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}du(),await KO({queuedCommands:[{value:A,preExpansionValue:T,mode:E,pastedContents:ee?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function KO(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=tr();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Al(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await Eo(C);C=w.attachmentCommands;let T=w.claimedCommands;if(C.length===0){l(null);return}let E=C[0]?.workload,D=E!==void 0&&C.every(e=>e.workload===E)?E:void 0,O=new Set,k;try{await Om(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await pg({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&O.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.nextInput,S=u.submitNextInput)}if(Al(`query_process_user_input_end`),Fu()&&(Al(`query_file_history_snapshot_start`),s.filter(fg).forEach(e=>{Wl(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Al(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=C[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?qp(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?qu({value:x,mode:`prompt`}):e.onInputChange(x))})}catch(e){k=e}if(T.length){let e=T.filter(e=>{let t=e.autonomy?.runId;return!t||!O.has(t)});if(k)try{await Jo({commands:e,outcome:{type:`failed`,error:k},currentDir:Kd(),priority:`later`,workload:D})}catch(e){X(ef(e))}else try{let t=await Jo({commands:e,outcome:{type:`completed`},currentDir:Kd(),priority:`later`,workload:D});for(let e of t)qu(e)}catch(e){X(ef(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}Ga();function qO(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 JO({executeInput:e}){let t=e=>e.agentId===void 0,n=Li(t);if(!n)return{processed:!1};if(qO(n)||n.mode===`bash`)return e([cc(t)]),{processed:!0};let r=n.mode,i=$o(e=>t(e)&&!qO(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Ga();function YO({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Rc,Ia);(0,Q.useEffect)(()=>{r||t||i.length!==0&&JO({executeInput:e})},[i,r,e,t,n])}function XO({isLoading:e,onSubmitMessage:t}){let n=Oo();(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 ZO(e,t){return e&&t&&t.length>0?Wa([...e,...t],`name`):e||[]}function QO(e,t){return(0,Q.useMemo)(()=>ZO(e,t),[e,t])}W(),dg(),Rg(),nd();function $O(e,t){return(0,Q.useMemo)(()=>t.length>0?Wa([...e,...t],`name`):e,[e,t])}_a(),rp();function ek(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{oo(),t(await eu(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Og.subscribe(n),[n])}rp(),Oe(),Yu(),ke();var tk=Ee(()=>be({method:ye(`selection_changed`),params:be({selection:be({start:be({line:xe(),character:xe()}),end:be({line:xe(),character:xe()})}).nullable().optional(),text:Se().optional(),filePath:Se().optional()})}));function nk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Kl(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(tk(),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){X(e)}}),n.current=!0},[e,t])}za(),B(),Z_(),J(),Dp();function rk({task:e,selected:t}){let n=ev(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(b,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(T,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(T,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(T,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(b,{flexShrink:0,children:(0,$.jsxs)(T,{dimColor:!0,children:[n,` · ↓ `,jp(r),` tokens`]})})]})}function ik(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 ak(){let e=TC(),t=G(e=>e.viewingAgentTaskId),n=G(e=>e.footerSelection),r=G(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)(b,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(T,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(T,{dimColor:!0,children:ik(i,s)})]}),e.map(e=>(0,$.jsx)(rk,{task:e,selected:e.agentId===a},e.agentId))]})}nf(),xd();var ok=1e3;function sk({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 fd(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)Y(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=ck(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await Bl(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=lk(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await an(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;hc(e);let t=Wu(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),ok,l)};u.current=r;try{n=Dv(t,r),n.unref(),Y(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){Y(`[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 ck(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 lk(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}zf(),s(),Yu();function uk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Rf().autoConnectIde||e||Ra()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!i(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:r.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:r.url,ideName:r.name,authToken:r.authToken,ideRunningInWindows:r.ideRunningInWindows,scope:`dynamic`}})}Dd(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}x_(),Ah(),B(),jh(),Cl(),J(),zf(),uf(),s();function dk({onBackgroundSession:e,isLoading:t}){let n=Yr(),r=br(),[i,o]=(0,Q.useState)(!1),s=R(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||($u(r.getState())?(rs(()=>r.getState(),n),Rf().hasUsedBackgroundTask||Lf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=G($u),u=a(`false`);A(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=wc(`task:background`,`Task`,`ctrl+b`),f=Sf.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:f,action:`background`})})})}J();function fk({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=G(e=>e.foregroundedTaskId),o=G(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Yr(),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}}Vi(),ig(),Zg();function pk(e,t){return t}async function mk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=co(e),i=await zr(Fl(e)),a;try{let e=Hn(),{size:t}=await jv(e);t<=52428800?a=await Av(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=O_(cf({trigger:t,version:`0.0.7`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await mm();let s=Hp();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":wm(),...s.headers},l=await f.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 Y(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return Y(Yd(e),{level:`error`}),{success:!1}}}var hk=t((()=>{p(),Gp(),nf(),lf(),_i(),Uc(),Qd()}));Oh(),hk();function gk({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)(kv()),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=kv(),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])}}xp(),zf(),s(),_i(),im(),Ef();var _k={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},vk={probability:0};function yk(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=Va(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=pk(`tengu_feedback_survey_config`,_k),u=pk(`tengu_bad_survey_transcript_ask_config`,vk),d=pk(`tengu_good_survey_transcript_ask_config`,vk),f=Of().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),Rf().feedbackSurveyState?.lastShownTime!==e&&Lf(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),ph(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),ph(`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`||Rf().transcriptShareDismissed||!Sr(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Z(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),ph(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(Z(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&Lf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await mk(g.current,i,e);return Z(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=gk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),ee=Em(),A=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(ee),[l.onForModels,ee]),j=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!A||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||kh()||!Sr(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=Rf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,A,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{j&&D()},[j,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Oh(),xp(),Zi(),zf(),s(),_i(),gh(),hk();var bk=3e3,xk=`tengu_memory_survey_event`,Sk=`memory_survey`;function Ck(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=gk({hideThanksAfterMs:bk,onOpen:(0,Q.useCallback)(e=>{Z(xk,{event_type:`appeared`,appearance_id:e}),ph(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(xk,{event_type:`responded`,appearance_id:e,response:t}),ph(`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`||Rf().transcriptShareDismissed||!Sr(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(xk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:Sk}),ph(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(xk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:Sk}),t===`dont_ask_again`&&Lf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await mk(o.current,Sk,e);return Z(xk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:Sk}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>Va(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Oh(),xp(),s(),_i(),gh();var wk=3e3,Tk=.2;function Ek(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 Dk(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=gk({hideThanksAfterMs:wk,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:cu()}),ph(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:cu()}),ph(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Ai(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||kh()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Ek(e,c.current)){c.current=null,Math.random()<Tk&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}hf(),B();var Ok=[`1`,`2`,`3`],kk={1:`yes`,2:`no`,3:`dont_ask_again`},Ak=e=>Ok.includes(e);function jk({onSelect:e,inputValue:t,setInputValue:n}){return uO({inputValue:t,setInputValue:n,isValidDigit:Ak,onDigit:t=>e(kk[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[df,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can we look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(b,{marginLeft:2,children:[(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}xp(),B();function Mk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Pk,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(jk,{onSelect:r,inputValue:i,setInputValue:a}):i&&!pO(i)?null:(0,$.jsx)(hO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Nk=e=>e===`1`;function Pk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;uO({inputValue:t,setInputValue:n,isValidDigit:Nk,enabled:!!i,once:!0,onDigit:()=>{Z(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}});let a=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;return(0,$.jsxs)(b,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(T,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(T,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}Zh(),eg(),at(),Lc(),rp();function Fk(e){let{addNotification:t}=di(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{je()||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(X))},[t])}function Ik(){Fk(async()=>(await $h()).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`}}))}Xd(),nf(),_i(),im(),K(),hv(),Gs(),B(),_i();function Lk(e,t,n){(0,Q.useRef)(null),(0,Q.useRef)(null);let r=(0,Q.useRef)(e),i=(0,Q.useRef)(n),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(null);r.current=e,i.current=n,(0,Q.useEffect)(()=>{},[!1,t]),(0,Q.useEffect)(()=>{if(n||!a.current)return;let e=F();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{F()},[n,!1])}xp(),zf(),nf(),s(),lf(),rp();function Rk(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var zk={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function Bk(e){let t=zk.INITIAL_DELAY_MS*zk.BACKOFF_MULTIPLIER**e;return Math.min(t,zk.MAX_DELAY_MS)}function Vk(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>=zk.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function Hk(){let e=Rf();if(!Vk(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(Rk())return Y(`Official marketplace auto-install disabled via env var, skipping`),Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await $n())[`claude-plugins-official`])return Y(`Official marketplace '${po}' already installed, skipping`),Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Ot(ir))return Y(`Official marketplace blocked by enterprise policy, skipping`),Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=bi(),n=Sv(t,po);if(await go(n,t)!==null){let e=await $n();return e[po]={source:ir,installLocation:n,lastUpdated:new Date().toISOString()},await lo(e),Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await wa()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+Bk(t),i=!1;try{Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(ef(e)),Y(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}Y(`Attempting to auto-install official marketplace`),await Ki(ir),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return qt(),Y(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),X(ef(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+Bk(r),o=!1;try{Lf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(ef(e)),Y(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}B(),nf();function Uk(){Fk(async()=>{let e=await Hk(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(T,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(Y(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(T,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(Y(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(T,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Ef(),xp();function Wk(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:sv(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function Gk(e){if(Tf().spinnerTipsEnabled===!1)return;let t=await uv(e);if(t.length!==0)return Wk(t)}function Kk(e){av(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}lf(),rp(),at(),J(),rn();var qk=!1;async function Jk(e,t,n){{if(qk)return;qk=!0;let{updateContext:r,notification:i}=await yr(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function Yk(){qk=!1}function Xk(){let e=G(e=>e.mainLoopModel),t=G(e=>e.mainLoopModelForSession),n=G(e=>e.fastMode),r=Yr(),i=br(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{je()||(a.current?a.current=!1:Yk(),Jk(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:ef(e)}))}))},[e,t,n])}lc();function Zk(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!Fu()||r.current||(r.current=!0,e&&vl(e,n))},[t,e,n])}B(),Vl(),xp(),fs(),Jg();function Qk({hostPattern:{host:e},onUserResponse:t}){function n(n){switch(process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:n}),n){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...ac()?[]:[{label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(T,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(T,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Xg,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(Fc,{options:r,onChange:n,onCancel:()=>{process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:`cancel`}),t({allow:!1,persistToSettings:!1})}})})]})})}B(),Vl(),lp();function $k(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function eA(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Mu.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Mu.isSandboxingEnabled()||cp()===`linux`||n===0?null:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{marginLeft:0,children:(0,$.jsxs)(T,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[$k(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}v_(),Lc(),at(),B();var tA=[];function nA({mcpClients:e=tA}){let{addNotification:t}=di();(0,Q.useEffect)(()=>{if(je())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`&&Xt(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`&&Xt(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}B(),Ef(),mu();var rA=`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.`;me(),at(),Lc(),B(),J(),nf(),s();var iA=5e3;function aA(){let{addNotification:e}=di(),t=Yr(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),Y(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(je()||Je())return;let e=Cs();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=ll();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);re(s,n?iA:null),Q.useEffect(()=>{je()||!n||s()},[s,n])}nf();var oA=new Map;async function sA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=oA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await op(t).catch(()=>null)&&(r=!0),oA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}zf(),nf(),oa();var cA=5;function lA(e){return Df.has(e.toLowerCase())}function uA(e){if(!e)return null;if(typeof e==`string`)return Y(`[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=fA(t);if(e)return e}return null}return fA(e)}function dA(e){return typeof e==`object`&&!!e}function fA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!dA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(dA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function pA(){let e=new Map;try{let t=await $n();for(let n of Object.keys(t))try{let t=await Wc(n),r=lA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=uA(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){Y(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){Y(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function mA(e){if(_A())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=xv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await pA(),r=Rf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){Y(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(gn(e)){Y(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await sA(e.command)?(a.push({info:e,pluginId:t}),Y(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):Y(`[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 hA(e){Lf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function gA(){Lf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function _A(){let e=Rf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=cA}u(),at(),B(),rp(),oa();function vA(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{je()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(X).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function yA(e,t,n,r,i){try{let a=await Mi(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(T,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){X(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(T,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}at(),Lc(),J(),zf(),nf(),rp(),Ef();var bA=28e3;function xA(){let e=G(e=>e.fileHistory.trackedFiles),{addNotification:t}=di(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=vA();return Q.useEffect(()=>{a(async()=>{if(et())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 mA(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ie(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:xv(e),shownAt:Date.now()}}catch(e){X(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(Y(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:yA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Sv(e.marketplaceInstallLocation,e.entry.source):void 0;await dl(n,e.entry,`user`,void 0,t),Nf(`userSettings`,{enabledPlugins:{...wf(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=bA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),gA());break}case`never`:hA(n);break;case`disable`:Lf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),fs(),Jg();var SA=3e4;function CA({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`),SA,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)(Xg,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(T,{children:[` `,n,` files`]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(Fc,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(T,{children:[`Never for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Lc(),xp(),nf(),Ns();function wA(){let e=Q.useSyncExternalStore(Ac,Eu),{addNotification:t}=di(),{recommendation:n,clearRecommendation:r,tryResolve:i}=vA();return Q.useEffect(()=>{e&&i(async()=>{let t=await Go(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),lu()),Eu()===e&&Us(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(wo(n.pluginId),Z(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;yA(e,r,`hint-plugin`,t,async t=>{let n=await tc({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`:Rr();break;case`no`:break}r()}},[n,t,r])}}B(),fs(),Jg();var TA=3e4;function EA({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`),TA,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)(Xg,{title:`Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`The `,(0,$.jsx)(T,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(T,{children:[` `,n]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install it?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(Fc,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}fs(),Jg();var DA=3e4;function OA({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(),DA,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)(Xg,{title:`Tool Recommendation`,children:(0,$.jsx)(Fc,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}ti();var kA=.15,AA=3;function jA(){let e=Q.useSyncExternalStore(Aa,Er),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,AA).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)>=kA,handleSelect:Q.useCallback(e=>{Zn()},[]),handleDismiss:Q.useCallback(()=>{Zn()},[])}}at(),Lc(),B(),J(),nf(),zp();function MA(){let{addNotification:e}=di(),t=G(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(!je()){if(!t){Y(`No installation status to monitor`);return}n!==0&&(Y(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(Y(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n,` `,Rp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}at(),Lc(),B(),nf(),P_();function NA(){let{addNotification:e}=di(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!je())return F_(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(je()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(T,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}nf(),rp(),oa(),Ag(),xp();function PA(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 FA(e){Y(`performBackgroundPluginInstallations called`);try{let t=lg(Ut(),await $n().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;Y(`Installing ${n.length} marketplace(s) in background`);let r=await sg({onProgress:t=>{switch(t.type){case`installing`:PA(e,t.name,`installing`);break;case`installed`:PA(e,t.name,`installed`);break;case`failed`:PA(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(Z(`tengu_marketplace_background_install`,i),Hf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){rl(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await kg(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Ou(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(rl(),Ou(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}zf(),nf(),oa(),ds();async function IA(e){if(Y(`performStartupChecks called`),!Vf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Hd()&&(rl(),Ou(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await FA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var LA=/https?:\/\/\S+/;function RA(){let[e,t]=(0,Q.useState)(cm.getInstance().getStatus());return(0,Q.useEffect)(()=>cm.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(b,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(T,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(LA);if(!n)return(0,$.jsx)(T,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(T,{dimColor:!0,children:[a,(0,$.jsx)(C,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{color:`error`,children:e.error})})]})}Lc(),B(),Xr(),Co(),Gp(),ym(),at();function zA(e){let{addNotification:t}=di(),n=Wo(),r=(0,Q.useMemo)(()=>Ld(n,e),[n,e]),i=(0,Q.useMemo)(()=>Yt(n),[n]),a=(0,Q.useRef)(null),o=Yp(),s=Cm(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{je()||(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)(()=>{je()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(T,{children:(0,$.jsx)(T,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Lc(),at();function BA(e){let{addNotification:t}=di(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(je())return;let r=ov(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 VA=``;function HA(){Fk(async()=>Pp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await Qh()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:VA,color:`warning`,priority:`high`})}Lc(),B(),zf(),Yu(),at();var UA=5;function WA({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=di(),{status:a,ideName:o}=sC(t),s=(0,Q.useRef)(!1),c=n?gd(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(je())return;if(Ra()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Rf().ideHintShownCount??0)>=UA)return;let e=setTimeout((e,t)=>{As(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Lf(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(T,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!je()){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(!je()){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(!je()){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])}zf();var GA=[e=>{if(qA(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(qA(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 KA(){Fk(()=>{let e=Rf(),t=[];for(let n of GA){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function qA(e){return e!==void 0&&Date.now()-e<3e3}Gp(),B(),xp(),zf();var JA=3;function YA(){Fk(async()=>{if((Rf().subscriptionNoticeCount??0)>=JA)return null;let e=await XA();return e===null?null:(Lf(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Z(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(T,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`]}),priority:`low`})})}async function XA(){if(Zp())return null;let e=await Xp();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Lc(),J(),um(),Dp(),at();var ZA=`fast-mode-cooldown-started`,QA=`fast-mode-cooldown-expired`,$A=`fast-mode-org-changed`,ej=`fast-mode-overage-rejected`;function tj(){let{addNotification:e}=di(),t=G(e=>e.fastMode),n=Yr();(0,Q.useEffect)(()=>{if(!je()&&xm())return lm(r=>{r?e({key:$A,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:$A,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!je()&&xm())return Sm(t=>{n(e=>({...e,fastMode:!1})),e({key:ej,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(je()||!t)return;let n=_m((t,n)=>{let r=nj(n,Ap(t-Date.now(),{hideTrailingZeros:!0}));e({key:ZA,invalidates:[QA],text:r,color:`warning`,priority:`immediate`})}),r=am(()=>{e({key:QA,invalidates:[ZA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function nj(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}B(),jh();function rj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return A(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{children:(0,$.jsx)(T,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,(0,$.jsx)(h,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Reason: `,n]})})]})}function ij(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 aj(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function oj(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 sj=()=>null;hf(),B();function cj(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(b,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(b,{minWidth:2,children:(0,$.jsx)(T,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(T,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(T,{dimColor:!0,children:` /issue to report it`})]})]}):null}Rm(),_i();var lj=[/\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/],uj=[/^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 dj(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(lj.some(t=>t.test(e)))return!1}}}return!0}function fj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=Wi(n);if(r)return uj.some(e=>e.test(r))}return!1}var pj=3,mj=1800*1e3;function hj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>dj(e)&&fj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<mj||t<pj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}at(),B();function gj(){return process.env.USER_TYPE===`ant`}function _j(){let[e,t]=(0,Q.useState)(yt);return ae(()=>{t(yt())},gj()?500:null),!gj()||e.length===0?null:(0,$.jsxs)(T,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}u(),B(),yo(),fs(),Hh(),J(),at(),o_(),_i(),Ga(),Gd(),up(),Uc(),Os();var vj=24,yj=11;function bj(){return new Date().toISOString().split(`T`)[0]}function xj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){Is(`ultraplan-choice`);let l=Yr(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(vj,Math.max(1,Math.floor(u/2)-yj)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
85
+ `),[e,f]),h=Math.max(0,m.length-p),[g,_]=Q.useState(0);Q.useEffect(()=>{_(e=>Math.min(e,h))},[h]);let v=m.length>p;oe((e,t)=>{if(!v)return;let n=Math.max(1,Math.floor(p/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+p).join(`
86
+ `),x=g>0,S=g<h,C=Q.useCallback(async a=>{switch(a){case`here`:Cd({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(`
87
+ `),mode:`task-notification`});break;case`fresh`:let t=st(),n=await jv(Hn()).then(()=>!0,()=>!1);await c_({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,ec(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),Cd({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=Sv(Kd(),`${bj()}-ultraplan.md`);await Mv(t,e,{encoding:`utf-8`}),r(e=>[...e,ec(`Ultraplan rejected · Plan saved to ${fp(t)}`,`suggestion`)]);break}}qn(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]),E=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)(ge,{title:`Ultraplan approved`,subtitle:`How should the plan be implemented?`,onCancel:()=>{},hideInputGuide:!0,children:(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{children:y}),v&&(0,$.jsxs)(T,{dimColor:!0,children:[x?d.arrowUp:` `,S?d.arrowDown:` `,` `,g+1,`–`,Math.min(g+p,m.length),` of `,m.length,` · ctrl+u/ctrl+d to scroll`]})]}),(0,$.jsx)(Fc,{options:E,onChange:e=>void C(e)})]})})}B(),fs(),Hh(),J(),zf(),Tl();function Sj(){return!Rf().hasSeenUltraplanTerms}function Cj(){return jl()}function wj({onChoice:e}){let[t]=Q.useState(Sj),[n]=Q.useState(Cj),r=Q.useMemo(()=>ss(n),[n]),i=G(e=>e.replBridgeEnabled),a=Yr(),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&&Lf(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)(ge,{title:`Run ultraplan in the cloud?`,subtitle:r.timeEstimate,onCancel:s,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:r.dialogBody}),t?(0,$.jsxs)(T,{dimColor:!0,children:[`For more information on Claude Code on the web:`,(0,$.jsx)(C,{url:Cu,children:Cu})]}):null]}),(0,$.jsx)(T,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(Fc,{options:c,onChange:o})]})})}B_(),B(),zf(),Zr();function Tj(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||!(Rf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function Ej(e){let[t]=y();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Cr(t).selectionBg)},[e,t])}Lc(),B(),jh(),nf();var Dj=40,Oj=.3,kj=6,Aj=200,jj=15,Mj=15,Nj=3,Pj=1500,Fj=150,Ij=5,Lj=5,Rj=80,zj=3,Bj=6,Vj=500;function Hj(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 Uj(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 Wj(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Pj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>Aj)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<Lj)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/Fj),n=Math.max(Mj,e.base*2),i=1+(e.mult-1)*t+jj*t;return e.mult=Math.min(n,i,e.mult+Nj),Math.floor(e.mult)}if(r>Dj)e.mult=e.base;else{let t=Math.max(kj,e.base*2);e.mult=Math.min(t,e.mult+Oj)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<Lj)return 1;if(!i||r>Vj)e.mult=2,e.frac=0;else{let t=.5**(r/Fj);e.mult=Math.min(r>=Rj?zj:Bj,1+(e.mult-1)*t+Ij*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function Gj(){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 Kj(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function qj(){let e=se(),t=Gj();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),Kj(e,t)}var Jj=2,Yj=50,Xj=200;function Zj({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ue(),{addNotification:a}=di(),o=(0,Q.useRef)(null);function s(e){let t=le(),n=e.length,r;switch(t){case`native`:r=`copied ${n} chars to clipboard`;break;case`tmux-buffer`:r=`copied ${n} chars to tmux buffer · paste with prefix + ]`;break;case`osc52`:r=`sent ${n} chars via OSC 52 · check terminal clipboard settings if paste fails`;break}a({key:`selection-copied`,text:r,color:`suggestion`,priority:`immediate`,timeoutMs:t===`native`?2e3:4e3})}function c(){let e=i.copySelection();e&&s(e)}function l(e,t){let n=i.getState();if(!n?.anchor||!n.focus)return;let r=e.getViewportTop(),a=r+e.getViewportHeight()-1;if(n.anchor.row<r||n.anchor.row>a||n.focus.row<r||n.focus.row>a)return;let o=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),s=e.getScrollTop()+e.getPendingDelta(),c=Math.max(0,Math.min(o,s+t))-s;if(c!==0)if(c>0)i.captureScrolledRows(r,r+c-1,`above`),i.shiftSelection(-c,r,a);else{let e=-c;i.captureScrolledRows(a-e+1,a,`below`),i.shiftSelection(e,r,a)}}return 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=eM(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=eM(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=qj()),nM(t,Wj(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=qj());let r=tM(t,Wj(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=eM(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=eM(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=eM(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=eM(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),oe((t,r,i)=>{let a=e.current;if(!a)return;let o=iM(a,rM(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=Uj(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}Hj(t)&&i.clearSelection()},{isActive:t}),Qj(e,i,t,n),Tj(i,t,s),Ej(i),null}function Qj(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>Xj){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(Jj,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-2)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(Jj,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(Jj)}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,Yj)))}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=$j(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 $j(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 eM(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 tM(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 nM(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function rM(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 iM(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),eM(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),eM(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),eM(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 aM=r({useFrustrationDetection:()=>sM});function oM(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function sM(e,t,n,r){let[i,a]=(0,cM.useState)(`closed`),o=Rf(),s=Sr(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=oM(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(mk(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(Lf(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var cM,lM=t((()=>{cM=n(z(),1),zf(),Zi(),hk()})),uM=r({useAntOrgWarningNotification:()=>dM});function dM(){}t((()=>{}));var fM=r({useProactive:()=>pM});function pM(e){let t=(0,mM.useRef)(e);t.current=e,(0,mM.useEffect)(()=>{if(!dh())return;let e=null,n=!1,r=!1;function i(){uh(Date.now()+hM),e=setTimeout(()=>{if(e=null,!ih()){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 At({basePrompt:`<${ep}>${new Date().toLocaleTimeString()}</${ep}>`,currentDir:Kd(),shouldCreate:()=>!n});if(n){await No({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await No({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},hM)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),uh(null)}},[dh(),rh(),ah()])}var mM,hM,gM=t((()=>{mM=n(z(),1),tp(),Gd(),ba(),nf(),hM=3e4}));function _M(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 vM(e){let t=us(e),n=_M(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
88
+ You have an active goal to work on. Continue making progress.
89
+
90
+ ## Active Goal
91
+ ${e.objective}
92
+
93
+ ## Status
94
+ - Elapsed active time: ${t}
95
+ - ${n}
96
+ - ${r}
97
+
98
+ ## Instructions
99
+
100
+ Continue working towards the goal. Do NOT narrow the scope of the goal — even if you cannot complete everything in one turn, maintain the full objective and make as much progress as possible.
101
+
102
+ When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
103
+
104
+ ### Completion Audit
105
+ 1. Derive concrete requirements from the objective and any referenced files.
106
+ 2. Preserve the original scope — do not redefine success around what is already done.
107
+ 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
108
+ 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
109
+ 5. Treat uncertain or indirect evidence as "not achieved".
110
+ 6. The audit must PROVE completion, not merely fail to find remaining work.
111
+
112
+ ### Blocked Audit
113
+ If you encounter an obstacle you genuinely cannot overcome:
114
+ - Do NOT mark blocked on the first encounter.
115
+ - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
116
+ - "Difficult", "slow", or "partially incomplete" is NOT blocked.
117
+ - If blocked, use the GoalTool with status "blocked" and a clear reason.
118
+
119
+ Resume working now.
120
+ </goal-steering>`}function yM(e){return`<goal-steering type="budget_limit">
121
+ ## Token Budget Reached
122
+
123
+ Your token budget for this goal has been exhausted.
124
+
125
+ - Goal: ${e.objective}
126
+ - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
127
+ - Active time: ${us(e)}
128
+
129
+ **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
130
+
131
+ Instead, provide a brief summary:
132
+ 1. What has been accomplished so far.
133
+ 2. What remains to be done.
134
+ 3. Any blockers or issues encountered.
135
+
136
+ 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.
137
+ </goal-steering>`}var bM=t((()=>{})),xM=r({useGoalContinuation:()=>CM});function SM(e){Y(`[goal] hook: ${e}`)}function CM(e){let t=(0,wM.useRef)(e);t.current=e;let n=(0,wM.useRef)(!1),r=(0,wM.useRef)(!1);(0,wM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){SM(`skip: queryActiveNow=true`);return}if(e.wasAborted){SM(`skip: wasAborted=true`);return}if(n.current)return;if(Ia().length>0){SM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){SM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){SM(`skip: planMode`);return}let t=bu();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=yM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),qu({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){SM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){Ms()&&(qo(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=ul();qo();let a=vM(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),qu({value:a,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-continuation`,skipSlashCommands:!0}),e.onContinuationEnqueued?.({turn:i,objective:t.objective})},[e.isLoading,e.wasAborted,e.queuedCommandsLength,e.hasActiveLocalJsxUI,e.isInPlanMode])}var wM,TM=t((()=>{wM=n(z(),1),nf(),zu(),bM(),Ga()})),EM=r({AntModelSwitchCallout:()=>DM,shouldShowModelSwitchCallout:()=>OM});function DM(e){return null}function OM(){return!1}t((()=>{}));var kM=r({UndercoverAutoCallout:()=>AM});function AM({onDone:e}){return(0,jM.useEffect)(()=>{e()},[e]),null}var jM,MM=t((()=>{jM=n(z(),1)}));at(),$t(),Pf(),u(),B(),yo(),zg(),Lc(),nf(),s(),Dp(),ba(),vn(),_a(),gg(),Et(),Su(),ol(),Cl(),Ku(),lf(),rp(),Gd(),is(),rn(),pl(),zf(),ym(),xp(),_i(),qh(),tp(),Ct(),Ks(),G_(),tg(),Ta(),kd(),Kg(),J(),ou(),Uc(),lc(),Yu(),Un(),Ga(),Ca(),jr(),Vl(),Tl(),Pi();var NM=process.env.USER_TYPE===`ant`?(lM(),e(aM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),PM=process.env.USER_TYPE===`ant`?e(uM).useAntOrgWarningNotification:()=>{},FM=(fh(),e(th)),IM=e=>()=>{},LM=()=>!1,RM=()=>null,zM=(e,t)=>!1,BM=(gM(),e(fM)).useProactive,VM=(TM(),e(xM)).useGoalContinuation,HM=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),UM=()=>({routeToSelectedPipes:()=>!1}),WM=process.env.USER_TYPE===`ant`?e(EM).AntModelSwitchCallout:null,GM=process.env.USER_TYPE===`ant`?e(EM).shouldShowModelSwitchCallout:()=>!1,KM=process.env.USER_TYPE===`ant`?(MM(),e(kM)).UndercoverAutoCallout:null,qM=[],JM=3e3;function YM(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 XM({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=wc(`app:toggleTranscript`,`Global`,`ctrl+o`),o=wc(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(b,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${d.arrowUp}${d.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function ZM({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=p_({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)(b,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(T,{children:`/`}),(0,$.jsx)(T,{children:s.slice(0,f)}),(0,$.jsx)(T,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(T,{children:s.slice(f+1)}),(0,$.jsx)(b,{flexGrow:1}),l===`building`?(0,$.jsx)(T,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(T,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(T,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(T,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var QM=[`⠂`,`⠐`],$M=`✳`,eN=960;function tN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=j(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%QM.length),eN,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?QM[a]??$M:$M;return te(n?null:r?t:`${s} ${t}`),null}var nN=`<${np}>`;function rN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(nN)}function iN({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:x=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:w,remoteSessionConfig:D,directConnectConfig:O,sshSession:k,thinkingConfig:ee}){let A=!!D,M=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),te=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(Y(`[REPL:mount] REPL mounted, disabled=${x}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[x]);let[F,re]=(0,Q.useState)(S),I=G(e=>e.toolPermissionContext),L=G(e=>e.verbose),R=G(e=>e.mcp),z=G(e=>e.plugins),ae=G(e=>e.agentDefinitions),se=G(e=>e.fileHistory),ce=G(e=>e.initialMessage),le=rC(),ue=G(e=>e.spinnerTip),pe=G(e=>e.expandedView)===`tasks`,B=G(e=>e.tasks),H=G(e=>e.elicitation),me=G(e=>e.ultraplanPendingChoice),he=G(e=>e.ultraplanLaunchPending),ge=G(e=>e.viewingAgentTaskId),U=Yr(),ve=ge?B[ge]:void 0,ye=ud(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;Bu(Ii(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!ud(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[ge,ye,U]);let be=br(),xe=E(),Se=Gg(),[Ce,we]=(0,Q.useState)(t);ek(A?void 0:dt(),we);let Te=Q.useSyncExternalStore(FM?.subscribeToProactiveChanges??IM,FM?.isProactiveActive??LM),Ee=Q.useSyncExternalStore(FM?.subscribeToProactiveChanges??IM,FM?.getNextTickAt??RM),De=G(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>_r(I),[I,Te,De]);Xk();let[ke,Ae]=(0,Q.useState)(f),je=(0,Q.useCallback)(e=>{Ae(e)},[Ae]),[Pe,Fe]=(0,Q.useState)(`prompt`),[Ie,Re]=(0,Q.useState)(!1),[Be,Ve]=(0,Q.useState)(!1),[He,We]=(0,Q.useState)(``),Ge=(0,Q.useRef)(0),Ke=(0,Q.useRef)(void 0),Je=(0,Q.useRef)(!1),{addNotification:Ze,removeNotification:Qe}=di(),$e=zM,et=QO(d,R.clients),[at,pt]=(0,Q.useState)(void 0),[mt,_t]=(0,Q.useState)(null),[yt,bt]=(0,Q.useState)(null),[St,Ct]=(0,Q.useState)(!1),[wt,Tt]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&GM()),Et=G(e=>e.showRemoteCallout),[Dt,Ot]=(0,Q.useState)(()=>dv());KA(),YA(),WA({ideSelection:at,mcpClients:et,ideInstallationStatus:yt}),nA({mcpClients:et}),MA(),NA(),__(),zA(Se),tj(),BA(Se),HA(),PM(),Ik(),Uk(),aA();let{recommendation:kt,handleResponse:At}=xA(),{recommendation:jt,handleResponse:Mt}=wA(),Nt=jA(),It=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);rg({enabled:!A});let Lt=Zt();(0,Q.useEffect)(()=>{A||IA(U)},[U,A]);let Rt=Lg(It,R.tools,I),{tools:zt,allowedAgentTypes:Vt}=(0,Q.useMemo)(()=>{if(!F)return{tools:Rt,allowedAgentTypes:void 0};let e=dn(F,Rt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[F,Rt]),Ht=$O($O(Ce,z.commands),R.commands),Ut=(0,Q.useMemo)(()=>C?[]:Ht,[C,Ht]);jy(A?qM:R.clients),nk(A?qM:R.clients,pt);let[Wt,Gt]=(0,Q.useState)(`responding`),qt=(0,Q.useRef)(Wt);qt.current=Wt;let[Jt,Yt]=(0,Q.useState)([]),[Xt,Qt]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Xt&&!Xt.isStreaming&&Xt.streamingEndedAt){let e=3e4-(Date.now()-Xt.streamingEndedAt);if(e>0){let t=setTimeout(Qt,e,null);return()=>clearTimeout(t)}else Qt(null)}},[Xt]);let[$t,en]=(0,Q.useState)(null),tn=(0,Q.useRef)(null);tn.current=$t;let nn=(0,Q.useRef)(0),[rn,an]=(0,Q.useState)(!1),sn=(0,Q.useRef)(()=>{}),ln=(0,Q.useRef)(()=>{}),un=(0,Q.useRef)(null),mn=(0,Q.useRef)(null),hn=(0,Q.useRef)(0),gn=Q.useRef(new dy).current,vn=Q.useSyncExternalStore(gn.subscribe,gn.getSnapshot),[yn,bn]=Q.useState(D?.hasInitialPrompt??!1),W=vn||yn,[xn,Sn]=Q.useState(void 0),Cn=Q.useRef(0),wn=Q.useRef(!1),En=Q.useRef(0),On=Q.useRef(0),kn=Q.useRef(null),An=Q.useCallback(()=>{En.current=Date.now(),On.current=0,kn.current=null},[]),jn=Q.useRef(!1);vn&&!jn.current&&An(),jn.current=vn;let Mn=Q.useCallback(e=>{bn(e),e&&An()},[An]),Nn=Q.useRef(void 0),[Fn,In]=Q.useState(!1),[Ln,Rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Ln?.notifications&&Ln.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Ln,Ze]),(0,Q.useEffect)(()=>{la()&&Mr().then(e=>{e&&Ze({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-DM6SBMwl.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-DRSwLozU.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),nn.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,$n]=(0,Q.useState)([]),er=(0,Q.useRef)(new Map),rr=G(e=>e.settings.terminalTitleFromRename)===!1?void 0:xl(st()),[ir,ar]=(0,Q.useState)(),or=(0,Q.useRef)((i?.length??0)>0),cr=F?.agentType,lr=rr??cr??ir??`Work Mate`,ur=Gn.length>0||Zn.length>0,fr=Vn?.isLocalJSXCommand===!0&&Vn?.jsx!=null,pr=W&&!ur&&!fr;(0,Q.useEffect)(()=>{if(W&&!ur&&!fr)return iy(),()=>ay()},[W,ur,fr]);let mr=ur||fr?`waiting`:W?`busy`:`idle`,hr=mr===`waiting`?Gn.length>0?`approve ${Gn[0].tool.name}`:fr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{hi({status:mr,waitingFor:hr})},[mr,hr]),P(null);let[K,gr]=(0,Q.useState)(i??[]),vr=(0,Q.useRef)(K),yr=(0,Q.useRef)(!1),q=(0,Q.useCallback)(e=>{let t=vr.current,n=typeof e==`function`?e(vr.current):e;if(vr.current=n,n.length<Cn.current)Cn.current=0;else if(n.length>t.length&&wn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(qa)?wn.current=!1:Cn.current=n.length}gr(n)},[]),xr=(0,Q.useCallback)(e=>{e===void 0?wn.current=!1:(Cn.current=vr.current.length,wn.current=!0),Sn(e)},[]),{dividerIndex:Sr,dividerYRef:Cr,onScrollAway:wr,onRepin:Tr,jumpToNew:Er,shiftDivider:Dr}=K_(K.length);Lk(K,q,W);let[Or,Ar]=(0,Q.useState)(null),jr=(0,Q.useRef)(null),Nr=(0,Q.useMemo)(()=>U_(K,Sr),[Sr,K.length]),Pr=(0,Q.useCallback)(()=>{un.current?.scrollToBottom(),Tr(),Ar(null)},[Tr,Ar]),Fr=K.at(-1),Ir=Fr!=null&&qa(Fr);(0,Q.useEffect)(()=>{Ir&&Pr()},[Ir,Fr,Pr]);let{maybeLoadOlder:Rr}=cO({config:D,setMessages:q,scrollRef:un,onPrepend:Dr}),zr=(0,Q.useCallback)((e,t)=>{hn.current=Date.now(),e?Tr():(wr(t),Rr(t))},[Tr,wr,Rr,U]),Br=wO(o,q),Vr=(0,Q.useDeferredValue)(Q.useMemo(()=>K.length>500?K.slice(-500):K,[K])),Hr=K.length-Vr.length;Hr>0&&Y(`[useDeferredValue] Messages deferred by ${Hr} (${Vr.length}→${K.length})`);let[Ur,Wr]=(0,Q.useState)(null),[Gr,Kr]=(0,Q.useState)(()=>iv()),Jr=(0,Q.useRef)(Gr);Jr.current=Gr;let Xr=(0,Q.useRef)(null),Zr=(0,Q.useCallback)(e=>{$e(Jr.current,e)||(Jr.current===``&&e!==``&&Date.now()-hn.current>=JM&&Pr(),Jr.current=e,Kr(e),In(e.trim().length>0))},[In,Pr,$e]);(0,Q.useEffect)(()=>{if(Gr.trim().length===0)return;let e=setTimeout(In,1500,!1);return()=>clearTimeout(e)},[Gr]);let[Qr,$r]=(0,Q.useState)(`prompt`),[ti,ni]=(0,Q.useState)(),ri=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||ka.has(e)))},[we]),[ii,oi]=(0,Q.useState)(new Set),si=(0,Q.useRef)(!1),ci=qD({config:D,setMessages:q,setIsLoading:Mn,onInit:ri,setToolUseConfirmQueue:Kn,tools:It,setStreamingToolUses:Yt,setStreamMode:Gt,setInProgressToolUseIDs:oi}),li=XD({config:O,setMessages:q,setIsLoading:Mn,setToolUseConfirmQueue:Kn,tools:It}),ui=ZD({session:k,setMessages:q,setIsLoading:Mn,setToolUseConfirmQueue:Kn,tools:It}),fi=ui.isRemoteMode?ui:li.isRemoteMode?li:ci,[pi,mi]=(0,Q.useState)({}),[gi,_i]=(0,Q.useState)(0),vi=(0,Q.useRef)(0),yi=(0,Q.useRef)([]),bi=(0,Q.useCallback)(e=>{let t=vi.current;if(vi.current=e(t),vi.current>t){let e=yi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=vi.current}}},[]),[xi,Si]=(0,Q.useState)(null),Ti=!(G(e=>e.settings.prefersReducedMotion)??!1)&&!V(),Ei=(0,Q.useCallback)(e=>{Ti&&Si(e)},[Ti]),Di=xi&&Ti&&xi.substring(0,xi.lastIndexOf(`
138
+ `)+1)||null,[Oi,ji]=(0,Q.useState)(0),[Mi,Ni]=(0,Q.useState)(null),[Pi,Fi]=(0,Q.useState)(null),[Li,Ri]=(0,Q.useState)(null),[zi,Bi]=(0,Q.useState)(!1),[Vi,Hi]=(0,Q.useState)(void 0),[Ui,Wi]=(0,Q.useState)(!1),[Gi,Ki]=(0,Q.useState)(kv()),[qi,Ji]=(0,Q.useState)(null),Yi=(0,Q.useRef)(!1),Xi=(0,Q.useRef)(Oi);Xi.current=Oi;let[J]=(0,Q.useState)(()=>({current:ei(i,c)}));cl(()=>{J.current=ta()});let[Zi,Qi]=(0,Q.useState)(Rf().hasAcknowledgedCostThreshold),[$i,ea]=(0,Q.useState)(`INSERT`),[ra,ia]=(0,Q.useState)(!1),[oa,sa]=(0,Q.useState)(!1),[ca,ua]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&ra&&ia(!1)},[me,ra]);let da=j(),pa=(0,Q.useRef)(da);pa.current=da;let[ma]=y(),ha=Q.useRef(!1),_a=(0,Q.useCallback)(()=>{if(ha.current)return;ha.current=!0;let e=vr.current.slice(Ua.current);for(let t of Pd(e))Ha.current.add(t);Ua.current=vr.current.length,Gk({theme:ma,readFileState:Va.current,bashTools:Ha.current}).then(async e=>{if(e){let t=await e.content({theme:ma});U(e=>({...e,spinnerTip:t})),Kk(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,ma]),va=(0,Q.useCallback)(()=>{Mn(!1),xr(void 0),vi.current=0,yi.current=[],Si(null),Yt([]),Ni(null),Fi(null),Ri(null),_a(),hh(),Il()},[_a]),ya=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(I.mode!==`auto`){ya.current=!1;return}if(ya.current||(Rf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Lf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,ec(rA,`warning`)])},800,ya,q);return()=>clearTimeout(e)}},[I.mode,q]);let ba=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ba.current)return;let e=_n();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ba.current=!0;let t=Math.round(e.creationDurationMs/1e3);q(e=>[...e,ec(`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`)])},[q]);let xa=(0,Q.useMemo)(()=>{let e=K.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`&&ii.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[K,ii]),{onBeforeQuery:Ca,onTurnComplete:wa,render:Ta}=xO({enabled:te,setMessages:q,inputValue:Gr,setInputValue:Zr,setToolJSX:Wn}),Ea=(!Vn||Vn.showSpinner===!0)&&Gn.length===0&&Zn.length===0&&(W||xn||md()>0)&&!xa&&(!Di||De),Da=Gn.length>0||Zn.length>0||Yn.length>0||H.queue.length>0,Aa=yk(K,W,gi,`session`,Da),ja=bO(q),Ma=hj(K,gi),Pa=(0,Q.useMemo)(()=>({...Aa,handleSelect:e=>{$a.current=!1;let t=Aa.handleSelect(e);e===`bad`&&!t&&ij(`feedback_survey_bad`)&&(Qa(`feedback_survey_bad`),$a.current=!0)}}),[Aa]),Ia=Dk(K,W,Da,{enabled:!A}),La=Ck(K,W,Da,{enabled:!A}),Ra=NM(K,W,Da,Pa.state!==`closed`||Ia.state!==`closed`||La.state!==`closed`);uk({autoConnectIdeFlag:p,ideToInstallExtension:mt,setDynamicMcpConfig:Ae,setShowIdeOnboarding:Ct,setIDEInstallationState:bt}),Zk(s,se,e=>U(t=>({...t,fileHistory:e})));let za=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Ci(n.messages),o=js();await Ko(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await Na(`resume`,{sessionId:t,agentType:F?.agentType,model:Se});a.push(...s),r===`fork`?Xo(n,qc(t)):Sa(n,qc(t)),Tg(n,U),n.fileHistorySnapshots&&xs(n);let{agentDefinition:c}=Cg(n.agentSetting,S,ae);re(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:wg(n.agentName,n.agentColor)})),na(n.agentName),Ja(a,n.projectPath??ut()),va(),en(null),Ki(t);let l=ga(t);Du(),ht(),gt(qc(t),n.fullPath?bv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-BsWpcxrc.js`);if(await u(),await $s(),kl(),ql(n),n.goal){let{hydrateGoalFromTranscript:r}=(To(),e(Mo)),i=new Map;i.set(t,n.goal),r(i,t)}if(or.current=!0,ar(void 0),r!==`fork`)Eg(),Dg(n.worktreeSession),Lr(),Tc({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=_n();e&&fn(e)}l&&rt(l),J.current&&r!==`fork`&&(J.current=Oa(a,n.contentReplacements??[])),q(()=>a),Wn(null),Zr(``),Z(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Z(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[va,U]),[Ba]=(0,Q.useState)(()=>Qm(100)),Va=(0,Q.useRef)(Ba),Ha=(0,Q.useRef)(new Set),Ua=(0,Q.useRef)(0),Wa=(0,Q.useRef)(new Set),Ga=(0,Q.useRef)(new Set),Ja=(0,Q.useCallback)((e,t)=>{let n=Kt(e,t,100);Va.current=eh(Va.current,n);for(let t of Pd(e))Ha.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Ja(i,ut()),Tc({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:Ya,reverify:Xa}=TO(),[Za,Qa]=(0,Q.useState)(null),$a=(0,Q.useRef)(!1),[eo,to]=(0,Q.useState)(null),[no,ro]=(0,Q.useState)(!1),ao=!W&&Ui;function oo(){if(no||eo)return;if(zi)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&&H.queue[0])return`elicitation`;if(e&&ao)return`cost`;if(e&&qi)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&St)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&wt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&zn)return`undercover-callout`;if(e&&Et)return`remote-callout`;if(e&&kt)return`lsp-recommendation`;if(e&&jt)return`plugin-hint`;if(e&&Nt.visible)return`search-extra-tools-hint`;if(e&&Dt)return`desktop-upsell`}let co=oo(),lo=Fn&&(Yn[0]||Gn[0]||Zn[0]||H.queue[0]||ao);Nn.current=co,(0,Q.useEffect)(()=>{if(!W)return;let e=co===`tool-permission`,t=Date.now();e&&kn.current===null?kn.current=t:!e&&kn.current!==null&&(On.current+=t-kn.current,kn.current=null)},[co,W]);let uo=(0,Q.useRef)(co);(0,Q.useLayoutEffect)(()=>{uo.current===`tool-permission`!=(co===`tool-permission`)&&Pr(),uo.current=co},[co,Pr]);function fo(){if(co!==`elicitation`){if(nn.current!==0&&Date.now()-nn.current<500){nn.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(nn.current=0,Y(`[onCancel] focusedInputDialog=${co} streamMode=${Wt}`),FM?.pauseProactive(),gn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(zu(),e(Ts)),{persistCurrentGoal:r}=(To(),e(Mo));t()?.status===`active`&&(n(),r())}if(an(!0),gn.forceEnd(),Yi.current=!1,xi?.trim()&&q(e=>[...e,Pl({content:xi})]),va(),tt(null),co===`tool-permission`)Gn[0]?.onAbort(),Kn([]);else if(co===`prompt`){for(let e of Zn)e.reject(Error(`Prompt cancelled by user`));$n([]),$t?.abort(`user-cancel`)}else fi.isRemoteMode?fi.cancelRequest():$t?.abort(`user-cancel`);en(null),wa(vr.current,!0)}}let po=(0,Q.useCallback)(()=>{let e=Jc(Gr,0);e&&(Zr(e.text),$r(`prompt`),e.images.length>0&&mi(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Zr,$r,Gr,mi]),mo={setToolUseConfirmQueue:Kn,onCancel:fo,onAgentsKilled:()=>q(e=>[...e,uu()]),isMessageSelectorVisible:zi||!!ra,screen:Pe,abortSignal:$t?.signal,popCommandFromQueue:po,vimMode:$i,isLocalJSXCommand:Vn?.isLocalJSXCommand,isSearchingHistory:oa,isHelpOpen:ca,inputMode:Qr,inputValue:Gr,streamMode:Wt};(0,Q.useEffect)(()=>{lt()>=5&&!Ui&&!Zi&&(Z(`tengu_cost_threshold_reached`,{}),Qi(!0),hm()&&Wi(!0))},[K,Ui,Zi]);let ho=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Xn(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=kv();t.sendRequest(n,og,{host:e.host},kv(),`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=er.current.get(e.host);if(i){for(let e of i)e();er.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=er.current.get(e.host)??[];a.push(i),er.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=Mu.getSandboxUnavailableReason();if(e){if(Mu.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),fa(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),Ze({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(T,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ze]),Mu.isSandboxingEnabled()&&Mu.initialize(ho).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Yd(e)}\n`),fa(1,`other`)});let go=(0,Q.useCallback)((e,t)=>{U(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Kn)},[U,Kn]),_o=UO(Kn,go),vo=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Ud(e.toolPermissionContext,e.mcp.tools),n=ug(It,t,e.toolPermissionContext.mode);return F?dn(F,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Ut,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:ee,mcpClients:ZO(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:yt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:ma,agentDefinitions:Vt?{...a.agentDefinitions,allowedAgentTypes:Vt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:U,messages:e,setMessages:q,updateFileHistoryState(e){U(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){U(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{x||Bi(!0)},onChangeAPIKey:Xa,readFileState:Va.current,setToolJSX:Wn,addNotification:Ze,appendSystemMessage:e=>q(t=>[...t,e]),sendOSNotification:e=>{Kv(e,xe)},onChangeDynamicMcpConfig:je,onInstallIDEExtension:_t,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ga.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Wa.current,setResponseLength:bi,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=vi.current;yi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Gt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Fi(`claudeBlue_FOR_SYSTEM_SPINNER`),Ri(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Ni(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Ni(`Compacting conversation`);break;case`compact_end`:Ni(null),Fi(null),Ri(null);break}},setInProgressToolUseIDs:oi,setHasInterruptibleToolInProgress:e=>{si.current=e},resume:za,setConversationId:Ki,requestPrompt:void 0,contentReplacementState:J.current}},[Ut,It,F,n,d,yt,ke,ma,Vt,be,U,Xa,Ze,q,je,za,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{$n(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,Ki]),{handleBackgroundSession:yo}=fk({setMessages:q,setIsLoading:Mn,resetLoadingState:va,setAbortController:en,onBackgroundQuery:(0,Q.useCallback)(()=>{$t?.abort(`background`);let e=Ft(e=>e.mode===`task-notification`);(async()=>{let t=vo(vr.current,[],new AbortController,Se),[n,r,i]=await Promise.all([fl(t.options.tools,Se,Array.from(I.additionalWorkingDirectories.keys()),t.options.mcpClients),on(),Fa()]),a=ai({mainThreadAgentDefinition:F,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await hd(e).catch(()=>[])).map(Td),s=new Set;for(let e of vr.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)));yd({messages:[...vr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:_o,toolUseContext:t,querySource:Pn()},description:lr,setAppState:U,agentDefinition:F})})()},[$t,Se,I,F,vo,h,g,_o,U])}),bo=(0,Q.useCallback)(t=>{tl(t,t=>{if(Ai(t)?(la()?q(e=>{let n=pn(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):q(()=>[t]),Ki(kv()),FM?.setContextBlocked(!1)):t.type===`progress`&&aa(t.data?.type)?q(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]}):q(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?FM?.setContextBlocked(!0):t.type===`assistant`&&FM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(_d(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}=(zu(),e(Ts)),{persistCurrentGoal:r}=(To(),e(Mo));t()?.status===`active`&&(n(),r(),Ze({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{bi(t=>t+e.length)},Gt,Yt,e=>{q(t=>t.filter(t=>t!==e)),sl(e.uuid)},Qt,e=>{let t=Date.now(),n=vi.current;yi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Ei)},[q,bi,Gt,Yt,Qt,Ei]),xo=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=ZO(d,be.getState().mcp.clients);ki.handleQueryStart(e);let t=Kl(e);t&&Iu(t)}if(Nh(),!M&&!rr&&!cr&&!or.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?_d(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(or.current=!0,Kh(n,new AbortController().signal).then(e=>{e?ar(e):or.current=!1},()=>{or.current=!1}))}if(be.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(Ai)&&(Ki(kv()),FM?.setContextBlocked(!1)),va(),en(null);return}let o=vo(e,t,n,a),{tools:s,mcpClients:c}=o.options;Al(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,Jk(I,U,be.getState().fastMode),fl(s,a,Array.from(I.additionalWorkingDirectories.keys()),c),on(),Fa()]),p={...u,...FM?.isProactiveActive()&&!pa.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Al(`query_context_loading_end`);let m=ai({mainThreadAgentDefinition:F,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,Al(`query_query_start`),ot(),ft(),it();for await(let t of Dn({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:_o,toolUseContext:o,querySource:Pn()}))bo(t);if(Al(`query_end`),process.env.USER_TYPE===`ant`&&yi.current.length>0){let e=yi.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=Ye(),a=Me(),o=Xe(),s=qe(),c=xt(),l=Ue(),u=Date.now()-En.current;q(e=>[...e,jc({ttftMs:r?YM(t):t[0],otps:r?YM(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:Bf()})])}va(),Au(),await v?.(vr.current)},[d,va,vo,I,U,h,v,g,_o,F,bo,rr,M]),So=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=gn.tryStart();if(s===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>_d(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{qu({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Zo.current=!1,an(!1),An(),q(t=>[...t,...e]),vi.current=0,tt((o?so(o):null)??Ne()),yi.current=[],Yt([]),Si(null);let s=vr.current;if(o&&await Ca(o,s,e.length),a&&o&&!await a(o,s))return!0;try{await xo(s,e,t,n,r,i)}catch(e){throw e}}finally{if(gn.end(s)){an(t.signal.aborted),ji(Date.now()),Yi.current=!1,va(),await wa(vr.current,t.signal.aborted),sn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&U(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Ne()!==null&&Ne()>0&&!t.signal.aborted&&(e={tokens:Le(),limit:Ne(),nudges:nt()}),tt(null);let n=Date.now()-En.current-On.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&q(t=>[...t,Jl(n,e,jf(t,kr))]),en(null)}if(t.signal.reason===`user-cancel`&&!gn.isActive&&Jr.current===``&&md()===0&&!be.getState().viewingAgentTaskId){let e=vr.current,t=e.findLast(fg);t&&mg(e,e.lastIndexOf(t))&&(Ec(),ln.current(t))}}return!0},[xo,U,va,gn,Ca,wa]),Co=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Co.current)return;Co.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?wu():void 0,{clearConversation:n}=await import(`./conversation-pUtvc-cE.js`);await n({setMessages:q,readFileState:Va.current,discoveredSkillNames:Wa.current,loadedNestedMemoryPaths:Ga.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:Ki}),or.current=!1,ar(void 0),Ha.current.clear(),Ua.current=0,t&&Oc(st(),t)}U(t=>{let n=e.mode?Sl(t.toolPermissionContext,Hx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=wi({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),Fu()&&Wl(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Br();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)wo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=tr();en(t),So([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Co)}t(e)},[ce,W,q,U,So,Se,zt]);let wo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Pr(),FM?.resumeProactive(),$o(e)){let n=Sc({content:e});q(e=>[...e,n]),r?.fromKeybinding||Po({display:Nu(e,Qr),pastedContents:pi}),Zr(``),t.setCursorOffset(0),t.clearBuffer(),mi({}),$r(`prompt`),pt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=Do(e,pi).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Ut.find(e=>Pu(e)&&(e.name===a||e.aliases?.includes(a)||bs(e)===a));s?.name===`clear`&&yr.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:yr.current,idleMinutes:Math.round((Date.now()-Xi.current)/6e4),messageCount:vr.current.length,totalInputTokens:ct()}),yr.current=!1);let c=gn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Jr.current.trim()&&(Zr(``),t.setCursorOffset(0),t.clearBuffer(),mi({}));let n=iu(e).filter(e=>pi[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(pi[t.id]?.content.length??0),0)}),Z(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Wn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!la())){let e=r?.displayArgs??o;i.push(ws(Ad(bs(s),e)),ws(`<${Qf}>${Ic(n)}</${Qf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Sc({content:e,isMeta:!0}))),i.length&&q(e=>[...e,...i]),ti!==void 0&&(Zr(ti.text),t.setCursorOffset(ti.cursorOffset),mi(ti.pastedContents),ni(void 0))},r=vo(vr.current,[],tr(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Wn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(fi.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Po({display:n?e:Nu(e,Qr),pastedContents:n?{}:pi}),Qr===`bash`&&sw(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||fi.isRemoteMode;if(ti!==void 0&&!i&&a?(Zr(ti.text),t.setCursorOffset(ti.cursorOffset),mi(ti.pastedContents),ni(void 0)):a&&(r?.fromKeybinding||(Zr(``),t.setCursorOffset(0)),mi({})),a&&($r(`prompt`),pt(void 0),_i(e=>e+1),t.clearBuffer(),ha.current=!1,!i&&Qr===`prompt`&&!n&&!fi.isRemoteMode&&(xr(e),An()),U(e=>({...e,attribution:bh(e.attribution,e=>{Vs(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await qr(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:q,readFileState:Va,cwd:ut()});if(t){let e=tr();en(e),So([],e,!0,[],Se)}return}if(fi.isRemoteMode&&!(i&&Ut.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Pu(t)&&(t.name===n||t.aliases?.includes(n)||bs(t)===n)})?.type===`local-jsx`)){let t=Object.values(pi),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=Sc({content:i,imagePasteIds:r});q(e=>[...e,o]),await fi.sendMessage(a,{uuid:o.uuid});return}await Br(),await GO({input:e,helpers:t,queryGuard:gn,isExternalLoading:yn,mode:Qr,commands:Ut,onInputChange:Zr,setPastedContents:mi,setToolJSX:Wn,getToolUseContext:vo,messages:vr.current,mainLoopModel:Se,pastedContents:pi,ideSelection:at,setUserInputOnProcessing:xr,setAbortController:en,abortController:$t,onQuery:So,setAppState:U,querySource:Pn(),onBeforeQuery:_,canUseTool:_o,addNotification:Ze,setMessages:q,streamMode:qt.current,hasInterruptibleToolInProgress:si.current}),(i||W)&&ti!==void 0&&(Zr(ti.text),t.setCursorOffset(ti.cursorOffset),mi(ti.pastedContents),ni(void 0))},[gn,W,yn,Qr,Ut,Zr,$r,mi,_i,pt,Wn,vo,Se,pi,at,xr,en,Ze,So,ti,ni,U,_,_o,ci,q,Br,Pr]),Oo=(0,Q.useCallback)(()=>{let e=Za?aj(Za):`/issue`;Qa(null),wo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${Yd(t)}`)})},[wo,Za]),ko=(0,Q.useCallback)(()=>{Qa(null)},[]),Ao=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;wo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[wo]),jo=(0,Q.useRef)(wo);jo.current=wo;let No=(0,Q.useCallback)(()=>{jo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Fo=(0,Q.useCallback)(async()=>{if(ro(!0),Bt()){Pv(`tmux`,[`detach-client`],{stdio:`ignore`}),ro(!1);return}if(_n()!==null){to((0,$.jsx)(S_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{to(null),ro(!1)}}));return}let e=await(await Ul.load()).call(()=>{});to(e),e===null&&ro(!1)},[]),Io=(0,Q.useCallback)(()=>{Bi(e=>!e)},[]),Lo=(0,Q.useCallback)(e=>{let t=vr.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),q(t.slice(0,n)),Ki(kv()),Id();let r=e.permissionMode;U(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}}))},[q,U]),Ro=(0,Q.useCallback)(e=>{Lo(e);let t=dr(e);if(t&&(Zr(t.text),$r(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}}}),mi(n)}}},[Lo,Zr]);ln.current=Ro;let zo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Ro,e)},[Ro]),Bo=e=>{let t=e.slice(0,24);return K.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Vo,handlers:Ho}=nc(Or,Ar,jr,{copy:e=>void ie(e).then(e=>{e&&process.stdout.write(e),Ze({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Bo(e.uuid),n=t>=0?K[t]:void 0;if(!n||!fg(n))return;let r=!await Zs(se,n.uuid),i=mg(K,t);r&&i?(fo(),zo(n)):(Hi(n),Bi(!0))}});async function Uo(){Xa();let e=await Pt();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
139
+ `);Y(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else Y(`No CLAUDE.md/rules files found`);for(let t of e)Va.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})}SO(rv()),fy(K,K.length===i?.length);let{sendBridgeResult:Wo}=ky(K,q,tn,Ut,Se);sn.current=Wo,CO();let Go=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(le.length<1){Go.current=!1;return}Go.current||(Go.current=!0,Lf(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[le.length]),YO({executeQueuedInput:(0,Q.useCallback)(async e=>{await GO({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:gn,commands:Ut,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Wn,getToolUseContext:vo,messages:K,mainLoopModel:Se,ideSelection:at,setUserInputOnProcessing:xr,setAbortController:en,onQuery:So,setAppState:U,querySource:Pn(),onBeforeQuery:_,canUseTool:_o,addNotification:Ze,setMessages:q,queuedCommands:e})},[gn,Ut,Wn,vo,K,Se,at,xr,_o,en,So,Ze,U,_]),hasActiveLocalJsxUI:fr,queryGuard:gn}),(0,Q.useEffect)(()=>{sr.recordUserActivity(),vt(!0)},[Gr,gi]),(0,Q.useEffect)(()=>{gi===1&&mv()},[gi]),(0,Q.useEffect)(()=>{if(W||gi===0||Oi===0)return;let e=setTimeout((e,t,n,r,i)=>{if(ze()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=Rf().messageIdleNotifThresholdMs&&Kv({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},Rf().messageIdleNotifThresholdMs,Oi,W,Vn,Nn,xe);return()=>clearTimeout(e)},[W,Vn,gi,Oi,xe]),(0,Q.useEffect)(()=>{},[Oi,W,Ze,Qe]);let qo=(0,Q.useCallback)((e,t)=>{if(gn.isActive||ms().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 Eo([n]),t=e.attachmentCommands[0];if(!t)return;let r=tr();en(r);let i=Sc({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await So([i],r,!0,[],Se)!==!1}catch(t){try{await Jo({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Kd(),priority:`later`})}catch(e){X(ef(e))}X(ef(t));return}if(a)try{let t=await Jo({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Kd(),priority:`later`});for(let e of t)qu(e)}catch(e){X(ef(e))}})().catch(e=>{X(ef(e))}),!0},[So,Se,be]),{relayPipeMessage:Yo,pipeReturnHadErrorRef:Zo}=HM();XO({isLoading:W,onSubmitMessage:qo}),G(e=>ng(e));let{routeToSelectedPipes:$o}=UM({store:be,setAppState:U,addNotification:Ze});process.env.USER_TYPE===`ant`&&sk({taskListId:w,isLoading:W,onSubmitTask:qo}),BM?.({isLoading:W||ce!==null,queuedCommandsLength:le.length,hasActiveLocalJsxUI:fr,isInPlanMode:I.mode===`plan`,onQueueTick:e=>qu(e)}),VM?.({isLoading:W||ce!==null,wasAborted:rn,queuedCommandsLength:le.length,hasActiveLocalJsxUI:fr,isInPlanMode:I.mode===`plan`,isQueryActiveNow:gn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;q(e=>[...e,Sc({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Ze({key:`goal-max-turns-reached`,text:`Goal reached max continuation turns (1). Run /goal continue to reset turn counter and continue.`,priority:`immediate`})}}),(0,Q.useEffect)(()=>{if(!Te){sh(null);return}if(!W){if(Ee!==null&&le.length===0&&!fr&&I.mode!==`plan`&&ce===null){sh({enabled:!0,phase:`standby`,next_tick_at:Ee,sleep_until:null});return}sh({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ce,W,fr,Te,Ee,le.length,I.mode]),(0,Q.useEffect)(()=>{le.some(e=>e.priority===`now`)&&tn.current?.abort(`interrupt`)},[le]);let es=(0,Q.useRef)(Uo);es.current=Uo;let ts=(0,Q.useRef)(ki);ts.current=ki,(0,Q.useEffect)(()=>(es.current(),()=>{ts.current.shutdown()}),[]);let{internal_eventEmitter:ns}=ne(),[rs,is]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
140
+ Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
141
+ Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
142
+ `)},t=()=>{is(e=>e+1)};return ns?.on(`suspend`,e),ns?.on(`resume`,t),()=>{ns?.off(`suspend`,e),ns?.off(`resume`,t)}},[ns]);let as=(0,Q.useMemo)(()=>{if(!W)return null;let e=K.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||K.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=jf(K,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?` '${Ep(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}`},[K,W]),os=(0,Q.useCallback)(()=>{Wr({messagesLength:K.length,streamingToolUsesLength:Jt.length})},[K.length,Jt.length]),ss=(0,Q.useCallback)(()=>{Wr(null)},[]),cs=la()&&!N,ls=(0,Q.useRef)(null),[us,ds]=(0,Q.useState)(!1),[fs,ps]=(0,Q.useState)(``),[hs,gs]=(0,Q.useState)(0),[_s,vs]=(0,Q.useState)(0),ys=(0,Q.useCallback)((e,t)=>{gs(e),vs(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){ls.current?.setAnchor(),ds(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&hs>0){let t=r===`n`?ls.current?.nextMatch:ls.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&cs&&!us&&!Be});let{setQuery:Ss,scanElement:Cs,setPositions:Es}=fe(),Ds=de().columns,Os=Q.useRef(Ds);Q.useEffect(()=>{Os.current!==Ds&&(Os.current=Ds,(fs||us)&&(ds(!1),ps(``),gs(0),vs(0),ls.current?.disarmSearch(),Ss(``)))},[Ds,fs,us,Ss]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ss(),n.stopImmediatePropagation();return}if(e===`[`&&!Be)Ve(!0),Re(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Je.current)return;Je.current=!0;let e=Ge.current,t=t=>{e===Ge.current&&(clearTimeout(Ke.current),We(t))};t(`rendering ${Vr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Hv(Vr,zt,e)).replace(/[ \t]+$/gm,``),r=Sv(_v(),`cc-transcript-${Date.now()}.txt`);await Mv(r,n);let i=Hg(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Je.current=!1,e===Ge.current&&(Ke.current=setTimeout(e=>e(``),4e3,We))})()}}},{isActive:Pe===`transcript`&&cs&&!us});let ks=Pe===`transcript`&&cs;(0,Q.useEffect)(()=>{ks||(ps(``),gs(0),vs(0),ds(!1),Ge.current++,clearTimeout(Ke.current),Ve(!1),We(``))},[ks]),(0,Q.useEffect)(()=>{Ss(ks?fs:``),ks||Es(null)},[ks,fs,Ss,Es]);let As={screen:Pe,setScreen:Fe,showAllInTranscript:Ie,setShowAllInTranscript:Re,messageCount:K.length,onEnterTranscript:os,onExitTranscript:ss,virtualScrollActive:cs,searchBarOpen:us},Ms=Ur?Vr.slice(0,Ur.messagesLength):Vr,Ns=Ur?Jt.slice(0,Ur.streamingToolUsesLength):Jt;jO({onOpenBackgroundTasks:fr?void 0:()=>ia(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Ps=ge?B[ge]:void 0,Fs=Ps&&ud(Ps)?Ps:void 0,Is=Ti||!W,Ls=Fs?.messages,Rs=(0,Q.useMemo)(()=>{if(!Fs)return;let e=Ls??[];if(!ud(Fs)||Fs.agentType!==`fork`||!Fs.prompt)return e;let t=Fs.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(rN))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=>!rN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Sc({content:Fs.prompt,timestamp:new Date(Fs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Fs,Ls]),zs=Fs?Rs??[]:Is?K:Vr;if(Pe===`transcript`){let e=la()&&!N&&!Be?un:void 0,t=(0,$.jsx)(Y_,{messages:Ms,tools:zt,commands:Ut,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:ii,isMessageSelectorVisible:!1,conversationId:Gi,screen:Pe,agentDefinitions:ae,streamingToolUses:Ns,showAllInTranscript:Ie,onOpenRateLimitOptions:No,isLoading:W,hidePastThinking:!0,streamingThinking:Xt,scrollRef:e,jumpRef:ls,onSearchMatchesChange:ys,scanElement:Cs,setPositions:Es,disableRenderCap:Be}),n=Vn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),r=(0,$.jsxs)(wd,{children:[(0,$.jsx)(tN,{isAnimating:pr,title:lr,disabled:M,noPrefix:!1}),(0,$.jsx)(EO,{...As}),(0,$.jsx)(OO,{onSubmit:wo,isActive:!Vn?.isLocalJSXCommand}),e?(0,$.jsx)(Zj,{scrollRef:un,isActive:co!==`ultraplan-choice`,isModal:!us,onScroll:()=>ls.current?.disarmSearch()}):null,(0,$.jsx)(AO,{...mo}),e?(0,$.jsx)(q_,{scrollRef:un,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(eA,{})]}),bottom:us?(0,$.jsx)(ZM,{jumpRef:ls,initialQuery:``,count:hs,current:_s,onClose:e=>{ps(hs>0?e:``),ds(!1),e||(gs(0),vs(0),ls.current?.setSearchQuery(``))},onCancel:()=>{ds(!1),ls.current?.setSearchQuery(``),ls.current?.setSearchQuery(fs),Ss(fs)},setHighlight:Ss}):(0,$.jsx)(XM,{showAllInTranscript:Ie,virtualScroll:!0,status:He||void 0,searchBadge:fs&&hs>0?{current:_s,count:hs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(eA,{}),(0,$.jsx)(XM,{showAllInTranscript:Ie,virtualScroll:!1,suppressShowAll:Be,status:He||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:nr(),children:r}):r}let Bs=xn&&!Fs&&zs.length<=Cn.current?xn:void 0,Hs=co===`tool-permission`?(0,$.jsx)(MS,{onDone:()=>Kn(([e,...t])=>t),onReject:po,toolUseConfirm:Gn[0],toolUseContext:vo(K,K,$t??tr(),Se),verbose:L,setStickyFooter:la()?Jn:void 0},Gn[0]?.toolUseID):null,Us=la()&&Vn?.isLocalJSXCommand===!0,Ws=Us?Vn.jsx:null,Gs=(0,$.jsxs)(wd,{children:[(0,$.jsx)(tN,{isAnimating:pr,title:lr,disabled:M,noPrefix:!1}),(0,$.jsx)(EO,{...As}),(0,$.jsx)(OO,{onSubmit:wo,isActive:!Vn?.isLocalJSXCommand}),(0,$.jsx)(Zj,{scrollRef:un,isActive:la()&&(Ws!=null||!co||co===`tool-permission`),onScroll:zr}),null,(0,$.jsx)(AO,{...mo}),(0,$.jsx)(ag,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(q_,{scrollRef:un,overlay:Hs,modal:Ws,modalScrollRef:mn,dividerYRef:Cr,hidePill:!!Fs,newMessageCount:Nr?.count??0,onPillClick:()=>{Ar(null),Er(un.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y_,{messages:zs,tools:zt,commands:Ut,verbose:L,toolJSX:Vn,toolUseConfirmQueue:Gn,inProgressToolUseIDs:ii,isMessageSelectorVisible:zi,conversationId:Gi,screen:Pe,streamingToolUses:Jt,showAllInTranscript:Ie,agentDefinitions:ae,onOpenRateLimitOptions:No,isLoading:W,streamingText:W&&!Fs?Di:null,isBriefOnly:!Fs&&De,unseenDivider:Fs?void 0:Nr,scrollRef:la()?un:void 0,trackStickyPrompt:la()?!0:void 0,cursor:Or,setCursor:Ar,cursorNavRef:jr}),(0,$.jsx)(RA,{}),!x&&Bs&&!Ws&&(0,$.jsx)(Qn,{param:{text:Bs,type:`text`},addMargin:!0,verbose:L}),Vn&&!(Vn.isLocalJSXCommand&&Vn.isImmediate)&&!Us&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(sj,{}),(0,$.jsx)(b,{flexGrow:1}),Ea&&(0,$.jsx)(Ka,{mode:Wt,spinnerTip:ue,responseLengthRef:vi,apiMetricsRef:yi,overrideMessage:Mi,spinnerSuffix:as,verbose:L,loadingStartTimeRef:En,totalPausedMsRef:On,pauseStartTimeRef:kn,overrideColor:Pi,overrideShimmerColor:Li,hasActiveTools:ii.size>0,leaderIsIdle:!W}),!Ea&&!W&&!xn&&De&&!Fs&&(0,$.jsx)(cn,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[la()&&(0,$.jsx)(mD,{}),qn,Vn?.isLocalJSXCommand&&Vn.isImmediate&&!Us&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Vn.jsx}),!Ea&&!Vn?.isLocalJSXCommand&&pe&&Lt&&Lt.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(io,{tasks:Lt,isStandalone:!0})}),co===`sandbox-permission`&&(0,$.jsx)(Qk,{hostPattern:Yn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Yn[0];if(!r)return;let i=r.hostPattern.host;Xn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=er.current.get(i);if(a){for(let e of a)e();er.current.delete(i)}}},Yn[0].hostPattern.host),co===`prompt`&&(0,$.jsx)(nC,{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}),$n(([,...e])=>e))},onAbort:()=>{let e=Zn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),$n(([,...e])=>e))}},Zn[0].request.prompt),co===`elicitation`&&(0,$.jsx)($S,{event:H.queue[0],onResponse:(e,t)=>{let n=H.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=H.queue[0];U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},H.queue[0].serverName+`:`+String(H.queue[0].requestId)),co===`cost`&&(0,$.jsx)(Uv,{onDone:()=>{Wi(!1),Qi(!0),Lf(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),co===`idle-return`&&qi&&(0,$.jsx)(Wv,{idleMinutes:qi.idleMinutes,totalInputTokens:ct(),onDone:async e=>{let t=qi;if(Ji(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:vr.current.length,totalInputTokens:ct()}),e===`dismiss`){Zr(t.input);return}if(e===`never`&&Lf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-pUtvc-cE.js`);await e({setMessages:q,readFileState:Va.current,discoveredSkillNames:Wa.current,loadedNestedMemoryPaths:Ga.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:Ki}),or.current=!1,ar(void 0),Ha.current.clear(),Ua.current=0}Yi.current=!0,jo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),co===`ide-onboarding`&&(0,$.jsx)(Tn,{onDone:()=>Ct(!1),installationStatus:yt}),process.env.USER_TYPE===`ant`&&co===`model-switch`&&WM&&(0,$.jsx)(WM,{onDone:(e,t)=>{Tt(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&co===`undercover-callout`&&KM&&(0,$.jsx)(KM,{onDone:()=>Bn(!1)}),co===`remote-callout`&&(0,$.jsx)(Qg,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),eo,co===`plugin-hint`&&jt&&(0,$.jsx)(EA,{pluginName:jt.pluginName,pluginDescription:jt.pluginDescription,marketplaceName:jt.marketplaceName,sourceCommand:jt.sourceCommand,onResponse:Mt}),co===`search-extra-tools-hint`&&Nt.visible&&(0,$.jsx)(OA,{tools:Nt.tools,onSelect:Nt.handleSelect,onDismiss:Nt.handleDismiss}),co===`lsp-recommendation`&&kt&&(0,$.jsx)(CA,{pluginName:kt.pluginName,pluginDescription:kt.pluginDescription,fileExtension:kt.fileExtension,onResponse:At}),co===`desktop-upsell`&&(0,$.jsx)(lv,{onDone:()=>Ot(!1)}),co===`ultraplan-choice`&&me&&(0,$.jsx)(xj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:q,readFileState:Va.current,getAppState:()=>be.getState(),setConversationId:Ki}),co===`ultraplan-launch`&&he&&(0,$.jsx)(wj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;q(e=>[...e,ws(Ad(`ultraplan`,n))]);let r=e=>q(t=>[...t,ws(`<local-command-stdout>${Ic(e)}</local-command-stdout>`)]);au({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:tr().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!gn.isActive){r(e);return}let t=gn.subscribe(()=>{gn.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),Ta(),!Vn?.shouldHidePromptInput&&!co&&!no&&!x&&!Or&&(0,$.jsxs)($.Fragment,{children:[Za&&(0,$.jsx)(rj,{onRun:Oo,onCancel:ko,reason:oj(Za)}),Ia.state===`closed`?La.state===`closed`?(0,$.jsx)(Mk,{state:Pa.state,lastResponse:Pa.lastResponse,handleSelect:Pa.handleSelect,handleTranscriptSelect:Pa.handleTranscriptSelect,inputValue:Gr,setInputValue:Zr,onRequestFeedback:$a.current?void 0:Ao}):(0,$.jsx)(Mk,{state:La.state,lastResponse:La.lastResponse,handleSelect:La.handleSelect,handleTranscriptSelect:La.handleTranscriptSelect,inputValue:Gr,setInputValue:Zr,onRequestFeedback:Ao,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(Mk,{state:Ia.state,lastResponse:Ia.lastResponse,handleSelect:Ia.handleSelect,inputValue:Gr,setInputValue:Zr,onRequestFeedback:Ao}),Ra.state!==`closed`&&(0,$.jsx)(Mk,{state:Ra.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ra.handleTranscriptSelect,inputValue:Gr,setInputValue:Zr}),ja.suggestion&&(0,$.jsx)(gO,{isOpen:ja.isOpen,skillName:ja.suggestion.skillName,updates:ja.suggestion.updates,handleSelect:ja.handleSelect,inputValue:Gr,setInputValue:Zr}),Ma&&(0,$.jsx)(cj,{}),(0,$.jsx)(ND,{debug:n,ideSelection:at,hasSuppressedDialogs:!!lo,isLocalJSXCommandActive:fr,getToolUseContext:vo,toolPermissionContext:I,setToolPermissionContext:go,apiKeyStatus:Ya,commands:Ut,agents:ae.activeAgents,isLoading:W,onExit:Fo,verbose:L,messages:K,onAutoUpdaterResult:Rn,autoUpdaterResult:Ln,input:Gr,onInputChange:Zr,mode:Qr,onModeChange:$r,stashedPrompt:ti,setStashedPrompt:ni,submitCount:gi,onShowMessageSelector:Io,onMessageActionsEnter:void 0,mcpClients:et,pastedContents:pi,setPastedContents:mi,vimMode:$i,setVimMode:ea,showBashesDialog:ra,setShowBashesDialog:ia,onSubmit:wo,isSearchingHistory:oa,setIsSearchingHistory:sa,helpOpen:ca,setHelpOpen:ua,insertTextRef:Xr}),(0,$.jsx)(dk,{onBackgroundSession:yo,isLoading:W}),(0,$.jsx)(ak,{})]}),Or&&(0,$.jsx)(Ll,{cursor:Or}),co===`message-selector`&&(0,$.jsx)(_g,{messages:K,preselectedMessage:Vi,onPreRestore:fo,onRestoreCode:async e=>{await vc(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=pn(K),i=r.indexOf(e);if(i===-1){q(e=>[...e,ec(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=tr(),o=vo(r,[],a,Se),s=o.getAppState(),c=await fl(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=ai({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([on(),Fa()]),f=await dc(r,i,o,{systemPrompt:l,userContext:u,systemContext:d,toolUseContext:o,forkContextMessages:r},t,n),p=f.messagesToKeep??[],m=n===`up_to`?[...f.summaryMessages,...p]:[...p,...f.summaryMessages],h=[f.boundaryMarker,...m,...f.attachments,...f.hookResults];if(la()&&n===`from`?q(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):q(h),FM?.setContextBlocked(!1),Ki(kv()),Lu(o.options.querySource),n===`from`){let t=dr(e);t&&(Zr(t.text),$r(t.mode))}let g=Qo(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:zo,onClose:()=>{Bi(!1),Hi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(_j,{})]})})})},rs)]});return la()?(0,$.jsx)(_e,{mouseTracking:nr(),children:Gs}):Gs}export{iN as t};