@readmagic/workmate 0.0.20 → 0.0.21

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 (420) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DgAxYgBY.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-DGMRVexR.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-Dp6CwZyI.js +1 -0
  4. package/dist/chunks/App-VWyPd524.js +1 -0
  5. package/dist/chunks/ApproveApiKey-Bolw0sPs.js +1 -0
  6. package/dist/chunks/ApproveApiKey-CyNPMd6g.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-DxagIOOw.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-OS2S66zQ.js +1 -0
  9. package/dist/chunks/{DiffDialog-DCpchgp5.js → DiffDialog-CMtml9iw.js} +3 -3
  10. package/dist/chunks/Doctor-Bk9P37mU.js +1 -0
  11. package/dist/chunks/Doctor-D9F3tKsr.js +3 -0
  12. package/dist/chunks/ExitFlow-DhRv5JPj.js +2 -0
  13. package/dist/chunks/{Grove-Dd6rjs5P.js → Grove-Bbh8PpH0.js} +1 -1
  14. package/dist/chunks/{HybridTransport-CJVkWa2u.js → HybridTransport-P1vEUwhv.js} +1 -1
  15. package/dist/chunks/InvalidConfigDialog-xAYpE-20.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-CXFSISy3.js +1 -0
  17. package/dist/chunks/MCPConnectionManager-CoId-C__.js +1 -0
  18. package/dist/chunks/MCPToolListView-BQkQ-hyF.js +1 -0
  19. package/dist/chunks/McpParsingWarnings-6ENzOklf.js +1 -0
  20. package/dist/chunks/MessageSelector-BvRVrfg6.js +3 -0
  21. package/dist/chunks/Messages-Cykztq1O.js +10 -0
  22. package/dist/chunks/Onboarding-CfeRwPNQ.js +1 -0
  23. package/dist/chunks/PermissionDialog-BaibiQae.js +1 -0
  24. package/dist/chunks/PressEnterToContinue-DZc_s_pE.js +1 -0
  25. package/dist/chunks/PromptInputFooterSuggestions-Blzgj5yW.js +1 -0
  26. package/dist/chunks/PromptInputHelpMenu-Ckp0k8E3.js +1 -0
  27. package/dist/chunks/QueryEngine-DduzztIG.js +1 -0
  28. package/dist/chunks/REPL-B8e5UU3H.js +128 -0
  29. package/dist/chunks/REPL-C4mbOhyL.js +1 -0
  30. package/dist/chunks/{RemoteSessionManager-BfsOv4K6.js → RemoteSessionManager-BPESC6Wu.js} +2 -2
  31. package/dist/chunks/ResumeConversation-DG1sLryB.js +1 -0
  32. package/dist/chunks/{SSETransport-B3K6eH9I.js → SSETransport-CDNP2PlK.js} +1 -1
  33. package/dist/chunks/{SearchBox-CwwV0W-w.js → SearchBox-C9xxQzh1.js} +1 -1
  34. package/dist/chunks/SearchExtraToolsTool-vK2PP628.js +1 -0
  35. package/dist/chunks/Settings-B7n_dfP-.js +2 -0
  36. package/dist/chunks/TeleportProgress-QL3ibQfK.js +1 -0
  37. package/dist/chunks/TeleportRepoMismatchDialog-f-xl7biD.js +1 -0
  38. package/dist/chunks/TeleportResumeWrapper-DzVcrFuP.js +1 -0
  39. package/dist/chunks/ThemePicker-CIFKZza0.js +1 -0
  40. package/dist/chunks/TrustDialog-C0HEwZPk.js +1 -0
  41. package/dist/chunks/{ValidationErrorsList-BfZ5gcIv.js → ValidationErrorsList-2QWIs_6h.js} +1 -1
  42. package/dist/chunks/add-dir-DmEhPnvj.js +1 -0
  43. package/dist/chunks/{agentDisplay-BM4QG_RX.js → agentDisplay-1Y-N-gqz.js} +1 -1
  44. package/dist/chunks/{agents-BbDBN5l9.js → agents-CvW8XjoJ.js} +1 -1
  45. package/dist/chunks/agents-D96ng5I9.js +101 -0
  46. package/dist/chunks/allErrors-CT2dbBF3.js +1 -0
  47. package/dist/chunks/{api-DyUWfg3a.js → api-DTyrmy1O.js} +1 -1
  48. package/dist/chunks/api-DumFOErN.js +1 -0
  49. package/dist/chunks/{auth-0rn1U4Eq.js → auth-CZ4EsFWF.js} +1 -1
  50. package/dist/chunks/auth-QvonHoG9.js +1 -0
  51. package/dist/chunks/auth-jV5THRH8.js +1 -0
  52. package/dist/chunks/backgroundHousekeeping-C72oPgfD.js +17 -0
  53. package/dist/chunks/backgroundHousekeeping-D9PScHES.js +1 -0
  54. package/dist/chunks/{banner-BkUdig-T.js → banner-ChT5Ri7Q.js} +1 -1
  55. package/dist/chunks/{bg-tGgpwpYx.js → bg-qG2osBbP.js} +2 -2
  56. package/dist/chunks/{branch-CQ38cx5n.js → branch-K8X6jx0i.js} +1 -1
  57. package/dist/chunks/{break-cache-CcwOjTKt.js → break-cache-BZ_UMtEL.js} +1 -1
  58. package/dist/chunks/{bridgeConfig-C5L-7KaP.js → bridgeConfig-C-bI-slm.js} +1 -1
  59. package/dist/chunks/bridgeConfig-_xpxhGB5.js +1 -0
  60. package/dist/chunks/{bridgeMessaging-DVC3qj-C.js → bridgeMessaging-DSJlYarJ.js} +1 -1
  61. package/dist/chunks/{bridgeStatusUtil-Cex6VowM.js → bridgeStatusUtil-DaEq5c69.js} +1 -1
  62. package/dist/chunks/btw-BNs5OX7x.js +1 -0
  63. package/dist/chunks/caches-CC5NHwAz.js +1 -0
  64. package/dist/chunks/caches-nHxJWXgO.js +1 -0
  65. package/dist/chunks/{ccrClient-DO563xlf.js → ccrClient-JnhF5b3z.js} +1 -1
  66. package/dist/chunks/{clear-DmqQBNKg.js → clear-D2KRoibg.js} +1 -1
  67. package/dist/chunks/client-BtTkq0YS.js +1 -0
  68. package/dist/chunks/commands-C_rYjyQZ.js +1 -0
  69. package/dist/chunks/compact-Cqd6vKpn.js +2 -0
  70. package/dist/chunks/config-Be0BkAAr.js +1 -0
  71. package/dist/chunks/{config-DRy1I12M.js → config-DUTgj3js.js} +1 -1
  72. package/dist/chunks/{config-e0Goy478.js → config-DoEDgAfv.js} +1 -1
  73. package/dist/chunks/context-Db9tH1VF.js +1 -0
  74. package/dist/chunks/{context-noninteractive-BzDVMnWC.js → context-noninteractive-CacA9VlT.js} +2 -2
  75. package/dist/chunks/context-noninteractive-D9tJYwi7.js +1 -0
  76. package/dist/chunks/conversation-DWfE4KGH.js +1 -0
  77. package/dist/chunks/conversation-Tvo4EDpQ.js +1 -0
  78. package/dist/chunks/convert-legacy-node-http-options-BZnGSjx2.js +1 -0
  79. package/dist/chunks/{createSSHSession-LVGVXHXL.js → createSSHSession-BQ83MMtr.js} +1 -1
  80. package/dist/chunks/createSession-CqHnHhCR.js +1 -0
  81. package/dist/chunks/{createSession-Dgwxk1WA.js → createSession-DqTtBycR.js} +1 -1
  82. package/dist/chunks/crossProjectResume-DIXtiODF.js +40 -0
  83. package/dist/chunks/{datadog-Bc6wkPne.js → datadog-BuElf2EQ.js} +1 -1
  84. package/dist/chunks/detectRepository-DUJBh5s2.js +1 -0
  85. package/dist/chunks/{detectRepository-CDOJ-M7h.js → detectRepository-pRAVv8SH.js} +1 -1
  86. package/dist/chunks/{diff-DIg66U_d.js → diff-yA6v_dpP.js} +1 -1
  87. package/dist/chunks/{directoryCompletion-BDGcGDuv.js → directoryCompletion-CuA3_YIT.js} +1 -1
  88. package/dist/chunks/doctor-eNAm6OiS.js +1 -0
  89. package/dist/chunks/{entry-B-Y-AYeK.js → entry-DidpiR-D.js} +5 -5
  90. package/dist/chunks/esm-0CwQE5CJ.js +10 -0
  91. package/dist/chunks/esm-BCUC71kt.js +1 -0
  92. package/dist/chunks/esm-BCmY8V0C.js +1 -0
  93. package/dist/chunks/esm-BUJtY-Rb.js +1 -0
  94. package/dist/chunks/esm-BadZVa27.js +1 -0
  95. package/dist/chunks/esm-BbMeEYcz.js +1 -0
  96. package/dist/chunks/esm-sVMjGuep.js +1 -0
  97. package/dist/chunks/execFileNoThrow-B_KRY4cT.js +34 -0
  98. package/dist/chunks/exit-DywUeiYd.js +1 -0
  99. package/dist/chunks/extraUsage-DiAirtuk.js +1 -0
  100. package/dist/chunks/extractMemories-_xiTnX95.js +1 -0
  101. package/dist/chunks/fast-DCXZACT9.js +1 -0
  102. package/dist/chunks/fast-Qo4WVqiW.js +1 -0
  103. package/dist/chunks/{fetchModelList-Dy-x4h3G.js → fetchModelList-fQDsmR3E.js} +1 -1
  104. package/dist/chunks/fetchModelList-woVzIVde.js +1 -0
  105. package/dist/chunks/{fileSuggestions-CFkJktgc.js → fileSuggestions-CRx1D6uk.js} +3 -3
  106. package/dist/chunks/firstPartyEventLogger-B261Wksn.js +3 -0
  107. package/dist/chunks/firstPartyEventLogger-DtFTeHy-.js +1 -0
  108. package/dist/chunks/{flushGate-BjKW7PFC.js → flushGate-BA8dSr0i.js} +1 -1
  109. package/dist/chunks/fpsMetrics-wxj9GAsd.js +1 -0
  110. package/dist/chunks/{gemini-NnmxBoEp.js → gemini-BXAyy1JN.js} +1 -1
  111. package/dist/chunks/generateSessionName-Cwmk2N3F.js +1 -0
  112. package/dist/chunks/{genericProcessUtils-6E7fB1dI.js → genericProcessUtils-Cnyun_Wr.js} +3 -3
  113. package/dist/chunks/{git-By_J4XJL.js → git-Wid-XppW.js} +1 -1
  114. package/dist/chunks/git-hO-TMvXc.js +1 -0
  115. package/dist/chunks/{githubRepoPathMapping-CzgPGOHQ.js → githubRepoPathMapping-OV8U1VFK.js} +1 -1
  116. package/dist/chunks/goal-C9clrwEH.js +3 -0
  117. package/dist/chunks/{grok-BxZ4vTDw.js → grok-CjeCecsZ.js} +1 -1
  118. package/dist/chunks/{grove-CYE1Cfcz.js → grove-DqTnK9nn.js} +2 -2
  119. package/dist/chunks/help-Bb6LdzXK.js +1 -0
  120. package/dist/chunks/{hooks-7iyENdDG.js → hooks-BDgToO1Z.js} +2 -2
  121. package/dist/chunks/hooks-BX2s7aoL.js +1 -0
  122. package/dist/chunks/{initReplBridge-BEZW5PEY.js → initReplBridge-D7cuY_os.js} +1 -1
  123. package/dist/chunks/install-eCA8UACi.js +1 -0
  124. package/dist/chunks/{instrumentation-2HH15DPu.js → instrumentation-BaRKojJh.js} +6 -6
  125. package/dist/chunks/{job-CXz7SLZp.js → job-DYMfSglZ.js} +1 -1
  126. package/dist/chunks/{jwtUtils-C_LG1txt.js → jwtUtils-JE2okZ70.js} +1 -1
  127. package/dist/chunks/keybindings-iBqc1KHL.js +1 -0
  128. package/dist/chunks/launchLocalMemory-IZPGEzMk.js +3 -0
  129. package/dist/chunks/launchOnboarding-BeNf51Ig.js +8 -0
  130. package/dist/chunks/loadAgentsDir-Bpke9CtB.js +1 -0
  131. package/dist/chunks/{loadAgentsDir-DaNpxaO-.js → loadAgentsDir-C96o6gCj.js} +576 -576
  132. package/dist/chunks/loadPluginHooks-0nGlugZ4.js +1 -0
  133. package/dist/chunks/{localSearch-C2SZ9bGW.js → localSearch-DLz5IGGu.js} +1 -1
  134. package/dist/chunks/localSearch-dodgnjGn.js +1 -0
  135. package/dist/chunks/logoUtils-Cg_6QV1Z.js +1 -0
  136. package/dist/chunks/{magicDocs-CrTwULyJ.js → magicDocs-DmPNMnNY.js} +2 -2
  137. package/dist/chunks/{main-Blm02_Js.js → main-7ssnA9Yb.js} +2 -2
  138. package/dist/chunks/{main-bJXadFi0.js → main-BEv6MqMX.js} +34 -34
  139. package/dist/chunks/{managedEnv-CUsdYhAI.js → managedEnv-CHYvwXBH.js} +1 -1
  140. package/dist/chunks/managedEnv-CbjOQmEe.js +1 -0
  141. package/dist/chunks/mappers-D8VLUZ2N.js +1 -0
  142. package/dist/chunks/mcp-BUn3yqsT.js +1 -0
  143. package/dist/chunks/mcp-BskLq9iP.js +2 -0
  144. package/dist/chunks/mcp-C-0DMaXx.js +6 -0
  145. package/dist/chunks/memory-vDkJM58W.js +1 -0
  146. package/dist/chunks/modalContext-DDZdU1J8.js +1 -0
  147. package/dist/chunks/mode-Dbh21H2Y.js +2 -0
  148. package/dist/chunks/model-BaMclMXn.js +1 -0
  149. package/dist/chunks/model-atn3_JBi.js +1 -0
  150. package/dist/chunks/model-vS1Iewyq.js +1 -0
  151. package/dist/chunks/{modelOptions-B3nis9cC.js → modelOptions-Cw1ThINb.js} +1 -1
  152. package/dist/chunks/nativeInstaller-CfZ5uNTh.js +1 -0
  153. package/dist/chunks/omit-B7eQ9q0x.js +1 -0
  154. package/dist/chunks/{onChangeAppState-vKml_lit.js → onChangeAppState-kEAt8nxV.js} +1 -1
  155. package/dist/chunks/{openai-DdupGVdC.js → openai-wh8AX5iz.js} +3 -3
  156. package/dist/chunks/panel-Cm23FDVt.js +1 -0
  157. package/dist/chunks/{partition-BivH9MBJ.js → partition-CENvOfiS.js} +1 -1
  158. package/dist/chunks/permissions-ChuIx-d4.js +3 -0
  159. package/dist/chunks/{pidLock-DiKz5Tza.js → pidLock-C1hmh3YQ.js} +2 -2
  160. package/dist/chunks/plan-s228H7IU.js +1 -0
  161. package/dist/chunks/plugin-DVBEWwMP.js +17 -0
  162. package/dist/chunks/{pluginAutoupdate-C2xTKLR_.js → pluginAutoupdate-aLXhSUVD.js} +1 -1
  163. package/dist/chunks/pluginBlocklist-BprCv0En.js +1 -0
  164. package/dist/chunks/pluginCliCommands-WzzqR1Sr.js +1 -0
  165. package/dist/chunks/{pluginFlagging-DRA0m76J.js → pluginFlagging-BSLuTk3M.js} +1 -1
  166. package/dist/chunks/pluginOperations-Ca9Lup5G.js +2 -0
  167. package/dist/chunks/pluginStartupCheck-DdtxcNwH.js +1 -0
  168. package/dist/chunks/{pluginStartupCheck-BF1N4Lih.js → pluginStartupCheck-xQbHZ5gf.js} +1 -1
  169. package/dist/chunks/plugins-DdIaXpNb.js +4 -0
  170. package/dist/chunks/{poorMode-CKQfWf3S.js → poorMode-Bt_A2arj.js} +1 -1
  171. package/dist/chunks/poorMode-ZIq2oz7q.js +1 -0
  172. package/dist/chunks/print-vxrRE1O2.js +14 -0
  173. package/dist/chunks/processBashCommand-ISucgwpi.js +1 -0
  174. package/dist/chunks/processSlashCommand-BnpXO_fI.js +5 -0
  175. package/dist/chunks/prompt-2AA5W7EH.js +1 -0
  176. package/dist/chunks/prompt-AXiS2LoO.js +1 -0
  177. package/dist/chunks/{prompt-8u06WVES.js → prompt-BNNE5tsG.js} +1 -1
  178. package/dist/chunks/promptEditor-DT6egmcb.js +4 -0
  179. package/dist/chunks/{protocolHandler-DzHVaPl3.js → protocolHandler-DukQ6b4Q.js} +1 -1
  180. package/dist/chunks/{reconciler-RIKmaPg7.js → reconciler-D3zyJCnV.js} +1 -1
  181. package/dist/chunks/refresh-BSG0t4cf.js +1 -0
  182. package/dist/chunks/{registerProtocol-C0IlPEoa.js → registerProtocol-BOEYaX-X.js} +1 -1
  183. package/dist/chunks/{reload-plugins-DC-tbXVv.js → reload-plugins-BFMRhbv8.js} +1 -1
  184. package/dist/chunks/{remoteBridgeCore-NGTnhQgw.js → remoteBridgeCore-D5OwvmAz.js} +1 -1
  185. package/dist/chunks/{remoteManagedSettings-BoOYHzYP.js → remoteManagedSettings-DyGVvvcW.js} +1 -1
  186. package/dist/chunks/rename-BrEwj3Xw.js +1 -0
  187. package/dist/chunks/resume-DR5JbICs.js +2 -0
  188. package/dist/chunks/{ripgrep-C3jtZL7k.js → ripgrep-Dt4a91S5.js} +1 -1
  189. package/dist/chunks/ripgrep-KTOU5s9J.js +1 -0
  190. package/dist/chunks/{runtimeObserver-L6041elO.js → runtimeObserver-CsZw5XBt.js} +2 -2
  191. package/dist/chunks/{runtimeObserver-DzesbvgI.js → runtimeObserver-DS1PK6We.js} +1 -1
  192. package/dist/chunks/sandbox-adapter-BqDyWcol.js +1 -0
  193. package/dist/chunks/sandbox-toggle-B9f_0NQI.js +1 -0
  194. package/dist/chunks/searchExtraTools-2pIT2C8u.js +1 -0
  195. package/dist/chunks/session-wkRTfdo8.js +2 -0
  196. package/dist/chunks/sessionFileAccessHooks-DV22q9JO.js +1 -0
  197. package/dist/chunks/sessionObserver-BLJg0qm_.js +1 -0
  198. package/dist/chunks/{sessionObserver-0D8xFoRK.js → sessionObserver-N7fORFdL.js} +2 -2
  199. package/dist/chunks/{sessionState-CQhbGfmh.js → sessionState-8jutEorw.js} +1 -1
  200. package/dist/chunks/sessionStorage-DRV7IhZF.js +1 -0
  201. package/dist/chunks/sessionTracing-fIp8g04N.js +11 -0
  202. package/dist/chunks/{settings-3xZ0fsvE.js → settings-BowI3jp-.js} +2 -2
  203. package/dist/chunks/settings-CHn0gJCG.js +1 -0
  204. package/dist/chunks/settingsSync-DF4JgSNc.js +1 -0
  205. package/dist/chunks/setup-UiEO9i7F.js +3 -0
  206. package/dist/chunks/{shadowedRuleDetection-Cy9tsuKc.js → shadowedRuleDetection-DEo1hvGi.js} +1 -1
  207. package/dist/chunks/{sideQuestion-Ds7Elgs4.js → sideQuestion-C11KgNGL.js} +3 -3
  208. package/dist/chunks/sinks-DnLqRPEC.js +1 -0
  209. package/dist/chunks/{sinks-BXX72cbf.js → sinks-mGBiINp8.js} +1 -1
  210. package/dist/chunks/skillChangeDetector-Dc6YZXJE.js +1 -0
  211. package/dist/chunks/{skillGapStore-BxCxKPev.js → skillGapStore-H4MkUFUY.js} +2 -2
  212. package/dist/chunks/{skillLifecycle-CfyNC3sW.js → skillLifecycle-ADUTDK7D.js} +2 -2
  213. package/dist/chunks/{skillSearchPanel-CMNJFIEC.js → skillSearchPanel-PpfVDMGR.js} +2 -2
  214. package/dist/chunks/skills-DKtN17ch.js +1 -0
  215. package/dist/chunks/src-9vmGsuSI.js +1 -0
  216. package/dist/chunks/{src-CgZmCiiH.js → src-BacxF9BD.js} +2 -2
  217. package/dist/chunks/{startupProfiler-CbzxVmbv.js → startupProfiler-B90b5vuq.js} +1 -1
  218. package/dist/chunks/startupProfiler-DG2TN5R_.js +1 -0
  219. package/dist/chunks/staticRender-BVWx0IM1.js +1 -0
  220. package/dist/chunks/stats-D4LEtkrw.js +1 -0
  221. package/dist/chunks/status-0ZBx6Ls0.js +2 -0
  222. package/dist/chunks/status-BUJ4-omB.js +1 -0
  223. package/dist/chunks/{statusNoticeHelpers-CZoOse-_.js → statusNoticeHelpers-BrpQWj0l.js} +1 -1
  224. package/dist/chunks/{stringUtils-CKD8qDqx.js → stringUtils-D7oJIyY2.js} +1 -1
  225. package/dist/chunks/switcher-D7Ey5uIi.js +1 -0
  226. package/dist/chunks/{switcher-DQF5ZNal.js → switcher-DWfKi17X.js} +1 -1
  227. package/dist/chunks/{syncCache-qWJ_VfBo.js → syncCache-DUhciJLz.js} +1 -1
  228. package/dist/chunks/{tasks-C8pb6ftc.js → tasks-BwSsj2vI.js} +1 -1
  229. package/dist/chunks/teleport-DwZMevmQ.js +1 -0
  230. package/dist/chunks/{templateJobs-DJ4dcfcL.js → templateJobs-fiKuu4DK.js} +1 -1
  231. package/dist/chunks/{terminalSetup-7PdC4fV5.js → terminalSetup-Cte5a4hM.js} +1 -1
  232. package/dist/chunks/{terminalSetup-kWdZRKWq.js → terminalSetup-a7-BNS4T.js} +1 -1
  233. package/dist/chunks/theme-CAoGjf2D.js +1 -0
  234. package/dist/chunks/{tmux-CpGd0Aca.js → tmux-DA06aewY.js} +1 -1
  235. package/dist/chunks/{toolEventObserver-D2nk8ZbW.js → toolEventObserver-Cq_ZV7x9.js} +1 -1
  236. package/dist/chunks/toolPool-mdsxlKWR.js +1 -0
  237. package/dist/chunks/{trustedDevice-CB6rNzl-.js → trustedDevice-C1m--Yjw.js} +1 -1
  238. package/dist/chunks/trustedDevice-CeDIk_ln.js +1 -0
  239. package/dist/chunks/{udsClient-U7MEfYj7.js → udsClient-BcwsY0XE.js} +1 -1
  240. package/dist/chunks/useExitOnCtrlCDWithKeybindings-L5idX6Kz.js +1 -0
  241. package/dist/chunks/useMainLoopModel-VXeS2EC6.js +1 -0
  242. package/dist/chunks/useManagePlugins-CAXp5CfH.js +1 -0
  243. package/dist/chunks/useMergedTools-DYXrPTIA.js +1 -0
  244. package/dist/chunks/useSearchInput-Bxl4wGcZ.js +1 -0
  245. package/dist/chunks/useSettingsErrors-sbjsaT7k.js +1 -0
  246. package/dist/chunks/{userAgent-i-oGzf40.js → userAgent-NbKd-hN7.js} +1 -1
  247. package/dist/chunks/util-DU63xTwZ.js +1 -0
  248. package/dist/chunks/validatePlugin-DQ_9OCpP.js +1 -0
  249. package/dist/chunks/{vim-BagKUX4j.js → vim-xruiCyUd.js} +1 -1
  250. package/dist/chunks/which-B8rchd8P.js +1 -0
  251. package/dist/chunks/{workerRegistry-BjxoZ12l.js → workerRegistry-BBgquE8F.js} +2 -2
  252. package/dist/chunks/worktree-C28I8mFB.js +1 -0
  253. package/dist/cli.js +1 -1
  254. package/package.json +3 -21
  255. package/dist/chunks/AddWorkspaceDirectory-BYNvxNrD.js +0 -1
  256. package/dist/chunks/AgentsMdExternalIncludesDialog-BSSz86ER.js +0 -1
  257. package/dist/chunks/AgentsMdExternalIncludesDialog-CMEGV4Md.js +0 -1
  258. package/dist/chunks/App-W_9d1DjK.js +0 -1
  259. package/dist/chunks/ApproveApiKey-Bf1Rb8Ql.js +0 -1
  260. package/dist/chunks/ApproveApiKey-wpdvXpFr.js +0 -1
  261. package/dist/chunks/BackgroundTasksDialog-lGn1Wj1k.js +0 -2
  262. package/dist/chunks/BypassPermissionsModeDialog-CjVjyNf8.js +0 -1
  263. package/dist/chunks/Doctor-6SjW91rd.js +0 -1
  264. package/dist/chunks/Doctor-FPYTivHw.js +0 -3
  265. package/dist/chunks/ExitFlow-Dy8_1D8J.js +0 -2
  266. package/dist/chunks/InvalidConfigDialog-Bisj9ic_.js +0 -1
  267. package/dist/chunks/InvalidSettingsDialog-DyTPNRQR.js +0 -1
  268. package/dist/chunks/MCPConnectionManager-DfyoZaiu.js +0 -1
  269. package/dist/chunks/MCPToolListView-Dioupv8F.js +0 -1
  270. package/dist/chunks/McpParsingWarnings-BUlgpZAF.js +0 -1
  271. package/dist/chunks/MessageSelector-D8fylxPg.js +0 -3
  272. package/dist/chunks/Messages-BZDFMYBT.js +0 -10
  273. package/dist/chunks/Onboarding-BKLomZYo.js +0 -1
  274. package/dist/chunks/PermissionDialog-BPhvs5xH.js +0 -1
  275. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +0 -1
  276. package/dist/chunks/PromptInputFooterSuggestions-DCum89fF.js +0 -1
  277. package/dist/chunks/PromptInputHelpMenu-DG2lRqis.js +0 -1
  278. package/dist/chunks/QueryEngine-CyGHpX7M.js +0 -1
  279. package/dist/chunks/REPL-BDsz8KIx.js +0 -1
  280. package/dist/chunks/REPL-CCBNfZfs.js +0 -128
  281. package/dist/chunks/ResumeConversation-pC8NLq0F.js +0 -1
  282. package/dist/chunks/SearchExtraToolsTool-DYoxHo9T.js +0 -1
  283. package/dist/chunks/Settings-CKaGmKg2.js +0 -2
  284. package/dist/chunks/TeleportProgress-CkgSp1cs.js +0 -1
  285. package/dist/chunks/TeleportRepoMismatchDialog-DdO_rECq.js +0 -1
  286. package/dist/chunks/TeleportResumeWrapper-BeG4N-2z.js +0 -1
  287. package/dist/chunks/ThemePicker-iD9ufy99.js +0 -1
  288. package/dist/chunks/TrustDialog-qO5OdQt8.js +0 -1
  289. package/dist/chunks/add-dir-C4eSVlZ6.js +0 -1
  290. package/dist/chunks/agents-D3APE_8d.js +0 -101
  291. package/dist/chunks/allErrors-BkgB7JNK.js +0 -1
  292. package/dist/chunks/api-BHBK9axp.js +0 -1
  293. package/dist/chunks/auth-BEoTPSgC.js +0 -1
  294. package/dist/chunks/auth-BPug7U_u.js +0 -1
  295. package/dist/chunks/backgroundHousekeeping-D7xAhUaE.js +0 -1
  296. package/dist/chunks/backgroundHousekeeping-km82qEh0.js +0 -17
  297. package/dist/chunks/bridgeConfig-CJMjDoaP.js +0 -1
  298. package/dist/chunks/btw-_P96ffHR.js +0 -1
  299. package/dist/chunks/caches-DH-q8Fjf.js +0 -1
  300. package/dist/chunks/caches-Dq0pJFDP.js +0 -1
  301. package/dist/chunks/client-C19cqYQS.js +0 -1
  302. package/dist/chunks/commands-BkpqHY9F.js +0 -1
  303. package/dist/chunks/compact-DuVIvqMu.js +0 -2
  304. package/dist/chunks/config-DMP6-Ccr.js +0 -1
  305. package/dist/chunks/context-DjgMzIfe.js +0 -1
  306. package/dist/chunks/context-noninteractive-DV7bIJCm.js +0 -1
  307. package/dist/chunks/conversation-BBOE_EoE.js +0 -1
  308. package/dist/chunks/conversation-WxH5pb2z.js +0 -1
  309. package/dist/chunks/createSession-BUzna9-E.js +0 -1
  310. package/dist/chunks/crossProjectResume-6B2NYy8a.js +0 -40
  311. package/dist/chunks/detectRepository-Cv9-k6dg.js +0 -1
  312. package/dist/chunks/doctor-BhUmhHQU.js +0 -1
  313. package/dist/chunks/esm-BYnFh4pG.js +0 -1
  314. package/dist/chunks/esm-Bx6rTxIs.js +0 -1
  315. package/dist/chunks/esm-C367Cyo-.js +0 -1
  316. package/dist/chunks/esm-CXM9jqO_.js +0 -1
  317. package/dist/chunks/esm-CXczu_-W.js +0 -1
  318. package/dist/chunks/esm-CXt5K8Xt.js +0 -1
  319. package/dist/chunks/esm-Cb-L4oAk.js +0 -1
  320. package/dist/chunks/esm-CvHtYRrr.js +0 -1
  321. package/dist/chunks/esm-DhRjocaU.js +0 -1
  322. package/dist/chunks/esm-DklLYEuz.js +0 -1
  323. package/dist/chunks/esm-IYgGg4wR.js +0 -1
  324. package/dist/chunks/esm-lyfry1WB.js +0 -10
  325. package/dist/chunks/execFileNoThrow-Bmb5HEFz.js +0 -34
  326. package/dist/chunks/exit-CW2eqUrR.js +0 -1
  327. package/dist/chunks/extraUsage-CkTon7ib.js +0 -1
  328. package/dist/chunks/extractMemories-CfmbvayQ.js +0 -1
  329. package/dist/chunks/fast-ByahC7Gw.js +0 -1
  330. package/dist/chunks/fast-xtIP4u4y.js +0 -1
  331. package/dist/chunks/fetchModelList-D9aePIPW.js +0 -1
  332. package/dist/chunks/firstPartyEventLogger-Bt9iG9xk.js +0 -1
  333. package/dist/chunks/firstPartyEventLogger-DqGSujCz.js +0 -3
  334. package/dist/chunks/fpsMetrics-Dk_pnSHJ.js +0 -1
  335. package/dist/chunks/generateSessionName-EpqGW-T2.js +0 -1
  336. package/dist/chunks/git-zJCasBa6.js +0 -1
  337. package/dist/chunks/goal-DbS8yJfB.js +0 -3
  338. package/dist/chunks/help-DatnwM25.js +0 -1
  339. package/dist/chunks/hooks-DjbqtbUV.js +0 -1
  340. package/dist/chunks/install-DJukI-kL.js +0 -1
  341. package/dist/chunks/keybindings-C9l5il16.js +0 -1
  342. package/dist/chunks/launchLocalMemory-BfGenqj1.js +0 -3
  343. package/dist/chunks/launchOnboarding-DjMmXeQE.js +0 -8
  344. package/dist/chunks/loadAgentsDir-DcI-8FQF.js +0 -1
  345. package/dist/chunks/loadPluginHooks-CGgpcyEC.js +0 -1
  346. package/dist/chunks/localSearch-CTTwYTU1.js +0 -1
  347. package/dist/chunks/logoUtils-CbIqOFrX.js +0 -1
  348. package/dist/chunks/managedEnv-DXeaUDSK.js +0 -1
  349. package/dist/chunks/mappers-_B-s9fNz.js +0 -1
  350. package/dist/chunks/mcp-BbbYzWpy.js +0 -6
  351. package/dist/chunks/mcp-D91sH9a8.js +0 -1
  352. package/dist/chunks/mcp-Dx-zgUgu.js +0 -2
  353. package/dist/chunks/memory-BeL7ui9m.js +0 -1
  354. package/dist/chunks/modalContext-wY9CeN4G.js +0 -1
  355. package/dist/chunks/mode-D695kgLI.js +0 -2
  356. package/dist/chunks/model-DX0TtzqX.js +0 -1
  357. package/dist/chunks/model-Do0f476p.js +0 -1
  358. package/dist/chunks/model-DpcM8dz5.js +0 -1
  359. package/dist/chunks/nativeInstaller-CymO8TNe.js +0 -1
  360. package/dist/chunks/omit-DO61BHZu.js +0 -1
  361. package/dist/chunks/panel-CVd1dzYl.js +0 -1
  362. package/dist/chunks/permissions-C9iqR4_N.js +0 -3
  363. package/dist/chunks/plan-KDN5IGWY.js +0 -1
  364. package/dist/chunks/plugin-D0rzUb8E.js +0 -17
  365. package/dist/chunks/pluginBlocklist-xdiUmUpt.js +0 -1
  366. package/dist/chunks/pluginCliCommands-CIDDvVN7.js +0 -1
  367. package/dist/chunks/pluginOperations-BEYsarAn.js +0 -2
  368. package/dist/chunks/pluginStartupCheck-DVkI4pqo.js +0 -1
  369. package/dist/chunks/plugins-CWWU4BKs.js +0 -4
  370. package/dist/chunks/poorMode-BTIe8W_H.js +0 -1
  371. package/dist/chunks/print-B5H2xbBS.js +0 -14
  372. package/dist/chunks/processBashCommand-EQ9EWaRV.js +0 -1
  373. package/dist/chunks/processSlashCommand-C4PKNyFT.js +0 -5
  374. package/dist/chunks/prompt-B9sDzLPK.js +0 -1
  375. package/dist/chunks/prompt-WsoTRhoh.js +0 -1
  376. package/dist/chunks/promptEditor-Cr4w-4Bz.js +0 -4
  377. package/dist/chunks/refresh-CCSCAjgz.js +0 -1
  378. package/dist/chunks/rename-DS1AmW-F.js +0 -1
  379. package/dist/chunks/resume-Cf5PSoPw.js +0 -2
  380. package/dist/chunks/ripgrep-CBUbn6Po.js +0 -1
  381. package/dist/chunks/sandbox-adapter-Z4Phj31K.js +0 -1
  382. package/dist/chunks/sandbox-toggle-COZE8Lo4.js +0 -1
  383. package/dist/chunks/searchExtraTools-CvkRbL2m.js +0 -1
  384. package/dist/chunks/session-BvA99K4j.js +0 -2
  385. package/dist/chunks/sessionFileAccessHooks-6XfAf6ke.js +0 -1
  386. package/dist/chunks/sessionObserver-CRWUBJEY.js +0 -1
  387. package/dist/chunks/sessionStorage-DqEuxDlb.js +0 -1
  388. package/dist/chunks/sessionTracing-BoOZsXU2.js +0 -11
  389. package/dist/chunks/settings-Crx1cI1u.js +0 -1
  390. package/dist/chunks/settingsSync-rkWmClKS.js +0 -1
  391. package/dist/chunks/setup-D8L275fT.js +0 -3
  392. package/dist/chunks/sinks-DMp6uEzM.js +0 -1
  393. package/dist/chunks/skillChangeDetector-CtithJ4a.js +0 -1
  394. package/dist/chunks/skills-DXMk-498.js +0 -1
  395. package/dist/chunks/src-D3yIF9I42.js +0 -1
  396. package/dist/chunks/src-DQOX_xI1.js +0 -1
  397. package/dist/chunks/src-Dt5IJd3C.js +0 -1
  398. package/dist/chunks/src-Dvp6-vB7.js +0 -19
  399. package/dist/chunks/src-PM8NIIu_.js +0 -1
  400. package/dist/chunks/startupProfiler-uHetQush.js +0 -1
  401. package/dist/chunks/staticRender-D9AbnQFr.js +0 -1
  402. package/dist/chunks/stats-Ce15gc3E.js +0 -1
  403. package/dist/chunks/status-CFrLuGbf.js +0 -2
  404. package/dist/chunks/status-D5OCkMZG.js +0 -1
  405. package/dist/chunks/switcher-AiMcRzoi.js +0 -1
  406. package/dist/chunks/teleport-Bi_1VFIZ.js +0 -1
  407. package/dist/chunks/theme-CEKOCSLw.js +0 -1
  408. package/dist/chunks/toolPool-Df5iUqJ-.js +0 -1
  409. package/dist/chunks/trustedDevice-DXGePUAC.js +0 -1
  410. package/dist/chunks/useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js +0 -1
  411. package/dist/chunks/useMainLoopModel-CIG2cjS2.js +0 -1
  412. package/dist/chunks/useManagePlugins-MSHw-qHx.js +0 -1
  413. package/dist/chunks/useMergedTools-Bb-INJa2.js +0 -1
  414. package/dist/chunks/useSearchInput-QL_VtdJD.js +0 -1
  415. package/dist/chunks/useSettingsErrors-Dvi6zLCr.js +0 -1
  416. package/dist/chunks/util-CLQvtXuD.js +0 -1
  417. package/dist/chunks/validatePlugin-1mTZ3TJR.js +0 -1
  418. package/dist/chunks/which-BxQ1hpjp.js +0 -1
  419. package/dist/chunks/worktree-DpksgxdF.js +0 -1
  420. /package/dist/chunks/{src-DL3w8VPk2.js → src-DL3w8VPk.js} +0 -0
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Du as i,F as a,Lu as o,N as s,Ou as c,P as l,Ru as u,np as d,rp as f,zS as p}from"./loadAgentsDir-C96o6gCj.js";import{D as m,I as h,P as g,T as _,Wt as v,ai as y,t as b,vn as x,y as S,yn as C}from"./src-DL3w8VPk.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{r as T,t as E}from"./directoryCompletion-CuA3_YIT.js";import{r as D,t as O}from"./PromptInputFooterSuggestions-Blzgj5yW.js";function k(){return(0,P.jsx)(g,{dimColor:!0,children:`Work Mate will be able to read files in this directory and make edits when auto-accept edits is on.`})}function A({path:e}){return(0,P.jsxs)(h,{flexDirection:`column`,paddingX:2,gap:1,children:[(0,P.jsx)(g,{color:`permission`,children:e}),(0,P.jsx)(k,{})]})}function j({value:e,onChange:t,onSubmit:n,error:i,suggestions:a,selectedSuggestion:s}){return(0,P.jsxs)(h,{flexDirection:`column`,children:[(0,P.jsx)(g,{children:`Enter the path to the directory:`}),(0,P.jsx)(h,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,P.jsx)(o,{showCursor:!0,placeholder:`Directory path${r.ellipsis}`,value:e,onChange:t,onSubmit:n,columns:80,cursorOffset:e.length,onChangeCursorOffset:()=>{}})}),a.length>0&&(0,P.jsx)(h,{marginBottom:1,children:(0,P.jsx)(O,{suggestions:a,selectedSuggestion:s})}),i&&(0,P.jsx)(g,{color:`error`,children:i})]})}function M({onAddDirectory:e,onCancel:t,permissionContext:n,directoryPath:r}){let[o,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(null),[f,p]=(0,N.useState)([]),[y,b]=(0,N.useState)(0),x=(0,N.useMemo)(()=>F,[]),w=C((0,N.useCallback)(async e=>{if(!e){p([]),b(0);return}let t=await E(e);p(t),b(0)},[]),100);(0,N.useEffect)(()=>{w(o)},[o,w]);let T=(0,N.useCallback)(e=>{let t=`${e.id}/`;c(t),u(null)},[]),D=(0,N.useCallback)(async t=>{let r=await a(t,n);r.resultType===`success`?e(r.absolutePath,!1):u(s(r))},[n,e]);v(`confirm:no`,t,{context:`Settings`});let O=(0,N.useCallback)(e=>{if(f.length>0){if(e.key===`tab`){e.preventDefault();let t=f[y];t&&T(t);return}if(e.key===`return`){e.preventDefault();let t=f[y];t&&D(`${t.id}/`);return}if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b(e=>e<=0?f.length-1:e-1);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),b(e=>e>=f.length-1?0:e+1);return}}},[f,y,T,D]),M=(0,N.useCallback)(n=>{if(r)switch(n){case`yes-session`:e(r,!1);break;case`yes-remember`:e(r,!0);break;case`no`:t();break}},[r,e,t]);return(0,P.jsx)(h,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:O,children:(0,P.jsx)(S,{title:`Add directory to workspace`,onCancel:t,color:`permission`,isCancelActive:!1,inputGuide:r?void 0:e=>e.pending?(0,P.jsxs)(g,{children:[`Press `,e.keyName,` again to exit`]}):(0,P.jsxs)(_,{children:[(0,P.jsx)(m,{shortcut:`Tab`,action:`complete`}),(0,P.jsx)(m,{shortcut:`Enter`,action:`add`}),(0,P.jsx)(d,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]}),children:r?(0,P.jsxs)(h,{flexDirection:`column`,gap:1,children:[(0,P.jsx)(A,{path:r}),(0,P.jsx)(i,{options:x,onChange:M,onCancel:()=>M(`no`)})]}):(0,P.jsxs)(h,{flexDirection:`column`,gap:1,marginX:2,children:[(0,P.jsx)(k,{}),(0,P.jsx)(j,{value:o,onChange:c,onSubmit:D,error:l,suggestions:f,selectedSuggestion:y})]})})})}var N,P,F,I=e((()=>{n(),N=t(y(),1),x(),l(),u(),b(),p(),T(),f(),c(),D(),P=w(),F=[{value:`yes-session`,label:`Yes, for this session`},{value:`yes-remember`,label:`Yes, and remember this directory`},{value:`no`,label:`No`}]}));export{I as n,M as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./AgentsMdExternalIncludesDialog-Dp6CwZyI.js";e();export{t as AgentsMdExternalIncludesDialog};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Du as n,Eu as r}from"./loadAgentsDir-C96o6gCj.js";import{I as i,Lt as a,P as o,ai as s,t as c,y as l}from"./src-DL3w8VPk.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{h as d,v as f}from"./config-DUTgj3js.js";import{n as p,r as m}from"./analytics-DJobLaWP.js";function h({onDone:e,isStandaloneDialog:t,externalIncludes:r}){g.useEffect(()=>{m(`tengu_claude_md_includes_dialog_shown`,{})},[]);let s=(0,g.useCallback)(t=>{t===`no`?(m(`tengu_claude_md_external_includes_dialog_declined`,{}),f(e=>({...e,hasAgentsMdExternalIncludesApproved:!1,hasAgentsMdExternalIncludesWarningShown:!0}))):(m(`tengu_claude_md_external_includes_dialog_accepted`,{}),f(e=>({...e,hasAgentsMdExternalIncludesApproved:!0,hasAgentsMdExternalIncludesWarningShown:!0}))),e()},[e]);return(0,_.jsxs)(l,{title:`Allow external AGENTS.md file imports?`,color:`warning`,onCancel:(0,g.useCallback)(()=>{s(`no`)},[s]),hideBorder:!t,hideInputGuide:!t,children:[(0,_.jsx)(o,{children:`This project's AGENTS.md imports files outside the current working directory. Never allow this for third-party repositories.`}),r&&r.length>0&&(0,_.jsxs)(i,{flexDirection:`column`,children:[(0,_.jsx)(o,{dimColor:!0,children:`External imports:`}),r.map((e,t)=>(0,_.jsxs)(o,{dimColor:!0,children:[` `,e.path]},t))]}),(0,_.jsxs)(o,{dimColor:!0,children:[`Important: Only use Work Mate with files you trust. Accessing untrusted files may pose security risks`,` `,(0,_.jsx)(a,{url:`https://code.workmate.com/docs/en/security`}),` `]}),(0,_.jsx)(n,{options:[{label:`Yes, allow external imports`,value:`yes`},{label:`No, disable external imports`,value:`no`}],onChange:e=>s(e)})]})}var g,_,v=e((()=>{g=t(s(),1),p(),c(),d(),r(),_=u()}));export{v as n,h as t};
@@ -0,0 +1 @@
1
+ import{Th as e,wh as t}from"./loadAgentsDir-C96o6gCj.js";import{R as n,t as r}from"./src-DL3w8VPk.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{c as a,h as o,y as s}from"./config-DUTgj3js.js";import{n as c}from"./onChangeAppState-kEAt8nxV.js";import{t as l}from"./fpsMetrics-wxj9GAsd.js";import{t as u}from"./stats-D4LEtkrw.js";e(),r(),o();var d=i();function f({getFpsMetrics:e,stats:r,initialState:i,children:o}){return(0,d.jsx)(l,{getFpsMetrics:e,children:(0,d.jsx)(u,{store:r,children:(0,d.jsx)(t,{initialState:i,onChangeAppState:c,children:(0,d.jsx)(n,{initialState:a().theme,onThemeSave:e=>s(t=>({...t,theme:e})),children:o})})})})}export{f as App};
@@ -0,0 +1 @@
1
+ import{Du as e,Eu as t}from"./loadAgentsDir-C96o6gCj.js";import{P as n,t as r,y as i}from"./src-DL3w8VPk.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{h as o,y as s}from"./config-DUTgj3js.js";r(),o(),t();var c=a();function l({customApiKeyTruncated:t,onDone:r}){function a(e){switch(e){case`yes`:s(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,approved:[...e.customApiKeyResponses?.approved??[],t]}})),r(!0);break;case`no`:s(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,rejected:[...e.customApiKeyResponses?.rejected??[],t]}})),r(!1);break}}return(0,c.jsxs)(i,{title:`Detected a custom API key in your environment`,color:`warning`,onCancel:()=>a(`no`),children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{bold:!0,children:`ANTHROPIC_API_KEY`}),(0,c.jsxs)(n,{children:[`: sk-ant-...`,t]})]}),(0,c.jsx)(n,{children:`Do you want to use this API key?`}),(0,c.jsx)(e,{defaultValue:`no`,defaultFocusValue:`no`,options:[{label:`Yes`,value:`yes`},{label:(0,c.jsxs)(n,{children:[`No (`,(0,c.jsx)(n,{bold:!0,children:`recommended`}),`)`]}),value:`no`}],onChange:e=>a(e),onCancel:()=>a(`no`)})]})}export{l as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./ApproveApiKey-Bolw0sPs.js";export{e as ApproveApiKey};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Al as i,Ax as a,BS as o,Bd as s,Bf as c,Ch as l,Du as u,Eh as d,En as f,Ff as p,GS as m,Hl as h,If as g,Ml as ee,Nl as _,Oh as te,On as ne,Ou as v,Pl as y,Pu as re,Rl as ie,Sc as ae,Sh as oe,Th as se,VS as ce,Vf as le,af as ue,ag as b,df as x,ds as de,ea as S,ff as C,fs as fe,jl as pe,ju as me,kx as he,ma as ge,mw as _e,ng as ve,ra as ye,sf as be,xc as xe,zS as w,zd as Se}from"./loadAgentsDir-C96o6gCj.js";import{D as T,Gt as E,H as Ce,I as D,Lt as we,P as O,T as k,ai as A,mt as Te,ot as Ee,t as j,y as M}from"./src-DL3w8VPk.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{P as De,R as Oe,_ as ke,f as Ae}from"./debug-D58GQBDG.js";import{In as P,Ln as je,Rn as Me,Ut as F}from"./settings-BowI3jp-.js";import{C as Ne,b as I,f as Pe,l as Fe,u as Ie,v as L}from"./startupProfiler-B90b5vuq.js";import{l as R,o as Le}from"./stringUtils-D7oJIyY2.js";import{Nt as Re,_n as ze,gn as Be,vn as Ve}from"./prompt-BNNE5tsG.js";import{i as He,n as Ue}from"./mappers-D8VLUZ2N.js";function z(e,t,n=1e3,r=0,i){let a=()=>Fe(Math.max(0,(i??Date.now())-e-r));return(0,We.useSyncExternalStore)((0,We.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var We,B=e((()=>{We=t(A(),1),L()}));function Ge(e,t,n){let r=Be(t,e.toolName);if(!r)return e.toolName;try{let t=r.inputSchema.safeParse(e.input),i=t.success?t.data:{},a=r.userFacingName(i);if(!a)return e.toolName;let o=r.renderToolUseMessage(i,{theme:n,verbose:!1});return o?(0,Ke.jsxs)(O,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var Ke,qe=e((()=>{j(),Ve(),Ke=N()}));function Je(e,t){let{isIdle:n,awaitingApproval:i,hasError:a,shutdownRequested:o}=t??{};return a?r.cross:i?r.questionMarkPrefix:o?r.warning:e===`running`?n?r.ellipsis:r.play:e===`completed`?r.tick:e===`failed`||e===`killed`?r.cross:r.bullet}function Ye(e,t){let{isIdle:n,awaitingApproval:r,hasError:i,shutdownRequested:a}=t??{};return i?`error`:r||a?`warning`:n?`background`:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:`background`}function Xe(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(C(t))return n=!0,!1;return n}var Ze=e((()=>{n(),x()}));function Qe({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=Ce(),a=(0,$e.useMemo)(()=>xe(ze()),[]),o=z(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);E({"confirm:yes":t},{context:`Confirmation`});let s=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},l=_e(e.prompt,`plan`),u=e.prompt.length>300?`${e.prompt.substring(0,297)}…`:e.prompt,d=e.result?.totalTokens??e.progress?.tokenCount,f=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,V.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:(0,V.jsx)(M,{title:(0,V.jsxs)(O,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,V.jsxs)(O,{children:[e.status!==`running`&&(0,V.jsxs)(O,{color:Ye(e.status),children:[Je(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,V.jsxs)(O,{dimColor:!0,children:[o,d!==void 0&&d>0&&(0,V.jsxs)(V.Fragment,{children:[` · `,Pe(d),` tokens`]}),f!==void 0&&f>0&&(0,V.jsxs)(V.Fragment,{children:[` `,`· `,f,` `,f===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,V.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,V.jsxs)(k,{children:[r&&(0,V.jsx)(T,{shortcut:`←`,action:`go back`}),(0,V.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,V.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:(0,V.jsxs)(D,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,V.jsxs)(D,{flexDirection:`column`,children:[(0,V.jsx)(O,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,V.jsxs)(O,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,Ge(t,a,i)]},n))]}),l?(0,V.jsx)(D,{marginTop:1,children:(0,V.jsx)(c,{addMargin:!1,planContent:l})}):(0,V.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,V.jsx)(O,{bold:!0,dimColor:!0,children:`Prompt`}),(0,V.jsx)(O,{wrap:`wrap`,children:u})]}),e.status===`failed`&&e.error&&(0,V.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,V.jsx)(O,{bold:!0,color:`error`,children:`Error`}),(0,V.jsx)(O,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var $e,V,et=e((()=>{$e=t(A(),1),B(),j(),w(),Ve(),ae(),L(),S(),le(),qe(),Ze(),V=N()}));function tt(e,t,n,r){if(!e)return`${t} found · ${n} verified`;if(e===`synthesizing`){let e=[`${n} verified`];return r>0&&e.push(`${r} refuted`),e.push(`deduping`),e.join(` · `)}if(e===`verifying`){let e=[`${t} found`,`${n} verified`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return t>0?`${t} found`:`finding`}function nt({text:e,phase:t=0}){return(0,H.jsx)(H.Fragment,{children:[...e].map((e,n)=>(0,H.jsx)(O,{color:p(n+t),children:e},n))})}function rt(e,t,n){let r=(0,ot.useRef)(e),i=(0,ot.useRef)(t);return n||e<r.current?r.current=e:e>r.current&&t!==i.current&&(r.current+=1,i.current=t),r.current}function it({session:e}){let t=l().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=Te(r&&!t?st:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,u=rt(a,i,c),d=rt(o,i,c),f=rt(s,i,c),p=Math.floor(i/(st*3))%7;if(e.status===`completed`)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:0}),(0,H.jsx)(O,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:0}),(0,H.jsxs)(O,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let m=n?tt(n.stage,u,d,f):`setting up`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(O,{color:`background`,children:[`◇`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:r?p:0}),(0,H.jsxs)(O,{dimColor:!0,children:[` · `,m]})]})}function at({session:e}){if(e.isRemoteReview)return(0,H.jsx)(it,{session:e});if(e.status===`completed`)return(0,H.jsx)(O,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,H.jsx)(O,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,H.jsxs)(O,{dimColor:!0,children:[e.status,`…`]});let t=P(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,H.jsxs)(O,{dimColor:!0,children:[t,`/`,n]})}var ot,H,st,ct=e((()=>{ot=t(A(),1),F(),oe(),j(),je(),g(),H=N(),st=80}));function U({status:e,label:t,suffix:n}){return(0,W.jsxs)(O,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function lt({shell:e}){switch(e.status){case`completed`:return(0,W.jsx)(U,{status:`completed`,label:`done`});case`failed`:return(0,W.jsx)(U,{status:`failed`,label:`error`});case`killed`:return(0,W.jsx)(U,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,W.jsx)(U,{status:`running`})}}var W,ut=e((()=>{j(),W=N()}));function dt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,G.jsxs)(O,{children:[I(e.command,n,!0),` `,(0,G.jsx)(lt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,G.jsx)(O,{children:(0,G.jsx)(at,{session:e})}):(0,G.jsxs)(O,{children:[(0,G.jsxs)(O,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),I(e.title,n,!0),(0,G.jsx)(O,{dimColor:!0,children:` · `}),(0,G.jsx)(at,{session:e})]});case`local_agent`:return(0,G.jsxs)(O,{children:[I(e.description,n,!0),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]});case`local_workflow`:{let t=e;return(0,G.jsxs)(O,{children:[I(t.workflowName??e.summary??e.description,n,!0),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`running`?`${t.agentCount} ${R(t.agentCount,`agent`)}`:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}case`dream`:{let t=e.filesTouched.length,n=e.phase===`updating`&&t>0?`${t} ${R(t,`file`)}`:`${e.sessionsReviewing} ${R(e.sessionsReviewing,`session`)}`;return(0,G.jsxs)(O,{children:[e.description,` `,(0,G.jsxs)(O,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var G,ft=e((()=>{j(),L(),Le(),F(),ct(),ut(),G=N()}));function pt({task:e,onDone:t,onBack:n,onKill:r}){let i=z(e.startTime,e.status===`running`,1e3,0);E({"confirm:yes":t},{context:`Confirmation`});let a=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&n?(i.preventDefault(),n()):i.key===`x`&&e.status===`running`&&r&&(i.preventDefault(),r())},o=e.turns.filter(e=>e.text!==``),s=o.slice(-6),c=o.length-s.length;return(0,K.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,K.jsx)(M,{title:`Memory consolidation`,subtitle:(0,K.jsxs)(O,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,R(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,R(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,K.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,K.jsxs)(k,{children:[n&&(0,K.jsx)(T,{shortcut:`←`,action:`go back`}),(0,K.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,K.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:(0,K.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,K.jsxs)(O,{children:[(0,K.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,K.jsx)(O,{color:`background`,children:`running`}):e.status===`completed`?(0,K.jsx)(O,{color:`success`,children:e.status}):(0,K.jsx)(O,{color:`error`,children:e.status})]}),s.length===0?(0,K.jsx)(O,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,K.jsxs)(K.Fragment,{children:[c>0&&(0,K.jsxs)(O,{dimColor:!0,children:[`(`,c,` earlier `,R(c,`turn`),`)`]}),s.map((e,t)=>(0,K.jsxs)(D,{flexDirection:`column`,children:[(0,K.jsx)(O,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,K.jsxs)(O,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,R(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var K,mt=e((()=>{B(),j(),w(),Le(),K=N()}));function ht({stage:e,completed:t,hasProgress:n}){let r=e?yt.indexOf(e):-1,i=!t&&!n;return(0,J.jsxs)(O,{children:[i?(0,J.jsx)(O,{color:`background`,children:`Setup`}):(0,J.jsx)(O,{dimColor:!0,children:`Setup`}),(0,J.jsx)(O,{dimColor:!0,children:` → `}),yt.map((e,n)=>{let a=!t&&!i&&n===r;return(0,J.jsxs)(q.Fragment,{children:[n>0&&(0,J.jsx)(O,{dimColor:!0,children:` → `}),a?(0,J.jsx)(O,{color:`background`,children:bt[e]}):(0,J.jsx)(O,{dimColor:!0,children:bt[e]})]},e)}),t&&(0,J.jsx)(O,{color:`success`,children:` ✓`})]})}function gt(e){let t=e.reviewProgress;if(!t)return e.status===`completed`?`done`:`setting up`;let n=t.bugsVerified,r=t.bugsRefuted??0;if(e.status===`completed`){let e=[`${n} ${R(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return tt(t.stage,t.bugsFound,n,r)}function _t({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,o=e.status===`running`||e.status===`pending`,[s,c]=(0,q.useState)(!1),l=z(e.startTime,o,1e3,0,e.endTime),d=()=>t(`Remote session details dismissed`,{display:`system`}),f=n??d,p=_(e.sessionId),m=i?`ready`:o?`running`:e.status;if(s)return(0,J.jsx)(M,{title:`Stop ultrareview?`,onCancel:()=>c(!1),color:`background`,children:(0,J.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,J.jsx)(O,{dimColor:!0,children:`This archives the remote session and stops local tracking. The review will not complete and any findings so far are discarded.`}),(0,J.jsx)(u,{options:[{label:`Stop ultrareview`,value:`stop`},{label:`Back`,value:`back`}],onChange:e=>{e===`stop`?(r?.(),f()):c(!1)}})]})});let h=i?[{label:`Open in Work Mate on the web`,value:`open`},{label:`Dismiss`,value:`dismiss`}]:[{label:`Open in Work Mate on the web`,value:`open`},...r&&o?[{label:`Stop ultrareview`,value:`stop`}]:[],{label:`Back`,value:`back`}];return(0,J.jsx)(M,{title:(0,J.jsxs)(O,{children:[(0,J.jsxs)(O,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,J.jsx)(O,{bold:!0,children:`ultrareview`}),(0,J.jsxs)(O,{dimColor:!0,children:[` · `,l,` · `,m]})]}),onCancel:f,color:`background`,inputGuide:e=>e.pending?(0,J.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,J.jsxs)(k,{children:[(0,J.jsx)(T,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(T,{shortcut:`Esc`,action:`go back`})]}),children:(0,J.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,J.jsx)(ht,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,J.jsxs)(D,{flexDirection:`column`,children:[(0,J.jsx)(O,{children:gt(e)}),(0,J.jsx)(we,{url:p,children:(0,J.jsx)(O,{dimColor:!0,children:p})})]}),(0,J.jsx)(u,{options:h,onChange:e=>{switch(e){case`open`:a(p),t();break;case`stop`:c(!0);break;case`back`:f();break;case`dismiss`:d();break}}})]})})}function vt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),l=(0,q.useMemo)(()=>e.isRemoteReview?[]:ge(He(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,J.jsx)(_t,{session:e,onDone:n,onBack:r,onKill:i});let u=()=>n(`Remote session details dismissed`,{display:`system`}),d=e=>{e.key===` `?(e.preventDefault(),n(`Remote session details dismissed`,{display:`system`})):e.key===`left`&&r?(e.preventDefault(),r()):e.key===`t`&&!a?(e.preventDefault(),f()):e.key===`return`&&(e.preventDefault(),u())};async function f(){o(!0),c(null);try{await h(e.sessionId)}catch(e){c(De(e))}finally{o(!1)}}let p=Ne(e.title,50),m=e.status===`pending`?`starting`:e.status;return(0,J.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:(0,J.jsxs)(M,{title:`Remote session details`,onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,J.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,J.jsxs)(k,{children:[r&&(0,J.jsx)(T,{shortcut:`←`,action:`go back`}),(0,J.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,J.jsx)(T,{shortcut:`t`,action:`teleport`})]}),children:[(0,J.jsxs)(D,{flexDirection:`column`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(O,{bold:!0,children:`Status`}),`:`,` `,m===`running`||m===`starting`?(0,J.jsx)(O,{color:`background`,children:m}):m===`completed`?(0,J.jsx)(O,{color:`success`,children:m}):(0,J.jsx)(O,{color:`error`,children:m})]}),(0,J.jsxs)(O,{children:[(0,J.jsx)(O,{bold:!0,children:`Runtime`}),`: `,Fe((e.endTime??Date.now())-e.startTime)]}),(0,J.jsxs)(O,{wrap:`truncate-end`,children:[(0,J.jsx)(O,{bold:!0,children:`Title`}),`: `,p]}),(0,J.jsxs)(O,{children:[(0,J.jsx)(O,{bold:!0,children:`Progress`}),`: `,(0,J.jsx)(at,{session:e})]}),(0,J.jsxs)(O,{children:[(0,J.jsx)(O,{bold:!0,children:`Session URL`}),`:`,` `,(0,J.jsx)(we,{url:_(e.sessionId),children:(0,J.jsx)(O,{dimColor:!0,children:_(e.sessionId)})})]})]}),e.log.length>0&&(0,J.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(O,{bold:!0,children:`Recent messages`}),`:`]}),(0,J.jsx)(D,{flexDirection:`column`,height:10,overflowY:`hidden`,children:l.map((e,n)=>(0,J.jsx)(ue,{message:e,lookups:ye,addMargin:n>0,tools:t.options.tools,commands:t.options.commands,verbose:t.options.verbose,inProgressToolUseIDs:new Set,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,style:`condensed`,isTranscriptMode:!1,isStatic:!0},n))}),(0,J.jsx)(D,{marginTop:1,children:(0,J.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing last `,l.length,` of `,e.log.length,` messages`]})})]}),s&&(0,J.jsx)(D,{marginTop:1,children:(0,J.jsxs)(O,{color:`error`,children:[`Teleport failed: `,s]})}),a&&(0,J.jsx)(O,{color:`background`,children:`Teleporting to session…`})]})})}var q,J,yt,bt,xt=e((()=>{q=t(A(),1),F(),B(),j(),y(),Re(),he(),Oe(),L(),Ue(),S(),Le(),ie(),v(),be(),ct(),J=N(),yt=[`finding`,`verifying`,`synthesizing`],bt={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function St(e){let t=f(e.id);try{let e=await ke(t,Tt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function Ct({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=Ee(),[a,o]=(0,Y.useState)(()=>St(e)),s=(0,Y.useDeferredValue)(a);(0,Y.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(St(t)),1e3,o,e);return()=>clearInterval(t)},[e.id,e.status]);let c=()=>t(`Shell details dismissed`,{display:`system`});E({"confirm:yes":c},{context:`Confirmation`});let l=i=>{i.key===` `?(i.preventDefault(),t(`Shell details dismissed`,{display:`system`})):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},u=Ne(e.command,280);return(0,X.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,X.jsxs)(M,{title:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,X.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,X.jsxs)(k,{children:[r&&(0,X.jsx)(T,{shortcut:`←`,action:`go back`}),(0,X.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,X.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:[(0,X.jsxs)(D,{flexDirection:`column`,children:[(0,X.jsxs)(O,{children:[(0,X.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,X.jsxs)(O,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,X.jsxs)(O,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,X.jsxs)(O,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,X.jsxs)(O,{children:[(0,X.jsx)(O,{bold:!0,children:`Runtime:`}),` `,Fe((e.endTime??Date.now())-e.startTime)]}),(0,X.jsxs)(O,{wrap:`wrap`,children:[(0,X.jsx)(O,{bold:!0,children:`Command:`}),` `,u]})]}),(0,X.jsxs)(D,{flexDirection:`column`,children:[(0,X.jsx)(O,{bold:!0,children:`Output:`}),(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(O,{dimColor:!0,children:`Loading output…`}),children:(0,X.jsx)(wt,{outputPromise:s,columns:i})})]})]})})}function wt({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,Y.use)(e);if(!n)return(0,X.jsx)(O,{dimColor:!0,children:`No output available`});let i=[],a=n.length;for(let e=0;e<10&&a>0;e++){let e=n.lastIndexOf(`
2
+ `,a-1);i.push(e+1),a=e}i.reverse();let o=r>n.length,s=[];for(let e=0;e<i.length;e++){let t=i[e],r=e<i.length-1?i[e+1]-1:n.length,a=n.slice(t,r);a&&s.push(a)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,X.jsx)(O,{wrap:`truncate-end`,children:e},t))}),(0,X.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Ie(r)}`:``]})]})}var Y,X,Tt,Et=e((()=>{Y=t(A(),1),m(),j(),w(),L(),Ae(),ne(),X=N(),Tt=8192}));function Dt(e,t){return Object.values(e??{}).filter(C).filter(e=>!(e.type===`local_agent`&&e.id===t))}function Ot({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=d(e=>e.tasks),i=d(e=>e.foregroundedTaskId),a=te(),o=ce(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),s=r,c=(0,Q.useRef)(!1),[l,u]=(0,Q.useState)(()=>{if(n)return c.current=!0,{mode:`detail`,itemId:n};let e=Dt(s,i);return e.length===1?(c.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[f,p]=(0,Q.useState)(0);re(`background-tasks-dialog`);let{bashTasks:m,remoteSessions:h,agentTasks:g,workflowTasks:_,dreamTasks:ne,allSelectableItems:v}=(0,Q.useMemo)(()=>{let e=Object.values(s??{}).filter(C).map(kt).sort((e,t)=>{let n=e.status,r=t.status;if(n===`running`&&r!==`running`)return-1;if(n!==`running`&&r===`running`)return 1;let i=`task`in e?e.task.startTime:0;return(`task`in t?t.task.startTime:0)-i}),t=e.filter(e=>e.type===`local_bash`),n=e.filter(e=>e.type===`remote_agent`),r=e.filter(e=>e.type===`local_agent`&&e.id!==i),a=e.filter(e=>e.type===`local_workflow`),o=e.filter(e=>e.type===`dream`);return{bashTasks:t,remoteSessions:n,agentTasks:r,workflowTasks:a,dreamTasks:o,allSelectableItems:[...t,...n,...r,...a,...o]}},[s,i]),y=v[f]??null;E({"confirm:previous":()=>p(e=>Math.max(0,e-1)),"confirm:next":()=>p(e=>Math.min(v.length-1,e+1)),"confirm:yes":()=>{let e=v[f];e&&u({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:l.mode===`list`});let ie=t=>{if(l.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=v[f];n&&t.key===`x`&&(t.preventDefault(),n.type===`local_bash`&&n.status===`running`?ae(n.id):n.type===`local_agent`&&n.status===`running`?oe(n.id):n.type===`local_workflow`&&n.status===`running`?At(n.id,a):n.type===`dream`&&n.status===`running`?se(n.id):n.type===`remote_agent`&&n.status===`running`&&le(n.id))};async function ae(e){await ve.kill(e,a)}async function oe(e){await de.kill(e,a)}async function se(e){await Se.kill(e,a)}async function le(e){await ee.kill(e,a)}let ue=(0,Q.useEffectEvent)(e);(0,Q.useEffect)(()=>{if(l.mode!==`list`){let e=s?.[l.itemId];(!e||e.type!==`local_workflow`&&!C(e))&&(c.current?ue(`Background tasks dialog dismissed`,{display:`system`}):u({mode:`list`}))}let e=v.length;f>=e&&e>0&&p(e-1)},[l,s,f,v,ue]);let b=()=>{c.current&&v.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(c.current=!1,u({mode:`list`}))};if(l.mode!==`list`&&s){let n=s[l.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,$.jsx)(Ct,{shell:n,onDone:e,onKillShell:()=>void ae(n.id),onBack:b},`shell-${n.id}`);case`local_agent`:return(0,$.jsx)(Qe,{agent:n,onDone:e,onKillAgent:()=>void oe(n.id),onBack:b},`agent-${n.id}`);case`remote_agent`:return(0,$.jsx)(vt,{session:n,onDone:e,toolUseContext:t,onBack:b,onKill:n.status===`running`?()=>void le(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`?()=>At(n.id,a):void 0;return(0,$.jsx)(D,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),b()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,$.jsx)(M,{title:n.workflowName,subtitle:(0,$.jsxs)(O,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:b,inputGuide:()=>(0,$.jsxs)(k,{children:[(0,$.jsx)(T,{shortcut:`←`,action:`go back`}),(0,$.jsx)(T,{shortcut:`Esc`,action:`close`}),e&&(0,$.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,$.jsxs)(O,{color:`error`,children:[`失败原因:`,n.error]}):null})},`workflow-${n.id}`)}case`dream`:return(0,$.jsx)(pt,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:b,onKill:n.status===`running`?()=>void se(n.id):void 0},`dream-${n.id}`)}}let x=P(m,e=>e.status===`running`),S=P(h,e=>e.status===`running`||e.status===`pending`)+P(g,e=>e.status===`running`),fe=Me([...x>0?[(0,$.jsxs)(O,{children:[x,` `,x===1?`active shell`:`active shells`]},`shells`)]:[],...S>0?[(0,$.jsxs)(O,{children:[S,` `,S===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,$.jsx)(O,{children:` · `},`separator-${e}`)),pe=[(0,$.jsx)(T,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,$.jsx)(T,{shortcut:`Enter`,action:`view`},`enter`),...(y?.type===`local_bash`||y?.type===`local_agent`||y?.type===`local_workflow`||y?.type===`dream`||y?.type===`remote_agent`)&&y.status===`running`?[(0,$.jsx)(T,{shortcut:`x`,action:`stop`},`kill`)]:[],...g.some(e=>e.status===`running`)?[(0,$.jsx)(T,{shortcut:o,action:`stop all agents`},`kill-all`)]:[],(0,$.jsx)(T,{shortcut:`←/Esc`,action:`close`},`esc`)],me=()=>e(`Background tasks dialog dismissed`,{display:`system`});function he(e){return e.pending?(0,$.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsx)(k,{children:pe})}return(0,$.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:(0,$.jsx)(M,{title:`Background tasks`,subtitle:fe,onCancel:me,color:`background`,inputGuide:he,children:v.length===0?(0,$.jsx)(O,{dimColor:!0,children:`No tasks currently running`}):(0,$.jsxs)(D,{flexDirection:`column`,children:[m.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(h.length>0||g.length>0)&&(0,$.jsxs)(O,{dimColor:!0,children:[(0,$.jsxs)(O,{bold:!0,children:[` `,`Shells`]}),` (`,m.length,`)`]}),(0,$.jsx)(D,{flexDirection:`column`,children:m.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===y?.id},e.id))})]}),h.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0),children:[(0,$.jsxs)(O,{dimColor:!0,children:[(0,$.jsxs)(O,{bold:!0,children:[` `,`Remote agents`]}),` (`,h.length,`)`]}),(0,$.jsx)(D,{flexDirection:`column`,children:h.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===y?.id},e.id))})]}),g.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0),children:[(0,$.jsxs)(O,{dimColor:!0,children:[(0,$.jsxs)(O,{bold:!0,children:[` `,`Local agents`]}),` (`,g.length,`)`]}),(0,$.jsx)(D,{flexDirection:`column`,children:g.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===y?.id},e.id))})]}),_.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0||g.length>0),children:[(0,$.jsxs)(O,{dimColor:!0,children:[(0,$.jsxs)(O,{bold:!0,children:[` `,`Workflows`]}),` (`,_.length,`)`]}),(0,$.jsx)(D,{flexDirection:`column`,children:_.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===y?.id},e.id))})]}),ne.length>0&&(0,$.jsx)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0||g.length>0||_.length>0),children:(0,$.jsx)(D,{flexDirection:`column`,children:ne.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===y?.id},e.id))})})]})})})}function kt(e){switch(e.type){case`local_bash`:return{id:e.id,type:`local_bash`,label:e.command,status:e.status,task:e};case`remote_agent`:return{id:e.id,type:`remote_agent`,label:e.title,status:e.status,task:e};case`local_agent`:return{id:e.id,type:`local_agent`,label:e.description,status:e.status,task:e};case`local_workflow`:return{id:e.id,type:`local_workflow`,label:e.summary??e.description,status:e.status,task:e};case`dream`:return{id:e.id,type:`dream`,label:e.description,status:e.status,task:e}}}function Z({item:e,isSelected:t}){let{columns:n}=Ee(),i=Math.max(30,n-26);return(0,$.jsxs)(D,{flexDirection:`row`,children:[(0,$.jsx)(O,{children:t?`${r.pointer} `:` `}),(0,$.jsx)(O,{color:t?`suggestion`:void 0,children:(0,$.jsx)(dt,{task:e.task,maxActivityWidth:i})})]})}var Q,$,At,jt=e((()=>{n(),Q=t(A(),1),m(),se(),s(),fe(),b(),y(),x(),je(),me(),j(),w(),o(),et(),ft(),mt(),xt(),Et(),i(),$=N(),At=pe}));export{B as a,Xe as i,jt as n,z as o,Ze as r,Ot as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Dd as t,Du as n,Eu as r,Od as i}from"./loadAgentsDir-C96o6gCj.js";import{I as a,Lt as o,P as s,ai as c,kt as l,t as u,y as d}from"./src-DL3w8VPk.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{b as p,h as m}from"./settings-BowI3jp-.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";var _=e(c(),1);h(),u(),i(),m(),r();var v=f();function y({onAccept:e}){let[r,i]=_.useState(null);_.useEffect(()=>{if(r!==null){let e=r,n=setTimeout(()=>t(e));return()=>clearTimeout(n)}},[r]),_.useEffect(()=>{g(`tengu_bypass_permissions_mode_dialog_shown`,{})},[]);function c(t){switch(t){case`accept`:g(`tengu_bypass_permissions_mode_dialog_accept`,{}),p(`userSettings`,{skipDangerousModePermissionPrompt:!0}),e();break;case`decline`:i(1);break}}let u=(0,_.useCallback)(()=>{i(0)},[]);return r===null?(0,v.jsxs)(d,{title:`WARNING: Work Mate running in Bypass Permissions mode`,color:`error`,onCancel:u,children:[(0,v.jsxs)(a,{flexDirection:`column`,gap:1,children:[(0,v.jsxs)(s,{children:[`In Bypass Permissions mode, Work Mate will not ask for your approval before running potentially dangerous commands.`,(0,v.jsx)(l,{}),`This mode should only be used in a sandboxed container/VM that has restricted internet access and can easily be restored if damaged.`]}),(0,v.jsx)(s,{children:`By proceeding, you accept all responsibility for actions taken while running in Bypass Permissions mode.`}),(0,v.jsx)(o,{url:`https://code.workmate.com/docs/en/security`})]}),(0,v.jsx)(n,{options:[{label:`No, exit`,value:`decline`},{label:`Yes, I accept`,value:`accept`}],onChange:e=>c(e)})]}):null}export{y as BypassPermissionsModeDialog};
@@ -1,6 +1,6 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Nh as i,Ph as a,ad as o,dC as s,fC as c,gC as l,nd as u,uC as d}from"./loadAgentsDir-DaNpxaO-.js";import{C as f,Gt as ee,I as p,P as m,T as h,ai as g,ot as _,t as v,y as te}from"./src-DL3w8VPk2.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{n as b,t as x}from"./cwd-Nh5IZNKO.js";import{An as S,Cn as C}from"./settings-3xZ0fsvE.js";import{l as w,m as T,p as E,s as D}from"./git-By_J4XJL.js";import{r as O,t as k}from"./execFileNoThrow-Bmb5HEFz.js";import{S as ne,v as re}from"./startupProfiler-CbzxVmbv.js";import{l as A,o as j}from"./stringUtils-CKD8qDqx.js";import{i as ie}from"./detectRepository-CDOJ-M7h.js";import{join as M,resolve as ae}from"path";import{access as oe}from"fs/promises";async function se(){if(!await w()||await P())return null;let{stdout:e,code:t}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`,`--shortstat`],{timeout:F,preserveOutputOnError:!1});if(t===0){let t=de(e);if(t&&t.filesCount>z)return{stats:t,perFileStats:new Map,hunks:new Map}}let{stdout:n,code:r}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`,`--numstat`],{timeout:F,preserveOutputOnError:!1});if(r!==0)return null;let{stats:i,perFileStats:a}=ce(n),o=I-a.size;if(o>0){let e=await ue(o);if(e){i.filesCount+=e.size;for(let[t,n]of e)a.set(t,n)}}return{stats:i,perFileStats:a,hunks:new Map}}async function N(){if(!await w()||await P())return new Map;let{stdout:e,code:t}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`],{timeout:F,preserveOutputOnError:!1});return t===0?le(e):new Map}function ce(e){let t=e.trim().split(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{BS as i,GS as a,Pu as o,VS as s,ch as c,ju as l,lh as u,zS as d}from"./loadAgentsDir-C96o6gCj.js";import{C as f,Gt as ee,I as p,P as m,T as h,ai as g,ot as _,t as v,y as te}from"./src-DL3w8VPk.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{n as b,t as x}from"./cwd-Nh5IZNKO.js";import{An as S,Cn as C}from"./settings-BowI3jp-.js";import{l as w,m as T,p as E,s as D}from"./git-Wid-XppW.js";import{i as O,t as k}from"./execFileNoThrow-B_KRY4cT.js";import{S as ne,v as re}from"./startupProfiler-B90b5vuq.js";import{l as A,o as j}from"./stringUtils-D7oJIyY2.js";import{i as ie}from"./detectRepository-pRAVv8SH.js";import{join as M,resolve as ae}from"path";import{access as oe}from"fs/promises";async function se(){if(!await w()||await P())return null;let{stdout:e,code:t}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`,`--shortstat`],{timeout:F,preserveOutputOnError:!1});if(t===0){let t=de(e);if(t&&t.filesCount>z)return{stats:t,perFileStats:new Map,hunks:new Map}}let{stdout:n,code:r}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`,`--numstat`],{timeout:F,preserveOutputOnError:!1});if(r!==0)return null;let{stats:i,perFileStats:a}=ce(n),o=I-a.size;if(o>0){let e=await ue(o);if(e){i.filesCount+=e.size;for(let[t,n]of e)a.set(t,n)}}return{stats:i,perFileStats:a,hunks:new Map}}async function N(){if(!await w()||await P())return new Map;let{stdout:e,code:t}=await k(E(),[`--no-optional-locks`,`diff`,`HEAD`],{timeout:F,preserveOutputOnError:!1});return t===0?le(e):new Map}function ce(e){let t=e.trim().split(`
2
2
  `).filter(Boolean),n=0,r=0,i=0,a=new Map;for(let e of t){let t=e.split(` `);if(t.length<3)continue;i++;let o=t[0],s=t[1],c=t.slice(2).join(` `),l=o===`-`||s===`-`,u=l?0:parseInt(o??`0`,10)||0,d=l?0:parseInt(s??`0`,10)||0;n+=u,r+=d,a.size<I&&a.set(c,{added:u,removed:d,isBinary:l})}return{stats:{filesCount:i,linesAdded:n,linesRemoved:r},perFileStats:a}}function le(e){let t=new Map;if(!e.trim())return t;let n=e.split(/^diff --git /m).filter(Boolean);for(let e of n){if(t.size>=I)break;if(e.length>L)continue;let n=e.split(`
3
3
  `),r=n[0]?.match(/^a\/(.+?) b\/(.+)$/);if(!r)continue;let i=r[2]??r[1]??``,a=[],o=null,s=0;for(let e=1;e<n.length;e++){let t=n[e]??``,r=t.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(r){o&&a.push(o),o={oldStart:parseInt(r[1]??`0`,10),oldLines:parseInt(r[2]??`1`,10),newStart:parseInt(r[3]??`0`,10),newLines:parseInt(r[4]??`1`,10),lines:[]};continue}if(!(t.startsWith(`index `)||t.startsWith(`---`)||t.startsWith(`+++`)||t.startsWith(`new file`)||t.startsWith(`deleted file`)||t.startsWith(`old mode`)||t.startsWith(`new mode`)||t.startsWith(`Binary files`))&&o&&(t.startsWith(`+`)||t.startsWith(`-`)||t.startsWith(` `)||t===``)){if(s>=R)continue;o.lines.push(`${t}`),s++}}o&&a.push(o),a.length>0&&t.set(i,a)}return t}async function P(){let e=await D(x());return e?(await Promise.all([`MERGE_HEAD`,`REBASE_HEAD`,`CHERRY_PICK_HEAD`,`REVERT_HEAD`].map(t=>oe(M(e,t)).then(()=>!0).catch(()=>!1)))).some(Boolean):!1}async function ue(e){let{stdout:t,code:n}=await k(E(),[`--no-optional-locks`,`ls-files`,`--others`,`--exclude-standard`],{timeout:F,preserveOutputOnError:!1});if(n!==0||!t.trim())return null;let r=t.trim().split(`
4
4
  `).filter(Boolean);if(r.length===0)return null;let i=new Map;for(let t of r.slice(0,e))i.set(t,{added:0,removed:0,isBinary:!1,isUntracked:!0});return i}function de(e){let t=e.match(/(\d+)\s+files?\s+changed(?:,\s+(\d+)\s+insertions?\(\+\))?(?:,\s+(\d+)\s+deletions?\(-\))?/);return t?{filesCount:parseInt(t[1]??`0`,10),linesAdded:parseInt(t[2]??`0`,10),linesRemoved:parseInt(t[3]??`0`,10)}:null}var F,I,L,R,z,B=e((()=>{b(),ie(),O(),C(),T(),F=5e3,I=50,L=1e6,R=400,z=500}));function V(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(new Map),[i,a]=(0,H.useState)(!0);return(0,H.useEffect)(()=>{let e=!1;async function n(){try{let[n,i]=await Promise.all([se(),N()]);e||(t(n),r(i),a(!1))}catch{e||(t(null),r(new Map),a(!1))}}return n(),()=>{e=!0}},[]),(0,H.useMemo)(()=>{if(!e)return{stats:null,files:[],hunks:new Map,loading:i};let{stats:t,perFileStats:r}=e,a=[];for(let[e,t]of r){let r=n.get(e),i=t.isUntracked??!1,o=!t.isBinary&&!i&&!r,s=t.added+t.removed,c=!o&&!t.isBinary&&s>U;a.push({path:e,linesAdded:t.added,linesRemoved:t.removed,isBinary:t.isBinary,isLargeFile:o,isTruncated:c,isUntracked:i})}return a.sort((e,t)=>e.path.localeCompare(t.path)),{stats:t,files:a,hunks:n,loading:!1}},[e,n,i])}var H,U,W=e((()=>{H=t(g(),1),B(),U=400}));function fe(e){if(!e||typeof e!=`object`)return!1;let t=e,n=typeof t.filePath==`string`,r=Array.isArray(t.structuredPatch)&&t.structuredPatch.length>0,i=t.type===`create`&&typeof t.content==`string`;return n&&(r||i)}function pe(e){return`type`in e&&(e.type===`create`||e.type===`update`)}function me(e){let t=0,n=0;for(let r of e)for(let e of r.lines)e.startsWith(`+`)?t++:e.startsWith(`-`)&&n++;return{added:t,removed:n}}function he(e){if(e.type!==`user`)return``;let t=e.message.content,n=typeof t==`string`?t:``;return n.length<=30?n:`${n.slice(0,29)}…`}function G(e){let t=0,n=0;for(let r of e.files.values())t+=r.linesAdded,n+=r.linesRemoved;e.stats={filesChanged:e.files.size,linesAdded:t,linesRemoved:n}}function ge(e){let t=(0,K.useRef)({completedTurns:[],currentTurn:null,lastProcessedIndex:0,lastTurnIndex:0});return(0,K.useMemo)(()=>{let n=t.current;e.length<n.lastProcessedIndex&&(n.completedTurns=[],n.currentTurn=null,n.lastProcessedIndex=0,n.lastTurnIndex=0);for(let t=n.lastProcessedIndex;t<e.length;t++){let r=e[t];if(r?.type===`user`){if(!(r.toolUseResult||Array.isArray(r.message.content)&&r.message.content[0]?.type===`tool_result`)&&!r.isMeta)n.currentTurn&&n.currentTurn.files.size>0&&(G(n.currentTurn),n.completedTurns.push(n.currentTurn)),n.lastTurnIndex++,n.currentTurn={turnIndex:n.lastTurnIndex,userPromptPreview:he(r),timestamp:r.timestamp,files:new Map,stats:{filesChanged:0,linesAdded:0,linesRemoved:0}};else if(n.currentTurn&&r.toolUseResult){let e=r.toolUseResult;if(fe(e)){let{filePath:t,structuredPatch:r}=e,i=`type`in e&&e.type===`create`,a=n.currentTurn.files.get(t);if(a||(a={filePath:t,hunks:[],isNewFile:i,linesAdded:0,linesRemoved:0},n.currentTurn.files.set(t,a)),i&&r.length===0&&pe(e)){let t=e.content.split(`
5
- `),n={oldStart:0,oldLines:0,newStart:1,newLines:t.length,lines:t.map(e=>`+${e}`)};a.hunks.push(n),a.linesAdded+=t.length}else{a.hunks.push(...r);let{added:e,removed:t}=me(r);a.linesAdded+=e,a.linesRemoved+=t}i&&(a.isNewFile=!0)}}}}n.lastProcessedIndex=e.length;let r=[...n.completedTurns];return n.currentTurn&&n.currentTurn.files.size>0&&(G(n.currentTurn),r.push(n.currentTurn)),r.reverse()},[e])}var K,_e=e((()=>{K=t(g(),1)}));function ve({filePath:e,hunks:t,isLargeFile:n,isBinary:r,isTruncated:a,isUntracked:o}){let{columns:s}=_(),{firstLine:c,fileContent:l}=(0,q.useMemo)(()=>{if(!e)return{firstLine:null,fileContent:void 0};let t=S(ae(x(),e));return{firstLine:t?.split(`
6
- `)[0]??null,fileContent:t??void 0}},[e]);return o?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(p,{children:[(0,J.jsx)(m,{bold:!0,children:e}),(0,J.jsx)(m,{dimColor:!0,children:` (untracked)`})]}),(0,J.jsx)(f,{padding:4}),(0,J.jsxs)(p,{flexDirection:`column`,children:[(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`New file not yet staged.`}),(0,J.jsxs)(m,{dimColor:!0,italic:!0,children:["Run `git add ",e,"` to see line counts."]})]})]}):r?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsx)(p,{children:(0,J.jsx)(m,{bold:!0,children:e})}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`Binary file - cannot display diff`})})]}):n?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsx)(p,{children:(0,J.jsx)(m,{bold:!0,children:e})}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`Large file - diff exceeds 1 MB limit`})})]}):(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(p,{children:[(0,J.jsx)(m,{bold:!0,children:e}),a&&(0,J.jsx)(m,{dimColor:!0,children:` (truncated)`})]}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:t.length===0?(0,J.jsx)(m,{dimColor:!0,children:`No diff content`}):t.map((t,n)=>(0,J.jsx)(i,{patch:t,filePath:e,firstLine:c,fileContent:l,dim:!1,width:s-2-2},n))}),a&&(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`… diff truncated (exceeded 400 line limit)`})]})}var q,J,ye=e((()=>{q=t(g(),1),l(),v(),b(),C(),a(),J=y()}));function be({files:e,selectedIndex:t}){let{columns:n}=_(),{startIndex:r,endIndex:i}=(0,Y.useMemo)(()=>{if(e.length===0||e.length<=Z)return{startIndex:0,endIndex:e.length};let n=Math.max(0,t-Math.floor(Z/2)),r=n+Z;return r>e.length&&(r=e.length,n=Math.max(0,r-Z)),{startIndex:n,endIndex:r}},[e.length,t]);if(e.length===0)return(0,X.jsx)(m,{dimColor:!0,children:`No changed files`});let a=e.slice(r,i),o=r>0,s=i<e.length,c=e.length>Z,l=Math.max(20,n-16-3-4);return(0,X.jsxs)(p,{flexDirection:`column`,children:[c&&(0,X.jsx)(m,{dimColor:!0,children:o?` ↑ ${r} more ${A(r,`file`)}`:` `}),a.map((e,n)=>(0,X.jsx)(xe,{file:e,isSelected:r+n===t,maxPathWidth:l},e.path)),c&&(0,X.jsx)(m,{dimColor:!0,children:s?` ↓ ${e.length-i} more ${A(e.length-i,`file`)}`:` `})]})}function xe({file:e,isSelected:t,maxPathWidth:n}){let i=ne(e.path,n),a=`${t?`${r.pointer} `:` `}${i}`;return(0,X.jsxs)(p,{flexDirection:`row`,children:[(0,X.jsx)(m,{bold:t,color:t?`background`:void 0,inverse:t,children:a}),(0,X.jsx)(p,{flexGrow:1}),(0,X.jsx)(Se,{file:e,isSelected:t})]})}function Se({file:e,isSelected:t}){return e.isUntracked?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`untracked`}):e.isBinary?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`Binary file`}):e.isLargeFile?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`Large file modified`}):(0,X.jsxs)(m,{children:[e.linesAdded>0&&(0,X.jsxs)(m,{color:`diffAddedWord`,bold:t,children:[`+`,e.linesAdded]}),e.linesAdded>0&&e.linesRemoved>0&&` `,e.linesRemoved>0&&(0,X.jsxs)(m,{color:`diffRemovedWord`,bold:t,children:[`-`,e.linesRemoved]}),e.isTruncated&&(0,X.jsx)(m,{dimColor:!t,children:` (truncated)`})]})}var Y,X,Z,Ce=e((()=>{n(),Y=t(g(),1),l(),v(),re(),j(),X=y(),Z=5}));function we(e){let t=Array.from(e.files.values()).map(e=>({path:e.filePath,linesAdded:e.linesAdded,linesRemoved:e.linesRemoved,isBinary:!1,isLargeFile:!1,isTruncated:!1,isNewFile:e.isNewFile})).sort((e,t)=>e.path.localeCompare(t.path)),n=new Map;for(let t of e.files.values())n.set(t.filePath,t.hunks);return{stats:{filesCount:e.stats.filesChanged,linesAdded:e.stats.linesAdded,linesRemoved:e.stats.linesRemoved},files:t,hunks:n,loading:!1}}function Te({messages:e,onDone:t}){let n=V(),r=ge(e),[i,a]=(0,Q.useState)(`list`),[s,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(0),f=(0,Q.useMemo)(()=>[{type:`current`},...r.map(e=>({type:`turn`,turn:e}))],[r]),g=f[u],_=g?.type===`turn`?g.turn:null,v=(0,Q.useMemo)(()=>_?we(_):n,[_,n]),y=v.files[s],b=(0,Q.useMemo)(()=>y&&v.hunks.get(y.path)||[],[y,v.hunks]);(0,Q.useEffect)(()=>{u>=f.length&&d(Math.max(0,f.length-1))},[f.length,u]);let x=(0,Q.useRef)(u);(0,Q.useEffect)(()=>{x.current!==u&&(l(0),x.current=u)},[u]),o(`diff-dialog`),ee({"diff:previousSource":()=>{i===`detail`?a(`list`):i===`list`&&f.length>1&&d(e=>Math.max(0,e-1))},"diff:nextSource":()=>{i===`list`&&f.length>1&&d(e=>Math.min(f.length-1,e+1))},"diff:back":()=>{i===`detail`&&a(`list`)},"diff:viewDetails":()=>{i===`list`&&y&&a(`detail`)},"diff:previousFile":()=>{i===`list`&&l(e=>Math.max(0,e-1))},"diff:nextFile":()=>{i===`list`&&l(e=>Math.min(v.files.length-1,e+1))}},{context:`DiffDialog`});let S=v.stats?(0,$.jsxs)(m,{dimColor:!0,children:[v.stats.filesCount,` `,A(v.stats.filesCount,`file`),` changed`,v.stats.linesAdded>0&&(0,$.jsxs)(m,{color:`diffAddedWord`,children:[` +`,v.stats.linesAdded]}),v.stats.linesRemoved>0&&(0,$.jsxs)(m,{color:`diffRemovedWord`,children:[` -`,v.stats.linesRemoved]})]}):null,C=_?`Turn ${_.turnIndex}`:`Uncommitted changes`,w=_?_.userPromptPreview?`"${_.userPromptPreview}"`:``:`(git diff HEAD)`,T=f.length>1?(0,$.jsxs)(p,{children:[u>0&&(0,$.jsx)(m,{dimColor:!0,children:`◀ `}),f.map((e,t)=>{let n=t===u,r=e.type===`current`?`Current`:`T${e.turn.turnIndex}`;return(0,$.jsxs)(m,{dimColor:!n,bold:n,children:[t>0?` · `:``,r]},t)}),u<f.length-1&&(0,$.jsx)(m,{dimColor:!0,children:` ▶`})]}):null,E=c(`diff:dismiss`,`DiffDialog`,`esc`),D=v.loading?`Loading diff…`:_?`No file changes in this turn`:v.stats&&v.stats.filesCount>0&&v.files.length===0?`Too many files to display details`:`Working tree is clean`,O=(0,$.jsxs)(m,{children:[C,w&&(0,$.jsxs)(m,{dimColor:!0,children:[` `,w]})]});function k(){i===`detail`?a(`list`):t(`Diff dialog dismissed`,{display:`system`})}return(0,$.jsxs)(te,{title:O,onCancel:k,color:`background`,inputGuide:e=>e.pending?(0,$.jsxs)(m,{children:[`Press `,e.keyName,` again to exit`]}):i===`list`?(0,$.jsxs)(h,{children:[f.length>1&&(0,$.jsx)(m,{children:`←/→ source`}),(0,$.jsx)(m,{children:`↑/↓ select`}),(0,$.jsx)(m,{children:`Enter view`}),(0,$.jsxs)(m,{children:[E,` close`]})]}):(0,$.jsxs)(h,{children:[(0,$.jsx)(m,{children:`← back`}),(0,$.jsxs)(m,{children:[E,` close`]})]}),children:[T,S,v.files.length===0?(0,$.jsx)(p,{marginTop:1,children:(0,$.jsx)(m,{dimColor:!0,children:D})}):i===`list`?(0,$.jsx)(p,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(be,{files:v.files,selectedIndex:s})}):(0,$.jsx)(p,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(ve,{filePath:y?.path||``,hunks:b,isLargeFile:y?.isLargeFile,isBinary:y?.isBinary,isTruncated:y?.isTruncated,isUntracked:y?.isUntracked})})]})}var Q,$;e((()=>{Q=t(g(),1),u(),W(),_e(),v(),d(),s(),j(),ye(),Ce(),$=y()}))();export{Te as DiffDialog};
5
+ `),n={oldStart:0,oldLines:0,newStart:1,newLines:t.length,lines:t.map(e=>`+${e}`)};a.hunks.push(n),a.linesAdded+=t.length}else{a.hunks.push(...r);let{added:e,removed:t}=me(r);a.linesAdded+=e,a.linesRemoved+=t}i&&(a.isNewFile=!0)}}}}n.lastProcessedIndex=e.length;let r=[...n.completedTurns];return n.currentTurn&&n.currentTurn.files.size>0&&(G(n.currentTurn),r.push(n.currentTurn)),r.reverse()},[e])}var K,_e=e((()=>{K=t(g(),1)}));function ve({filePath:e,hunks:t,isLargeFile:n,isBinary:r,isTruncated:i,isUntracked:a}){let{columns:o}=_(),{firstLine:s,fileContent:l}=(0,q.useMemo)(()=>{if(!e)return{firstLine:null,fileContent:void 0};let t=S(ae(x(),e));return{firstLine:t?.split(`
6
+ `)[0]??null,fileContent:t??void 0}},[e]);return a?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(p,{children:[(0,J.jsx)(m,{bold:!0,children:e}),(0,J.jsx)(m,{dimColor:!0,children:` (untracked)`})]}),(0,J.jsx)(f,{padding:4}),(0,J.jsxs)(p,{flexDirection:`column`,children:[(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`New file not yet staged.`}),(0,J.jsxs)(m,{dimColor:!0,italic:!0,children:["Run `git add ",e,"` to see line counts."]})]})]}):r?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsx)(p,{children:(0,J.jsx)(m,{bold:!0,children:e})}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`Binary file - cannot display diff`})})]}):n?(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsx)(p,{children:(0,J.jsx)(m,{bold:!0,children:e})}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`Large file - diff exceeds 1 MB limit`})})]}):(0,J.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(p,{children:[(0,J.jsx)(m,{bold:!0,children:e}),i&&(0,J.jsx)(m,{dimColor:!0,children:` (truncated)`})]}),(0,J.jsx)(f,{padding:4}),(0,J.jsx)(p,{flexDirection:`column`,children:t.length===0?(0,J.jsx)(m,{dimColor:!0,children:`No diff content`}):t.map((t,n)=>(0,J.jsx)(c,{patch:t,filePath:e,firstLine:s,fileContent:l,dim:!1,width:o-2-2},n))}),i&&(0,J.jsx)(m,{dimColor:!0,italic:!0,children:`… diff truncated (exceeded 400 line limit)`})]})}var q,J,ye=e((()=>{q=t(g(),1),a(),v(),b(),C(),u(),J=y()}));function be({files:e,selectedIndex:t}){let{columns:n}=_(),{startIndex:r,endIndex:i}=(0,Y.useMemo)(()=>{if(e.length===0||e.length<=Z)return{startIndex:0,endIndex:e.length};let n=Math.max(0,t-Math.floor(Z/2)),r=n+Z;return r>e.length&&(r=e.length,n=Math.max(0,r-Z)),{startIndex:n,endIndex:r}},[e.length,t]);if(e.length===0)return(0,X.jsx)(m,{dimColor:!0,children:`No changed files`});let a=e.slice(r,i),o=r>0,s=i<e.length,c=e.length>Z,l=Math.max(20,n-16-3-4);return(0,X.jsxs)(p,{flexDirection:`column`,children:[c&&(0,X.jsx)(m,{dimColor:!0,children:o?` ↑ ${r} more ${A(r,`file`)}`:` `}),a.map((e,n)=>(0,X.jsx)(xe,{file:e,isSelected:r+n===t,maxPathWidth:l},e.path)),c&&(0,X.jsx)(m,{dimColor:!0,children:s?` ↓ ${e.length-i} more ${A(e.length-i,`file`)}`:` `})]})}function xe({file:e,isSelected:t,maxPathWidth:n}){let i=ne(e.path,n),a=`${t?`${r.pointer} `:` `}${i}`;return(0,X.jsxs)(p,{flexDirection:`row`,children:[(0,X.jsx)(m,{bold:t,color:t?`background`:void 0,inverse:t,children:a}),(0,X.jsx)(p,{flexGrow:1}),(0,X.jsx)(Se,{file:e,isSelected:t})]})}function Se({file:e,isSelected:t}){return e.isUntracked?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`untracked`}):e.isBinary?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`Binary file`}):e.isLargeFile?(0,X.jsx)(m,{dimColor:!t,italic:!0,children:`Large file modified`}):(0,X.jsxs)(m,{children:[e.linesAdded>0&&(0,X.jsxs)(m,{color:`diffAddedWord`,bold:t,children:[`+`,e.linesAdded]}),e.linesAdded>0&&e.linesRemoved>0&&` `,e.linesRemoved>0&&(0,X.jsxs)(m,{color:`diffRemovedWord`,bold:t,children:[`-`,e.linesRemoved]}),e.isTruncated&&(0,X.jsx)(m,{dimColor:!t,children:` (truncated)`})]})}var Y,X,Z,Ce=e((()=>{n(),Y=t(g(),1),a(),v(),re(),j(),X=y(),Z=5}));function we(e){let t=Array.from(e.files.values()).map(e=>({path:e.filePath,linesAdded:e.linesAdded,linesRemoved:e.linesRemoved,isBinary:!1,isLargeFile:!1,isTruncated:!1,isNewFile:e.isNewFile})).sort((e,t)=>e.path.localeCompare(t.path)),n=new Map;for(let t of e.files.values())n.set(t.filePath,t.hunks);return{stats:{filesCount:e.stats.filesChanged,linesAdded:e.stats.linesAdded,linesRemoved:e.stats.linesRemoved},files:t,hunks:n,loading:!1}}function Te({messages:e,onDone:t}){let n=V(),r=ge(e),[i,a]=(0,Q.useState)(`list`),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(0),f=(0,Q.useMemo)(()=>[{type:`current`},...r.map(e=>({type:`turn`,turn:e}))],[r]),g=f[u],_=g?.type===`turn`?g.turn:null,v=(0,Q.useMemo)(()=>_?we(_):n,[_,n]),y=v.files[c],b=(0,Q.useMemo)(()=>y&&v.hunks.get(y.path)||[],[y,v.hunks]);(0,Q.useEffect)(()=>{u>=f.length&&d(Math.max(0,f.length-1))},[f.length,u]);let x=(0,Q.useRef)(u);(0,Q.useEffect)(()=>{x.current!==u&&(l(0),x.current=u)},[u]),o(`diff-dialog`),ee({"diff:previousSource":()=>{i===`detail`?a(`list`):i===`list`&&f.length>1&&d(e=>Math.max(0,e-1))},"diff:nextSource":()=>{i===`list`&&f.length>1&&d(e=>Math.min(f.length-1,e+1))},"diff:back":()=>{i===`detail`&&a(`list`)},"diff:viewDetails":()=>{i===`list`&&y&&a(`detail`)},"diff:previousFile":()=>{i===`list`&&l(e=>Math.max(0,e-1))},"diff:nextFile":()=>{i===`list`&&l(e=>Math.min(v.files.length-1,e+1))}},{context:`DiffDialog`});let S=v.stats?(0,$.jsxs)(m,{dimColor:!0,children:[v.stats.filesCount,` `,A(v.stats.filesCount,`file`),` changed`,v.stats.linesAdded>0&&(0,$.jsxs)(m,{color:`diffAddedWord`,children:[` +`,v.stats.linesAdded]}),v.stats.linesRemoved>0&&(0,$.jsxs)(m,{color:`diffRemovedWord`,children:[` -`,v.stats.linesRemoved]})]}):null,C=_?`Turn ${_.turnIndex}`:`Uncommitted changes`,w=_?_.userPromptPreview?`"${_.userPromptPreview}"`:``:`(git diff HEAD)`,T=f.length>1?(0,$.jsxs)(p,{children:[u>0&&(0,$.jsx)(m,{dimColor:!0,children:`◀ `}),f.map((e,t)=>{let n=t===u,r=e.type===`current`?`Current`:`T${e.turn.turnIndex}`;return(0,$.jsxs)(m,{dimColor:!n,bold:n,children:[t>0?` · `:``,r]},t)}),u<f.length-1&&(0,$.jsx)(m,{dimColor:!0,children:` ▶`})]}):null,E=s(`diff:dismiss`,`DiffDialog`,`esc`),D=v.loading?`Loading diff…`:_?`No file changes in this turn`:v.stats&&v.stats.filesCount>0&&v.files.length===0?`Too many files to display details`:`Working tree is clean`,O=(0,$.jsxs)(m,{children:[C,w&&(0,$.jsxs)(m,{dimColor:!0,children:[` `,w]})]});function k(){i===`detail`?a(`list`):t(`Diff dialog dismissed`,{display:`system`})}return(0,$.jsxs)(te,{title:O,onCancel:k,color:`background`,inputGuide:e=>e.pending?(0,$.jsxs)(m,{children:[`Press `,e.keyName,` again to exit`]}):i===`list`?(0,$.jsxs)(h,{children:[f.length>1&&(0,$.jsx)(m,{children:`←/→ source`}),(0,$.jsx)(m,{children:`↑/↓ select`}),(0,$.jsx)(m,{children:`Enter view`}),(0,$.jsxs)(m,{children:[E,` close`]})]}):(0,$.jsxs)(h,{children:[(0,$.jsx)(m,{children:`← back`}),(0,$.jsxs)(m,{children:[E,` close`]})]}),children:[T,S,v.files.length===0?(0,$.jsx)(p,{marginTop:1,children:(0,$.jsx)(m,{dimColor:!0,children:D})}):i===`list`?(0,$.jsx)(p,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(be,{files:v.files,selectedIndex:c})}):(0,$.jsx)(p,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(ve,{filePath:y?.path||``,hunks:b,isLargeFile:y?.isLargeFile,isBinary:y?.isBinary,isTruncated:y?.isTruncated,isUntracked:y?.isUntracked})})]})}var Q,$;e((()=>{Q=t(g(),1),l(),W(),_e(),v(),d(),i(),j(),ye(),Ce(),$=y()}))();export{Te as DiffDialog};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./Doctor-D9F3tKsr.js";e();export{t as Doctor};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$i as o,Cl as s,Eh as c,IT as l,LT as u,Qi as d,RT as f,Th as p,Tl as m,_C as ee,__ as h,bC as g,fw as te,hy as _,lT as v,oT as y,pw as b,vC as x,v_ as S,vy as C,wl as w,xC as ne,xy as re,yC as ie,yy as ae,zS as oe,zT as se}from"./loadAgentsDir-C96o6gCj.js";import{Gt as ce,I as T,P as E,ai as D,t as O,x as k}from"./src-DL3w8VPk.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as j,Ut as M}from"./state-D5D6QpTX.js";import{Cn as N,On as P,R as F,V as I}from"./settings-BowI3jp-.js";import{l as L,o as R}from"./stringUtils-D7oJIyY2.js";import{Bn as z,Ln as B,_ as V,u as H}from"./model-BaMclMXn.js";import{n as U,t as W}from"./ValidationErrorsList-2QWIs_6h.js";import{f as G,g as le,h as ue,i as de,n as fe,o as pe,p as me,r as he}from"./pidLock-C1hmh3YQ.js";import{n as ge,t as _e}from"./useExitOnCtrlCDWithKeybindings-L5idX6Kz.js";import{n as ve,t as ye}from"./McpParsingWarnings-6ENzOklf.js";import{n as be,t as xe}from"./PressEnterToContinue-DZc_s_pE.js";import{n as Se,t as Ce}from"./useSettingsErrors-sbjsaT7k.js";import{n as we,t as Te}from"./shadowedRuleDetection-DEo1hvGi.js";import{n as Ee,r as De,t as K}from"./statusNoticeHelpers-BrpQWj0l.js";import{join as q}from"path";function Oe(){if(!se())return null;let e=l();if(e.length===0)return null;let t=e.filter(e=>e.severity===`error`),n=e.filter(e=>e.severity===`warning`);return(0,J.jsxs)(T,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(E,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{dimColor:!0,children:`Location: `}),(0,J.jsx)(E,{dimColor:!0,children:u()})]}),(0,J.jsxs)(T,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(T,{flexDirection:`column`,children:[(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{dimColor:!0,children:`└ `}),(0,J.jsx)(E,{color:`error`,children:`[Error]`}),(0,J.jsxs)(E,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(T,{marginLeft:3,children:(0,J.jsxs)(E,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(T,{flexDirection:`column`,children:[(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{dimColor:!0,children:`└ `}),(0,J.jsx)(E,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(E,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(T,{marginLeft:3,children:(0,J.jsxs)(E,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,ke=e((()=>{O(),f(),J=A()}));function Ae(){if(!y.isSupportedPlatform()||!y.isSandboxEnabledInSettings())return null;let e=y.checkDependencies(),t=e.errors.length>0,n=e.warnings.length>0;return!t&&!n?null:(0,Y.jsxs)(T,{flexDirection:`column`,children:[(0,Y.jsx)(E,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(E,{children:[`└ Status: `,(0,Y.jsx)(E,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(E,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(E,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(E,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,je=e((()=>{O(),v(),Y=A()}));async function Me(){let e=C(await ae());if(e.length===0)return null;let t=e.sort((e,t)=>t.content.length-e.content.length).map(e=>`${e.path}: ${e.content.length.toLocaleString()} chars`);return{type:`agentsmd_files`,severity:`warning`,message:e.length===1?`Large AGENTS.md file detected (${e[0].content.length.toLocaleString()} chars > ${_.toLocaleString()})`:`${e.length} large AGENTS.md files detected (each > ${_.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:_}}async function Ne(e){if(!e)return null;let t=Ee(e);if(t<=15e3)return null;let n=e.activeAgents.filter(e=>e.source!==`built-in`).map(e=>{let t=`${e.agentType}: ${e.whenToUse}`;return{name:e.agentType,tokens:o(t)}}).sort((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>`${e.name}: ~${e.tokens.toLocaleString()} tokens`);return n.length>5&&r.push(`(${n.length-5} more custom agents)`),{type:`agent_descriptions`,severity:`warning`,message:`Large agent descriptions (~${t.toLocaleString()} tokens > ${K.toLocaleString()})`,details:r,currentValue:t,threshold:K}}async function X(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await h(e,t,n,H());if(r<=Z)return null;let a=new Map;for(let e of i){let t=e.name.split(`__`)[1]||`unknown`,n=a.get(t)||{count:0,tokens:0};a.set(t,{count:n.count+1,tokens:n.tokens+e.tokens})}let o=Array.from(a.entries()).sort((e,t)=>t[1].tokens-e[1].tokens),s=o.slice(0,5).map(([e,t])=>`${e}: ${t.count} tools (~${t.tokens.toLocaleString()} tokens)`);return o.length>5&&s.push(`(${o.length-5} more servers)`),{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${r.toLocaleString()} tokens > ${Z.toLocaleString()})`,details:s,currentValue:r,threshold:Z}}catch{let e=r.reduce((e,t)=>e+o(((t.name?.length||0)+t.description.length).toString()),0);return e<=Z?null:{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${e.toLocaleString()} tokens estimated > ${Z.toLocaleString()})`,details:[`${r.length} MCP tools detected (token count estimated)`],currentValue:e,threshold:Z}}}async function Pe(e){let t=Te(await e(),{sandboxAutoAllowEnabled:y.isSandboxingEnabled()&&y.isAutoAllowBashIfSandboxedEnabled()});if(t.length===0)return null;let n=t.flatMap(e=>[`${I(e.rule.ruleValue)}: ${e.reason}`,` Fix: ${e.fix}`]);return{type:`unreachable_rules`,severity:`warning`,message:`${t.length} ${L(t.length,`unreachable permission rule`)} detected`,details:n,currentValue:t.length,threshold:0}}async function Fe(e,t,n){let[r,i,a,o]=await Promise.all([Me(),Ne(t),X(e,n,t),Pe(n)]);return{agentsMdWarning:r,agentWarning:i,mcpWarning:a,unreachableRulesWarning:o}}var Z,Ie=e((()=>{d(),S(),re(),V(),F(),we(),v(),De(),R(),Z=25e3}));function Le({onDone:e}){let t=c(e=>e.agentDefinitions),r=c(e=>e.mcp.tools),i=c(e=>e.toolPermissionContext),o=c(e=>e.plugins.errors);ge();let l=(0,Q.useMemo)(()=>r||[],[r]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=Se().filter(e=>e.mcpErrorMetadata===void 0),y=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:ee,upperLimit:x},{name:`TASK_MAX_OUTPUT_LENGTH`,default:s,upperLimit:w},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...B(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=ne(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{ue().then(d),(async()=>{let e=q(n(),`agents`),r=q(j(),`.workmate`,`agents`),{activeAgents:a,allAgents:o,failedFiles:s}=t,[c,u]=await Promise.all([P(e),P(r)]),d={activeAgents:a.map(e=>({agentType:e.agentType,source:e.source})),userAgentsDir:e,projectAgentsDir:r,userDirExists:c,projectDirExists:u,failedFiles:s};p(d);let f=await Fe(l,{activeAgents:a,allAgents:o,failedFiles:s},async()=>i);if(h(f),pe()){let e=q(G(),`claude`,`locks`),t=fe(e),n=he(e);_({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else _({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,l,t]);let b=(0,Q.useCallback)(()=>{e(`Work Mate diagnostics dismissed`,{display:`system`})},[e]);return ce({"confirm:yes":b,"confirm:no":b},{context:`Confirmation`}),u?(0,$.jsxs)(k,{children:[(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(E,{children:[`└ Currently running: `,u.installationType,` (`,u.version,`)`]}),u.packageManager&&(0,$.jsxs)(E,{children:[`└ Package manager: `,u.packageManager]}),(0,$.jsxs)(E,{children:[`└ Path: `,u.installationPath]}),(0,$.jsxs)(E,{children:[`└ Invoked: `,u.invokedBinary]}),(0,$.jsxs)(E,{children:[`└ Config install method: `,u.configInstallMethod]}),(0,$.jsxs)(E,{children:[`└ Search: `,u.ripgrepStatus.working?`OK`:`Not working`,` (`,u.ripgrepStatus.mode===`embedded`?`bundled`:u.ripgrepStatus.mode===`builtin`?`vendor`:u.ripgrepStatus.systemPath||`system`,`)`]}),u.ripgrepStatus.note&&(0,$.jsxs)(E,{color:`warning`,children:[`└ Note: `,u.ripgrepStatus.note]}),u.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{}),(0,$.jsxs)(E,{color:`warning`,children:[`Recommendation: `,u.recommendation.split(`
2
+ `)[0]]}),(0,$.jsx)(E,{dimColor:!0,children:u.recommendation.split(`
3
+ `)[1]})]}),u.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{}),(0,$.jsx)(E,{color:`warning`,children:`Warning: Multiple installations found`}),u.multipleInstallations.map((e,t)=>(0,$.jsxs)(E,{children:[`└ `,e.type,` at `,e.path]},t))]}),u.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{}),u.warnings.map((e,t)=>(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsxs)(E,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(E,{children:[`Fix: `,e.fix]})]},t))]}),v.length>0&&(0,$.jsxs)(T,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(E,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(W,{errors:v})]})]}),(0,$.jsx)(Ae,{}),(0,$.jsx)(ye,{}),(0,$.jsx)(Oe,{}),y.length>0&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,children:`Environment Variables`}),y.map((e,t)=>(0,$.jsxs)(E,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(E,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),g?.enabled&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,children:`Version Locks`}),g.staleLocksCleaned>0&&(0,$.jsxs)(E,{dimColor:!0,children:[`└ Cleaned `,g.staleLocksCleaned,` stale lock(s)`]}),g.locks.length===0?(0,$.jsx)(E,{dimColor:!0,children:`└ No active version locks`}):g.locks.map((e,t)=>(0,$.jsxs)(E,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(E,{children:`(running)`}):(0,$.jsx)(E,{color:`warning`,children:`(stale)`})]},t))]}),f?.failedFiles&&f.failedFiles.length>0&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(E,{color:`error`,children:[`└ Failed to parse `,f.failedFiles.length,` agent file(s):`]}),f.failedFiles.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),o.length>0&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(E,{color:`error`,children:[`└ `,o.length,` plugin error(s) detected:`]}),o.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,te(e)]},t))]}),m?.unreachableRulesWarning&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(E,{children:[`└`,` `,(0,$.jsxs)(E,{color:`warning`,children:[a.warning,` `,m.unreachableRulesWarning.message]})]}),m.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m&&(m.agentsMdWarning||m.agentWarning||m.mcpWarning)&&(0,$.jsxs)(T,{flexDirection:`column`,children:[(0,$.jsx)(E,{bold:!0,children:`Context Usage Warnings`}),m.agentsMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(E,{children:[`└`,` `,(0,$.jsxs)(E,{color:`warning`,children:[a.warning,` `,m.agentsMdWarning.message]})]}),(0,$.jsxs)(E,{children:[` `,`└ Files:`]}),m.agentsMdWarning.details.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(E,{children:[`└`,` `,(0,$.jsxs)(E,{color:`warning`,children:[a.warning,` `,m.agentWarning.message]})]}),(0,$.jsxs)(E,{children:[` `,`└ Top contributors:`]}),m.agentWarning.details.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(E,{children:[`└`,` `,(0,$.jsxs)(E,{color:`warning`,children:[a.warning,` `,m.mcpWarning.message]})]}),(0,$.jsxs)(E,{children:[` `,`└ MCP servers:`]}),m.mcpWarning.details.map((e,t)=>(0,$.jsxs)(E,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(T,{children:(0,$.jsx)(xe,{})})]}):(0,$.jsx)(k,{children:(0,$.jsx)(E,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,Re=e((()=>{i(),Q=t(D(),1),ke(),ve(),z(),r(),M(),O(),be(),je(),U(),Ce(),_e(),oe(),p(),b(),Ie(),le(),g(),N(),de(),ie(),m(),me(),$=A()}));export{Re as n,Le as t};
@@ -0,0 +1,2 @@
1
+ import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{Du as r,Ed as i,Od as a,Ou as o,St as s,Tt as c,aC as l,bT as u,br as d,ft as f,iC as p,lu as m,mi as h,nE as g,rE as _,su as v,wt as y,xT as b,yt as x}from"./loadAgentsDir-C96o6gCj.js";import{I as S,P as C,ai as w,t as T,y as E}from"./src-DL3w8VPk.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{c as O,i as k}from"./debug-D58GQBDG.js";import{i as A,t as j}from"./execFileNoThrow-B_KRY4cT.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(d(),e(h)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,i]=(0,I.useState)(`loading`),[a,o]=(0,I.useState)([]),[s,u]=(0,I.useState)(0),[d,p]=(0,I.useState)(),m=x();if((0,I.useEffect)(()=>{async function e(){let e=[],t=await j(`git`,[`status`,`--porcelain`]);if(t.stdout&&(e=t.stdout.split(`
2
+ `).filter(e=>e.trim()!==``),o(e)),m){let{stdout:t}=await j(`git`,[`rev-list`,`--count`,`${m.originalHeadCommit}..HEAD`]),n=parseInt(t.trim(),10)||0;if(u(n),e.length===0&&n===0){i(`removing`),f().then(()=>{process.chdir(m.originalCwd),l(m.originalCwd),P(),g.cache.clear?.(),p(`Worktree removed (no changes)`)}).catch(e=>{O(`Failed to clean up worktree: ${e}`,{level:`error`}),p(`Worktree cleanup failed, exiting anyway`)}).then(()=>{i(`done`)});return}else i(`asking`)}}e()},[m]),(0,I.useEffect)(()=>{n===`done`&&e(d)},[n,e,d]),!m)return e(`No active worktree session found`,{display:`system`}),null;if(n===`loading`||n===`done`)return null;async function h(e){if(!m)return;let t=!!m.tmuxSessionName;if(e===`keep`||e===`keep-with-tmux`)i(`keeping`),N(`tengu_worktree_kept`,{commits:s,changed_files:a.length}),await y(),process.chdir(m.originalCwd),l(m.originalCwd),P(),g.cache.clear?.(),p(t?`Worktree kept. Your work is saved at ${m.worktreePath} on branch ${m.worktreeBranch}. Reattach to tmux session with: tmux attach -t ${m.tmuxSessionName}`:`Worktree kept. Your work is saved at ${m.worktreePath} on branch ${m.worktreeBranch}`),i(`done`);else if(e===`keep-kill-tmux`)i(`keeping`),N(`tengu_worktree_kept`,{commits:s,changed_files:a.length}),m.tmuxSessionName&&await c(m.tmuxSessionName),await y(),process.chdir(m.originalCwd),l(m.originalCwd),P(),g.cache.clear?.(),p(`Worktree kept at ${m.worktreePath} on branch ${m.worktreeBranch}. Tmux session terminated.`),i(`done`);else if(e===`remove`||e===`remove-with-tmux`){i(`removing`),N(`tengu_worktree_removed`,{commits:s,changed_files:a.length}),m.tmuxSessionName&&await c(m.tmuxSessionName);try{await f(),process.chdir(m.originalCwd),l(m.originalCwd),P(),g.cache.clear?.()}catch(e){O(`Failed to clean up worktree: ${e}`,{level:`error`}),p(`Worktree cleanup failed, exiting anyway`),i(`done`);return}let e=t?` Tmux session terminated.`:``;s>0&&a.length>0?p(`Worktree removed. ${s} ${s===1?`commit`:`commits`} and uncommitted changes were discarded.${e}`):s>0?p(`Worktree removed. ${s} ${s===1?`commit`:`commits`} on ${m.worktreeBranch} ${s===1?`was`:`were`} discarded.${e}`):a.length>0?p(`Worktree removed. Uncommitted changes were discarded.${e}`):p(`Worktree removed.${e}`),i(`done`)}}if(n===`keeping`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(v,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(v,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let _=m.worktreeBranch,b=a.length>0,w=s>0,T=``;T=b&&w?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`} and ${s} ${s===1?`commit`:`commits`} on ${_}. All will be lost if you remove.`:b?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${s} ${s===1?`commit`:`commits`} on ${_}. The branch will be deleted if you remove the worktree.`:`You are working in a worktree. Keep it to continue working there, or remove it to clean up.`;function D(){if(t){t();return}h(`keep`)}let k=b||w?`All changes and commits will be lost.`:`Clean up the worktree directory.`,A=!!m.tmuxSessionName,M=A?[{label:`Keep worktree and tmux session`,value:`keep-with-tmux`,description:`Stays at ${m.worktreePath}. Reattach with: tmux attach -t ${m.tmuxSessionName}`},{label:`Keep worktree, kill tmux session`,value:`keep-kill-tmux`,description:`Keeps worktree at ${m.worktreePath}, terminates tmux session.`},{label:`Remove worktree and tmux session`,value:`remove-with-tmux`,description:k}]:[{label:`Keep worktree`,value:`keep`,description:`Stays at ${m.worktreePath}`},{label:`Remove worktree`,value:`remove`,description:k}];return(0,L.jsx)(E,{title:`Exiting worktree session`,subtitle:T,onCancel:D,children:(0,L.jsx)(r,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:h})})}var I,L,R=t((()=>{I=n(w(),1),M(),k(),T(),A(),_(),p(),s(),o(),m(),L=D()}));function z(){return b(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await i(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{u(),a(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Qu as t,Zu as n}from"./loadAgentsDir-DaNpxaO-.js";import{D as r,I as i,Lt as a,P as o,T as s,ai as c,t as l,y as u}from"./src-DL3w8VPk2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{n as f,r as p}from"./analytics-DJobLaWP.js";import{i as m,o as h,r as g,s as _,t as v}from"./grove-CYE1Cfcz.js";var y=e(c(),1);f(),l(),n();var b=d(),x=` _____________
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Du as t,Eu as n}from"./loadAgentsDir-C96o6gCj.js";import{D as r,I as i,Lt as a,P as o,T as s,ai as c,t as l,y as u}from"./src-DL3w8VPk.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{n as f,r as p}from"./analytics-DJobLaWP.js";import{i as m,o as h,r as g,s as _,t as v}from"./grove-DqTnK9nn.js";var y=e(c(),1);f(),l(),n();var b=d(),x=` _____________
2
2
  | \\ \\
3
3
  | NEW TERMS \\__\\
4
4
  | |
@@ -1,2 +1,2 @@
1
- import{l as e,o as t}from"./envUtils-DcaKZlRU.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{JC as o,qC as s}from"./loadAgentsDir-DaNpxaO-.js";import{C as c,c as l,i as u,x as d}from"./debug-D58GQBDG.js";import{O as f,k as p}from"./git-By_J4XJL.js";import{n as m,r as h}from"./analytics-DJobLaWP.js";import{c as g,h as _,l as v,m as y,s as b}from"./proxy-BhIc7-mj.js";import{C as x,S,f as C,g as w,u as T}from"./sessionState-CQhbGfmh.js";import{n as E,t as D}from"./rcDebugLog-DSchf3Hs.js";import{r as O}from"./ccrClient-DO563xlf.js";a(),x(),m(),o(),u(),D(),f(),t(),_(),v(),T(),d(),n();var k=`{"type":"keep_alive"}
1
+ import{l as e,o as t}from"./envUtils-DcaKZlRU.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{CC as o,SC as s}from"./loadAgentsDir-C96o6gCj.js";import{C as c,c as l,i as u,x as d}from"./debug-D58GQBDG.js";import{O as f,k as p}from"./git-Wid-XppW.js";import{n as m,r as h}from"./analytics-DJobLaWP.js";import{c as g,h as _,l as v,m as y,s as b}from"./proxy-BhIc7-mj.js";import{C as x,S,f as C,g as w,u as T}from"./sessionState-8jutEorw.js";import{n as E,t as D}from"./rcDebugLog-DSchf3Hs.js";import{r as O}from"./ccrClient-JnhF5b3z.js";a(),x(),m(),o(),u(),D(),f(),t(),_(),v(),T(),d(),n();var k=`{"type":"keep_alive"}
2
2
  `,A=1e3,j=1e3,M=3e4,N=6e5,P=1e4,F=12e4,I=M*2,L=new Set([1002,4001,4003]),R=class{constructor(e,t={},n,i,a){r(this,`ws`,null),r(this,`lastSentId`,null),r(this,`url`,void 0),r(this,`state`,`idle`),r(this,`onData`,void 0),r(this,`onCloseCallback`,void 0),r(this,`onConnectCallback`,void 0),r(this,`headers`,void 0),r(this,`sessionId`,void 0),r(this,`autoReconnect`,void 0),r(this,`isBridge`,void 0),r(this,`reconnectAttempts`,0),r(this,`reconnectStartTime`,null),r(this,`reconnectTimer`,null),r(this,`lastReconnectAttemptTime`,null),r(this,`lastActivityTime`,0),r(this,`pingInterval`,null),r(this,`pongReceived`,!0),r(this,`keepAliveInterval`,null),r(this,`messageBuffer`,void 0),r(this,`isBunWs`,!1),r(this,`connectStartTime`,0),r(this,`refreshHeaders`,void 0),r(this,`onBunOpen`,()=>{this.handleOpenEvent(),this.lastSentId&&this.replayBufferedMessages(``)}),r(this,`onBunMessage`,e=>{let t=typeof e.data==`string`?e.data:String(e.data);this.lastActivityTime=Date.now(),p(`info`,`cli_websocket_message_received`,{length:t.length}),this.onData&&this.onData(t)}),r(this,`onBunError`,()=>{l(`WebSocketTransport: Error`,{level:`error`}),p(`error`,`cli_websocket_connect_error`)}),r(this,`onBunClose`,e=>{let t=e.code===1e3||e.code===1001;l(`WebSocketTransport: Closed: ${e.code}`,t?void 0:{level:`error`}),p(`error`,`cli_websocket_connect_closed`),this.handleConnectionError(e.code)}),r(this,`onNodeOpen`,()=>{let e=this.ws;if(this.handleOpenEvent(),!e)return;let t=e.upgradeReq;if(t?.headers?.[`x-last-request-id`]){let e=t.headers[`x-last-request-id`];this.replayBufferedMessages(e)}}),r(this,`onNodeMessage`,e=>{let t=e.toString();this.lastActivityTime=Date.now(),p(`info`,`cli_websocket_message_received`,{length:t.length}),this.onData&&this.onData(t)}),r(this,`onNodeError`,e=>{l(`WebSocketTransport: Error: ${e.message}`,{level:`error`}),p(`error`,`cli_websocket_connect_error`)}),r(this,`onNodeClose`,(e,t)=>{let n=e===1e3||e===1001;l(`WebSocketTransport: Closed: ${e}`,n?void 0:{level:`error`}),p(`error`,`cli_websocket_connect_closed`),this.handleConnectionError(e)}),r(this,`onPong`,()=>{this.pongReceived=!0}),this.url=e,this.headers=t,this.sessionId=n,this.refreshHeaders=i,this.autoReconnect=a?.autoReconnect??!0,this.isBridge=a?.isBridge??!1,this.messageBuffer=new s(A)}async connect(){if(this.state!==`idle`&&this.state!==`reconnecting`){l(`WebSocketTransport: Cannot connect, current state is ${this.state}`,{level:`error`}),p(`error`,`cli_websocket_connect_failed`);return}this.state=`reconnecting`,this.connectStartTime=Date.now(),l(`WebSocketTransport: Opening ${this.url.href}`),p(`info`,`cli_websocket_connect_opening`);let e={...this.headers};if(this.lastSentId&&(e[`X-Last-Request-Id`]=this.lastSentId,l(`WebSocketTransport: Adding X-Last-Request-Id header: ${this.lastSentId}`)),typeof Bun<`u`){let t=new globalThis.WebSocket(this.url.href,{headers:e,proxy:g(this.url.href),tls:y()||void 0});this.ws=t,this.isBunWs=!0,t.addEventListener(`open`,this.onBunOpen),t.addEventListener(`message`,this.onBunMessage),t.addEventListener(`error`,this.onBunError),t.addEventListener(`close`,this.onBunClose),t.addEventListener(`pong`,this.onPong)}else{let{default:t}=await import(`./wrapper-K8ZapJVu.js`),n=new t(this.url.href,{headers:e,agent:b(this.url.href),...y()});this.ws=n,this.isBunWs=!1,n.on(`open`,this.onNodeOpen),n.on(`message`,this.onNodeMessage),n.on(`error`,this.onNodeError),n.on(`close`,this.onNodeClose),n.on(`pong`,this.onPong)}}handleOpenEvent(){let e=Date.now()-this.connectStartTime;l(`WebSocketTransport: Connected`),p(`info`,`cli_websocket_connect_connected`,{duration_ms:e}),this.isBridge&&this.reconnectStartTime!==null&&h(`tengu_ws_transport_reconnected`,{attempts:this.reconnectAttempts,downtimeMs:Date.now()-this.reconnectStartTime}),this.reconnectAttempts=0,this.reconnectStartTime=null,this.lastReconnectAttemptTime=null,this.lastActivityTime=Date.now(),this.state=`connected`,this.onConnectCallback?.(),this.startPingInterval(),this.startKeepaliveInterval(),C(()=>{this.write({type:`keep_alive`})})}sendLine(e){if(!this.ws||this.state!==`connected`)return l(`WebSocketTransport: Not connected`),p(`info`,`cli_websocket_send_not_connected`),!1;try{return this.ws.send(e),this.lastActivityTime=Date.now(),!0}catch(e){return l(`WebSocketTransport: Failed to send: ${e}`,{level:`error`}),p(`error`,`cli_websocket_send_error`),this.handleConnectionError(),!1}}removeWsListeners(e){if(this.isBunWs){let t=e;t.removeEventListener(`open`,this.onBunOpen),t.removeEventListener(`message`,this.onBunMessage),t.removeEventListener(`error`,this.onBunError),t.removeEventListener(`close`,this.onBunClose),t.removeEventListener(`pong`,this.onPong)}else{let t=e;t.off(`open`,this.onNodeOpen),t.off(`message`,this.onNodeMessage),t.off(`error`,this.onNodeError),t.off(`close`,this.onNodeClose),t.off(`pong`,this.onPong)}}doDisconnect(){this.stopPingInterval(),this.stopKeepaliveInterval(),w(),this.ws&&(this.removeWsListeners(this.ws),this.ws.close(),this.ws=null)}handleConnectionError(e){if(E(`WS handleConnectionError: code=${e} state=${this.state} url=${this.url.href.replace(/token=[^&]+/,`token=***`)} msSinceLastActivity=${this.lastActivityTime>0?Date.now()-this.lastActivityTime:-1} reconnectAttempts=${this.reconnectAttempts}`),l(`WebSocketTransport: Disconnected from ${this.url.href}`+(e==null?``:` (code ${e})`)),p(`info`,`cli_websocket_disconnected`),this.isBridge&&h(`tengu_ws_transport_closed`,{closeCode:e,msSinceLastActivity:this.lastActivityTime>0?Date.now()-this.lastActivityTime:-1,wasConnected:this.state===`connected`,reconnectAttempts:this.reconnectAttempts}),this.doDisconnect(),this.state===`closing`||this.state===`closed`)return;let t=!1;if(e===4003&&this.refreshHeaders){let e=this.refreshHeaders();e.Authorization!==this.headers.Authorization&&(Object.assign(this.headers,e),t=!0,l(`WebSocketTransport: 4003 received but headers refreshed, scheduling reconnect`),p(`info`,`cli_websocket_4003_token_refreshed`))}if(e!=null&&L.has(e)&&!t){l(`WebSocketTransport: Permanent close code ${e}, not reconnecting`,{level:`error`}),p(`error`,`cli_websocket_permanent_close`,{closeCode:e}),this.state=`closed`,this.onCloseCallback?.(e);return}if(!this.autoReconnect){this.state=`closed`,this.onCloseCallback?.(e);return}let n=Date.now();this.reconnectStartTime||(this.reconnectStartTime=n),this.lastReconnectAttemptTime!==null&&n-this.lastReconnectAttemptTime>I&&(l(`WebSocketTransport: Detected system sleep (${Math.round((n-this.lastReconnectAttemptTime)/1e3)}s gap), resetting reconnection budget`),p(`info`,`cli_websocket_sleep_detected`,{gapMs:n-this.lastReconnectAttemptTime}),this.reconnectStartTime=n,this.reconnectAttempts=0),this.lastReconnectAttemptTime=n;let r=n-this.reconnectStartTime;if(r<N){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),!t&&this.refreshHeaders){let e=this.refreshHeaders();Object.assign(this.headers,e),l(`WebSocketTransport: Refreshed headers for reconnect`)}this.state=`reconnecting`,this.reconnectAttempts++;let e=Math.min(j*2**(this.reconnectAttempts-1),M),n=Math.max(0,e+e*.25*(2*Math.random()-1));l(`WebSocketTransport: Reconnecting in ${Math.round(n)}ms (attempt ${this.reconnectAttempts}, ${Math.round(r/1e3)}s elapsed)`),p(`error`,`cli_websocket_reconnect_attempt`,{reconnectAttempts:this.reconnectAttempts}),this.isBridge&&h(`tengu_ws_transport_reconnecting`,{attempt:this.reconnectAttempts,elapsedMs:r,delayMs:Math.round(n)}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},n)}else l(`WebSocketTransport: Reconnection time budget exhausted after ${Math.round(r/1e3)}s for ${this.url.href}`,{level:`error`}),p(`error`,`cli_websocket_reconnect_exhausted`,{reconnectAttempts:this.reconnectAttempts,elapsedMs:r}),this.state=`closed`,this.onCloseCallback&&this.onCloseCallback(e)}close(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopPingInterval(),this.stopKeepaliveInterval(),w(),this.state=`closing`,this.doDisconnect()}replayBufferedMessages(e){let t=this.messageBuffer.toArray();if(t.length===0)return;let n=0;if(e){let r=t.findIndex(t=>`uuid`in t&&t.uuid===e);if(r>=0){n=r+1;let e=t.slice(n);this.messageBuffer.clear(),this.messageBuffer.addAll(e),e.length===0&&(this.lastSentId=null),l(`WebSocketTransport: Evicted ${n} confirmed messages, ${e.length} remaining`),p(`info`,`cli_websocket_evicted_confirmed_messages`,{evicted:n,remaining:e.length})}}let r=t.slice(n);if(r.length===0){l(`WebSocketTransport: No new messages to replay`),p(`info`,`cli_websocket_no_messages_to_replay`);return}l(`WebSocketTransport: Replaying ${r.length} buffered messages`),p(`info`,`cli_websocket_messages_to_replay`,{count:r.length});for(let e of r){let t=`${c(e)}\n`;if(!this.sendLine(t)){this.handleConnectionError();break}}}isConnectedStatus(){return this.state===`connected`}isClosedStatus(){return this.state===`closed`}setOnData(e){this.onData=e}setOnConnect(e){this.onConnectCallback=e}setOnClose(e){this.onCloseCallback=e}getStateLabel(){return this.state}async write(e){`uuid`in e&&typeof e.uuid==`string`&&(this.messageBuffer.add(e),this.lastSentId=e.uuid);let t=`${c(e)}\n`;if(this.state!==`connected`)return;let n=this.sessionId?` session=${this.sessionId}`:``,r=this.getControlMessageDetailLabel(e);l(`WebSocketTransport: Sending message type=${e.type}${n}${r}`),this.sendLine(t)}getControlMessageDetailLabel(e){if(e.type===`control_request`){let{request_id:t,request:n}=e,r=n.subtype===`can_use_tool`?n.tool_name:``;return` subtype=${n.subtype} request_id=${t}${r?` tool=${r}`:``}`}if(e.type===`control_response`){let{subtype:t,request_id:n}=e.response;return` subtype=${t} request_id=${n}`}return``}startPingInterval(){this.stopPingInterval(),this.pongReceived=!0;let e=Date.now();this.pingInterval=setInterval(()=>{if(this.state===`connected`&&this.ws){let t=Date.now(),n=t-e;if(e=t,n>I){l(`WebSocketTransport: ${Math.round(n/1e3)}s tick gap detected — process was suspended, forcing reconnect`),p(`info`,`cli_websocket_sleep_detected_on_ping`,{gapMs:n}),this.handleConnectionError();return}if(!this.pongReceived){l(`WebSocketTransport: No pong received, connection appears dead`,{level:`error`}),p(`error`,`cli_websocket_pong_timeout`),this.handleConnectionError();return}this.pongReceived=!1;try{this.ws.ping?.()}catch(e){l(`WebSocketTransport: Ping failed: ${e}`,{level:`error`}),p(`error`,`cli_websocket_ping_failed`)}}},P)}stopPingInterval(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=null)}startKeepaliveInterval(){this.stopKeepaliveInterval(),!e(process.env.CLAUDE_CODE_REMOTE)&&(this.keepAliveInterval=setInterval(()=>{if(this.state===`connected`&&this.ws)try{this.ws.send(k),this.lastActivityTime=Date.now(),l(`WebSocketTransport: Sent periodic keep_alive data frame`)}catch(e){l(`WebSocketTransport: Periodic keep_alive failed: ${e}`,{level:`error`}),p(`error`,`cli_websocket_keepalive_failed`)}},F))}stopKeepaliveInterval(){this.keepAliveInterval&&(clearInterval(this.keepAliveInterval),this.keepAliveInterval=null)}};u(),D(),f(),n();var z=100,B=15e3,V=3e3,H=class extends R{constructor(e,t={},n,i,a){super(e,t,n,i,a),r(this,`postUrl`,void 0),r(this,`uploader`,void 0),r(this,`streamEventBuffer`,[]),r(this,`streamEventTimer`,null);let{maxConsecutiveFailures:o,onBatchDropped:s}=a??{};this.postUrl=U(e),this.uploader=new O({maxBatchSize:500,maxQueueSize:1e4,baseDelayMs:500,maxDelayMs:8e3,jitterMs:1e3,maxConsecutiveFailures:o,onBatchDropped:(e,t)=>{p(`error`,`cli_hybrid_batch_dropped_max_failures`,{batchSize:e,failures:t}),s?.(e,t)},send:e=>this.postOnce(e)}),l(`HybridTransport: POST URL = ${this.postUrl}`),p(`info`,`cli_hybrid_transport_initialized`)}async write(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>this.flushStreamEvents(),z));return}return await this.uploader.enqueue([...this.takeStreamEvents(),e]),this.uploader.flush()}async writeBatch(e){return await this.uploader.enqueue([...this.takeStreamEvents(),...e]),this.uploader.flush()}get droppedBatchCount(){return this.uploader.droppedBatchCount}flush(){return this.uploader.enqueue(this.takeStreamEvents()),this.uploader.flush()}takeStreamEvents(){this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null);let e=this.streamEventBuffer;return this.streamEventBuffer=[],e}flushStreamEvents(){this.streamEventTimer=null,this.uploader.enqueue(this.takeStreamEvents())}close(){this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[];let e=this.uploader,t;Promise.race([e.flush(),new Promise(e=>{t=setTimeout(e,V)})]).finally(()=>{clearTimeout(t),e.close()}),super.close()}async postOnce(e){let t=S();if(!t){l(`HybridTransport: No session token available for POST`),p(`warn`,`cli_hybrid_post_no_token`);return}let n={Authorization:`Bearer ${t}`,"Content-Type":`application/json`},r;try{r=await i.post(this.postUrl,{events:e},{headers:n,validateStatus:()=>!0,timeout:B})}catch(e){throw l(`HybridTransport: POST error: ${e.message}`),p(`warn`,`cli_hybrid_post_network_error`),e}if(r.status>=200&&r.status<300){l(`HybridTransport: POST success count=${e.length}`);return}if(r.status>=400&&r.status<500&&r.status!==429){E(`Hybrid POST ${r.status}: url=${this.postUrl.replace(/token=[^&]+/,`token=***`)} events=${e.length} body=${JSON.stringify(r.data).slice(0,200)}`),l(`HybridTransport: POST returned ${r.status} (permanent), dropping`),p(`warn`,`cli_hybrid_post_client_error`,{status:r.status});return}throw l(`HybridTransport: POST returned ${r.status} (retryable)`),p(`warn`,`cli_hybrid_post_retryable_error`,{status:r.status}),Error(`POST failed with ${r.status}`)}};function U(e){let t=e.protocol===`wss:`?`https:`:`http:`,n=e.pathname;return n=n.replace(`/ws/`,`/session/`),n.endsWith(`/events`)||(n=n.endsWith(`/`)?`${n}events`:`${n}/events`),`${t}//${e.host}${n}${e.search}`}export{R as n,H as t};
@@ -0,0 +1 @@
1
+ import{Du as e,Eu as t,Th as n,iu as r,ru as i,wh as a}from"./loadAgentsDir-C96o6gCj.js";import{I as o,P as s,kn as c,t as l,y as u}from"./src-DL3w8VPk.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{C as f,T as p,x as m}from"./debug-D58GQBDG.js";import{t as h}from"./renderOptions-D-aQZbzS.js";l(),r(),n(),m(),t();var g=d();function _({filePath:t,errorDescription:n,onExit:r,onReset:i}){return(0,g.jsxs)(u,{title:`Configuration Error`,color:`error`,onCancel:r,children:[(0,g.jsxs)(o,{flexDirection:`column`,gap:1,children:[(0,g.jsxs)(s,{children:[`The configuration file at `,(0,g.jsx)(s,{bold:!0,children:t}),` contains invalid JSON.`]}),(0,g.jsx)(s,{children:n})]}),(0,g.jsxs)(o,{flexDirection:`column`,children:[(0,g.jsx)(s,{bold:!0,children:`Choose an option:`}),(0,g.jsx)(e,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Reset with default configuration`,value:`reset`}],onChange:e=>{e===`exit`?r():i()},onCancel:r})]})]})}var v=`dark`;async function y({error:e}){let t={...h(!1),theme:v};await new Promise(async n=>{let{unmount:r}=await c((0,g.jsx)(a,{children:(0,g.jsx)(i,{children:(0,g.jsx)(_,{filePath:e.filePath,errorDescription:e.message,onExit:()=>{r(),n(),process.exit(1)},onReset:()=>{p(e.filePath,f(e.defaultConfig,null,2),{flush:!1,encoding:`utf8`}),r(),n(),process.exit(0)}})})}),t)})}export{y as showInvalidConfigDialog};
@@ -0,0 +1 @@
1
+ import{Du as e,Eu as t}from"./loadAgentsDir-C96o6gCj.js";import{P as n,t as r,y as i}from"./src-DL3w8VPk.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{n as o,t as s}from"./ValidationErrorsList-2QWIs_6h.js";r(),t(),o();var c=a();function l({settingsErrors:t,onContinue:r,onExit:a}){function o(e){e===`exit`?a():r()}return(0,c.jsxs)(i,{title:`Settings Error`,onCancel:a,color:`warning`,children:[(0,c.jsx)(s,{errors:t}),(0,c.jsx)(n,{dimColor:!0,children:`Files with errors are skipped entirely, not just the invalid settings.`}),(0,c.jsx)(e,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Continue without these settings`,value:`continue`}],onChange:o})]})}export{l as InvalidSettingsDialog};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$b as n,Bb as r,CT as i,Dh as a,Eh as o,Jy as s,Oh as c,Pb as l,Qb as u,Qy as d,ST as f,Td as p,Th as m,Xy as h,Zy as g,ab as _,ax as v,dS as y,dx as b,eb as x,ex as ee,fS as S,fx as C,gS as w,hS as te,hx as T,ob as ne,ox as re,px as ie,qb as E,rb as D,sx as O,tb as k,wd as A}from"./loadAgentsDir-C96o6gCj.js";import{ai as j}from"./src-DL3w8VPk.js";import{t as M}from"./jsx-runtime-Bb4Xn-E0.js";import{Ut as N,ft as ae}from"./state-D5D6QpTX.js";import{P,R as oe,c as se,i as ce}from"./debug-D58GQBDG.js";import{rt as le,tt as F}from"./settings-BowI3jp-.js";import{c as I,l as L,o as R}from"./log-CZ7ploQm.js";import{n as z,r as B}from"./analytics-DJobLaWP.js";import{o as V,t as H}from"./localSearch-DLz5IGGu.js";import{n as U,t as ue}from"./omit-B7eQ9q0x.js";function W(e){let t=`plugin`in e?e.plugin:`no-plugin`;return`${e.type}:${e.source}:${t}`}function G(e,t){t.length!==0&&e(e=>{let n=new Set(e.plugins.errors.map(e=>W(e))),r=t.filter(e=>!n.has(W(e)));return r.length===0?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,...r]}}})}function de(e,t=!1){let f=a(),m=o(e=>e.authVersion),_=o(e=>e.mcp.pluginReconnectKey),w=c(),T=(0,K.useRef)(new Map),{addNotification:re}=p(),E=(0,K.useRef)([]),k=(0,K.useRef)(null),A=(0,K.useCallback)(()=>{k.current=null;let e=E.current;e.length!==0&&(E.current=[],w(t=>{let n=t.mcp;for(let t of e){let{tools:e,commands:r,resources:a,...o}=t,s=o.type===`disabled`||o.type===`failed`?e??[]:e,c=o.type===`disabled`||o.type===`failed`?r??[]:r,u=o.type===`disabled`||o.type===`failed`?a??[]:a,d=F(o.name),f=n.clients.findIndex(e=>e.name===o.name)===-1?[...n.clients,o]:n.clients.map(e=>e.name===o.name?o:e),p=s===void 0?n.tools:[...i(n.tools,e=>e.name?.startsWith(d)),...s],m=c===void 0?n.commands:[...i(n.commands,e=>l(e,o.name)),...c],h=u===void 0?n.resources:{...n.resources,...u.length>0?{[o.name]:u}:U(n.resources,o.name)};n={...n,clients:f,tools:p,commands:m,resources:h}}return{...t,mcp:n}}))},[w]),j=(0,K.useCallback)(e=>{E.current.push(e),k.current===null&&(k.current=setTimeout(A,16))},[A]),M=(0,K.useCallback)(({client:e,tools:t,commands:n,resources:r})=>{switch(j({...e,tools:t,commands:n,resources:r}),e.type){case`connected`:ne(e.client,e.name,w),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(s(e.name,e.config).catch(()=>{se(`Failed to invalidate the server cache: ${e.name}`)}),O(e.name)){I(e.name,`Server is disabled, skipping automatic reconnection`);return}if(t!==`stdio`&&t!==`sdk`){let n=fe(t);I(e.name,`${n} transport closed/disconnected, attempting automatic reconnection`);let r=T.current.get(e.name);r&&(clearTimeout(r),T.current.delete(e.name)),(async()=>{for(let t=1;t<=q;t++){if(O(e.name)){I(e.name,`Server disabled during reconnection, stopping retry`),T.current.delete(e.name);return}j({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:q});let r=Date.now();try{let i=await D(e.name,e.config),a=Date.now()-r;if(i.client.type===`connected`){I(e.name,`${n} reconnection successful after ${a}ms (attempt ${t})`),T.current.delete(e.name),M(i);return}if(I(e.name,`${n} reconnection attempt ${t} completed with status: ${i.client.type}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),T.current.delete(e.name),M(i);return}}catch(i){let a=Date.now()-r;if(L(e.name,`${n} reconnection attempt ${t} failed after ${a}ms: ${i}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),T.current.delete(e.name),j({...e,type:`failed`});return}}let i=Math.min(J*2**(t-1),Y);I(e.name,`Scheduling reconnection attempt ${t+1} in ${i}ms`),await new Promise(t=>{let n=setTimeout(t,i);T.current.set(e.name,n)})}})()}else j({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(te,async()=>{I(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=d.cache.get(e.name);d.cache.delete(e.name);let n=await d(e),r=n.length;t?t.then(e=>{B(`tengu_mcp_list_changed`,{type:`tools`,previousCount:e.length,newCount:r})},()=>{B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r})}):B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r}),j({...e,tools:n})}catch(t){L(e.name,`Failed to refresh tools after list_changed notification: ${P(t)}`)}}),e.capabilities?.prompts?.listChanged&&e.client.setNotificationHandler(y,async()=>{I(e.name,`Received prompts/list_changed notification, refreshing prompts`),B(`tengu_mcp_list_changed`,{type:`prompts`});try{h.cache.delete(e.name);let[t,n]=await Promise.all([h(e),Promise.resolve([])]);j({...e,commands:[...t,...n]}),H()}catch(t){L(e.name,`Failed to refresh prompts after list_changed notification: ${P(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(S,async()=>{I(e.name,`Received resources/list_changed notification, refreshing resources`),B(`tengu_mcp_list_changed`,{type:`resources`});try{g.cache.delete(e.name);{let t=await g(e);j({...e,resources:t})}}catch(t){L(e.name,`Failed to refresh resources after list_changed notification: ${P(t)}`)}});break;case`needs-auth`:case`failed`:case`pending`:case`disabled`:break}},[j]),N=ae();return(0,K.useEffect)(()=>{async function n(){let{servers:n,errors:i}=t?{servers:{},errors:[]}:await v(e),a={...n,...e};G(w,i),w(e=>{let{stale:t,...n}=r(e.mcp,a);for(let e of t){let t=T.current.get(e.name);t&&(clearTimeout(t),T.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,s(e.name,e.config).catch(()=>{}))}let i=new Set(n.clients.map(e=>e.name)),o=Object.entries(a).filter(([e])=>!i.has(e)).map(([e,t])=>({name:e,type:O(e)?`disabled`:`pending`,config:t}));return o.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...o]}}})}n().catch(e=>{L(`useManageMCPConnections`,`Failed to initialize servers as pending: ${P(e)}`)})},[t,e,w,N,_]),(0,K.useEffect)(()=>{let r=!1;async function i(){let i;t||n()?i=Promise.resolve({}):(C(),i=ie());let{servers:a,errors:o}=t?{servers:{},errors:[]}:await v(e,i);if(r)return;G(w,o);let s={...a,...e},c=Object.fromEntries(Object.entries(s).filter(([e])=>!O(e)));x(M,c).catch(e=>{L(`useManageMcpConnections`,`Failed to get MCP resources: ${P(e)}`)});let l={};if(!t){if(l=ee(await i).allowed,r)return;if(Object.keys(l).length>0){let{servers:e}=u(l,s);l=e}if(Object.keys(l).length>0){w(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(l).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:O(e)?`disabled`:`pending`,config:t}));return n.length===0?e:{...e,mcp:{...e.mcp,clients:[...e.mcp.clients,...n]}}});let e=Object.fromEntries(Object.entries(l).filter(([e])=>!O(e)));x(M,e).catch(e=>{L(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${P(e)}`)})}}let d={...s,...l},f={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(d))t.scope===`enterprise`?f.enterprise++:t.scope===`user`?f.global++:t.scope===`project`?f.project++:t.scope===`local`?f.user++:t.scope===`dynamic`?f.plugin++:t.scope===`claudeai`&&f.claudeai++;B(`tengu_mcp_servers`,{...f})}return i(),()=>{r=!0}},[t,e,M,w,m,N,_]),(0,K.useEffect)(()=>{let e=T.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),k.current!==null&&(clearTimeout(k.current),k.current=null,A())}},[A]),{reconnectMcpServer:(0,K.useCallback)(async e=>{let t=f.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);let n=T.current.get(e);n&&(clearTimeout(n),T.current.delete(e));let r=await D(e,t.config);return M(r),r},[f,M]),toggleMcpServer:(0,K.useCallback)(async e=>{let t=f.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);if(t.type!==`disabled`){let n=T.current.get(e);n&&(clearTimeout(n),T.current.delete(e)),b(e,!1),t.type===`connected`&&await s(e,t.config),j({name:e,type:`disabled`,config:t.config})}else{b(e,!0),j({name:e,type:`pending`,config:t.config});let n=await D(e,t.config);M(n)}},[f,j,M])}}function fe(e){switch(e){case`http`:return`HTTP`;case`ws`:case`ws-ide`:return`WebSocket`;default:return`SSE`}}var K,q,J,Y,pe=e((()=>{K=t(j(),1),N(),k(),V(),w(),ue(),f(),z(),re(),ce(),A(),m(),oe(),R(),_(),T(),le(),E(),q=5,J=1e3,Y=3e4}));function me(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpReconnect must be used within MCPConnectionManager`);return e.reconnectMcpServer}function X(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpToggleEnabled must be used within MCPConnectionManager`);return e.toggleMcpServer}function he({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=de(t,n),a=(0,Z.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,Q.jsx)($.Provider,{value:a,children:e})}var Z,Q,$,ge=e((()=>{Z=t(j(),1),pe(),Q=M(),$=(0,Z.createContext)(null)}));export{X as i,ge as n,me as r,he as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Ax as i,Du as a,Eh as o,Eu as s,Fb as c,GS as l,Jy as u,Lu as ee,Oh as te,Rb as ne,Ru as d,Th as f,Ub as re,Vb as p,Wb as m,kx as ie,lu as h,np as g,nx as ae,ox as _,pb as oe,qb as v,rp as y,su as b,tb as x,vb as S,xb as se,yb as ce,zS as le,zb as ue}from"./loadAgentsDir-C96o6gCj.js";import{D as C,H as de,I as w,Lt as fe,P as T,T as E,Wt as pe,ai as D,dr as me,hn as he,j as O,ot as ge,t as k,y as A}from"./src-DL3w8VPk.js";import{t as j}from"./jsx-runtime-Bb4Xn-E0.js";import{P as _e,R as M}from"./debug-D58GQBDG.js";import{$ as N,et as P,rt as F}from"./settings-BowI3jp-.js";import{c as ve,o as I}from"./log-CZ7ploQm.js";import{n as L,r as R}from"./analytics-DJobLaWP.js";import{l as ye,u as z}from"./oauth-D38aRTUb.js";import{l as be,n as xe,o as B}from"./stringUtils-D7oJIyY2.js";import{Pt as V,Tt as Se}from"./model-BaMclMXn.js";import{i as Ce,n as H,r as we}from"./MCPConnectionManager-CoId-C__.js";import{n as Te,t as U}from"./useExitOnCtrlCDWithKeybindings-L5idX6Kz.js";function Ee({serverToolsCount:e,serverPromptsCount:t,serverResourcesCount:n}){let r=[];return e>0&&r.push(`tools`),n>0&&r.push(`resources`),t>0&&r.push(`prompts`),(0,W.jsxs)(w,{children:[(0,W.jsx)(T,{bold:!0,children:`Capabilities: `}),(0,W.jsx)(T,{color:`text`,children:r.length>0?(0,W.jsx)(E,{children:r}):`none`})]})}var W,De=e((()=>{k(),W=j()}));function Oe(e,t){switch(e.client.type){case`connected`:return{message:`Reconnected to ${t}.`,success:!0};case`needs-auth`:return{message:`${t} requires authentication. Use the 'Authenticate' option.`,success:!1};case`failed`:return{message:`Failed to reconnect to ${t}.`,success:!1};default:return{message:`Unknown result when reconnecting to ${t}.`,success:!1}}}function ke(e,t){return`Error reconnecting to ${t}: ${e instanceof Error?e.message:String(e)}`}var G=e((()=>{}));function Ae({server:e,serverToolsCount:t,onViewTools:n,onCancel:s,onComplete:l,borderless:d=!1}){let[f]=de(),m=Te(),{columns:ie}=ge(),[h,ae]=K.useState(!1),[_,v]=K.useState(null),y=o(e=>e.mcp),x=te(),[S,le]=K.useState(null),[D,k]=(0,K.useState)(!1),A=(0,K.useRef)(null),[j,M]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(!1),[L,z]=(0,K.useState)(null),[be,B]=(0,K.useState)(!1),[V,H]=(0,K.useState)(!1),U=(0,K.useRef)(void 0),W=(0,K.useRef)(!1),[De,G]=(0,K.useState)(``),[Ae,je]=(0,K.useState)(0),[Me,J]=(0,K.useState)(null);(0,K.useEffect)(()=>()=>{W.current=!0,A.current?.abort(),U.current!==void 0&&clearTimeout(U.current)},[]);let Y=e.isAuthenticated||e.client.type===`connected`&&t>0,X=we(),Ne=K.useCallback(async()=>{M(!1),P(null),k(!0);try{let t=await X(e.name),n=t.client.type===`connected`;R(`tengu_claudeai_mcp_auth_completed`,{success:n}),n?l?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?l?.(`Authentication successful, but server still requires authentication. You may need to manually restart Work Mate.`):l?.(`Authentication successful, but server reconnection failed. You may need to manually restart Work Mate for the changes to take effect.`)}catch(t){R(`tengu_claudeai_mcp_auth_completed`,{success:!1}),l?.(ke(t,e.name))}finally{k(!1)}},[X,e.name,l]),Pe=K.useCallback(async()=>{await u(e.name,{...e.config,scope:e.scope}),x(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`needs-auth`}:t),r=p(t.mcp.tools,e.name),i=ne(t.mcp.commands,e.name),a=ue(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),R(`tengu_claudeai_mcp_clear_auth_completed`,{}),l?.(`Disconnected from ${e.name}.`),I(!1),z(null),B(!1)},[e.name,e.config,e.scope,x,l]);pe(`confirm:no`,()=>{A.current?.abort(),A.current=null,ae(!1),le(null)},{context:`Confirmation`,isActive:h}),pe(`confirm:no`,()=>{M(!1),P(null)},{context:`Confirmation`,isActive:j}),pe(`confirm:no`,()=>{I(!1),z(null),B(!1)},{context:`Confirmation`,isActive:F}),he((e,t)=>{if(t.return&&j&&Ne(),t.return&&F)if(be)Pe();else{let e=`${ye().CLAUDE_AI_ORIGIN}/settings/connectors`;z(e),B(!0),i(e)}if(e===`c`&&!V){let e=S||N||L;e&&me(e).then(e=>{W.current||(e&&process.stdout.write(e),H(!0),U.current!==void 0&&clearTimeout(U.current),U.current=setTimeout(H,2e3,!1))})}});let Z=xe(String(e.name)),Fe=re(y.commands,e.name).length,Ie=Ce(),Le=K.useCallback(async()=>{let t=ye().CLAUDE_AI_ORIGIN,n=Se()?.organizationUuid,r;r=n&&e.config.type===`claudeai-proxy`&&e.config.id?`${t}/api/organizations/${n}/mcp/start-auth/${e.config.id.startsWith(`mcprs`)?`mcpsrv${e.config.id.slice(5)}`:e.config.id}?product_surface=${encodeURIComponent(process.env.CLAUDE_CODE_ENTRYPOINT||`cli`)}`:`${t}/settings/connectors`,P(r),M(!0),R(`tengu_claudeai_mcp_auth_started`,{}),await i(r)},[e.config]),Q=K.useCallback(()=>{I(!0),R(`tengu_claudeai_mcp_clear_auth_started`,{})},[]),Re=K.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await Ie(e.name),e.config.type===`claudeai-proxy`&&R(`tengu_claudeai_mcp_toggle`,{new_state:t?`disabled`:`enabled`}),s()}catch(n){l?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${_e(n)}`)}},[e.client.type,e.config.type,e.name,Ie,s,l]),ze=K.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;ae(!0),v(null);let t=new AbortController;A.current=t;try{if(e.isAuthenticated&&e.config&&await se(e.name,e.config,{preserveStepUpState:!0}),e.config){await ce(e.name,e.config,le,t.signal,{onWaitingForCallback:e=>{J(()=>e)}}),R(`tengu_mcp_auth_config_authenticate`,{wasAuthenticated:e.isAuthenticated});let n=await X(e.name);if(n.client.type===`connected`){let t=Y?`Authentication successful. Reconnected to ${e.name}.`:`Authentication successful. Connected to ${e.name}.`;l?.(t)}else n.client.type===`needs-auth`?l?.(`Authentication successful, but server still requires authentication. You may need to manually restart Work Mate.`):(ve(e.name,`Reconnection failed after authentication`),l?.(`Authentication successful, but server reconnection failed. You may need to manually restart Work Mate for the changes to take effect.`))}}catch(e){e instanceof Error&&!(e instanceof oe)&&v(e.message)}finally{ae(!1),A.current=null,J(null),G(``)}},[e.isAuthenticated,e.config,e.name,l,X,Y]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await se(e.name,e.config),R(`tengu_mcp_auth_config_clear`,{}),await u(e.name,{...e.config,scope:e.scope}),x(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`failed`}:t),r=p(t.mcp.tools,e.name),i=ne(t.mcp.commands,e.name),a=ue(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),l?.(`Authentication cleared for ${e.name}.`))};if(h){let t=e.config.type!==`claudeai-proxy`&&e.config.oauth?.xaa?` Authenticating via your identity provider`:` A browser window will open for authentication`;return(0,q.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(T,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,q.jsxs)(w,{children:[(0,q.jsx)(b,{}),(0,q.jsx)(T,{children:t})]}),S&&(0,q.jsxs)(w,{flexDirection:`column`,children:[(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),V?(0,q.jsx)(T,{color:`success`,children:`(Copied!)`}):(0,q.jsx)(T,{dimColor:!0,children:(0,q.jsx)(C,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,q.jsx)(fe,{url:S})]}),h&&S&&Me&&(0,q.jsxs)(w,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(T,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,q.jsxs)(w,{children:[(0,q.jsxs)(T,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,q.jsx)(ee,{value:De,onChange:G,onSubmit:e=>{Me(e.trim()),G(``)},cursorOffset:Ae,onChangeCursorOffset:je,columns:ie-8})]})]}),(0,q.jsx)(w,{marginLeft:3,children:(0,q.jsx)(T,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(j)return(0,q.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(T,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,q.jsxs)(w,{children:[(0,q.jsx)(b,{}),(0,q.jsx)(T,{children:` A browser window will open for authentication`})]}),N&&(0,q.jsxs)(w,{flexDirection:`column`,children:[(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),V?(0,q.jsx)(T,{color:`success`,children:`(Copied!)`}):(0,q.jsx)(T,{dimColor:!0,children:(0,q.jsx)(C,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,q.jsx)(fe,{url:N})]}),(0,q.jsxs)(w,{marginLeft:3,flexDirection:`column`,children:[(0,q.jsxs)(T,{color:`permission`,children:[`Press `,(0,q.jsx)(T,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,q.jsx)(T,{dimColor:!0,italic:!0,children:(0,q.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(F)return(0,q.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(T,{color:`claude`,children:[`Clear authentication for `,e.name]}),be?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T,{children:`Find the MCP server in the browser and click "Disconnect".`}),L&&(0,q.jsxs)(w,{flexDirection:`column`,children:[(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),V?(0,q.jsx)(T,{color:`success`,children:`(Copied!)`}):(0,q.jsx)(T,{dimColor:!0,children:(0,q.jsx)(C,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,q.jsx)(fe,{url:L})]}),(0,q.jsxs)(w,{marginLeft:3,flexDirection:`column`,children:[(0,q.jsxs)(T,{color:`permission`,children:[`Press `,(0,q.jsx)(T,{bold:!0,children:`Enter`}),` when done.`]}),(0,q.jsx)(T,{dimColor:!0,italic:!0,children:(0,q.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,q.jsxs)(w,{marginLeft:3,flexDirection:`column`,children:[(0,q.jsxs)(T,{color:`permission`,children:[`Press `,(0,q.jsx)(T,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,q.jsx)(T,{dimColor:!0,italic:!0,children:(0,q.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(D)return(0,q.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(T,{color:`text`,children:[`Connecting to `,(0,q.jsx)(T,{bold:!0,children:e.name}),`…`]}),(0,q.jsxs)(w,{children:[(0,q.jsx)(b,{}),(0,q.jsx)(T,{children:` Establishing connection to MCP server`})]}),(0,q.jsx)(T,{dimColor:!0,children:`This may take a few moments.`})]});let $=[];return e.client.type===`disabled`&&$.push({label:`Enable`,value:`toggle-enabled`}),e.client.type===`connected`&&t>0&&$.push({label:`View tools`,value:`tools`}),e.config.type===`claudeai-proxy`?e.client.type===`connected`?$.push({label:`Clear authentication`,value:`claudeai-clear-auth`}):e.client.type!==`disabled`&&$.push({label:`Authenticate`,value:`claudeai-auth`}):(Y&&($.push({label:`Re-authenticate`,value:`reauth`}),$.push({label:`Clear authentication`,value:`clear-auth`})),Y||$.push({label:`Authenticate`,value:`auth`})),e.client.type!==`disabled`&&(e.client.type!==`needs-auth`&&$.push({label:`Reconnect`,value:`reconnectMcpServer`}),$.push({label:`Disable`,value:`toggle-enabled`})),$.length===0&&$.push({label:`Back`,value:`back`}),(0,q.jsxs)(w,{flexDirection:`column`,children:[(0,q.jsxs)(w,{flexDirection:`column`,paddingX:1,borderStyle:d?void 0:`round`,children:[(0,q.jsx)(w,{marginBottom:1,children:(0,q.jsxs)(T,{bold:!0,children:[Z,` MCP Server`]})}),(0,q.jsxs)(w,{flexDirection:`column`,gap:0,children:[(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,q.jsxs)(T,{children:[O(`inactive`,f)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,q.jsxs)(T,{children:[O(`success`,f)(r.tick),` connected`]}):e.client.type===`pending`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T,{dimColor:!0,children:r.radioOff}),(0,q.jsx)(T,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,q.jsxs)(T,{children:[O(`warning`,f)(r.triangleUpOutline),` needs authentication`]}):(0,q.jsxs)(T,{children:[O(`error`,f)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{bold:!0,children:`Auth: `}),Y?(0,q.jsxs)(T,{children:[O(`success`,f)(r.tick),` authenticated`]}):(0,q.jsxs)(T,{children:[O(`error`,f)(r.cross),` not authenticated`]})]}),(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{bold:!0,children:`URL: `}),(0,q.jsx)(T,{dimColor:!0,children:e.config.url})]}),(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{bold:!0,children:`Config location: `}),(0,q.jsx)(T,{dimColor:!0,children:c(e.scope)})]}),e.client.type===`connected`&&(0,q.jsx)(Ee,{serverToolsCount:t,serverPromptsCount:Fe,serverResourcesCount:y.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,q.jsxs)(w,{children:[(0,q.jsx)(T,{bold:!0,children:`Tools: `}),(0,q.jsxs)(T,{dimColor:!0,children:[t,` tools`]})]})]}),_&&(0,q.jsx)(w,{marginTop:1,children:(0,q.jsxs)(T,{color:`error`,children:[`Error: `,_]})}),$.length>0&&(0,q.jsx)(w,{marginTop:1,children:(0,q.jsx)(a,{options:$,onChange:async t=>{switch(t){case`tools`:n();break;case`auth`:case`reauth`:await ze();break;case`clear-auth`:await Be();break;case`claudeai-auth`:await Le();break;case`claudeai-clear-auth`:Q();break;case`reconnectMcpServer`:k(!0);try{let t=await X(e.name);e.config.type===`claudeai-proxy`&&R(`tengu_claudeai_mcp_reconnect`,{success:t.client.type===`connected`});let{message:n}=Oe(t,e.name);l?.(n)}catch(t){e.config.type===`claudeai-proxy`&&R(`tengu_claudeai_mcp_reconnect`,{success:!1}),l?.(ke(t,e.name))}finally{k(!1)}break;case`toggle-enabled`:await Re();break;case`back`:s();break}},onCancel:s})})]}),(0,q.jsx)(w,{marginTop:1,children:(0,q.jsx)(T,{dimColor:!0,italic:!0,children:m.pending?(0,q.jsxs)(q.Fragment,{children:[`Press `,m.keyName,` again to exit`]}):(0,q.jsxs)(E,{children:[(0,q.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,q.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,q.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var K,q,je=e((()=>{n(),K=t(D(),1),L(),z(),U(),l(),k(),le(),S(),x(),H(),v(),f(),V(),ie(),M(),I(),B(),y(),s(),h(),d(),De(),G(),q=j()}));function Me({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:s,borderless:l=!1}){let[u]=de(),ee=Te(),te=o(e=>e.mcp),ne=we(),d=Ce(),[f,p]=(0,J.useState)(!1),m=J.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await d(e.name),i()}catch(n){s(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${_e(n)}`)}},[e.client.type,e.name,d,i,s]),ie=xe(String(e.name)),h=re(te.commands,e.name).length,_=[];return e.client.type!==`disabled`&&t>0&&_.push({label:`View tools`,value:`tools`}),e.client.type!==`disabled`&&_.push({label:`Reconnect`,value:`reconnectMcpServer`}),_.push({label:e.client.type===`disabled`?`Enable`:`Disable`,value:`toggle-enabled`}),_.length===0&&_.push({label:`Back`,value:`back`}),f?(0,Y.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,Y.jsxs)(T,{color:`text`,children:[`Reconnecting to `,(0,Y.jsx)(T,{bold:!0,children:e.name})]}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(b,{}),(0,Y.jsx)(T,{children:` Restarting MCP server process`})]}),(0,Y.jsx)(T,{dimColor:!0,children:`This may take a few moments.`})]}):(0,Y.jsxs)(w,{flexDirection:`column`,children:[(0,Y.jsxs)(w,{flexDirection:`column`,paddingX:1,borderStyle:l?void 0:`round`,children:[(0,Y.jsx)(w,{marginBottom:1,children:(0,Y.jsxs)(T,{bold:!0,children:[ie,` MCP Server`]})}),(0,Y.jsxs)(w,{flexDirection:`column`,gap:0,children:[(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,Y.jsxs)(T,{children:[O(`inactive`,u)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,Y.jsxs)(T,{children:[O(`success`,u)(r.tick),` connected`]}):e.client.type===`pending`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{dimColor:!0,children:r.radioOff}),(0,Y.jsx)(T,{children:` connecting…`})]}):(0,Y.jsxs)(T,{children:[O(`error`,u)(r.cross),` failed`]})]}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{bold:!0,children:`Command: `}),(0,Y.jsx)(T,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{bold:!0,children:`Args: `}),(0,Y.jsx)(T,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{bold:!0,children:`Config location: `}),(0,Y.jsx)(T,{dimColor:!0,children:c(ae(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,Y.jsx)(Ee,{serverToolsCount:t,serverPromptsCount:h,serverResourcesCount:te.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{bold:!0,children:`Tools: `}),(0,Y.jsxs)(T,{dimColor:!0,children:[t,` tools`]})]})]}),_.length>0&&(0,Y.jsx)(w,{marginTop:1,children:(0,Y.jsx)(a,{options:_,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){p(!0);try{let{message:t}=Oe(await ne(e.name),e.name);s?.(t)}catch(t){s?.(ke(t,e.name))}finally{p(!1)}}else t===`toggle-enabled`?await m():t===`back`&&i()},onCancel:i})})]}),(0,Y.jsx)(w,{marginTop:1,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:ee.pending?(0,Y.jsxs)(Y.Fragment,{children:[`Press `,ee.keyName,` again to exit`]}):(0,Y.jsxs)(E,{children:[(0,Y.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var J,Y,X=e((()=>{n(),J=t(D(),1),U(),k(),_(),H(),v(),f(),M(),B(),y(),s(),h(),De(),G(),Y=j()}));function Ne({tool:e,server:t,onBack:n}){let[r,i]=Pe.useState(``),a=P(e.name,t.name),o=N(e.userFacingName?e.userFacingName({}):a),s=e.isReadOnly?.({})??!1,c=e.isDestructive?.({})??!1,l=e.isOpenWorld?.({})??!1;return Pe.useEffect(()=>{async function t(){try{let t=await e.description({},{isNonInteractiveSession:!1,toolPermissionContext:{mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1},tools:[]});i(t)}catch{i(`Failed to load description`)}}t()},[e]),(0,Z.jsx)(A,{title:(0,Z.jsxs)(Z.Fragment,{children:[o,s&&(0,Z.jsx)(T,{color:`success`,children:` [read-only]`}),c&&(0,Z.jsx)(T,{color:`error`,children:` [destructive]`}),l&&(0,Z.jsx)(T,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,Z.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,Z.jsxs)(w,{flexDirection:`column`,children:[(0,Z.jsxs)(w,{children:[(0,Z.jsx)(T,{bold:!0,children:`Tool name: `}),(0,Z.jsx)(T,{dimColor:!0,children:a})]}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(T,{bold:!0,children:`Full name: `}),(0,Z.jsx)(T,{dimColor:!0,children:e.name})]}),r&&(0,Z.jsxs)(w,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(T,{bold:!0,children:`Description:`}),(0,Z.jsx)(T,{wrap:`wrap`,children:r})]}),e.inputJSONSchema?.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,Z.jsxs)(w,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(T,{bold:!0,children:`Parameters:`}),(0,Z.jsx)(w,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,Z.jsxs)(T,{children:[`• `,t,r&&(0,Z.jsx)(T,{dimColor:!0,children:` (required)`}),`:`,` `,(0,Z.jsx)(T,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,Z.jsxs)(T,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var Pe,Z,Fe=e((()=>{Pe=t(D(),1),k(),F(),y(),Z=j()}));function Ie({server:e,onSelectTool:t,onBack:n}){let r=o(e=>e.mcp.tools),i=Le.useMemo(()=>e.client.type===`connected`?m(r,e.name):[],[e,r]),s=i.map((t,n)=>{let r=P(t.name,e.name),i=N(t.userFacingName?t.userFacingName({}):r),a=t.isReadOnly?.({})??!1,o=t.isDestructive?.({})??!1,s=t.isOpenWorld?.({})??!1,c=[];return a&&c.push(`read-only`),o&&c.push(`destructive`),s&&c.push(`open-world`),{label:i,value:n.toString(),description:c.length>0?c.join(`, `):void 0,descriptionColor:o?`error`:a?`success`:void 0}});return(0,Q.jsx)(A,{title:`Tools for ${e.name}`,subtitle:`${i.length} ${be(i.length,`tool`)}`,onCancel:n,inputGuide:e=>e.pending?(0,Q.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(E,{children:[(0,Q.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:i.length===0?(0,Q.jsx)(T,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(a,{options:s,onChange:e=>{let n=parseInt(e,10),r=i[n];r&&t(r,n)},onCancel:n})})}var Le,Q,Re=e((()=>{Le=t(D(),1),k(),F(),v(),f(),B(),y(),s(),Q=j()}));export{Me as a,je as c,Fe as i,Re as n,X as o,Ne as r,Ae as s,Ie as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fb as n,Kb as r,ox as i,qb as a,rx as o}from"./loadAgentsDir-C96o6gCj.js";import{I as s,Lt as c,P as l,ai as u,t as d}from"./src-DL3w8VPk.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";function p({scope:e,parsingErrors:t,warnings:i}){let a=t.length>0,o=i.length>0;return!a&&!o?null:(0,_.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,_.jsxs)(s,{children:[(a||o)&&(0,_.jsxs)(l,{color:a?`error`:`warning`,children:[`[`,a?`Failed to parse`:`Contains warnings`,`] `]}),(0,_.jsx)(l,{children:r(e)})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(l,{dimColor:!0,children:`Location: `}),(0,_.jsx)(l,{dimColor:!0,children:n(e)})]}),(0,_.jsxs)(s,{marginLeft:1,flexDirection:`column`,children:[t.map((e,t)=>{let n=e.mcpErrorMetadata?.serverName;return(0,_.jsx)(s,{children:(0,_.jsxs)(l,{children:[(0,_.jsx)(l,{dimColor:!0,children:`└ `}),(0,_.jsx)(l,{color:`error`,children:`[Error]`}),(0,_.jsxs)(l,{dimColor:!0,children:[` `,n&&`[${n}] `,e.path&&e.path!==``?`${e.path}: `:``,e.message]})]})},`error-${t}`)}),i.map((e,t)=>{let n=e.mcpErrorMetadata?.serverName;return(0,_.jsx)(s,{children:(0,_.jsxs)(l,{children:[(0,_.jsx)(l,{dimColor:!0,children:`└ `}),(0,_.jsx)(l,{color:`warning`,children:`[Warning]`}),(0,_.jsxs)(l,{dimColor:!0,children:[` `,n&&`[${n}] `,e.path&&e.path!==``?`${e.path}: `:``,e.message]})]})},`warning-${t}`)})]})]})}function m(){let e=(0,g.useMemo)(()=>[{scope:`user`,config:o(`user`)},{scope:`project`,config:o(`project`)},{scope:`local`,config:o(`local`)},{scope:`enterprise`,config:o(`enterprise`)}],[]),t=e.some(({config:e})=>h(e.errors,`fatal`).length>0),n=e.some(({config:e})=>h(e.errors,`warning`).length>0);return!t&&!n?null:(0,_.jsxs)(s,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,_.jsx)(l,{bold:!0,children:`MCP Config Diagnostics`}),(0,_.jsx)(s,{marginTop:1,children:(0,_.jsxs)(l,{dimColor:!0,children:[`For help configuring MCP servers, see:`,` `,(0,_.jsx)(c,{url:`https://code.workmate.com/docs/en/mcp`,children:`https://code.workmate.com/docs/en/mcp`})]})}),e.map(({scope:e,config:t})=>(0,_.jsx)(p,{scope:e,parsingErrors:h(t.errors,`fatal`),warnings:h(t.errors,`warning`)},e))]})}function h(e,t){return e.filter(e=>e.mcpErrorMetadata?.severity===t)}var g,_,v=e((()=>{g=t(u(),1),i(),a(),d(),_=f()}));export{v as n,m as t};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./figures-5ThXQEtq.js";import{$o as a,Aw as o,DC as s,Da as c,Du as l,Eh as u,GS as d,Hh as f,Jw as p,Nw as m,OC as h,Ou as g,TC as _,Th as v,Uh as y,Wh as b,Yh as x,dc as S,dn as C,dy as w,ea as T,es as E,fc as D,fy as O,gw as k,hn as A,jf as j,kf as M,lu as N,mc as P,mw as F,nn as I,ns as ee,su as te,uc as L,wa as ne,zS as R}from"./loadAgentsDir-C96o6gCj.js";import{C as re,Gt as ie,I as z,P as B,Wt as ae,ai as oe,ot as se,t as ce}from"./src-DL3w8VPk.js";import{t as le}from"./jsx-runtime-Bb4Xn-E0.js";import{Ut as ue,Wn as de}from"./state-D5D6QpTX.js";import{In as V,Ln as fe}from"./settings-BowI3jp-.js";import{h as H,m as pe,o as me,q as he,s as U,w as ge}from"./log-CZ7ploQm.js";import{n as W,r as G}from"./analytics-DJobLaWP.js";import{b as _e,m as ve,v as ye}from"./startupProfiler-B90b5vuq.js";import{E as be,T as xe,c as Se,d as Ce,w as we}from"./sessionTracing-fIp8g04N.js";import{n as Te,t as Ee}from"./useExitOnCtrlCDWithKeybindings-L5idX6Kz.js";import*as K from"path";import{randomUUID as q}from"crypto";var J=t(oe(),1),Y=le();ce(),ue(),he(),pe(),me(),fe(),W(),ye(),s(),w(),we(),M(),Se(),D(),L(),ee(),T(),A();function De(e){let t=e.toLowerCase();return/\b(wtf|wth|ffs|omfg|shit(ty|tiest)?|dumbass|horrible|awful|piss(ed|ing)? off|piece of (shit|crap|junk)|what the (fuck|hell)|fucking? (broken|useless|terrible|awful|horrible)|fuck you|screw (this|you)|so frustrating|this sucks|damn it)\b/.test(t)}function Oe(e){let t=e.toLowerCase().trim();return t===`continue`||/\b(keep going|go on)\b/.test(t)}function ke(e,t,n,r,i,a,o){let s=q();de(s);let c=typeof e==`string`?e:e.find(e=>e.type===`text`)?.text||``;Ce(c);let l=typeof e==`string`?e:e.findLast(e=>e.type===`text`)?.text||``;return l&&xe(`user_prompt`,{prompt_length:String(l.length),prompt:be(l),"prompt.id":s}),G(`tengu_input_prompt`,{is_negative:De(c),is_keep_going:Oe(c)}),t.length>0?{messages:[m({content:[...typeof e==`string`?e.trim()?[{type:`text`,text:e}]:[]:e,...t],uuid:i,imagePasteIds:n.length>0?n:void 0,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}:{messages:[m({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}W(),T();async function Ae({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:s,ideSelection:c,messages:l,setUserInputOnProcessing:u,uuid:d,isAlreadyProcessing:f,querySource:p,canUseTool:h,skipSlashCommands:g,bridgeOrigin:_,isMeta:v,skipAttachments:y,autonomy:b}){let x=typeof e==`string`?e:null,S=x?.startsWith(`/`)&&!g;n===`prompt`&&x!==null&&!v&&!S&&u?.(x),P(`query_process_user_input_base_start`);let w=i.getAppState(),T=await Me(e,n,r,i,s,c,l,d,f,p,h,w.toolPermissionContext.mode,g,_,v,y,t,b);if(P(`query_process_user_input_base_end`),!T.shouldQuery)return T;P(`query_hooks_start`);let E=k(e)||``;for await(let t of I(E,w.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[o(`${C(t.blockingError)}\n\nOriginal prompt: ${e}`,`warning`)],shouldQuery:!1,allowedTools:T.allowedTools};if(t.preventContinuation){let e=t.stopReason?`Operation stopped by hook: ${t.stopReason}`:`Operation stopped by hook`;return T.messages.push(m({content:e})),T.shouldQuery=!1,T}if(t.additionalContexts&&t.additionalContexts.length>0&&T.messages.push(a({type:`hook_additional_context`,content:t.additionalContexts.map(je),hookName:`UserPromptSubmit`,toolUseID:`hook-${q()}`,hookEvent:`UserPromptSubmit`})),t.message)switch(t.message.attachment.type){case`hook_success`:if(!t.message.attachment.content)break;T.messages.push({...t.message,attachment:{...t.message.attachment,content:je(t.message.attachment.content)}});break;default:T.messages.push(t.message);break}}return P(`query_hooks_end`),T}var X=1e4;function je(e){return e.length>X?`${e.substring(0,X)}… [output truncated - exceeded ${X} characters]`:e}async function Me(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,g,v,y){let b=null,x=[],C=[],w=e;if(typeof e==`string`)b=e;else if(e.length>0){P(`query_image_processing_start`);let t=[];for(let n of e)if(n.type===`image`){let e=await h(n);if(e.dimensions){let t=_(e.dimensions);t&&C.push(t)}t.push(e.block)}else t.push(n);w=t,P(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(b=n.text,x=t.slice(0,-1)):x=t}if(b===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let T=i?Object.values(i).filter(O):[],D=T.map(e=>e.id),k=i?await j(i):new Map;P(`query_pasted_image_processing_start`);let A=await Promise.all(T.map(async e=>{let t={type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}};return G(`tengu_pasted_image_resize_attempt`,{original_size_bytes:e.content.length}),{resized:await h(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??k.get(e.id)}})),M=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of A){if(e.dimensions){let t=_(e.dimensions,n);t&&C.push(t)}else if(t){let e=_(t,n);e&&C.push(e)}else n&&C.push(`[Image source: ${n}]`);M.push(e.block)}P(`query_pasted_image_processing_end`);let N=f,F=!g&&b!==null&&(t!==`prompt`||N||!b.startsWith(`/`));P(`query_attachment_loading_start`);let I=F?await S(E(b,r,a??null,[],o,l)):[];if(P(`query_attachment_loading_end`),b!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-ISucgwpi.js`);return Z(await e(b,x,I,r,n),C)}if(b!==null&&!N&&b.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-BnpXO_fI.js`);return Z(await e(b,x,M,I,r,n,s,c,u,y),C)}if(b!==null&&t===`prompt`){let e=b.trim(),t=I.find(e=>e.attachment.type===`agent_mention`);if(t){let n=`@agent-${t.attachment.agentType}`,r=e===n;G(`tengu_subagent_at_mention`,{is_subagent_only:r,is_prefix:e.startsWith(n)&&!r})}}return Z(ke(w,M,D,I,s,d,m),C)}function Z(e,t){return t.length>0&&e.messages.push(m({content:t.map(e=>({type:`text`,text:e})),isMeta:!0})),e}var Ne=n({MessageSelector:()=>Fe,messagesAfterAreOnlySynthetic:()=>Ue,selectableUserMessagesFilter:()=>He});function Pe(e){return e.type===`text`}function Q(e){return e===`summarize`}function Fe({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:a,onClose:o,preselectedMessage:s}){let c=u(e=>e.fileHistory),[d,p]=(0,J.useState)(void 0),h=y(),g=(0,J.useMemo)(q,[]),_=(0,J.useMemo)(()=>[...e.filter(He),{...m({content:``}),uuid:g}],[e,g]),[v,x]=(0,J.useState)(_.length-1),S=Math.max(0,Math.min(v-Math.floor($/2),_.length-$)),C=_.length>1,[w,T]=(0,J.useState)(s),[E,D]=(0,J.useState)(void 0);(0,J.useEffect)(()=>{if(!s||!h)return;let e=!1;return b(c,s.uuid).then(t=>{e||D(t)}),()=>{e=!0}},[s,h,c]);let[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(null),[M,N]=(0,J.useState)(`both`),[P,F]=(0,J.useState)(``);function I(e){let t=e?[{value:`both`,label:`Restore code and conversation`},{value:`conversation`,label:`Restore conversation`},{value:`code`,label:`Restore code`}]:[{value:`conversation`,label:`Restore conversation`}];return t.push({value:`summarize`,label:`Summarize from here`,type:`input`,placeholder:`add context (optional)`,initialValue:``,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,onChange:F}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,J.useEffect)(()=>{G(`tengu_message_selector_opened`,{})},[]);async function ee(e){t(),k(!0);try{await n(e),k(!1),o()}catch(e){U(e),k(!1),p(`Failed to restore the conversation:\n${e}`)}}async function L(t){let n=e.indexOf(t);if(G(`tengu_message_selector_selected`,{index_from_end:e.length-1-n,message_type:t.type,is_current_prompt:!1}),!e.includes(t)){o();return}if(!h){await ee(t);return}let r=await b(c,t.uuid);T(t),D(r)}async function ne(e){if(G(`tengu_message_selector_restore_option_selected`,{option:e}),!w){p(`Message not found.`);return}if(e===`nevermind`){s?o():T(void 0);return}if(Q(e)){t(),k(!0),j(e),p(void 0);try{let e=P.trim()||void 0;await a(w,e,`from`),k(!1),j(null),T(void 0),o()}catch(e){U(e),k(!1),j(null),T(void 0),p(`Failed to summarize:\n${e}`)}return}t(),k(!0),p(void 0);let i=null,c=null;if(e===`code`||e===`both`)try{await r(w)}catch(e){i=e,U(i)}if(e===`conversation`||e===`both`)try{await n(w)}catch(e){c=e,U(c)}k(!1),T(void 0),c&&i?p(`Failed to restore the conversation and code:\n${c}\n${i}`):c?p(`Failed to restore the conversation:\n${c}`):i?p(`Failed to restore the code:\n${i}`):o()}let R=Te(),oe=(0,J.useCallback)(()=>{if(w&&!s){T(void 0);return}G(`tengu_message_selector_cancelled`,{}),o()},[o,w,s]),se=(0,J.useCallback)(()=>x(e=>Math.max(0,e-1)),[]),ce=(0,J.useCallback)(()=>x(e=>Math.min(_.length-1,e+1)),[_.length]),le=(0,J.useCallback)(()=>x(0),[]),ue=(0,J.useCallback)(()=>x(_.length-1),[_.length]),de=(0,J.useCallback)(()=>{let e=_[v];e&&L(e)},[_,v,L]);ae(`confirm:no`,oe,{context:`Confirmation`,isActive:!w}),ie({"messageSelector:up":se,"messageSelector:down":ce,"messageSelector:top":le,"messageSelector:bottom":ue,"messageSelector:select":de},{context:`MessageSelector`,isActive:!O&&!d&&!w&&C});let[V,fe]=(0,J.useState)({});(0,J.useEffect)(()=>{async function t(){h&&Promise.all(_.map(async(t,n)=>{if(t.uuid!==g){let r=f(c,t.uuid),i=_.at(n+1),a=r?Ve(e,t.uuid,i?.uuid===g?void 0:i?.uuid):void 0;fe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[_,e,g,c,h]);let H=h&&E?.filesChanged&&E.filesChanged.length>0,pe=!d&&!w&&!s&&C;return(0,Y.jsxs)(z,{flexDirection:`column`,width:`100%`,children:[(0,Y.jsx)(re,{color:`suggestion`}),(0,Y.jsxs)(z,{flexDirection:`column`,marginX:1,gap:1,children:[(0,Y.jsx)(B,{bold:!0,color:`suggestion`,children:`Rewind`}),d&&(0,Y.jsxs)(B,{color:`error`,children:[`Error: `,d]}),!C&&(0,Y.jsx)(B,{children:`Nothing to rewind to yet.`}),!d&&w&&C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{children:[`Confirm you want to restore `,!E&&`the conversation `,`to the point before you sent this message:`]}),(0,Y.jsxs)(z,{flexDirection:`column`,paddingLeft:1,borderStyle:`single`,borderRight:!1,borderTop:!1,borderBottom:!1,borderLeft:!0,borderLeftDimColor:!0,children:[(0,Y.jsx)(Be,{userMessage:w,color:`text`,isCurrent:!1}),(0,Y.jsxs)(B,{dimColor:!0,children:[`(`,ve(new Date(w.timestamp)),`)`]})]}),(0,Y.jsx)(Le,{selectedRestoreOption:M,canRestoreCode:!!H,diffStatsForRestore:E}),O&&Q(A)?(0,Y.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(te,{}),(0,Y.jsx)(B,{children:`Summarizing…`})]}):(0,Y.jsx)(l,{isDisabled:O,options:I(!!H),defaultFocusValue:H?`both`:`conversation`,onFocus:e=>N(e),onChange:e=>ne(e),onCancel:()=>s?o():T(void 0)}),H&&(0,Y.jsx)(z,{marginBottom:1,children:(0,Y.jsxs)(B,{dimColor:!0,children:[i.warning,` Rewinding does not affect files edited manually or via bash.`]})})]}),pe&&(0,Y.jsxs)(Y.Fragment,{children:[h?(0,Y.jsx)(B,{children:`Restore the code and/or conversation to the point before…`}):(0,Y.jsx)(B,{children:`Restore and fork the conversation to the point before…`}),(0,Y.jsx)(z,{width:`100%`,flexDirection:`column`,children:_.slice(S,S+$).map((e,t)=>{let n=S+t,r=n===v,a=e.uuid===g,o=n in V,s=V[n],c=s?.filesChanged?.length;return(0,Y.jsxs)(z,{height:h?3:2,overflow:`hidden`,width:`100%`,flexDirection:`row`,children:[(0,Y.jsx)(z,{width:2,minWidth:2,children:r?(0,Y.jsxs)(B,{color:`permission`,bold:!0,children:[i.pointer,` `]}):(0,Y.jsx)(B,{children:` `})}),(0,Y.jsxs)(z,{flexDirection:`column`,children:[(0,Y.jsx)(z,{flexShrink:1,height:1,overflow:`hidden`,children:(0,Y.jsx)(Be,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:a,paddingRight:10})}),h&&o&&(0,Y.jsx)(z,{height:1,flexDirection:`row`,children:s?(0,Y.jsx)(B,{dimColor:!r,color:`inactive`,children:c?(0,Y.jsxs)(Y.Fragment,{children:[c===1&&s.filesChanged[0]?`${K.basename(s.filesChanged[0])} `:`${c} files changed `,(0,Y.jsx)(ze,{diffStats:s})]}):(0,Y.jsx)(Y.Fragment,{children:`No code changes`})}):(0,Y.jsxs)(B,{dimColor:!0,color:`warning`,children:[i.warning,` No code restore`]})})]})]},e.uuid)})})]}),!w&&(0,Y.jsx)(B,{dimColor:!0,italic:!0,children:R.pending?(0,Y.jsxs)(Y.Fragment,{children:[`Press `,R.keyName,` again to exit`]}):(0,Y.jsxs)(Y.Fragment,{children:[!d&&C&&`Enter to continue · `,`Esc to exit`]})})]})]})}function Ie(e){switch(e){case`summarize`:return`Messages after this point will be summarized.`;case`both`:case`conversation`:return`The conversation will be forked.`;case`code`:case`nevermind`:return`The conversation will be unchanged.`}}function Le({selectedRestoreOption:e,canRestoreCode:t,diffStatsForRestore:n}){let r=t&&(e===`both`||e===`code`);return(0,Y.jsxs)(z,{flexDirection:`column`,children:[(0,Y.jsx)(B,{dimColor:!0,children:Ie(e)}),!Q(e)&&(r?(0,Y.jsx)(Re,{diffStatsForRestore:n}):(0,Y.jsx)(B,{dimColor:!0,children:`The code will be unchanged.`}))]})}function Re({diffStatsForRestore:e}){if(e===void 0)return;if(!e.filesChanged?.[0])return(0,Y.jsx)(B,{dimColor:!0,children:`The code has not changed (nothing will be restored).`});let t=e.filesChanged.length,n=``;return n=t===1?K.basename(e.filesChanged[0]||``):t===2?`${K.basename(e.filesChanged[0]||``)} and ${K.basename(e.filesChanged[1]||``)}`:`${K.basename(e.filesChanged[0]||``)} and ${e.filesChanged.length-1} other files`,(0,Y.jsxs)(B,{dimColor:!0,children:[`The code will be restored `,(0,Y.jsx)(ze,{diffStats:e}),` in `,n,`.`]})}function ze({diffStats:e}){if(e?.filesChanged)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{color:`diffAddedWord`,children:[`+`,e.insertions,` `]}),(0,Y.jsxs)(B,{color:`diffRemovedWord`,children:[`-`,e.deletions]})]})}function Be({userMessage:e,color:t,dimColor:n,isCurrent:r,paddingRight:i}){let{columns:a}=se();if(r)return(0,Y.jsx)(z,{width:`100%`,children:(0,Y.jsx)(B,{italic:!0,color:t,dimColor:n,children:`(current)`})});let o=e.message.content,s=typeof o==`string`?null:o[o.length-1],c=H(typeof o==`string`?o.trim():s&&Pe(s)?s.text.trim():`(no prompt)`);if(ne(c))return(0,Y.jsx)(z,{flexDirection:`row`,width:`100%`,children:(0,Y.jsx)(B,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(c.includes(`<bash-input>`)){let e=F(c,`bash-input`);if(e)return(0,Y.jsxs)(z,{flexDirection:`row`,width:`100%`,children:[(0,Y.jsx)(B,{color:`bashBorder`,children:`!`}),(0,Y.jsxs)(B,{color:t,dimColor:n,children:[` `,e]})]})}if(c.includes(`<command-message>`)){let e=F(c,ge),r=F(c,`command-args`),i=F(c,`skill-format`)===`true`;if(e)return i?(0,Y.jsx)(z,{flexDirection:`row`,width:`100%`,children:(0,Y.jsxs)(B,{color:t,dimColor:n,children:[`Skill(`,e,`)`]})}):(0,Y.jsx)(z,{flexDirection:`row`,width:`100%`,children:(0,Y.jsxs)(B,{color:t,dimColor:n,children:[`/`,e,` `,r]})})}return(0,Y.jsx)(z,{flexDirection:`row`,width:`100%`,children:(0,Y.jsx)(B,{color:t,dimColor:n,children:i?_e(c,a-i,!0):c.slice(0,500).split(`
2
+ `).slice(0,4).join(`
3
+ `)})})}function Ve(e,t,n){let r=e.findIndex(e=>e.uuid===t);if(r===-1)return;let i=n?e.findIndex(e=>e.uuid===n):e.length;i===-1&&(i=e.length);let a=[],o=0,s=0;for(let t=r+1;t<i;t++){let n=e[t];if(!n||!c(n))continue;let r=n.toolUseResult;if(!(!r?.filePath||!r.structuredPatch)){a.includes(r.filePath)||a.push(r.filePath);try{if(`type`in r&&r.type===`create`)o+=r.content.split(/\r?\n/).length;else for(let e of r.structuredPatch){let t=V(e.lines,e=>e.startsWith(`+`)),n=V(e.lines,e=>e.startsWith(`-`));o+=t,s+=n}}catch{}}}return{filesChanged:a,insertions:o,deletions:s}}function He(e){if(e.type!==`user`||Array.isArray(e.message.content)&&e.message.content[0]?.type===`tool_result`||p(e)||e.isMeta||e.isCompactSummary||e.isVisibleInTranscriptOnly)return!1;let t=e.message.content,n=typeof t==`string`?null:t[t.length-1],r=typeof t==`string`?t.trim():n&&Pe(n)?n.text.trim():``;return!(r.indexOf(`<local-command-stdout>`)!==-1||r.indexOf(`<local-command-stderr>`)!==-1||r.indexOf(`<bash-stdout>`)!==-1||r.indexOf(`<bash-stderr>`)!==-1||r.indexOf(`<task-notification>`)!==-1||r.indexOf(`<tick>`)!==-1)}function Ue(e,t){for(let n=t+1;n<e.length;n++){let t=e[n];if(t&&!p(t)&&!c(t)&&t.type!==`progress`&&t.type!==`system`&&t.type!==`attachment`&&!(t.type===`user`&&t.isMeta)){if(t.type===`assistant`){let e=t.message.content;if(Array.isArray(e)&&e.some(e=>e.type===`text`&&e.text.trim()||e.type===`tool_use`))return!1;continue}if(t.type===`user`)return!1}}return!0}var $,We=e((()=>{r(),W(),v(),x(),Ee(),R(),T(),g(),N(),d(),$=7}));export{He as a,Ue as i,Ne as n,Ae as o,We as r,Fe as t};
@@ -0,0 +1,10 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$f as o,Ax as s,BS as c,Bw as l,Cm as u,Eh as d,FS as f,GS as p,Gf as m,IS as h,LS as g,NS as _,PS as v,Qf as y,Sm as b,Ta as x,Th as S,Tw as C,VS as w,Vw as T,Wf as ee,_f as E,aa as D,af as te,ag as ne,ba as re,bf as ie,ca as ae,da as oe,ea as se,ga as O,gf as k,gu as A,hu as j,hy as ce,ia as le,jS as ue,jx as de,kx as M,lT as N,la as fe,ma as pe,mu as P,mw as me,nT as he,oT as ge,oa as _e,of as ve,pf as ye,sa as be,sf as xe,tT as Se,va as Ce,vf as we,vh as Te,vw as Ee,vy as De,xf as F,xy as Oe,yf as ke,yh as Ae,yw as je,yy as Me,zw as I}from"./loadAgentsDir-C96o6gCj.js";import{C as Ne,Gr as L,I as R,N as Pe,P as z,Pn as Fe,Rn as Ie,ai as B,di as Le,fi as Re,j as ze,mt as Be,ot as Ve,t as V,xt as He}from"./src-DL3w8VPk.js";import{t as H}from"./jsx-runtime-Bb4Xn-E0.js";import{Ut as Ue,z as We}from"./state-D5D6QpTX.js";import{n as Ge,t as Ke}from"./cwd-Nh5IZNKO.js";import{a as qe,c as Je,i as Ye,n as Xe,o as Ze}from"./debug-D58GQBDG.js";import{Ut as Qe,Vt as $e,h as et,t as tt}from"./settings-BowI3jp-.js";import{c as nt,h as rt,y as it}from"./config-DUTgj3js.js";import{B as at,L as ot,R as st,q as ct}from"./log-CZ7ploQm.js";import{b as lt,f as ut,m as dt,v as ft}from"./startupProfiler-B90b5vuq.js";import{l as pt,o as mt}from"./stringUtils-D7oJIyY2.js";import{E as ht,Pt as gt,_ as _t,b as vt,dn as yt,fn as bt,gt as xt,xt as St,yt as Ct,zt as wt}from"./model-BaMclMXn.js";import{gn as Tt,vn as Et}from"./prompt-BNNE5tsG.js";import{d as Dt,f as Ot,h as kt,p as At}from"./terminalSetup-a7-BNS4T.js";import{at as jt,st as Mt}from"./sessionState-8jutEorw.js";import{n as Nt,t as Pt}from"./systemTheme-Ceakddth.js";import{n as Ft,r as It}from"./PromptInputFooterSuggestions-Blzgj5yW.js";import{n as Lt,t as Rt}from"./useMainLoopModel-VXeS2EC6.js";import{n as zt,t as Bt}from"./modalContext-DDZdU1J8.js";import{n as Vt,r as Ht,t as Ut}from"./statusNoticeHelpers-BrpQWj0l.js";import{a as Wt,c as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,t as Zt,u as Qt}from"./logoUtils-Cg_6QV1Z.js";import{homedir as $t}from"os";import{relative as en}from"path";import{fileURLToPath as tn}from"url";function nn(e,t){for(let n of e)if(!t.has(n))return!1;return!0}var rn=e((()=>{}));function an(e){if(e.type!==`user`)return!1;let t=Array.isArray(e.message.content)?e.message.content[0]:void 0;return!t||typeof t==`string`||t?.type!==`text`||!t.text.includes(`<task-notification`)||me(t.text,`status`)!==`completed`?!1:me(t.text,`summary`)?.startsWith(`Background command `)??!1}function on(e,t){if(!Ae()||t)return e;let n=[],r=0;for(;r<e.length;){let t=e[r];if(an(t)){let i=0;for(;r<e.length&&an(e[r]);)i++,r++;i===1?n.push(t):n.push({...t,message:{role:`user`,content:[{type:`text`,text:`<${at}><${ot}>completed</${ot}><${st}>${i} background commands completed</${st}></${at}>`}]}})}else n.push(t),r++}return n}var sn=e((()=>{ct(),ne(),Te(),se()}));function cn(e){return e.type===`system`&&e.subtype===`stop_hook_summary`&&e.hookLabel!==void 0}function ln(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(cn(r)){let i=r.hookLabel,a=[];for(;n<e.length;){let t=e[n];if(!cn(t)||t.hookLabel!==i)break;a.push(t),n++}a.length===1?t.push(r):t.push({...r,hookCount:a.reduce((e,t)=>e+t.hookCount,0),hookInfos:a.flatMap(e=>e.hookInfos),hookErrors:a.flatMap(e=>e.hookErrors),preventedContinuation:a.some(e=>e.preventedContinuation),hasOutput:a.some(e=>e.hasOutput),totalDurationMs:Math.max(...a.map(e=>e.totalDurationMs??0))})}else t.push(r),n++}return t}var un=e((()=>{}));function dn(e){let t=mn.get(e);return t||(t=new Set(e.filter(e=>e.renderGroupedToolUse).map(e=>e.name)),mn.set(e,t)),t}function fn(e){if(e.type===`assistant`&&e.message?.content&&Array.isArray(e.message.content)&&e.message.content[0]?.type===`tool_use`){let t=e.message.content[0];return{messageId:e.message.id,toolUseId:t.id,toolName:t.name}}return null}function pn(e,t,n=!1){if(n)return{messages:e};let r=dn(t),i=new Map;for(let t of e){let e=fn(t);if(e&&r.has(e.toolName)){let n=`${e.messageId}:${e.toolName}`,r=i.get(n)??[];r.push(t),i.set(n,r)}}let a=new Map,o=new Set;for(let[e,t]of i)if(t.length>=2){a.set(e,t);for(let e of t){let t=fn(e);t&&o.add(t.toolUseId)}}let s=new Map;for(let t of e)if(t.type===`user`&&t.message?.content&&Array.isArray(t.message.content))for(let e of t.message.content)e.type===`tool_result`&&o.has(e.tool_use_id)&&s.set(e.tool_use_id,t);let c=[],l=new Set;for(let t of e){let e=fn(t);if(e){let t=`${e.messageId}:${e.toolName}`,n=a.get(t);if(n){if(!l.has(t)){l.add(t);let r=n[0],i=[];for(let e of n){let t=e.message.content[0].id,n=s.get(t);n&&i.push(n)}let a={type:`grouped_tool_use`,toolName:e.toolName,messages:n,results:i,displayMessage:r,uuid:`grouped-${r.uuid}`,timestamp:r.timestamp,messageId:e.messageId};c.push(a)}continue}}if(t.type===`user`&&t.message?.content&&Array.isArray(t.message.content)){let e=t.message.content.filter(e=>e.type===`tool_result`);if(e.length>0&&e.every(e=>o.has(e.tool_use_id)))continue}c.push(t)}return{messages:c}}var mn,hn=e((()=>{mn=new WeakMap}));function gn(e){let t=Sn.get(e);if(t!==void 0)return t;let n=_n(e).toLowerCase();return Sn.set(e,n),n}function _n(e){let t=``;switch(e.type){case`user`:{let n=e.message.content;if(typeof n==`string`)t=xn.has(n)?``:n;else{let r=[];for(let t of n??[])t.type===`text`?xn.has(t.text)||r.push(t.text):t.type===`tool_result`&&r.push(yn(e.toolUseResult));t=r.join(`
2
+ `)}break}case`assistant`:{let n=e.message.content;Array.isArray(n)&&(t=n.flatMap(e=>e.type===`text`?[e.text]:e.type===`tool_use`?[vn(e.input)]:[]).join(`
3
+ `));break}case`attachment`:if(e.attachment.type===`relevant_memories`)t=(e.attachment.memories??[]).map(e=>e.content).join(`
4
+ `);else if(e.attachment.type===`queued_command`&&e.attachment.commandMode!==`task-notification`&&!e.attachment.isMeta){let n=e.attachment.prompt;t=typeof n==`string`?n:n.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
5
+ `)}break;case`collapsed_read_search`:e.relevantMemories&&(t=e.relevantMemories.map(e=>e.content).join(`
6
+ `));break;default:break}let n=t,r=n.indexOf(`<system-reminder>`);for(;r>=0;){let e=n.indexOf(bn,r);if(e<0)break;n=n.slice(0,r)+n.slice(e+18),r=n.indexOf(`<system-reminder>`)}return n}function vn(e){if(!e||typeof e!=`object`)return``;let t=e,n=[];for(let e of[`command`,`pattern`,`file_path`,`path`,`prompt`,`description`,`query`,`url`,`skill`]){let r=t[e];typeof r==`string`&&n.push(r)}for(let e of[`args`,`files`]){let r=t[e];Array.isArray(r)&&r.every(e=>typeof e==`string`)&&n.push(r.join(` `))}return n.join(`
7
+ `)}function yn(e){if(!e||typeof e!=`object`)return typeof e==`string`?e:``;let t=e;if(typeof t.stdout==`string`){let e=typeof t.stderr==`string`?t.stderr:``;return t.stdout+(e?`\n${e}`:``)}if(t.file&&typeof t.file==`object`&&typeof t.file.content==`string`)return t.file.content;let n=[];for(let e of[`content`,`output`,`result`,`text`,`message`]){let r=t[e];typeof r==`string`&&n.push(r)}for(let e of[`filenames`,`lines`,`results`]){let r=t[e];Array.isArray(r)&&r.every(e=>typeof e==`string`)&&n.push(r.join(`
8
+ `))}return n.join(`
9
+ `)}var bn,xn,Sn,Cn=e((()=>{se(),bn=`</system-reminder>`,xn=new Set([l,T]),Sn=new WeakMap}));function wn({pose:e=`default`}={}){return(0,Tn.jsxs)(R,{flexDirection:`column`,alignItems:`center`,children:[(0,Tn.jsx)(z,{color:`clawd_body`,children:` █████ `}),(0,Tn.jsx)(z,{color:`clawd_body`,children:`██ ● ● ██`}),(0,Tn.jsx)(z,{color:`clawd_body`,children:`██ ▄▄▄ ██`}),(0,Tn.jsx)(z,{color:`clawd_body`,children:` █ █ █ █ `})]})}var Tn,En=e((()=>{V(),Tn=H()}));function Dn(e){let{title:t,lines:n,footer:r,emptyMessage:i,customContent:a}=e,o=L(t);if(a!==void 0)o=Math.max(o,a.width);else if(n.length===0&&i)o=Math.max(o,L(i));else{let e=Math.max(0,...n.map(e=>e.timestamp?L(e.timestamp):0));for(let t of n){let n=e>0?e:0,r=L(t.text)+(n>0?n+2:0);o=Math.max(o,r)}}return r&&(o=Math.max(o,L(r))),o}function On({config:e,actualWidth:t}){let{title:n,lines:r,footer:i,emptyMessage:a,customContent:o}=e,s=Math.max(0,...r.map(e=>e.timestamp?L(e.timestamp):0));return(0,U.jsxs)(R,{flexDirection:`column`,width:t,children:[(0,U.jsx)(z,{bold:!0,color:`claude`,children:n}),o?(0,U.jsxs)(U.Fragment,{children:[o.content,i&&(0,U.jsx)(z,{dimColor:!0,italic:!0,children:lt(i,t)})]}):r.length===0&&a?(0,U.jsx)(z,{dimColor:!0,children:lt(a,t)}):(0,U.jsxs)(U.Fragment,{children:[r.map((e,n)=>{let r=Math.max(10,t-(s>0?s+2:0));return(0,U.jsxs)(z,{children:[s>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(z,{dimColor:!0,children:(e.timestamp||``).padEnd(s)}),` `]}),(0,U.jsx)(z,{children:lt(e.text,r)})]},n)}),i&&(0,U.jsx)(z,{dimColor:!0,italic:!0,children:lt(i,t)})]})]})}var U,kn=e((()=>{V(),ft(),U=H()}));function An({feeds:e,maxWidth:t}){let n=e.map(e=>Dn(e)),r=Math.max(...n),i=Math.min(r,t);return(0,Mn.jsx)(R,{flexDirection:`column`,children:e.map((t,n)=>(0,Mn.jsxs)(jn.Fragment,{children:[(0,Mn.jsx)(On,{config:t,actualWidth:i}),n<e.length-1&&(0,Mn.jsx)(Ne,{color:`claude`,width:i})]},n))})}var jn,Mn,Nn=e((()=>{jn=t(B(),1),V(),kn(),Mn=H()}));function Pn(e){let t=e.map(e=>{let t=dt(e.modified);return{text:(e.summary&&e.summary!==`No prompt`?e.summary:e.firstPrompt)||``,timestamp:t}});return{title:`Recent activity`,lines:t,footer:t.length>0?`/resume for more`:void 0,emptyMessage:`No recent activity`}}function Fn(e){let t=e.filter(({isEnabled:e})=>e).sort((e,t)=>Number(e.isComplete)-Number(t.isComplete)).map(({text:e,isComplete:t})=>({text:`${t?`${a.tick} `:``}${e}`})),n=Ke()===$t()?`Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead.`:void 0;return n&&t.push({text:n}),{title:`Tips for getting started`,lines:t}}var In=e((()=>{i(),Ge(),ft()}));function Ln(e,t,n){return Array.from({length:n},()=>({pose:e,offset:t}))}function Rn(){let{pose:e,bounceOffset:t,onClick:n}=zn();return(0,Vn.jsx)(R,{height:qn,flexDirection:`column`,onClick:n,children:(0,Vn.jsx)(R,{marginTop:t,flexShrink:0,children:(0,Vn.jsx)(wn,{pose:e})})})}function zn(){let[e]=(0,Bn.useState)(()=>tt().prefersReducedMotion??!1),[t,n]=(0,Bn.useState)(-1),r=(0,Bn.useRef)(Hn),i=()=>{e||t!==-1||(r.current=Un[Math.floor(Math.random()*Un.length)],n(0))};(0,Bn.useEffect)(()=>{if(t===-1)return;if(t>=r.current.length){n(-1);return}let e=setTimeout(n,Gn,Kn);return()=>clearTimeout(e)},[t]);let a=r.current,o=t>=0&&t<a.length?a[t]:Wn;return{pose:o.pose,bounceOffset:o.offset,onClick:i}}var Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn=e((()=>{Bn=t(B(),1),V(),et(),En(),Vn=H(),Hn=[...Ln(`default`,1,2),...Ln(`arms-up`,0,3),...Ln(`default`,0,1),...Ln(`default`,1,2),...Ln(`arms-up`,0,3),...Ln(`default`,0,1)],Un=[Hn,[...Ln(`look-right`,0,5),...Ln(`look-left`,0,5),...Ln(`default`,0,1)]],Wn={pose:`default`,offset:0},Gn=60,Kn=e=>e+1,qn=3}));function Yn(){let{columns:e}=Ve(),t=d(e=>e.agent),n=ht(Lt()),{version:r,cwd:i,billingType:a,agentName:o}=Yt(),s=t??o,c=Math.max(e-15,20),l=lt(r,Math.max(c-11,6)),{shouldSplit:u,truncatedModel:f,truncatedBilling:p}=Xt(n,a,c),m=s?c-1-L(s)-3:c,h=Qt(i,Math.max(m,10));return(0,W.jsx)(b,{children:(0,W.jsxs)(R,{flexDirection:`row`,gap:2,alignItems:`center`,children:[Ae()?(0,W.jsx)(Rn,{}):(0,W.jsx)(wn,{}),(0,W.jsxs)(R,{flexDirection:`column`,children:[(0,W.jsxs)(z,{children:[(0,W.jsx)(z,{bold:!0,children:`Work Mate`}),` `,(0,W.jsxs)(z,{dimColor:!0,children:[`v`,l]})]}),u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(z,{dimColor:!0,children:f}),(0,W.jsx)(z,{dimColor:!0,children:p})]}):(0,W.jsxs)(z,{dimColor:!0,children:[f,` · `,p]}),(0,W.jsx)(z,{dimColor:!0,children:s?`@${s} · ${h}`:h})]})]})})}var W,Xn=e((()=>{Rt(),p(),V(),S(),ft(),Te(),qt(),_t(),u(),Jn(),En(),W=H()}));function Zn(){let e=(0,$n.useMemo)(Qn,[]),t=(0,$n.useMemo)(()=>nt().lastShownEmergencyTip,[]),n=e.tip&&e.tip!==t;return(0,$n.useEffect)(()=>{n&&it(t=>t.lastShownEmergencyTip===e.tip?t:{...t,lastShownEmergencyTip:e.tip})},[n,e.tip]),n?(0,er.jsx)(R,{paddingLeft:2,flexDirection:`column`,children:(0,er.jsx)(z,{...e.color===`warning`?{color:`warning`}:e.color===`error`?{color:`error`}:{dimColor:!0},children:e.tip})}):null}function Qn(){return tr}var $n,er,tr,nr=e((()=>{$n=t(B(),1),V(),rt(),er=H(),tr={tip:``,color:`dim`}}));function rr({char:e=`✻`}){let[t]=(0,ir.useState)(()=>tt().prefersReducedMotion??!1),[n,r]=(0,ir.useState)(t),i=(0,ir.useRef)(null),[a,o]=Be(n?null:50);return(0,ir.useEffect)(()=>{if(n)return;let e=setTimeout(r,sr,!0);return()=>clearTimeout(e)},[n]),n?(0,ar.jsx)(R,{ref:a,children:(0,ar.jsx)(z,{color:cr,children:e})}):(i.current===null&&(i.current=o),(0,ar.jsx)(R,{ref:a,children:(0,ar.jsx)(z,{color:A(P((o-i.current)/or*360%360)),children:e})}))}var ir,ar,or,sr,cr,lr=e((()=>{ir=t(B(),1),Qe(),V(),et(),j(),ar=H(),or=1500,sr=or*2,cr=A({r:153,g:153,b:153})}));function ur(){return vt()&&(nt().opus1mMergeNoticeSeenCount??0)<mr}function dr(){let[e]=(0,fr.useState)(ur);return(0,fr.useEffect)(()=>{if(!e)return;let t=(nt().opus1mMergeNoticeSeenCount??0)+1;it(e=>(e.opus1mMergeNoticeSeenCount??0)>=t?e:{...e,opus1mMergeNoticeSeenCount:t})},[e]),e?(0,pr.jsxs)(R,{paddingLeft:2,children:[(0,pr.jsx)(rr,{char:`↑`}),(0,pr.jsx)(z,{dimColor:!0,children:` Opus now defaults to 1M context · 5x more room, same pricing`})]}):null}var fr,pr,mr,hr=e((()=>{fr=t(B(),1),Qe(),V(),rt(),_t(),lr(),pr=H(),mr=6}));function gr(){let e=Gt(),t=nt().oauthAccount?.displayName??``,{columns:r}=Ve(),i=kt(),a=ge.isSandboxingEnabled(),o=d(e=>e.agent),s=nt(),[c]=(0,_r.useState)(()=>{let e=tt().companyAnnouncements;if(!(!e||e.length===0))return s.numStartups===1?e[0]:e[Math.floor(Math.random()*e.length)]});(0,_r.useEffect)(()=>{i&&Ot()},[i]),!i&&n(process.env.CLAUDE_CODE_FORCE_FULL_LOGO);let l=ht(Lt()),{version:u,cwd:f,billingType:p,agentName:m}=Yt(),h=o??m,g=lt(l,vr-20);if(!i&&!n(process.env.CLAUDE_CODE_FORCE_FULL_LOGO))return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Yn,{}),(0,G.jsx)(dr,{}),qe()&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[(0,G.jsx)(z,{color:`warning`,children:`Debug mode enabled`}),(0,G.jsxs)(z,{dimColor:!0,children:[`Logging to: `,Ze()?`stderr`:Xe()]})]}),(0,G.jsx)(Zn,{}),process.env.CLAUDE_CODE_TMUX_SESSION&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[(0,G.jsxs)(z,{dimColor:!0,children:[`tmux session: `,process.env.CLAUDE_CODE_TMUX_SESSION]}),(0,G.jsx)(z,{dimColor:!0,children:process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Work Mate uses ${process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),c&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[!process.env.IS_DEMO&&s.oauthAccount?.organizationName&&(0,G.jsxs)(z,{dimColor:!0,children:[`Message from `,s.oauthAccount.organizationName,`:`]}),(0,G.jsx)(z,{children:c})]})]});let _=Wt(r),v=Nt(nt().theme),y=` ${ze(`claude`,v)(`Work Mate`)} ${ze(`inactive`,v)(`v${u}`)} `,x=ze(`claude`,v)(` Work Mate `);if(_===`compact`){let e=Kt(t);L(e)>r-4&&(e=Kt(null));let n=h?r-4-1-L(h)-3:r-4,i=Qt(f,Math.max(n,10));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(b,{children:(0,G.jsxs)(R,{flexDirection:`column`,borderStyle:`round`,borderColor:`claude`,borderText:{content:x,position:`top`,align:`start`,offset:1},paddingX:1,paddingY:1,alignItems:`center`,width:r,children:[(0,G.jsx)(z,{bold:!0,children:e}),(0,G.jsx)(R,{marginY:1,children:(0,G.jsx)(wn,{})}),(0,G.jsx)(z,{dimColor:!0,children:g}),(0,G.jsx)(z,{dimColor:!0,children:p}),(0,G.jsx)(z,{dimColor:!0,children:h?`@${h} · ${i}`:i})]})}),(0,G.jsx)(dr,{}),a&&(0,G.jsx)(R,{marginTop:1,flexDirection:`column`,children:(0,G.jsx)(z,{color:`warning`,children:`Your bash commands will be sandboxed. Disable with /sandbox.`})})]})}let S=Kt(t),C=!process.env.IS_DEMO&&s.oauthAccount?.organizationName?`${g} · ${p} · ${s.oauthAccount.organizationName}`:`${g} · ${p}`,w=h?vr-1-L(h)-3:vr,T=Qt(f,Math.max(w,10)),ee=h?`@${h} · ${T}`:T,{leftWidth:E,rightWidth:D}=Zt(r,_,Jt(S,ee,C));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(b,{children:(0,G.jsx)(R,{flexDirection:`column`,borderStyle:`round`,borderColor:`claude`,borderText:{content:y,position:`top`,align:`start`,offset:3},children:(0,G.jsxs)(R,{flexDirection:_===`horizontal`?`row`:`column`,paddingX:1,gap:1,children:[(0,G.jsxs)(R,{flexDirection:`column`,width:E,justifyContent:`space-between`,alignItems:`center`,minHeight:9,children:[(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{bold:!0,children:S})}),(0,G.jsx)(wn,{}),(0,G.jsxs)(R,{flexDirection:`column`,alignItems:`center`,children:[(0,G.jsx)(z,{dimColor:!0,children:C}),(0,G.jsx)(z,{dimColor:!0,children:ee})]})]}),_===`horizontal`&&(0,G.jsx)(R,{height:`100%`,borderStyle:`single`,borderColor:`claude`,borderDimColor:!0,borderTop:!1,borderBottom:!1,borderLeft:!1}),_===`horizontal`&&(0,G.jsx)(An,{feeds:i?[Fn(Dt()),Pn(e)]:[Pn(e)],maxWidth:D})]})})}),(0,G.jsx)(dr,{}),qe()&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[(0,G.jsx)(z,{color:`warning`,children:`Debug mode enabled`}),(0,G.jsxs)(z,{dimColor:!0,children:[`Logging to: `,Ze()?`stderr`:Xe()]})]}),(0,G.jsx)(Zn,{}),process.env.CLAUDE_CODE_TMUX_SESSION&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[(0,G.jsxs)(z,{dimColor:!0,children:[`tmux session: `,process.env.CLAUDE_CODE_TMUX_SESSION]}),(0,G.jsx)(z,{dimColor:!0,children:process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Work Mate uses ${process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),c&&(0,G.jsxs)(R,{paddingLeft:2,flexDirection:`column`,children:[!process.env.IS_DEMO&&s.oauthAccount?.organizationName&&(0,G.jsxs)(z,{dimColor:!0,children:[`Message from `,s.oauthAccount.organizationName,`:`]}),(0,G.jsx)(z,{children:c})]}),a&&(0,G.jsx)(R,{paddingLeft:2,flexDirection:`column`,children:(0,G.jsx)(z,{color:`warning`,children:`Your bash commands will be sandboxed. Disable with /sandbox.`})})]})}var _r,G,vr,yr=e((()=>{V(),p(),qt(),ft(),En(),Nn(),In(),rt(),Pt(),et(),Ye(),_r=t(B(),1),At(),Xn(),u(),r(),nr(),hr(),N(),S(),Rt(),_t(),G=H(),vr=50}));function br({message:e,isTranscriptMode:t}){let n=e.message?.content,r=Array.isArray(n)?n:[];if(!(t&&e.type===`assistant`&&e.message?.model&&r.some(e=>e?.type===`text`)))return null;let i=e.message.model;return(0,xr.jsx)(R,{minWidth:L(i)+8,children:(0,xr.jsx)(z,{dimColor:!0,children:i})})}var xr,Sr=e((()=>{V(),xr=H()}));function Cr({message:e,isTranscriptMode:t}){if(!(t&&e.timestamp&&e.type===`assistant`&&Array.isArray(e.message.content)&&e.message.content.some(e=>e.type===`text`)))return null;let n=new Date(e.timestamp).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!0});return(0,wr.jsx)(R,{minWidth:L(n),children:(0,wr.jsx)(z,{dimColor:!0,children:n})})}var wr,Tr=e((()=>{V(),wr=H()}));function Er(e,t,n,r){for(let i=t+1;i<e.length;i++){let t=e[i];if(t?.type===`assistant`){let e=Nr(t.message.content);if(e?.type===`thinking`||e?.type===`redacted_thinking`||e?.type===`tool_use`&&(we(e.name,e.input,n).isCollapsible||r.has(e.id)))continue;return!0}if(!(t?.type===`system`||t?.type===`attachment`)&&!(t?.type===`user`&&Nr(t.message.content)?.type===`tool_result`)){if(t?.type===`grouped_tool_use`){let e=Nr(t.messages[0]?.message.content)?.input;if(we(t.toolName,e,n).isCollapsible)continue}return!0}}return!1}function Dr({message:e,isUserContinuation:t,hasContentAfter:n,tools:r,commands:i,verbose:a,inProgressToolUseIDs:o,streamingToolUseIDs:s,screen:c,canAnimate:l,lastThinkingBlockId:u,latestBashOutputUUID:d,columns:f,isLoading:p,lookups:m,shouldCollapseDiffs:h}){let g=c===`transcript`,_=e.type===`grouped_tool_use`,v=e.type===`collapsed_read_search`,y=v&&(ie(e,o)||p&&!n),x=_?e.displayMessage:v?E(e):e,S=_||v?[]:_e(e,m),C=qi(e,s,o,_||v?I:be(e,m),c,m),w=!1;if(l)if(_)w=e.messages.some(e=>{let t=Nr(e.message.content);return t?.type===`tool_use`&&o.has(t.id)});else if(v)w=ie(e,o);else{let t=je(e);w=!t||o.has(t)}let T=g&&x.type===`assistant`&&Array.isArray(x.message.content)&&x.message.content.some(e=>e.type===`text`)&&(x.timestamp||x.message.model),ee=(0,Mr.jsx)(te,{message:e,lookups:m,addMargin:!T,containerWidth:T?void 0:f,tools:r,commands:i,verbose:a,inProgressToolUseIDs:o,progressMessagesForMessage:S,shouldAnimate:w,shouldShowDot:!0,isTranscriptMode:g,isStatic:C,isActiveCollapsedGroup:y,isUserContinuation:t,lastThinkingBlockId:u,latestBashOutputUUID:d,shouldCollapseDiffs:h});return T?(0,Mr.jsx)(b,{children:(0,Mr.jsxs)(R,{width:f,flexDirection:`column`,children:[(0,Mr.jsxs)(R,{flexDirection:`row`,justifyContent:`flex-end`,gap:1,marginTop:1,children:[(0,Mr.jsx)(Cr,{message:x,isTranscriptMode:g}),(0,Mr.jsx)(br,{message:x,isTranscriptMode:g})]}),ee]})}):(0,Mr.jsx)(b,{children:ee})}function Or(e,t){if(e.type===`grouped_tool_use`)return e.messages.some(e=>{let n=Nr(e.message.content);return n?.type===`tool_use`&&t.has(n.id)});if(e.type===`collapsed_read_search`)return ke(e).some(e=>t.has(e));let n=je(e);return!!n&&t.has(n)}function kr(e,t){if(e.type===`grouped_tool_use`)return e.messages.every(e=>{let n=Nr(e.message.content);return n?.type===`tool_use`&&t.has(n.id)});if(e.type===`collapsed_read_search`)return ke(e).every(e=>t.has(e));if(e.type===`assistant`){let n=Nr(e.message.content);if(n?.type===`server_tool_use`)return t.has(n.id)}let n=je(e);return!n||t.has(n)}function Ar(e,t){if(e.message!==t.message||e.screen!==t.screen||e.verbose!==t.verbose||e.message.type===`collapsed_read_search`&&t.screen!==`transcript`||e.columns!==t.columns||e.latestBashOutputUUID===e.message.uuid!=(t.latestBashOutputUUID===t.message.uuid)||e.lastThinkingBlockId!==t.lastThinkingBlockId&&ve(t.message))return!1;let n=Or(e.message,e.streamingToolUseIDs),r=kr(e.message,e.lookups.resolvedToolUseIDs);return!(n||!r)}var jr,Mr,Nr,Pr,Fr=e((()=>{jr=t(B(),1),V(),F(),se(),xe(),Mr=H(),Sr(),ta(),Tr(),u(),Nr=e=>{if(!Array.isArray(e))return;let t=e[0];if(!(t==null||typeof t==`string`))return t},Pr=jr.memo(Dr,Ar)}));function Ir(e){return e.type===`attachment`&&Lr.has(e.attachment.type)}var Lr,Rr=e((()=>{Lr=new Set(`hook_success.hook_additional_context.hook_cancelled.command_permissions.agent_mention.budget_usd.critical_system_reminder.edited_image_file.edited_text_file.opened_file_in_ide.output_style.plan_mode.plan_mode_exit.plan_mode_reentry.structured_output.todo_reminder.context_efficiency.deferred_tools_delta.mcp_instructions_delta.token_usage.max_turns_reached.task_reminder.auto_mode.auto_mode_exit.output_token_usage.verify_plan_reminder.current_session_memory.compaction_reminder.date_change`.split(`.`))}));function zr(e){return Gr.filter(t=>t.isActive(e))}var K,Br,Vr,Hr,Ur,Wr,Gr,Kr=e((()=>{V(),Oe(),i(),Ge(),ft(),gt(),Ht(),K=H(),Br={id:`large-memory-files`,type:`warning`,isActive:e=>De(e.memoryFiles).length>0,render:e=>(0,K.jsx)(K.Fragment,{children:De(e.memoryFiles).map(e=>{let t=e.path.startsWith(Ke())?en(Ke(),e.path):e.path;return(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:a.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Large `,(0,K.jsx)(z,{bold:!0,children:t}),` will impact performance (`,ut(e.content.length),` chars > `,ut(ce),`)`,(0,K.jsx)(z,{dimColor:!0,children:` · /memory to edit`})]})]},e.path)})})},Vr={id:`claude-ai-external-token`,type:`warning`,isActive:()=>{let e=St();return wt()&&(e.source===`ANTHROPIC_AUTH_TOKEN`||e.source===`apiKeyHelper`)},render:()=>{let e=St();return(0,K.jsxs)(R,{flexDirection:`row`,marginTop:1,children:[(0,K.jsx)(z,{color:`warning`,children:a.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Auth conflict: Using `,e.source,` instead of Work Mate account subscription token. Either unset`,` `,e.source,", or run `claude /logout`."]})]})}},Hr={id:`api-key-conflict`,type:`warning`,isActive:()=>{let{source:e}=xt({skipRetrievingKeyFromApiKeyHelper:!0});return!!Ct()&&(e===`ANTHROPIC_API_KEY`||e===`apiKeyHelper`)},render:()=>{let{source:e}=xt({skipRetrievingKeyFromApiKeyHelper:!0});return(0,K.jsxs)(R,{flexDirection:`row`,marginTop:1,children:[(0,K.jsx)(z,{color:`warning`,children:a.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Auth conflict: Using `,e,` instead of Console key. Either unset `,e,", or run `claude /logout`."]})]})}},Ur={id:`both-auth-methods`,type:`warning`,isActive:()=>{let{source:e}=xt({skipRetrievingKeyFromApiKeyHelper:!0}),t=St();return e!==`none`&&t.source!==`none`&&!(e===`apiKeyHelper`&&t.source===`apiKeyHelper`)},render:()=>{let{source:e}=xt({skipRetrievingKeyFromApiKeyHelper:!0}),t=St();return(0,K.jsxs)(R,{flexDirection:`column`,marginTop:1,children:[(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:a.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Auth conflict: Both a token (`,t.source,`) and an API key (`,e,`) are set. This may lead to unexpected behavior.`]})]}),(0,K.jsxs)(R,{flexDirection:`column`,marginLeft:3,children:[(0,K.jsxs)(z,{color:`warning`,children:[`· Trying to use `,t.source===`claude.ai`?`claude.ai`:t.source,`?`,` `,e===`ANTHROPIC_API_KEY`?`Unset the ANTHROPIC_API_KEY environment variable, or claude /logout then say "No" to the API key approval before login.`:e===`apiKeyHelper`?`Unset the apiKeyHelper setting.`:`claude /logout`]}),(0,K.jsxs)(z,{color:`warning`,children:[`· Trying to use `,e,`?`,` `,t.source===`claude.ai`?`claude /logout to sign out of claude.ai.`:`Unset the ${t.source} environment variable.`]})]})]})}},Wr={id:`large-agent-descriptions`,type:`warning`,isActive:e=>Vt(e.agentDefinitions)>Ut,render:e=>{let t=Vt(e.agentDefinitions);return(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:a.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Large cumulative agent descriptions will impact performance (~`,ut(t),` tokens > `,ut(Ut),`)`,(0,K.jsx)(z,{dimColor:!0,children:` · /agents to manage`})]})]})}},Gr=[Br,Wr,Vr,Hr,Ur]}));function qr({agentDefinitions:e}={}){let t={config:nt(),agentDefinitions:e,memoryFiles:(0,Yr.use)(Me())},n=zr(t);return n.length===0?null:(0,Xr.jsx)(R,{flexDirection:`column`,paddingLeft:1,children:n.map(e=>(0,Xr.jsx)(Jr.Fragment,{children:e.render(t)},e.id))})}var Jr,Yr,Xr,Zr=e((()=>{Jr=t(B(),1),Yr=t(B(),1),V(),Oe(),rt(),Kr(),Xr=H()}));function Qr(e,t,n){let r=(0,q.useRef)(new Map),i=(0,q.useRef)(0),a=(0,q.useRef)(0),o=(0,q.useRef)({arr:new Float64Array,version:-1,n:-1}),s=(0,q.useRef)(new Map),c=(0,q.useRef)(new Map),l=(0,q.useRef)(n),u=(0,q.useRef)(!1),d=(0,q.useRef)(null),f=(0,q.useRef)(0);if(l.current!==n){let e=l.current/n;l.current=n;for(let[t,n]of r.current)r.current.set(t,Math.max(1,Math.round(n*e)));i.current++,u.current=!0,f.current=2}let p=f.current>0?d.current:null,m=(0,q.useRef)(0),h=(0,q.useRef)(null);(0,q.useSyncExternalStore)((0,q.useCallback)(t=>e.current?.subscribe(t)??oi,[e]),()=>{let t=e.current;if(!t)return NaN;let n=t.getScrollTop()+t.getPendingDelta(),r=Math.floor(n/ni);return t.isSticky()?~r:r});let g=e.current?.getScrollTop()??-1,_=e.current?.getPendingDelta()??0,v=e.current?.getViewportHeight()??0,y=e.current?.isSticky()??!0;(0,q.useMemo)(()=>{let e=new Set(t),n=!1;for(let t of r.current.keys())e.has(t)||(r.current.delete(t),n=!0);for(let t of c.current.keys())e.has(t)||c.current.delete(t);n&&i.current++},[t]);let b=t.length;if(o.current.version!==i.current||o.current.n!==b){let e=o.current.arr.length>=b+1?o.current.arr:new Float64Array(b+1);e[0]=0;for(let n=0;n<b;n++)e[n+1]=e[n]+(r.current.get(t[n])??$r);o.current={arr:e,version:i.current,n:b}}let x=o.current.arr,S=x[b],C,w;if(p)[C,w]=p,C=Math.min(C,b),w=Math.min(w,b);else if(v===0||g<0)C=Math.max(0,b-ti),w=b;else{if(y){let e=v+ei;for(C=b;C>0&&S-x[C-1]<e;)C--;w=b}else{let e=m.current,n=v*3,i=Math.min(g,g+_),a=Math.max(g,g+_),o=a-i,c=o>n&&_<0?a-n:i,l=c+Math.min(o,n),u=Math.max(0,c-e),f=l-e,p=u-ei;{let e=0,t=b;for(;e<t;){let n=e+t>>1;x[n+1]<=p?e=n+1:t=n}C=e}{let e=d.current;if(e&&e[0]<C)for(let n=e[0];n<Math.min(C,e[1]);n++){let e=t[n];if(s.current.has(e)&&!r.current.has(e)){C=n;break}}}let h=v+2*ei,y=Math.min(b,C+ii),S=0;for(w=C;w<y&&(S<h||x[w]<f+v+ei);)S+=r.current.get(t[w])??ri,w++}let e=v+2*ei,n=Math.max(0,w-ii),i=0;for(let e=C;e<w;e++)i+=r.current.get(t[e])??ri;for(;C>n&&i<e;)C--,i+=r.current.get(t[C])??ri;let o=d.current,c=Math.abs(g-a.current)+Math.abs(_);if(o&&c>v*2){let[e,t]=o;C<e-ai&&(C=e-ai),w>t+ai&&(w=t+ai),C>w&&(w=Math.min(C+ai,b))}a.current=g}f.current>0?f.current--:d.current=[C,w];let T=(0,q.useDeferredValue)(C),ee=(0,q.useDeferredValue)(w),E=C<T?T:C,D=w>ee?ee:w;if((E>D||y)&&(E=C,D=w),_>0&&(D=w),D-E>ii){let e=(x[E]+x[D])/2;g-m.current<e?D=E+ii:E=D-ii}let te=m.current,ne=x[E],re=E===0?0:ne+te,ie=D===b?1/0:Math.max(ne,x[D]-v)+te;(0,q.useLayoutEffect)(()=>{y?e.current?.setClampBounds(void 0,void 0):e.current?.setClampBounds(re,ie)}),(0,q.useLayoutEffect)(()=>{let e=h.current?.yogaNode;if(e&&e.getComputedWidth()>0&&(m.current=e.getComputedTop()),u.current){u.current=!1;return}let t=!1;for(let[e,n]of s.current){let i=n.yogaNode;if(!i)continue;let a=i.getComputedHeight(),o=r.current.get(e);a>0?o!==a&&(r.current.set(e,a),t=!0):i.getComputedWidth()>0&&o!==0&&(r.current.set(e,0),t=!0)}t&&i.current++});let ae=(0,q.useCallback)(e=>{let t=c.current.get(e);return t||(t=t=>{if(t)s.current.set(e,t);else{let t=s.current.get(e)?.yogaNode;if(t&&!u.current){let n=t.getComputedHeight();(n>0||t.getComputedWidth()>0)&&r.current.get(e)!==n&&(r.current.set(e,n),i.current++)}s.current.delete(e)}},c.current.set(e,t)),t},[]),oe=(0,q.useCallback)(e=>{let n=s.current.get(t[e])?.yogaNode;return!n||n.getComputedWidth()===0?-1:n.getComputedTop()},[t]),se=(0,q.useCallback)(e=>s.current.get(t[e])??null,[t]),O=(0,q.useCallback)(e=>r.current.get(t[e]),[t]),k=(0,q.useCallback)(t=>{let n=o.current;t<0||t>=n.n||e.current?.scrollTo(n.arr[t]+m.current)},[e]),A=S-x[D];return{range:[E,D],topSpacer:ne,bottomSpacer:A,measureRef:ae,spacerRef:h,offsets:x,getItemTop:oe,getItemElement:se,getItemHeight:O,scrollToIndex:k}}var q,$r,ei,ti,ni,ri,ii,ai,oi,si=e((()=>{q=t(B(),1),$r=3,ei=40,ti=30,ni=20,ri=1,ii=200,ai=25,oi=()=>{}}));function ci({children:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null);return(0,pi.jsx)(hi.Provider,{value:n,children:(0,pi.jsx)(_i.Provider,{value:i,children:(0,pi.jsx)(mi.Provider,{value:t,children:(0,pi.jsx)(gi.Provider,{value:r,children:e})})})})}function li(){return(0,J.useContext)(mi)}function ui(){return(0,J.useContext)(gi)}function di(e){let t=(0,J.useContext)(hi);(0,J.useEffect)(()=>{if(t)return t(e),()=>t(null)},[t,e])}function fi(e){let t=(0,J.useContext)(_i);(0,J.useEffect)(()=>{if(t)return t(e),()=>t(null)},[t,e])}var J,pi,mi,hi,gi,_i,vi=e((()=>{J=t(B(),1),pi=H(),mi=(0,J.createContext)(null),hi=(0,J.createContext)(null),gi=(0,J.createContext)(null),_i=(0,J.createContext)(null)}));function yi(e){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(e);r.current=e;let i=(0,Y.useRef)(null),a=(0,Y.useCallback)(()=>{n(null)},[]),o=(0,Y.useCallback)(e=>{let t=Math.max(0,e.getScrollHeight()-e.getViewportHeight());e.getScrollTop()+e.getPendingDelta()>=t||i.current===null&&(i.current=e.getScrollHeight(),n(r.current))},[]),s=(0,Y.useCallback)(e=>{e&&e.scrollToBottom()},[]);return(0,Y.useEffect)(()=>{t===null?i.current=null:e<t&&(i.current=null,n(null))},[e,t]),{dividerIndex:t,dividerYRef:i,onScrollAway:o,onRepin:a,jumpToNew:s,shiftDivider:(0,Y.useCallback)((e,t)=>{n(t=>t===null?null:t+e),i.current!==null&&(i.current+=t)},[])}}function bi(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(t.type===`progress`||t.type===`assistant`&&!xi(t))continue;let a=t.type===`assistant`;a&&!r&&n++,r=a}return n}function xi(e){if(e.type!==`assistant`||!Array.isArray(e.message.content))return!1;for(let t of e.message.content)if(typeof t!=`string`&&t.type===`text`&&t.text.trim()!==``)return!0;return!1}function Si(e,t){if(t===null)return;let n=t;for(;n<e.length&&(e[n]?.type===`progress`||Ir(e[n]));)n++;let r=e[n]?.uuid;if(!r)return;let i=bi(e,t);return{firstUnseenUuid:r,count:Math.max(1,i)}}function Ci({scrollable:e,bottom:t,overlay:n,bottomFloat:r,modal:i,modalScrollRef:a,scrollRef:o,dividerYRef:c,hidePill:l=!1,hideSticky:u=!1,newMessageCount:d=0,onPillClick:f}){let{rows:p,columns:m}=Ve(),[h,g]=(0,Y.useState)(null),_=(0,Y.useMemo)(()=>({setStickyPrompt:g}),[]),v=(0,Y.useSyncExternalStore)((0,Y.useCallback)(e=>o?.current?.subscribe(e)??(()=>{}),[o]),()=>{let e=o?.current,t=c?.current;return!e||t==null?!1:e.getScrollTop()+e.getPendingDelta()+e.getViewportHeight()<t});if((0,Y.useLayoutEffect)(()=>{if(!Ae())return;let e=Ie.get(process.stdout);if(e)return e.onHyperlinkClick=e=>{if(e.startsWith(`file:`))try{de(tn(e))}catch{}else s(e)},()=>{e.onHyperlinkClick=void 0}},[]),Ae()){let s=u?null:h,c=s!=null&&s!==`clicked`&&n==null?s:null,g=s!=null&&n==null;return(0,X.jsxs)(ci,{children:[(0,X.jsx)(R,{flexDirection:`row`,flexGrow:1,overflow:`hidden`,width:`100%`,children:(0,X.jsxs)(R,{flexDirection:`column`,flexGrow:1,width:m,overflow:`hidden`,children:[(0,X.jsxs)(R,{flexGrow:1,flexDirection:`column`,overflow:`hidden`,children:[c&&(0,X.jsx)(Ti,{text:c.text,onClick:c.scrollTo}),(0,X.jsxs)(He,{ref:o,flexGrow:1,flexDirection:`column`,paddingTop:+!g,stickyScroll:!0,children:[(0,X.jsx)(ki,{value:_,children:e}),n]}),!l&&v&&n==null&&(0,X.jsx)(wi,{count:d,onClick:f}),r!=null&&(0,X.jsx)(R,{position:`absolute`,bottom:0,right:0,opaque:!0,children:r})]}),(0,X.jsxs)(R,{flexDirection:`column`,flexShrink:0,width:`100%`,maxHeight:`50%`,children:[(0,X.jsx)(Ei,{}),(0,X.jsx)(Di,{}),(0,X.jsx)(R,{flexDirection:`column`,width:`100%`,flexGrow:1,overflowY:`hidden`,children:t})]})]})}),i!=null&&(0,X.jsx)(Bt,{value:{rows:p-Oi-1,columns:m-4,scrollRef:a??null},children:(0,X.jsxs)(R,{position:`absolute`,bottom:0,left:0,right:0,maxHeight:p-Oi,flexDirection:`column`,overflow:`hidden`,opaque:!0,children:[(0,X.jsx)(R,{flexShrink:0,children:(0,X.jsx)(z,{color:`permission`,children:`▔`.repeat(m)})}),(0,X.jsx)(R,{flexDirection:`column`,paddingX:2,flexShrink:0,overflow:`hidden`,children:i})]})})]})}return(0,X.jsxs)(X.Fragment,{children:[e,t,n,i]})}function wi({count:e,onClick:t}){let[n,r]=(0,Y.useState)(!1);return(0,X.jsx)(R,{position:`absolute`,bottom:0,left:0,right:0,justifyContent:`center`,children:(0,X.jsx)(R,{onClick:t,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:(0,X.jsxs)(z,{backgroundColor:n?`userMessageBackgroundHover`:`userMessageBackground`,dimColor:!0,children:[` `,e>0?`${e} new ${pt(e,`message`)}`:`Jump to bottom`,` `,a.arrowDown,` `]})})})}function Ti({text:e,onClick:t}){let[n,r]=(0,Y.useState)(!1);return(0,X.jsx)(R,{flexShrink:0,width:`100%`,height:1,paddingRight:1,backgroundColor:n?`userMessageBackgroundHover`:`userMessageBackground`,onClick:t,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:(0,X.jsxs)(z,{color:`subtle`,wrap:`truncate-end`,children:[a.pointer,` `,e]})})}function Ei(){let e=li();return!e||e.suggestions.length===0?null:(0,X.jsx)(R,{position:`absolute`,bottom:`100%`,left:0,right:0,paddingX:2,paddingTop:1,flexDirection:`column`,opaque:!0,children:(0,X.jsx)(Ft,{suggestions:e.suggestions,selectedSuggestion:e.selectedSuggestion,maxColumnWidth:e.maxColumnWidth,overlay:!0})})}function Di(){let e=ui();return e?(0,X.jsx)(R,{position:`absolute`,bottom:`100%`,left:0,right:0,opaque:!0,children:e}):null}var Y,X,Oi,ki,Ai=e((()=>{i(),Y=t(B(),1),zt(),vi(),p(),V(),M(),Te(),mt(),Rr(),It(),X=H(),Oi=2,ki=(0,Y.createContext)({setStickyPrompt:()=>{}})}));function ji(e){let t=zi.get(e);if(t!==void 0)return t;let n=gn(e);return zi.set(e,n),n}function Mi(e){let t=Vi.get(e);if(t!==void 0)return t;let n=Ni(e);return Vi.set(e,n),n}function Ni(e){let t=null;if(e.type===`user`){if(e.isMeta||e.isVisibleInTranscriptOnly)return null;let n=e.message.content[0];if(n?.type!==`text`)return null;t=n.text??null}else if(e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode!==`task-notification`&&!e.attachment.isMeta){let n=e.attachment.prompt;t=typeof n==`string`?n:n.flatMap(e=>e.type===`text`?[e.text??``]:[]).join(`
10
+ `)}if(t===null)return null;let n=h(t);return n.startsWith(`<`)||n===``?null:n}function Pi({itemKey:e,msg:t,idx:n,measureRef:r,expanded:i,hovered:a,clickable:o,onClickK:s,onEnterK:c,onLeaveK:l,renderItem:u}){return(0,Li.jsx)(R,{ref:r(e),flexDirection:`column`,backgroundColor:i?`userMessageBackgroundHover`:void 0,paddingBottom:i?1:void 0,onClick:o?e=>s(t,e.cellIsBlank):void 0,onMouseEnter:o?()=>c(e):void 0,onMouseLeave:o?()=>l(e):void 0,children:(0,Li.jsx)(Pe.Provider,{value:a&&!i?`text`:void 0,children:u(t,n)})})}function Fi({messages:e,scrollRef:t,columns:n,itemKey:r,renderItem:i,onItemClick:a,isItemClickable:o,isItemExpanded:s,extractSearchText:c=ji,trackStickyPrompt:l,selectedIndex:u,cursorNavRef:d,setCursor:p,jumpRef:m,onSearchMatchesChange:h,scanElement:_,setPositions:v}){let y=(0,Z.useRef)([]),b=(0,Z.useRef)(e),x=(0,Z.useRef)(r);if(x.current!==r||e.length<y.current.length||e[0]!==b.current[0])y.current=e.map(e=>r(e));else for(let t=y.current.length;t<e.length;t++)y.current.push(r(e[t]));b.current=e,x.current=r;let S=y.current,{range:C,topSpacer:w,bottomSpacer:T,measureRef:ee,spacerRef:E,offsets:D,getItemTop:te,getItemElement:ne,getItemHeight:re,scrollToIndex:ie}=Qr(t,S,n),[ae,oe]=C,se=(0,Z.useCallback)(t=>re(t)!==0&&f(e[t]),[re,e]);(0,Z.useImperativeHandle)(d,()=>{let n=e=>p?.({uuid:e.uuid,msgType:e.type,expanded:!1,toolName:g(e)?.name}),r=u??-1,i=(t,r,i=se)=>{for(let a=t;a>=0&&a<e.length;a+=r)if(i(a))return n(e[a]),!0;return!1},a=t=>se(t)&&e[t].type===`user`;return{enterCursor:()=>i(e.length-1,-1,a),navigatePrev:()=>i(r-1,-1),navigateNext:()=>{i(r+1,1)||(t.current?.scrollToBottom(),p?.(null))},navigatePrevUser:()=>i(r-1,-1,a),navigateNextUser:()=>i(r+1,1,a),navigateTop:()=>i(0,1),navigateBottom:()=>i(e.length-1,-1),getSelected:()=>r>=0?e[r]??null:null}},[e,u,p,se]);let O=(0,Z.useRef)({offsets:D,start:ae,getItemElement:ne,getItemTop:te,messages:e,scrollToIndex:ie});O.current={offsets:D,start:ae,getItemElement:ne,getItemTop:te,messages:e,scrollToIndex:ie},(0,Z.useEffect)(()=>{if(u===void 0)return;let e=O.current,n=e.getItemElement(u);n?t.current?.scrollToElement(n,1):e.scrollToIndex(u)},[u,t]);let k=(0,Z.useRef)(null),A=(0,Z.useRef)({msgIdx:-1,positions:[]}),j=(0,Z.useRef)(-1),ce=(0,Z.useRef)(0),le=(0,Z.useRef)(0),ue=(0,Z.useRef)(()=>{}),de=(0,Z.useRef)(()=>{}),M=(0,Z.useRef)({matches:[],ptr:0,screenOrd:0,prefixSum:[]}),N=(0,Z.useRef)(-1),fe=(0,Z.useRef)(!1);function pe(e){let t=O.current.getItemTop(e);return Math.max(0,t-Ri)}function P(e){let n=t.current,{msgIdx:r,positions:i}=A.current;if(!n||i.length===0||r<0){v?.(null);return}let a=Math.max(0,Math.min(e,i.length-1)),o=i[a],s=O.current.getItemTop(r),c=n.getViewportTop(),l=s-n.getScrollTop(),u=n.getViewportHeight(),d=c+l+o.row;(d<c||d>=c+u)&&(n.scrollTo(Math.max(0,s+o.row-Ri)),l=s-n.getScrollTop(),d=c+l+o.row),v?.({positions:i,rowOffset:c+l,currentIdx:a});let f=M.current,p=f.prefixSum.at(-1)??0,m=(f.prefixSum[f.ptr]??0)+a+1;h?.(p,m),Je(`highlight(i=${r}, ord=${a}/${i.length}): pos={row:${o.row},col:${o.col}} lo=${l} screenRow=${d} badge=${m}/${p}`)}de.current=P;let[me,he]=(0,Z.useState)(0),ge=(0,Z.useCallback)(()=>he(e=>e+1),[]);(0,Z.useEffect)(()=>{let e=k.current;if(!e)return;let{idx:n,wantLast:r,tries:i}=e,a=t.current;if(!a)return;let{getItemElement:o,getItemTop:s,scrollToIndex:c}=O.current,l=o(n),u=l?.yogaNode?.getComputedHeight()??0;if(!l||u===0){if(i>1){k.current=null,Je(`seek(i=${n}): no mount after scrollToIndex, skip`),ue.current(r?-1:1);return}k.current={idx:n,wantLast:r,tries:i+1},c(n),ge();return}k.current=null,a.scrollTo(Math.max(0,s(n)-Ri));let d=_?.(l)??[];if(A.current={msgIdx:n,positions:d},Je(`seek(i=${n} t=${i}): ${d.length} positions`),d.length===0){if(++ce.current>20){ce.current=0;return}ue.current(r?-1:1);return}ce.current=0;let f=r?d.length-1:0;M.current.screenOrd=f,j.current=-1,de.current(f);let p=le.current;p&&(le.current=0,ue.current(p))},[me]);function _e(e,n){let r=t.current;if(!r)return;let i=O.current,{getItemElement:a,scrollToIndex:o}=i;if(e<0||e>=i.messages.length)return;v?.(null),A.current={msgIdx:-1,positions:[]},k.current={idx:e,wantLast:n,tries:0};let s=a(e),c=s?.yogaNode?.getComputedHeight()??0;s&&c>0?r.scrollTo(pe(e)):o(e),ge()}function ve(e){let t=M.current,{matches:n,prefixSum:r}=t,i=r.at(-1)??0;if(n.length===0)return;if(k.current){le.current=e;return}j.current<0&&(j.current=t.ptr);let{positions:a}=A.current,o=t.screenOrd+e;if(o>=0&&o<a.length){t.screenOrd=o,P(o),j.current=-1;return}let s=(t.ptr+e+n.length)%n.length;if(s===j.current){v?.(null),j.current=-1,Je(`step: wraparound at ptr=${s}, all ${n.length} msgs phantoms`);return}t.ptr=s,t.screenOrd=0,_e(n[s],e<0);let c=e<0?r[s+1]??i:r[s]+1;h?.(i,c)}ue.current=ve,(0,Z.useImperativeHandle)(m,()=>({jumpToIndex:e=>{let n=t.current;n&&n.scrollTo(pe(e))},setSearchQuery:e=>{k.current=null,A.current={msgIdx:-1,positions:[]},j.current=-1,v?.(null);let n=e.toLowerCase(),r=[],i=[0];if(n){let e=O.current.messages;for(let t=0;t<e.length;t++){let a=c(e[t]),o=a.indexOf(n),s=0;for(;o>=0;)s++,o=a.indexOf(n,o+n.length);s>0&&(r.push(t),i.push(i.at(-1)+s))}}let a=i.at(-1),o=0,s=t.current,{offsets:l,start:u,getItemTop:d}=O.current,f=d(u),p=f>=0?f-l[u]:0;if(r.length>0&&s){let t=N.current>=0?N.current:s.getScrollTop(),n=1/0;for(let e=0;e<r.length;e++){let i=Math.abs(p+l[r[e]]-t);i<=n&&(n=i,o=e)}Je(`setSearchQuery('${e}'): ${r.length} msgs · ptr=${o} msgIdx=${r[o]} curTop=${t} origin=${p}`)}M.current={matches:r,ptr:o,screenOrd:0,prefixSum:i},r.length>0?_e(r[o],!0):N.current>=0&&s&&s.scrollTo(N.current),h?.(a,r.length>0?i[o+1]??a:0)},nextMatch:()=>ve(1),prevMatch:()=>ve(-1),setAnchor:()=>{let e=t.current;e&&(N.current=e.getScrollTop())},disarmSearch:()=>{v?.(null),k.current=null,A.current={msgIdx:-1,positions:[]},j.current=-1},warmSearchIndex:async()=>{if(fe.current)return 0;let e=O.current.messages,t=0,n=performance.now();for(let n=0;n<e.length;n+=500){await bt(0);let r=performance.now(),i=Math.min(n+500,e.length);for(let t=n;t<i;t++)c(e[t]);t+=performance.now()-r}let r=Math.round(performance.now()-n);return Je(`warmSearchIndex: ${e.length} msgs · work=${Math.round(t)}ms wall=${r}ms chunks=${Math.ceil(e.length/500)}`),fe.current=!0,Math.round(t)}}),[t]);let[ye,be]=(0,Z.useState)(null),xe=(0,Z.useRef)({onItemClick:a,setHoveredKey:be});xe.current={onItemClick:a,setHoveredKey:be};let Se=(0,Z.useCallback)((e,t)=>{let n=xe.current;!t&&n.onItemClick&&n.onItemClick(e)},[]),Ce=(0,Z.useCallback)(e=>{xe.current.setHoveredKey(e)},[]),we=(0,Z.useCallback)(e=>{xe.current.setHoveredKey(t=>t===e?null:t)},[]);return(0,Li.jsxs)(Li.Fragment,{children:[(0,Li.jsx)(R,{ref:E,height:w,flexShrink:0}),e.slice(ae,oe).map((e,t)=>{let n=ae+t,r=S[n],c=!!a&&(o?.(e)??!0),l=c&&ye===r,u=s?.(e);return(0,Li.jsx)(Pi,{itemKey:r,msg:e,idx:n,measureRef:ee,expanded:u,hovered:l,clickable:c,onClickK:Se,onEnterK:Ce,onLeaveK:we,renderItem:i},r)}),T>0&&(0,Li.jsx)(R,{height:T,flexShrink:0}),l&&(0,Li.jsx)(Ii,{messages:e,start:ae,end:oe,offsets:D,getItemTop:te,getItemElement:ne,scrollRef:t})]})}function Ii({messages:e,start:t,end:n,offsets:r,getItemTop:i,getItemElement:a,scrollRef:o}){let{setStickyPrompt:s}=(0,Z.useContext)(ki);(0,Z.useSyncExternalStore)((0,Z.useCallback)(e=>o.current?.subscribe(e)??Hi,[o]),()=>{let e=o.current;if(!e)return NaN;let t=e.getScrollTop()+e.getPendingDelta();return e.isSticky()?-1-t:t});let c=o.current?.isSticky()??!0,l=Math.max(0,(o.current?.getScrollTop()??0)+(o.current?.getPendingDelta()??0)),u=t,d=-1;for(let e=n-1;e>=t;e--){let t=i(e);if(t>=0){if(t<l)break;d=t}u=e}let f=-1,p=null;if(u>0&&!c)for(let t=u-1;t>=0;t--){let n=Mi(e[t]);if(n===null)continue;let r=i(t);if(!(r>=0&&r+1>=l)){f=t,p=n;break}}let m=d>=0?d-r[u]:0,h=f>=0?Math.max(0,m+r[f]):-1,g=(0,Z.useRef)({idx:-1,tries:0}),_=(0,Z.useRef)(`none`),v=(0,Z.useRef)(-1);return(0,Z.useEffect)(()=>{if(g.current.idx>=0)return;if(_.current===`armed`){_.current=`force`;return}let e=_.current===`force`;if(_.current=`none`,!e&&v.current===f)return;if(v.current=f,p===null){s(null);return}let t=p.trimStart(),n=t.search(/\n\s*\n/),r=(n>=0?t.slice(0,n):t).slice(0,Bi).replace(/\s+/g,` `).trim();if(r===``){s(null);return}let i=f,c=h;s({text:r,scrollTo:()=>{s(`clicked`),_.current=`armed`;let e=a(i);e?o.current?.scrollToElement(e,1):(o.current?.scrollTo(c),g.current={idx:i,tries:0})}})}),(0,Z.useEffect)(()=>{if(g.current.idx<0)return;let e=a(g.current.idx);e?(o.current?.scrollToElement(e,1),g.current={idx:-1,tries:0}):++g.current.tries>5&&(g.current={idx:-1,tries:0})}),null}var Z,Li,Ri,zi,Bi,Vi,Hi,Ui=e((()=>{Z=t(B(),1),si(),V(),ye(),Ai(),Li=H(),Ye(),yt(),Cn(),v(),Ri=3,zi=new WeakMap,Bi=500,Vi=new WeakMap,Hi=()=>{}}));function Wi(e,t,n=Zi,r=Qi){let i=t.current,a=i?e.findIndex(e=>e.uuid===i.uuid):-1,o=a>=0?a:i?Math.min(i.idx,Math.max(0,e.length-n)):0;e.length-o>n+r&&(o=e.length-n);let s=e[o];return s&&(i?.uuid!==s.uuid||i.idx!==o)?t.current={uuid:s.uuid,idx:o}:!s&&i&&(t.current=null),o}function Gi(e){return(e.type===`assistant`||e.type===`user`?je(e):null)??e.uuid}function Ki(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function qi(e,t,n,r,i,a){if(i===`transcript`)return!0;switch(e.type){case`attachment`:case`user`:case`assistant`:{if(e.type===`assistant`){let t=e.message.content[0];if(t?.type===`server_tool_use`)return a.resolvedToolUseIDs.has(t.id)}let i=je(e);return i?t.has(i)||n.has(i)||fe(i,`PostToolUse`,a)?!1:nn(r,a.resolvedToolUseIDs):!0}case`system`:return e.subtype!==`api_error`;case`grouped_tool_use`:return e.messages.every(e=>{let t=e.message.content[0];return t?.type===`tool_use`&&a.resolvedToolUseIDs.has(t.id)});case`collapsed_read_search`:return!1;default:return!0}}var Ji,Q,$,Yi,Xi,Zi,Qi,$i,ea,ta=e((()=>{Re(),Ji=t(B(),1),Q=t(B(),1),rn(),Ue(),Qe(),p(),V(),c(),Et(),Se(),sn(),un(),F(),rt(),r(),Te(),hn(),se(),mt(),Cn(),yr(),o(),Fr(),v(),m(),Rr(),u(),Zr(),$=H(),jt(),Ui(),Yi=Ji.memo(function({agentDefinitions:e}){return(0,$.jsx)(b,{children:(0,$.jsxs)(R,{flexDirection:`column`,gap:1,children:[(0,$.jsx)(gr,{}),(0,$.jsx)(Ji.Suspense,{fallback:null,children:(0,$.jsx)(qr,{agentDefinitions:e})})]})})}),Xi=30,Zi=200,Qi=50,$i=({messages:e,tools:t,commands:r,verbose:i,toolJSX:a,toolUseConfirmQueue:o,inProgressToolUseIDs:s,isMessageSelectorVisible:c,conversationId:l,screen:u,streamingToolUses:d,showAllInTranscript:f=!1,agentDefinitions:p,hideLogo:m=!1,isLoading:h,hidePastThinking:g=!1,streamingThinking:v,streamingText:b,unseenDivider:S,scrollRef:T,trackStickyPrompt:E,jumpRef:te,onSearchMatchesChange:ne,scanElement:ie,setPositions:se,disableRenderCap:A=!1,cursor:j=null,setCursor:ce,cursorNavRef:de,renderRange:M})=>{let{columns:N}=Ve(),fe=w(`transcript:toggleShowAll`,`Transcript`,`Ctrl+E`),P=(0,Q.useMemo)(()=>pe(e).filter(x),[e]),me=(0,Q.useMemo)(()=>v?v.isStreaming?!0:v.streamingEndedAt?Date.now()-v.streamingEndedAt<3e4:!1:!1,[v]),{lastThinkingBlockId:ge,latestBashOutputUUID:_e}=(0,Q.useMemo)(()=>{let e=null,t=null,n=g&&!me;g&&me&&(e=`streaming`);for(let r=P.length-1;r>=0;r--){let i=P[r];if(i?.type===`user`){let r=i.message.content;if(!t){for(let e of r)if(e.type===`text`){let n=e.text??``;if(n.startsWith(`<bash-stdout`)||n.startsWith(`<bash-stderr`)){t=i.uuid;break}}}n&&!e&&(r.some(e=>e.type===`tool_result`)||(e=`no-thinking`))}else if(i?.type===`assistant`&&n&&!e){let t=i.message.content;for(let n=t.length-1;n>=0;n--)if(t[n]?.type===`thinking`){e=`${i.uuid}:${n}`;break}}if(e!==null&&t)break}return g||(e=null),{lastThinkingBlockId:e,latestBashOutputUUID:t}},[P,g,me]),ve=(0,Q.useMemo)(()=>ae(P),[P]),ye=(0,Q.useMemo)(()=>d.filter(e=>!s.has(e.contentBlock.id)&&!ve.has(e.contentBlock.id)),[d,s,ve]),be=(0,Q.useMemo)(()=>ye.flatMap(e=>{let t=C({content:[e.contentBlock]});return t.uuid=Ce(e.contentBlock.id,0),pe([t])}),[ye]),xe=u===`transcript`,Se=(0,Q.useMemo)(()=>n(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]),we=T!=null&&!Se,Te=xe&&!f&&!we,De=(0,Q.useRef)(null),F=(0,Q.useRef)(null),{collapsed:Oe,lookups:ke,hasTruncatedMessages:je,hiddenMessageCount:Me}=(0,Q.useMemo)(()=>{let e=O((i||Ae()?P:Ee(P,{includeSnipped:!0})).filter(e=>e.type!==`progress`&&!Ir(e)&&re(e,xe)),be),n=Te?e.slice(-30):e,r=Te&&e.length>Xi,{messages:a}=pn(n,t,i),o=on(ln(k(a,t)),i),s=D(P,n),c=(()=>{let e=n.at(-1);return e?.type===`assistant`?e.message?.id:void 0})(),l;if(F.current&&F.current.key===s)l=F.current.lookups;else if(F.current&&P.length>=F.current.normalizedCount&&n.length>=F.current.messageCount&&F.current.lastAssistantMsgId===c){let e=oe(F.current.lookups,F.current.normalizedCount,F.current.messageCount,P,n);e?(l=e,F.current={key:s,lookups:l,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:c}):(l=le(P,n),F.current={key:s,lookups:l,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:c})}else l=le(P,n),F.current={key:s,lookups:l,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:c};let u=e.length-Xi;return{collapsed:o,lookups:l,hasTruncatedMessages:r,hiddenMessageCount:u}},[i,P,xe,be,Te,t]),I=(0,Q.useMemo)(()=>{let e=!we&&!A?Wi(Oe,De):0;return M?Oe.slice(M[0],M[1]):e>0?Oe.slice(e):Oe},[Oe,M,we,A]),L=(0,Q.useMemo)(()=>new Set(d.map(e=>e.contentBlock.id)),[d]),{dividerBeforeIndex:Pe,selectedIdx:Ie}=(0,Q.useMemo)(()=>{if(!S&&!j)return{dividerBeforeIndex:-1,selectedIdx:-1};let e=-1,t=-1,n=S?.firstUnseenUuid.slice(0,24);for(let r=0;r<I.length;r++){let i=I[r];if(e===-1&&n&&i.uuid.slice(0,24)===n&&(e=r),t===-1&&j&&i.uuid===j.uuid&&(t=r),e!==-1&&t!==-1)break}return{dividerBeforeIndex:e,selectedIdx:t}},[S,j,I]),[B,Re]=(0,Q.useState)(()=>new Set),ze=(0,Q.useCallback)(e=>{let t=Gi(e);Re(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),Be=(0,Q.useCallback)(e=>B.size>0&&B.has(Gi(e)),[B]),V=(0,Q.useRef)(ke);V.current=ke;let He=(0,Q.useCallback)(e=>{if(e.type===`collapsed_read_search`)return!0;if(e.type===`assistant`){let t=e.message.content,n=Array.isArray(t)?t[0]:void 0;return n!=null&&he(n)&&n.type===`advisor_tool_result`&&n.content.type===`advisor_result`}if(e.type!==`user`)return!1;let n=e.message.content[0];if(n?.type!==`tool_result`||n.is_error||!e.toolUseResult)return!1;let r=V.current.toolUseByToolUseID.get(n.tool_use_id??``)?.name;return(r?Tt(t,r):void 0)?.isResultTruncated?.(e.toolUseResult)??!1},[t]),H=(!a||!!a.shouldContinueAnimation)&&!o.length&&!c,Ue=s.size>0,{progress:Ge}=Fe(),Ke=(0,Q.useRef)(null),qe=nt().terminalProgressBarEnabled&&!We()&&!Mt();(0,Q.useEffect)(()=>{let e=qe?Ue?`indeterminate`:`completed`:null;Ke.current!==e&&(Ke.current=e,Ge(e))},[Ge,qe,Ue]),(0,Q.useEffect)(()=>()=>Ge(null),[Ge]);let Je=(0,Q.useCallback)(e=>`${e.uuid}-${l}`,[l]),Ye=(e,n)=>{let a=n>0?I[n-1]?.type:void 0,o=e.type===`user`&&a===`user`,c=e.type===`collapsed_read_search`&&(!!b||Er(I,n,t,L)),l=I.length-1-n>0,d=Je(e),f=(0,$.jsx)(Pr,{message:e,isUserContinuation:o,hasContentAfter:c,tools:t,commands:r,verbose:i||Be(e)||j?.expanded===!0&&n===Ie,inProgressToolUseIDs:s,streamingToolUseIDs:L,screen:u,canAnimate:H,lastThinkingBlockId:ge,latestBashOutputUUID:_e,columns:N,isLoading:h,lookups:ke,shouldCollapseDiffs:l},d),p=(0,$.jsx)(_.Provider,{value:n===Ie,children:f},d);return S&&n===Pe?[(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(Ne,{title:`${S.count} new ${pt(S.count,`message`)}`,width:N,color:`inactive`})},`unseen-divider`),p]:p},Xe=(0,Q.useRef)(new WeakMap),Ze=(0,Q.useCallback)(e=>{let n=Xe.current.get(e);if(n!==void 0)return n;let r=gn(e);if(e.type===`user`&&e.toolUseResult&&Array.isArray(e.message.content)){let n=e.message.content.find(e=>e.type===`tool_result`);if(n&&`tool_use_id`in n){let i=ke.toolUseByToolUseID.get(n.tool_use_id),a=(i&&Tt(t,i.name))?.extractSearchText?.(e.toolUseResult);a!==void 0&&(r=a)}}let i=r.toLowerCase();return Xe.current.set(e,i),i},[t,ke]);return(0,$.jsxs)($.Fragment,{children:[!m&&!(M&&M[0]>0)&&(0,$.jsx)(Yi,{agentDefinitions:p}),je&&(0,$.jsx)(Ne,{title:`${fe} to show ${Le.bold(Me)} previous messages`,width:N}),xe&&f&&Me>0&&!A&&(0,$.jsx)(Ne,{title:`${fe} to hide ${Le.bold(Me)} previous messages`,width:N}),we?(0,$.jsx)(ue.Provider,{value:!0,children:(0,$.jsx)(Fi,{messages:I,scrollRef:T,columns:N,itemKey:Je,renderItem:Ye,onItemClick:ze,isItemClickable:He,isItemExpanded:Be,trackStickyPrompt:E,selectedIndex:Ie>=0?Ie:void 0,cursorNavRef:de,setCursor:ce,jumpRef:te,onSearchMatchesChange:ne,scanElement:ie,setPositions:se,extractSearchText:Ze})}):I.flatMap(Ye),b&&(0,$.jsx)(R,{alignItems:`flex-start`,flexDirection:`row`,marginTop:1,width:`100%`,children:(0,$.jsxs)(R,{flexDirection:`row`,children:[(0,$.jsx)(R,{minWidth:2,children:(0,$.jsx)(z,{color:`text`,children:$e})}),(0,$.jsx)(R,{flexDirection:`column`,children:(0,$.jsx)(y,{children:b})})]})}),me&&v&&(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(ee,{param:{type:`thinking`,thinking:v.thinking},addMargin:!1,isTranscriptMode:!0,verbose:i,hideInTranscript:!1})})]})},ea=Ji.memo($i,(e,t)=>{let n=Object.keys(e);for(let r of n)if(!(r===`scrollRef`||r===`trackStickyPrompt`||r===`setCursor`||r===`cursorNavRef`||r===`jumpRef`||r===`onSearchMatchesChange`||r===`scanElement`||r===`setPositions`)&&e[r]!==t[r]){if(r===`streamingToolUses`){let n=e.streamingToolUses,r=t.streamingToolUses;if(n.length===r.length&&n.every((e,t)=>e.contentBlock===r[t]?.contentBlock))continue}if(r===`inProgressToolUseIDs`&&Ki(e.inProgressToolUseIDs,t.inProgressToolUseIDs))continue;if(r===`unseenDivider`){let n=e.unseenDivider,r=t.unseenDivider;if(n?.firstUnseenUuid===r?.firstUnseenUuid&&n?.count===r?.count)continue}if(r===`tools`){let n=e.tools,r=t.tools;if(n.length===r.length&&n.every((e,t)=>e.name===r[t]?.name))continue}return!1}return!0})}));export{Ai as a,di as c,Si as i,fi as l,ta as n,yi as o,Ci as r,vi as s,ea as t};