@readmagic/workmate 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-mANiG0xj.js → AddWorkspaceDirectory-BTC7FPqM.js} +1 -1
  2. package/dist/chunks/{App-aUVaOLeo.js → App-DOm71vtY.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-36iUE5CW.js → ApproveApiKey-9YQzwrrC.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-LPrZMlgU.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-BLcvdkgb.js → AssistantSessionChooser-CnYfFWrx.js} +1 -1
  6. package/dist/chunks/{BackgroundTasksDialog-DyjVt81B.js → BackgroundTasksDialog-D_UHm7xo.js} +1 -1
  7. package/dist/chunks/{BypassPermissionsModeDialog-CTlpvTuz.js → BypassPermissionsModeDialog-DAq-qbqC.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--w2zWWEn.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-5pipE8m8.js → ClaudeMdExternalIncludesDialog-CyvidoR3.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-BXdC6j3_.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-Blg1TVut.js → DesktopHandoff-gRvy-WlW.js} +1 -1
  12. package/dist/chunks/{DiffDialog-CUEpuocY.js → DiffDialog-CdfVTgOx.js} +1 -1
  13. package/dist/chunks/Doctor-BuiYwjAS.js +1 -0
  14. package/dist/chunks/{Doctor-DlE1Mbb9.js → Doctor-DKlHJBXq.js} +1 -1
  15. package/dist/chunks/{ExitFlow-DCIhnP5h.js → ExitFlow-rExuBL3w.js} +1 -1
  16. package/dist/chunks/{Feedback-CDTqPqsM.js → Feedback-gGpjUC_F.js} +1 -1
  17. package/dist/chunks/{Grove-D9lSG_Lh.js → Grove-CD769Wvw.js} +1 -1
  18. package/dist/chunks/Grove-ENfM8hC6.js +1 -0
  19. package/dist/chunks/{HybridTransport-8j0AviF6.js → HybridTransport-kN1jmg26.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-I3t-0nU3.js → InvalidConfigDialog-BpJub73a.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-BnthOxGT.js → InvalidSettingsDialog-DzOp3Ihx.js} +1 -1
  22. package/dist/chunks/{MCPConnectionManager-zdocEDgk.js → MCPConnectionManager-CaBvO7NB.js} +1 -1
  23. package/dist/chunks/{McpParsingWarnings-D0XvLirX.js → McpParsingWarnings-Cc6FWyU4.js} +1 -1
  24. package/dist/chunks/{MessageSelector-BBhCstBa.js → MessageSelector-DOB1S2-O.js} +1 -1
  25. package/dist/chunks/{Messages-Dv2VrytX.js → Messages-Clihwd2F.js} +2 -2
  26. package/dist/chunks/{Onboarding-B1WRpoBI.js → Onboarding-D00lTweB.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-BSmgq089.js → OverageCreditUpsell-B-Bf_-UX.js} +1 -1
  28. package/dist/chunks/{PluginSettings-DN9rpwc_.js → PluginSettings-DUxj_oAg.js} +1 -1
  29. package/dist/chunks/{PromptInputFooterSuggestions-3rjz6zhK.js → PromptInputFooterSuggestions-MwS_cExV.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-DgDJHZqC.js → PromptInputHelpMenu-V2dEpzhC.js} +1 -1
  31. package/dist/chunks/{QueryEngine-BnaHDZVZ.js → QueryEngine-BLcPQYq_.js} +1 -1
  32. package/dist/chunks/{REPL-CA8FEO7J.js → REPL-B_E07dnf.js} +6 -6
  33. package/dist/chunks/REPL-BhURgntS.js +1 -0
  34. package/dist/chunks/{RemoteCallout-BFzCx_Pn.js → RemoteCallout-ChCjmgw1.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-BhUrtejX.js → RemoteSessionManager-B43isWQs.js} +1 -1
  36. package/dist/chunks/{ResumeConversation-BseKUFRI.js → ResumeConversation-DaQ9n8_C.js} +1 -1
  37. package/dist/chunks/{SSETransport-DGIytG74.js → SSETransport-h43pQVlJ.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-DSq7beKs.js +1 -0
  39. package/dist/chunks/{Settings-BvhG1XoW.js → Settings-CNsaWv8g.js} +2 -2
  40. package/dist/chunks/{TeleportProgress-Bens06DU.js → TeleportProgress-QtJrXSCX.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-BtLBCZUe.js → TeleportRepoMismatchDialog-D-HVj-A6.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-t50LfWyN.js → TeleportResumeWrapper-C6sbzJsJ.js} +1 -1
  43. package/dist/chunks/{ThemePicker-BTfuZZ7E.js → ThemePicker-CqPCp5Hs.js} +1 -1
  44. package/dist/chunks/{TrustDialog-CgE_pYUK.js → TrustDialog-CeVwxDlZ.js} +1 -1
  45. package/dist/chunks/{WelcomeV2-C93xQYAF.js → WelcomeV2-DNiXQ5ES.js} +1 -1
  46. package/dist/chunks/{add-dir-C3IhJYVH.js → add-dir-V3xjklnJ.js} +1 -1
  47. package/dist/chunks/{agentDisplay-Cju-aXCx.js → agentDisplay-BuiwcrQi.js} +1 -1
  48. package/dist/chunks/{agents-Bhg0CtXR.js → agents-D7um1IXM.js} +1 -1
  49. package/dist/chunks/{agents-Du3FQ82k.js → agents-ZY6IaVE7.js} +1 -1
  50. package/dist/chunks/{allErrors-DJYCAtab.js → allErrors-CHVdQ3fT.js} +1 -1
  51. package/dist/chunks/{ant-CVvy4SuO.js → ant-D66LZCap.js} +1 -1
  52. package/dist/chunks/{api-gJBnC8z3.js → api-C-rOQY-l.js} +1 -1
  53. package/dist/chunks/api-Dmn7DUgU.js +1 -0
  54. package/dist/chunks/{assistant-C_SkUDk_.js → assistant-CYF7ch7C.js} +1 -1
  55. package/dist/chunks/auth-C4Rvit2q.js +1 -0
  56. package/dist/chunks/auth-Cj7EX1eG.js +1 -0
  57. package/dist/chunks/{auth-CgEABs3i.js → auth-DAxGNCIR.js} +1 -1
  58. package/dist/chunks/{autoMode-CZyb-mMY.js → autoMode-TysBQkU_.js} +1 -1
  59. package/dist/chunks/{autonomy-DJZ25xZp.js → autonomy-CNEbT-t_.js} +1 -1
  60. package/dist/chunks/{autonomy-BpINX4jw.js → autonomy-k3QPea5z.js} +1 -1
  61. package/dist/chunks/{autonomyPanel-ssoiIOx5.js → autonomyPanel-DiztRblF.js} +1 -1
  62. package/dist/chunks/{backgroundHousekeeping-BHncba6e.js → backgroundHousekeeping-C9m4tiFi.js} +2 -2
  63. package/dist/chunks/backgroundHousekeeping-DQjzXBe0.js +1 -0
  64. package/dist/chunks/{branch-BXo5z2al.js → branch-_NBgDfrK.js} +1 -1
  65. package/dist/chunks/{bridge-CbKc1HeD.js → bridge-DpmFl8p8.js} +2 -2
  66. package/dist/chunks/{bridgeConfig-DbqUHe0H.js → bridgeConfig-DMBOO3gW.js} +1 -1
  67. package/dist/chunks/bridgeConfig-DsI5d0s7.js +1 -0
  68. package/dist/chunks/bridgeEnabled-DZzlF2d8.js +1 -0
  69. package/dist/chunks/{bridgeEnabled-CM3SaumJ.js → bridgeEnabled-FjPuA7zx.js} +1 -1
  70. package/dist/chunks/{bridgeMain-CzhBVCsN.js → bridgeMain-BppY0KW3.js} +6 -6
  71. package/dist/chunks/bridgeMain-BrY4tkF6.js +1 -0
  72. package/dist/chunks/{bridgeMessaging-lfa_v3oi.js → bridgeMessaging-N5zlzCCr.js} +1 -1
  73. package/dist/chunks/{btw-Cp0whJaJ.js → btw-BFRje_Zi.js} +1 -1
  74. package/dist/chunks/caches-BBLH8G1I.js +1 -0
  75. package/dist/chunks/{caches-CmW7idg5.js → caches-CcfPJ4_A.js} +2 -2
  76. package/dist/chunks/{ccrClient-BPXmxWHw.js → ccrClient-q2JCVCU2.js} +1 -1
  77. package/dist/chunks/{clear-DjGPxX7T.js → clear-CxY7W5Wt.js} +1 -1
  78. package/dist/chunks/client-CtVu3BLD.js +1 -0
  79. package/dist/chunks/{color-DYYBN52b.js → color-DOWhfjnA.js} +1 -1
  80. package/dist/chunks/commands-BWw1sQeH.js +1 -0
  81. package/dist/chunks/{commitAttribution-Bmzgtqc6.js → commitAttribution-CLbEIaRJ.js} +1 -1
  82. package/dist/chunks/commitAttribution-DIT_s0vY.js +1 -0
  83. package/dist/chunks/{compact-D6xqZN4Q.js → compact-CaOnQVkH.js} +1 -1
  84. package/dist/chunks/config-DmPGzNmi.js +1 -0
  85. package/dist/chunks/{config-huQaTcNb.js → config-HHTwEsWp.js} +1 -1
  86. package/dist/chunks/{context-Bh_iUj76.js → context-B2OvKo2t.js} +1 -1
  87. package/dist/chunks/context-noninteractive-BilCSCV1.js +1 -0
  88. package/dist/chunks/{context-noninteractive-Cb3EM2Oz.js → context-noninteractive-BuGxX3YL.js} +1 -1
  89. package/dist/chunks/conversation-BWXf3un9.js +1 -0
  90. package/dist/chunks/{conversation-CvCQta8e.js → conversation-awh8AwwL.js} +1 -1
  91. package/dist/chunks/{createSSHSession-B0s839mX.js → createSSHSession-C-c7I5iJ.js} +1 -1
  92. package/dist/chunks/{createSession-VMTMXOHu.js → createSession-D_fIDqgc.js} +1 -1
  93. package/dist/chunks/createSession-Hvpx3Le7.js +1 -0
  94. package/dist/chunks/{crossProjectResume-DGpgCUfk.js → crossProjectResume-_XjvSXA3.js} +1 -1
  95. package/dist/chunks/{datadog-D9rlcN12.js → datadog-Ed8emSFA.js} +1 -1
  96. package/dist/chunks/{desktop-DidI-4N5.js → desktop-D_ofPlyi.js} +1 -1
  97. package/dist/chunks/{diff-CZg5qL2n.js → diff-CUAgBDu1.js} +1 -1
  98. package/dist/chunks/doctor-CkdQ7Fv7.js +1 -0
  99. package/dist/chunks/{effort-BcvNemuq.js → effort-DCgooYMY.js} +1 -1
  100. package/dist/chunks/{entry-dA1UCfC0.js → entry-Bh0gPOAo.js} +1 -1
  101. package/dist/chunks/{envLessBridgeConfig-BFjJ8Kt4.js → envLessBridgeConfig-DJHZAlU-.js} +1 -1
  102. package/dist/chunks/envLessBridgeConfig-sxodu0xO.js +1 -0
  103. package/dist/chunks/{esm-DjGYYlQe.js → esm-B62dCLgf.js} +1 -1
  104. package/dist/chunks/{exit-COMnVxzw.js → exit-CFJR3NfE.js} +1 -1
  105. package/dist/chunks/{extra-usage-BTv_OwGN.js → extra-usage-CjaHpu8y.js} +1 -1
  106. package/dist/chunks/extra-usage-D1Y-3OWQ.js +1 -0
  107. package/dist/chunks/{extra-usage-core-RZMzaH0L.js → extra-usage-core-B6ga8Rni.js} +1 -1
  108. package/dist/chunks/{extra-usage-noninteractive-BB-BQ3kh.js → extra-usage-noninteractive-Dc9AndId.js} +1 -1
  109. package/dist/chunks/{extraUsage-CTn9FWSk.js → extraUsage-2DwLEr26.js} +1 -1
  110. package/dist/chunks/extractMemories-C3qrwpu2.js +1 -0
  111. package/dist/chunks/{fast-CNXgsvnE.js → fast-CW_NsL0x.js} +1 -1
  112. package/dist/chunks/fast-D3CPmUX4.js +1 -0
  113. package/dist/chunks/{feedback-DeJ2gvw2.js → feedback-BpRorTAC.js} +1 -1
  114. package/dist/chunks/{firstPartyEventLogger-CQdJn3LV.js → firstPartyEventLogger-CuUiNdj8.js} +2 -2
  115. package/dist/chunks/firstPartyEventLogger-DPUQnc6J.js +1 -0
  116. package/dist/chunks/{flushGate-CJ73xcaK.js → flushGate-BltVae97.js} +1 -1
  117. package/dist/chunks/{gemini-Cn9bMXwP.js → gemini-YyIxfveQ.js} +1 -1
  118. package/dist/chunks/{generateRecap-BO9kzRon.js → generateRecap-tx4wLIkI.js} +1 -1
  119. package/dist/chunks/{generateSessionName-CGpL6ATy.js → generateSessionName-BkDigIN8.js} +1 -1
  120. package/dist/chunks/{goal-C8Qzl7_i.js → goal-DZrD4puM.js} +1 -1
  121. package/dist/chunks/{grok-CDT9P_BL.js → grok-BZf7W_hL.js} +1 -1
  122. package/dist/chunks/{grove-BGXzEyH9.js → grove-CFBPplP6.js} +1 -1
  123. package/dist/chunks/{heapdump-CFHvdSZv.js → heapdump-DWc3Z2NO.js} +1 -1
  124. package/dist/chunks/{help-DUZ7Y7Em.js → help-pap9jNUJ.js} +1 -1
  125. package/dist/chunks/{hooks-RHwUCXcT.js → hooks-Bmat0L6A.js} +1 -1
  126. package/dist/chunks/hooks-cCAzfabs.js +1 -0
  127. package/dist/chunks/inboundAttachments-DZgSqDwY.js +1 -0
  128. package/dist/chunks/{inboundAttachments-Cfl4_n0S.js → inboundAttachments-DkfNHtF9.js} +1 -1
  129. package/dist/chunks/{initReplBridge-GH3-LHF4.js → initReplBridge-myzllvlk.js} +1 -1
  130. package/dist/chunks/{install-OkuNmjmB.js → install-D4jmHjmk.js} +1 -1
  131. package/dist/chunks/{instrumentation-hrXeo-G4.js → instrumentation-Nqgm1SMw.js} +3 -3
  132. package/dist/chunks/{job-DjmIpwJl.js → job-CT9bcgPb.js} +1 -1
  133. package/dist/chunks/{keybindings-B8U17bhs.js → keybindings-DETOn3qJ.js} +1 -1
  134. package/dist/chunks/{launchAgentsPlatform-DnxH2SAn.js → launchAgentsPlatform-CuRQgd2Q.js} +1 -1
  135. package/dist/chunks/{launchLocalMemory-CgXtGng1.js → launchLocalMemory-CRMqifzn.js} +1 -1
  136. package/dist/chunks/{launchLocalVault-Bs6Km3Ua.js → launchLocalVault-DlKX_oDE.js} +1 -1
  137. package/dist/chunks/{launchMemoryStores-DxVAIJuB.js → launchMemoryStores-CN0ecWpP.js} +1 -1
  138. package/dist/chunks/{launchOnboarding-Cn0t_o2k.js → launchOnboarding-DTdUA_wE.js} +1 -1
  139. package/dist/chunks/{launchSchedule-Chwr3Nzd.js → launchSchedule-psiSLmTA.js} +1 -1
  140. package/dist/chunks/{launchSkillStore-6zxJfWVU.js → launchSkillStore-CQQ00Ads.js} +1 -1
  141. package/dist/chunks/{launchTeleport-Ba_Hj13c.js → launchTeleport-CXFRPVMR.js} +1 -1
  142. package/dist/chunks/{launchVault-hGVrHy33.js → launchVault-Dn6jq0Rc.js} +1 -1
  143. package/dist/chunks/{loadAgentsDir-DrDu5yYy.js → loadAgentsDir-BURvZNN6.js} +38 -38
  144. package/dist/chunks/loadAgentsDir-Db9UTm45.js +1 -0
  145. package/dist/chunks/{loadPluginHooks-s7bvGtns.js → loadPluginHooks-C9A9oS-w.js} +1 -1
  146. package/dist/chunks/{localSearch-_bQhk9W6.js → localSearch-D2Rs8wQP.js} +1 -1
  147. package/dist/chunks/localSearch-hBh1ATr2.js +1 -0
  148. package/dist/chunks/{logoV2Utils-CoC4nheD.js → logoV2Utils-DN9nzdX-.js} +1 -1
  149. package/dist/chunks/{magicDocs-kMjYpjCA.js → magicDocs-DIeTcwAA.js} +1 -1
  150. package/dist/chunks/{main-C_rVSWfm.js → main-CI54PZrG.js} +14 -14
  151. package/dist/chunks/{mappers-D0CNXG32.js → mappers-Q_Z3Kjo-.js} +1 -1
  152. package/dist/chunks/{mcp-1ZuFesM9.js → mcp-CtbhGaLC.js} +1 -1
  153. package/dist/chunks/{mcp-CKvGBEjz.js → mcp-DMacvhqZ.js} +1 -1
  154. package/dist/chunks/{mcp-DtxIl6aN.js → mcp-RvwPC7FB.js} +2 -2
  155. package/dist/chunks/{memory-DE2jtkd_.js → memory-BPN8gW7n.js} +1 -1
  156. package/dist/chunks/{mode-B4WIxCMW.js → mode-Jl_Boaym.js} +1 -1
  157. package/dist/chunks/{model-fi472PRc.js → model-BIVmcl_N.js} +1 -1
  158. package/dist/chunks/{model-j9GNZDFr.js → model-CWBwPvTH.js} +1 -1
  159. package/dist/chunks/model-DlVpqR0P.js +1 -0
  160. package/dist/chunks/{nativeInstaller-DktvrWRd.js → nativeInstaller-8arnRiUO.js} +1 -1
  161. package/dist/chunks/{onChangeAppState-CGVeNkt7.js → onChangeAppState-DBantDJ6.js} +1 -1
  162. package/dist/chunks/{openai-BSVjSJiF.js → openai-yin1iDG8.js} +1 -1
  163. package/dist/chunks/{overageCreditGrant-BVxlYgeU.js → overageCreditGrant-CN_sVURL.js} +1 -1
  164. package/dist/chunks/{panelCall-Cp6fpQeL.js → panelCall-CPKC6VR5.js} +1 -1
  165. package/dist/chunks/{partition-RjCtgt9J.js → partition-CW0BJ881.js} +1 -1
  166. package/dist/chunks/{passes-ByTLy6pj.js → passes-DOm9ukdK.js} +1 -1
  167. package/dist/chunks/{permissions-B3df_htx.js → permissions-CxDJ__l6.js} +1 -1
  168. package/dist/chunks/{pidLock-CdNZ0Wfg.js → pidLock-C69HNTTb.js} +2 -2
  169. package/dist/chunks/{plan-BxTA-b4l.js → plan-B0rEs32a.js} +1 -1
  170. package/dist/chunks/{plugin-DOpl5e1t.js → plugin-BSEMgcGu.js} +1 -1
  171. package/dist/chunks/{pluginAutoupdate-L09CQ-ph.js → pluginAutoupdate-CTByPD8J.js} +1 -1
  172. package/dist/chunks/{pluginBlocklist-B32eWmzn.js → pluginBlocklist-mogKaK0p.js} +1 -1
  173. package/dist/chunks/{pluginCliCommands-CDMWnO3d.js → pluginCliCommands-DQQ7C7kk.js} +1 -1
  174. package/dist/chunks/{pluginFlagging-3FQGvIfq.js → pluginFlagging-mHNff1t9.js} +1 -1
  175. package/dist/chunks/{pluginOperations-ClzXYNQe.js → pluginOperations-JEedVzfS.js} +1 -1
  176. package/dist/chunks/pluginStartupCheck-D7ts2V3p.js +1 -0
  177. package/dist/chunks/{pluginStartupCheck-BNd2QNzZ.js → pluginStartupCheck-RscVZDi4.js} +1 -1
  178. package/dist/chunks/{plugins-CcDG95Bs.js → plugins-Cr03lISA.js} +1 -1
  179. package/dist/chunks/policyLimits-DWtLyJ4n.js +1 -0
  180. package/dist/chunks/{print-Cc_QOSPF.js → print-CZUmAzmt.js} +4 -4
  181. package/dist/chunks/{privacy-settings-ChNsgGUs.js → privacy-settings-CwJ1H8Ua.js} +1 -1
  182. package/dist/chunks/{processBashCommand-Bx6_oZoE.js → processBashCommand-aKNneP2u.js} +1 -1
  183. package/dist/chunks/{processSlashCommand-AltWgIFt.js → processSlashCommand-BcPnWNxZ.js} +1 -1
  184. package/dist/chunks/prompt-CIyhCdkE.js +1 -0
  185. package/dist/chunks/{prompt-C0nU0VK3.js → prompt-DNDgGM9q.js} +1 -1
  186. package/dist/chunks/prompt-DRhjinu2.js +1 -0
  187. package/dist/chunks/{promptEditor-Cumef6hJ.js → promptEditor-DMJyosKj.js} +1 -1
  188. package/dist/chunks/{rate-limit-options-VL7S3SCx.js → rate-limit-options--Y3oF1g0.js} +1 -1
  189. package/dist/chunks/{rcDebugLog-2-1XSyFV.js → rcDebugLog-DoL1FpGJ.js} +1 -1
  190. package/dist/chunks/{reconciler-DHRE_gV2.js → reconciler-CJcSh6xo.js} +1 -1
  191. package/dist/chunks/{referral-DrebVwqx.js → referral-UKJv23_5.js} +1 -1
  192. package/dist/chunks/{refresh-pFezssA8.js → refresh-ul_i5R1a.js} +1 -1
  193. package/dist/chunks/{release-notes-D7vrFNXp.js → release-notes-CGv_6MMt.js} +1 -1
  194. package/dist/chunks/{releaseNotes-CDx2P0fb.js → releaseNotes-BKZNuDLD.js} +1 -1
  195. package/dist/chunks/{reload-plugins-CltHfg-l.js → reload-plugins-2W11dpLQ.js} +1 -1
  196. package/dist/chunks/{remote-env-SvvSuP0J.js → remote-env-D9xsoBfx.js} +1 -1
  197. package/dist/chunks/{remoteBridgeCore-BOeljn2c.js → remoteBridgeCore-asY9JAXU.js} +1 -1
  198. package/dist/chunks/{remoteManagedSettings-CaY_ZH8r.js → remoteManagedSettings-Bxo3bv1U.js} +1 -1
  199. package/dist/chunks/{rename-CbqrCCBO.js → rename-CHsHMWpO.js} +1 -1
  200. package/dist/chunks/{resume-DockJaY9.js → resume-NduOaghx.js} +1 -1
  201. package/dist/chunks/{runtimeObserver-XufSllVw.js → runtimeObserver-BXbjibFk.js} +2 -2
  202. package/dist/chunks/{runtimeObserver-DSUuYKfs.js → runtimeObserver-Bo80nWQf.js} +1 -1
  203. package/dist/chunks/sandbox-adapter-DDfVl_2V.js +1 -0
  204. package/dist/chunks/{sandbox-toggle-CZI5fuK3.js → sandbox-toggle-C-WCDRN4.js} +1 -1
  205. package/dist/chunks/searchExtraTools-BHWzsbNO.js +1 -0
  206. package/dist/chunks/{session-B-Z3DU9o.js → session-pDd13-wE.js} +1 -1
  207. package/dist/chunks/{sessionDiscovery-C3pMZkBM.js → sessionDiscovery-CSUnpsCy.js} +1 -1
  208. package/dist/chunks/sessionFileAccessHooks-BZvxeufx.js +1 -0
  209. package/dist/chunks/{sessionMemory-CqRpgwtU.js → sessionMemory-CAmpw2yb.js} +1 -1
  210. package/dist/chunks/sessionMemory-DT0IkiA1.js +1 -0
  211. package/dist/chunks/sessionMemoryUtils-B4kGNH4j.js +1 -0
  212. package/dist/chunks/{sessionObserver-B_09FQKV.js → sessionObserver-Ur7PqKl_.js} +1 -1
  213. package/dist/chunks/sessionObserver-oIkwTidC.js +1 -0
  214. package/dist/chunks/sessionStorage-DqARUj0K.js +1 -0
  215. package/dist/chunks/{sessionTitle-CmLWNFuX.js → sessionTitle-pWMaI79N.js} +1 -1
  216. package/dist/chunks/{sessionTracing-lArOaj9u.js → sessionTracing-CCPRzOvy.js} +1 -1
  217. package/dist/chunks/{settingsSync-BlDk6rsM.js → settingsSync-D_4P3Esd.js} +1 -1
  218. package/dist/chunks/{setup-DdbmxSZh.js → setup-JHvhWKh9.js} +2 -2
  219. package/dist/chunks/{shadowedRuleDetection-E2wF1UjU.js → shadowedRuleDetection-Chi3afMR.js} +1 -1
  220. package/dist/chunks/{sideQuestion-BjHCLSR9.js → sideQuestion-D03MXdE2.js} +1 -1
  221. package/dist/chunks/{sinks-Cb--pqr-.js → sinks-B4_pw0Gb.js} +2 -2
  222. package/dist/chunks/sinks-Cro1Y8C2.js +1 -0
  223. package/dist/chunks/{skill-learning-B0dyBT1_.js → skill-learning-7ZQF5JvA.js} +1 -1
  224. package/dist/chunks/{skillChangeDetector-DQof8SUY.js → skillChangeDetector-uCaYrerZ.js} +1 -1
  225. package/dist/chunks/{skillGapStore-D2fqmnKx.js → skillGapStore-BND2Lq0Z.js} +1 -1
  226. package/dist/chunks/{skillGapStore-75ZYlfwi.js → skillGapStore-z3LP64O-.js} +2 -2
  227. package/dist/chunks/{skillGenerator-CwXUfM4Y.js → skillGenerator-DaNb-yKH.js} +2 -2
  228. package/dist/chunks/skillLearning-GZxYPlyl.js +1 -0
  229. package/dist/chunks/{skillLearning-CB-5fdMl.js → skillLearning-rMX1bSBa.js} +1 -1
  230. package/dist/chunks/{skillPanel-Bum7xpgo.js → skillPanel-q7GPSQ6_.js} +3 -3
  231. package/dist/chunks/{skillSearchPanel-LSPwZIOw.js → skillSearchPanel-oj8gy1ZL.js} +2 -2
  232. package/dist/chunks/{skills-G8WBeffd.js → skills-QqbeFP0s.js} +1 -1
  233. package/dist/chunks/{status-i5beKggW.js → status-BEIsLmfj.js} +1 -1
  234. package/dist/chunks/{status-ClSsvm1N.js → status-DW3Z_7xa.js} +1 -1
  235. package/dist/chunks/{statusNoticeHelpers-BK-54uGY.js → statusNoticeHelpers-CaHS8xig.js} +1 -1
  236. package/dist/chunks/{tag-DYYq4H_i.js → tag-CRg93Die.js} +1 -1
  237. package/dist/chunks/{tasks-BySzm_YJ.js → tasks-BEohK1ij.js} +1 -1
  238. package/dist/chunks/{teleport-dxtBcM01.js → teleport-4Srg5vcP.js} +1 -1
  239. package/dist/chunks/{templateJobs-CT5VxeRr.js → templateJobs-DYP1fjYU.js} +1 -1
  240. package/dist/chunks/{theme-CVTVsRwt.js → theme-kNL4kl_3.js} +1 -1
  241. package/dist/chunks/{thinkback-CXsRbDYN.js → thinkback-gV-sKkMM.js} +1 -1
  242. package/dist/chunks/thinkback-hc5eJ9ul.js +1 -0
  243. package/dist/chunks/{thinkback-play-BhfCaIye.js → thinkback-play-BpWMqbgJ.js} +1 -1
  244. package/dist/chunks/{toolEventObserver-DdhPsAs1.js → toolEventObserver-C98uraqD.js} +1 -1
  245. package/dist/chunks/{toolEventObserver--4fqXxQZ.js → toolEventObserver-ar5NDa0M.js} +1 -1
  246. package/dist/chunks/{toolPool-DvHECcbN.js → toolPool-CNYKDRq5.js} +1 -1
  247. package/dist/chunks/trustedDevice-0dehm9qz.js +1 -0
  248. package/dist/chunks/{trustedDevice-DvpN4J1F.js → trustedDevice-BBKUhCCL.js} +1 -1
  249. package/dist/chunks/{ultrareviewCommand-i3PfFKly.js → ultrareviewCommand-yXlFsMnv.js} +1 -1
  250. package/dist/chunks/{undercover-Q24TWRw0.js → undercover-BTIRVF1t.js} +1 -1
  251. package/dist/chunks/undercover-CG_269xD.js +1 -0
  252. package/dist/chunks/{updateCCB-CEXA6dax.js → updateCCB-B2xAJ4Nr.js} +1 -1
  253. package/dist/chunks/upgrade-J7lKLkD2.js +1 -0
  254. package/dist/chunks/{upgrade-7OrBbrzS.js → upgrade-yNl7EO4e.js} +1 -1
  255. package/dist/chunks/{upload-B-lNHpWe.js → upload-BWVIHmMB.js} +1 -1
  256. package/dist/chunks/{usage-CZdPfUqP.js → usage-B2PbCUMi.js} +1 -1
  257. package/dist/chunks/usage-Ck8Cu45g.js +1 -0
  258. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CzFtdlnD.js → useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js} +1 -1
  259. package/dist/chunks/useMainLoopModel-CO4yBjRM.js +1 -0
  260. package/dist/chunks/{useManagePlugins-BkK1zydO.js → useManagePlugins-BzFKIDrD.js} +1 -1
  261. package/dist/chunks/{useMergedTools-DMGRA1ga.js → useMergedTools-CRLWSGDl.js} +1 -1
  262. package/dist/chunks/{useSearchInput-D5VU9IDU.js → useSearchInput-BzGq4t7t.js} +1 -1
  263. package/dist/chunks/{useSettingsErrors-B5PSF1va.js → useSettingsErrors-CSemUjj1.js} +1 -1
  264. package/dist/chunks/{util-CNa1ib_4.js → util-BnReK81E.js} +1 -1
  265. package/dist/chunks/{validatePlugin-Dw-RGCrm.js → validatePlugin-D6sPqea1.js} +1 -1
  266. package/dist/chunks/{workerRegistry-B2QD2sKq.js → workerRegistry-CUXbNyL9.js} +1 -1
  267. package/dist/chunks/worktree-89ttIVxH.js +1 -0
  268. package/dist/cli.js +1 -1
  269. package/package.json +2 -6
  270. package/dist/chunks/ApproveApiKey-DPdcp1CQ.js +0 -1
  271. package/dist/chunks/ClaudeMdExternalIncludesDialog-Dn7Le--z.js +0 -1
  272. package/dist/chunks/ConsoleOAuthFlow-BDr1Vx5K.js +0 -1
  273. package/dist/chunks/Doctor-B540I-gq.js +0 -1
  274. package/dist/chunks/Grove-DLYXL8hv.js +0 -1
  275. package/dist/chunks/REPL-B3RbzeV7.js +0 -1
  276. package/dist/chunks/SearchExtraToolsTool-h6OunbMd.js +0 -1
  277. package/dist/chunks/api-CI8HXREw.js +0 -1
  278. package/dist/chunks/auth-B9V3i5oZ.js +0 -1
  279. package/dist/chunks/auth-fSFfSKy_.js +0 -1
  280. package/dist/chunks/backgroundHousekeeping-QK8iEXoI.js +0 -1
  281. package/dist/chunks/bridgeConfig-CLHy-BiF.js +0 -1
  282. package/dist/chunks/bridgeEnabled-BWSUZ7Xg.js +0 -1
  283. package/dist/chunks/bridgeMain-BESKzpm0.js +0 -1
  284. package/dist/chunks/caches-CpqTC0Lb.js +0 -1
  285. package/dist/chunks/client-DPUvQ6Rf.js +0 -1
  286. package/dist/chunks/commands-D7l3P1k9.js +0 -1
  287. package/dist/chunks/commitAttribution-B7NUPJ8E.js +0 -1
  288. package/dist/chunks/config-qLaiAn7z.js +0 -1
  289. package/dist/chunks/context-noninteractive-CNot6jbs.js +0 -1
  290. package/dist/chunks/conversation-CSpwF3Ha.js +0 -1
  291. package/dist/chunks/createSession-GNSNbUbN.js +0 -1
  292. package/dist/chunks/doctor-CKUXGCri.js +0 -1
  293. package/dist/chunks/envLessBridgeConfig-bei51W3H.js +0 -1
  294. package/dist/chunks/extra-usage-By33zGLT.js +0 -1
  295. package/dist/chunks/extractMemories-CXGZGe0h.js +0 -1
  296. package/dist/chunks/fast-BXzdzzXU.js +0 -1
  297. package/dist/chunks/firstPartyEventLogger-CdLshdJY.js +0 -1
  298. package/dist/chunks/hooks-fZ1r0jUF.js +0 -1
  299. package/dist/chunks/inboundAttachments-YMxf4fmR.js +0 -1
  300. package/dist/chunks/loadAgentsDir-BHOyHxwz.js +0 -1
  301. package/dist/chunks/localSearch-CebU5BA9.js +0 -1
  302. package/dist/chunks/model-C4RHNhDQ.js +0 -1
  303. package/dist/chunks/pluginStartupCheck-RiZxW-WU.js +0 -1
  304. package/dist/chunks/policyLimits-Bwi9VqDF.js +0 -1
  305. package/dist/chunks/prompt-CYx145pp.js +0 -1
  306. package/dist/chunks/prompt-DH3lKFag.js +0 -1
  307. package/dist/chunks/sandbox-adapter-CEZnHq0U.js +0 -1
  308. package/dist/chunks/searchExtraTools-iQfI39wB.js +0 -1
  309. package/dist/chunks/sessionFileAccessHooks-DyrZmoA7.js +0 -1
  310. package/dist/chunks/sessionMemory-D_HQmhj7.js +0 -1
  311. package/dist/chunks/sessionMemoryUtils-CZOIKrn0.js +0 -1
  312. package/dist/chunks/sessionObserver-B400YG3s.js +0 -1
  313. package/dist/chunks/sessionStorage-DRnvtrpU.js +0 -1
  314. package/dist/chunks/sinks-DbwDBd-E.js +0 -1
  315. package/dist/chunks/skillLearning-CSY5R5Jn.js +0 -1
  316. package/dist/chunks/thinkback-B-GpXG9U.js +0 -1
  317. package/dist/chunks/trustedDevice-e6iF1X7C.js +0 -1
  318. package/dist/chunks/undercover-CPvoDtJ1.js +0 -1
  319. package/dist/chunks/upgrade-uR7SIVtx.js +0 -1
  320. package/dist/chunks/usage-7jOeIVv9.js +0 -1
  321. package/dist/chunks/useMainLoopModel-DegH12LZ.js +0 -1
  322. package/dist/chunks/worktree-D38cJ23W.js +0 -1
@@ -1,4 +1,4 @@
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 A,Wt as j,Xn as M,Xt as N,Y as ee,Yt as P,Z as F,Zn as I,_n as te,bn as ne,ct as L,di as R,dr as re,et as ie,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{E as ye,M as be,S as xe,T as Se,a as Ce,d as we,n as Te,r as Ee,s as De,t as Oe,w as ke}from"./lazySchema-DcIJE_0i.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,$D as Ct,$T as wt,$_ as Tt,$b as Et,$d as Dt,$f as Ot,$m as kt,$x as At,AC as jt,AE as Mt,AS as Nt,Af as Pt,Ah as Ft,Ao as It,Ap as Lt,As as Rt,Au as zt,Aw as Bt,Ax as Vt,BC as Ht,BO as Ut,Bb as Wt,Bc as Gt,Bd as Kt,Bf as qt,Bg as Jt,Bm as Yt,Bn as Xt,Bo as Zt,Bp as Qt,Bs as $t,Bw as en,Bx as tn,C as nn,CD as rn,CE as an,CS as on,CT as sn,Cb as cn,Cf as ln,Cg as un,Ci as dn,Cl as fn,Cr as pn,Ct as mn,Cw as hn,Cx as gn,D as _n,DS as vn,DT as yn,Db as bn,Dg as xn,Du as Sn,Dw as Cn,Dx as wn,E as Tn,EC as W,EE as En,ES as Dn,ET as On,Eb as kn,Ec as An,Ef as jn,Em as Mn,Eo as Nn,Er as Pn,Es as Fn,Et as In,Eu as Ln,Ew as Rn,Ex as zn,Ey as Bn,FC as Vn,FT as Hn,Fd as Un,Ff as Wn,Fh as Gn,Fm as Kn,Fo as qn,Fp as Jn,Fs as Yn,Ft as Xn,Fw as Zn,G as Qn,GC as $n,GD as er,GS as tr,Gd as nr,Gf as rr,Gl as ir,Gm as ar,Gt as or,Gu as sr,Gx as cr,Gy as lr,HC as ur,HO as dr,Hb as fr,Hd as pr,Hf as mr,Hl as hr,Hm as gr,Hs as _r,Hw as vr,Hx as yr,I as br,IC as G,IS as xr,IT as Sr,Ib as Cr,Id as wr,If as Tr,Il as K,Im as Er,Io as Dr,Ip as Or,Ir as kr,Is as Ar,Iw as jr,J as Mr,JC as Nr,JE as Pr,JS as q,Jf as Fr,Jg as Ir,Jl as Lr,Jn as Rr,Jo as zr,Jr as Br,Js as Vr,Jx as Hr,KD as Ur,KE as Wr,KS as Gr,KT as Kr,Kf as qr,Ki as Jr,Kl as Yr,Ks as Xr,Ku as Zr,Kx as Qr,Ky as $r,LC as ei,LE as ti,LT as ni,Ld as ri,Lf as ii,Lg as ai,Ll as oi,Lm as si,Ln as ci,Lp as li,Ls as ui,Lw as di,M as fi,MC as pi,MD as mi,MO as hi,MT as gi,Mb as _i,Mc as vi,Mf as yi,Mp as bi,Mr as xi,Mu as Si,Mw as Ci,N as wi,NT as Ti,Nb as Ei,Nd as Di,Nf as Oi,Ng as ki,Nl as Ai,Np as ji,Nu as Mi,Nw as Ni,Nx as Pi,OC as Fi,OS as Ii,OT as Li,Ob as Ri,Oc as zi,Og as Bi,Oo as Vi,Op as Hi,Ou as Ui,Ox as Wi,Oy as Gi,P as Ki,PC as qi,PS as Ji,PT as Yi,Pd as Xi,Pf as Zi,Pg as Qi,Ph as $i,Pl as ea,Pm as ta,Pn as na,Pp as ra,Pr as ia,Pu as aa,Pw as oa,Px as sa,Q as ca,QC as la,QD as ua,QT as da,Qa as fa,Qb as pa,Qd as ma,Qf as ha,Qi as ga,Qm as _a,Qn as va,Qo as ya,Qs as ba,Qu as xa,Qx as Sa,RC as Ca,RT as wa,Ra as Ta,Rb as Ea,Rc as Da,Rg as Oa,Ri as ka,Rm as Aa,Rp as ja,Rs as Ma,Rw as Na,Rx as Pa,SS as Fa,ST as Ia,Sf as La,Sg as Ra,Sl as za,So as Ba,Sw as Va,Sx as Ha,TE as Ua,TO as Wa,TS as Ga,TT as Ka,Tb as qa,Tf as Ja,Tm as Ya,To as Xa,Tu as Za,Tv as Qa,Tx as $a,UC as eo,UO as to,UT as no,Ua as ro,Ub as io,Ud as ao,Uf as oo,Ul as so,Um as co,Up as lo,Ut as uo,Uu as fo,Uw as po,Ux as mo,VC as ho,VO as go,Va as _o,Vb as vo,Vc as yo,Vd as bo,Vf as xo,Vg as So,Vi as Co,Vl as wo,Vm as To,Vs as Eo,Vu as Do,Vw as Oo,Vx as ko,W as Ao,WC as jo,WE as Mo,WO as No,WS as Po,WT as Fo,Wd as Io,Wf as Lo,Wi as Ro,Wl as zo,Wm as Bo,Wp as Vo,Wu as Ho,Wx as Uo,X as Wo,XC as Go,XS as Ko,Xb as qo,Xg as Jo,Xm as Yo,Xu as Xo,Xx as Zo,Xy as Qo,YC as $o,YS as es,YT as ts,Yb as ns,Yu as rs,Yx as is,Z as as,ZC as os,ZD as ss,Zb as cs,Zg as ls,Zi as us,Zm as ds,Zs as fs,Zt as ps,Zu as ms,Zy as hs,_D as gs,_S as _s,_b as vs,_l as ys,_m as bs,_p as xs,_u as Ss,_v as Cs,_x as ws,aT as Ts,aa as Es,ac as Ds,af as Os,ao as ks,ap as As,ax as js,b as Ms,bD as Ns,bS as Ps,bf as Fs,bg as Is,bo as Ls,cC as Rs,cS as zs,ca as Bs,cb as Vs,cl as Hs,cm as Us,cp as Ws,cs as Gs,cu as Ks,cx as qs,dC as Js,dS as Ys,dT as Xs,db as Zs,dh as Qs,dm as $s,dn as ec,do as tc,dw as nc,dx as rc,eS as ic,eh as ac,ei as oc,en as sc,ep as cc,es as lc,et as uc,ev as dc,ex as fc,fC as pc,fE as mc,fS as hc,fb as gc,fh as _c,fi as vc,fm as yc,fp as bc,fs as xc,fx as Sc,gS as Cc,gb as wc,gl as Tc,gm as Ec,gp as Dc,gs as Oc,gu as kc,gv as Ac,gx as jc,hS as Mc,hi as Nc,hl as Pc,hm as Fc,ho as Ic,hp as Lc,hu as Rc,iT as zc,id as Bc,if as Vc,ih as Hc,im as Uc,io as Wc,ip as Gc,it as Kc,iu as qc,ix as Jc,jC as Yc,jD as Xc,jE as Zc,jO as Qc,jS as $c,jT as el,jc as tl,jf as nl,jg as rl,jm as il,jp as al,jr as ol,ju as sl,jy as cl,kE as ll,kS as ul,kT as dl,kb as fl,kc as pl,kg as ml,kh as hl,km as gl,ko as _l,kw as vl,kx as yl,ky as bl,lC as xl,lS as Sl,lh as Cl,li as wl,ll as Tl,lm as El,lt as Dl,lu as Ol,lx as kl,mS as Al,ma as jl,mb as Ml,mm as Nl,mo as Pl,mp as Fl,mr as Il,mu as Ll,my as Rl,nT as zl,na as Bl,nd as Vl,nm as Hl,no as Ul,nr as Wl,oT as Gl,oa as Kl,ob as ql,oc as Jl,od as Yl,ol as Xl,op as Zl,or as Ql,os as $l,ox as eu,pS as tu,pa as nu,pb as ru,ph as iu,pi as au,pm as ou,po as su,pu as cu,pw as lu,px as uu,py as du,q as fu,qC as pu,qD as mu,qE as hu,qS as J,qT as gu,qf as _u,qg as vu,qi as yu,ql as bu,qo as xu,qx as Su,rT as Cu,ra as wu,rd as Tu,rg as Eu,rh as Du,rm as Ou,ro as ku,rp as Au,sC as ju,sa as Mu,sd as Nu,sh as Pu,si as Fu,sl as Iu,sm as Lu,su as Ru,tS as zu,ta as Bu,tm as Vu,tp as Hu,tt as Uu,tw as Wu,tx as Gu,uC as Ku,uS as qu,ua as Ju,ub as Yu,uh as Xu,ul as Zu,um as Qu,uo as $u,ur as ed,ut as td,uu as nd,uw as rd,vi as id,vp as ad,vs as od,vu as sd,vw as cd,vx as ld,wO as ud,wS as dd,wT as fd,wf as pd,wi as md,wu as hd,ww as gd,wx as _d,x as vd,xE as yd,xS as bd,xb as xd,xf as Sd,xv as Cd,xw as wd,xx as Td,yf as Ed,yg as Dd,yn as Od,yo as kd,ys as Ad,yv as jd,yw as Md,yx as Nd,zC as Pd,zE as Fd,za as Id,zb as Ld,zc as Rd,zf as zd,zg as Bd,zl as Vd,zm as Hd,zn as Ud,zo as Wd,zp as Gd,zs as Kd,zw as qd,zx as Jd}from"./loadAgentsDir-DrDu5yYy.js";import{n as Yd,t as Xd}from"./cwd-CYmmnQVS.js";import{C as Zd,D as Qd,F as $d,G as ef,Q as tf,S as nf,V as rf,W as af,_ as of,a as sf,d as cf,l as Y,nt as lf,p as uf,rt as df,w as ff,z as pf}from"./debug-BrXObCdR.js";import{B as mf,Bt as hf,Ft as gf,Ht as _f,It as vf,Jt as yf,Kt as bf,L as xf,Pt as Sf,St as Cf,Ut as wf,Vt as Tf,Wt as Ef,Xt as Df,Zt as Of,_n as kf,c as Af,cn as jf,dn as Mf,f as Nf,ft as Pf,g as Ff,gn as If,n as Lf,vn as Rf,y as zf}from"./settings-DfWP5y6X.js";import{P as Bf,b as Vf,c as Hf,g as Uf,l as Wf,n as Gf}from"./config-DiT2Z8dY.js";import{M as Kf,_ as qf,a as Jf,d as Yf,i as Xf,j as Zf}from"./git-Do0wJvux.js";import{r as Qf,t as $f}from"./execFileNoThrow-D244NytW.js";import{B as ep,L as tp,N as np,R as rp,U as ip,Y as ap,k as op,o as sp,s as X}from"./log-BMCygSzM.js";import{n as cp,t as lp}from"./memoize-B0zhbT8Z.js";import{n as up,t as dp}from"./which-CKQnSouy.js";import{i as fp,o as pp}from"./platform-BrYefG_2.js";import{i as mp,n as hp,o as gp,r as _p}from"./path-D5U-tm91.js";import{D as vp,E as yp,T as bp,f as xp,l as Sp}from"./file-DcZWPH2V.js";import{s as Cp,u as wp}from"./types-C-MRCL8J.js";import{n as Tp,r as Z}from"./analytics-BotDBGh0.js";import{c as Ep,n as Dp,s as Op,t as kp}from"./intl-cKc-V6Mq.js";import{T as Ap,b as jp,d as Mp,f as Np,u as Pp,y as Fp}from"./startupProfiler-xa3NmN7Z.js";import{l as Ip,u as Lp}from"./oauth-BqJqV-2M.js";import{n as Rp,t as zp}from"./bundledMode--fG1S62b.js";import{a as Bp,d as Vp,l as Hp,o as Up,r as Wp,s as Gp}from"./stringUtils-DGLPkqJ4.js";import{C as Kp,Ct as qp,D as Jp,Dt as Yp,Er as Xp,Hn as Zp,It as Qp,Kt as $p,Qr as em,T as tm,Tr as nm,Ut as rm,Vn as im,Vt as am,Xr as om,Z as sm,Zt as cm,_ as lm,at as um,b as dm,ci as fm,cr as pm,ct as mm,en as hm,er as gm,h as _m,ht as vm,ir as ym,it as bm,jt as xm,lt as Sm,m as Cm,nn as wm,nr as Tm,nt as Em,oi as Dm,ot as Om,qn as km,rt as Am,si as jm,sr as Mm,st as Nm,tt as Pm,u as Fm,wt as Im,x as Lm}from"./model-fi472PRc.js";import{At as Rm,Cn as zm,Et as Bm,Ht as Vm,Tn as Hm,Tt as Um,Ut as Wm,an as Gm,bn as Km,dn as qm,fn as Jm,hn as Ym,jt as Xm,mn as Zm,st as Qm,yn as $m}from"./prompt-C0nU0VK3.js";import{et as eh,rt as th}from"./esm-DjGYYlQe.js";import{a as nh,i as rh,r as ih}from"./shellQuote-DkSy9MYE.js";import{a as ah}from"./ripgrep-BXmXjAzA.js";import{a as oh,o as sh,s as ch}from"./fileStateCache-DDW5toIs.js";import{C as lh,N as uh,S as dh,T as fh,b as ph,d as mh,f as hh,j as gh,st as _h,w as vh,x as yh,y as bh}from"./rcDebugLog-2-1XSyFV.js";import{T as xh,c as Sh,r as Ch,w as wh}from"./sessionTracing-lArOaj9u.js";import{i as Th,n as Eh,r as Dh}from"./parser-DFwaTGf7.js";import{c as Oh,l as kh}from"./commitAttribution-Bmzgtqc6.js";import{n as Ah,t as jh}from"./poorMode-CtcqaiwD.js";import{a as Mh,f as Nh,l as Ph,o as Fh}from"./api-gJBnC8z3.js";import{f as Ih,m as Lh}from"./firstPartyEventLogger-CQdJn3LV.js";import{l as Rh,u as zh}from"./referral-DrebVwqx.js";import{i as Bh,m as Vh,n as Hh,p as Uh}from"./terminalSetup-BNs9nLbT.js";import{n as Wh,t as Gh}from"./browser-BmZuQom6.js";import{i as Kh,r as qh}from"./bridgeEnabled-CM3SaumJ.js";import{n as Jh,r as Yh}from"./undercover-Q24TWRw0.js";import{t as Xh}from"./Dialog-vfLXEPed.js";import{t as Zh}from"./lib-BlVGipXx.js";import{n as Qh,t as $h}from"./mappers-D0CNXG32.js";import{n as eg,r as tg}from"./sessionTitle-CmLWNFuX.js";import{t as ng}from"./bridgeMessaging-lfa_v3oi.js";import{C as rg,S as ig,d as ag,l as og}from"./pidLock-CdNZ0Wfg.js";import{n as sg,t as cg}from"./nativeInstaller-DktvrWRd.js";import{r as lg,t as ug}from"./pipeTransport-CqCnc-Ys.js";import{t as dg}from"./useManagePlugins-BkK1zydO.js";import{n as fg,t as pg}from"./MCPConnectionManager-zdocEDgk.js";import{i as mg,n as hg,r as gg,t as _g}from"./reconciler-DHRE_gV2.js";import{n as vg,t as yg}from"./toolPool-DvHECcbN.js";import{a as bg,c as xg,i as Sg,l as Cg,r as wg,t as Tg,u as Eg}from"./MessageSelector-BBhCstBa.js";import{n as Dg,t as Og}from"./useExitOnCtrlCDWithKeybindings-CzFtdlnD.js";import{n as kg,t as Ag}from"./sideQuestion-BjHCLSR9.js";import{a as jg,n as Mg,o as Ng,r as Pg,s as Fg,t as Ig}from"./skillChangeDetector-DQof8SUY.js";import{n as Lg,t as Rg}from"./refresh-pFezssA8.js";import{i as zg,n as Bg,r as Vg,t as Hg}from"./directoryCompletion-CW2ckkQg.js";import{r as Ug,t as Wg}from"./PromptInputFooterSuggestions-3rjz6zhK.js";import{n as Gg,t as Kg}from"./useMergedTools-DMGRA1ga.js";import{a as qg,i as Jg,n as Yg,o as Xg,r as Zg,t as Qg}from"./promptEditor-Cumef6hJ.js";import{n as $g,t as e_}from"./useMainLoopModel-DegH12LZ.js";import{i as t_,n as n_,r as r_,t as i_}from"./PermissionDialog-0ya1CU5k.js";import{n as a_,t as o_}from"./RemoteCallout-BFzCx_Pn.js";import{a as s_,c as c_,i as l_,o as u_,r as d_,s as f_}from"./caches-CmW7idg5.js";import{i as p_,n as m_,r as h_,t as g_}from"./conversation-CvCQta8e.js";import{a as __,i as v_,n as y_,o as b_,r as x_,s as S_,t as C_}from"./extraUsage-CTn9FWSk.js";import{n as w_,t as T_}from"./useSearchInput-D5VU9IDU.js";import{n as E_,t as D_}from"./staticRender-BIxpgNUq.js";import{n as O_,t as k_}from"./useSettingsErrors-B5PSF1va.js";import{n as A_,t as j_}from"./shadowedRuleDetection-E2wF1UjU.js";import{n as M_,t as N_}from"./ExitFlow-DCIhnP5h.js";import{a as P_,i as F_,r as I_,t as L_}from"./fast-CNXgsvnE.js";import{n as R_,r as z_}from"./Feedback-CDTqPqsM.js";import{a as B_,i as V_,n as H_,r as U_,t as W_}from"./PromptInputHelpMenu-DgDJHZqC.js";import{n as G_,r as K_}from"./pluginAutoupdate-L09CQ-ph.js";import{n as q_,r as J_}from"./autoModeDenials-BxNzGJdR.js";import{n as Y_,t as X_}from"./generateSessionName-CGpL6ATy.js";import{a as Z_,c as Q_,d as $_,i as ev,l as tv,n as nv,o as rv,r as iv,s as av,t as ov,u as sv}from"./Messages-Dv2VrytX.js";import{a as cv,i as lv,n as uv,o as dv,r as fv,t as pv}from"./BackgroundTasksDialog-DyjVt81B.js";import{n as mv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as hv}from"./earlyInput-BTC_Wucv.js";import{a as gv,c as _v,i as vv,l as yv,o as bv,r as xv,s as Sv,t as Cv}from"./RemoteSessionManager-BhUrtejX.js";import{n as wv,t as Tv}from"./backgroundHousekeeping-BHncba6e.js";import{n as Ev}from"./language-BA5WprZv.js";import{homedir as Dv,tmpdir as Ov}from"os";import*as kv from"path";import{basename as Av,dirname as jv,extname as Mv,join as Nv,relative as Pv,sep as Fv}from"path";import{dirname as Iv,join as Lv}from"node:path";import{watch as Rv}from"fs";import{createHash as zv}from"node:crypto";import{randomUUID as Bv}from"crypto";import{readFile as Vv,stat as Hv,writeFile as Uv}from"fs/promises";import{spawn as Wv,spawnSync as Gv}from"child_process";import{mkdir as Kv,readFile as qv,rename as Jv,writeFile as Yv}from"node:fs/promises";s(),c(),p(),R(),me(),u(),B(),Ee(),We(),at(),Yd(),lf(),ef(),pf(),nf(),uf(),sf(),Zf(),ap(),sp(),Qf(),lp(),dp(),qf(),pp(),mp(),yp(),kf(),Tp(),xp(),Cp(),Op(),jp(),Mf(),Oe(),Lp(),zp(),Of(),bf(),gf(),Cf(),xf(),Up(),Ff(),Bf(),Uf(),fm(),em(),Xp(),Mm(),ym(),km(),am(),Pm(),lm(),to(),hi(),Hm(),Km(),Ym(),Gm(),eh(),Ct(),Ur(),Xc(),ah(),Ns(),Wm(),Xm(),Bm(),Qm(),Pr(),Mo(),sh(),Fd(),Zc(),Ua(),mc(),da(),ts(),Fo(),gi(),Xs(),Ts(),po(),wh(),Dh(),ih(),Zn(),vl(),gd(),cd(),nc(),Wu(),os(),uh(),pu(),$n(),eo(),Ca(),pi(),pc(),xl(),zh(),ju(),Po(),$c(),ul(),Dn(),dd(),Fa(),Uh(),Bh(),Al(),Sa(),Qr(),Rh(),Uo(),ko(),Jd(),wn(),zn(),ld(),qo(),fl(),wc(),ql(),Qo(),Rl(),Gh(),dc(),Ir(),So(),Bi(),kt(),To(),si(),Mn(),bs(),El(),Hl(),Vo(),Gd(),xs(),Zl(),Hu(),ii(),Oi(),nl(),jn(),pd(),Sd(),Fs(),qh(),ao(),bo(),wr(),Xi(),bh(),Tu(),Xo(),Do(),zt(),Sn(),Ln(),sd(),kc(),Sh(),Ru(),qc(),bu(),K(),Ai(),za(),Pc(),Tl(),Iu(),yo(),Da(),tl(),pl(),Ds(),ba(),Eo(),Fn(),od(),xc(),$l(),Wd(),_o(),jl(),ga(),ol(),ci(),Od(),uc(),as(),fu(),Qn(),nn(),t_(),n_(),T_(),R_();var Q=n(z(),1);x(),nv(),yl(),Ji(),J(),D_();var $=ve();function Xv({children:e}){let{bindings:t}=xr(),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 Zv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Qv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>E_((0,$.jsx)(Gr,{children:(0,$.jsx)(Xv,{children:(0,$.jsx)(ov,{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+=Zv(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 $v(e,t=[],n){let r=[];return await Qv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}Oo(),Cd(),Qs(),Cl(),qg(),jc();function ey({onDone:e}){return(0,$.jsxs)(ge,{title:`You've spent $5 on the Anthropic 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)(ws,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),jc();function ty({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${ny(e)} and this conversation is ${Fp(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)(ws,{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 ny(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 ry(e,t){let n=Hf().preferredNotifChannel;await uo(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await ay(n,e,t),term:yf.terminal})}var iy=`Work Mate`;async function ay(e,t,n){let r=t.title||iy;try{switch(e){case`auto`:return oy(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:sy()}),`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 oy(e,t){let n=e.title||iy;switch(yf.terminal){case`Apple_Terminal`:return await cy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:sy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function sy(){return Math.floor(Math.random()*1e4)}async function cy(){try{if(yf.terminal!==`Apple_Terminal`)return!1;let e=(await $f(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await $f(`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 ly=300,uy=240*1e3,dy=null,fy=null,py=0,my=!1;function hy(){py++,py===1&&(by(),vy())}function gy(){py>0&&py--,py===0&&(yy(),xy())}function _y(){py=0,yy(),xy()}function vy(){process.platform===`darwin`&&fy===null&&(fy=setInterval(()=>{py>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),xy(),by())},uy),fy.unref())}function yy(){fy!==null&&(clearInterval(fy),fy=null)}function by(){if(process.platform===`darwin`&&dy===null){my||(my=!0,df(async()=>{_y()}));try{dy=Wv(`caffeinate`,[`-i`,`-t`,String(ly)],{stdio:`ignore`}),dy.unref();let e=dy;dy.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),dy===e&&(dy=null)}),dy.on(`exit`,()=>{dy===e&&(dy=null)}),Y(`Started caffeinate to prevent sleep`)}catch{dy=null}}}function xy(){if(dy!==null){let e=dy;dy=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var Sy=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 Cy(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(Fu(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=va(f,e).findLast(xi);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function wy(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function Ty(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 Ey(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&wy(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&wy(t.response)?t.response:void 0,r=Ty(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function Dy(t){{let{pauseProactive:t}=(bh(),e(lh));t()}t?.abort()}function Oy(e,t){return e<t}function ky(e,t){return e&&t===0}function Ay({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||Oy(n,r)}uu(),h_();function jy(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 My(e,t){return e.id.localeCompare(t.id)}function Ny(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(jy).sort(My)}}function Py(e,t){return JSON.stringify(Ny(e,t))}function Fy(e,t){let n=Ny(e,t);return{type:`task_state`,uuid:Bv(),...n}}B(),J(),sf();var Iy=50,Ly=5e3,Ry=1e4,zy=3;function By(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=Ko(),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 _=es(),{addNotification:v}=tr(),y=q(e=>e.replBridgeEnabled),b=q(e=>e.replBridgeConnected),x=q(e=>e.replBridgeSessionActive),S=q(e=>e.replBridgeOutboundOnly),C=q(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>=zy){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-GH3-LHF4.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-bei51W3H.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-z2o4-UJe.js`);b=e()}async function x(e){try{let t=gg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-YMxf4fmR.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}`:``}`),Ka({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!==``?kl(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?ei(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,kd(`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))},Ry);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=Ey(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(){Dy(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(_n())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`&&!Tn()){let e=vd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${Ms(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Ki(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))},Ry);return}if(a.current=D,p_(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=ei(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:kl(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,Pl(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=$d(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))},Ry),r||t(e=>[...e,kd(`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,p_(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&&ky(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=Rv(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=jt();c(Yc(n));try{let r=await qi(n);if(e||a.current!==t)return;let i=Py(n,r);if(i===o&&t===s)return;t.writeSdkMessages([Fy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${$d(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},Iy),t.unref?.()};l();let d=Vn(u);return n=setInterval(()=>{l()},Ly),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(ky(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||Ay({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}js(),Gu(),cs(),Wt(),Ld(),Og(),wg(),Tp();var Vy=Te(()=>ye({method:xe(`log_event`),params:ye({eventName:be(),eventData:ye({}).passthrough()})}));function Hy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Ra(e);t&&t.client.setNotificationHandler(Vy(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}at(),B();var Uy=6e3;function Wy(){return Date.now()-ze()}function Gy(e){return Wy()<e}function Ky(e){return!Gy(e)}function qy(e,t){let n=E();(0,Q.useEffect)(()=>{vt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Ky(6e3)&&!r&&(r=!0,clearInterval(i),ry({message:e,notificationType:t},n))},Uy);return()=>clearInterval(i)},[e,t,n])}Pi(),ds(),Or(),ji(),Lt(),Zg(),B(),Ac();var Jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Yy(e){return Ga().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(qd());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({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)(()=>Xu(e,s,a),[e,s,a]).split(`
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 A,Wt as j,Xn as M,Xt as N,Y as ee,Yt as P,Z as F,Zn as I,_n as te,bn as ne,ct as L,di as R,dr as re,et as ie,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{E as ye,M as be,S as xe,T as Se,a as Ce,d as we,n as Te,r as Ee,s as De,t as Oe,w as ke}from"./lazySchema-DcIJE_0i.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,$D as Ct,$T as wt,$_ as Tt,$b as Et,$d as Dt,$f as Ot,$m as kt,$x as At,AC as jt,AE as Mt,AS as Nt,Af as Pt,Ah as Ft,Ao as It,Ap as Lt,As as Rt,Au as zt,Aw as Bt,Ax as Vt,BC as Ht,BO as Ut,Bb as Wt,Bc as Gt,Bd as Kt,Bf as qt,Bg as Jt,Bm as Yt,Bn as Xt,Bo as Zt,Bp as Qt,Bs as $t,Bw as en,Bx as tn,C as nn,CD as rn,CE as an,CS as on,CT as sn,Cb as cn,Cf as ln,Cg as un,Ci as dn,Cl as fn,Cr as pn,Ct as mn,Cw as hn,Cx as gn,D as _n,DS as vn,DT as yn,Db as bn,Dg as xn,Du as Sn,Dw as Cn,Dx as wn,E as Tn,EC as W,EE as En,ES as Dn,ET as On,Eb as kn,Ec as An,Ef as jn,Em as Mn,Eo as Nn,Er as Pn,Es as Fn,Et as In,Eu as Ln,Ew as Rn,Ex as zn,Ey as Bn,FC as Vn,FT as Hn,Fd as Un,Ff as Wn,Fh as Gn,Fm as Kn,Fo as qn,Fp as Jn,Fs as Yn,Ft as Xn,Fw as Zn,G as Qn,GC as $n,GD as er,GS as tr,Gd as nr,Gf as rr,Gl as ir,Gm as ar,Gt as or,Gu as sr,Gx as cr,Gy as lr,HC as ur,HO as dr,Hb as fr,Hd as pr,Hf as mr,Hl as hr,Hm as gr,Hs as _r,Hw as vr,Hx as yr,I as br,IC as G,IS as xr,IT as Sr,Ib as Cr,Id as wr,If as Tr,Il as K,Im as Er,Io as Dr,Ip as Or,Ir as kr,Is as Ar,Iw as jr,J as Mr,JC as Nr,JE as Pr,JS as q,Jf as Fr,Jg as Ir,Jl as Lr,Jn as Rr,Jo as zr,Jr as Br,Js as Vr,Jx as Hr,KD as Ur,KE as Wr,KS as Gr,KT as Kr,Kf as qr,Ki as Jr,Kl as Yr,Ks as Xr,Ku as Zr,Kx as Qr,Ky as $r,LC as ei,LE as ti,LT as ni,Ld as ri,Lf as ii,Lg as ai,Ll as oi,Lm as si,Ln as ci,Lp as li,Ls as ui,Lw as di,M as fi,MC as pi,MD as mi,MO as hi,MT as gi,Mb as _i,Mc as vi,Mf as yi,Mp as bi,Mr as xi,Mu as Si,Mw as Ci,N as wi,NT as Ti,Nb as Ei,Nd as Di,Nf as Oi,Ng as ki,Nl as Ai,Np as ji,Nu as Mi,Nw as Ni,Nx as Pi,OC as Fi,OS as Ii,OT as Li,Ob as Ri,Oc as zi,Og as Bi,Oo as Vi,Op as Hi,Ou as Ui,Ox as Wi,Oy as Gi,P as Ki,PC as qi,PS as Ji,PT as Yi,Pd as Xi,Pf as Zi,Pg as Qi,Ph as $i,Pl as ea,Pm as ta,Pn as na,Pp as ra,Pr as ia,Pu as aa,Pw as oa,Px as sa,Q as ca,QC as la,QD as ua,QT as da,Qa as fa,Qb as pa,Qd as ma,Qf as ha,Qi as ga,Qm as _a,Qn as va,Qo as ya,Qs as ba,Qu as xa,Qx as Sa,RC as Ca,RT as wa,Ra as Ta,Rb as Ea,Rc as Da,Rg as Oa,Ri as ka,Rm as Aa,Rp as ja,Rs as Ma,Rw as Na,Rx as Pa,SS as Fa,ST as Ia,Sf as La,Sg as Ra,Sl as za,So as Ba,Sw as Va,Sx as Ha,TE as Ua,TO as Wa,TS as Ga,TT as Ka,Tb as qa,Tf as Ja,Tm as Ya,To as Xa,Tu as Za,Tv as Qa,Tx as $a,UC as eo,UO as to,UT as no,Ua as ro,Ub as io,Ud as ao,Uf as oo,Ul as so,Um as co,Up as lo,Ut as uo,Uu as fo,Uw as po,Ux as mo,VC as ho,VO as go,Va as _o,Vb as vo,Vc as yo,Vd as bo,Vf as xo,Vg as So,Vi as Co,Vl as wo,Vm as To,Vs as Eo,Vu as Do,Vw as Oo,Vx as ko,W as Ao,WC as jo,WE as Mo,WO as No,WS as Po,WT as Fo,Wd as Io,Wf as Lo,Wi as Ro,Wl as zo,Wm as Bo,Wp as Vo,Wu as Ho,Wx as Uo,X as Wo,XC as Go,XS as Ko,Xb as qo,Xg as Jo,Xm as Yo,Xu as Xo,Xx as Zo,Xy as Qo,YC as $o,YS as es,YT as ts,Yb as ns,Yu as rs,Yx as is,Z as as,ZC as os,ZD as ss,Zb as cs,Zg as ls,Zi as us,Zm as ds,Zs as fs,Zt as ps,Zu as ms,Zy as hs,_D as gs,_S as _s,_b as vs,_l as ys,_m as bs,_p as xs,_u as Ss,_v as Cs,_x as ws,aT as Ts,aa as Es,ac as Ds,af as Os,ao as ks,ap as As,ax as js,b as Ms,bD as Ns,bS as Ps,bf as Fs,bg as Is,bo as Ls,cC as Rs,cS as zs,ca as Bs,cb as Vs,cl as Hs,cm as Us,cp as Ws,cs as Gs,cu as Ks,cx as qs,dC as Js,dS as Ys,dT as Xs,db as Zs,dh as Qs,dm as $s,dn as ec,do as tc,dw as nc,dx as rc,eS as ic,eh as ac,ei as oc,en as sc,ep as cc,es as lc,et as uc,ev as dc,ex as fc,fC as pc,fE as mc,fS as hc,fb as gc,fh as _c,fi as vc,fm as yc,fp as bc,fs as xc,fx as Sc,gS as Cc,gb as wc,gl as Tc,gm as Ec,gp as Dc,gs as Oc,gu as kc,gv as Ac,gx as jc,hS as Mc,hi as Nc,hl as Pc,hm as Fc,ho as Ic,hp as Lc,hu as Rc,iT as zc,id as Bc,if as Vc,ih as Hc,im as Uc,io as Wc,ip as Gc,it as Kc,iu as qc,ix as Jc,jC as Yc,jD as Xc,jE as Zc,jO as Qc,jS as $c,jT as el,jc as tl,jf as nl,jg as rl,jm as il,jp as al,jr as ol,ju as sl,jy as cl,kE as ll,kS as ul,kT as dl,kb as fl,kc as pl,kg as ml,kh as hl,km as gl,ko as _l,kw as vl,kx as yl,ky as bl,lC as xl,lS as Sl,lh as Cl,li as wl,ll as Tl,lm as El,lt as Dl,lu as Ol,lx as kl,mS as Al,ma as jl,mb as Ml,mm as Nl,mo as Pl,mp as Fl,mr as Il,mu as Ll,my as Rl,nT as zl,na as Bl,nd as Vl,nm as Hl,no as Ul,nr as Wl,oT as Gl,oa as Kl,ob as ql,oc as Jl,od as Yl,ol as Xl,op as Zl,or as Ql,os as $l,ox as eu,pS as tu,pa as nu,pb as ru,ph as iu,pi as au,pm as ou,po as su,pu as cu,pw as lu,px as uu,py as du,q as fu,qC as pu,qD as mu,qE as hu,qS as J,qT as gu,qf as _u,qg as vu,qi as yu,ql as bu,qo as xu,qx as Su,rT as Cu,ra as wu,rd as Tu,rg as Eu,rh as Du,rm as Ou,ro as ku,rp as Au,sC as ju,sa as Mu,sd as Nu,sh as Pu,si as Fu,sl as Iu,sm as Lu,su as Ru,tS as zu,ta as Bu,tm as Vu,tp as Hu,tt as Uu,tw as Wu,tx as Gu,uC as Ku,uS as qu,ua as Ju,ub as Yu,uh as Xu,ul as Zu,um as Qu,uo as $u,ur as ed,ut as td,uu as nd,uw as rd,vi as id,vp as ad,vs as od,vu as sd,vw as cd,vx as ld,wO as ud,wS as dd,wT as fd,wf as pd,wi as md,wu as hd,ww as gd,wx as _d,x as vd,xE as yd,xS as bd,xb as xd,xf as Sd,xv as Cd,xw as wd,xx as Td,yf as Ed,yg as Dd,yn as Od,yo as kd,ys as Ad,yv as jd,yw as Md,yx as Nd,zC as Pd,zE as Fd,za as Id,zb as Ld,zc as Rd,zf as zd,zg as Bd,zl as Vd,zm as Hd,zn as Ud,zo as Wd,zp as Gd,zs as Kd,zw as qd,zx as Jd}from"./loadAgentsDir-BURvZNN6.js";import{n as Yd,t as Xd}from"./cwd-CYmmnQVS.js";import{C as Zd,D as Qd,F as $d,G as ef,Q as tf,S as nf,V as rf,W as af,_ as of,a as sf,d as cf,l as Y,nt as lf,p as uf,rt as df,w as ff,z as pf}from"./debug-BrXObCdR.js";import{B as mf,Bt as hf,Ft as gf,Ht as _f,It as vf,Jt as yf,Kt as bf,L as xf,Pt as Sf,St as Cf,Ut as wf,Vt as Tf,Wt as Ef,Xt as Df,Zt as Of,_n as kf,c as Af,cn as jf,dn as Mf,f as Nf,ft as Pf,g as Ff,gn as If,n as Lf,vn as Rf,y as zf}from"./settings-DfWP5y6X.js";import{P as Bf,b as Vf,c as Hf,g as Uf,l as Wf,n as Gf}from"./config-DiT2Z8dY.js";import{M as Kf,_ as qf,a as Jf,d as Yf,i as Xf,j as Zf}from"./git-Do0wJvux.js";import{r as Qf,t as $f}from"./execFileNoThrow-D244NytW.js";import{B as ep,L as tp,N as np,R as rp,U as ip,Y as ap,k as op,o as sp,s as X}from"./log-BMCygSzM.js";import{n as cp,t as lp}from"./memoize-B0zhbT8Z.js";import{n as up,t as dp}from"./which-CKQnSouy.js";import{i as fp,o as pp}from"./platform-BrYefG_2.js";import{i as mp,n as hp,o as gp,r as _p}from"./path-D5U-tm91.js";import{D as vp,E as yp,T as bp,f as xp,l as Sp}from"./file-DcZWPH2V.js";import{s as Cp,u as wp}from"./types-C-MRCL8J.js";import{n as Tp,r as Z}from"./analytics-BotDBGh0.js";import{c as Ep,n as Dp,s as Op,t as kp}from"./intl-cKc-V6Mq.js";import{T as Ap,b as jp,d as Mp,f as Np,u as Pp,y as Fp}from"./startupProfiler-xa3NmN7Z.js";import{l as Ip,u as Lp}from"./oauth-BqJqV-2M.js";import{n as Rp,t as zp}from"./bundledMode--fG1S62b.js";import{a as Bp,d as Vp,l as Hp,o as Up,r as Wp,s as Gp}from"./stringUtils-DGLPkqJ4.js";import{C as Kp,Ct as qp,D as Jp,Dt as Yp,Er as Xp,Hn as Zp,It as Qp,Kt as $p,Qr as em,T as tm,Tr as nm,Ut as rm,Vn as im,Vt as am,Xr as om,Z as sm,Zt as cm,_ as lm,at as um,b as dm,ci as fm,cr as pm,ct as mm,en as hm,er as gm,h as _m,ht as vm,ir as ym,it as bm,jt as xm,lt as Sm,m as Cm,nn as wm,nr as Tm,nt as Em,oi as Dm,ot as Om,qn as km,rt as Am,si as jm,sr as Mm,st as Nm,tt as Pm,u as Fm,wt as Im,x as Lm}from"./model-BIVmcl_N.js";import{At as Rm,Cn as zm,Et as Bm,Ht as Vm,Tn as Hm,Tt as Um,Ut as Wm,an as Gm,bn as Km,dn as qm,fn as Jm,hn as Ym,jt as Xm,mn as Zm,st as Qm,yn as $m}from"./prompt-DNDgGM9q.js";import{et as eh,rt as th}from"./esm-B62dCLgf.js";import{a as nh,i as rh,r as ih}from"./shellQuote-DkSy9MYE.js";import{a as ah}from"./ripgrep-BXmXjAzA.js";import{a as oh,o as sh,s as ch}from"./fileStateCache-DDW5toIs.js";import{C as lh,N as uh,S as dh,T as fh,b as ph,d as mh,f as hh,j as gh,st as _h,w as vh,x as yh,y as bh}from"./rcDebugLog-DoL1FpGJ.js";import{T as xh,c as Sh,r as Ch,w as wh}from"./sessionTracing-CCPRzOvy.js";import{i as Th,n as Eh,r as Dh}from"./parser-DFwaTGf7.js";import{c as Oh,l as kh}from"./commitAttribution-CLbEIaRJ.js";import{n as Ah,t as jh}from"./poorMode-CtcqaiwD.js";import{a as Mh,f as Nh,l as Ph,o as Fh}from"./api-C-rOQY-l.js";import{f as Ih,m as Lh}from"./firstPartyEventLogger-CuUiNdj8.js";import{l as Rh,u as zh}from"./referral-UKJv23_5.js";import{i as Bh,m as Vh,n as Hh,p as Uh}from"./terminalSetup-BNs9nLbT.js";import{n as Wh,t as Gh}from"./browser-BmZuQom6.js";import{i as Kh,r as qh}from"./bridgeEnabled-FjPuA7zx.js";import{n as Jh,r as Yh}from"./undercover-BTIRVF1t.js";import{t as Xh}from"./Dialog-vfLXEPed.js";import{t as Zh}from"./lib-BlVGipXx.js";import{n as Qh,t as $h}from"./mappers-Q_Z3Kjo-.js";import{n as eg,r as tg}from"./sessionTitle-pWMaI79N.js";import{t as ng}from"./bridgeMessaging-N5zlzCCr.js";import{C as rg,S as ig,d as ag,l as og}from"./pidLock-C69HNTTb.js";import{n as sg,t as cg}from"./nativeInstaller-8arnRiUO.js";import{r as lg,t as ug}from"./pipeTransport-CqCnc-Ys.js";import{t as dg}from"./useManagePlugins-BzFKIDrD.js";import{n as fg,t as pg}from"./MCPConnectionManager-CaBvO7NB.js";import{i as mg,n as hg,r as gg,t as _g}from"./reconciler-CJcSh6xo.js";import{n as vg,t as yg}from"./toolPool-CNYKDRq5.js";import{a as bg,c as xg,i as Sg,l as Cg,r as wg,t as Tg,u as Eg}from"./MessageSelector-DOB1S2-O.js";import{n as Dg,t as Og}from"./useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js";import{n as kg,t as Ag}from"./sideQuestion-D03MXdE2.js";import{a as jg,n as Mg,o as Ng,r as Pg,s as Fg,t as Ig}from"./skillChangeDetector-uCaYrerZ.js";import{n as Lg,t as Rg}from"./refresh-ul_i5R1a.js";import{i as zg,n as Bg,r as Vg,t as Hg}from"./directoryCompletion-CW2ckkQg.js";import{r as Ug,t as Wg}from"./PromptInputFooterSuggestions-MwS_cExV.js";import{n as Gg,t as Kg}from"./useMergedTools-CRLWSGDl.js";import{a as qg,i as Jg,n as Yg,o as Xg,r as Zg,t as Qg}from"./promptEditor-DMJyosKj.js";import{n as $g,t as e_}from"./useMainLoopModel-CO4yBjRM.js";import{i as t_,n as n_,r as r_,t as i_}from"./PermissionDialog-0ya1CU5k.js";import{n as a_,t as o_}from"./RemoteCallout-ChCjmgw1.js";import{a as s_,c as c_,i as l_,o as u_,r as d_,s as f_}from"./caches-CcfPJ4_A.js";import{i as p_,n as m_,r as h_,t as g_}from"./conversation-awh8AwwL.js";import{a as __,i as v_,n as y_,o as b_,r as x_,s as S_,t as C_}from"./extraUsage-2DwLEr26.js";import{n as w_,t as T_}from"./useSearchInput-BzGq4t7t.js";import{n as E_,t as D_}from"./staticRender-BIxpgNUq.js";import{n as O_,t as k_}from"./useSettingsErrors-CSemUjj1.js";import{n as A_,t as j_}from"./shadowedRuleDetection-Chi3afMR.js";import{n as M_,t as N_}from"./ExitFlow-rExuBL3w.js";import{a as P_,i as F_,r as I_,t as L_}from"./fast-CW_NsL0x.js";import{n as R_,r as z_}from"./Feedback-gGpjUC_F.js";import{a as B_,i as V_,n as H_,r as U_,t as W_}from"./PromptInputHelpMenu-V2dEpzhC.js";import{n as G_,r as K_}from"./pluginAutoupdate-CTByPD8J.js";import{n as q_,r as J_}from"./autoModeDenials-BxNzGJdR.js";import{n as Y_,t as X_}from"./generateSessionName-BkDigIN8.js";import{a as Z_,c as Q_,d as $_,i as ev,l as tv,n as nv,o as rv,r as iv,s as av,t as ov,u as sv}from"./Messages-Clihwd2F.js";import{a as cv,i as lv,n as uv,o as dv,r as fv,t as pv}from"./BackgroundTasksDialog-D_UHm7xo.js";import{n as mv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as hv}from"./earlyInput-BTC_Wucv.js";import{a as gv,c as _v,i as vv,l as yv,o as bv,r as xv,s as Sv,t as Cv}from"./RemoteSessionManager-B43isWQs.js";import{n as wv,t as Tv}from"./backgroundHousekeeping-C9m4tiFi.js";import{n as Ev}from"./language-BA5WprZv.js";import{homedir as Dv,tmpdir as Ov}from"os";import*as kv from"path";import{basename as Av,dirname as jv,extname as Mv,join as Nv,relative as Pv,sep as Fv}from"path";import{dirname as Iv,join as Lv}from"node:path";import{watch as Rv}from"fs";import{createHash as zv}from"node:crypto";import{randomUUID as Bv}from"crypto";import{readFile as Vv,stat as Hv,writeFile as Uv}from"fs/promises";import{spawn as Wv,spawnSync as Gv}from"child_process";import{mkdir as Kv,readFile as qv,rename as Jv,writeFile as Yv}from"node:fs/promises";s(),c(),p(),R(),me(),u(),B(),Ee(),We(),at(),Yd(),lf(),ef(),pf(),nf(),uf(),sf(),Zf(),ap(),sp(),Qf(),lp(),dp(),qf(),pp(),mp(),yp(),kf(),Tp(),xp(),Cp(),Op(),jp(),Mf(),Oe(),Lp(),zp(),Of(),bf(),gf(),Cf(),xf(),Up(),Ff(),Bf(),Uf(),fm(),em(),Xp(),Mm(),ym(),km(),am(),Pm(),lm(),to(),hi(),Hm(),Km(),Ym(),Gm(),eh(),Ct(),Ur(),Xc(),ah(),Ns(),Wm(),Xm(),Bm(),Qm(),Pr(),Mo(),sh(),Fd(),Zc(),Ua(),mc(),da(),ts(),Fo(),gi(),Xs(),Ts(),po(),wh(),Dh(),ih(),Zn(),vl(),gd(),cd(),nc(),Wu(),os(),uh(),pu(),$n(),eo(),Ca(),pi(),pc(),xl(),zh(),ju(),Po(),$c(),ul(),Dn(),dd(),Fa(),Uh(),Bh(),Al(),Sa(),Qr(),Rh(),Uo(),ko(),Jd(),wn(),zn(),ld(),qo(),fl(),wc(),ql(),Qo(),Rl(),Gh(),dc(),Ir(),So(),Bi(),kt(),To(),si(),Mn(),bs(),El(),Hl(),Vo(),Gd(),xs(),Zl(),Hu(),ii(),Oi(),nl(),jn(),pd(),Sd(),Fs(),qh(),ao(),bo(),wr(),Xi(),bh(),Tu(),Xo(),Do(),zt(),Sn(),Ln(),sd(),kc(),Sh(),Ru(),qc(),bu(),K(),Ai(),za(),Pc(),Tl(),Iu(),yo(),Da(),tl(),pl(),Ds(),ba(),Eo(),Fn(),od(),xc(),$l(),Wd(),_o(),jl(),ga(),ol(),ci(),Od(),uc(),as(),fu(),Qn(),nn(),t_(),n_(),T_(),R_();var Q=n(z(),1);x(),nv(),yl(),Ji(),J(),D_();var $=ve();function Xv({children:e}){let{bindings:t}=xr(),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 Zv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Qv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>E_((0,$.jsx)(Gr,{children:(0,$.jsx)(Xv,{children:(0,$.jsx)(ov,{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+=Zv(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 $v(e,t=[],n){let r=[];return await Qv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}Oo(),Cd(),Qs(),Cl(),qg(),jc();function ey({onDone:e}){return(0,$.jsxs)(ge,{title:`You've spent $5 on the Anthropic 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)(ws,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),jc();function ty({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${ny(e)} and this conversation is ${Fp(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)(ws,{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 ny(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 ry(e,t){let n=Hf().preferredNotifChannel;await uo(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await ay(n,e,t),term:yf.terminal})}var iy=`Work Mate`;async function ay(e,t,n){let r=t.title||iy;try{switch(e){case`auto`:return oy(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:sy()}),`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 oy(e,t){let n=e.title||iy;switch(yf.terminal){case`Apple_Terminal`:return await cy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:sy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function sy(){return Math.floor(Math.random()*1e4)}async function cy(){try{if(yf.terminal!==`Apple_Terminal`)return!1;let e=(await $f(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await $f(`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 ly=300,uy=240*1e3,dy=null,fy=null,py=0,my=!1;function hy(){py++,py===1&&(by(),vy())}function gy(){py>0&&py--,py===0&&(yy(),xy())}function _y(){py=0,yy(),xy()}function vy(){process.platform===`darwin`&&fy===null&&(fy=setInterval(()=>{py>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),xy(),by())},uy),fy.unref())}function yy(){fy!==null&&(clearInterval(fy),fy=null)}function by(){if(process.platform===`darwin`&&dy===null){my||(my=!0,df(async()=>{_y()}));try{dy=Wv(`caffeinate`,[`-i`,`-t`,String(ly)],{stdio:`ignore`}),dy.unref();let e=dy;dy.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),dy===e&&(dy=null)}),dy.on(`exit`,()=>{dy===e&&(dy=null)}),Y(`Started caffeinate to prevent sleep`)}catch{dy=null}}}function xy(){if(dy!==null){let e=dy;dy=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var Sy=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 Cy(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(Fu(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=va(f,e).findLast(xi);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function wy(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function Ty(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 Ey(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&wy(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&wy(t.response)?t.response:void 0,r=Ty(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function Dy(t){{let{pauseProactive:t}=(bh(),e(lh));t()}t?.abort()}function Oy(e,t){return e<t}function ky(e,t){return e&&t===0}function Ay({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||Oy(n,r)}uu(),h_();function jy(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 My(e,t){return e.id.localeCompare(t.id)}function Ny(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(jy).sort(My)}}function Py(e,t){return JSON.stringify(Ny(e,t))}function Fy(e,t){let n=Ny(e,t);return{type:`task_state`,uuid:Bv(),...n}}B(),J(),sf();var Iy=50,Ly=5e3,Ry=1e4,zy=3;function By(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=Ko(),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 _=es(),{addNotification:v}=tr(),y=q(e=>e.replBridgeEnabled),b=q(e=>e.replBridgeConnected),x=q(e=>e.replBridgeSessionActive),S=q(e=>e.replBridgeOutboundOnly),C=q(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>=zy){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-myzllvlk.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-sxodu0xO.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-z2o4-UJe.js`);b=e()}async function x(e){try{let t=gg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-DZgSqDwY.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}`:``}`),Ka({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!==``?kl(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?ei(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,kd(`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))},Ry);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=Ey(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(){Dy(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(_n())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`&&!Tn()){let e=vd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${Ms(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Ki(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))},Ry);return}if(a.current=D,p_(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=ei(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:kl(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,Pl(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=$d(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))},Ry),r||t(e=>[...e,kd(`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,p_(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&&ky(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=Rv(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=jt();c(Yc(n));try{let r=await qi(n);if(e||a.current!==t)return;let i=Py(n,r);if(i===o&&t===s)return;t.writeSdkMessages([Fy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${$d(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},Iy),t.unref?.()};l();let d=Vn(u);return n=setInterval(()=>{l()},Ly),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(ky(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||Ay({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}js(),Gu(),cs(),Wt(),Ld(),Og(),wg(),Tp();var Vy=Te(()=>ye({method:xe(`log_event`),params:ye({eventName:be(),eventData:ye({}).passthrough()})}));function Hy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Ra(e);t&&t.client.setNotificationHandler(Vy(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}at(),B();var Uy=6e3;function Wy(){return Date.now()-ze()}function Gy(e){return Wy()<e}function Ky(e){return!Gy(e)}function qy(e,t){let n=E();(0,Q.useEffect)(()=>{vt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Ky(6e3)&&!r&&(r=!0,clearInterval(i),ry({message:e,notificationType:t},n))},Uy);return()=>clearInterval(i)},[e,t,n])}Pi(),ds(),Or(),ji(),Lt(),Zg(),B(),Ac();var Jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Yy(e){return Ga().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(qd());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({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)(()=>Xu(e,s,a),[e,s,a]).split(`
2
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=`${Jy.topLeft}${Jy.horizontal.repeat(v-2)}${Jy.topRight}`,C=`${Jy.bottomLeft}${Jy.horizontal.repeat(v-2)}${Jy.bottomRight}`,w=d?(()=>{let e=u.length-l,t=`${Jy.horizontal.repeat(3)} \u2702 ${Jy.horizontal.repeat(3)} ${e} lines hidden `,n=_(t),r=Math.max(0,v-2-n);return`${Jy.teeLeft}${t}${Jy.horizontal.repeat(r)}${Jy.teeRight}`})():null;return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:S}),m.map((e,t)=>{let n=_(e)>x?Cs(e,0,x):e,r=` `.repeat(Math.max(0,x-_(n)));return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[Jy.vertical,` `]}),(0,$.jsx)(g,{children:n}),(0,$.jsxs)(T,{dimColor:!0,children:[r,` `,Jy.vertical]})]},t)}),w&&(0,$.jsx)(T,{color:`warning`,children:w}),(0,$.jsx)(T,{dimColor:!0,children:C})]})}xl(),B(),jp();function Qy({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?Ap(e,l-2-2):Ap(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(),xl(),B(),J(),Bi();function $y({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=q(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),A=Jg(),M=A?ai(A):null,N=e.question,ee=i[N],P=e.options,[F,I]=(0,Q.useState)(0),te=(0,Q.useRef)(N);if(te.current!==N){te.current=N;let e=ee?.selectedValue,t=e?P.findIndex(t=>t.label===e):-1;I(t>=0?t:0)}let ne=P[F],L=ee?.selectedValue,R=ee?.textInputValue||``,re=(0,Q.useCallback)(e=>{let t=P[e];t&&(I(e),c(N,{selectedValue:t.label},!1),l(N,t.label))},[P,N,c,l]),ie=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?F>0?F-1:F:F<P.length-1?F+1:F,t>=0&&t<P.length&&I(t)},[F,P.length,E]);j(`chat:externalEditor`,async()=>{let e=ee?.textInputValue||``,t=await Yg(e);t.content!==null&&t.content!==e&&c(N,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!A}),v({"tabs:previous":()=>p?.(),"tabs:next":()=>h?.()},{context:`Tabs`,isActive:!E&&!x});let z=(0,Q.useCallback)(()=>{D(!1),u(!1),L&&l(N,L)},[L,N,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(),F>0&&ie(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),F===P.length-1?ae():ie(`down`);else if(e.key===`return`)e.preventDefault(),re(F);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<P.length&&ie(t)}},[x,C,y,E,F,P.length,oe,ae,ie,re,z,g,_,f,u]),ce=ne?.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)(Qy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(r_,{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:P.map((e,t)=>{let n=F===t,r=L===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)(Yy,{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)(Pa,{value:R,placeholder:`Add notes on this design…`,onChange:e=>{c(N,{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:R||`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&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}u(),B(),J(),qg(),Bi(),Zg(),jc(),t_();function eb({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=q(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[A,j]=(0,Q.useState)(!1),M=Jg(),N=M?ai(M):null,ee=(0,Q.useCallback)(e=>{let t=e===`__other__`;j(t),f(t)},[f]),P=(0,Q.useCallback)(()=>{D(!0)},[]),F=(0,Q.useCallback)(()=>{D(!1)},[]),I=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?F():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,F,v,y,p]),te=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),ne=e.question,L=i[ne],R=(0,Q.useCallback)(async(t,n)=>{let r=await Yg(t);r.content!==null&&r.content!==t&&(n(r.content),l(ne,{textInputValue:r.content},e.multiSelect??!1))},[ne,l,e.multiSelect]),re={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:L?.textInputValue??``,onChange:t=>{l(ne,{textInputValue:t},e.multiSelect??!1)}},ie=[...te,re];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)($y,{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:I,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)(Yo,{filePath:o})]})]}),(0,$.jsx)(b,{marginTop:-1,children:(0,$.jsx)(m,{color:`inactive`})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Qy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(r_,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(b,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Nd,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(ne,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[ne]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(ne,n,void 0,!1)},onFocus:ee,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:P,isDisabled:E,onOpenEditor:R,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question):(0,$.jsx)(ws,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(ne,{selectedValue:e},!1);let t=e===`__other__`?i[ne]?.textInputValue:void 0;u(ne,e,t)},onFocus:ee,onCancel:p,onDownFromLastItem:P,isDisabled:E,layout:`compact-vertical`,onOpenEditor:R,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:[ie.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:[ie.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`,A&&N&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,N]}),` · Esc to cancel`]})})]})]})]})}function tb(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(mf(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 nb({permissionResult:e,toolType:t}){let n=q(e=>e.toolPermissionContext.mode),r=tb(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,rb.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[i?(0,rb.jsx)(T,{color:i,children:r.reasonString}):(0,rb.jsx)(T,{children:(0,rb.jsx)(g,{children:r.reasonString})}),r.configString&&(0,rb.jsx)(T,{dimColor:!0,children:r.configString})]})}var rb,ib=t((()=>{z(),B(),J(),rb=ve()}));u(),B(),jc(),t_(),ib();function ab({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)(Qy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(r_,{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)(nb,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(T,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(ws,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function ob(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 sb={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function cb(){let[e,t]=(0,Q.useReducer)(ob,sb),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}}dd(),xl(),B(),zh(),Tp(),J(),Oo(),sp(),Qs();var lb=12,ub=40,db=15;function fb(e){return Ga().syntaxHighlightingDisabled?(0,$.jsx)(mb,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(mb,{...e,highlight:null}),children:(0,$.jsx)(pb,{...e})})}function pb(e){let t=(0,Q.use)(qd());return(0,$.jsx)(mb,{...e,highlight:t})}function mb({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Kt.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(lb,o-db);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=Xu(e.preview,s,r).split(`
3
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,lb),n),globalContentWidth:Math.max(t,ub)}},[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};Vt(s),sa(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=q(e=>e.toolPermissionContext.mode)===`plan`,x=b?ru():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:A}=cb(),j=S<(a?.length||0)?a?.[S]:null,M=S===(a?.length||0),N=a?.every(e=>e?.question&&!!C[e.question])??!1,ee=a.length===1&&!a[0]?.multiSelect,P=(0,Q.useCallback)(()=>{u&&Z(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&ri()}),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),F=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
4
  This means they may have additional information, context or questions for you.
@@ -68,7 +68,7 @@ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, o
68
68
  `)&&(a+=`
69
69
  `),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(Ep(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 UT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=BT(n.cursor,r,`G`,e,t);HT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function WT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=BT(n.cursor,r,`gg`,e,t);HT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var GT={d:`delete`,c:`change`,y:`yank`};function KT(e){return e in GT}var qT=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),JT=new Set([`f`,`F`,`t`,`T`]),YT={i:`inner`,a:`around`};function XT(e){return e in YT}var ZT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),QT=1e4;function $T(){return{mode:`INSERT`,insertedText:``}}function eE(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function tE(e,t,n){switch(e.type){case`idle`:return iE(t,n);case`count`:return aE(e,t,n);case`operator`:return oE(e,t,n);case`operatorCount`:return sE(e,t,n);case`operatorFind`:return cE(e,t,n);case`operatorTextObj`:return lE(e,t,n);case`find`:return uE(e,t,n);case`g`:return dE(e,t,n);case`operatorG`:return fE(e,t,n);case`replace`:return pE(e,t,n);case`indent`:return mE(e,t,n)}}function nE(e,t,n){return KT(e)?{next:{type:`operator`,op:GT[e],count:t}}:qT.has(e)?{execute:()=>{let r=yT(e,n.cursor,t);n.setOffset(r.offset)}}:JT.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:()=>PT(t,n)}:e===`x`?{execute:()=>MT(t,n)}:e===`J`?{execute:()=>FT(t,n)}:e===`p`||e===`P`?{execute:()=>IT(e===`p`,t,n)}:e===`D`?{execute:()=>OT(`delete`,`$`,1,n)}:e===`C`?{execute:()=>OT(`change`,`$`,1,n)}:e===`Y`?{execute:()=>jT(`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:()=>hE(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:()=>RT(`below`,n)}:e===`O`?{execute:()=>RT(`above`,n)}:null}function rE(e,t,n,r){return XT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:YT[n]}}:JT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:qT.has(n)?{execute:()=>OT(e,n,t,r)}:n===`G`?{execute:()=>UT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function iE(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:nE(e,1,t)||{}}function aE(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),QT))}}}return nE(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function oE(e,t,n){return t===e.op[0]?{execute:()=>jT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:rE(e.op,e.count,t,n)||{next:{type:`idle`}}}function sE(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),QT);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return rE(e.op,i,t,n)||{next:{type:`idle`}}}function cE(e,t,n){return{execute:()=>kT(e.op,e.find,t,e.count,n)}}function lE(e,t,n){return ZT.has(t)?{execute:()=>AT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function uE(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 dE(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=yT(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
70
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 fE(e,t,n){return t===`j`||t===`k`?{execute:()=>OT(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>WT(e.op,e.count,n)}:{next:{type:`idle`}}}function pE(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>NT(t,e.count,n)}}function mE(e,t,n){return t===e.dir?{execute:()=>LT(e.dir,e.count,n)}:{next:{type:`idle`}}}function hE(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)}Sa(),Op();function gE(e){let t=Q.useRef($T()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(eE()),a=cr({...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=Zo.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`:MT(t.count,r);break;case`replace`:NT(t.char,t.count,r);break;case`toggleCase`:PT(t.count,r);break;case`indent`:LT(t.dir,t.count,r);break;case`join`:FT(t.count,r);break;case`openLine`:RT(t.direction,r);break;case`operator`:OT(t.op,t.motion,t.count,r);break;case`operatorFind`:kT(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:AT(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=Zo.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,-(Ep(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=tE(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}}R(),B();function _E(e){let[t]=y(),n=M();vn(n,!!e.onImagePaste);let r=gE({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)(tn,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}kh(),Jh(),In(),lg(),U_(),s();function vE(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 yE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function bE(e){let t=zv(`sha256`).update(e).digest(`hex`).slice(0,16);return Lv(o(),`cache-stats`,`${t}.json`)}var xE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function SE(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 CE(e){try{let t=await qv(e,`utf8`),n=JSON.parse(t);return SE(n)?n:{...xE}}catch{return{...xE}}}async function wE(e,t){await Kv(Iv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Yv(n,JSON.stringify(t),`utf8`),await Jv(n,e)}catch{}}var TE={signature:null,lastResetAt:null,lastHitRate:null},EE=null;async function DE(e){EE=e;let t=await CE(bE(e));TE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function OE(e){let t=yE(e),n=vE(e);return t!==TE.signature&&(TE={signature:t,lastResetAt:Date.now(),lastHitRate:n},EE!==null&&wE(bE(EE),{version:1,signature:t,lastResetAt:TE.lastResetAt,lastHitRate:n})),{...TE}}function kE(){return{...TE}}B(),jp(),xl();function AE(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 jE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function ME({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=`${Fp(n)}/${Fp(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(jE,{}),(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)(jE,{}),(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:[` `,AE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(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:[` `,AE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{children:Au(i)})]})]})}var NE=Q.memo(ME);Tp(),J(),at(),Po(),Zl(),e_(),dd(),B(),Uf(),km(),Yd(),sf(),Od(),Wd(),lm(),ol(),Ua(),jp();var PE=3600*1e3;function FE(e){return String(Math.floor(e)).padStart(2,`0`)}function IE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${FE(t)}:${FE(n)}`}function LE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=an(e),o=(0,Q.useRef)(null);if(a!==null){let e=yE(a);e!==o.current&&(o.current=e,OE(a))}let{lastResetAt:s,lastHitRate:c}=kE(),l=s===null?null:t-s,u=l===null?null:PE-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,DE(st()))},[]);let h=a===null?c:vE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:IE(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 RE(){let{getGoal:t,formatGoalStatusLabel:n}=(xs(),e(Lc)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Fp(r.tokensUsed):`${Fp(r.tokensUsed)}/${Fp(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 zE(e){return Fe()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function BE(e,t,n,r,i,a,o){let s=$e(),c=mn(),l=Cm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=an(r),f=Zp(l,pt()),p=im(d,f),m=Il(st()),h=no(),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{...Xn(),...m&&{session_name:m},model:{id:l,display_name:tm(l)},workspace:{current_dir:Xd(),project_dir:ut(),added_dirs:i},version:`0.0.3`,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},...B_()&&{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 VE(e){return _l(e)?.uuid??null}function HE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=q(e=>e.toolPermissionContext.mode),a=q(e=>e.toolPermissionContext.additionalWorkingDirectories),o=q(e=>e.statusLineText),s=Ko(),c=Ga(),{addNotification:l}=tr(),u=$g(),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=VE(n);r!==_.current.messageId&&(e=yd(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await sc(BE(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`}),Gf()||(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=Cm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=Zp(D,pt()),k=an(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(im(k,O).used??0):0,M=no(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},ee=c?.statusLineEnabled===!0,P=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[ee&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(NE,{modelName:tm(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:lt(),rateLimits:N}),(0,$.jsx)(RE,{}),(0,$.jsx)(LE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):P&&Su()?(0,$.jsx)(T,{children:` `}):null]})}var UE=(0,Q.memo)(HE);u(),J(),zt(),Kn(),B();function WE({tasksSelected:e,onOpenDialog:t}){let n=q(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>vo(e)&&!(process.env.USER_TYPE===`ant`&&Si(e))),[n]);return lv(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(GE,{selected:e,onClick:t,children:ta(r)}),Er(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function GE({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(),Jd();function KE({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)(Pa,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Qf(),qf(),nf();var qE=5e3;function JE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function YE(){if(!await Yf())return null;let[e,t]=await Promise.all([Xf(),Jf()]);if(e===t)return null;let{stdout:n,code:r}=await $f(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Zd(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:JE(e.isDraft,e.reviewDecision)}}catch{return null}}at();var XE=6e4,ZE=4e3,QE=60*6e4,$E={number:null,url:null,reviewState:null,lastUpdated:0};function eD(e,t=!0){let[n,r]=(0,Q.useState)($E),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>=QE)return;let l=Date.now(),u=await YE();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>ZE){a.current=!0;return}e||(i.current=setTimeout(c,XE))}}let l=Date.now()-o.current;return l>=XE?c():i.current=setTimeout(c,XE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),U_(),wn(),gf(),Wt(),zt(),kf(),fv(),J(),at(),xl(),jp(),Qr(),Uf(),pp(),Hd();var tD=(bh(),e(lh)),nD=e=>()=>{},rD=()=>null,iD=5e3,aD=1e3;function oD(){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=Mp(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,iD);return()=>clearInterval(n)},[]),e}function sD(){let e=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),[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 `,Pp(t*1e3,{mostSignificantOnly:!0})]})}function cD(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),aD);return()=>clearInterval(e)},[]);let r=(xs(),e(Lc)),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 lD({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=B_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(KE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(uD,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function uD({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=Wi(`chat:cycleMode`,`Chat`,`shift+tab`),u=q(e=>e.tasks),f=es(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=eD(i,fD()),g=q(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),v=L(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>If(Object.values(u),e=>vo(e)&&!(process.env.USER_TYPE===`ant`&&Si(e))),[u]),w=pa(),E=w!==void 0&&w.length>0,D=Wi(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=Wi(`app:toggleTodos`,`Global`,`ctrl+t`),A=Wi(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),j=q(e=>e.notifications.current?.key===`kill-agents-confirm`),M=oD();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let N=n?.mode,ee=!vf(N),P=S>0,F=+!!ee+ +!!P,I=fD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&F<2&&(F===0||c>=80),te=F<2,ne=N&&ee&&!je()?(0,$.jsxs)(T,{color:Sf(N),children:[hf(N),` `,Tf(N).toLowerCase(),` on`,te&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,R=[...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`)]:[],...I?[(0,$.jsx)(Aa,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...M?[(0,$.jsxs)(T,{dimColor:M.level===`normal`,color:M.level===`error`?`error`:M.level===`warning`?`warning`:void 0,children:[M.text,` · pid:`,process.pid]},`rss`)]:[],...(xs(),e(Lc)).getGoal()?[(0,$.jsx)(cD,{},`goal-elapsed`)]:[]],re=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),ie=r?dD(i,D,k,A,E,re,j):[];x?R.push((0,$.jsx)(sD,{},`proactive`)):r&&R.push(...ie);let z=P&&!lv(u,!1)?(0,$.jsx)(WE,{tasksSelected:a,onOpenDialog:s}):null;R.length===0&&!z&&!ne&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Hf().copyOnSelect??!0,oe=v&&(!ae||se());if(Su()&&oe){let e=fp()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);R.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&&R.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),R.length===0&&!z&&!ne?Su()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[ne&&(0,$.jsxs)(b,{flexShrink:0,children:[ne,(z||R.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,R.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),R.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:R})})]})}function dD(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 fD(){return Hf().prStatusFooterEnabled??!0}uu(),dd(),xl(),B(),Td(),J(),Qr(),Ug(),H_();function pD({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:A,onOpenTasksDialog:j}){let M=Ga(),{columns:N,rows:ee}=de(),P=(0,Q.useRef)(E);P.current=E;let F=(0,Q.useMemo)(()=>VE(E),[E]),I=N<80,te=Su(),ne=te&&ee<24,L=_,R=h||zE(M)||D;return Q_((0,Q.useMemo)(()=>te&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[te,u,d,f])),u.length&&!te?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Wg,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(W_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:I?`column`:`row`,justifyContent:I?`flex-start`:`space-between`,paddingX:2,gap:+!I,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!I,children:[i===`prompt`&&!ne&&!n.show&&!C&&zE(M)&&(0,$.jsx)(UE,{messagesRef:P,lastAssistantMessageId:F,vimMode:r}),(0,$.jsx)(gD,{}),(0,$.jsx)(lD,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:R,isLoading:g,tasksSelected:L,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[te?null:(0,$.jsx)(OC,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:I}),process.env.USER_TYPE===`ant`&&Yh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(hD,{bridgeSelected:v})]})]})})}var mD=(0,Q.memo)(pD);function hD({bridgeSelected:e}){let t=q(e=>e.replBridgeEnabled),n=q(e=>e.replBridgeConnected),r=q(e=>e.replBridgeSessionActive),i=q(e=>e.replBridgeReconnecting),a=q(e=>e.replBridgeExplicit);if(!Kh()||!t)return null;let o=Sc({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 gD(){return null}u(),B();function _D({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function vD({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)(_D,{isLoading:t})})}B(),J(),ar(),gi(),Wd(),nf(),il();var yD=new Set;function bD(e){try{return Zd(e)?.type===`idle_notification`}catch{return!1}}var xD=3;function SD(e){return`<${ep}>
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=Zo.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`:MT(t.count,r);break;case`replace`:NT(t.char,t.count,r);break;case`toggleCase`:PT(t.count,r);break;case`indent`:LT(t.dir,t.count,r);break;case`join`:FT(t.count,r);break;case`openLine`:RT(t.direction,r);break;case`operator`:OT(t.op,t.motion,t.count,r);break;case`operatorFind`:kT(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:AT(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=Zo.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,-(Ep(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=tE(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}}R(),B();function _E(e){let[t]=y(),n=M();vn(n,!!e.onImagePaste);let r=gE({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)(tn,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}kh(),Jh(),In(),lg(),U_(),s();function vE(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 yE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function bE(e){let t=zv(`sha256`).update(e).digest(`hex`).slice(0,16);return Lv(o(),`cache-stats`,`${t}.json`)}var xE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function SE(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 CE(e){try{let t=await qv(e,`utf8`),n=JSON.parse(t);return SE(n)?n:{...xE}}catch{return{...xE}}}async function wE(e,t){await Kv(Iv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Yv(n,JSON.stringify(t),`utf8`),await Jv(n,e)}catch{}}var TE={signature:null,lastResetAt:null,lastHitRate:null},EE=null;async function DE(e){EE=e;let t=await CE(bE(e));TE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function OE(e){let t=yE(e),n=vE(e);return t!==TE.signature&&(TE={signature:t,lastResetAt:Date.now(),lastHitRate:n},EE!==null&&wE(bE(EE),{version:1,signature:t,lastResetAt:TE.lastResetAt,lastHitRate:n})),{...TE}}function kE(){return{...TE}}B(),jp(),xl();function AE(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 jE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function ME({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=`${Fp(n)}/${Fp(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(jE,{}),(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)(jE,{}),(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:[` `,AE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(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:[` `,AE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{children:Au(i)})]})]})}var NE=Q.memo(ME);Tp(),J(),at(),Po(),Zl(),e_(),dd(),B(),Uf(),km(),Yd(),sf(),Od(),Wd(),lm(),ol(),Ua(),jp();var PE=3600*1e3;function FE(e){return String(Math.floor(e)).padStart(2,`0`)}function IE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${FE(t)}:${FE(n)}`}function LE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=an(e),o=(0,Q.useRef)(null);if(a!==null){let e=yE(a);e!==o.current&&(o.current=e,OE(a))}let{lastResetAt:s,lastHitRate:c}=kE(),l=s===null?null:t-s,u=l===null?null:PE-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,DE(st()))},[]);let h=a===null?c:vE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:IE(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 RE(){let{getGoal:t,formatGoalStatusLabel:n}=(xs(),e(Lc)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Fp(r.tokensUsed):`${Fp(r.tokensUsed)}/${Fp(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 zE(e){return Fe()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function BE(e,t,n,r,i,a,o){let s=$e(),c=mn(),l=Cm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=an(r),f=Zp(l,pt()),p=im(d,f),m=Il(st()),h=no(),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{...Xn(),...m&&{session_name:m},model:{id:l,display_name:tm(l)},workspace:{current_dir:Xd(),project_dir:ut(),added_dirs:i},version:`0.0.4`,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},...B_()&&{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 VE(e){return _l(e)?.uuid??null}function HE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=q(e=>e.toolPermissionContext.mode),a=q(e=>e.toolPermissionContext.additionalWorkingDirectories),o=q(e=>e.statusLineText),s=Ko(),c=Ga(),{addNotification:l}=tr(),u=$g(),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=VE(n);r!==_.current.messageId&&(e=yd(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await sc(BE(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`}),Gf()||(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=Cm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=Zp(D,pt()),k=an(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(im(k,O).used??0):0,M=no(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},ee=c?.statusLineEnabled===!0,P=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[ee&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(NE,{modelName:tm(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:lt(),rateLimits:N}),(0,$.jsx)(RE,{}),(0,$.jsx)(LE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):P&&Su()?(0,$.jsx)(T,{children:` `}):null]})}var UE=(0,Q.memo)(HE);u(),J(),zt(),Kn(),B();function WE({tasksSelected:e,onOpenDialog:t}){let n=q(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>vo(e)&&!(process.env.USER_TYPE===`ant`&&Si(e))),[n]);return lv(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(GE,{selected:e,onClick:t,children:ta(r)}),Er(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function GE({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(),Jd();function KE({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)(Pa,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Qf(),qf(),nf();var qE=5e3;function JE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function YE(){if(!await Yf())return null;let[e,t]=await Promise.all([Xf(),Jf()]);if(e===t)return null;let{stdout:n,code:r}=await $f(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Zd(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:JE(e.isDraft,e.reviewDecision)}}catch{return null}}at();var XE=6e4,ZE=4e3,QE=60*6e4,$E={number:null,url:null,reviewState:null,lastUpdated:0};function eD(e,t=!0){let[n,r]=(0,Q.useState)($E),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>=QE)return;let l=Date.now(),u=await YE();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>ZE){a.current=!0;return}e||(i.current=setTimeout(c,XE))}}let l=Date.now()-o.current;return l>=XE?c():i.current=setTimeout(c,XE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),U_(),wn(),gf(),Wt(),zt(),kf(),fv(),J(),at(),xl(),jp(),Qr(),Uf(),pp(),Hd();var tD=(bh(),e(lh)),nD=e=>()=>{},rD=()=>null,iD=5e3,aD=1e3;function oD(){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=Mp(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,iD);return()=>clearInterval(n)},[]),e}function sD(){let e=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),[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 `,Pp(t*1e3,{mostSignificantOnly:!0})]})}function cD(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),aD);return()=>clearInterval(e)},[]);let r=(xs(),e(Lc)),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 lD({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=B_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(KE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(uD,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function uD({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=Wi(`chat:cycleMode`,`Chat`,`shift+tab`),u=q(e=>e.tasks),f=es(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=eD(i,fD()),g=q(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),v=L(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>If(Object.values(u),e=>vo(e)&&!(process.env.USER_TYPE===`ant`&&Si(e))),[u]),w=pa(),E=w!==void 0&&w.length>0,D=Wi(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=Wi(`app:toggleTodos`,`Global`,`ctrl+t`),A=Wi(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),j=q(e=>e.notifications.current?.key===`kill-agents-confirm`),M=oD();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let N=n?.mode,ee=!vf(N),P=S>0,F=+!!ee+ +!!P,I=fD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&F<2&&(F===0||c>=80),te=F<2,ne=N&&ee&&!je()?(0,$.jsxs)(T,{color:Sf(N),children:[hf(N),` `,Tf(N).toLowerCase(),` on`,te&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,R=[...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`)]:[],...I?[(0,$.jsx)(Aa,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...M?[(0,$.jsxs)(T,{dimColor:M.level===`normal`,color:M.level===`error`?`error`:M.level===`warning`?`warning`:void 0,children:[M.text,` · pid:`,process.pid]},`rss`)]:[],...(xs(),e(Lc)).getGoal()?[(0,$.jsx)(cD,{},`goal-elapsed`)]:[]],re=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),ie=r?dD(i,D,k,A,E,re,j):[];x?R.push((0,$.jsx)(sD,{},`proactive`)):r&&R.push(...ie);let z=P&&!lv(u,!1)?(0,$.jsx)(WE,{tasksSelected:a,onOpenDialog:s}):null;R.length===0&&!z&&!ne&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Hf().copyOnSelect??!0,oe=v&&(!ae||se());if(Su()&&oe){let e=fp()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);R.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&&R.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),R.length===0&&!z&&!ne?Su()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[ne&&(0,$.jsxs)(b,{flexShrink:0,children:[ne,(z||R.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,R.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),R.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:R})})]})}function dD(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 fD(){return Hf().prStatusFooterEnabled??!0}uu(),dd(),xl(),B(),Td(),J(),Qr(),Ug(),H_();function pD({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:A,onOpenTasksDialog:j}){let M=Ga(),{columns:N,rows:ee}=de(),P=(0,Q.useRef)(E);P.current=E;let F=(0,Q.useMemo)(()=>VE(E),[E]),I=N<80,te=Su(),ne=te&&ee<24,L=_,R=h||zE(M)||D;return Q_((0,Q.useMemo)(()=>te&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[te,u,d,f])),u.length&&!te?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Wg,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(W_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:I?`column`:`row`,justifyContent:I?`flex-start`:`space-between`,paddingX:2,gap:+!I,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!I,children:[i===`prompt`&&!ne&&!n.show&&!C&&zE(M)&&(0,$.jsx)(UE,{messagesRef:P,lastAssistantMessageId:F,vimMode:r}),(0,$.jsx)(gD,{}),(0,$.jsx)(lD,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:R,isLoading:g,tasksSelected:L,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[te?null:(0,$.jsx)(OC,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:I}),process.env.USER_TYPE===`ant`&&Yh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(hD,{bridgeSelected:v})]})]})})}var mD=(0,Q.memo)(pD);function hD({bridgeSelected:e}){let t=q(e=>e.replBridgeEnabled),n=q(e=>e.replBridgeConnected),r=q(e=>e.replBridgeSessionActive),i=q(e=>e.replBridgeReconnecting),a=q(e=>e.replBridgeExplicit);if(!Kh()||!t)return null;let o=Sc({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 gD(){return null}u(),B();function _D({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function vD({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)(_D,{isLoading:t})})}B(),J(),ar(),gi(),Wd(),nf(),il();var yD=new Set;function bD(e){try{return Zd(e)?.type===`idle_notification`}catch{return!1}}var xD=3;function SD(e){return`<${ep}>
72
72
  <${rp}>+${e} more tasks completed</${rp}>
73
73
  <${tp}>completed</${tp}>
74
74
  </${ep}>`}function CD(e){let t=e.filter(e=>typeof e.value!=`string`||!bD(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=xD)return[...r,...n];let i=n.slice(0,xD-1),a={value:SD(n.length-(xD-1)),mode:`task-notification`};return[...r,...i,a]}function wD(){let e=mC(),t=q(e=>!!e.viewingAgentTaskId),n=q(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(Yi);return t.length===0?null:xu(CD(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Ba({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(b,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(Bo,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(gl,{message:e,lookups:fa,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:yD,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var TD=Q.memo(wD);co(),u(),B();function ED({hasStash:e}){return e?(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Al();var DD=1e4,OD=1e3;function kD(e,t){if(e.length<=DD)return{truncatedText:e,placeholderContent:``};let n=Math.floor(OD/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+AD(t,tu(a))+i,placeholderContent:a}}function AD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function jD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=kD(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function MD({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}=jD(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(),Uf(),gi();var ND=(bh(),e(lh)),PD=3;function FD({input:e,submitCount:t}){let n=mC(),r=q(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Ti)&&(Hf().queuedCommandUpHintCount||0)<PD)return`Press up to edit queued messages`;if(t<1&&r&&!ND?.isProactiveActive())return yv()}},[e,n,t,r])}var ID=5e3,LD=!1;function RD(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(LD||!e)return;LD=!0,n(!0);let t=setTimeout(n,ID,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}R(),Po(),Tp(),J(),Yd(),gi(),x(),ga(),Td(),av(),Al(),e_(),xl(),B(),yl(),$c(),zh(),os(),kf(),Sa(),Uf(),sf(),Of(),pf(),Qr(),Pi(),sp(),lm(),pp(),Zg(),zn(),Jd(),fv(),Fa(),U_();var zD=5,BD=3;function VD({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:A,onExit:M,getToolUseContext:N,onSubmit:ee,isSearchingHistory:F,setIsSearchingHistory:I,onDismissSideQuestion:te,isSideQuestionVisible:ne,helpOpen:L,setHelpOpen:R,hasSuppressedDialogs:re,isLocalJSXCommandActive:z=!1,insertTextRef:ae}){let se=$g(),ce=Ha()||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=es(),U=Ko(),_e=q(e=>e.tasks),ve=q(e=>e.replBridgeConnected),ye=q(e=>e.replBridgeExplicit),be=q(e=>e.replBridgeReconnecting),xe=ve&&(ye||be),Se=q(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Ce=process.env.USER_TYPE===`ant`&&Se,we=q(e=>!1),Te=mC(),Ee=q(e=>e.promptSuggestion),De=q(e=>e.speculation),Oe=q(e=>e.speculationSessionTimeSavedMs),ke=q(e=>e.isBriefOnly),Ae=q(e=>e.mainLoopModel),je=q(e=>e.mainLoopModelForSession),Me=q(e=>e.thinkingEnabled),Ne=q(e=>bm()?e.fastMode:!1),Pe=q(e=>e.effortValue),Fe=q(e=>e.viewingAgentTaskId);q(e=>e.viewSelectionMode);let{historyQuery:Ie,setHistoryQuery:Le,historyMatch:Re,historyFailedMatch:ze}=LC(e=>{E(e.pastedContents),ln(e.display)},f,he,H,V,h,m,F,I,E,w),Be=(0,Q.useRef)(-1);Be.current===-1&&(Be.current=HD(l));let Ve=(0,Q.useRef)(!1),[He,Ue]=(0,Q.useState)(!1),We=q(e=>e.selectedBgAgentIndex),Ge=(0,Q.useCallback)(e=>U(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[U]),[Ke,qe]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(!1),[Xe,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(!1),[nt,rt]=(0,Q.useState)(!1),[it,at]=(0,Q.useState)(!1),[ot,st]=(0,Q.useState)(!1),ct=(0,Q.useMemo)(()=>{let e=f.indexOf(`
@@ -81,7 +81,7 @@ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, o
81
81
  Server disconnected.
82
82
  `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,Ku(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])}Hm(),sf(),pc();function cO({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(tO(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=eO(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useSSHSession] permission request: ${e.tool_name}`);let a=zm(l.current,e.tool_name)??KD(e.tool_name),o=GD(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:Bv(),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}`),Ku(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])}sf(),Fh();async function lO(e){let{accessToken:t,orgUUID:n}=await Ph();return{baseUrl:`${Ip().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...Mh(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function uO(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 dO(e,t=100){return uO(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function fO(e,t,n=100){return uO(e,{limit:n,before_id:t},`fetchOlderEvents`)}sf();var pO=40,mO=10,hO=`loading older messages…`,gO=`failed to load older messages — scroll up to retry`,_O=`start of session`;function vO(e){let t=[];for(let n of e.events){let e=eO(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function yO({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)(Bv());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=vO(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(_O);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 lO(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await dO(n);t||!r||(l.current=mO,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(hO),...t]});try{let r=await fO(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(gO),...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()<pO&&p()},[p])}}Up();var bO=400;function xO({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=bO}){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=Gp(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 SO=[`0`,`1`,`2`,`3`],CO={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},wO=e=>SO.includes(e),TO=`How is Claude doing this session? (optional)`;function EO({onSelect:e,inputValue:t,setInputValue:n,message:r=TO}){return xO({inputValue:t,setInputValue:n,isValidDigit:wO,onDigit:t=>e(CO[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`]})})]})]})}bf(),B(),Up();function DO({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!wO(i)?null:(0,$.jsx)(AO,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var OO=[`0`,`1`];function kO(e){return OO.includes(e)}function AO({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=Gp(r.slice(-1));kO(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:[wf,` `]}),(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`]})})]})]})}Tp(),J(),Wd();function jO(e){let t=q(e=>e.skillImprovement.suggestion),n=Ko(),[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&&wv(r.skillName,r.updates).then(()=>{e(e=>[...e,kd(`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 MO(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}sr(),fo(),td(),Zl();function NO(e){(0,Q.useEffect)(()=>{let t=()=>{jm()&&process.stdout.write(`
83
83
  `+Gc()+`
84
- `),Ws(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function PO(){(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 FO(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(),uc(),am();function IO(){let[e,t]=(0,Q.useState)(()=>{if(!rm()||$p())return`valid`;let{key:e,source:t}=qp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!rm()||$p()){t(`valid`);return}await Im(bt());let{key:e,source:n}=qp();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 Kc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}at(),B(),Yd(),sf(),B(),zh(),Tp(),J();function LO({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=q(e=>e.expandedView),d=Ko(),f=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[u,d]),p=q(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(Os(),e(Vc));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}=(Os(),e(Vc));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]);j(`app:toggleTodos`,f,{context:`Global`}),j(`app:toggleTranscript`,m,{context:`Global`}),j(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),j(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),j(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return j(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),j(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Td(),yl(),zh();var RO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function zO({onSubmit:e,isActive:t=!0}){let n=P(),r=Ha(),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}`,RO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Tp(),J(),U_(),Po(),Td(),$c(),zh(),zt(),gi();var BO=3e3;function VO(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=es(),g=Ko(),_=mC().length,{addNotification:v,removeNotification:y}=tr(),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(el()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=gn(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(B_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);j(`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;Mi(e,g);let n=[];for(let[e,r]of t)aa(e,g),n.push(r.description),gh(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return On({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 j(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),j(`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<=BO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),Ia(),k();return}b.current=t;let n=Nt(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:BO})},[h,v,y,k]),{context:`Chat`}),null}B(),J(),Wt();function HO(e){let t=q(e=>e.tasks),n=q(e=>e.pipeIpc),r=Object.values(t).some(vo),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 A(n.keypress))}),{handleKeyDown:i}}q_(),sp();async function UO(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 WO=new Map,GO=null;function KO(){return GO??null}function qO(e,t){let n=KO();if(!n)return null;let r=Bv(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return WO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function JO(e){e&&WO.delete(e)}function YO(e,t){if(!e)return;let n=KO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Tp(),eh(),kc(),sf(),Od(),Wd(),gd(),di();function XO(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 ZO(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){Na({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:th(e.name)})},async persistPermissions(e){return e.length===0?!1:(Rn(e),a(wd(n.getAppState().toolPermissionContext,e)),e.some(e=>Cn(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?ks:ku}${t}`:a?Wc:Ul,s=a?o:lc(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 or(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 QO(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))}}}sf(),B(),kc(),kt(),pf();function $O(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=XO(t),u,d,f=o?Bv():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){YO(h,e),JO(h),h=null}function _(){JO(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||_a(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 Ao(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=qO(v,e=>{l()&&(_(),_a(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),_a(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))})()}Tp(),eh(),B(),kc(),kt(),sf(),pf(),sp(),Qn(),nf(),di();function ek(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=ZO(n,r,i,a,o,t,QO(e));if(!l.resolveIfAborted(c))return(s===void 0?Ao(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:th(n.name),behavior:e.behavior,input:ff(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`&&ac(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`:Na({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(J_({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 UO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;$O({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof Qd||e instanceof tf?(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(()=>{_a(o)})}),[e,t])}mh(),Tp(),ga(),Al(),Yd(),sf(),pc(),pf(),sp(),gi(),lm();function tk(){Js(0)}async function nk(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){nd(),await rk({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(Cc(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(Rd);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?nk({...e,input:`/exit`}):tk();return}let j=Sl(T,k),M=Cc(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Z(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Ju(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,[],vr(),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?Ka({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`)),Ka({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}nd(),await rk({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function rk(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=vr();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Ol(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await Cu(w);w=T.attachmentCommands;let E=T.claimedCommands;if(w.length===0){l(null);return}let D=w[0]?.workload,O=D!==void 0&&w.every(e=>e.workload===D)?D:void 0,k=new Set,A;try{await pm(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await xg({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&k.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.effort,S=u.nextInput,C=u.submitNextInput)}if(Ol(`query_process_user_input_end`),cn()&&(Ol(`query_file_history_snapshot_start`),s.filter(bg).forEach(e=>{kn(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Ol(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=w[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?Jp(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?Ka({value:S,mode:`prompt`}):e.onInputChange(S))})}catch(e){A=e}if(E.length){let e=E.filter(e=>{let t=e.autonomy?.runId;return!t||!k.has(t)});if(A)try{await zc({commands:e,outcome:{type:`failed`,error:A},currentDir:Xd(),priority:`later`,workload:O})}catch(e){X(af(e))}else try{let t=await zc({commands:e,outcome:{type:`completed`},currentDir:Xd(),priority:`later`,workload:O});for(let e of t)Ka(e)}catch(e){X(af(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}gi();function ik(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 ak({executeInput:e}){let t=e=>e.agentId===void 0,n=Hn(t);if(!n)return{processed:!1};if(ik(n)||n.mode===`bash`)return e([sn(t)]),{processed:!0};let r=n.mode,i=fd(e=>t(e)&&!ik(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}gi();function ok({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(wa,dl);(0,Q.useEffect)(()=>{r||t||i.length!==0&&ak({executeInput:e})},[i,r,e,t,n])}function sk({isLoading:e,onSubmitMessage:t}){let n=Rs();(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 ck(e,t){return e&&t&&t.length>0?mi([...e,...t],`name`):e||[]}function lk(e,t){return(0,Q.useMemo)(()=>ck(e,t),[e,t])}Ht(),yg(),Kg(),Xc();function uk(e,t){return(0,Q.useMemo)(()=>t.length>0?mi([...e,...t],`name`):e,[e,t])}ga(),sp();function dk(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Co(),t(await yu(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Ig.subscribe(n),[n])}sp(),Ee(),Bi(),Oe();var fk=Te(()=>ye({method:xe(`selection_changed`),params:ye({selection:ye({start:ye({line:Se(),character:Se()}),end:ye({line:Se(),character:Se()})}).nullable().optional(),text:be().optional(),filePath:be().optional()})}));function pk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Ra(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(fk(),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])}hl(),B(),cv(),J(),jp();function mk({task:e,selected:t}){let n=dv(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,` · ↓ `,Fp(r),` tokens`]})})]})}function hk(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 gk(){let e=IC(),t=q(e=>e.viewingAgentTaskId),n=q(e=>e.footerSelection),r=q(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:hk(i,s)})]}),e.map(e=>(0,$.jsx)(mk,{task:e,selected:e.agentId===a},e.agentId))]})}sf(),pi();var _k=1e3;function vk({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 qi(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=yk(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await W(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=bk(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await G(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;Fi(e);let t=Yc(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),_k,l)};u.current=r;try{n=Rv(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 yk(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 bk(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}Uf(),s(),Bi();function xk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Hf().autoConnectIde||e||ki()||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`}})}ml(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}M_(),Rh(),B(),zh(),wn(),J(),Uf(),Of(),s();function Sk({onBackgroundSession:e,isLoading:t}){let n=Ko(),r=es(),[i,o]=(0,Q.useState)(!1),s=ie(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Za(r.getState())?(hd(()=>r.getState(),n),Hf().hasUsedBackgroundTask||Vf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=q(Za),u=a(`false`);j(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=Wi(`task:background`,`Task`,`ctrl+b`),f=yf.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 Ck({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=q(e=>e.foregroundedTaskId),o=q(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Ko(),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}}Bd(),B(),am(),Uf(),lm(),Ff(),ld(),S_(),n_();var wk=3e4;function Tk({model:e,onDone:t}){let n=Qc(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{kk()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,wk);return()=>clearTimeout(e)},[i]);let a=Wa(e),o=a?ud(a):`high`,s=(0,Q.useCallback)(e=>{zf(`userSettings`,{effortLevel:Ut(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(Dk,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(Dk,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(Dk,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(i_,{title:n.dialogTitle,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:n.dialogDescription})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[(0,$.jsx)(Ek,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(Ek,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(Ek,{level:`high`}),` high`]})}),(0,$.jsx)(ws,{options:c,onChange:s,onCancel:i})]})})}function Ek({level:e}){return(0,$.jsx)(T,{color:`suggestion`,children:__(e)})}function Dk({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ek,{level:e}),` `,t]})}function Ok(e){if(!Kp(e).toLowerCase().includes(`opus-4-6`))return!1;let t=Hf();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(kk(),!1):hm()?t.effortCalloutDismissed?(kk(),!1):Qc().enabled:cm()||wm()?Qc().enabled:(kk(),!1)}function kk(){Vf(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}fg(),a_();function Ak(e,t){return t}async function jk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=zr(e),i=await Br(Ql(e)),a;try{let e=Pn(),{size:t}=await Hv(e);t<=52428800?a=await Vv(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=z_(ff({trigger:t,version:`0.0.3`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await vm();let s=gm();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Tm(),...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($d(e),{level:`error`}),{success:!1}}}var Mk=t((()=>{p(),am(),sf(),pf(),Wd(),ol(),nf()}));Ih(),Mk();function Nk({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)(Bv()),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=Bv(),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])}}Tp(),Uf(),s(),Wd(),lm(),Ff();var Pk={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},Fk={probability:0};function Ik(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=_l(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=Ak(`tengu_feedback_survey_config`,Pk),u=Ak(`tengu_bad_survey_transcript_ask_config`,Fk),d=Ak(`tengu_good_survey_transcript_ask_config`,Fk),f=Lf().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}),Hf().feedbackSurveyState?.lastShownTime!==e&&Vf(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}),xh(`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}),xh(`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`||Hf().transcriptShareDismissed||!ro(`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}),xh(`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`&&Vf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(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}=Nk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Fm(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Lh()||!ro(`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=Hf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Ih(),Tp(),_o(),Uf(),s(),Wd(),wh(),Mk();var Lk=3e3,Rk=`tengu_memory_survey_event`,zk=`memory_survey`;function Bk(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}=Nk({hideThanksAfterMs:Lk,onOpen:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`appeared`,appearance_id:e}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(Rk,{event_type:`responded`,appearance_id:e,response:t}),xh(`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`||Hf().transcriptShareDismissed||!ro(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:zk}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(Rk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:zk}),t===`dont_ask_again`&&Vf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(o.current,zk,e);return Z(Rk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:zk}),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)(()=>_l(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Ih(),Tp(),s(),Wd(),wh();var Vk=3e3,Hk=.2;function Uk(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 Wk(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}=Nk({hideThanksAfterMs:Vk,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:Zu()}),xh(`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:Zu()}),xh(`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=>Zt(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||Lh()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Uk(e,c.current)){c.current=null,Math.random()<Hk&&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}}bf(),B();var Gk=[`1`,`2`,`3`],Kk={1:`yes`,2:`no`,3:`dont_ask_again`},qk=e=>Gk.includes(e);function Jk({onSelect:e,inputValue:t,setInputValue:n}){return xO({inputValue:t,setInputValue:n,isValidDigit:qk,onDigit:t=>e(Kk[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[wf,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can Anthropic 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`]})})]})]})}Tp(),B();function Yk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Zk,{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&&!wO(i)?null:(0,$.jsx)(EO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Xk=e=>e===`1`;function Zk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;xO({inputValue:t,setInputValue:n,isValidDigit:Xk,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.`]})]})}ag(),cg(),at(),Po(),sp();function Qk(e){let{addNotification:t}=tr(),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 $k(){Qk(async()=>(await sg()).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`}}))}ef(),sf(),Wd(),lm(),ts(),Ev(),uc(),B(),Wd();function eA(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=I();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{I()},[n,!1])}Tp(),Uf(),sf(),s(),pf(),sp();function tA(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var nA={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function rA(e){let t=nA.INITIAL_DELAY_MS*nA.BACKOFF_MULTIPLIER**e;return Math.min(t,nA.MAX_DELAY_MS)}function iA(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>=nA.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function aA(){let e=Hf();if(!iA(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(tA())return Y(`Official marketplace auto-install disabled via env var, skipping`),Vf(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 _r())[`claude-plugins-official`])return Y(`Official marketplace '${ss}' already installed, skipping`),Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Jl(ua))return Y(`Official marketplace blocked by enterprise policy, skipping`),Vf(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=Kd(),n=Nv(t,ss);if(await fs(n,t)!==null){let e=await _r();return e[ss]={source:ua,installLocation:n,lastUpdated:new Date().toISOString()},await Vr(e),Vf(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 er()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+rA(t),i=!1;try{Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(af(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 Yn(ua),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Vf(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 mu(),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(af(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+rA(r),o=!1;try{Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(af(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(),sf();function oA(){Qk(async()=>{let e=await aA(),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:`✓ Anthropic 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 Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Ff(),Tp();function sA(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vv(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function cA(e){if(Nf().spinnerTipsEnabled===!1)return;let t=await xv(e);if(t.length!==0)return sA(t)}function lA(e){gv(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}pf(),sp(),at(),J(),nn();var uA=!1;async function dA(e,t,n){{if(uA)return;uA=!0;let{updateContext:r,notification:i}=await br(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 fA(){uA=!1}function pA(){let e=q(e=>e.mainLoopModel),t=q(e=>e.mainLoopModelForSession),n=q(e=>e.fastMode),r=Ko(),i=es(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{je()||(a.current?a.current=!1:fA(),dA(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:af(e)}))}))},[e,t,n])}fl();function mA(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!cn()||r.current||(r.current=!0,e&&bn(e,n))},[t,e,n])}B(),Ns(),Tp(),ld(),n_();function hA({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`},...rn()?[]:[{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)(i_,{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)(ws,{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(),Ns(),pp();function gA(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function _A(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=gs.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!gs.isSandboxingEnabled()||fp()===`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:[gA(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]})})]})}k_(),Po(),at(),B();var vA=[];function yA({mcpClients:e=vA}){let{addNotification:t}=tr();(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`&&Tt(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`&&Tt(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(),Ff(),jc();var bA=`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(),Po(),B(),J(),sf(),s();var xA=5e3;function SA(){let{addNotification:e}=tr(),t=Ko(),[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=Fc();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=Ec();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);ne(s,n?xA:null),Q.useEffect(()=>{je()||!n||s()},[s,n])}sf();var CA=new Map;async function wA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=CA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await up(t).catch(()=>null)&&(r=!0),CA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Uf(),sf(),Eo();var TA=5;function EA(e){return Pf.has(e.toLowerCase())}function DA(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=kA(t);if(e)return e}return null}return kA(e)}function OA(e){return typeof e==`object`&&!!e}function kA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!OA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(OA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function AA(){let e=new Map;try{let t=await _r();for(let n of Object.keys(t))try{let t=await Ma(n),r=EA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=DA(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 jA(e){if(PA())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Mv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await AA(),r=Hf().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(Rt(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 wA(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 MA(e){Vf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function NA(){Vf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function PA(){let e=Hf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=TA}u(),at(),B(),sp(),Eo();function FA(){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 IA(e,t,n,r,i){try{let a=await $t(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(),Po(),J(),Uf(),sf(),sp(),Ff();var LA=28e3;function RA(){let e=q(e=>e.fileHistory.trackedFiles),{addNotification:t}=tr(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=FA();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 jA(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:Mv(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`:IA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Nv(e.marketplaceInstallLocation,e.entry.source):void 0;await Oc(n,e.entry,`user`,void 0,t),zf(`userSettings`,{enabledPlugins:{...Af(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=LA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),NA());break}case`never`:MA(n);break;case`disable`:Vf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),ld(),n_();var zA=3e4;function BA({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`),zA,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)(i_,{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)(ws,{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`)})})]})})}Po(),Tp(),sf(),od();function VA(){let e=Q.useSyncExternalStore($s,Us),{addNotification:t}=tr(),{recommendation:n,clearRecommendation:r,tryResolve:i}=FA();return Q.useEffect(()=>{e&&i(async()=>{let t=await Uc(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Qu()),Us()===e&&Lu(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Ou(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;IA(e,r,`hint-plugin`,t,async t=>{let n=await Ad({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`:Vu();break;case`no`:break}r()}},[n,t,r])}}B(),ld(),n_();var HA=3e4;function UA({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`),HA,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)(i_,{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)(ws,{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`)})})]})})}ld(),n_();var WA=3e4;function GA({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(),WA,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)(i_,{title:`Tool Recommendation`,children:(0,$.jsx)(ws,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}zo();var KA=.15,qA=3;function JA(){let e=Q.useSyncExternalStore(ir,so),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,qA).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=>{hr()},[]),handleDismiss:Q.useCallback(()=>{hr()},[])}}at(),Po(),B(),J(),sf(),Up();function YA(){let{addNotification:e}=tr(),t=q(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,` `,Hp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}at(),Po(),B(),sf(),G_();function XA(){let{addNotification:e}=tr(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!je())return K_(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])}sf(),sp(),Eo(),Rg(),Tp();function ZA(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 QA(e){Y(`performBackgroundPluginInstallations called`);try{let t=_g(ui(),await _r().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 hg({onProgress:t=>{switch(t.type){case`installing`:ZA(e,t.name,`installing`);break;case`installed`:ZA(e,t.name,`installed`);break;case`failed`:ZA(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),Kf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Ar(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Lg(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Gs(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Ar(),Gs(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}Uf(),sf(),Eo(),xc();async function $A(e){if(Y(`performStartupChecks called`),!Gf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Xr()&&(Ar(),Gs(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await QA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var ej=/https?:\/\/\S+/;function tj(){let[e,t]=(0,Q.useState)(nm.getInstance().getStatus());return(0,Q.useEffect)(()=>nm.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(ej);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})})]})}Po(),B(),Fo(),Du(),am(),fm(),at();function nj(e){let{addNotification:t}=tr(),n=Hc(),r=(0,Q.useMemo)(()=>Kr(n,e),[n,e]),i=(0,Q.useMemo)(()=>gu(n),[n]),a=(0,Q.useRef)(null),o=Qp(),s=Dm(),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])}Po(),at();function rj(e){let{addNotification:t}=tr(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(je())return;let r=_v(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 ij=``;function aj(){Qk(async()=>Rp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await og()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:ij,color:`warning`,priority:`high`})}Po(),B(),Uf(),Bi(),at();var oj=5;function sj({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=tr(),{status:a,ideName:o}=vC(t),s=(0,Q.useRef)(!1),c=n?rl(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(ki()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Hf().ideHintShownCount??0)>=oj)return;let e=setTimeout((e,t)=>{Is(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Vf(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])}Uf();var cj=[e=>{if(uj(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(uj(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 lj(){Qk(()=>{let e=Hf(),t=[];for(let n of cj){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function uj(e){return e!==void 0&&Date.now()-e<3e3}am(),B(),Tp(),Uf();var dj=3;function fj(){Qk(async()=>{if((Hf().subscriptionNoticeCount??0)>=dj)return null;let e=await pj();return e===null?null:(Vf(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`,(0,$.jsxs)(T,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function pj(){if($p())return null;let e=await om();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Po(),J(),Pm(),jp(),at();var mj=`fast-mode-cooldown-started`,hj=`fast-mode-cooldown-expired`,gj=`fast-mode-org-changed`,_j=`fast-mode-overage-rejected`;function vj(){let{addNotification:e}=tr(),t=q(e=>e.fastMode),n=Ko();(0,Q.useEffect)(()=>{if(!je()&&bm())return Sm(r=>{r?e({key:gj,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:gj,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!je()&&bm())return mm(t=>{n(e=>({...e,fastMode:!1})),e({key:_j,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(je()||!t)return;let n=Nm((t,n)=>{let r=yj(n,Pp(t-Date.now(),{hideTrailingZeros:!0}));e({key:mj,invalidates:[hj],text:r,color:`warning`,priority:`immediate`})}),r=Om(()=>{e({key:hj,invalidates:[mj],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function yj(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(),zh();function bj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return j(`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 xj(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 Sj(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function Cj(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 wj=()=>null;bf(),B();function Tj(){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}Km(),Wd();var Ej=[/\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/],Dj=[/^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 Oj(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(Ej.some(t=>t.test(e)))return!1}}}return!0}function kj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=qn(n);if(r)return Dj.some(e=>e.test(r))}return!1}var Aj=3,jj=1800*1e3;function Mj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>Oj(e)&&kj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<jj||t<Aj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}at(),B();function Nj(){return process.env.USER_TYPE===`ant`}function Pj(){let[e,t]=(0,Q.useState)(yt);return ae(()=>{t(yt())},Nj()?500:null),!Nj()||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(),xl(),ld(),Xh(),J(),at(),m_(),Wd(),gi(),Yd(),mp(),ol(),Td();var Fj=24,Ij=11;function Lj(){return new Date().toISOString().split(`T`)[0]}function Rj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){_d(`ultraplan-choice`);let l=Ko(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(Fj,Math.max(1,Math.floor(u/2)-Ij)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
84
+ `),Ws(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function PO(){(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 FO(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(),uc(),am();function IO(){let[e,t]=(0,Q.useState)(()=>{if(!rm()||$p())return`valid`;let{key:e,source:t}=qp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!rm()||$p()){t(`valid`);return}await Im(bt());let{key:e,source:n}=qp();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 Kc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}at(),B(),Yd(),sf(),B(),zh(),Tp(),J();function LO({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=q(e=>e.expandedView),d=Ko(),f=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[u,d]),p=q(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(Os(),e(Vc));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}=(Os(),e(Vc));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]);j(`app:toggleTodos`,f,{context:`Global`}),j(`app:toggleTranscript`,m,{context:`Global`}),j(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),j(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),j(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return j(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),j(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Td(),yl(),zh();var RO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function zO({onSubmit:e,isActive:t=!0}){let n=P(),r=Ha(),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}`,RO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Tp(),J(),U_(),Po(),Td(),$c(),zh(),zt(),gi();var BO=3e3;function VO(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=es(),g=Ko(),_=mC().length,{addNotification:v,removeNotification:y}=tr(),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(el()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=gn(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(B_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);j(`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;Mi(e,g);let n=[];for(let[e,r]of t)aa(e,g),n.push(r.description),gh(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return On({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 j(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),j(`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<=BO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),Ia(),k();return}b.current=t;let n=Nt(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:BO})},[h,v,y,k]),{context:`Chat`}),null}B(),J(),Wt();function HO(e){let t=q(e=>e.tasks),n=q(e=>e.pipeIpc),r=Object.values(t).some(vo),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 A(n.keypress))}),{handleKeyDown:i}}q_(),sp();async function UO(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 WO=new Map,GO=null;function KO(){return GO??null}function qO(e,t){let n=KO();if(!n)return null;let r=Bv(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return WO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function JO(e){e&&WO.delete(e)}function YO(e,t){if(!e)return;let n=KO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Tp(),eh(),kc(),sf(),Od(),Wd(),gd(),di();function XO(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 ZO(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){Na({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:th(e.name)})},async persistPermissions(e){return e.length===0?!1:(Rn(e),a(wd(n.getAppState().toolPermissionContext,e)),e.some(e=>Cn(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?ks:ku}${t}`:a?Wc:Ul,s=a?o:lc(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 or(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 QO(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))}}}sf(),B(),kc(),kt(),pf();function $O(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=XO(t),u,d,f=o?Bv():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){YO(h,e),JO(h),h=null}function _(){JO(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||_a(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 Ao(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=qO(v,e=>{l()&&(_(),_a(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),_a(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))})()}Tp(),eh(),B(),kc(),kt(),sf(),pf(),sp(),Qn(),nf(),di();function ek(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=ZO(n,r,i,a,o,t,QO(e));if(!l.resolveIfAborted(c))return(s===void 0?Ao(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:th(n.name),behavior:e.behavior,input:ff(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`&&ac(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`:Na({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(J_({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 UO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;$O({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof Qd||e instanceof tf?(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(()=>{_a(o)})}),[e,t])}mh(),Tp(),ga(),Al(),Yd(),sf(),pc(),pf(),sp(),gi(),lm();function tk(){Js(0)}async function nk(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){nd(),await rk({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(Cc(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(Rd);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?nk({...e,input:`/exit`}):tk();return}let j=Sl(T,k),M=Cc(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Z(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Ju(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,[],vr(),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?Ka({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`)),Ka({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}nd(),await rk({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function rk(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=vr();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Ol(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await Cu(w);w=T.attachmentCommands;let E=T.claimedCommands;if(w.length===0){l(null);return}let D=w[0]?.workload,O=D!==void 0&&w.every(e=>e.workload===D)?D:void 0,k=new Set,A;try{await pm(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await xg({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&k.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.effort,S=u.nextInput,C=u.submitNextInput)}if(Ol(`query_process_user_input_end`),cn()&&(Ol(`query_file_history_snapshot_start`),s.filter(bg).forEach(e=>{kn(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Ol(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=w[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?Jp(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?Ka({value:S,mode:`prompt`}):e.onInputChange(S))})}catch(e){A=e}if(E.length){let e=E.filter(e=>{let t=e.autonomy?.runId;return!t||!k.has(t)});if(A)try{await zc({commands:e,outcome:{type:`failed`,error:A},currentDir:Xd(),priority:`later`,workload:O})}catch(e){X(af(e))}else try{let t=await zc({commands:e,outcome:{type:`completed`},currentDir:Xd(),priority:`later`,workload:O});for(let e of t)Ka(e)}catch(e){X(af(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}gi();function ik(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 ak({executeInput:e}){let t=e=>e.agentId===void 0,n=Hn(t);if(!n)return{processed:!1};if(ik(n)||n.mode===`bash`)return e([sn(t)]),{processed:!0};let r=n.mode,i=fd(e=>t(e)&&!ik(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}gi();function ok({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(wa,dl);(0,Q.useEffect)(()=>{r||t||i.length!==0&&ak({executeInput:e})},[i,r,e,t,n])}function sk({isLoading:e,onSubmitMessage:t}){let n=Rs();(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 ck(e,t){return e&&t&&t.length>0?mi([...e,...t],`name`):e||[]}function lk(e,t){return(0,Q.useMemo)(()=>ck(e,t),[e,t])}Ht(),yg(),Kg(),Xc();function uk(e,t){return(0,Q.useMemo)(()=>t.length>0?mi([...e,...t],`name`):e,[e,t])}ga(),sp();function dk(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Co(),t(await yu(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Ig.subscribe(n),[n])}sp(),Ee(),Bi(),Oe();var fk=Te(()=>ye({method:xe(`selection_changed`),params:ye({selection:ye({start:ye({line:Se(),character:Se()}),end:ye({line:Se(),character:Se()})}).nullable().optional(),text:be().optional(),filePath:be().optional()})}));function pk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Ra(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(fk(),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])}hl(),B(),cv(),J(),jp();function mk({task:e,selected:t}){let n=dv(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,` · ↓ `,Fp(r),` tokens`]})})]})}function hk(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 gk(){let e=IC(),t=q(e=>e.viewingAgentTaskId),n=q(e=>e.footerSelection),r=q(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:hk(i,s)})]}),e.map(e=>(0,$.jsx)(mk,{task:e,selected:e.agentId===a},e.agentId))]})}sf(),pi();var _k=1e3;function vk({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 qi(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=yk(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await W(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=bk(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await G(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;Fi(e);let t=Yc(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),_k,l)};u.current=r;try{n=Rv(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 yk(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 bk(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}Uf(),s(),Bi();function xk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Hf().autoConnectIde||e||ki()||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`}})}ml(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}M_(),Rh(),B(),zh(),wn(),J(),Uf(),Of(),s();function Sk({onBackgroundSession:e,isLoading:t}){let n=Ko(),r=es(),[i,o]=(0,Q.useState)(!1),s=ie(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Za(r.getState())?(hd(()=>r.getState(),n),Hf().hasUsedBackgroundTask||Vf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=q(Za),u=a(`false`);j(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=Wi(`task:background`,`Task`,`ctrl+b`),f=yf.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 Ck({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=q(e=>e.foregroundedTaskId),o=q(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Ko(),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}}Bd(),B(),am(),Uf(),lm(),Ff(),ld(),S_(),n_();var wk=3e4;function Tk({model:e,onDone:t}){let n=Qc(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{kk()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,wk);return()=>clearTimeout(e)},[i]);let a=Wa(e),o=a?ud(a):`high`,s=(0,Q.useCallback)(e=>{zf(`userSettings`,{effortLevel:Ut(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(Dk,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(Dk,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(Dk,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(i_,{title:n.dialogTitle,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:n.dialogDescription})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[(0,$.jsx)(Ek,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(Ek,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(Ek,{level:`high`}),` high`]})}),(0,$.jsx)(ws,{options:c,onChange:s,onCancel:i})]})})}function Ek({level:e}){return(0,$.jsx)(T,{color:`suggestion`,children:__(e)})}function Dk({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ek,{level:e}),` `,t]})}function Ok(e){if(!Kp(e).toLowerCase().includes(`opus-4-6`))return!1;let t=Hf();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(kk(),!1):hm()?t.effortCalloutDismissed?(kk(),!1):Qc().enabled:cm()||wm()?Qc().enabled:(kk(),!1)}function kk(){Vf(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}fg(),a_();function Ak(e,t){return t}async function jk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=zr(e),i=await Br(Ql(e)),a;try{let e=Pn(),{size:t}=await Hv(e);t<=52428800?a=await Vv(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=z_(ff({trigger:t,version:`0.0.4`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await vm();let s=gm();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Tm(),...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($d(e),{level:`error`}),{success:!1}}}var Mk=t((()=>{p(),am(),sf(),pf(),Wd(),ol(),nf()}));Ih(),Mk();function Nk({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)(Bv()),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=Bv(),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])}}Tp(),Uf(),s(),Wd(),lm(),Ff();var Pk={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},Fk={probability:0};function Ik(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=_l(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=Ak(`tengu_feedback_survey_config`,Pk),u=Ak(`tengu_bad_survey_transcript_ask_config`,Fk),d=Ak(`tengu_good_survey_transcript_ask_config`,Fk),f=Lf().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}),Hf().feedbackSurveyState?.lastShownTime!==e&&Vf(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}),xh(`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}),xh(`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`||Hf().transcriptShareDismissed||!ro(`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}),xh(`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`&&Vf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(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}=Nk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Fm(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Lh()||!ro(`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=Hf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Ih(),Tp(),_o(),Uf(),s(),Wd(),wh(),Mk();var Lk=3e3,Rk=`tengu_memory_survey_event`,zk=`memory_survey`;function Bk(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}=Nk({hideThanksAfterMs:Lk,onOpen:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`appeared`,appearance_id:e}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(Rk,{event_type:`responded`,appearance_id:e,response:t}),xh(`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`||Hf().transcriptShareDismissed||!ro(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:zk}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(Rk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:zk}),t===`dont_ask_again`&&Vf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(o.current,zk,e);return Z(Rk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:zk}),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)(()=>_l(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Ih(),Tp(),s(),Wd(),wh();var Vk=3e3,Hk=.2;function Uk(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 Wk(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}=Nk({hideThanksAfterMs:Vk,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:Zu()}),xh(`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:Zu()}),xh(`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=>Zt(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||Lh()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Uk(e,c.current)){c.current=null,Math.random()<Hk&&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}}bf(),B();var Gk=[`1`,`2`,`3`],Kk={1:`yes`,2:`no`,3:`dont_ask_again`},qk=e=>Gk.includes(e);function Jk({onSelect:e,inputValue:t,setInputValue:n}){return xO({inputValue:t,setInputValue:n,isValidDigit:qk,onDigit:t=>e(Kk[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[wf,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can Anthropic 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`]})})]})]})}Tp(),B();function Yk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Zk,{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&&!wO(i)?null:(0,$.jsx)(EO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Xk=e=>e===`1`;function Zk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;xO({inputValue:t,setInputValue:n,isValidDigit:Xk,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.`]})]})}ag(),cg(),at(),Po(),sp();function Qk(e){let{addNotification:t}=tr(),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 $k(){Qk(async()=>(await sg()).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`}}))}ef(),sf(),Wd(),lm(),ts(),Ev(),uc(),B(),Wd();function eA(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=I();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{I()},[n,!1])}Tp(),Uf(),sf(),s(),pf(),sp();function tA(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var nA={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function rA(e){let t=nA.INITIAL_DELAY_MS*nA.BACKOFF_MULTIPLIER**e;return Math.min(t,nA.MAX_DELAY_MS)}function iA(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>=nA.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function aA(){let e=Hf();if(!iA(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(tA())return Y(`Official marketplace auto-install disabled via env var, skipping`),Vf(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 _r())[`claude-plugins-official`])return Y(`Official marketplace '${ss}' already installed, skipping`),Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Jl(ua))return Y(`Official marketplace blocked by enterprise policy, skipping`),Vf(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=Kd(),n=Nv(t,ss);if(await fs(n,t)!==null){let e=await _r();return e[ss]={source:ua,installLocation:n,lastUpdated:new Date().toISOString()},await Vr(e),Vf(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 er()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+rA(t),i=!1;try{Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(af(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 Yn(ua),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Vf(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 mu(),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(af(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+rA(r),o=!1;try{Vf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(af(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(),sf();function oA(){Qk(async()=>{let e=await aA(),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:`✓ Anthropic 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 Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Ff(),Tp();function sA(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vv(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function cA(e){if(Nf().spinnerTipsEnabled===!1)return;let t=await xv(e);if(t.length!==0)return sA(t)}function lA(e){gv(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}pf(),sp(),at(),J(),nn();var uA=!1;async function dA(e,t,n){{if(uA)return;uA=!0;let{updateContext:r,notification:i}=await br(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 fA(){uA=!1}function pA(){let e=q(e=>e.mainLoopModel),t=q(e=>e.mainLoopModelForSession),n=q(e=>e.fastMode),r=Ko(),i=es(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{je()||(a.current?a.current=!1:fA(),dA(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:af(e)}))}))},[e,t,n])}fl();function mA(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!cn()||r.current||(r.current=!0,e&&bn(e,n))},[t,e,n])}B(),Ns(),Tp(),ld(),n_();function hA({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`},...rn()?[]:[{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)(i_,{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)(ws,{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(),Ns(),pp();function gA(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function _A(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=gs.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!gs.isSandboxingEnabled()||fp()===`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:[gA(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]})})]})}k_(),Po(),at(),B();var vA=[];function yA({mcpClients:e=vA}){let{addNotification:t}=tr();(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`&&Tt(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`&&Tt(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(),Ff(),jc();var bA=`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(),Po(),B(),J(),sf(),s();var xA=5e3;function SA(){let{addNotification:e}=tr(),t=Ko(),[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=Fc();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=Ec();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);ne(s,n?xA:null),Q.useEffect(()=>{je()||!n||s()},[s,n])}sf();var CA=new Map;async function wA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=CA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await up(t).catch(()=>null)&&(r=!0),CA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Uf(),sf(),Eo();var TA=5;function EA(e){return Pf.has(e.toLowerCase())}function DA(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=kA(t);if(e)return e}return null}return kA(e)}function OA(e){return typeof e==`object`&&!!e}function kA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!OA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(OA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function AA(){let e=new Map;try{let t=await _r();for(let n of Object.keys(t))try{let t=await Ma(n),r=EA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=DA(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 jA(e){if(PA())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Mv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await AA(),r=Hf().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(Rt(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 wA(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 MA(e){Vf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function NA(){Vf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function PA(){let e=Hf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=TA}u(),at(),B(),sp(),Eo();function FA(){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 IA(e,t,n,r,i){try{let a=await $t(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(),Po(),J(),Uf(),sf(),sp(),Ff();var LA=28e3;function RA(){let e=q(e=>e.fileHistory.trackedFiles),{addNotification:t}=tr(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=FA();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 jA(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:Mv(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`:IA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Nv(e.marketplaceInstallLocation,e.entry.source):void 0;await Oc(n,e.entry,`user`,void 0,t),zf(`userSettings`,{enabledPlugins:{...Af(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=LA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),NA());break}case`never`:MA(n);break;case`disable`:Vf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),ld(),n_();var zA=3e4;function BA({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`),zA,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)(i_,{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)(ws,{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`)})})]})})}Po(),Tp(),sf(),od();function VA(){let e=Q.useSyncExternalStore($s,Us),{addNotification:t}=tr(),{recommendation:n,clearRecommendation:r,tryResolve:i}=FA();return Q.useEffect(()=>{e&&i(async()=>{let t=await Uc(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Qu()),Us()===e&&Lu(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Ou(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;IA(e,r,`hint-plugin`,t,async t=>{let n=await Ad({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`:Vu();break;case`no`:break}r()}},[n,t,r])}}B(),ld(),n_();var HA=3e4;function UA({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`),HA,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)(i_,{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)(ws,{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`)})})]})})}ld(),n_();var WA=3e4;function GA({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(),WA,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)(i_,{title:`Tool Recommendation`,children:(0,$.jsx)(ws,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}zo();var KA=.15,qA=3;function JA(){let e=Q.useSyncExternalStore(ir,so),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,qA).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=>{hr()},[]),handleDismiss:Q.useCallback(()=>{hr()},[])}}at(),Po(),B(),J(),sf(),Up();function YA(){let{addNotification:e}=tr(),t=q(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,` `,Hp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}at(),Po(),B(),sf(),G_();function XA(){let{addNotification:e}=tr(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!je())return K_(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])}sf(),sp(),Eo(),Rg(),Tp();function ZA(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 QA(e){Y(`performBackgroundPluginInstallations called`);try{let t=_g(ui(),await _r().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 hg({onProgress:t=>{switch(t.type){case`installing`:ZA(e,t.name,`installing`);break;case`installed`:ZA(e,t.name,`installed`);break;case`failed`:ZA(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),Kf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Ar(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Lg(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Gs(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Ar(),Gs(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}Uf(),sf(),Eo(),xc();async function $A(e){if(Y(`performStartupChecks called`),!Gf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Xr()&&(Ar(),Gs(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await QA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var ej=/https?:\/\/\S+/;function tj(){let[e,t]=(0,Q.useState)(nm.getInstance().getStatus());return(0,Q.useEffect)(()=>nm.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(ej);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})})]})}Po(),B(),Fo(),Du(),am(),fm(),at();function nj(e){let{addNotification:t}=tr(),n=Hc(),r=(0,Q.useMemo)(()=>Kr(n,e),[n,e]),i=(0,Q.useMemo)(()=>gu(n),[n]),a=(0,Q.useRef)(null),o=Qp(),s=Dm(),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])}Po(),at();function rj(e){let{addNotification:t}=tr(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(je())return;let r=_v(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 ij=``;function aj(){Qk(async()=>Rp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await og()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:ij,color:`warning`,priority:`high`})}Po(),B(),Uf(),Bi(),at();var oj=5;function sj({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=tr(),{status:a,ideName:o}=vC(t),s=(0,Q.useRef)(!1),c=n?rl(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(ki()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Hf().ideHintShownCount??0)>=oj)return;let e=setTimeout((e,t)=>{Is(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Vf(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])}Uf();var cj=[e=>{if(uj(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(uj(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 lj(){Qk(()=>{let e=Hf(),t=[];for(let n of cj){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function uj(e){return e!==void 0&&Date.now()-e<3e3}am(),B(),Tp(),Uf();var dj=3;function fj(){Qk(async()=>{if((Hf().subscriptionNoticeCount??0)>=dj)return null;let e=await pj();return e===null?null:(Vf(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`,(0,$.jsxs)(T,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function pj(){if($p())return null;let e=await om();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Po(),J(),Pm(),jp(),at();var mj=`fast-mode-cooldown-started`,hj=`fast-mode-cooldown-expired`,gj=`fast-mode-org-changed`,_j=`fast-mode-overage-rejected`;function vj(){let{addNotification:e}=tr(),t=q(e=>e.fastMode),n=Ko();(0,Q.useEffect)(()=>{if(!je()&&bm())return Sm(r=>{r?e({key:gj,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:gj,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!je()&&bm())return mm(t=>{n(e=>({...e,fastMode:!1})),e({key:_j,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(je()||!t)return;let n=Nm((t,n)=>{let r=yj(n,Pp(t-Date.now(),{hideTrailingZeros:!0}));e({key:mj,invalidates:[hj],text:r,color:`warning`,priority:`immediate`})}),r=Om(()=>{e({key:hj,invalidates:[mj],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function yj(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(),zh();function bj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return j(`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 xj(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 Sj(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function Cj(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 wj=()=>null;bf(),B();function Tj(){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}Km(),Wd();var Ej=[/\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/],Dj=[/^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 Oj(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(Ej.some(t=>t.test(e)))return!1}}}return!0}function kj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=qn(n);if(r)return Dj.some(e=>e.test(r))}return!1}var Aj=3,jj=1800*1e3;function Mj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>Oj(e)&&kj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<jj||t<Aj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}at(),B();function Nj(){return process.env.USER_TYPE===`ant`}function Pj(){let[e,t]=(0,Q.useState)(yt);return ae(()=>{t(yt())},Nj()?500:null),!Nj()||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(),xl(),ld(),Xh(),J(),at(),m_(),Wd(),gi(),Yd(),mp(),ol(),Td();var Fj=24,Ij=11;function Lj(){return new Date().toISOString().split(`T`)[0]}function Rj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){_d(`ultraplan-choice`);let l=Ko(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(Fj,Math.max(1,Math.floor(u/2)-Ij)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
85
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
86
  `),x=g>0,S=g<h,C=Q.useCallback(async a=>{switch(a){case`here`:On({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
87
  `),mode:`task-notification`});break;case`fresh`:let t=st(),n=await Hv(Pn()).then(()=>!0,()=>!1);await g_({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,kd(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),On({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=Nv(Xd(),`${Lj()}-ultraplan.md`);await Uv(t,e,{encoding:`utf-8`}),r(e=>[...e,kd(`Ultraplan rejected · Plan saved to ${gp(t)}`,`suggestion`)]);break}}Nr(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),bl(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)(ws,{options:E,onChange:e=>void C(e)})]})})}B(),ld(),Xh(),J(),Uf(),Bl();function zj(){return!Hf().hasSeenUltraplanTerms}function Bj(){return Kl()}function Vj({onChoice:e}){let[t]=Q.useState(zj),[n]=Q.useState(Bj),r=Q.useMemo(()=>Es(n),[n]),i=q(e=>e.replBridgeEnabled),a=Ko(),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&&Vf(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:Bu,children:Bu})]}):null]}),(0,$.jsx)(T,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(ws,{options:c,onChange:o})]})})}Z_(),B(),Uf(),qo();function Hj(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||!(Hf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function Uj(e){let[t]=y();(0,Q.useEffect)(()=>{e.setSelectionBgColor(ns(t).selectionBg)},[e,t])}Po(),B(),zh(),sf();var Wj=40,Gj=.3,Kj=6,qj=200,Jj=15,Yj=15,Xj=3,Zj=1500,Qj=150,$j=5,eM=5,tM=80,nM=3,rM=6,iM=500;function aM(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 oM(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 sM(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Zj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>qj)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<eM)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/Qj),n=Math.max(Yj,e.base*2),i=1+(e.mult-1)*t+Jj*t;return e.mult=Math.min(n,i,e.mult+Xj),Math.floor(e.mult)}if(r>Wj)e.mult=e.base;else{let t=Math.max(Kj,e.base*2);e.mult=Math.min(t,e.mult+Gj)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<eM)return 1;if(!i||r>iM)e.mult=2,e.frac=0;else{let t=.5**(r/Qj);e.mult=Math.min(r>=tM?nM:rM,1+(e.mult-1)*t+$j*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function cM(){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 lM(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function uM(){let e=se(),t=cM();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),lM(e,t)}var dM=2,fM=50,pM=200;function mM({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ue(),{addNotification:a}=tr(),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=_M(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=_M(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=uM()),yM(t,sM(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=uM());let r=vM(t,sM(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=_M(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=_M(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=_M(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=_M(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),oe((t,r,i)=>{let a=e.current;if(!a)return;let o=xM(a,bM(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=oM(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}aM(t)&&i.clearSelection()},{isActive:t}),hM(e,i,t,n),Hj(i,t,s),Uj(i),null}function hM(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>pM){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(dM,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(dM,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(dM)}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,fM)))}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=gM(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 gM(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 _M(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 vM(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 yM(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function bM(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 xM(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),_M(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),_M(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),_M(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 SM=r({useFrustrationDetection:()=>wM});function CM(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function wM(e,t,n,r){let[i,a]=(0,TM.useState)(`closed`),o=Hf(),s=ro(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=CM(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(jk(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(Vf(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var TM,EM=t((()=>{TM=n(z(),1),Uf(),_o(),Mk()})),DM=r({useAntOrgWarningNotification:()=>OM});function OM(){}t((()=>{}));var kM=r({useProactive:()=>AM});function AM(e){let t=(0,jM.useRef)(e);t.current=e,(0,jM.useEffect)(()=>{if(!yh())return;let e=null,n=!1,r=!1;function i(){vh(Date.now()+MM),e=setTimeout(()=>{if(e=null,!fh()){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 Gl({basePrompt:`<${ip}>${new Date().toLocaleTimeString()}</${ip}>`,currentDir:Xd(),shouldCreate:()=>!n});if(n){await zl({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await zl({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},MM)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),vh(null)}},[yh(),dh(),ph()])}var jM,MM,NM=t((()=>{jM=n(z(),1),ap(),Yd(),Ts(),sf(),MM=3e4}));function PM(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 FM(e){let t=bc(e),n=PM(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
@@ -134,9 +134,9 @@ Instead, provide a brief summary:
134
134
  3. Any blockers or issues encountered.
135
135
 
136
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 LM=t((()=>{})),RM=r({useGoalContinuation:()=>BM});function zM(e){Y(`[goal] hook: ${e}`)}function BM(e){let t=(0,VM.useRef)(e);t.current=e;let n=(0,VM.useRef)(!1),r=(0,VM.useRef)(!1);(0,VM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){zM(`skip: queryActiveNow=true`);return}if(e.wasAborted){zM(`skip: wasAborted=true`);return}if(n.current)return;if(dl().length>0){zM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){zM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){zM(`skip: planMode`);return}let t=Fl();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=IM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Ka({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){zM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){ad()&&(Bc(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=Dc();Bc();let a=FM(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Ka({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 VM,HM=t((()=>{VM=n(z(),1),sf(),xs(),LM(),gi()})),UM=r({AntModelSwitchCallout:()=>WM,shouldShowModelSwitchCallout:()=>GM});function WM(e){return null}function GM(){return!1}t((()=>{}));var KM=r({UndercoverAutoCallout:()=>qM});function qM({onDone:e}){return(0,JM.useEffect)(()=>{e()},[e]),null}var JM,YM=t((()=>{JM=n(z(),1)}));at(),bu(),kf(),u(),B(),xl(),qg(),Po(),sf(),s(),jp(),Ts(),zt(),ga(),wg(),Zl(),Al(),Fa(),wn(),$c(),pf(),sp(),Yd(),gd(),nn(),kc(),Uf(),fm(),Tp(),Wd(),tg(),ap(),pc(),Ru(),nv(),lg(),cs(),Od(),e_(),J(),wc(),ol(),fl(),Bi(),In(),gi(),os(),po(),Ns(),Bl(),Qr();var XM=process.env.USER_TYPE===`ant`?(EM(),e(SM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),ZM=process.env.USER_TYPE===`ant`?e(DM).useAntOrgWarningNotification:()=>{},QM=(bh(),e(lh)),$M=e=>()=>{},eN=()=>!1,tN=()=>null,nN=(e,t)=>!1,rN=(NM(),e(kM)).useProactive,iN=(HM(),e(RM)).useGoalContinuation,aN=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),oN=()=>({routeToSelectedPipes:()=>!1}),sN=process.env.USER_TYPE===`ant`?e(UM).AntModelSwitchCallout:null,cN=process.env.USER_TYPE===`ant`?e(UM).shouldShowModelSwitchCallout:()=>!1,lN=process.env.USER_TYPE===`ant`?(YM(),e(KM)).UndercoverAutoCallout:null,uN=[],dN=3e3;function fN(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 pN({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=Wi(`app:toggleTranscript`,`Global`,`ctrl+o`),o=Wi(`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 mN({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=w_({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 hN=[`⠂`,`⠐`],gN=`✳`,_N=960;function vN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=M(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%hN.length),_N,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?hN[a]??gN:gN;return ee(n?null:r?t:`${s} ${t}`),null}var yN=`<${op}>`;function bN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(yN)}function xN({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:A}){let j=!!D,N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),ee=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),P=(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[I,ne]=(0,Q.useState)(S),L=q(e=>e.toolPermissionContext),R=q(e=>e.verbose),ie=q(e=>e.mcp),z=q(e=>e.plugins),ae=q(e=>e.agentDefinitions),se=q(e=>e.fileHistory),ce=q(e=>e.initialMessage),le=mC(),ue=q(e=>e.spinnerTip),pe=q(e=>e.expandedView)===`tasks`,B=q(e=>e.tasks),H=q(e=>e.elicitation),me=q(e=>e.ultraplanPendingChoice),he=q(e=>e.ultraplanLaunchPending),ge=q(e=>e.viewingAgentTaskId),U=Ko(),ve=ge?B[ge]:void 0,ye=sl(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;ed(ho(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!sl(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=es(),xe=E(),Se=$g(),[Ce,we]=(0,Q.useState)(t);dk(j?void 0:dt(),we);let Te=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.isProactiveActive??eN),Ee=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.getNextTickAt??tN),De=q(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>rs(L),[L,Te,De]);pA();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}=tr(),$e=nN,et=lk(d,ie.clients),[at,pt]=(0,Q.useState)(void 0),[mt,_t]=(0,Q.useState)(null),[yt,bt]=(0,Q.useState)(null),[Ct,wt]=(0,Q.useState)(!1),[Tt,Dt]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&cN()),[Ot,kt]=(0,Q.useState)(()=>Ok(Se)),At=q(e=>e.showRemoteCallout),[jt,Pt]=(0,Q.useState)(()=>Sv());lj(),fj(),sj({ideSelection:at,mcpClients:et,ideInstallationStatus:yt}),yA({mcpClients:et}),YA(),XA(),O_(),nj(Se),vj(),rj(Se),aj(),ZM(),$k(),oA(),SA();let{recommendation:Lt,handleResponse:Rt}=RA(),{recommendation:zt,handleResponse:Bt}=VA(),Vt=JA(),Ht=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);dg({enabled:!j});let Ut=Et();(0,Q.useEffect)(()=>{j||$A(U)},[U,j]);let Wt=Gg(Ht,ie.tools,L),{tools:Gt,allowedAgentTypes:Kt}=(0,Q.useMemo)(()=>{if(!I)return{tools:Wt,allowedAgentTypes:void 0};let e=Ft(I,Wt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[I,Wt]),qt=uk(uk(Ce,z.commands),ie.commands),Jt=(0,Q.useMemo)(()=>C?[]:qt,[C,qt]);Hy(j?uN:ie.clients),pk(j?uN:ie.clients,pt);let[Xt,Qt]=(0,Q.useState)(`responding`),$t=(0,Q.useRef)(Xt);$t.current=Xt;let[en,tn]=(0,Q.useState)([]),[nn,rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(nn&&!nn.isStreaming&&nn.streamingEndedAt){let e=3e4-(Date.now()-nn.streamingEndedAt);if(e>0){let t=setTimeout(rn,e,null);return()=>clearTimeout(t)}else rn(null)}},[nn]);let[an,sn]=(0,Q.useState)(null),ln=(0,Q.useRef)(null);ln.current=an;let un=(0,Q.useRef)(0),[pn,hn]=(0,Q.useState)(!1),gn=(0,Q.useRef)(()=>{}),_n=(0,Q.useRef)(()=>{}),vn=(0,Q.useRef)(null),bn=(0,Q.useRef)(null),xn=(0,Q.useRef)(0),Sn=Q.useRef(new Sy).current,Cn=Q.useSyncExternalStore(Sn.subscribe,Sn.getSnapshot),[wn,Tn]=Q.useState(D?.hasInitialPrompt??!1),W=Cn||wn,[En,Dn]=Q.useState(void 0),On=Q.useRef(0),jn=Q.useRef(!1),Mn=Q.useRef(0),Pn=Q.useRef(0),Fn=Q.useRef(null),In=Q.useCallback(()=>{Mn.current=Date.now(),Pn.current=0,Fn.current=null},[]),Ln=Q.useRef(!1);Cn&&!Ln.current&&In(),Ln.current=Cn;let Rn=Q.useCallback(e=>{Tn(e),e&&In()},[In]),zn=Q.useRef(void 0),[Bn,Vn]=Q.useState(!1),[Hn,Un]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Hn?.notifications&&Hn.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Hn,Ze]),(0,Q.useEffect)(()=>{Su()&&is().then(e=>{e&&Ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Wn,Gn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-B7NUPJ8E.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-CPvoDtJ1.js`);t()&&Gn(!0)})()},[]);let[Kn,qn]=(0,Q.useState)(null),Jn=(0,Q.useRef)(null),Yn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Jn.current={...n,isLocalJSXCommand:!0},qn(n);return}if(Jn.current){if(e?.clearLocalJSX){Jn.current=null,qn(null),un.current=Date.now();return}return}if(e?.clearLocalJSX){qn(null);return}qn(e)},[]),[Xn,Zn]=(0,Q.useState)([]),[Qn,$n]=(0,Q.useState)(null),[er,nr]=(0,Q.useState)([]),[rr,ir]=(0,Q.useState)([]),ar=(0,Q.useRef)(new Map),or=q(e=>e.settings.terminalTitleFromRename)===!1?void 0:Il(st()),[sr,cr]=(0,Q.useState)(),dr=(0,Q.useRef)((i?.length??0)>0),fr=I?.agentType,pr=or??fr??sr??`Work Mate`,mr=Xn.length>0||rr.length>0,hr=Kn?.isLocalJSXCommand===!0&&Kn?.jsx!=null,_r=W&&!mr&&!hr;(0,Q.useEffect)(()=>{if(W&&!mr&&!hr)return hy(),()=>gy()},[W,mr,hr]);let yr=mr||hr?`waiting`:W?`busy`:`idle`,br=yr===`waiting`?Xn.length>0?`approve ${Xn[0].tool.name}`:hr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Vd({status:yr,waitingFor:br})},[yr,br]),F(null);let[G,xr]=(0,Q.useState)(i??[]),wr=(0,Q.useRef)(G),Tr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=wr.current,n=typeof e==`function`?e(wr.current):e;if(wr.current=n,n.length<On.current)On.current=0;else if(n.length>t.length&&jn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(vi)?jn.current=!1:On.current=n.length}xr(n)},[]),Er=(0,Q.useCallback)(e=>{e===void 0?jn.current=!1:(On.current=wr.current.length,jn.current=!0),Dn(e)},[]),{dividerIndex:Or,dividerYRef:Ar,onScrollAway:jr,onRepin:Mr,jumpToNew:Nr,shiftDivider:Pr}=rv(G.length);eA(G,K,W);let[Fr,Ir]=(0,Q.useState)(null),zr=(0,Q.useRef)(null),Br=(0,Q.useMemo)(()=>ev(G,Or),[Or,G.length]),Vr=(0,Q.useCallback)(()=>{vn.current?.scrollToBottom(),Mr(),Ir(null)},[Mr,Ir]),Ur=G.at(-1),Gr=Ur!=null&&vi(Ur);(0,Q.useEffect)(()=>{Gr&&Vr()},[Gr,Ur,Vr]);let{maybeLoadOlder:Kr}=yO({config:D,setMessages:K,scrollRef:vn,onPrepend:Pr}),qr=(0,Q.useCallback)((e,t)=>{xn.current=Date.now(),e?Mr():(jr(t),Kr(t))},[Mr,jr,Kr,U]),Jr=FO(o,K),Yr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),Xr=G.length-Yr.length;Xr>0&&Y(`[useDeferredValue] Messages deferred by ${Xr} (${Yr.length}→${G.length})`);let[Qr,$r]=(0,Q.useState)(null),[ei,ri]=(0,Q.useState)(()=>hv()),ii=(0,Q.useRef)(ei);ii.current=ei;let ai=(0,Q.useRef)(null),si=(0,Q.useCallback)(e=>{$e(ii.current,e)||(ii.current===``&&e!==``&&Date.now()-xn.current>=dN&&Vr(),ii.current=e,ri(e),Vn(e.trim().length>0))},[Vn,Vr,$e]);(0,Q.useEffect)(()=>{if(ei.trim().length===0)return;let e=setTimeout(Vn,1500,!1);return()=>clearTimeout(e)},[ei]);let[ci,li]=(0,Q.useState)(`prompt`),[ui,di]=(0,Q.useState)(),fi=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||ka.has(e)))},[we]),[pi,mi]=(0,Q.useState)(new Set),hi=(0,Q.useRef)(!1),gi=iO({config:D,setMessages:K,setIsLoading:Rn,onInit:fi,setToolUseConfirmQueue:Zn,tools:Ht,setStreamingToolUses:tn,setStreamMode:Qt,setInProgressToolUseIDs:mi}),yi=sO({config:O,setMessages:K,setIsLoading:Rn,setToolUseConfirmQueue:Zn,tools:Ht}),bi=cO({session:k,setMessages:K,setIsLoading:Rn,setToolUseConfirmQueue:Zn,tools:Ht}),xi=bi.isRemoteMode?bi:yi.isRemoteMode?yi:gi,[Si,Ci]=(0,Q.useState)({}),[Ti,Ei]=(0,Q.useState)(0),Di=(0,Q.useRef)(0),Oi=(0,Q.useRef)([]),ki=(0,Q.useCallback)(e=>{let t=Di.current;if(Di.current=e(t),Di.current>t){let e=Oi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Di.current}}},[]),[Ai,ji]=(0,Q.useState)(null),Mi=!(q(e=>e.settings.prefersReducedMotion)??!1)&&!V(),Ni=(0,Q.useCallback)(e=>{Mi&&ji(e)},[Mi]),Pi=Ai&&Mi&&Ai.substring(0,Ai.lastIndexOf(`
138
- `)+1)||null,[Fi,Ii]=(0,Q.useState)(0),[Bi,Hi]=(0,Q.useState)(null),[Wi,Ki]=(0,Q.useState)(null),[qi,Ji]=(0,Q.useState)(null),[Yi,Xi]=(0,Q.useState)(!1),[Zi,Qi]=(0,Q.useState)(void 0),[$i,ta]=(0,Q.useState)(!1),[na,ra]=(0,Q.useState)(Bv()),[aa,oa]=(0,Q.useState)(null),sa=(0,Q.useRef)(!1),ca=(0,Q.useRef)(Fi);ca.current=Fi;let[ua]=(0,Q.useState)(()=>({current:Jo(i,c)}));Tc(()=>{ua.current=vu()});let[da,fa]=(0,Q.useState)(Hf().hasAcknowledgedCostThreshold),[pa,ma]=(0,Q.useState)(`INSERT`),[ha,ga]=(0,Q.useState)(!1),[_a,va]=(0,Q.useState)(!1),[ba,xa]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&ha&&ga(!1)},[me,ha]);let Sa=M(),Ca=(0,Q.useRef)(Sa);Ca.current=Sa;let[wa]=y(),Ta=Q.useRef(!1),Da=(0,Q.useCallback)(()=>{if(Ta.current)return;Ta.current=!0;let e=wr.current.slice(to.current);for(let t of la(e))eo.current.add(t);to.current=wr.current.length,cA({theme:wa,readFileState:$a.current,bashTools:eo.current}).then(async e=>{if(e){let t=await e.content({theme:wa});U(e=>({...e,spinnerTip:t})),lA(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,wa]),Aa=(0,Q.useCallback)(()=>{Rn(!1),Er(void 0),Di.current=0,Oi.current=[],ji(null),tn([]),Hi(null),Ki(null),Ji(null),Da(),Ch(),cu()},[Da]),ja=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(L.mode!==`auto`){ja.current=!1;return}if(ja.current||(Hf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Vf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,kd(bA,`warning`)])},800,ja,K);return()=>clearTimeout(e)}},[L.mode,K]);let Ma=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ma.current)return;let e=mn();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ma.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,kd(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[K]);let Na=(0,Q.useMemo)(()=>{let e=G.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&pi.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[G,pi]),{onBeforeQuery:Pa,onTurnComplete:Fa,render:Ia}=MO({enabled:ee,setMessages:K,inputValue:ei,setInputValue:si,setToolJSX:Yn}),La=(!Kn||Kn.showSpinner===!0)&&Xn.length===0&&rr.length===0&&(W||En||Li()>0)&&!Na&&(!Pi||De),za=Xn.length>0||rr.length>0||er.length>0||H.queue.length>0,Va=Ik(G,W,Ti,`session`,za),Ha=jO(K),Ua=Mj(G,Ti),Wa=(0,Q.useMemo)(()=>({...Va,handleSelect:e=>{lo.current=!1;let t=Va.handleSelect(e);e===`bad`&&!t&&xj(`feedback_survey_bad`)&&(co(`feedback_survey_bad`),lo.current=!0)}}),[Va]),Ga=Wk(G,W,za,{enabled:!j}),Ja=Bk(G,W,za,{enabled:!j}),Ya=XM(G,W,za,Wa.state!==`closed`||Ga.state!==`closed`||Ja.state!==`closed`);xk({autoConnectIdeFlag:p,ideToInstallExtension:mt,setDynamicMcpConfig:Ae,setShowIdeOnboarding:wt,setIDEInstallationState:bt}),mA(s,se,e=>U(t=>({...t,fileHistory:e})));let Xa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=lr(n.messages),o=ec();await ps(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await hs(`resume`,{sessionId:t,agentType:I?.agentType,model:Se});a.push(...s),r===`fork`?Yu(n,ur(t)):Zs(n,ur(t)),Ng(n,U),n.fileHistorySnapshots&&xd(n);let{agentDefinition:c}=jg(n.agentSetting,S,ae);ne(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Mg(n.agentName,n.agentColor)})),wo(n.agentName),io(a,n.projectPath??ut()),Aa(),sn(null),ra(t);let l=As(t);Ws(),ht(),gt(ur(t),n.fullPath?jv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-BsWpcxrc.js`);if(await u(),await vc(),Wl(),au(n),n.goal){let{hydrateGoalFromTranscript:r}=(Tu(),e(Vl)),i=new Map;i.set(t,n.goal),r(i,t)}if(dr.current=!0,cr(void 0),r!==`fork`)Pg(),Fg(n.worktreeSession),Rr(),Gi({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=mn();e&&dn(e)}l&&rt(l),ua.current&&r!==`fork`&&(ua.current=ls(a,n.contentReplacements??[])),K(()=>a),Yn(null),si(``),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}},[Aa,U]),[Za]=(0,Q.useState)(()=>oh(100)),$a=(0,Q.useRef)(Za),eo=(0,Q.useRef)(new Set),to=(0,Q.useRef)(0),no=(0,Q.useRef)(new Set),ro=(0,Q.useRef)(new Set),io=(0,Q.useCallback)((e,t)=>{let n=St(e,t,100);$a.current=ch($a.current,n);for(let t of la(e))eo.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(io(i,ut()),Gi({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:ao,reverify:oo}=IO(),[so,co]=(0,Q.useState)(null),lo=(0,Q.useRef)(!1),[uo,fo]=(0,Q.useState)(null),[po,mo]=(0,Q.useState)(!1),go=!W&&$i;function _o(){if(po||uo)return;if(Yi)return`message-selector`;if(Bn)return;if(er[0])return`sandbox-permission`;let e=!Kn||Kn.shouldContinueAnimation;if(e&&Xn[0])return`tool-permission`;if(e&&rr[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&go)return`cost`;if(e&&aa)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&Ct)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Tt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&Wn)return`undercover-callout`;if(e&&Ot)return`effort-callout`;if(e&&At)return`remote-callout`;if(e&&Lt)return`lsp-recommendation`;if(e&&zt)return`plugin-hint`;if(e&&Vt.visible)return`search-extra-tools-hint`;if(e&&jt)return`desktop-upsell`}let vo=_o(),yo=Bn&&(er[0]||Xn[0]||rr[0]||H.queue[0]||go);zn.current=vo,(0,Q.useEffect)(()=>{if(!W)return;let e=vo===`tool-permission`,t=Date.now();e&&Fn.current===null?Fn.current=t:!e&&Fn.current!==null&&(Pn.current+=t-Fn.current,Fn.current=null)},[vo,W]);let bo=(0,Q.useRef)(vo);(0,Q.useLayoutEffect)(()=>{bo.current===`tool-permission`!=(vo===`tool-permission`)&&Vr(),bo.current=vo},[vo,Vr]);function xo(){if(vo!==`elicitation`){if(un.current!==0&&Date.now()-un.current<500){un.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(un.current=0,Y(`[onCancel] focusedInputDialog=${vo} streamMode=${Xt}`),QM?.pauseProactive(),Sn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(xs(),e(Lc)),{persistCurrentGoal:r}=(Tu(),e(Vl));t()?.status===`active`&&(n(),r())}if(hn(!0),Sn.forceEnd(),sa.current=!1,Ai?.trim()&&K(e=>[...e,su({content:Ai})]),Aa(),tt(null),vo===`tool-permission`)Xn[0]?.onAbort(),Zn([]);else if(vo===`prompt`){for(let e of rr)e.reject(Error(`Prompt cancelled by user`));ir([]),an?.abort(`user-cancel`)}else xi.isRemoteMode?xi.cancelRequest():an?.abort(`user-cancel`);sn(null),Fa(wr.current,!0)}}let So=(0,Q.useCallback)(()=>{let e=Sr(ei,0);e&&(si(e.text),li(`prompt`),e.images.length>0&&Ci(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[si,li,ei,Ci]),Co={setToolUseConfirmQueue:Zn,onCancel:xo,onAgentsKilled:()=>K(e=>[...e,$u()]),isMessageSelectorVisible:Yi||!!ha,screen:Pe,abortSignal:an?.signal,popCommandFromQueue:So,vimMode:pa,isLocalJSXCommand:Kn?.isLocalJSXCommand,isSearchingHistory:_a,isHelpOpen:ba,inputMode:ci,inputValue:ei,streamMode:Xt};(0,Q.useEffect)(()=>{lt()>=5&&!$i&&!da&&(Z(`tengu_cost_threshold_reached`,{}),fa(!0),jm()&&ta(!0))},[G,$i,da]);let To=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}nr(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=Bv();t.sendRequest(n,mg,{host:e.host},Bv(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;nr(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=ar.current.get(e.host);if(i){for(let e of i)e();ar.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=ar.current.get(e.host)??[];a.push(i),ar.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=gs.getSandboxUnavailableReason();if(e){if(gs.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Js(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]),gs.isSandboxingEnabled()&&gs.initialize(To).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${$d(e)}\n`),Js(1,`other`)});let Eo=(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))},Zn)},[U,Zn]),Do=ek(Zn,Eo),Oo=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Zr(e.toolPermissionContext,e.mcp.tools),n=vg(Ht,t,e.toolPermissionContext.mode);return I?Ft(I,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Jt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:A,mcpClients:ck(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:yt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:wa,agentDefinitions:Kt?{...a.agentDefinitions,allowedAgentTypes:Kt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:U,messages:e,setMessages:K,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||Xi(!0)},onChangeAPIKey:oo,readFileState:$a.current,setToolJSX:Yn,addNotification:Ze,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{ry(e,xe)},onChangeDynamicMcpConfig:je,onInstallIDEExtension:_t,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:ro.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:no.current,setResponseLength:ki,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Di.current;Oi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Qt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Ki(`claudeBlue_FOR_SYSTEM_SPINNER`),Ji(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Hi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Hi(`Compacting conversation`);break;case`compact_end`:Hi(null),Ki(null),Ji(null);break}},setInProgressToolUseIDs:mi,setHasInterruptibleToolInProgress:e=>{hi.current=e},resume:Xa,setConversationId:ra,requestPrompt:void 0,contentReplacementState:ua.current}},[Jt,Ht,I,n,d,yt,ke,wa,Kt,be,U,oo,Ze,K,je,Xa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{ir(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,ra]),{handleBackgroundSession:ko}=Ck({setMessages:K,setIsLoading:Rn,resetLoadingState:Aa,setAbortController:sn,onBackgroundQuery:(0,Q.useCallback)(()=>{an?.abort(`background`);let e=ni(e=>e.mode===`task-notification`);(async()=>{let t=Oo(wr.current,[],new AbortController,Se),[n,r,i]=await Promise.all([Dl(t.options.tools,Se,Array.from(L.additionalWorkingDirectories.keys()),t.options.mcpClients),Mt(),ll()]),a=Ho({mainThreadAgentDefinition:I,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await zi(e).catch(()=>[])).map(An),s=new Set;for(let e of wr.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));Ui({messages:[...wr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Do,toolUseContext:t,querySource:Pd()},description:pr,setAppState:U,agentDefinition:I})})()},[an,Se,L,I,Oo,h,g,Do,U])}),Ao=(0,Q.useCallback)(t=>{Dr(t,t=>{if(Zt(t)?(Su()?K(e=>{let n=It(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),ra(Bv()),QM?.setContextBlocked(!1)):t.type===`progress`&&ia(t.data?.type)?K(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?QM?.setContextBlocked(!0):t.type===`assistant`&&QM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Vi(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}=(xs(),e(Lc)),{persistCurrentGoal:r}=(Tu(),e(Vl));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=>{ki(t=>t+e.length)},Qt,tn,e=>{K(t=>t.filter(t=>t!==e)),wl(e.uuid)},rn,e=>{let t=Date.now(),n=Di.current;Oi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Ni)},[K,ki,Qt,tn,rn,Ni]),Mo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=ck(d,be.getState().mcp.clients);Yt.handleQueryStart(e);let t=Ra(e);t&&Dd(t)}if(Vh(),!N&&!or&&!fr&&!dr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Vi(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(dr.current=!0,eg(n,new AbortController().signal).then(e=>{e?cr(e):dr.current=!1},()=>{dr.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(Zt)&&(ra(Bv()),QM?.setContextBlocked(!1)),Aa(),sn(null);return}let s=Oo(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}Ol(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,dA(L,U,be.getState().fastMode),Dl(c,a,Array.from(L.additionalWorkingDirectories.keys()),l),Mt(),ll()]),m={...f,...QM?.isProactiveActive()&&!Ca.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Ol(`query_context_loading_end`);let _=Ho({mainThreadAgentDefinition:I,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,Ol(`query_query_start`),ot(),ft(),it();for await(let t of ea({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:Do,toolUseContext:s,querySource:Pd()}))Ao(t);if(Ol(`query_end`),process.env.USER_TYPE===`ant`&&Oi.current.length>0){let e=Oi.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()-Mn.current;K(e=>[...e,tc({ttftMs:r?fN(t):t[0],otps:r?fN(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:Wf()})])}Aa(),Ks(),await v?.(wr.current)},[d,Aa,Oo,L,U,h,v,g,Do,I,Ao,or,N]),No=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{let c=Sn.tryStart();if(c===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Vi(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Ka({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{ss.current=!1,hn(!1),In(),K(t=>[...t,...e]),Di.current=0,tt((o?Lr(o):null)??Ne()),Oi.current=[],tn([]),ji(null);let c=wr.current;if(o&&await Pa(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await Mo(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(Sn.end(c)){hn(t.signal.aborted),Ii(Date.now()),sa.current=!1,Aa(),await Fa(wr.current,t.signal.aborted),gn.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()-Mn.current-Pn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&K(t=>[...t,Ls(n,e,If(t,kr))]),sn(null)}if(t.signal.reason===`user-cancel`&&!Sn.isActive&&ii.current===``&&Li()===0&&!be.getState().viewingAgentTaskId){let e=wr.current,t=e.findLast(bg);t&&Sg(e,e.lastIndexOf(t))&&(_s(),_n.current(t))}}return!0},[Mo,U,Aa,Sn,Pa,Fa]),Po=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Po.current)return;Po.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Ml():void 0,{clearConversation:n}=await import(`./conversation-CSpwF3Ha.js`);await n({setMessages:K,readFileState:$a.current,discoveredSkillNames:no.current,loadedNestedMemoryPaths:ro.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:ra}),dr.current=!1,cr(void 0),eo.current.clear(),to.current=0,t&&vs(st(),t)}U(t=>{let n=e.mode?wd(t.toolPermissionContext,$x(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=wi({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),cn()&&kn(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Jr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Fo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=vr();sn(t),No([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Po)}t(e)},[ce,W,K,U,No,Se,Gt]);let Fo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Vr(),QM?.resumeProactive(),cs(e)){let n=Ba({content:e});K(e=>[...e,n]),r?.fromKeybinding||zs({display:on(e,ci),pastedContents:Si}),si(``),t.setCursorOffset(0),t.clearBuffer(),Ci({}),li(`prompt`),pt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=Sl(e,Si).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Jt.find(e=>Ju(e)&&(e.name===a||e.aliases?.includes(a)||Bs(e)===a));s?.name===`clear`&&Tr.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:Tr.current,idleMinutes:Math.round((Date.now()-ca.current)/6e4),messageCount:wr.current.length,totalInputTokens:ct()}),Tr.current=!1);let c=Sn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===ii.current.trim()&&(si(``),t.setCursorOffset(0),t.clearBuffer(),Ci({}));let n=Cc(e).filter(e=>Si[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(Si[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,Yn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Su())){let e=r?.displayArgs??o;i.push(Ic(Nn(Bs(s),e)),Ic(`<${np}>${jo(n)}</${np}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Ba({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),ui!==void 0&&(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0))},r=Oo(wr.current,[],vr(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Yn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(xi.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(zs({display:n?e:on(e,ci),pastedContents:n?{}:Si}),ci===`bash`&&vw(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||xi.isRemoteMode;if(ui!==void 0&&!i&&a?(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0)):a&&(r?.fromKeybinding||(si(``),t.setCursorOffset(0)),Ci({})),a&&(li(`prompt`),pt(void 0),Ei(e=>e+1),t.clearBuffer(),Ta.current=!1,!i&&ci===`prompt`&&!n&&!xi.isRemoteMode&&(Er(e),In()),U(e=>({...e,attribution:Oh(e.attribution,e=>{oc(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Go(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:$a,cwd:ut()});if(t){let e=vr();sn(e),No([],e,!0,[],Se)}return}if(xi.isRemoteMode&&!(i&&Jt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Ju(t)&&(t.name===n||t.aliases?.includes(n)||Bs(t)===n)})?.type===`local-jsx`)){let t=Object.values(Si),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=Ba({content:i,imagePasteIds:r});K(e=>[...e,o]),await xi.sendMessage(a,{uuid:o.uuid});return}await Jr(),await nk({input:e,helpers:t,queryGuard:Sn,isExternalLoading:wn,mode:ci,commands:Jt,onInputChange:si,setPastedContents:Ci,setToolJSX:Yn,getToolUseContext:Oo,messages:wr.current,mainLoopModel:Se,pastedContents:Si,ideSelection:at,setUserInputOnProcessing:Er,setAbortController:sn,abortController:an,onQuery:No,setAppState:U,querySource:Pd(),onBeforeQuery:_,canUseTool:Do,addNotification:Ze,setMessages:K,streamMode:$t.current,hasInterruptibleToolInProgress:hi.current}),(i||W)&&ui!==void 0&&(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0))},[Sn,W,wn,ci,Jt,si,li,Ci,Ei,pt,Yn,Oo,Se,Si,at,Er,sn,Ze,No,ui,di,U,_,Do,gi,K,Jr,Vr]),Io=(0,Q.useCallback)(()=>{let e=so?Sj(so):`/issue`;co(null),Fo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${$d(t)}`)})},[Fo,so]),Lo=(0,Q.useCallback)(()=>{co(null)},[]),Ro=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;Fo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Fo]),zo=(0,Q.useRef)(Fo);zo.current=Fo;let Bo=(0,Q.useCallback)(()=>{zo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Vo=(0,Q.useCallback)(async()=>{if(mo(!0),oi()){Gv(`tmux`,[`detach-client`],{stdio:`ignore`}),mo(!1);return}if(mn()!==null){fo((0,$.jsx)(N_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{fo(null),mo(!1)}}));return}let e=await(await nu.load()).call(()=>{});fo(e),e===null&&mo(!1)},[]),Uo=(0,Q.useCallback)(()=>{Xi(e=>!e)},[]),Wo=(0,Q.useCallback)(e=>{let t=wr.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),ra(Bv()),Wr();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}}))},[K,U]),qo=(0,Q.useCallback)(e=>{Wo(e);let t=ya(e);if(t&&(si(t.text),li(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}}}),Ci(n)}}},[Wo,si]);_n.current=qo;let Yo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),qo,e)},[qo]),Xo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Zo,handlers:Qo}=Qa(Fr,Ir,zr,{copy:e=>void re(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=Xo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!bg(n))return;let r=!await qa(se,n.uuid),i=Sg(G,t);r&&i?(xo(),Yo(n)):(Qi(n),Xi(!0))}});async function $o(){oo();let e=await ti();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
137
+ </goal-steering>`}var LM=t((()=>{})),RM=r({useGoalContinuation:()=>BM});function zM(e){Y(`[goal] hook: ${e}`)}function BM(e){let t=(0,VM.useRef)(e);t.current=e;let n=(0,VM.useRef)(!1),r=(0,VM.useRef)(!1);(0,VM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){zM(`skip: queryActiveNow=true`);return}if(e.wasAborted){zM(`skip: wasAborted=true`);return}if(n.current)return;if(dl().length>0){zM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){zM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){zM(`skip: planMode`);return}let t=Fl();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=IM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Ka({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){zM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){ad()&&(Bc(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=Dc();Bc();let a=FM(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Ka({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 VM,HM=t((()=>{VM=n(z(),1),sf(),xs(),LM(),gi()})),UM=r({AntModelSwitchCallout:()=>WM,shouldShowModelSwitchCallout:()=>GM});function WM(e){return null}function GM(){return!1}t((()=>{}));var KM=r({UndercoverAutoCallout:()=>qM});function qM({onDone:e}){return(0,JM.useEffect)(()=>{e()},[e]),null}var JM,YM=t((()=>{JM=n(z(),1)}));at(),bu(),kf(),u(),B(),xl(),qg(),Po(),sf(),s(),jp(),Ts(),zt(),ga(),wg(),Zl(),Al(),Fa(),wn(),$c(),pf(),sp(),Yd(),gd(),nn(),kc(),Uf(),fm(),Tp(),Wd(),tg(),ap(),pc(),Ru(),nv(),lg(),cs(),Od(),e_(),J(),wc(),ol(),fl(),Bi(),In(),gi(),os(),po(),Ns(),Bl(),Qr();var XM=process.env.USER_TYPE===`ant`?(EM(),e(SM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),ZM=process.env.USER_TYPE===`ant`?e(DM).useAntOrgWarningNotification:()=>{},QM=(bh(),e(lh)),$M=e=>()=>{},eN=()=>!1,tN=()=>null,nN=(e,t)=>!1,rN=(NM(),e(kM)).useProactive,iN=(HM(),e(RM)).useGoalContinuation,aN=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),oN=()=>({routeToSelectedPipes:()=>!1}),sN=process.env.USER_TYPE===`ant`?e(UM).AntModelSwitchCallout:null,cN=process.env.USER_TYPE===`ant`?e(UM).shouldShowModelSwitchCallout:()=>!1,lN=process.env.USER_TYPE===`ant`?(YM(),e(KM)).UndercoverAutoCallout:null,uN=[],dN=3e3;function fN(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 pN({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=Wi(`app:toggleTranscript`,`Global`,`ctrl+o`),o=Wi(`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 mN({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=w_({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 hN=[`⠂`,`⠐`],gN=`✳`,_N=960;function vN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=M(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%hN.length),_N,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?hN[a]??gN:gN;return ee(n?null:r?t:`${s} ${t}`),null}var yN=`<${op}>`;function bN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(yN)}function xN({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:A}){let j=!!D,N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),ee=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),P=(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[I,ne]=(0,Q.useState)(S),L=q(e=>e.toolPermissionContext),R=q(e=>e.verbose),ie=q(e=>e.mcp),z=q(e=>e.plugins),ae=q(e=>e.agentDefinitions),se=q(e=>e.fileHistory),ce=q(e=>e.initialMessage),le=mC(),ue=q(e=>e.spinnerTip),pe=q(e=>e.expandedView)===`tasks`,B=q(e=>e.tasks),H=q(e=>e.elicitation),me=q(e=>e.ultraplanPendingChoice),he=q(e=>e.ultraplanLaunchPending),ge=q(e=>e.viewingAgentTaskId),U=Ko(),ve=ge?B[ge]:void 0,ye=sl(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;ed(ho(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!sl(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=es(),xe=E(),Se=$g(),[Ce,we]=(0,Q.useState)(t);dk(j?void 0:dt(),we);let Te=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.isProactiveActive??eN),Ee=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.getNextTickAt??tN),De=q(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>rs(L),[L,Te,De]);pA();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}=tr(),$e=nN,et=lk(d,ie.clients),[at,pt]=(0,Q.useState)(void 0),[mt,_t]=(0,Q.useState)(null),[yt,bt]=(0,Q.useState)(null),[Ct,wt]=(0,Q.useState)(!1),[Tt,Dt]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&cN()),[Ot,kt]=(0,Q.useState)(()=>Ok(Se)),At=q(e=>e.showRemoteCallout),[jt,Pt]=(0,Q.useState)(()=>Sv());lj(),fj(),sj({ideSelection:at,mcpClients:et,ideInstallationStatus:yt}),yA({mcpClients:et}),YA(),XA(),O_(),nj(Se),vj(),rj(Se),aj(),ZM(),$k(),oA(),SA();let{recommendation:Lt,handleResponse:Rt}=RA(),{recommendation:zt,handleResponse:Bt}=VA(),Vt=JA(),Ht=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);dg({enabled:!j});let Ut=Et();(0,Q.useEffect)(()=>{j||$A(U)},[U,j]);let Wt=Gg(Ht,ie.tools,L),{tools:Gt,allowedAgentTypes:Kt}=(0,Q.useMemo)(()=>{if(!I)return{tools:Wt,allowedAgentTypes:void 0};let e=Ft(I,Wt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[I,Wt]),qt=uk(uk(Ce,z.commands),ie.commands),Jt=(0,Q.useMemo)(()=>C?[]:qt,[C,qt]);Hy(j?uN:ie.clients),pk(j?uN:ie.clients,pt);let[Xt,Qt]=(0,Q.useState)(`responding`),$t=(0,Q.useRef)(Xt);$t.current=Xt;let[en,tn]=(0,Q.useState)([]),[nn,rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(nn&&!nn.isStreaming&&nn.streamingEndedAt){let e=3e4-(Date.now()-nn.streamingEndedAt);if(e>0){let t=setTimeout(rn,e,null);return()=>clearTimeout(t)}else rn(null)}},[nn]);let[an,sn]=(0,Q.useState)(null),ln=(0,Q.useRef)(null);ln.current=an;let un=(0,Q.useRef)(0),[pn,hn]=(0,Q.useState)(!1),gn=(0,Q.useRef)(()=>{}),_n=(0,Q.useRef)(()=>{}),vn=(0,Q.useRef)(null),bn=(0,Q.useRef)(null),xn=(0,Q.useRef)(0),Sn=Q.useRef(new Sy).current,Cn=Q.useSyncExternalStore(Sn.subscribe,Sn.getSnapshot),[wn,Tn]=Q.useState(D?.hasInitialPrompt??!1),W=Cn||wn,[En,Dn]=Q.useState(void 0),On=Q.useRef(0),jn=Q.useRef(!1),Mn=Q.useRef(0),Pn=Q.useRef(0),Fn=Q.useRef(null),In=Q.useCallback(()=>{Mn.current=Date.now(),Pn.current=0,Fn.current=null},[]),Ln=Q.useRef(!1);Cn&&!Ln.current&&In(),Ln.current=Cn;let Rn=Q.useCallback(e=>{Tn(e),e&&In()},[In]),zn=Q.useRef(void 0),[Bn,Vn]=Q.useState(!1),[Hn,Un]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Hn?.notifications&&Hn.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Hn,Ze]),(0,Q.useEffect)(()=>{Su()&&is().then(e=>{e&&Ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Wn,Gn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-DIT_s0vY.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-CG_269xD.js`);t()&&Gn(!0)})()},[]);let[Kn,qn]=(0,Q.useState)(null),Jn=(0,Q.useRef)(null),Yn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Jn.current={...n,isLocalJSXCommand:!0},qn(n);return}if(Jn.current){if(e?.clearLocalJSX){Jn.current=null,qn(null),un.current=Date.now();return}return}if(e?.clearLocalJSX){qn(null);return}qn(e)},[]),[Xn,Zn]=(0,Q.useState)([]),[Qn,$n]=(0,Q.useState)(null),[er,nr]=(0,Q.useState)([]),[rr,ir]=(0,Q.useState)([]),ar=(0,Q.useRef)(new Map),or=q(e=>e.settings.terminalTitleFromRename)===!1?void 0:Il(st()),[sr,cr]=(0,Q.useState)(),dr=(0,Q.useRef)((i?.length??0)>0),fr=I?.agentType,pr=or??fr??sr??`Work Mate`,mr=Xn.length>0||rr.length>0,hr=Kn?.isLocalJSXCommand===!0&&Kn?.jsx!=null,_r=W&&!mr&&!hr;(0,Q.useEffect)(()=>{if(W&&!mr&&!hr)return hy(),()=>gy()},[W,mr,hr]);let yr=mr||hr?`waiting`:W?`busy`:`idle`,br=yr===`waiting`?Xn.length>0?`approve ${Xn[0].tool.name}`:hr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Vd({status:yr,waitingFor:br})},[yr,br]),F(null);let[G,xr]=(0,Q.useState)(i??[]),wr=(0,Q.useRef)(G),Tr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=wr.current,n=typeof e==`function`?e(wr.current):e;if(wr.current=n,n.length<On.current)On.current=0;else if(n.length>t.length&&jn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(vi)?jn.current=!1:On.current=n.length}xr(n)},[]),Er=(0,Q.useCallback)(e=>{e===void 0?jn.current=!1:(On.current=wr.current.length,jn.current=!0),Dn(e)},[]),{dividerIndex:Or,dividerYRef:Ar,onScrollAway:jr,onRepin:Mr,jumpToNew:Nr,shiftDivider:Pr}=rv(G.length);eA(G,K,W);let[Fr,Ir]=(0,Q.useState)(null),zr=(0,Q.useRef)(null),Br=(0,Q.useMemo)(()=>ev(G,Or),[Or,G.length]),Vr=(0,Q.useCallback)(()=>{vn.current?.scrollToBottom(),Mr(),Ir(null)},[Mr,Ir]),Ur=G.at(-1),Gr=Ur!=null&&vi(Ur);(0,Q.useEffect)(()=>{Gr&&Vr()},[Gr,Ur,Vr]);let{maybeLoadOlder:Kr}=yO({config:D,setMessages:K,scrollRef:vn,onPrepend:Pr}),qr=(0,Q.useCallback)((e,t)=>{xn.current=Date.now(),e?Mr():(jr(t),Kr(t))},[Mr,jr,Kr,U]),Jr=FO(o,K),Yr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),Xr=G.length-Yr.length;Xr>0&&Y(`[useDeferredValue] Messages deferred by ${Xr} (${Yr.length}→${G.length})`);let[Qr,$r]=(0,Q.useState)(null),[ei,ri]=(0,Q.useState)(()=>hv()),ii=(0,Q.useRef)(ei);ii.current=ei;let ai=(0,Q.useRef)(null),si=(0,Q.useCallback)(e=>{$e(ii.current,e)||(ii.current===``&&e!==``&&Date.now()-xn.current>=dN&&Vr(),ii.current=e,ri(e),Vn(e.trim().length>0))},[Vn,Vr,$e]);(0,Q.useEffect)(()=>{if(ei.trim().length===0)return;let e=setTimeout(Vn,1500,!1);return()=>clearTimeout(e)},[ei]);let[ci,li]=(0,Q.useState)(`prompt`),[ui,di]=(0,Q.useState)(),fi=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||ka.has(e)))},[we]),[pi,mi]=(0,Q.useState)(new Set),hi=(0,Q.useRef)(!1),gi=iO({config:D,setMessages:K,setIsLoading:Rn,onInit:fi,setToolUseConfirmQueue:Zn,tools:Ht,setStreamingToolUses:tn,setStreamMode:Qt,setInProgressToolUseIDs:mi}),yi=sO({config:O,setMessages:K,setIsLoading:Rn,setToolUseConfirmQueue:Zn,tools:Ht}),bi=cO({session:k,setMessages:K,setIsLoading:Rn,setToolUseConfirmQueue:Zn,tools:Ht}),xi=bi.isRemoteMode?bi:yi.isRemoteMode?yi:gi,[Si,Ci]=(0,Q.useState)({}),[Ti,Ei]=(0,Q.useState)(0),Di=(0,Q.useRef)(0),Oi=(0,Q.useRef)([]),ki=(0,Q.useCallback)(e=>{let t=Di.current;if(Di.current=e(t),Di.current>t){let e=Oi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Di.current}}},[]),[Ai,ji]=(0,Q.useState)(null),Mi=!(q(e=>e.settings.prefersReducedMotion)??!1)&&!V(),Ni=(0,Q.useCallback)(e=>{Mi&&ji(e)},[Mi]),Pi=Ai&&Mi&&Ai.substring(0,Ai.lastIndexOf(`
138
+ `)+1)||null,[Fi,Ii]=(0,Q.useState)(0),[Bi,Hi]=(0,Q.useState)(null),[Wi,Ki]=(0,Q.useState)(null),[qi,Ji]=(0,Q.useState)(null),[Yi,Xi]=(0,Q.useState)(!1),[Zi,Qi]=(0,Q.useState)(void 0),[$i,ta]=(0,Q.useState)(!1),[na,ra]=(0,Q.useState)(Bv()),[aa,oa]=(0,Q.useState)(null),sa=(0,Q.useRef)(!1),ca=(0,Q.useRef)(Fi);ca.current=Fi;let[ua]=(0,Q.useState)(()=>({current:Jo(i,c)}));Tc(()=>{ua.current=vu()});let[da,fa]=(0,Q.useState)(Hf().hasAcknowledgedCostThreshold),[pa,ma]=(0,Q.useState)(`INSERT`),[ha,ga]=(0,Q.useState)(!1),[_a,va]=(0,Q.useState)(!1),[ba,xa]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&ha&&ga(!1)},[me,ha]);let Sa=M(),Ca=(0,Q.useRef)(Sa);Ca.current=Sa;let[wa]=y(),Ta=Q.useRef(!1),Da=(0,Q.useCallback)(()=>{if(Ta.current)return;Ta.current=!0;let e=wr.current.slice(to.current);for(let t of la(e))eo.current.add(t);to.current=wr.current.length,cA({theme:wa,readFileState:$a.current,bashTools:eo.current}).then(async e=>{if(e){let t=await e.content({theme:wa});U(e=>({...e,spinnerTip:t})),lA(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,wa]),Aa=(0,Q.useCallback)(()=>{Rn(!1),Er(void 0),Di.current=0,Oi.current=[],ji(null),tn([]),Hi(null),Ki(null),Ji(null),Da(),Ch(),cu()},[Da]),ja=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(L.mode!==`auto`){ja.current=!1;return}if(ja.current||(Hf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Vf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,kd(bA,`warning`)])},800,ja,K);return()=>clearTimeout(e)}},[L.mode,K]);let Ma=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ma.current)return;let e=mn();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ma.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,kd(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[K]);let Na=(0,Q.useMemo)(()=>{let e=G.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&pi.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[G,pi]),{onBeforeQuery:Pa,onTurnComplete:Fa,render:Ia}=MO({enabled:ee,setMessages:K,inputValue:ei,setInputValue:si,setToolJSX:Yn}),La=(!Kn||Kn.showSpinner===!0)&&Xn.length===0&&rr.length===0&&(W||En||Li()>0)&&!Na&&(!Pi||De),za=Xn.length>0||rr.length>0||er.length>0||H.queue.length>0,Va=Ik(G,W,Ti,`session`,za),Ha=jO(K),Ua=Mj(G,Ti),Wa=(0,Q.useMemo)(()=>({...Va,handleSelect:e=>{lo.current=!1;let t=Va.handleSelect(e);e===`bad`&&!t&&xj(`feedback_survey_bad`)&&(co(`feedback_survey_bad`),lo.current=!0)}}),[Va]),Ga=Wk(G,W,za,{enabled:!j}),Ja=Bk(G,W,za,{enabled:!j}),Ya=XM(G,W,za,Wa.state!==`closed`||Ga.state!==`closed`||Ja.state!==`closed`);xk({autoConnectIdeFlag:p,ideToInstallExtension:mt,setDynamicMcpConfig:Ae,setShowIdeOnboarding:wt,setIDEInstallationState:bt}),mA(s,se,e=>U(t=>({...t,fileHistory:e})));let Xa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=lr(n.messages),o=ec();await ps(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await hs(`resume`,{sessionId:t,agentType:I?.agentType,model:Se});a.push(...s),r===`fork`?Yu(n,ur(t)):Zs(n,ur(t)),Ng(n,U),n.fileHistorySnapshots&&xd(n);let{agentDefinition:c}=jg(n.agentSetting,S,ae);ne(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Mg(n.agentName,n.agentColor)})),wo(n.agentName),io(a,n.projectPath??ut()),Aa(),sn(null),ra(t);let l=As(t);Ws(),ht(),gt(ur(t),n.fullPath?jv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-BsWpcxrc.js`);if(await u(),await vc(),Wl(),au(n),n.goal){let{hydrateGoalFromTranscript:r}=(Tu(),e(Vl)),i=new Map;i.set(t,n.goal),r(i,t)}if(dr.current=!0,cr(void 0),r!==`fork`)Pg(),Fg(n.worktreeSession),Rr(),Gi({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=mn();e&&dn(e)}l&&rt(l),ua.current&&r!==`fork`&&(ua.current=ls(a,n.contentReplacements??[])),K(()=>a),Yn(null),si(``),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}},[Aa,U]),[Za]=(0,Q.useState)(()=>oh(100)),$a=(0,Q.useRef)(Za),eo=(0,Q.useRef)(new Set),to=(0,Q.useRef)(0),no=(0,Q.useRef)(new Set),ro=(0,Q.useRef)(new Set),io=(0,Q.useCallback)((e,t)=>{let n=St(e,t,100);$a.current=ch($a.current,n);for(let t of la(e))eo.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(io(i,ut()),Gi({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:ao,reverify:oo}=IO(),[so,co]=(0,Q.useState)(null),lo=(0,Q.useRef)(!1),[uo,fo]=(0,Q.useState)(null),[po,mo]=(0,Q.useState)(!1),go=!W&&$i;function _o(){if(po||uo)return;if(Yi)return`message-selector`;if(Bn)return;if(er[0])return`sandbox-permission`;let e=!Kn||Kn.shouldContinueAnimation;if(e&&Xn[0])return`tool-permission`;if(e&&rr[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&go)return`cost`;if(e&&aa)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&Ct)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Tt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&Wn)return`undercover-callout`;if(e&&Ot)return`effort-callout`;if(e&&At)return`remote-callout`;if(e&&Lt)return`lsp-recommendation`;if(e&&zt)return`plugin-hint`;if(e&&Vt.visible)return`search-extra-tools-hint`;if(e&&jt)return`desktop-upsell`}let vo=_o(),yo=Bn&&(er[0]||Xn[0]||rr[0]||H.queue[0]||go);zn.current=vo,(0,Q.useEffect)(()=>{if(!W)return;let e=vo===`tool-permission`,t=Date.now();e&&Fn.current===null?Fn.current=t:!e&&Fn.current!==null&&(Pn.current+=t-Fn.current,Fn.current=null)},[vo,W]);let bo=(0,Q.useRef)(vo);(0,Q.useLayoutEffect)(()=>{bo.current===`tool-permission`!=(vo===`tool-permission`)&&Vr(),bo.current=vo},[vo,Vr]);function xo(){if(vo!==`elicitation`){if(un.current!==0&&Date.now()-un.current<500){un.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(un.current=0,Y(`[onCancel] focusedInputDialog=${vo} streamMode=${Xt}`),QM?.pauseProactive(),Sn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(xs(),e(Lc)),{persistCurrentGoal:r}=(Tu(),e(Vl));t()?.status===`active`&&(n(),r())}if(hn(!0),Sn.forceEnd(),sa.current=!1,Ai?.trim()&&K(e=>[...e,su({content:Ai})]),Aa(),tt(null),vo===`tool-permission`)Xn[0]?.onAbort(),Zn([]);else if(vo===`prompt`){for(let e of rr)e.reject(Error(`Prompt cancelled by user`));ir([]),an?.abort(`user-cancel`)}else xi.isRemoteMode?xi.cancelRequest():an?.abort(`user-cancel`);sn(null),Fa(wr.current,!0)}}let So=(0,Q.useCallback)(()=>{let e=Sr(ei,0);e&&(si(e.text),li(`prompt`),e.images.length>0&&Ci(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[si,li,ei,Ci]),Co={setToolUseConfirmQueue:Zn,onCancel:xo,onAgentsKilled:()=>K(e=>[...e,$u()]),isMessageSelectorVisible:Yi||!!ha,screen:Pe,abortSignal:an?.signal,popCommandFromQueue:So,vimMode:pa,isLocalJSXCommand:Kn?.isLocalJSXCommand,isSearchingHistory:_a,isHelpOpen:ba,inputMode:ci,inputValue:ei,streamMode:Xt};(0,Q.useEffect)(()=>{lt()>=5&&!$i&&!da&&(Z(`tengu_cost_threshold_reached`,{}),fa(!0),jm()&&ta(!0))},[G,$i,da]);let To=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}nr(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=Bv();t.sendRequest(n,mg,{host:e.host},Bv(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;nr(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=ar.current.get(e.host);if(i){for(let e of i)e();ar.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=ar.current.get(e.host)??[];a.push(i),ar.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=gs.getSandboxUnavailableReason();if(e){if(gs.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Js(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]),gs.isSandboxingEnabled()&&gs.initialize(To).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${$d(e)}\n`),Js(1,`other`)});let Eo=(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))},Zn)},[U,Zn]),Do=ek(Zn,Eo),Oo=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Zr(e.toolPermissionContext,e.mcp.tools),n=vg(Ht,t,e.toolPermissionContext.mode);return I?Ft(I,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Jt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:A,mcpClients:ck(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:yt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:wa,agentDefinitions:Kt?{...a.agentDefinitions,allowedAgentTypes:Kt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:U,messages:e,setMessages:K,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||Xi(!0)},onChangeAPIKey:oo,readFileState:$a.current,setToolJSX:Yn,addNotification:Ze,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{ry(e,xe)},onChangeDynamicMcpConfig:je,onInstallIDEExtension:_t,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:ro.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:no.current,setResponseLength:ki,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Di.current;Oi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Qt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Ki(`claudeBlue_FOR_SYSTEM_SPINNER`),Ji(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Hi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Hi(`Compacting conversation`);break;case`compact_end`:Hi(null),Ki(null),Ji(null);break}},setInProgressToolUseIDs:mi,setHasInterruptibleToolInProgress:e=>{hi.current=e},resume:Xa,setConversationId:ra,requestPrompt:void 0,contentReplacementState:ua.current}},[Jt,Ht,I,n,d,yt,ke,wa,Kt,be,U,oo,Ze,K,je,Xa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{ir(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,ra]),{handleBackgroundSession:ko}=Ck({setMessages:K,setIsLoading:Rn,resetLoadingState:Aa,setAbortController:sn,onBackgroundQuery:(0,Q.useCallback)(()=>{an?.abort(`background`);let e=ni(e=>e.mode===`task-notification`);(async()=>{let t=Oo(wr.current,[],new AbortController,Se),[n,r,i]=await Promise.all([Dl(t.options.tools,Se,Array.from(L.additionalWorkingDirectories.keys()),t.options.mcpClients),Mt(),ll()]),a=Ho({mainThreadAgentDefinition:I,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await zi(e).catch(()=>[])).map(An),s=new Set;for(let e of wr.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));Ui({messages:[...wr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Do,toolUseContext:t,querySource:Pd()},description:pr,setAppState:U,agentDefinition:I})})()},[an,Se,L,I,Oo,h,g,Do,U])}),Ao=(0,Q.useCallback)(t=>{Dr(t,t=>{if(Zt(t)?(Su()?K(e=>{let n=It(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),ra(Bv()),QM?.setContextBlocked(!1)):t.type===`progress`&&ia(t.data?.type)?K(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?QM?.setContextBlocked(!0):t.type===`assistant`&&QM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Vi(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}=(xs(),e(Lc)),{persistCurrentGoal:r}=(Tu(),e(Vl));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=>{ki(t=>t+e.length)},Qt,tn,e=>{K(t=>t.filter(t=>t!==e)),wl(e.uuid)},rn,e=>{let t=Date.now(),n=Di.current;Oi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Ni)},[K,ki,Qt,tn,rn,Ni]),Mo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=ck(d,be.getState().mcp.clients);Yt.handleQueryStart(e);let t=Ra(e);t&&Dd(t)}if(Vh(),!N&&!or&&!fr&&!dr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Vi(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(dr.current=!0,eg(n,new AbortController().signal).then(e=>{e?cr(e):dr.current=!1},()=>{dr.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(Zt)&&(ra(Bv()),QM?.setContextBlocked(!1)),Aa(),sn(null);return}let s=Oo(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}Ol(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,dA(L,U,be.getState().fastMode),Dl(c,a,Array.from(L.additionalWorkingDirectories.keys()),l),Mt(),ll()]),m={...f,...QM?.isProactiveActive()&&!Ca.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Ol(`query_context_loading_end`);let _=Ho({mainThreadAgentDefinition:I,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,Ol(`query_query_start`),ot(),ft(),it();for await(let t of ea({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:Do,toolUseContext:s,querySource:Pd()}))Ao(t);if(Ol(`query_end`),process.env.USER_TYPE===`ant`&&Oi.current.length>0){let e=Oi.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()-Mn.current;K(e=>[...e,tc({ttftMs:r?fN(t):t[0],otps:r?fN(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:Wf()})])}Aa(),Ks(),await v?.(wr.current)},[d,Aa,Oo,L,U,h,v,g,Do,I,Ao,or,N]),No=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{let c=Sn.tryStart();if(c===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Vi(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Ka({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{ss.current=!1,hn(!1),In(),K(t=>[...t,...e]),Di.current=0,tt((o?Lr(o):null)??Ne()),Oi.current=[],tn([]),ji(null);let c=wr.current;if(o&&await Pa(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await Mo(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(Sn.end(c)){hn(t.signal.aborted),Ii(Date.now()),sa.current=!1,Aa(),await Fa(wr.current,t.signal.aborted),gn.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()-Mn.current-Pn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&K(t=>[...t,Ls(n,e,If(t,kr))]),sn(null)}if(t.signal.reason===`user-cancel`&&!Sn.isActive&&ii.current===``&&Li()===0&&!be.getState().viewingAgentTaskId){let e=wr.current,t=e.findLast(bg);t&&Sg(e,e.lastIndexOf(t))&&(_s(),_n.current(t))}}return!0},[Mo,U,Aa,Sn,Pa,Fa]),Po=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Po.current)return;Po.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Ml():void 0,{clearConversation:n}=await import(`./conversation-BWXf3un9.js`);await n({setMessages:K,readFileState:$a.current,discoveredSkillNames:no.current,loadedNestedMemoryPaths:ro.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:ra}),dr.current=!1,cr(void 0),eo.current.clear(),to.current=0,t&&vs(st(),t)}U(t=>{let n=e.mode?wd(t.toolPermissionContext,$x(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=wi({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),cn()&&kn(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Jr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Fo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=vr();sn(t),No([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Po)}t(e)},[ce,W,K,U,No,Se,Gt]);let Fo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Vr(),QM?.resumeProactive(),cs(e)){let n=Ba({content:e});K(e=>[...e,n]),r?.fromKeybinding||zs({display:on(e,ci),pastedContents:Si}),si(``),t.setCursorOffset(0),t.clearBuffer(),Ci({}),li(`prompt`),pt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=Sl(e,Si).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Jt.find(e=>Ju(e)&&(e.name===a||e.aliases?.includes(a)||Bs(e)===a));s?.name===`clear`&&Tr.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:Tr.current,idleMinutes:Math.round((Date.now()-ca.current)/6e4),messageCount:wr.current.length,totalInputTokens:ct()}),Tr.current=!1);let c=Sn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===ii.current.trim()&&(si(``),t.setCursorOffset(0),t.clearBuffer(),Ci({}));let n=Cc(e).filter(e=>Si[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(Si[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,Yn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Su())){let e=r?.displayArgs??o;i.push(Ic(Nn(Bs(s),e)),Ic(`<${np}>${jo(n)}</${np}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Ba({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),ui!==void 0&&(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0))},r=Oo(wr.current,[],vr(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Yn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(xi.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(zs({display:n?e:on(e,ci),pastedContents:n?{}:Si}),ci===`bash`&&vw(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||xi.isRemoteMode;if(ui!==void 0&&!i&&a?(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0)):a&&(r?.fromKeybinding||(si(``),t.setCursorOffset(0)),Ci({})),a&&(li(`prompt`),pt(void 0),Ei(e=>e+1),t.clearBuffer(),Ta.current=!1,!i&&ci===`prompt`&&!n&&!xi.isRemoteMode&&(Er(e),In()),U(e=>({...e,attribution:Oh(e.attribution,e=>{oc(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Go(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:$a,cwd:ut()});if(t){let e=vr();sn(e),No([],e,!0,[],Se)}return}if(xi.isRemoteMode&&!(i&&Jt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Ju(t)&&(t.name===n||t.aliases?.includes(n)||Bs(t)===n)})?.type===`local-jsx`)){let t=Object.values(Si),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=Ba({content:i,imagePasteIds:r});K(e=>[...e,o]),await xi.sendMessage(a,{uuid:o.uuid});return}await Jr(),await nk({input:e,helpers:t,queryGuard:Sn,isExternalLoading:wn,mode:ci,commands:Jt,onInputChange:si,setPastedContents:Ci,setToolJSX:Yn,getToolUseContext:Oo,messages:wr.current,mainLoopModel:Se,pastedContents:Si,ideSelection:at,setUserInputOnProcessing:Er,setAbortController:sn,abortController:an,onQuery:No,setAppState:U,querySource:Pd(),onBeforeQuery:_,canUseTool:Do,addNotification:Ze,setMessages:K,streamMode:$t.current,hasInterruptibleToolInProgress:hi.current}),(i||W)&&ui!==void 0&&(si(ui.text),t.setCursorOffset(ui.cursorOffset),Ci(ui.pastedContents),di(void 0))},[Sn,W,wn,ci,Jt,si,li,Ci,Ei,pt,Yn,Oo,Se,Si,at,Er,sn,Ze,No,ui,di,U,_,Do,gi,K,Jr,Vr]),Io=(0,Q.useCallback)(()=>{let e=so?Sj(so):`/issue`;co(null),Fo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${$d(t)}`)})},[Fo,so]),Lo=(0,Q.useCallback)(()=>{co(null)},[]),Ro=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;Fo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Fo]),zo=(0,Q.useRef)(Fo);zo.current=Fo;let Bo=(0,Q.useCallback)(()=>{zo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Vo=(0,Q.useCallback)(async()=>{if(mo(!0),oi()){Gv(`tmux`,[`detach-client`],{stdio:`ignore`}),mo(!1);return}if(mn()!==null){fo((0,$.jsx)(N_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{fo(null),mo(!1)}}));return}let e=await(await nu.load()).call(()=>{});fo(e),e===null&&mo(!1)},[]),Uo=(0,Q.useCallback)(()=>{Xi(e=>!e)},[]),Wo=(0,Q.useCallback)(e=>{let t=wr.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),ra(Bv()),Wr();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}}))},[K,U]),qo=(0,Q.useCallback)(e=>{Wo(e);let t=ya(e);if(t&&(si(t.text),li(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}}}),Ci(n)}}},[Wo,si]);_n.current=qo;let Yo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),qo,e)},[qo]),Xo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Zo,handlers:Qo}=Qa(Fr,Ir,zr,{copy:e=>void re(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=Xo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!bg(n))return;let r=!await qa(se,n.uuid),i=Sg(G,t);r&&i?(xo(),Yo(n)):(Qi(n),Xi(!0))}});async function $o(){oo();let e=await ti();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
139
  `);Y(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else Y(`No CLAUDE.md/rules files found`);for(let t of e)$a.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})}NO(mv()),Cy(G,G.length===i?.length);let{sendBridgeResult:ts}=By(G,K,ln,Jt,Se);gn.current=ts,PO();let ns=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(le.length<1){ns.current=!1;return}ns.current||(ns.current=!0,Vf(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[le.length]),ok({executeQueuedInput:(0,Q.useCallback)(async e=>{await nk({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Sn,commands:Jt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Yn,getToolUseContext:Oo,messages:G,mainLoopModel:Se,ideSelection:at,setUserInputOnProcessing:Er,setAbortController:sn,onQuery:No,setAppState:U,querySource:Pd(),onBeforeQuery:_,canUseTool:Do,addNotification:Ze,setMessages:K,queuedCommands:e})},[Sn,Jt,Yn,Oo,G,Se,at,Er,Do,sn,No,Ze,U,_]),hasActiveLocalJsxUI:hr,queryGuard:Sn}),(0,Q.useEffect)(()=>{Jc.recordUserActivity(),vt(!0)},[ei,Ti]),(0,Q.useEffect)(()=>{Ti===1&&Tv()},[Ti]),(0,Q.useEffect)(()=>{if(W||Ti===0||Fi===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>=Hf().messageIdleNotifThresholdMs&&ry({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},Hf().messageIdleNotifThresholdMs,Fi,W,Kn,zn,xe);return()=>clearTimeout(e)},[W,Kn,Ti,Fi,xe]),(0,Q.useEffect)(()=>{},[Fi,W,Ze,Qe]);let as=(0,Q.useCallback)((e,t)=>{if(Sn.isActive||yn().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 Cu([n]),t=e.attachmentCommands[0];if(!t)return;let r=vr();sn(r);let i=Ba({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await No([i],r,!0,[],Se)!==!1}catch(t){try{await zc({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Xd(),priority:`later`})}catch(e){X(af(e))}X(af(t));return}if(a)try{let t=await zc({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Xd(),priority:`later`});for(let e of t)Ka(e)}catch(e){X(af(e))}})().catch(e=>{X(af(e))}),!0},[No,Se,be]),{relayPipeMessage:os,pipeReturnHadErrorRef:ss}=aN();sk({isLoading:W,onSubmitMessage:as}),q(e=>ug(e));let{routeToSelectedPipes:cs}=oN({store:be,setAppState:U,addNotification:Ze});process.env.USER_TYPE===`ant`&&vk({taskListId:w,isLoading:W,onSubmitTask:as}),rN?.({isLoading:W||ce!==null,queuedCommandsLength:le.length,hasActiveLocalJsxUI:hr,isInPlanMode:L.mode===`plan`,onQueueTick:e=>Ka(e)}),iN?.({isLoading:W||ce!==null,wasAborted:pn,queuedCommandsLength:le.length,hasActiveLocalJsxUI:hr,isInPlanMode:L.mode===`plan`,isQueryActiveNow:Sn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;K(e=>[...e,Ba({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){hh(null);return}if(!W){if(Ee!==null&&le.length===0&&!hr&&L.mode!==`plan`&&ce===null){hh({enabled:!0,phase:`standby`,next_tick_at:Ee,sleep_until:null});return}hh({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ce,W,hr,Te,Ee,le.length,L.mode]),(0,Q.useEffect)(()=>{le.some(e=>e.priority===`now`)&&ln.current?.abort(`interrupt`)},[le]);let us=(0,Q.useRef)($o);us.current=$o;let ds=(0,Q.useRef)(Yt);ds.current=Yt,(0,Q.useEffect)(()=>(us.current(),()=>{ds.current.shutdown()}),[]);let{internal_eventEmitter:fs}=te(),[ms,bs]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
140
140
  Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
141
141
  Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
142
- `)},t=()=>{bs(e=>e+1)};return fs?.on(`suspend`,e),fs?.on(`resume`,t),()=>{fs?.off(`suspend`,e),fs?.off(`resume`,t)}},[fs]);let Ss=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||G.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=If(G,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${Ap(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[G,W]),Cs=(0,Q.useCallback)(()=>{$r({messagesLength:G.length,streamingToolUsesLength:en.length})},[G.length,en.length]),ws=(0,Q.useCallback)(()=>{$r(null)},[]),Ts=Su()&&!P,Es=(0,Q.useRef)(null),[Ds,Os]=(0,Q.useState)(!1),[ks,js]=(0,Q.useState)(``),[Ms,Ns]=(0,Q.useState)(0),[Ps,Fs]=(0,Q.useState)(0),Is=(0,Q.useCallback)((e,t)=>{Ns(e),Fs(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Es.current?.setAnchor(),Os(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Ms>0){let t=r===`n`?Es.current?.nextMatch:Es.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&Ts&&!Ds&&!Be});let{setQuery:Rs,scanElement:Vs,setPositions:Hs}=fe(),Us=de().columns,Gs=Q.useRef(Us);Q.useEffect(()=>{Gs.current!==Us&&(Gs.current=Us,(ks||Ds)&&(Os(!1),js(``),Ns(0),Fs(0),Es.current?.disarmSearch(),Rs(``)))},[Us,ks,Ds,Rs]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ws(),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 ${Yr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await $v(Yr,Gt,e)).replace(/[ \t]+$/gm,``),r=Nv(Ov(),`cc-transcript-${Date.now()}.txt`);await Uv(r,n);let i=Xg(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`&&Ts&&!Ds});let qs=Pe===`transcript`&&Ts;(0,Q.useEffect)(()=>{qs||(js(``),Ns(0),Fs(0),Os(!1),Ge.current++,clearTimeout(Ke.current),Ve(!1),We(``))},[qs]),(0,Q.useEffect)(()=>{Rs(qs?ks:``),qs||Hs(null)},[qs,ks,Rs,Hs]);let Ys={screen:Pe,setScreen:Fe,showAllInTranscript:Ie,setShowAllInTranscript:Re,messageCount:G.length,onEnterTranscript:Cs,onExitTranscript:ws,virtualScrollActive:Ts,searchBarOpen:Ds},Xs=Qr?Yr.slice(0,Qr.messagesLength):Yr,Qs=Qr?en.slice(0,Qr.streamingToolUsesLength):en;HO({onOpenBackgroundTasks:hr?void 0:()=>ga(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let $s=ge?B[ge]:void 0,nc=$s&&sl($s)?$s:void 0,rc=Mi||!W,ic=nc?.messages,ac=(0,Q.useMemo)(()=>{if(!nc)return;let e=ic??[];if(!sl(nc)||nc.agentType!==`fork`||!nc.prompt)return e;let t=nc.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(bN))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=>!bN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Ba({content:nc.prompt,timestamp:new Date(nc.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[nc,ic]),sc=nc?ac??[]:rc?G:Yr;if(Pe===`transcript`){let e=Su()&&!P&&!Be?vn:void 0,t=(0,$.jsx)(ov,{messages:Xs,tools:Gt,commands:Jt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:pi,isMessageSelectorVisible:!1,conversationId:na,screen:Pe,agentDefinitions:ae,streamingToolUses:Qs,showAllInTranscript:Ie,onOpenRateLimitOptions:Bo,isLoading:W,hidePastThinking:!0,streamingThinking:nn,scrollRef:e,jumpRef:Es,onSearchMatchesChange:Is,scanElement:Vs,setPositions:Hs,disableRenderCap:Be}),n=Kn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),r=(0,$.jsxs)(_i,{children:[(0,$.jsx)(vN,{isAnimating:_r,title:pr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ys}),(0,$.jsx)(zO,{onSubmit:Fo,isActive:!Kn?.isLocalJSXCommand}),e?(0,$.jsx)(mM,{scrollRef:vn,isActive:vo!==`ultraplan-choice`,isModal:!Ds,onScroll:()=>Es.current?.disarmSearch()}):null,(0,$.jsx)(VO,{...Co}),e?(0,$.jsx)(iv,{scrollRef:vn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{})]}),bottom:Ds?(0,$.jsx)(mN,{jumpRef:Es,initialQuery:``,count:Ms,current:Ps,onClose:e=>{js(Ms>0?e:``),Os(!1),e||(Ns(0),Fs(0),Es.current?.setSearchQuery(``))},onCancel:()=>{Os(!1),Es.current?.setSearchQuery(``),Es.current?.setSearchQuery(ks),Rs(ks)},setHighlight:Rs}):(0,$.jsx)(pN,{showAllInTranscript:Ie,virtualScroll:!0,status:He||void 0,searchBadge:ks&&Ms>0?{current:Ps,count:Ms}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{}),(0,$.jsx)(pN,{showAllInTranscript:Ie,virtualScroll:!1,suppressShowAll:Be,status:He||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:Hr(),children:r}):r}let cc=En&&!nc&&sc.length<=On.current?En:void 0,lc=vo===`tool-permission`?(0,$.jsx)(US,{onDone:()=>Zn(([e,...t])=>t),onReject:So,toolUseConfirm:Xn[0],toolUseContext:Oo(G,G,an??vr(),Se),verbose:R,setStickyFooter:Su()?$n:void 0},Xn[0]?.toolUseID):null,uc=Su()&&Kn?.isLocalJSXCommand===!0,dc=uc?Kn.jsx:null,pc=(0,$.jsxs)(_i,{children:[(0,$.jsx)(vN,{isAnimating:_r,title:pr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ys}),(0,$.jsx)(zO,{onSubmit:Fo,isActive:!Kn?.isLocalJSXCommand}),(0,$.jsx)(mM,{scrollRef:vn,isActive:Su()&&(dc!=null||!vo||vo===`tool-permission`),onScroll:qr}),null,(0,$.jsx)(VO,{...Co}),(0,$.jsx)(pg,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(iv,{scrollRef:vn,overlay:lc,modal:dc,modalScrollRef:bn,dividerYRef:Ar,hidePill:!!nc,newMessageCount:Br?.count??0,onPillClick:()=>{Ir(null),Nr(vn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ov,{messages:sc,tools:Gt,commands:Jt,verbose:R,toolJSX:Kn,toolUseConfirmQueue:Xn,inProgressToolUseIDs:pi,isMessageSelectorVisible:Yi,conversationId:na,screen:Pe,streamingToolUses:en,showAllInTranscript:Ie,agentDefinitions:ae,onOpenRateLimitOptions:Bo,isLoading:W,streamingText:W&&!nc?Pi:null,isBriefOnly:!nc&&De,unseenDivider:nc?void 0:Br,scrollRef:Su()?vn:void 0,trackStickyPrompt:Su()?!0:void 0,cursor:Fr,setCursor:Ir,cursorNavRef:zr}),(0,$.jsx)(tj,{}),!x&&cc&&!dc&&(0,$.jsx)(gr,{param:{text:cc,type:`text`},addMargin:!0,verbose:R}),Kn&&!(Kn.isLocalJSXCommand&&Kn.isImmediate)&&!uc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(wj,{}),(0,$.jsx)(b,{flexGrow:1}),La&&(0,$.jsx)(Ea,{mode:Xt,spinnerTip:ue,responseLengthRef:Di,apiMetricsRef:Oi,overrideMessage:Bi,spinnerSuffix:Ss,verbose:R,loadingStartTimeRef:Mn,totalPausedMsRef:Pn,pauseStartTimeRef:Fn,overrideColor:Wi,overrideShimmerColor:qi,hasActiveTools:pi.size>0,leaderIsIdle:!W}),!La&&!W&&!En&&De&&!nc&&(0,$.jsx)(Cr,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[Su()&&(0,$.jsx)(TD,{}),Qn,Kn?.isLocalJSXCommand&&Kn.isImmediate&&!uc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),!La&&!Kn?.isLocalJSXCommand&&pe&&Ut&&Ut.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(fc,{tasks:Ut,isStandalone:!0})}),vo===`sandbox-permission`&&(0,$.jsx)(hA,{hostPattern:er[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=er[0];if(!r)return;let i=r.hostPattern.host;nr(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=ar.current.get(i);if(a){for(let e of a)e();ar.current.delete(i)}}},er[0].hostPattern.host),vo===`prompt`&&(0,$.jsx)(pC,{title:rr[0].title,toolInputSummary:rr[0].toolInputSummary,request:rr[0].request,onRespond:e=>{let t=rr[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),ir(([,...e])=>e))},onAbort:()=>{let e=rr[0];e&&(e.reject(Error(`Prompt cancelled by user`)),ir(([,...e])=>e))}},rr[0].request.prompt),vo===`elicitation`&&(0,$.jsx)(uC,{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)),vo===`cost`&&(0,$.jsx)(ey,{onDone:()=>{ta(!1),fa(!0),Vf(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),vo===`idle-return`&&aa&&(0,$.jsx)(ty,{idleMinutes:aa.idleMinutes,totalInputTokens:ct(),onDone:async e=>{let t=aa;if(oa(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:wr.current.length,totalInputTokens:ct()}),e===`dismiss`){si(t.input);return}if(e===`never`&&Vf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-CSpwF3Ha.js`);await e({setMessages:K,readFileState:$a.current,discoveredSkillNames:no.current,loadedNestedMemoryPaths:ro.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:ra}),dr.current=!1,cr(void 0),eo.current.clear(),to.current=0}sa.current=!0,zo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),vo===`ide-onboarding`&&(0,$.jsx)(Oa,{onDone:()=>wt(!1),installationStatus:yt}),process.env.USER_TYPE===`ant`&&vo===`model-switch`&&sN&&(0,$.jsx)(sN,{onDone:(e,t)=>{Dt(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&vo===`undercover-callout`&&lN&&(0,$.jsx)(lN,{onDone:()=>Gn(!1)}),vo===`effort-callout`&&(0,$.jsx)(Tk,{model:Se,onDone:e=>{kt(!1),e!==`dismiss`&&U(t=>({...t,effortValue:e}))}}),vo===`remote-callout`&&(0,$.jsx)(o_,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),uo,vo===`plugin-hint`&&zt&&(0,$.jsx)(UA,{pluginName:zt.pluginName,pluginDescription:zt.pluginDescription,marketplaceName:zt.marketplaceName,sourceCommand:zt.sourceCommand,onResponse:Bt}),vo===`search-extra-tools-hint`&&Vt.visible&&(0,$.jsx)(GA,{tools:Vt.tools,onSelect:Vt.handleSelect,onDismiss:Vt.handleDismiss}),vo===`lsp-recommendation`&&Lt&&(0,$.jsx)(BA,{pluginName:Lt.pluginName,pluginDescription:Lt.pluginDescription,fileExtension:Lt.fileExtension,onResponse:Rt}),vo===`desktop-upsell`&&(0,$.jsx)(bv,{onDone:()=>Pt(!1)}),vo===`ultraplan-choice`&&me&&(0,$.jsx)(Rj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:K,readFileState:$a.current,getAppState:()=>be.getState(),setConversationId:ra}),vo===`ultraplan-launch`&&he&&(0,$.jsx)(Vj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,Ic(Nn(`ultraplan`,n))]);let r=e=>K(t=>[...t,Ic(`<local-command-stdout>${jo(e)}</local-command-stdout>`)]);wu({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:vr().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!Sn.isActive){r(e);return}let t=Sn.subscribe(()=>{Sn.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),Ia(),!Kn?.shouldHidePromptInput&&!vo&&!po&&!x&&!Fr&&(0,$.jsxs)($.Fragment,{children:[so&&(0,$.jsx)(bj,{onRun:Io,onCancel:Lo,reason:Cj(so)}),Ga.state===`closed`?Ja.state===`closed`?(0,$.jsx)(Yk,{state:Wa.state,lastResponse:Wa.lastResponse,handleSelect:Wa.handleSelect,handleTranscriptSelect:Wa.handleTranscriptSelect,inputValue:ei,setInputValue:si,onRequestFeedback:lo.current?void 0:Ro}):(0,$.jsx)(Yk,{state:Ja.state,lastResponse:Ja.lastResponse,handleSelect:Ja.handleSelect,handleTranscriptSelect:Ja.handleTranscriptSelect,inputValue:ei,setInputValue:si,onRequestFeedback:Ro,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(Yk,{state:Ga.state,lastResponse:Ga.lastResponse,handleSelect:Ga.handleSelect,inputValue:ei,setInputValue:si,onRequestFeedback:Ro}),Ya.state!==`closed`&&(0,$.jsx)(Yk,{state:Ya.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ya.handleTranscriptSelect,inputValue:ei,setInputValue:si}),Ha.suggestion&&(0,$.jsx)(DO,{isOpen:Ha.isOpen,skillName:Ha.suggestion.skillName,updates:Ha.suggestion.updates,handleSelect:Ha.handleSelect,inputValue:ei,setInputValue:si}),Ua&&(0,$.jsx)(Tj,{}),(0,$.jsx)(WD,{debug:n,ideSelection:at,hasSuppressedDialogs:!!yo,isLocalJSXCommandActive:hr,getToolUseContext:Oo,toolPermissionContext:L,setToolPermissionContext:Eo,apiKeyStatus:ao,commands:Jt,agents:ae.activeAgents,isLoading:W,onExit:Vo,verbose:R,messages:G,onAutoUpdaterResult:Un,autoUpdaterResult:Hn,input:ei,onInputChange:si,mode:ci,onModeChange:li,stashedPrompt:ui,setStashedPrompt:di,submitCount:Ti,onShowMessageSelector:Uo,onMessageActionsEnter:void 0,mcpClients:et,pastedContents:Si,setPastedContents:Ci,vimMode:pa,setVimMode:ma,showBashesDialog:ha,setShowBashesDialog:ga,onSubmit:Fo,isSearchingHistory:_a,setIsSearchingHistory:va,helpOpen:ba,setHelpOpen:xa,insertTextRef:ai}),(0,$.jsx)(Sk,{onBackgroundSession:ko,isLoading:W}),(0,$.jsx)(gk,{})]}),Fr&&(0,$.jsx)(jd,{cursor:Fr}),vo===`message-selector`&&(0,$.jsx)(Tg,{messages:G,preselectedMessage:Zi,onPreRestore:xo,onRestoreCode:async e=>{await Ri(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=It(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,kd(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=vr(),o=Oo(r,[],a,Se),s=o.getAppState(),c=await Dl(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=Ho({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([Mt(),ll()]),f=await fn(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(Su()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):K(h),QM?.setContextBlocked(!1),ra(Bv()),ys(o.options.querySource),n===`from`){let t=ya(e);t&&(si(t.text),li(t.mode))}let g=Nt(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Yo,onClose:()=>{Xi(!1),Qi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Pj,{})]})})})},ms)]});return Su()?(0,$.jsx)(_e,{mouseTracking:Hr(),children:pc}):pc}export{xN as t};
142
+ `)},t=()=>{bs(e=>e+1)};return fs?.on(`suspend`,e),fs?.on(`resume`,t),()=>{fs?.off(`suspend`,e),fs?.off(`resume`,t)}},[fs]);let Ss=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||G.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=If(G,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${Ap(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[G,W]),Cs=(0,Q.useCallback)(()=>{$r({messagesLength:G.length,streamingToolUsesLength:en.length})},[G.length,en.length]),ws=(0,Q.useCallback)(()=>{$r(null)},[]),Ts=Su()&&!P,Es=(0,Q.useRef)(null),[Ds,Os]=(0,Q.useState)(!1),[ks,js]=(0,Q.useState)(``),[Ms,Ns]=(0,Q.useState)(0),[Ps,Fs]=(0,Q.useState)(0),Is=(0,Q.useCallback)((e,t)=>{Ns(e),Fs(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Es.current?.setAnchor(),Os(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Ms>0){let t=r===`n`?Es.current?.nextMatch:Es.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&Ts&&!Ds&&!Be});let{setQuery:Rs,scanElement:Vs,setPositions:Hs}=fe(),Us=de().columns,Gs=Q.useRef(Us);Q.useEffect(()=>{Gs.current!==Us&&(Gs.current=Us,(ks||Ds)&&(Os(!1),js(``),Ns(0),Fs(0),Es.current?.disarmSearch(),Rs(``)))},[Us,ks,Ds,Rs]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ws(),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 ${Yr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await $v(Yr,Gt,e)).replace(/[ \t]+$/gm,``),r=Nv(Ov(),`cc-transcript-${Date.now()}.txt`);await Uv(r,n);let i=Xg(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`&&Ts&&!Ds});let qs=Pe===`transcript`&&Ts;(0,Q.useEffect)(()=>{qs||(js(``),Ns(0),Fs(0),Os(!1),Ge.current++,clearTimeout(Ke.current),Ve(!1),We(``))},[qs]),(0,Q.useEffect)(()=>{Rs(qs?ks:``),qs||Hs(null)},[qs,ks,Rs,Hs]);let Ys={screen:Pe,setScreen:Fe,showAllInTranscript:Ie,setShowAllInTranscript:Re,messageCount:G.length,onEnterTranscript:Cs,onExitTranscript:ws,virtualScrollActive:Ts,searchBarOpen:Ds},Xs=Qr?Yr.slice(0,Qr.messagesLength):Yr,Qs=Qr?en.slice(0,Qr.streamingToolUsesLength):en;HO({onOpenBackgroundTasks:hr?void 0:()=>ga(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let $s=ge?B[ge]:void 0,nc=$s&&sl($s)?$s:void 0,rc=Mi||!W,ic=nc?.messages,ac=(0,Q.useMemo)(()=>{if(!nc)return;let e=ic??[];if(!sl(nc)||nc.agentType!==`fork`||!nc.prompt)return e;let t=nc.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(bN))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=>!bN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Ba({content:nc.prompt,timestamp:new Date(nc.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[nc,ic]),sc=nc?ac??[]:rc?G:Yr;if(Pe===`transcript`){let e=Su()&&!P&&!Be?vn:void 0,t=(0,$.jsx)(ov,{messages:Xs,tools:Gt,commands:Jt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:pi,isMessageSelectorVisible:!1,conversationId:na,screen:Pe,agentDefinitions:ae,streamingToolUses:Qs,showAllInTranscript:Ie,onOpenRateLimitOptions:Bo,isLoading:W,hidePastThinking:!0,streamingThinking:nn,scrollRef:e,jumpRef:Es,onSearchMatchesChange:Is,scanElement:Vs,setPositions:Hs,disableRenderCap:Be}),n=Kn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),r=(0,$.jsxs)(_i,{children:[(0,$.jsx)(vN,{isAnimating:_r,title:pr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ys}),(0,$.jsx)(zO,{onSubmit:Fo,isActive:!Kn?.isLocalJSXCommand}),e?(0,$.jsx)(mM,{scrollRef:vn,isActive:vo!==`ultraplan-choice`,isModal:!Ds,onScroll:()=>Es.current?.disarmSearch()}):null,(0,$.jsx)(VO,{...Co}),e?(0,$.jsx)(iv,{scrollRef:vn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{})]}),bottom:Ds?(0,$.jsx)(mN,{jumpRef:Es,initialQuery:``,count:Ms,current:Ps,onClose:e=>{js(Ms>0?e:``),Os(!1),e||(Ns(0),Fs(0),Es.current?.setSearchQuery(``))},onCancel:()=>{Os(!1),Es.current?.setSearchQuery(``),Es.current?.setSearchQuery(ks),Rs(ks)},setHighlight:Rs}):(0,$.jsx)(pN,{showAllInTranscript:Ie,virtualScroll:!0,status:He||void 0,searchBadge:ks&&Ms>0?{current:Ps,count:Ms}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{}),(0,$.jsx)(pN,{showAllInTranscript:Ie,virtualScroll:!1,suppressShowAll:Be,status:He||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:Hr(),children:r}):r}let cc=En&&!nc&&sc.length<=On.current?En:void 0,lc=vo===`tool-permission`?(0,$.jsx)(US,{onDone:()=>Zn(([e,...t])=>t),onReject:So,toolUseConfirm:Xn[0],toolUseContext:Oo(G,G,an??vr(),Se),verbose:R,setStickyFooter:Su()?$n:void 0},Xn[0]?.toolUseID):null,uc=Su()&&Kn?.isLocalJSXCommand===!0,dc=uc?Kn.jsx:null,pc=(0,$.jsxs)(_i,{children:[(0,$.jsx)(vN,{isAnimating:_r,title:pr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ys}),(0,$.jsx)(zO,{onSubmit:Fo,isActive:!Kn?.isLocalJSXCommand}),(0,$.jsx)(mM,{scrollRef:vn,isActive:Su()&&(dc!=null||!vo||vo===`tool-permission`),onScroll:qr}),null,(0,$.jsx)(VO,{...Co}),(0,$.jsx)(pg,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(iv,{scrollRef:vn,overlay:lc,modal:dc,modalScrollRef:bn,dividerYRef:Ar,hidePill:!!nc,newMessageCount:Br?.count??0,onPillClick:()=>{Ir(null),Nr(vn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ov,{messages:sc,tools:Gt,commands:Jt,verbose:R,toolJSX:Kn,toolUseConfirmQueue:Xn,inProgressToolUseIDs:pi,isMessageSelectorVisible:Yi,conversationId:na,screen:Pe,streamingToolUses:en,showAllInTranscript:Ie,agentDefinitions:ae,onOpenRateLimitOptions:Bo,isLoading:W,streamingText:W&&!nc?Pi:null,isBriefOnly:!nc&&De,unseenDivider:nc?void 0:Br,scrollRef:Su()?vn:void 0,trackStickyPrompt:Su()?!0:void 0,cursor:Fr,setCursor:Ir,cursorNavRef:zr}),(0,$.jsx)(tj,{}),!x&&cc&&!dc&&(0,$.jsx)(gr,{param:{text:cc,type:`text`},addMargin:!0,verbose:R}),Kn&&!(Kn.isLocalJSXCommand&&Kn.isImmediate)&&!uc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(wj,{}),(0,$.jsx)(b,{flexGrow:1}),La&&(0,$.jsx)(Ea,{mode:Xt,spinnerTip:ue,responseLengthRef:Di,apiMetricsRef:Oi,overrideMessage:Bi,spinnerSuffix:Ss,verbose:R,loadingStartTimeRef:Mn,totalPausedMsRef:Pn,pauseStartTimeRef:Fn,overrideColor:Wi,overrideShimmerColor:qi,hasActiveTools:pi.size>0,leaderIsIdle:!W}),!La&&!W&&!En&&De&&!nc&&(0,$.jsx)(Cr,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[Su()&&(0,$.jsx)(TD,{}),Qn,Kn?.isLocalJSXCommand&&Kn.isImmediate&&!uc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Kn.jsx}),!La&&!Kn?.isLocalJSXCommand&&pe&&Ut&&Ut.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(fc,{tasks:Ut,isStandalone:!0})}),vo===`sandbox-permission`&&(0,$.jsx)(hA,{hostPattern:er[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=er[0];if(!r)return;let i=r.hostPattern.host;nr(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=ar.current.get(i);if(a){for(let e of a)e();ar.current.delete(i)}}},er[0].hostPattern.host),vo===`prompt`&&(0,$.jsx)(pC,{title:rr[0].title,toolInputSummary:rr[0].toolInputSummary,request:rr[0].request,onRespond:e=>{let t=rr[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),ir(([,...e])=>e))},onAbort:()=>{let e=rr[0];e&&(e.reject(Error(`Prompt cancelled by user`)),ir(([,...e])=>e))}},rr[0].request.prompt),vo===`elicitation`&&(0,$.jsx)(uC,{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)),vo===`cost`&&(0,$.jsx)(ey,{onDone:()=>{ta(!1),fa(!0),Vf(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),vo===`idle-return`&&aa&&(0,$.jsx)(ty,{idleMinutes:aa.idleMinutes,totalInputTokens:ct(),onDone:async e=>{let t=aa;if(oa(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:wr.current.length,totalInputTokens:ct()}),e===`dismiss`){si(t.input);return}if(e===`never`&&Vf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-BWXf3un9.js`);await e({setMessages:K,readFileState:$a.current,discoveredSkillNames:no.current,loadedNestedMemoryPaths:ro.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:ra}),dr.current=!1,cr(void 0),eo.current.clear(),to.current=0}sa.current=!0,zo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),vo===`ide-onboarding`&&(0,$.jsx)(Oa,{onDone:()=>wt(!1),installationStatus:yt}),process.env.USER_TYPE===`ant`&&vo===`model-switch`&&sN&&(0,$.jsx)(sN,{onDone:(e,t)=>{Dt(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&vo===`undercover-callout`&&lN&&(0,$.jsx)(lN,{onDone:()=>Gn(!1)}),vo===`effort-callout`&&(0,$.jsx)(Tk,{model:Se,onDone:e=>{kt(!1),e!==`dismiss`&&U(t=>({...t,effortValue:e}))}}),vo===`remote-callout`&&(0,$.jsx)(o_,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),uo,vo===`plugin-hint`&&zt&&(0,$.jsx)(UA,{pluginName:zt.pluginName,pluginDescription:zt.pluginDescription,marketplaceName:zt.marketplaceName,sourceCommand:zt.sourceCommand,onResponse:Bt}),vo===`search-extra-tools-hint`&&Vt.visible&&(0,$.jsx)(GA,{tools:Vt.tools,onSelect:Vt.handleSelect,onDismiss:Vt.handleDismiss}),vo===`lsp-recommendation`&&Lt&&(0,$.jsx)(BA,{pluginName:Lt.pluginName,pluginDescription:Lt.pluginDescription,fileExtension:Lt.fileExtension,onResponse:Rt}),vo===`desktop-upsell`&&(0,$.jsx)(bv,{onDone:()=>Pt(!1)}),vo===`ultraplan-choice`&&me&&(0,$.jsx)(Rj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:K,readFileState:$a.current,getAppState:()=>be.getState(),setConversationId:ra}),vo===`ultraplan-launch`&&he&&(0,$.jsx)(Vj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,Ic(Nn(`ultraplan`,n))]);let r=e=>K(t=>[...t,Ic(`<local-command-stdout>${jo(e)}</local-command-stdout>`)]);wu({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:vr().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!Sn.isActive){r(e);return}let t=Sn.subscribe(()=>{Sn.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),Ia(),!Kn?.shouldHidePromptInput&&!vo&&!po&&!x&&!Fr&&(0,$.jsxs)($.Fragment,{children:[so&&(0,$.jsx)(bj,{onRun:Io,onCancel:Lo,reason:Cj(so)}),Ga.state===`closed`?Ja.state===`closed`?(0,$.jsx)(Yk,{state:Wa.state,lastResponse:Wa.lastResponse,handleSelect:Wa.handleSelect,handleTranscriptSelect:Wa.handleTranscriptSelect,inputValue:ei,setInputValue:si,onRequestFeedback:lo.current?void 0:Ro}):(0,$.jsx)(Yk,{state:Ja.state,lastResponse:Ja.lastResponse,handleSelect:Ja.handleSelect,handleTranscriptSelect:Ja.handleTranscriptSelect,inputValue:ei,setInputValue:si,onRequestFeedback:Ro,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(Yk,{state:Ga.state,lastResponse:Ga.lastResponse,handleSelect:Ga.handleSelect,inputValue:ei,setInputValue:si,onRequestFeedback:Ro}),Ya.state!==`closed`&&(0,$.jsx)(Yk,{state:Ya.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ya.handleTranscriptSelect,inputValue:ei,setInputValue:si}),Ha.suggestion&&(0,$.jsx)(DO,{isOpen:Ha.isOpen,skillName:Ha.suggestion.skillName,updates:Ha.suggestion.updates,handleSelect:Ha.handleSelect,inputValue:ei,setInputValue:si}),Ua&&(0,$.jsx)(Tj,{}),(0,$.jsx)(WD,{debug:n,ideSelection:at,hasSuppressedDialogs:!!yo,isLocalJSXCommandActive:hr,getToolUseContext:Oo,toolPermissionContext:L,setToolPermissionContext:Eo,apiKeyStatus:ao,commands:Jt,agents:ae.activeAgents,isLoading:W,onExit:Vo,verbose:R,messages:G,onAutoUpdaterResult:Un,autoUpdaterResult:Hn,input:ei,onInputChange:si,mode:ci,onModeChange:li,stashedPrompt:ui,setStashedPrompt:di,submitCount:Ti,onShowMessageSelector:Uo,onMessageActionsEnter:void 0,mcpClients:et,pastedContents:Si,setPastedContents:Ci,vimMode:pa,setVimMode:ma,showBashesDialog:ha,setShowBashesDialog:ga,onSubmit:Fo,isSearchingHistory:_a,setIsSearchingHistory:va,helpOpen:ba,setHelpOpen:xa,insertTextRef:ai}),(0,$.jsx)(Sk,{onBackgroundSession:ko,isLoading:W}),(0,$.jsx)(gk,{})]}),Fr&&(0,$.jsx)(jd,{cursor:Fr}),vo===`message-selector`&&(0,$.jsx)(Tg,{messages:G,preselectedMessage:Zi,onPreRestore:xo,onRestoreCode:async e=>{await Ri(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=It(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,kd(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=vr(),o=Oo(r,[],a,Se),s=o.getAppState(),c=await Dl(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=Ho({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([Mt(),ll()]),f=await fn(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(Su()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):K(h),QM?.setContextBlocked(!1),ra(Bv()),ys(o.options.querySource),n===`from`){let t=ya(e);t&&(si(t.text),li(t.mode))}let g=Nt(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Yo,onClose:()=>{Xi(!1),Qi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Pj,{})]})})})},ms)]});return Su()?(0,$.jsx)(_e,{mouseTracking:Hr(),children:pc}):pc}export{xN as t};