@readmagic/workmate 0.0.13 → 0.0.14

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 (428) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-m2d3nOQJ.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BRXGkHO4.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-CH9x1Ngp.js → AgentsMdExternalIncludesDialog-D58Vn3SK.js} +1 -1
  4. package/dist/chunks/App-CeC-2dzL.js +1 -0
  5. package/dist/chunks/ApproveApiKey-DFpddLyp.js +1 -0
  6. package/dist/chunks/ApproveApiKey-NXTWIAMj.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-9ruzl1jm.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-B0BizN_J.js → BypassPermissionsModeDialog-C4QGpcBT.js} +1 -1
  9. package/dist/chunks/DiffDialog-LTdtTqsC.js +6 -0
  10. package/dist/chunks/Doctor-DmiDH-lg.js +1 -0
  11. package/dist/chunks/Doctor-Yvrzcrvx.js +3 -0
  12. package/dist/chunks/ExitFlow-DH0L3tyY.js +2 -0
  13. package/dist/chunks/{Grove-D0nn8zOV.js → Grove-BhhnrFX9.js} +1 -1
  14. package/dist/chunks/{HybridTransport-BQNLZNa_.js → HybridTransport-CEWG9ZRi.js} +2 -4
  15. package/dist/chunks/InvalidConfigDialog-Ue3kJUPJ.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-BO2AOTVf.js +1 -0
  17. package/dist/chunks/MCPConnectionManager-Ciy9y9VV.js +1 -0
  18. package/dist/chunks/MCPToolListView-Ddmu2UcL.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-CUx2zexI.js → McpParsingWarnings-BsCDFWci.js} +1 -1
  20. package/dist/chunks/MessageSelector-DY5K0NHd.js +3 -0
  21. package/dist/chunks/Messages-LD6ZO301.js +10 -0
  22. package/dist/chunks/{Onboarding-t-P6Q5O6.js → Onboarding-w0-VVsDz.js} +1 -1
  23. package/dist/chunks/PermissionDialog-BPhvs5xH.js +1 -0
  24. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +1 -0
  25. package/dist/chunks/{PromptInputFooterSuggestions-R12fbdmp.js → PromptInputFooterSuggestions-OEXx0Abp.js} +1 -1
  26. package/dist/chunks/PromptInputHelpMenu-DyaUsvNx.js +1 -0
  27. package/dist/chunks/QueryEngine-sH-KjJIq.js +1 -0
  28. package/dist/chunks/REPL-BMH_RItw.js +128 -0
  29. package/dist/chunks/REPL-DkPd3vk5.js +1 -0
  30. package/dist/chunks/RemoteSessionManager-DJhrR1dz.js +2 -0
  31. package/dist/chunks/ResumeConversation-BbNrpSFB.js +1 -0
  32. package/dist/chunks/SSETransport-CLiI2qnD.js +2 -0
  33. package/dist/chunks/{SearchBox-C9vUA4IM.js → SearchBox-CwwV0W-w.js} +1 -1
  34. package/dist/chunks/SearchExtraToolsTool-DupzA6Vm.js +1 -0
  35. package/dist/chunks/Settings-B1EI5LOU.js +2 -0
  36. package/dist/chunks/{TeleportProgress-3hmIApkj.js → TeleportProgress-IB--CbqZ.js} +1 -1
  37. package/dist/chunks/{TeleportRepoMismatchDialog-BA1a66RK.js → TeleportRepoMismatchDialog-KjdlS_gA.js} +1 -1
  38. package/dist/chunks/{TeleportResumeWrapper-BT4O-Wsi.js → TeleportResumeWrapper-DnHTI39O.js} +1 -1
  39. package/dist/chunks/ThemePicker-BrD_T7xF.js +1 -0
  40. package/dist/chunks/{TrustDialog-Dpk03V1Y.js → TrustDialog-L0rvvpit.js} +1 -1
  41. package/dist/chunks/ValidationErrorsList-QZvtUrAy.js +2 -0
  42. package/dist/chunks/add-dir-CpWXReCi.js +1 -0
  43. package/dist/chunks/{agentDisplay-D7bdOOG7.js → agentDisplay-CrQvGkTT.js} +1 -1
  44. package/dist/chunks/agents-BYQO6DbG.js +101 -0
  45. package/dist/chunks/{agents-22wiC58F.js → agents-C99yMsVF.js} +1 -1
  46. package/dist/chunks/allErrors-uyOMiF9U.js +1 -0
  47. package/dist/chunks/{api-f3GN2I_J.js → api-C5I2xwgd.js} +1 -1
  48. package/dist/chunks/api-j0iE1mkR.js +1 -0
  49. package/dist/chunks/attributionHooks-C0aXyx9L.js +1 -0
  50. package/dist/chunks/{auth-Czy7GoRh.js → auth-BYCRa_mb.js} +7 -12
  51. package/dist/chunks/auth-C9FUZzpW.js +1 -0
  52. package/dist/chunks/auth-DwPrlTHv.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-BxcVB3By.js +1 -0
  54. package/dist/chunks/backgroundHousekeeping-CjD8bACB.js +17 -0
  55. package/dist/chunks/{banner-BcAM7iSx.js → banner-HfMnBd03.js} +2 -2
  56. package/dist/chunks/{bg-Ci7pG4eo.js → bg-DltfF1_K.js} +2 -2
  57. package/dist/chunks/branch-BOWBZo5K.js +2 -0
  58. package/dist/chunks/{break-cache-4rlQORVk.js → break-cache-Cd1yQ-0h.js} +2 -3
  59. package/dist/chunks/bridgeConfig-Bxs5dqjH.js +1 -0
  60. package/dist/chunks/{bridgeConfig-B80T_lw7.js → bridgeConfig-CgAVrQfz.js} +1 -1
  61. package/dist/chunks/{bridgeMessaging-DyvHd16Z.js → bridgeMessaging-cOFtbkf_.js} +1 -1
  62. package/dist/chunks/{bridgePointer-DHWK3LEe.js → bridgePointer-CiHy2tTN.js} +1 -1
  63. package/dist/chunks/{bridgeStatusUtil-DStiD05t.js → bridgeStatusUtil-BQF0AJDO.js} +1 -1
  64. package/dist/chunks/btw-B0UmiVKl.js +1 -0
  65. package/dist/chunks/caches-C9--b9a7.js +1 -0
  66. package/dist/chunks/caches-wN3JyvNE.js +1 -0
  67. package/dist/chunks/{capacityWake-ByL6fM6I.js → capacityWake-LRiPhPeM.js} +1 -1
  68. package/dist/chunks/{ccrClient-BALhzhPF.js → ccrClient-wtUIz75R.js} +1 -1
  69. package/dist/chunks/{claudeDesktop-Ct_hyICL.js → claudeDesktop-DPIJpc1V.js} +1 -1
  70. package/dist/chunks/{clear-B_yVyJXP.js → clear-CNzBoL7O.js} +1 -1
  71. package/dist/chunks/{cliLaunch-OPOtzhvA.js → cliLaunch-xIVvtPZy.js} +1 -1
  72. package/dist/chunks/{client-BMA05FW8.js → client-B7WkO81L.js} +1 -1
  73. package/dist/chunks/client-BCzhAEd0.js +1 -0
  74. package/dist/chunks/client-Dr9AYB-r.js +1 -0
  75. package/dist/chunks/commands-DTB0Qzd5.js +1 -0
  76. package/dist/chunks/compact-Bj8mdDYN.js +2 -0
  77. package/dist/chunks/config-B1kYcRIP.js +1 -0
  78. package/dist/chunks/{config-9rLTDOYW.js → config-BkbL2e5Q.js} +1 -1
  79. package/dist/chunks/{config-DMKtiMzJ.js → config-WMxn2jLl.js} +1 -1
  80. package/dist/chunks/context-DB1Ar85E.js +1 -0
  81. package/dist/chunks/context-noninteractive-Bno2Xsmp.js +1 -0
  82. package/dist/chunks/{context-noninteractive-CHzerxnH.js → context-noninteractive-CqnJTDcI.js} +2 -2
  83. package/dist/chunks/conversation-DOgBzrm0.js +1 -0
  84. package/dist/chunks/conversation-hNXWaswI.js +1 -0
  85. package/dist/chunks/{createSSHSession-XkHMiGRN.js → createSSHSession-Cf2tOgK_.js} +3 -4
  86. package/dist/chunks/createSession-BZx-2UIB.js +1 -0
  87. package/dist/chunks/{createSession-BNGm9fL4.js → createSession-DD5YaQKM.js} +1 -1
  88. package/dist/chunks/crossProjectResume-CkiPQYYE.js +40 -0
  89. package/dist/chunks/{datadog-3WUWcCFn.js → datadog-DcLf1QpG.js} +1 -1
  90. package/dist/chunks/{debug-Dr1SjdXn.js → debug-BQj6h99Q.js} +1 -1
  91. package/dist/chunks/debugUtils-B86DM1Sp.js +1 -0
  92. package/dist/chunks/{detached-CqfQYVOi.js → detached--wGwkuHX.js} +1 -2
  93. package/dist/chunks/{detectRepository-CMEkS5_2.js → detectRepository-Qy3zKoyn.js} +1 -1
  94. package/dist/chunks/detectRepository-tRUoPOKy.js +1 -0
  95. package/dist/chunks/{diff-CKlLimGq.js → diff-dfXWiuLA.js} +1 -1
  96. package/dist/chunks/directoryCompletion-BtlRKLzw.js +1 -0
  97. package/dist/chunks/doctor-aKE2bG5C.js +1 -0
  98. package/dist/chunks/{entry-DCbq734V.js → entry-wISucmYc.js} +4 -5
  99. package/dist/chunks/esm-CrJVXrKW.js +1 -0
  100. package/dist/chunks/{execFileNoThrow-mXq4K0rl.js → execFileNoThrow-DYm1GeGn.js} +1 -1
  101. package/dist/chunks/{execSyncWrapper-Ne33rRiD.js → execSyncWrapper-CqvQqke-.js} +1 -1
  102. package/dist/chunks/exit-pjN4EJHV.js +1 -0
  103. package/dist/chunks/exit-s9XGerrH.js +1 -0
  104. package/dist/chunks/{extraUsage-C86bZVgt.js → extraUsage-CwDhpClH.js} +1 -1
  105. package/dist/chunks/extractMemories-WmPLOLUT.js +1 -0
  106. package/dist/chunks/fast-BVABmasw.js +1 -0
  107. package/dist/chunks/fast-Cuj3bfFm.js +1 -0
  108. package/dist/chunks/{fileSuggestions-BalHmi1-.js → fileSuggestions-Dy2BUZzd.js} +2 -2
  109. package/dist/chunks/firstPartyEventLogger-CabA8fu0.js +1 -0
  110. package/dist/chunks/{firstPartyEventLogger-1RTgXHSz.js → firstPartyEventLogger-D4yuDP-n.js} +3 -5
  111. package/dist/chunks/flushGate-B6ecrC4j.js +1 -0
  112. package/dist/chunks/{fpsMetrics-DffAomdg.js → fpsMetrics-Dk_pnSHJ.js} +1 -1
  113. package/dist/chunks/gemini-BC-BxZmj.js +1 -0
  114. package/dist/chunks/generateSessionName-JTR8nPYD.js +1 -0
  115. package/dist/chunks/{genericProcessUtils-Dc1pfb7J.js → genericProcessUtils-Bbcbi11g.js} +1 -1
  116. package/dist/chunks/git-BaSq69E7.js +1 -0
  117. package/dist/chunks/{git-CoQQ6YEf.js → git-DplvjXEY.js} +2 -3
  118. package/dist/chunks/{githubRepoPathMapping-CmpEaQoo.js → githubRepoPathMapping-Bk4FZrng.js} +1 -1
  119. package/dist/chunks/goal-B09SOyra.js +3 -0
  120. package/dist/chunks/grok-BBo3jGfP.js +1 -0
  121. package/dist/chunks/{grove-b9gGKgu4.js → grove-DsAIY-rZ.js} +2 -2
  122. package/dist/chunks/help-CELr6oJZ.js +1 -0
  123. package/dist/chunks/hooks-9rkDD2iw.js +1 -0
  124. package/dist/chunks/{hooks-C-QMGvCg.js → hooks-BI4NY5IC.js} +2 -2
  125. package/dist/chunks/initReplBridge-BYrL6ou1.js +1 -0
  126. package/dist/chunks/{install-DGH_bjUh.js → install-Dn3_M1Ui.js} +1 -1
  127. package/dist/chunks/{instrumentation-DQ705pC7.js → instrumentation-5cSwEKaF.js} +4 -4
  128. package/dist/chunks/{job-BaMT6Lb2.js → job-rW1mEYtm.js} +1 -1
  129. package/dist/chunks/{jwtUtils-FQWtM6iM.js → jwtUtils-YCoZL0FW.js} +1 -1
  130. package/dist/chunks/keybindings-B5kUoxvg.js +1 -0
  131. package/dist/chunks/{launchLocalMemory-CtZrkmaw.js → launchLocalMemory-CPucX8Xj.js} +2 -2
  132. package/dist/chunks/launchOnboarding--GCJWeeS.js +8 -0
  133. package/dist/chunks/loadAgentsDir-D-a1uUb5.js +1 -0
  134. package/dist/chunks/{loadAgentsDir-mcRW90aq.js → loadAgentsDir-JrGMJN05.js} +656 -693
  135. package/dist/chunks/loadPluginHooks-C4zrlV0u.js +1 -0
  136. package/dist/chunks/localSearch-C-stDP9C.js +1 -0
  137. package/dist/chunks/localSearch-hOERAH9v.js +1 -0
  138. package/dist/chunks/{log-27kCA_9u.js → log-BlJ7CcKG.js} +1 -1
  139. package/dist/chunks/{logoV2Utils--8OUQQPd.js → logoV2Utils-J2Sqfube.js} +1 -1
  140. package/dist/chunks/{magicDocs-26J_l1De.js → magicDocs-Dpe3YhyL.js} +2 -2
  141. package/dist/chunks/main-C_PDzJdv.js +356 -0
  142. package/dist/chunks/{main-CGLCy2pM.js → main-Zh18lf2J.js} +2 -2
  143. package/dist/chunks/managedEnv-AEhH_HUs.js +1 -0
  144. package/dist/chunks/{managedEnv-Ds6MlFQE.js → managedEnv-C8SisyLk.js} +1 -1
  145. package/dist/chunks/{mappers-DwZw084m.js → mappers-CMJorgSL.js} +1 -1
  146. package/dist/chunks/mcp-B2mJmWKt.js +6 -0
  147. package/dist/chunks/mcp-SuAh71Ht.js +2 -0
  148. package/dist/chunks/mcp-_tBxhPV-.js +1 -0
  149. package/dist/chunks/{memoize-Co4vS6UF.js → memoize-_2f7NWDv.js} +1 -1
  150. package/dist/chunks/memory-DK8bOrUr.js +1 -0
  151. package/dist/chunks/{modalContext-CUThy6Ph.js → modalContext-wY9CeN4G.js} +1 -1
  152. package/dist/chunks/{mode-B80CHkqo.js → mode-BhfhEpnW.js} +2 -2
  153. package/dist/chunks/model-BCM7RpVk.js +1 -0
  154. package/dist/chunks/model-BWR43D3c.js +1 -0
  155. package/dist/chunks/model-CmDF8O9G.js +1 -0
  156. package/dist/chunks/modelOptions-DEQat7lU.js +1 -0
  157. package/dist/chunks/nativeInstaller-xxyUjXbl.js +1 -0
  158. package/dist/chunks/{omit-KEhe84f4.js → omit-od_CYp5o.js} +1 -1
  159. package/dist/chunks/{onChangeAppState-Dq1tIEJI.js → onChangeAppState-CqTb0yEa.js} +1 -1
  160. package/dist/chunks/openai-qW8mATAs.js +10 -0
  161. package/dist/chunks/{panel-CoF2a-h4.js → panel-Bg_0PHE6.js} +1 -1
  162. package/dist/chunks/{parser-CUUiH40T.js → parser-a2S_eFyE.js} +1 -1
  163. package/dist/chunks/parser-x-w3ikxt.js +1 -0
  164. package/dist/chunks/{partition-DeT341qu.js → partition-CYoWXLNU.js} +1 -1
  165. package/dist/chunks/permissions--iKUbWBw.js +3 -0
  166. package/dist/chunks/pidLock-BR4hzYgp.js +3 -0
  167. package/dist/chunks/plan-DiHCGXhM.js +1 -0
  168. package/dist/chunks/{platform-Dg1c9F_1.js → platform-DVeTi9mp.js} +2 -2
  169. package/dist/chunks/plugin-BeC4D7XF.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-Bj-CrFuO.js +1 -0
  171. package/dist/chunks/{pluginBlocklist-BfoLN9a-.js → pluginBlocklist-DzOs-RS1.js} +1 -1
  172. package/dist/chunks/{pluginCliCommands-Bc2Iybhz.js → pluginCliCommands-DwIGn58t.js} +1 -1
  173. package/dist/chunks/{pluginFlagging-Cr0d0hBA.js → pluginFlagging-BzuymJuf.js} +1 -1
  174. package/dist/chunks/pluginOperations-CP1v-nu0.js +2 -0
  175. package/dist/chunks/pluginStartupCheck-BGN6Je6d.js +1 -0
  176. package/dist/chunks/{pluginStartupCheck-DiCDQQlr.js → pluginStartupCheck-BUeBiYVq.js} +1 -1
  177. package/dist/chunks/plugins-D1N31THW.js +4 -0
  178. package/dist/chunks/{poorMode-DxgO_bUb.js → poorMode-D4L_-yWS.js} +1 -1
  179. package/dist/chunks/poorMode-XDBnxTiF.js +1 -0
  180. package/dist/chunks/print-DaJi1wF_.js +14 -0
  181. package/dist/chunks/processBashCommand-BGCIqxc9.js +1 -0
  182. package/dist/chunks/processSlashCommand-qR_j1DE8.js +5 -0
  183. package/dist/chunks/prompt-B0gADAvI.js +1 -0
  184. package/dist/chunks/{prompt-DIlq8NTy.js → prompt-DnPppVz8.js} +21 -23
  185. package/dist/chunks/prompt-DqyEtC_I2.js +1 -0
  186. package/dist/chunks/{promptEditor-BILqOGl1.js → promptEditor-Cilc9N3L.js} +3 -3
  187. package/dist/chunks/protocolHandler-DdbiucQa.js +13 -0
  188. package/dist/chunks/{proxy-BEKNaTXI.js → proxy-C0j74LqT.js} +1 -1
  189. package/dist/chunks/reconciler-Bte4gdP-.js +1 -0
  190. package/dist/chunks/refresh-MiZ0acBm.js +1 -0
  191. package/dist/chunks/registerProtocol-Bpte9dly.js +1 -0
  192. package/dist/chunks/{reload-plugins-CGb0HTsH.js → reload-plugins-GdqFZblC.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-BmteXmI9.js → remoteBridgeCore-CAl3_H-O.js} +1 -1
  194. package/dist/chunks/{remoteManagedSettings-CwDGxL5p.js → remoteManagedSettings-BcLJLEr7.js} +1 -1
  195. package/dist/chunks/rename-BDo5qIK0.js +1 -0
  196. package/dist/chunks/{renderOptions-45A-EdsK.js → renderOptions-CkqTbz6d.js} +1 -1
  197. package/dist/chunks/resume-Bbweh2hA.js +2 -0
  198. package/dist/chunks/ripgrep-DrpZ79Pp.js +1 -0
  199. package/dist/chunks/{ripgrep-DQ_ILUJV.js → ripgrep-X5m4gJ-3.js} +1 -1
  200. package/dist/chunks/{runtimeObserver-CtNY8Al2.js → runtimeObserver-CxXxUcrm.js} +1 -1
  201. package/dist/chunks/{runtimeObserver-4ZqaCXYy.js → runtimeObserver-Hjbo43xj.js} +4 -4
  202. package/dist/chunks/sandbox-adapter-DQ_fJSIo.js +1 -0
  203. package/dist/chunks/sandbox-toggle-DmNSThQK.js +1 -0
  204. package/dist/chunks/searchExtraTools-C7b2x2p_.js +1 -0
  205. package/dist/chunks/{session-wb6X4Wrq.js → session-CkuTMD_4.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-CQvGAbvL.js +1 -0
  207. package/dist/chunks/{sessionIdCompat-DMayYBrf.js → sessionIdCompat-Dgp6PW_1.js} +1 -1
  208. package/dist/chunks/sessionObserver-BoQY7nOa.js +1 -0
  209. package/dist/chunks/{sessionObserver-BJQ5hwjU.js → sessionObserver-CvQ6oyoj.js} +2 -2
  210. package/dist/chunks/sessionState-C2REgUrs.js +11 -0
  211. package/dist/chunks/sessionStorage-BeaEgnaa.js +1 -0
  212. package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +3 -0
  213. package/dist/chunks/{sessionTitle-Cbzrb9jT.js → sessionTitle-2IWcNB8H.js} +2 -2
  214. package/dist/chunks/{sessionTracing-CEsm8pZL.js → sessionTracing-Bm7hQKHA.js} +2 -2
  215. package/dist/chunks/settings-Da6ax5aI.js +1 -0
  216. package/dist/chunks/{settings-DiBMs2gM.js → settings-aUygByiZ.js} +4 -5
  217. package/dist/chunks/settingsSync-DgzCU1BZ.js +1 -0
  218. package/dist/chunks/setup-CvaG4nl5.js +3 -0
  219. package/dist/chunks/{shadowedRuleDetection-D5X5fhzj.js → shadowedRuleDetection-CWCQ5dZ0.js} +1 -1
  220. package/dist/chunks/{shellQuote-C_I6DHLV.js → shellQuote-D3Ocv_U-.js} +1 -1
  221. package/dist/chunks/{sideQuestion-BHRtwhyj.js → sideQuestion-BoW-xYkh.js} +3 -3
  222. package/dist/chunks/sinks-B_ehGpvp.js +1 -0
  223. package/dist/chunks/sinks-ZHKfs6gv.js +1 -0
  224. package/dist/chunks/skillChangeDetector-C-HWR_8v.js +1 -0
  225. package/dist/chunks/{skillGapStore-BjQSSz2E.js → skillGapStore-CCNeSjIb.js} +2 -2
  226. package/dist/chunks/{skillLifecycle-Sp8strFv.js → skillLifecycle-wU4JDNYQ.js} +2 -2
  227. package/dist/chunks/{skillSearchPanel-3sYRez_Q.js → skillSearchPanel-Cxr1QQn4.js} +4 -4
  228. package/dist/chunks/skills-BghnKnNo.js +1 -0
  229. package/dist/chunks/{src-r6ZFgWPx2.js → src-D3yIF9I42.js} +1 -1
  230. package/dist/chunks/src-DL3w8VPk2.js +51 -0
  231. package/dist/chunks/{startupProfiler-Dc5r6LgE.js → startupProfiler-2sjXZkIP.js} +1 -1
  232. package/dist/chunks/startupProfiler-B2fyaBEa.js +1 -0
  233. package/dist/chunks/{staticRender-DrU6eWoq.js → staticRender-D9AbnQFr.js} +1 -1
  234. package/dist/chunks/{stats-BkadEKa-.js → stats-unp6R0Ah.js} +1 -1
  235. package/dist/chunks/status-BraYBx4N.js +2 -0
  236. package/dist/chunks/status-DwyWiaVc.js +1 -0
  237. package/dist/chunks/statusNoticeHelpers-Dm1aiibR.js +1 -0
  238. package/dist/chunks/{stringUtils-Df-Lnjxd.js → stringUtils-BjnclTLB.js} +3 -3
  239. package/dist/chunks/{switcher-uoQMHmEZ.js → switcher-BUNSEJ-7.js} +1 -1
  240. package/dist/chunks/switcher-DDUnWU_4.js +1 -0
  241. package/dist/chunks/{syncCache-BooMjgU6.js → syncCache-1s9xV8WV.js} +1 -1
  242. package/dist/chunks/tasks-BjFot03S.js +1 -0
  243. package/dist/chunks/teleport-Dj2Kvbmx.js +1 -0
  244. package/dist/chunks/{templateJobs-BYYfF4m5.js → templateJobs-CY7GNRo5.js} +1 -3
  245. package/dist/chunks/{terminalSetup-fwhFTxGi.js → terminalSetup-CpMNk6dc.js} +5 -6
  246. package/dist/chunks/{terminalSetup-CbXKCpWM.js → terminalSetup-Ty8T8ePM.js} +1 -1
  247. package/dist/chunks/theme-c6grxWNn.js +1 -0
  248. package/dist/chunks/{tmux-d3cNCIZA.js → tmux-g0cQ0Buz.js} +1 -1
  249. package/dist/chunks/{toolEventObserver-BFEl47bq.js → toolEventObserver-D7WbjgFR.js} +1 -1
  250. package/dist/chunks/toolPool-O5nkEFb1.js +1 -0
  251. package/dist/chunks/{trustedDevice-BLiKbGpG.js → trustedDevice-BF78PNK8.js} +1 -1
  252. package/dist/chunks/trustedDevice-D_z7bAQh.js +1 -0
  253. package/dist/chunks/{types-BJ7qTz75.js → types-BomO8WUz.js} +1 -1
  254. package/dist/chunks/{udsClient-CF8BmZgN.js → udsClient-DSvRPCvR.js} +1 -1
  255. package/dist/chunks/updateCCB-ts7Joyve.js +5 -0
  256. package/dist/chunks/upstreamproxy-DYoLvdM9.js +10 -0
  257. package/dist/chunks/useExitOnCtrlCDWithKeybindings-qLfN0tc-.js +1 -0
  258. package/dist/chunks/useMainLoopModel-DkjG_ikT.js +1 -0
  259. package/dist/chunks/useManagePlugins-E0Qzj-ws.js +1 -0
  260. package/dist/chunks/useMergedTools-B7iYaNwM.js +1 -0
  261. package/dist/chunks/{useSearchInput-KFKh2ozY.js → useSearchInput-CsxiM9i0.js} +1 -1
  262. package/dist/chunks/useSettingsErrors-DdVTahNa.js +1 -0
  263. package/dist/chunks/{userAgent-DUrr02yh.js → userAgent-BggRZ-ZE.js} +1 -1
  264. package/dist/chunks/util-Xdy1nOjj.js +1 -0
  265. package/dist/chunks/validatePlugin-Be5aSSnP.js +1 -0
  266. package/dist/chunks/{vim-C4Hs5U2h.js → vim-cFcxfuac.js} +1 -1
  267. package/dist/chunks/{which-mplwBbc0.js → which-BR8YVCCW.js} +1 -1
  268. package/dist/chunks/{windowsPaths-C7Mdo9aU.js → windowsPaths-BmXyrasP.js} +1 -1
  269. package/dist/chunks/windowsPaths-BybjGW7e.js +1 -0
  270. package/dist/chunks/{workSecret-XLodD7tw.js → workSecret-BUd8cQ6-.js} +1 -1
  271. package/dist/chunks/workerRegistry-GrD7IAVQ.js +2 -0
  272. package/dist/chunks/worktree-V7xiUAtl.js +1 -0
  273. package/dist/cli.js +1 -1
  274. package/package.json +1 -1
  275. package/dist/chunks/AddWorkspaceDirectory-BzNj9rS6.js +0 -1
  276. package/dist/chunks/AgentsMdExternalIncludesDialog-CDZPR488.js +0 -1
  277. package/dist/chunks/App-D-bYAYAl.js +0 -1
  278. package/dist/chunks/ApproveApiKey-BEGV9Zj9.js +0 -1
  279. package/dist/chunks/ApproveApiKey-CjacpIqq.js +0 -1
  280. package/dist/chunks/BackgroundTasksDialog-A9hw_SV0.js +0 -2
  281. package/dist/chunks/DiffDialog-mQ-5_TSv.js +0 -6
  282. package/dist/chunks/Doctor-BC6IuQhd.js +0 -3
  283. package/dist/chunks/Doctor-i_5_AQd-.js +0 -1
  284. package/dist/chunks/ExitFlow-Bu2cVGpC.js +0 -2
  285. package/dist/chunks/InvalidConfigDialog-C5CIiSIE.js +0 -1
  286. package/dist/chunks/InvalidSettingsDialog-Dq7hKXcO.js +0 -1
  287. package/dist/chunks/MCPConnectionManager-aDDsYkGM.js +0 -1
  288. package/dist/chunks/MCPToolListView-Cr0MDkzT.js +0 -1
  289. package/dist/chunks/MessageSelector-DwGOWKKL.js +0 -3
  290. package/dist/chunks/Messages-C1jh4ixt.js +0 -11
  291. package/dist/chunks/PermissionDialog-Cb3z8OUP.js +0 -1
  292. package/dist/chunks/PressEnterToContinue-Dq0Imo9c.js +0 -1
  293. package/dist/chunks/PromptInputHelpMenu-BgADIzRj.js +0 -1
  294. package/dist/chunks/QueryEngine-HlLQJmsd.js +0 -1
  295. package/dist/chunks/REPL-Rs_JQkDc.js +0 -1
  296. package/dist/chunks/REPL-VKAmKkII.js +0 -133
  297. package/dist/chunks/RemoteSessionManager-BbgXeM-t.js +0 -2
  298. package/dist/chunks/ResumeConversation-66zbx12g.js +0 -1
  299. package/dist/chunks/SSETransport-BBQkdn4e.js +0 -4
  300. package/dist/chunks/SearchExtraToolsTool-Bq87I_vu.js +0 -1
  301. package/dist/chunks/Settings-BKdLcyXe.js +0 -2
  302. package/dist/chunks/ThemePicker-DUlhcoso.js +0 -1
  303. package/dist/chunks/ValidationErrorsList-DSSUWdgd.js +0 -2
  304. package/dist/chunks/add-dir-BUr0z-VU.js +0 -1
  305. package/dist/chunks/agents-8ELI8RJo.js +0 -103
  306. package/dist/chunks/allErrors-C1eMbHSv.js +0 -1
  307. package/dist/chunks/api-DgjIFdMn.js +0 -1
  308. package/dist/chunks/attributionHooks-CUAoGkU6.js +0 -1
  309. package/dist/chunks/auth-B73a4Cob.js +0 -1
  310. package/dist/chunks/auth-D_0waidQ.js +0 -1
  311. package/dist/chunks/autoModeDenials-BxNzGJdR.js +0 -1
  312. package/dist/chunks/backgroundHousekeeping-C_ArdTFX.js +0 -17
  313. package/dist/chunks/backgroundHousekeeping-YJhvZ0dh.js +0 -1
  314. package/dist/chunks/branch-bb4-bErF.js +0 -3
  315. package/dist/chunks/bridgeConfig-DywkIo_k.js +0 -1
  316. package/dist/chunks/btw-BRmV51bR.js +0 -1
  317. package/dist/chunks/caches-C5DIVdvI.js +0 -1
  318. package/dist/chunks/caches-zDZEgNKq.js +0 -1
  319. package/dist/chunks/client-7lIxWcaM.js +0 -1
  320. package/dist/chunks/client-DVg8PpFX.js +0 -1
  321. package/dist/chunks/commands-ByFXqW43.js +0 -1
  322. package/dist/chunks/compact-BUShp2eQ.js +0 -2
  323. package/dist/chunks/config-BwHNU_pI.js +0 -1
  324. package/dist/chunks/context-6Pk3iVhh.js +0 -1
  325. package/dist/chunks/context-noninteractive-DFwRQyFE.js +0 -1
  326. package/dist/chunks/conversation-5zb5XkSA.js +0 -1
  327. package/dist/chunks/conversation-JP2ZXrwu.js +0 -1
  328. package/dist/chunks/createSession-VTqzWAu6.js +0 -1
  329. package/dist/chunks/crossProjectResume-DxgQVYSi.js +0 -40
  330. package/dist/chunks/debugUtils-cK-iOsEV.js +0 -1
  331. package/dist/chunks/detectRepository-BsKZDRoI.js +0 -1
  332. package/dist/chunks/directoryCompletion-ByBTSuLu.js +0 -1
  333. package/dist/chunks/doctor-Bvx0u0sO.js +0 -1
  334. package/dist/chunks/esm-CtQkOk5D.js +0 -1
  335. package/dist/chunks/exit-BOhGfSlm.js +0 -2
  336. package/dist/chunks/exit-DTsz5Lcb.js +0 -1
  337. package/dist/chunks/extractMemories-6OnMgL2S.js +0 -1
  338. package/dist/chunks/fast-B2ziqJEA.js +0 -1
  339. package/dist/chunks/fast-BkhjaTkZ.js +0 -1
  340. package/dist/chunks/firstPartyEventLogger-CXMzhLrF.js +0 -1
  341. package/dist/chunks/flushGate-DWL05x7v.js +0 -1
  342. package/dist/chunks/gemini-BLpLJyli.js +0 -1
  343. package/dist/chunks/generateSessionName-CdbMksHi.js +0 -1
  344. package/dist/chunks/git-Bs1vtuvX.js +0 -1
  345. package/dist/chunks/goal-V3qix-i1.js +0 -3
  346. package/dist/chunks/grok-BLLATotv.js +0 -1
  347. package/dist/chunks/help-BR7UEr5R.js +0 -1
  348. package/dist/chunks/hooks-D6wtd0Qq.js +0 -1
  349. package/dist/chunks/initReplBridge-DyScxedy.js +0 -1
  350. package/dist/chunks/keybindings-CG292HS1.js +0 -2
  351. package/dist/chunks/launchOnboarding-CyOtdZkT.js +0 -8
  352. package/dist/chunks/loadAgentsDir-4UC4yLg1.js +0 -1
  353. package/dist/chunks/loadPluginHooks-CWI0RMUx.js +0 -1
  354. package/dist/chunks/localSearch-CCCDKpYx.js +0 -1
  355. package/dist/chunks/localSearch-D4hVR7-d.js +0 -1
  356. package/dist/chunks/main-DUjtDK1Q.js +0 -513
  357. package/dist/chunks/managedEnv-BuCurT_S.js +0 -1
  358. package/dist/chunks/mcp-CEKR7PjL.js +0 -6
  359. package/dist/chunks/mcp-DCAf2hHD.js +0 -1
  360. package/dist/chunks/mcp-mCuc8dNe.js +0 -2
  361. package/dist/chunks/memory-B5SkpC7u.js +0 -1
  362. package/dist/chunks/model-BqaneI4D.js +0 -1
  363. package/dist/chunks/model-C29_32BD.js +0 -1
  364. package/dist/chunks/model-NG8fvuT2.js +0 -1
  365. package/dist/chunks/modelOptions-CiZgZxZC.js +0 -1
  366. package/dist/chunks/nativeInstaller-DqbEfGSX.js +0 -1
  367. package/dist/chunks/openai-BvnsYTpQ.js +0 -10
  368. package/dist/chunks/parser-B2PlJg4C.js +0 -1
  369. package/dist/chunks/permissions-BPpeHxpk.js +0 -3
  370. package/dist/chunks/pidLock-DQGDoFQP.js +0 -3
  371. package/dist/chunks/plan-BRiC5ujG.js +0 -1
  372. package/dist/chunks/plugin-Dcg_GGR9.js +0 -17
  373. package/dist/chunks/pluginAutoupdate-ByH9IPC9.js +0 -1
  374. package/dist/chunks/pluginOperations-CKNyYjS-.js +0 -2
  375. package/dist/chunks/pluginStartupCheck-B48_cGgo.js +0 -1
  376. package/dist/chunks/plugins-BP_36tOl.js +0 -4
  377. package/dist/chunks/poorMode-Djw0P9Gu.js +0 -1
  378. package/dist/chunks/print-2uavraPq.js +0 -26
  379. package/dist/chunks/processBashCommand-g3sAMpHt.js +0 -1
  380. package/dist/chunks/processSlashCommand-tIbeCrv5.js +0 -5
  381. package/dist/chunks/prompt-DLv-Cd67.js +0 -1
  382. package/dist/chunks/prompt-DV5tCLRh.js +0 -1
  383. package/dist/chunks/protocolHandler-B83fCYI4.js +0 -13
  384. package/dist/chunks/reconciler-CDq6XgAS.js +0 -1
  385. package/dist/chunks/refresh-ysrhoWCo.js +0 -1
  386. package/dist/chunks/registerProtocol-DduKPsn_.js +0 -36
  387. package/dist/chunks/rename-1GLIUlYk.js +0 -1
  388. package/dist/chunks/resume-DWtlUiHW.js +0 -2
  389. package/dist/chunks/ripgrep-BLQnqPnE.js +0 -1
  390. package/dist/chunks/sandbox-adapter-BzjRQh_r.js +0 -1
  391. package/dist/chunks/sandbox-toggle-Bz49-F6e.js +0 -1
  392. package/dist/chunks/searchExtraTools-D6vj8qJ-.js +0 -1
  393. package/dist/chunks/sessionFileAccessHooks-Da97UA2n.js +0 -1
  394. package/dist/chunks/sessionObserver-DXO4trhk.js +0 -1
  395. package/dist/chunks/sessionState-Bn3ESS5f.js +0 -11
  396. package/dist/chunks/sessionStorage-DlPVsQn9.js +0 -1
  397. package/dist/chunks/sessionStoragePortable-BhkGMZWp.js +0 -3
  398. package/dist/chunks/settings-3ionQKNv.js +0 -1
  399. package/dist/chunks/settingsSync-eHaSngKo.js +0 -1
  400. package/dist/chunks/setup-DeyiuGNX.js +0 -3
  401. package/dist/chunks/sinks-Bgy2UNK-.js +0 -2
  402. package/dist/chunks/sinks-CgzLmim2.js +0 -1
  403. package/dist/chunks/skillChangeDetector-BlSP16j6.js +0 -1
  404. package/dist/chunks/skills-CJhWI8t1.js +0 -1
  405. package/dist/chunks/src-P_wYS_NJ2.js +0 -53
  406. package/dist/chunks/startupProfiler-CUlV07MD.js +0 -1
  407. package/dist/chunks/status-CDCurOqs.js +0 -2
  408. package/dist/chunks/status-yoQIQ2Ni.js +0 -1
  409. package/dist/chunks/statusNoticeHelpers-Sl4jjauz.js +0 -1
  410. package/dist/chunks/switcher-C-m6MUwE.js +0 -1
  411. package/dist/chunks/tasks-CHG_6sXQ.js +0 -1
  412. package/dist/chunks/teleport-C9KRE4X8.js +0 -1
  413. package/dist/chunks/theme-MvX7hojJ.js +0 -1
  414. package/dist/chunks/toolPool-Cq74Cvjp.js +0 -1
  415. package/dist/chunks/trustedDevice-BGwujSqc.js +0 -1
  416. package/dist/chunks/updateCCB-CfckOy7T.js +0 -11
  417. package/dist/chunks/upstreamproxy-BuBFDFAD.js +0 -11
  418. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CPLBDluY.js +0 -1
  419. package/dist/chunks/useMainLoopModel-C00PbZ1Q.js +0 -1
  420. package/dist/chunks/useManagePlugins-DFaGntzJ.js +0 -1
  421. package/dist/chunks/useMergedTools-DYobZ5N4.js +0 -1
  422. package/dist/chunks/useSettingsErrors-BRgjvaHd.js +0 -1
  423. package/dist/chunks/util-D7uwPgF1.js +0 -1
  424. package/dist/chunks/validatePlugin-VukX52bx.js +0 -1
  425. package/dist/chunks/windowsPaths-B8p9tFRF.js +0 -1
  426. package/dist/chunks/workerRegistry-BA37PVbv.js +0 -6
  427. package/dist/chunks/worktree-Lik8xuKd.js +0 -1
  428. package/dist/chunks/xdg-DcF9ejUM.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{l as e,o as t,u as n}from"./envUtils-DcaKZlRU.js";import{Dt as r,St as i,dS as a,fS as o,mt as s}from"./loadAgentsDir-JrGMJN05.js";import{t as c}from"./src-DL3w8VPk2.js";import{C as l,P as u,R as d,S as f,c as p,i as m,x as h}from"./debug-BQj6h99Q.js";import{Wt as g}from"./settings-aUygByiZ.js";import{O as _,k as v}from"./git-DplvjXEY.js";import{o as y,s as b}from"./log-BlJ7CcKG.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-2sjXZkIP.js";import{Bt as E,Ot as D,_n as O,vn as k}from"./model-CmDF8O9G.js";import{i as ee,t as A}from"./sessionIdCompat-Dgp6PW_1.js";import{n as j}from"./firstPartyEventLogger-D4yuDP-n.js";import{t as te}from"./datadog-DcLf1QpG.js";import{n as M,o as N,r as P}from"./debugUtils-B86DM1Sp.js";import{t as F}from"./pollConfig-BgpfHQPJ.js";import{n as I,t as L}from"./rcDebugLog-DSchf3Hs.js";import{a as R,i as z,n as B,o as ne,r as re,s as V,t as H}from"./capacityWake-LRiPhPeM.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-BUd8cQ6-.js";import{i as U}from"./trustedDevice-BF78PNK8.js";import{t as le}from"./jwtUtils-YCoZL0FW.js";import{n as W,r as G}from"./cliLaunch-xIVvtPZy.js";import"./bridgeStatusUtil-BQF0AJDO.js";import{t as K}from"./lib-BlVGipXx.js";import{hostname as q,tmpdir as ue}from"os";import{dirname as J,join as de,resolve as Y}from"path";import{createWriteStream as X}from"fs";import{randomUUID as Z}from"crypto";import{spawn as fe}from"child_process";import{createInterface as Q}from"readline";t(),d(),h(),_(),y(),x(),T(),O(),o(),te(),j(),i(),L(),K(),g(),c(),m(),A(),N();var pe=10,me=10;function he(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var ge={Read:`Reading`,Write:`Writing`,Edit:`Editing`,MultiEdit:`Editing`,Bash:`Running`,Glob:`Searching`,Grep:`Searching`,WebFetch:`Fetching`,WebSearch:`Searching`,Task:`Running task`,FileReadTool:`Reading`,FileWriteTool:`Writing`,FileEditTool:`Editing`,GlobTool:`Searching`,GrepTool:`Searching`,BashTool:`Running`,NotebookEditTool:`Editing notebook`,LSP:`LSP`};function $(e,t){let n=ge[e]??e,r=t.file_path??t.filePath??t.pattern??t.command?.slice(0,60)??t.url??t.query??``;return r?`${n} ${r}`:n}function _e(e,t,n){let r;try{r=f(e)}catch{return[]}if(!r||typeof r!=`object`)return[];let i=r,a=[],o=Date.now();switch(i.type){case`assistant`:{let e=i.message;if(!e)break;let r=e.content;if(!Array.isArray(r))break;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e;if(r.type===`tool_use`){let e=r.name??`Tool`,i=r.input??{},s=$(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${ye(i)}`)}else if(r.type===`text`){let e=r.text??``;e.length>0&&(a.push({type:`text`,summary:e.slice(0,80),timestamp:o}),n(`[bridge:activity] sessionId=${t} text "${e.slice(0,100)}"`))}}break}case`result`:{let e=i.subtype;if(e===`success`)a.push({type:`result`,summary:`Session completed`,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=success`);else if(e){let r=i.errors?.[0]??`Error: ${e}`;a.push({type:`error`,summary:r,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=${e} error="${r}"`)}else n(`[bridge:activity] sessionId=${t} result subtype=undefined`);break}default:break}return a}function ve(e){if(e.parent_tool_use_id!=null||e.isSynthetic||e.isReplay)return;let t=e.message?.content,n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`){n=e.text;break}}return n=n?.trim(),n||void 0}function ye(e){let t=[];for(let[n,r]of Object.entries(e))if(typeof r==`string`&&t.push(`${n}="${r.slice(0,100)}"`),t.length>=3)break;return t.join(` `)}function be(e){return{spawn(t,n){let r=he(t.sessionId),i;if(e.debugFile){let t=e.debugFile.lastIndexOf(`.`);i=t>0?`${e.debugFile.slice(0,t)}-${r}${e.debugFile.slice(t)}`:`${e.debugFile}-${r}`}else e.verbose&&(i=de(ue(),`claude`,`bridge-session-${r}.log`));let a=null,o;e.debugFile&&(o=de(J(e.debugFile),`bridge-transcript-${r}.jsonl`),a=X(o,{flags:`a`}),a.on(`error`,t=>{e.onDebug(`[bridge:session] Transcript write error: ${t.message}`),a=null}),e.onDebug(`[bridge:session] Transcript log: ${o}`));let s=[...e.scriptArgs,`--print`,`--sdk-url`,t.sdkUrl,`--session-id`,t.sessionId,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--replay-user-messages`,...e.verbose?[`--verbose`]:[],...i?[`--debug-file`,i]:[],...e.permissionMode?[`--permission-mode`,e.permissionMode]:[]],c={...e.env,CLAUDE_CODE_OAUTH_TOKEN:void 0,CLAUDE_CODE_ENVIRONMENT_KIND:`bridge`,...e.sandbox&&{CLAUDE_CODE_FORCE_SANDBOX:`1`},CLAUDE_CODE_SESSION_ACCESS_TOKEN:t.accessToken,CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2:`1`,...t.useCcrV2&&{CLAUDE_CODE_USE_CCR_V2:`1`,CLAUDE_CODE_WORKER_EPOCH:String(t.workerEpoch)}};e.onDebug(`[bridge:session] Spawning sessionId=${t.sessionId} sdkUrl=${t.sdkUrl} accessToken=${t.accessToken?`present`:`MISSING`}`),e.onDebug(`[bridge:session] Child args: ${s.join(` `)}`),i&&e.onDebug(`[bridge:session] Debug log: ${i}`);let u=fe(e.execPath,s,{cwd:n,stdio:[`pipe`,`pipe`,`pipe`],env:c,windowsHide:!0});e.onDebug(`[bridge:session] sessionId=${t.sessionId} pid=${u.pid}`);let d=[],p=null,m=[],h=!1,g=!1;u.stderr&&Q({input:u.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(`${t}\n`),m.length>=me&&m.shift(),m.push(t)}),u.stdout&&Q({input:u.stdout}).on(`line`,n=>{a&&a.write(`${n}\n`),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${M(n)}`),e.verbose&&process.stderr.write(`${n}\n`);let r=_e(n,t.sessionId,e.onDebug);for(let n of r)d.length>=pe&&d.shift(),d.push(n),p=n,e.onActivity?.(t.sessionId,n);{let r;try{r=f(n)}catch{}if(r&&typeof r==`object`){let n=r;if(n.type===`control_request`)n.request?.subtype===`can_use_tool`&&e.onPermissionRequest&&e.onPermissionRequest(t.sessionId,r,t.accessToken);else if(n.type===`user`&&!g&&t.onFirstUserMessage){let e=ve(n);e&&(g=!0,t.onFirstUserMessage(e))}}}});let _=new Promise(n=>{u.on(`close`,(r,i)=>{a&&(a.end(),a=null),i===`SIGTERM`||i===`SIGINT`?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} interrupted signal=${i} pid=${u.pid}`),n(`interrupted`)):r===0?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} completed exit_code=0 pid=${u.pid}`),n(`completed`)):(e.onDebug(`[bridge:session] sessionId=${t.sessionId} failed exit_code=${r} pid=${u.pid}`),n(`failed`))}),u.on(`error`,r=>{e.onDebug(`[bridge:session] sessionId=${t.sessionId} spawn error: ${r.message}`),n(`failed`)})}),v={sessionId:t.sessionId,done:_,activities:d,accessToken:t.accessToken,lastStderr:m,get currentActivity(){return p},kill(){u.killed||(e.onDebug(`[bridge:session] Sending SIGTERM to sessionId=${t.sessionId} pid=${u.pid}`),process.platform===`win32`?u.kill():u.kill(`SIGTERM`))},forceKill(){!h&&u.pid&&(h=!0,e.onDebug(`[bridge:session] Sending SIGKILL to sessionId=${t.sessionId} pid=${u.pid}`),process.platform===`win32`?u.kill():u.kill(`SIGKILL`))},writeStdin(n){u.stdin&&!u.stdin.destroyed&&(e.onDebug(`[bridge:ws] sessionId=${t.sessionId} >>> ${M(n)}`),u.stdin.write(n))},updateAccessToken(n){v.accessToken=n,v.writeStdin(`${l({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})}\n`),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return v}}}m(),N();var xe={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Se=1e3;function Ce(e){return e.connCapMs*2}function we(){let e=[...W()],t=G();return t&&e.push(t),e}function Te(e,t,n){try{return e.spawn(t,n)}catch(e){let t=u(e);return b(Error(`Session spawn failed: ${t}`)),t}}async function Ee(t,i,o,c,l,d,f,m=xe,h,g){let _=new AbortController;f.aborted?_.abort():f.addEventListener(`abort`,()=>_.abort(),{once:!0});let y=_.signal,x=new Map,C=new Map,T=new Map,E=new Map,D=new Map,O=new Map,A=new Set,j=new Map,te=new Set,M=new Set,N=H(y);async function L(){I(`heartbeat: checking ${x.size} active session(s)`);let e=!1,t=!1,n=[];for(let[r]of x){let a=T.get(r),o=D.get(r);if(!(!a||!o))try{await c.heartbeatWork(i,a,o),e=!0}catch(e){p(`[bridge:heartbeat] Failed for sessionId=${r} workId=${a}: ${u(e)}`),e instanceof B&&(S(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),e.status===401||e.status===403?n.push(r):t=!0)}}for(let e of n){d.logVerbose(`Session ${e} token expired — re-queuing via bridge/reconnect`);try{await c.reconnectSession(i,e),p(`[bridge:heartbeat] Re-queued sessionId=${e} via bridge/reconnect`)}catch(t){d.logError(`Failed to refresh session ${e} token: ${u(t)}`),p(`[bridge:heartbeat] reconnectSession(${e}) failed: ${u(t)}`,{level:`error`})}}return t?`fatal`:n.length>0?`auth_failed`:e?`ok`:`failed`}let re=new Set,V=g?le({getAccessToken:g,onRefresh:(e,t)=>{let n=x.get(e);n&&(re.has(e)?(d.logVerbose(`Refreshing session ${e} token via bridge/reconnect`),c.reconnectSession(i,e).catch(t=>{d.logError(`Failed to refresh session ${e} token: ${u(t)}`),p(`[bridge:token] reconnectSession(${e}) failed: ${u(t)}`,{level:`error`})})):n.updateAccessToken(t))},label:`bridge`}):null,U=Date.now(),W=new Set;function G(e){W.add(e),e.finally(()=>W.delete(e))}let K=0,q=0,J=null,Y=null,X=null,Z=null;p(`[bridge:work] Starting poll loop spawnMode=${t.spawnMode} maxSessions=${t.maxSessions} environmentId=${i}`),v(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),d.printBanner(t,i),d.updateSessionCount(0,t.maxSessions,t.spawnMode),h&&d.setAttached(h);function fe(){d.updateSessionCount(x.size,t.maxSessions,t.spawnMode);for(let[e,t]of x){let n=t.currentActivity;n&&d.updateSessionActivity(E.get(e)??e,n)}if(x.size===0){d.updateIdleStatus();return}let[e,n]=[...x.entries()].pop(),r=C.get(e);if(!r)return;let i=n.currentActivity;if(!i||i.type===`result`||i.type===`error`){t.maxSessions>1&&d.refreshDisplay();return}let a=w(Date.now()-r),o=n.activities.filter(e=>e.type===`tool_start`).slice(-5).map(e=>e.summary);d.updateSessionStatus(e,a,i,o)}function Q(){pe(),fe(),Z=setInterval(fe,Se)}function pe(){Z&&(clearInterval(Z),Z=null)}function me(e,n,a){return o=>{let s=T.get(e);I(`session done: sessionId=${e} workId=${s??`none`} status=${o} wasTimedOut=${te.has(e)} duration=${Math.round((Date.now()-n)/1e3)}s stderr=${a.lastStderr.length>0?a.lastStderr.join(`\\n`).slice(0,500):`(none)`}`),x.delete(e),C.delete(e),T.delete(e),D.delete(e);let l=E.get(e)??e;E.delete(e),d.removeSession(l),M.delete(l),re.delete(e);let f=O.get(e);f&&(clearTimeout(f),O.delete(e)),V?.cancel(e),N.wake();let h=te.delete(e),g=h&&o===`interrupted`?`failed`:o,k=Date.now()-n;p(`[bridge:session] sessionId=${e} workId=${s??`unknown`} exited status=${g} duration=${w(k)}`),S(`tengu_bridge_session_done`,{status:g,duration_ms:k}),v(`info`,`bridge_session_done`,{status:g,duration_ms:k}),d.clearStatus(),pe();let ee=a.lastStderr.length>0?a.lastStderr.join(`
2
+ `):void 0,P;switch(g){case`completed`:d.logSessionComplete(e,k);break;case`failed`:!h&&!y.aborted&&(P=ee??`Process exited with error`,d.logSessionFailed(e,P),b(Error(`Bridge session failed: ${P}`)));break;case`interrupted`:d.logVerbose(`Session ${e} interrupted`);break}g!==`interrupted`&&s&&(G(Me(c,i,s,d,m.stopWorkBaseDelayMs)),A.add(s));let F=j.get(e);if(F&&(j.delete(e),G(r(F.worktreePath,F.worktreeBranch,F.gitRoot,F.hookBased).catch(e=>d.logVerbose(`Failed to remove worktree ${F.worktreePath}: ${u(e)}`)))),g!==`interrupted`&&!y.aborted)if(t.spawnMode!==`single-session`)G(c.archiveSession(l).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`))),p(`[bridge:session] Session ${g}, returning to idle (multi-session mode)`);else{p(`[bridge:session] Session ${g}, aborting poll loop to tear down environment`),_.abort();return}y.aborted||Q()}}for(h||Q();!y.aborted;){let f=F();try{I(`poll: envId=${i} activeSessions=${x.size}`);let g=await c.pollForWork(i,o,y,f.reclaim_older_than_ms);if(J!==null||Y!==null){let e=Date.now()-(J??Y??Date.now());d.logReconnected(e),p(`[bridge:poll] Reconnected after ${w(e)}`),S(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(K=0,q=0,J=null,Y=null,X=null,!g){if(x.size>=t.maxSessions){let e=f.multisession_poll_interval_ms_at_capacity;if(f.non_exclusive_heartbeat_interval_ms>0){S(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:x.size,heartbeat_interval_ms:f.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!y.aborted&&x.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=F();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=N.signal();if(r=await L(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await k(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:y.aborted?`shutdown`:x.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(S(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:x.size}),a===`poll_due`&&p(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=N.signal();await k(e>0?e:f.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=N.signal();await k(e,t.signal),t.cleanup()}}else await k(x.size>0?f.multisession_poll_interval_ms_partial_capacity:f.multisession_poll_interval_ms_not_at_capacity,y);continue}let _=x.size>=t.maxSessions;if(A.has(g.id)){if(p(`[bridge:work] Skipping already-completed workId=${g.id}`),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await k(1e3,y);continue}let P;try{P=se(g.secret)}catch(e){let t=u(e);if(d.logError(`Failed to decode work secret for workId=${g.id}: ${t}`),S(`tengu_bridge_work_secret_failed`,{}),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs)),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let R=async()=>{p(`[bridge:work] Acknowledging workId=${g.id}`);try{await c.acknowledgeWork(i,g.id,P.session_ingress_token)}catch(e){p(`[bridge:work] Acknowledge failed workId=${g.id}: ${u(e)}`)}},z=g.data.type;switch(g.data.type){case`healthcheck`:await R(),p(`[bridge:work] Healthcheck received`),d.logVerbose(`Healthcheck received`);break;case`session`:{let o=g.data.id;I(`work received: type=session sessionId=${o} workId=${g.id}`);try{ne(o,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${o}`);break}let f=x.get(o);if(f){f.updateAccessToken(P.session_ingress_token),D.set(o,P.session_ingress_token),T.set(o,g.id),V?.schedule(o,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${o} workId=${g.id}`),await R();break}if(x.size>=t.maxSessions){p(`[bridge:work] At capacity (${x.size}/${t.maxSessions}), cannot spawn new session for workId=${g.id}`);break}await R();let _=Date.now(),w,N=!1,F;if(P.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){w=ce(t.apiBaseUrl,o);for(let e=1;e<=2;e++)try{F=await ae(w,P.session_ingress_token),N=!0,p(`[bridge:session] CCR v2: registered worker sessionId=${o} epoch=${F} attempt=${e}`);break}catch(t){let n=u(t);if(e<2){if(p(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await k(2e3,y),y.aborted)break;continue}d.logError(`CCR v2 worker registration failed for session ${o}: ${n}`),b(Error(`registerWorker failed: ${n}`)),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs))}if(!N)break}else w=oe(t.sessionIngressUrl,o);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(o,h))){let e=Date.now();try{let t=await s(`bridge-${he(o)}`);B=Date.now()-e,j.set(o,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),z=t.worktreePath,p(`[bridge:session] Created worktree for sessionId=${o} at ${t.worktreePath}`)}catch(e){let t=u(e);d.logError(`Failed to create worktree for session ${o}: ${t}`),b(Error(`Worktree creation failed: ${t}`)),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs));break}}p(`[bridge:session] Spawning sessionId=${o} sdkUrl=${w}`);let H=ee(o);I(`spawning session: sessionId=${o} sdkUrl=${w} useCcrV2=${N} workerEpoch=${F} dir=${z} accessToken=${P.session_ingress_token?`${P.session_ingress_token.slice(0,8)}...`:`NONE`}`);let se=Te(l,{sessionId:o,sdkUrl:w,accessToken:P.session_ingress_token,useCcrV2:N,workerEpoch:F,onFirstUserMessage:e=>{if(M.has(H))return;M.add(H);let n=Fe(e);d.setSessionTitle(H,n),p(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-BZx-2UIB.js`).then(({updateBridgeSessionTitle:e})=>e(H,n,{baseUrl:t.apiBaseUrl})).catch(e=>p(`[bridge:title] failed to update title for ${H}: ${e}`,{level:`error`}))}},z);if(typeof se==`string`){d.logError(`Failed to spawn session ${o}: ${se}`);let e=j.get(o);e&&(j.delete(o),G(r(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>d.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${u(t)}`)))),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs));break}let U=se,le=Date.now()-_;S(`tengu_bridge_session_started`,{active_sessions:x.size,spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B}),x.set(o,U),T.set(o,g.id),D.set(o,P.session_ingress_token),E.set(o,H);let W=Date.now();C.set(o,W),d.logSessionStart(o,`Session ${o}`);let K=he(o),q;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);q=e>0?`${t.debugFile.slice(0,e)}-${K}${t.debugFile.slice(e)}`:`${t.debugFile}-${K}`}else t.verbose&&(q=de(ue(),`claude`,`bridge-session-${K}.log`));q&&d.logVerbose(`Debug log: ${q}`),d.addSession(H,a(H,t.sessionIngressUrl)),Q(),d.setAttached(H),Ie(H,t.apiBaseUrl).then(e=>{e&&x.has(o)&&(M.add(H),d.setSessionTitle(H,e),p(`[bridge:title] server title for ${H}: ${e}`))}).catch(e=>p(`[bridge:title] failed to fetch title for ${H}: ${e}`,{level:`error`}));let J=t.sessionTimeoutMs??864e5;if(J>0){let e=setTimeout(Ne,J,o,J,d,te,U);O.set(o,e)}N&&re.add(o),V?.schedule(o,P.session_ingress_token),U.done.then(me(o,W,U));break}default:await R(),p(`[bridge:work] Unknown work type: ${z}, skipping`);break}if(_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(y.aborted)break;if(e instanceof B){z(e.errorType)?d.logStatus(e.message):R(e)?p(`[bridge:work] Suppressed 403 error: ${e.message}`):(d.logError(e.message),b(e)),S(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),v(z(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=P(e);if(I(`poll error: ${t} isConn=${Oe(e)} isServer=${ke(e)} activeSessions=${x.size}`),Oe(e)||ke(e)){let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,J||(J=e);let n=e-J;if(n>=m.connGiveUpMs){d.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n});break}Y=null,q=0,K=K?Math.min(K*2,m.connCapMs):m.connInitialMs;let r=Ae(K);d.logVerbose(`Connection error, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}else{let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,Y||(Y=e);let n=e-Y;if(n>=m.generalGiveUpMs){d.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n});break}J=null,K=0,q=q?Math.min(q*2,m.generalCapMs):m.generalInitialMs;let r=Ae(q);d.logVerbose(`Poll failed, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}}}pe(),d.clearStatus();let ge=Date.now()-U;S(`tengu_bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge}),v(`info`,`bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge});let $=new Set(x.keys());h&&$.add(h);let _e=new Map(E);if(x.size>0){p(`[bridge:shutdown] Shutting down ${x.size} active session(s)`),d.logStatus(`Shutting down ${x.size} active session(s)\u2026`);let e=new Map(T);for(let[e,t]of x.entries())p(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...x.values()].map(e=>e.done)),k(m.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of x.entries())p(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of O.values())clearTimeout(e);if(O.clear(),V?.cancelAll(),j.size>0){let e=[...j.values()];j.clear(),p(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>r(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>c.stopWork(i,t,!0).catch(n=>d.logVerbose(`Failed to stop work ${t} for session ${e}: ${u(n)}`))))}W.size>0&&await Promise.allSettled([...W]),$.size>0&&(p(`[bridge:shutdown] Archiving ${$.size} session(s)`),await Promise.allSettled([...$].map(e=>c.archiveSession(_e.get(e)??ee(e)).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`)))));try{await c.deregisterEnvironment(i),p(`[bridge:shutdown] Environment deregistered, bridge offline`),d.logVerbose(`Environment deregistered.`)}catch(e){d.logVerbose(`Failed to deregister environment: ${u(e)}`)}let{clearBridgePointer:ve}=await import(`./bridgePointer-CiHy2tTN.js`);await ve(t.dir),d.logVerbose(`Environment offline.`)}var De=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function Oe(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&De.has(e.code))}function ke(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function Ae(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function je(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function Me(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),p(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof B){R(e)?p(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),v(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=u(e);if(a<3){let e=Ae(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${je(e)}: ${t}`),await k(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),v(`error`,`bridge_stop_work_failed`,{attempts:3})}}function Ne(e,t,n,r,i){p(`[bridge:session] sessionId=${e} timed out after ${w(t)}`),S(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${w(t)}`),r.add(e),i.kill()}var Pe=80;function Fe(e){return C(e.replace(/\s+/g,` `).trim(),Pe)}async function Ie(e,t){let{getBridgeSession:n}=await import(`./createSession-BZx-2UIB.js`);return(await n(e,{baseUrl:t}))?.title||void 0}var Le=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function Re(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-CsdHk8n-.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-WMxn2jLl.js`);o();let{initSinks:c}=await import(`./sinks-B_ehGpvp.js`);if(c(),!s())throw new Le(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(V);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-Bxs5dqjH.js`),d=l();if(d.startsWith(`http://`)&&!d.includes(`localhost`)&&!d.includes(`127.0.0.1`))throw new Le(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let f=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||d,{getBranch:p,getRemoteUrl:m,findGitRoot:h}=await import(`./git-BaSq69E7.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-9rkDD2iw.js`);if(e.spawnMode===`worktree`&&!(g()||h(n)!==null))throw new Le(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let _=await p(),v=await m(),y=q(),b=Z(),x={dir:n,machineName:y,branch:_,gitRepoUrl:v,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:b,workerType:`claude_code`,environmentId:Z(),apiBaseUrl:d,sessionIngressUrl:f,sessionTimeoutMs:e.sessionTimeoutMs},S=re({baseUrl:d,getAccessToken:e.getAccessToken,runnerVersion:`0.0.14`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:U}),C,w;try{let e=await S.registerBridgeEnvironment(x);C=e.environment_id,w=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${u(e)}`)}let T=be({execPath:process.execPath,scriptArgs:we(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),E=ze(r);E.printBanner(x,C);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-BZx-2UIB.js`);try{let i=await n({environmentId:C,title:e.name,events:[],gitRepoUrl:v,branch:_,signal:t,baseUrl:d,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(D=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${u(e)}`)}}await Ee(x,C,w,S,T,E,t,void 0,D,async()=>e.getAccessToken())}function ze(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}E(),d();var Be=78,Ve=1;async function He(e){if(!e){console.error(`Error: --daemon-worker requires a worker kind`),process.exitCode=Be;return}switch(e){case`remoteControl`:await Ue();break;default:console.error(`Error: unknown daemon worker kind '${e}'`),process.exitCode=Be}}async function Ue(){let e=process.env.DAEMON_WORKER_DIR||Y(`.`),t=process.env.DAEMON_WORKER_NAME||void 0,n=process.env.DAEMON_WORKER_SPAWN_MODE||`same-dir`,r=parseInt(process.env.DAEMON_WORKER_CAPACITY||`4`,10),i=process.env.DAEMON_WORKER_PERMISSION||void 0,a=process.env.DAEMON_WORKER_SANDBOX===`1`,o=process.env.DAEMON_WORKER_TIMEOUT_MS?parseInt(process.env.DAEMON_WORKER_TIMEOUT_MS,10):void 0,s=process.env.DAEMON_WORKER_CREATE_SESSION!==`0`,c=new AbortController,l=()=>c.abort();process.on(`SIGTERM`,l),process.on(`SIGINT`,l);let d={dir:e,name:t,spawnMode:n,capacity:r,permissionMode:i,sandbox:a,sessionTimeoutMs:o,createSessionOnStart:s,getAccessToken:()=>D()?.accessToken,onAuth401:async e=>!!D()?.accessToken,log:e=>{console.log(`[remoteControl] ${e}`)}};try{await Re(d,c.signal)}catch(e){e instanceof Le?(console.error(`[remoteControl] permanent error: ${e.message}`),process.exitCode=Be):(console.error(`[remoteControl] transient error: ${u(e)}`),process.exitCode=Ve)}finally{process.off(`SIGTERM`,l),process.off(`SIGINT`,l)}}export{He as runDaemonWorker};
@@ -0,0 +1 @@
1
+ import{St as e,_t as t}from"./loadAgentsDir-JrGMJN05.js";e();export{t as execIntoTmuxWorktree};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- import{l as e,o as t}from"./chunks/envUtils-DcaKZlRU.js";var n=globalThis.performance,r=new Map,i=new Map;function a(){return n.now()}function o(e){return r.set(e,a()),{name:e,entryType:`mark`,startTime:r.get(e),duration:0}}function s(e,t,n){let o,s;if(typeof t==`string`){let e=r.get(t),i=n?r.get(n):a();o=e??a(),s=(i??a())-o}else t&&typeof t==`object`?(o=t.start??0,s=(t.end??a())-o):(o=0,s=a());i.set(e,{name:e,startTime:o,duration:s})}function c(e){return e===`mark`?[...r.entries()].map(([e,t])=>({name:e,entryType:`mark`,startTime:t,duration:0})):e===`measure`?[...i.values()].map(e=>({name:e.name,entryType:`measure`,startTime:e.startTime,duration:e.duration})):[]}function l(e,t){return c(t??`mark`).concat(t===void 0?c(`measure`):[]).filter(t=>t.name===e)}function u(e){e===void 0?r.clear():r.delete(e)}function d(e){e===void 0?i.clear():i.delete(e)}var f={now:a,mark:o,measure:s,getEntriesByType:c,getEntriesByName:l,clearMarks:u,clearMeasures:d,clearResourceTimings:(()=>{}),setResourceTimingBufferSize:(()=>{}),markResourceTiming:(()=>{}),get timeOrigin(){return n.timeOrigin},get onresourcetimingbufferfull(){return n.onresourcetimingbufferfull},set onresourcetimingbufferfull(e){},toJSON(){return n.toJSON()}};function p(){globalThis.__performanceShimInstalled||(globalThis.__performanceShimInstalled=!0,globalThis.performance=f)}if(p(),t(),globalThis.MACRO===void 0&&(globalThis.MACRO={VERSION:process.env.CLAUDE_CODE_VERSION||`2.1.888`,BUILD_TIME:new Date().toISOString(),FEEDBACK_CHANNEL:``,ISSUES_EXPLAINER:``,NATIVE_PACKAGE_URL:``,PACKAGE_URL:``,VERSION_CHANGELOG:``}),e(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)){for(let e of[process.stdin,process.stdout,process.stderr])if(!e.isTTY)try{Object.defineProperty(e,"isTTY",{value:!0,configurable:!0})}catch{}}if(process.env.COREPACK_ENABLE_AUTO_PIN=`0`,process.env.CLAUDE_CODE_REMOTE===`true`){let e=process.env.NODE_OPTIONS||``;process.env.NODE_OPTIONS=e?`${e} --max-old-space-size=8192`:`--max-old-space-size=8192`}async function m(){let e=process.argv.slice(2);if(e.length===1&&(e[0]===`--version`||e[0]===`-v`||e[0]===`-V`)){console.log(`0.0.13 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-CUlV07MD.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-DCbq734V.js`);await e();return}if(e[0]===`--daemon-worker`||e[0]?.startsWith(`--daemon-worker=`)){let t=e[0]===`--daemon-worker`?e[1]:e[0].split(`=`)[1],{runDaemonWorker:n}=await import(`./chunks/workerRegistry-BA37PVbv.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);r();let{initSinks:i}=await import(`./chunks/sinks-CgzLmim2.js`);i();let{daemonMain:a}=await import(`./chunks/main-CGLCy2pM.js`);await a(e.slice(1));return}if(e.includes(`--bg`)||e.includes(`--background`)){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);r(),await(await import(`./chunks/bg-Ci7pG4eo.js`)).handleBgStart(e.filter(e=>e!==`--bg`&&e!==`--background`));return}if(e[0]===`ps`||e[0]===`logs`||e[0]===`attach`||e[0]===`kill`){let n=e[0]===`ps`?`status`:e[0];console.error(`[deprecated] Use: claude daemon ${n}${e[1]?` `+e[1]:``}`),t(`cli_daemon_path`);let{enableConfigs:r}=await import(`./chunks/config-DMKtiMzJ.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);i();let{initSinks:a}=await import(`./chunks/sinks-CgzLmim2.js`);a();let{daemonMain:o}=await import(`./chunks/main-CGLCy2pM.js`);await o([e[0]===`ps`?`status`:e[0],...e.slice(1)]);return}if(e[0]===`job`){t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-BYYfF4m5.js`);await n(e.slice(1)),process.exit(0)}if(e[0]===`new`||e[0]===`list`||e[0]===`reply`){console.error(`[deprecated] Use: claude job ${e[0]} ${e.slice(1).join(` `)}`.trim()),t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-BYYfF4m5.js`);await n(e),process.exit(0)}if((e.includes(`--tmux`)||e.includes(`--tmux=classic`))&&(e.includes(`-w`)||e.includes(`--worktree`)||e.some(e=>e.startsWith(`--worktree=`)))){t(`cli_tmux_worktree_fast_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-Lik8xuKd.js`),n=await t(e);if(n.handled)return;if(n.error){let{exitWithError:e}=await import(`./chunks/process-CNfq37LF.js`);e(n.error)}}}e.length===1&&(e[0]===`--update`||e[0]===`--upgrade`)&&(process.argv=[process.argv[0],process.argv[1],`update`]),e.includes(`--bare`)&&(process.env.CLAUDE_CODE_SIMPLE=`1`);let{startCapturingEarlyInput:n}=await import(`./chunks/earlyInput-BEjRkAtH.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-DUjtDK1Q.js`);t(`cli_after_main_import`),await r(),t(`cli_after_main_complete`)}await m();export{};
2
+ import{l as e,o as t}from"./chunks/envUtils-DcaKZlRU.js";var n=globalThis.performance,r=new Map,i=new Map;function a(){return n.now()}function o(e){return r.set(e,a()),{name:e,entryType:`mark`,startTime:r.get(e),duration:0}}function s(e,t,n){let o,s;if(typeof t==`string`){let e=r.get(t),i=n?r.get(n):a();o=e??a(),s=(i??a())-o}else t&&typeof t==`object`?(o=t.start??0,s=(t.end??a())-o):(o=0,s=a());i.set(e,{name:e,startTime:o,duration:s})}function c(e){return e===`mark`?[...r.entries()].map(([e,t])=>({name:e,entryType:`mark`,startTime:t,duration:0})):e===`measure`?[...i.values()].map(e=>({name:e.name,entryType:`measure`,startTime:e.startTime,duration:e.duration})):[]}function l(e,t){return c(t??`mark`).concat(t===void 0?c(`measure`):[]).filter(t=>t.name===e)}function u(e){e===void 0?r.clear():r.delete(e)}function d(e){e===void 0?i.clear():i.delete(e)}var f={now:a,mark:o,measure:s,getEntriesByType:c,getEntriesByName:l,clearMarks:u,clearMeasures:d,clearResourceTimings:(()=>{}),setResourceTimingBufferSize:(()=>{}),markResourceTiming:(()=>{}),get timeOrigin(){return n.timeOrigin},get onresourcetimingbufferfull(){return n.onresourcetimingbufferfull},set onresourcetimingbufferfull(e){},toJSON(){return n.toJSON()}};function p(){globalThis.__performanceShimInstalled||(globalThis.__performanceShimInstalled=!0,globalThis.performance=f)}if(p(),t(),globalThis.MACRO===void 0&&(globalThis.MACRO={VERSION:process.env.CLAUDE_CODE_VERSION||`2.1.888`,BUILD_TIME:new Date().toISOString(),FEEDBACK_CHANNEL:``,ISSUES_EXPLAINER:``,NATIVE_PACKAGE_URL:``,PACKAGE_URL:``,VERSION_CHANGELOG:``}),e(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)){for(let e of[process.stdin,process.stdout,process.stderr])if(!e.isTTY)try{Object.defineProperty(e,"isTTY",{value:!0,configurable:!0})}catch{}}if(process.env.COREPACK_ENABLE_AUTO_PIN=`0`,process.env.CLAUDE_CODE_REMOTE===`true`){let e=process.env.NODE_OPTIONS||``;process.env.NODE_OPTIONS=e?`${e} --max-old-space-size=8192`:`--max-old-space-size=8192`}async function m(){let e=process.argv.slice(2);if(e.length===1&&(e[0]===`--version`||e[0]===`-v`||e[0]===`-V`)){console.log(`0.0.14 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-B2fyaBEa.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-wISucmYc.js`);await e();return}if(e[0]===`--daemon-worker`||e[0]?.startsWith(`--daemon-worker=`)){let t=e[0]===`--daemon-worker`?e[1]:e[0].split(`=`)[1],{runDaemonWorker:n}=await import(`./chunks/workerRegistry-GrD7IAVQ.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-WMxn2jLl.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-BybjGW7e.js`);r();let{initSinks:i}=await import(`./chunks/sinks-B_ehGpvp.js`);i();let{daemonMain:a}=await import(`./chunks/main-Zh18lf2J.js`);await a(e.slice(1));return}if(e.includes(`--bg`)||e.includes(`--background`)){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-WMxn2jLl.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-BybjGW7e.js`);r(),await(await import(`./chunks/bg-DltfF1_K.js`)).handleBgStart(e.filter(e=>e!==`--bg`&&e!==`--background`));return}if(e[0]===`ps`||e[0]===`logs`||e[0]===`attach`||e[0]===`kill`){let n=e[0]===`ps`?`status`:e[0];console.error(`[deprecated] Use: claude daemon ${n}${e[1]?` ${e[1]}`:``}`),t(`cli_daemon_path`);let{enableConfigs:r}=await import(`./chunks/config-WMxn2jLl.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-BybjGW7e.js`);i();let{initSinks:a}=await import(`./chunks/sinks-B_ehGpvp.js`);a();let{daemonMain:o}=await import(`./chunks/main-Zh18lf2J.js`);await o([e[0]===`ps`?`status`:e[0],...e.slice(1)]);return}if(e[0]===`job`){t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-CY7GNRo5.js`);await n(e.slice(1)),process.exit(0)}if(e[0]===`new`||e[0]===`list`||e[0]===`reply`){console.error(`[deprecated] Use: claude job ${e[0]} ${e.slice(1).join(` `)}`.trim()),t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-CY7GNRo5.js`);await n(e),process.exit(0)}if((e.includes(`--tmux`)||e.includes(`--tmux=classic`))&&(e.includes(`-w`)||e.includes(`--worktree`)||e.some(e=>e.startsWith(`--worktree=`)))){t(`cli_tmux_worktree_fast_path`);let{enableConfigs:n}=await import(`./chunks/config-WMxn2jLl.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-V7xiUAtl.js`),n=await t(e);if(n.handled)return;if(n.error){let{exitWithError:e}=await import(`./chunks/process-CNfq37LF.js`);e(n.error)}}}e.length===1&&(e[0]===`--update`||e[0]===`--upgrade`)&&(process.argv=[process.argv[0],process.argv[1],`update`]),e.includes(`--bare`)&&(process.env.CLAUDE_CODE_SIMPLE=`1`);let{startCapturingEarlyInput:n}=await import(`./chunks/earlyInput-BEjRkAtH.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-C_PDzJdv.js`);t(`cli_after_main_import`),await r(),t(`cli_after_main_complete`)}await m();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readmagic/workmate",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "workMate",
5
5
  "type": "module",
6
6
  "author": "Frandy",
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Ap as i,EC as a,F as o,I as s,L as c,Xu as l,Zu as u,jp as d,od as f,sd as p}from"./loadAgentsDir-mcRW90aq.js";import{D as m,I as h,P as g,T as _,Wt as v,fi as y,t as b,vn as x,y as S,yn as C}from"./src-P_wYS_NJ2.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{r as T,t as E}from"./directoryCompletion-ByBTSuLu.js";import{r as D,t as O}from"./PromptInputFooterSuggestions-R12fbdmp.js";function k(){return(0,P.jsx)(g,{dimColor:!0,children:`Claude Code 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:o}){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)(f,{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:o})}),i&&(0,P.jsx)(g,{color:`error`,children:i})]})}function M({onAddDirectory:e,onCancel:t,permissionContext:n,directoryPath:r}){let[a,s]=(0,N.useState)(``),[u,d]=(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(a)},[a,w]);let T=(0,N.useCallback)(e=>{let t=e.id+`/`;s(t),d(null)},[]),D=(0,N.useCallback)(async t=>{let r=await c(t,n);r.resultType===`success`?e(r.absolutePath,!1):d(o(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)(i,{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)(l,{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:a,onChange:s,onSubmit:D,error:u,suggestions:f,selectedSuggestion:y})]})})})}var N,P,F,I=e((()=>{n(),y(),N=t(y(),1),x(),s(),p(),b(),a(),T(),d(),u(),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};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./AgentsMdExternalIncludesDialog-CH9x1Ngp.js";e();export{t as AgentsMdExternalIncludesDialog};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{ng as e,tg as t}from"./loadAgentsDir-mcRW90aq.js";import{R as n,fi as r,t as i}from"./src-P_wYS_NJ2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{c as o,h as s,y as c}from"./config-9rLTDOYW.js";import{n as l}from"./onChangeAppState-Dq1tIEJI.js";import{t as u}from"./fpsMetrics-DffAomdg.js";import{t as d}from"./stats-BkadEKa-.js";r(),e(),i(),s();var f=a();function p({getFpsMetrics:e,stats:r,initialState:i,children:a}){return(0,f.jsx)(u,{getFpsMetrics:e,children:(0,f.jsx)(d,{store:r,children:(0,f.jsx)(t,{initialState:i,onChangeAppState:l,children:(0,f.jsx)(n,{initialState:o().theme,onThemeSave:e=>c(t=>({...t,theme:e})),children:a})})})})}export{p as App};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{Xu as e,Yu as t}from"./loadAgentsDir-mcRW90aq.js";import{P as n,fi as r,t as i,y as a}from"./src-P_wYS_NJ2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{h as s,y as c}from"./config-9rLTDOYW.js";r(),i(),s(),t();var l=o();function u({customApiKeyTruncated:t,onDone:r}){function i(e){switch(e){case`yes`:c(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,approved:[...e.customApiKeyResponses?.approved??[],t]}})),r(!0);break;case`no`:c(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,rejected:[...e.customApiKeyResponses?.rejected??[],t]}})),r(!1);break}}return(0,l.jsxs)(a,{title:`Detected a custom API key in your environment`,color:`warning`,onCancel:()=>i(`no`),children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,children:`ANTHROPIC_API_KEY`}),(0,l.jsxs)(n,{children:[`: sk-ant-...`,t]})]}),(0,l.jsx)(n,{children:`Do you want to use this API key?`}),(0,l.jsx)(e,{defaultValue:`no`,defaultFocusValue:`no`,options:[{label:`Yes`,value:`yes`},{label:(0,l.jsxs)(n,{children:[`No (`,(0,l.jsx)(n,{bold:!0,children:`recommended`}),`)`]}),value:`no`}],onChange:e=>i(e),onCancel:()=>i(`no`)})]})}export{u as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./ApproveApiKey-BEGV9Zj9.js";export{e as ApproveApiKey};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./figures-5ThXQEtq.js";import{$c as a,$h as o,$l as s,An as c,Bf as l,DC as u,EC as d,Ea as f,Ff as p,Ig as m,MC as h,Nf as g,Ng as ee,OC as te,On as _,Rs as ne,Xu as v,Zu as y,_S as b,ag as re,du as ie,ed as ae,eg as oe,el as se,eu as ce,gS as le,hp as x,lp as S,mf as C,mp as ue,na as de,ng as fe,nu as w,pf as pe,qa as me,rd as he,rg as ge,ru as _e,su as ve,tu as ye,up as be,za as xe,zf as Se,zs as Ce}from"./loadAgentsDir-mcRW90aq.js";import{D as T,Gt as E,H as we,I as D,Lt as Te,P as O,T as k,fi as A,mt as Ee,ot as De,t as j,y as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Oe,R as ke,_ as Ae,f as je}from"./debug-Dr1SjdXn.js";import{Ln as P,Rn as Me,Wt as Ne,zn as Pe}from"./settings-DiBMs2gM.js";import{C as Fe,b as F,f as Ie,l as Le,u as Re,v as I}from"./startupProfiler-Dc5r6LgE.js";import{l as L,o as ze}from"./stringUtils-Df-Lnjxd.js";import{bn as Be,jt as Ve,vn as He,yn as Ue}from"./prompt-DIlq8NTy.js";import{i as We,n as Ge}from"./mappers-DwZw084m.js";function R(e,t,n=1e3,r=0,i){let a=()=>Le(Math.max(0,(i??Date.now())-e-r));return(0,Ke.useSyncExternalStore)((0,Ke.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var Ke,z=t((()=>{Ke=n(A(),1),I()}));function qe(e,t,n){let r=He(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,Je.jsxs)(O,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var Je,Ye=t((()=>{A(),j(),Be(),Je=N()}));function Xe(e,t){let{isIdle:n,awaitingApproval:r,hasError:a,shutdownRequested:o}=t??{};return a?i.cross:r?i.questionMarkPrefix:o?i.warning:e===`running`?n?i.ellipsis:i.play:e===`completed`?i.tick:e===`failed`||e===`killed`?i.cross:i.bullet}function Ze(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 Qe(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(l(t))return n=!0,!1;return n}var $e=t((()=>{r(),Se()}));function et({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=we(),o=(0,tt.useMemo)(()=>a(Ue()),[]),s=R(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);E({"confirm:yes":t},{context:`Confirmation`});let c=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},l=f(e.prompt,`plan`),u=e.prompt.length>300?e.prompt.substring(0,297)+`…`:e.prompt,d=e.result?.totalTokens??e.progress?.tokenCount,p=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,B.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:c,children:(0,B.jsx)(M,{title:(0,B.jsxs)(O,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,B.jsxs)(O,{children:[e.status!==`running`&&(0,B.jsxs)(O,{color:Ze(e.status),children:[Xe(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,B.jsxs)(O,{dimColor:!0,children:[s,d!==void 0&&d>0&&(0,B.jsxs)(B.Fragment,{children:[` · `,Ie(d),` tokens`]}),p!==void 0&&p>0&&(0,B.jsxs)(B.Fragment,{children:[` `,`· `,p,` `,p===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,B.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,B.jsxs)(k,{children:[r&&(0,B.jsx)(T,{shortcut:`←`,action:`go back`}),(0,B.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,B.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:(0,B.jsxs)(D,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,B.jsxs)(D,{flexDirection:`column`,children:[(0,B.jsx)(O,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,B.jsxs)(O,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,qe(t,o,i)]},n))]}),l?(0,B.jsx)(D,{marginTop:1,children:(0,B.jsx)(ue,{addMargin:!1,planContent:l})}):(0,B.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(O,{bold:!0,dimColor:!0,children:`Prompt`}),(0,B.jsx)(O,{wrap:`wrap`,children:u})]}),e.status===`failed`&&e.error&&(0,B.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(O,{bold:!0,color:`error`,children:`Error`}),(0,B.jsx)(O,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var tt,B,nt=t((()=>{tt=n(A(),1),z(),j(),d(),Be(),se(),I(),xe(),x(),Ye(),$e(),B=N()}));function rt(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 it({text:e,phase:t=0}){return(0,V.jsx)(V.Fragment,{children:[...e].map((e,n)=>(0,V.jsx)(O,{color:S(n+t),children:e},n))})}function at(e,t,n){let r=(0,ct.useRef)(e),i=(0,ct.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 ot({session:e}){let t=oe().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=Ee(r&&!t?lt:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,l=at(a,i,c),u=at(o,i,c),d=at(s,i,c),f=Math.floor(i/(lt*3))%7;if(e.status===`completed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsx)(O,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsxs)(O,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let p=n?rt(n.stage,l,u,d):`setting up`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◇`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:r?f:0}),(0,V.jsxs)(O,{dimColor:!0,children:[` · `,p]})]})}function st({session:e}){if(e.isRemoteReview)return(0,V.jsx)(ot,{session:e});if(e.status===`completed`)return(0,V.jsx)(O,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,V.jsx)(O,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,V.jsxs)(O,{dimColor:!0,children:[e.status,`…`]});let t=P(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,V.jsxs)(O,{dimColor:!0,children:[t,`/`,n]})}var ct,V,lt,ut=t((()=>{ct=n(A(),1),Ne(),o(),j(),Me(),be(),V=N(),lt=80}));function H({status:e,label:t,suffix:n}){return(0,U.jsxs)(O,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function dt({shell:e}){switch(e.status){case`completed`:return(0,U.jsx)(H,{status:`completed`,label:`done`});case`failed`:return(0,U.jsx)(H,{status:`failed`,label:`error`});case`killed`:return(0,U.jsx)(H,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,U.jsx)(H,{status:`running`})}}var U,ft=t((()=>{j(),U=N()}));function pt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,W.jsxs)(O,{children:[F(e.command,n,!0),` `,(0,W.jsx)(dt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,W.jsx)(O,{children:(0,W.jsx)(st,{session:e})}):(0,W.jsxs)(O,{children:[(0,W.jsxs)(O,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),F(e.title,n,!0),(0,W.jsx)(O,{dimColor:!0,children:` · `}),(0,W.jsx)(st,{session:e})]});case`local_agent`:return(0,W.jsxs)(O,{children:[F(e.description,n,!0),` `,(0,W.jsx)(H,{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,W.jsxs)(O,{children:[F(t.workflowName??e.summary??e.description,n,!0),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`running`?`${t.agentCount} ${L(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} ${L(t,`file`)}`:`${e.sessionsReviewing} ${L(e.sessionsReviewing,`session`)}`;return(0,W.jsxs)(O,{children:[e.description,` `,(0,W.jsxs)(O,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var W,mt=t((()=>{A(),j(),I(),ze(),Ne(),ut(),ft(),W=N()}));function ht({task:e,onDone:t,onBack:n,onKill:r}){let i=R(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,G.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,G.jsx)(M,{title:`Memory consolidation`,subtitle:(0,G.jsxs)(O,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,L(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,G.jsxs)(G.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,L(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,G.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,G.jsxs)(k,{children:[n&&(0,G.jsx)(T,{shortcut:`←`,action:`go back`}),(0,G.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,G.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:(0,G.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,G.jsxs)(O,{children:[(0,G.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,G.jsx)(O,{color:`background`,children:`running`}):e.status===`completed`?(0,G.jsx)(O,{color:`success`,children:e.status}):(0,G.jsx)(O,{color:`error`,children:e.status})]}),s.length===0?(0,G.jsx)(O,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,G.jsxs)(G.Fragment,{children:[c>0&&(0,G.jsxs)(O,{dimColor:!0,children:[`(`,c,` earlier `,L(c,`turn`),`)`]}),s.map((e,t)=>(0,G.jsxs)(D,{flexDirection:`column`,children:[(0,G.jsx)(O,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,G.jsxs)(O,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,L(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var G,gt=t((()=>{A(),z(),j(),d(),ze(),G=N()}));function _t({stage:e,completed:t,hasProgress:n}){let r=e?xt.indexOf(e):-1,i=!t&&!n;return(0,q.jsxs)(O,{children:[i?(0,q.jsx)(O,{color:`background`,children:`Setup`}):(0,q.jsx)(O,{dimColor:!0,children:`Setup`}),(0,q.jsx)(O,{dimColor:!0,children:` → `}),xt.map((e,n)=>{let a=!t&&!i&&n===r;return(0,q.jsxs)(K.Fragment,{children:[n>0&&(0,q.jsx)(O,{dimColor:!0,children:` → `}),a?(0,q.jsx)(O,{color:`background`,children:St[e]}):(0,q.jsx)(O,{dimColor:!0,children:St[e]})]},e)}),t&&(0,q.jsx)(O,{color:`success`,children:` ✓`})]})}function vt(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} ${L(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return rt(t.stage,t.bugsFound,n,r)}function yt({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,a=e.status===`running`||e.status===`pending`,[o,s]=(0,K.useState)(!1),c=R(e.startTime,a,1e3,0,e.endTime),l=()=>t(`Remote session details dismissed`,{display:`system`}),u=n??l,d=w(e.sessionId),f=i?`ready`:a?`running`:e.status;if(o)return(0,q.jsx)(M,{title:`Stop ultrareview?`,onCancel:()=>s(!1),color:`background`,children:(0,q.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,q.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,q.jsx)(v,{options:[{label:`Stop ultrareview`,value:`stop`},{label:`Back`,value:`back`}],onChange:e=>{e===`stop`?(r?.(),u()):s(!1)}})]})});let p=i?[{label:`Open in Claude Code on the web`,value:`open`},{label:`Dismiss`,value:`dismiss`}]:[{label:`Open in Claude Code on the web`,value:`open`},...r&&a?[{label:`Stop ultrareview`,value:`stop`}]:[],{label:`Back`,value:`back`}];return(0,q.jsx)(M,{title:(0,q.jsxs)(O,{children:[(0,q.jsxs)(O,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,q.jsx)(O,{bold:!0,children:`ultrareview`}),(0,q.jsxs)(O,{dimColor:!0,children:[` · `,c,` · `,f]})]}),onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(k,{children:[(0,q.jsx)(T,{shortcut:`Enter`,action:`select`}),(0,q.jsx)(T,{shortcut:`Esc`,action:`go back`})]}),children:(0,q.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(_t,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,q.jsxs)(D,{flexDirection:`column`,children:[(0,q.jsx)(O,{children:vt(e)}),(0,q.jsx)(Te,{url:d,children:(0,q.jsx)(O,{dimColor:!0,children:d})})]}),(0,q.jsx)(v,{options:p,onChange:e=>{switch(e){case`open`:b(d),t();break;case`stop`:s(!0);break;case`back`:u();break;case`dismiss`:l();break}}})]})})}function bt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null),l=(0,K.useMemo)(()=>e.isRemoteReview?[]:me(We(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,q.jsx)(yt,{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 ie(e.sessionId)}catch(e){c(Oe(e))}finally{o(!1)}}let p=Fe(e.title,50),m=e.status===`pending`?`starting`:e.status;return(0,q.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:(0,q.jsxs)(M,{title:`Remote session details`,onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(k,{children:[r&&(0,q.jsx)(T,{shortcut:`←`,action:`go back`}),(0,q.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,q.jsx)(T,{shortcut:`t`,action:`teleport`})]}),children:[(0,q.jsxs)(D,{flexDirection:`column`,children:[(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Status`}),`:`,` `,m===`running`||m===`starting`?(0,q.jsx)(O,{color:`background`,children:m}):m===`completed`?(0,q.jsx)(O,{color:`success`,children:m}):(0,q.jsx)(O,{color:`error`,children:m})]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Runtime`}),`: `,Le((e.endTime??Date.now())-e.startTime)]}),(0,q.jsxs)(O,{wrap:`truncate-end`,children:[(0,q.jsx)(O,{bold:!0,children:`Title`}),`: `,p]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Progress`}),`: `,(0,q.jsx)(st,{session:e})]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Session URL`}),`:`,` `,(0,q.jsx)(Te,{url:w(e.sessionId),children:(0,q.jsx)(O,{dimColor:!0,children:w(e.sessionId)})})]})]}),e.log.length>0&&(0,q.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Recent messages`}),`:`]}),(0,q.jsx)(D,{flexDirection:`column`,height:10,overflowY:`hidden`,children:l.map((e,n)=>(0,q.jsx)(g,{message:e,lookups:de,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,q.jsx)(D,{marginTop:1,children:(0,q.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing last `,l.length,` of `,e.log.length,` messages`]})})]}),s&&(0,q.jsx)(D,{marginTop:1,children:(0,q.jsxs)(O,{color:`error`,children:[`Teleport failed: `,s]})}),a&&(0,q.jsx)(O,{color:`background`,children:`Teleporting to session…`})]})})}var K,q,xt,St,Ct=t((()=>{K=n(A(),1),Ne(),z(),j(),_e(),Ve(),le(),ke(),I(),Ge(),xe(),ze(),ve(),y(),p(),ut(),q=N(),xt=[`finding`,`verifying`,`synthesizing`],St={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function wt(e){let t=_(e.id);try{let e=await Ae(t,Dt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function Tt({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=De(),[a,o]=(0,J.useState)(()=>wt(e)),s=(0,J.useDeferredValue)(a);(0,J.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(wt(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=Fe(e.command,280);return(0,Y.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,Y.jsxs)(M,{title:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,Y.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,Y.jsxs)(k,{children:[r&&(0,Y.jsx)(T,{shortcut:`←`,action:`go back`}),(0,Y.jsx)(T,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,Y.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:[(0,Y.jsxs)(D,{flexDirection:`column`,children:[(0,Y.jsxs)(O,{children:[(0,Y.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,Y.jsxs)(O,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,Y.jsxs)(O,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,Y.jsxs)(O,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,Y.jsxs)(O,{children:[(0,Y.jsx)(O,{bold:!0,children:`Runtime:`}),` `,Le((e.endTime??Date.now())-e.startTime)]}),(0,Y.jsxs)(O,{wrap:`wrap`,children:[(0,Y.jsx)(O,{bold:!0,children:`Command:`}),` `,u]})]}),(0,Y.jsxs)(D,{flexDirection:`column`,children:[(0,Y.jsx)(O,{bold:!0,children:`Output:`}),(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(O,{dimColor:!0,children:`Loading output…`}),children:(0,Y.jsx)(Et,{outputPromise:s,columns:i})})]})]})})}function Et({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,J.use)(e);if(!n)return(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,Y.jsx)(O,{wrap:`truncate-end`,children:e},t))}),(0,Y.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Re(r)}`:``]})]})}var J,Y,Dt,Ot=t((()=>{J=n(A(),1),h(),j(),d(),I(),je(),c(),Y=N(),Dt=8192}));function kt(e,t){return Object.values(e??{}).filter(l).filter(e=>!(e.type===`local_agent`&&e.id===t))}function At({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=ge(e=>e.tasks),i=ge(e=>e.foregroundedTaskId),a=re(),o=te(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),s=r,c=(0,Z.useRef)(!1),[u,d]=(0,Z.useState)(()=>{if(n)return c.current=!0,{mode:`detail`,itemId:n};let e=kt(s,i);return e.length===1?(c.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[f,p]=(0,Z.useState)(0);he(`background-tasks-dialog`);let{bashTasks:m,remoteSessions:h,agentTasks:g,workflowTasks:_,dreamTasks:v,allSelectableItems:y}=(0,Z.useMemo)(()=>{let e=Object.values(s??{}).filter(l).map(jt).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]),b=y[f]??null;E({"confirm:previous":()=>p(e=>Math.max(0,e-1)),"confirm:next":()=>p(e=>Math.min(y.length-1,e+1)),"confirm:yes":()=>{let e=y[f];e&&d({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:u.mode===`list`});let ie=t=>{if(u.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=y[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`&&$?$(n.id,a):n.type===`dream`&&n.status===`running`?se(n.id):n.type===`remote_agent`&&n.status===`running`&&ce(n.id))};async function ae(e){await ee.kill(e,a)}async function oe(e){await ne.kill(e,a)}async function se(e){await pe.kill(e,a)}async function ce(e){await ye.kill(e,a)}let le=(0,Z.useEffectEvent)(e);(0,Z.useEffect)(()=>{if(u.mode!==`list`){let e=(s??{})[u.itemId];(!e||e.type!==`local_workflow`&&!l(e))&&(c.current?le(`Background tasks dialog dismissed`,{display:`system`}):d({mode:`list`}))}let e=y.length;f>=e&&e>0&&p(e-1)},[u,s,f,y,le]);let x=()=>{c.current&&y.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(c.current=!1,d({mode:`list`}))};if(u.mode!==`list`&&s){let n=s[u.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,Q.jsx)(Tt,{shell:n,onDone:e,onKillShell:()=>void ae(n.id),onBack:x},`shell-${n.id}`);case`local_agent`:return(0,Q.jsx)(et,{agent:n,onDone:e,onKillAgent:()=>void oe(n.id),onBack:x},`agent-${n.id}`);case`remote_agent`:return(0,Q.jsx)(bt,{session:n,onDone:e,toolUseContext:t,onBack:x,onKill:n.status===`running`?()=>void ce(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`&&$?()=>$(n.id,a):void 0;return(0,Q.jsx)(D,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),x()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,Q.jsx)(M,{title:n.workflowName,subtitle:(0,Q.jsxs)(O,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:x,inputGuide:()=>(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{shortcut:`←`,action:`go back`}),(0,Q.jsx)(T,{shortcut:`Esc`,action:`close`}),e&&(0,Q.jsx)(T,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,Q.jsxs)(O,{color:`error`,children:[`失败原因:`,n.error]}):null})},`workflow-${n.id}`)}case`dream`:return(0,Q.jsx)(ht,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:x,onKill:n.status===`running`?()=>void se(n.id):void 0},`dream-${n.id}`)}}let S=P(m,e=>e.status===`running`),C=P(h,e=>e.status===`running`||e.status===`pending`)+P(g,e=>e.status===`running`),ue=Pe([...S>0?[(0,Q.jsxs)(O,{children:[S,` `,S===1?`active shell`:`active shells`]},`shells`)]:[],...C>0?[(0,Q.jsxs)(O,{children:[C,` `,C===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,Q.jsx)(O,{children:` · `},`separator-${e}`)),de=[(0,Q.jsx)(T,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,Q.jsx)(T,{shortcut:`Enter`,action:`view`},`enter`),...(b?.type===`local_bash`||b?.type===`local_agent`||b?.type===`local_workflow`||b?.type===`dream`||b?.type===`remote_agent`)&&b.status===`running`?[(0,Q.jsx)(T,{shortcut:`x`,action:`stop`},`kill`)]:[],...g.some(e=>e.status===`running`)?[(0,Q.jsx)(T,{shortcut:o,action:`stop all agents`},`kill-all`)]:[],(0,Q.jsx)(T,{shortcut:`←/Esc`,action:`close`},`esc`)],fe=()=>e(`Background tasks dialog dismissed`,{display:`system`});function w(e){return e.pending?(0,Q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsx)(k,{children:de})}return(0,Q.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:(0,Q.jsx)(M,{title:`Background tasks`,subtitle:(0,Q.jsx)(Q.Fragment,{children:ue}),onCancel:fe,color:`background`,inputGuide:w,children:y.length===0?(0,Q.jsx)(O,{dimColor:!0,children:`No tasks currently running`}):(0,Q.jsxs)(D,{flexDirection:`column`,children:[m.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,children:[(h.length>0||g.length>0)&&(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Shells`]}),` (`,m.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:m.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),h.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Remote agents`]}),` (`,h.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:h.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),g.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Local agents`]}),` (`,g.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:g.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),_.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0||g.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Workflows`]}),` (`,_.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:_.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),v.length>0&&(0,Q.jsx)(D,{flexDirection:`column`,marginTop:+(m.length>0||h.length>0||g.length>0||_.length>0),children:(0,Q.jsx)(D,{flexDirection:`column`,children:v.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})})]})})})}function jt(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 X({item:e,isSelected:t}){let{columns:n}=De(),r=Math.max(30,n-26);return(0,Q.jsxs)(D,{flexDirection:`row`,children:[(0,Q.jsx)(O,{children:t?i.pointer+` `:` `}),(0,Q.jsx)(O,{color:t?`suggestion`:void 0,children:(0,Q.jsx)(pt,{task:e.task,maxActivityWidth:r})})]})}var Z,Q,$,Mt=t((()=>{r(),Z=n(A(),1),h(),fe(),C(),Ce(),m(),_e(),Se(),Me(),ae(),j(),d(),u(),nt(),mt(),gt(),Ct(),Ot(),Q=N(),$=(ce(),e(s))?.killWorkflowTask??null}));export{z as a,Qe as i,Mt as n,R as o,$e as r,At as t};
@@ -1,6 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Bh as i,DC as a,EC as o,MC as s,OC as c,ed as l,rd as u,zh as d}from"./loadAgentsDir-mcRW90aq.js";import{C as f,Gt as ee,I as p,P as m,T as h,fi as g,ot as _,t as v,y as te}from"./src-P_wYS_NJ2.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{n as b,t as x}from"./cwd-Besi3Os3.js";import{jn as S,wn as C}from"./settings-DiBMs2gM.js";import{l as w,m as T,p as E,s as D}from"./git-CoQQ6YEf.js";import{r as O,t as k}from"./execFileNoThrow-mXq4K0rl.js";import{S as ne,v as re}from"./startupProfiler-Dc5r6LgE.js";import{l as A,o as j}from"./stringUtils-Df-Lnjxd.js";import{i as ie}from"./detectRepository-CMEkS5_2.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
- `).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
- `),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
- `).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||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:i,isUntracked:a}){let{columns:o}=_(),{firstLine:s,fileContent:c}=(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)(d,{patch:t,filePath:e,firstLine:s,fileContent:c,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),s(),v(),b(),C(),i(),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),s(),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`),[o,s]=(0,Q.useState)(0),[l,d]=(0,Q.useState)(0),f=(0,Q.useMemo)(()=>[{type:`current`},...r.map(e=>({type:`turn`,turn:e}))],[r]),g=f[l],_=g?.type===`turn`?g.turn:null,v=(0,Q.useMemo)(()=>_?we(_):n,[_,n]),y=v.files[o],b=(0,Q.useMemo)(()=>y&&v.hunks.get(y.path)||[],[y,v.hunks]);(0,Q.useEffect)(()=>{l>=f.length&&d(Math.max(0,f.length-1))},[f.length,l]);let x=(0,Q.useRef)(l);(0,Q.useEffect)(()=>{x.current!==l&&(s(0),x.current=l)},[l]),u(`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`&&s(e=>Math.max(0,e-1))},"diff:nextFile":()=>{i===`list`&&s(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:[l>0&&(0,$.jsx)(m,{dimColor:!0,children:`◀ `}),f.map((e,t)=>{let n=t===l,r=e.type===`current`?`Current`:`T${e.turn.turnIndex}`;return(0,$.jsxs)(m,{dimColor:!n,bold:n,children:[t>0?` · `:``,r]},t)}),l<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:o})}):(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(),o(),a(),j(),ye(),Ce(),$=y()}))();export{Te as DiffDialog};
@@ -1,3 +0,0 @@
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{$w as o,EC as s,JT as c,J_ as l,Jl as u,KT as d,Kl as f,YT as p,Y_ as m,Zy as h,aw as ee,cw as te,eT as g,ea as _,eb as v,gT as y,iw as ne,ng as b,ow as x,qT as S,ql as re,rb as C,rg as w,sw as ie,ta as T,tb as ae,yT as E}from"./loadAgentsDir-mcRW90aq.js";import{Gt as D,I as O,P as k,fi as A,t as j,x as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as oe,et as se}from"./state-BPFYBqm1.js";import{H as ce,g as le,kn as P,n as F,wn as I,z as L}from"./settings-DiBMs2gM.js";import{l as R,o as z}from"./stringUtils-Df-Lnjxd.js";import{Kn as B,Un as V,_ as H,u as U}from"./model-C29_32BD.js";import{n as W,t as ue}from"./ValidationErrorsList-DSSUWdgd.js";import{d as de,f as fe,h as pe,i as me,m as he,n as ge,o as _e,r as ve,u as G}from"./pidLock-DQGDoFQP.js";import{a as ye,i as be}from"./xdg-DcF9ejUM.js";import{n as xe,t as Se}from"./useExitOnCtrlCDWithKeybindings-CPLBDluY.js";import{n as Ce,t as we}from"./McpParsingWarnings-CUx2zexI.js";import{n as Te,t as Ee}from"./PressEnterToContinue-Dq0Imo9c.js";import{n as De,t as Oe}from"./useSettingsErrors-BRgjvaHd.js";import{n as ke,t as Ae}from"./shadowedRuleDetection-D5X5fhzj.js";import{n as je,r as Me,t as K}from"./statusNoticeHelpers-Sl4jjauz.js";import{join as q}from"path";function Ne(){if(!p())return null;let e=d();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)(O,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(k,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(O,{children:[(0,J.jsx)(k,{dimColor:!0,children:`Location: `}),(0,J.jsx)(k,{dimColor:!0,children:S()})]}),(0,J.jsxs)(O,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(O,{flexDirection:`column`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(k,{dimColor:!0,children:`└ `}),(0,J.jsx)(k,{color:`error`,children:`[Error]`}),(0,J.jsxs)(k,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(O,{marginLeft:3,children:(0,J.jsxs)(k,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(O,{flexDirection:`column`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(k,{dimColor:!0,children:`└ `}),(0,J.jsx)(k,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(k,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(O,{marginLeft:3,children:(0,J.jsxs)(k,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,Pe=e((()=>{A(),j(),c(),J=N()}));function Fe(){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)(O,{flexDirection:`column`,children:[(0,Y.jsx)(k,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(k,{children:[`└ Status: `,(0,Y.jsx)(k,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(k,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(k,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(k,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,Ie=e((()=>{A(),j(),E(),Y=N()}));async function Le(){let e=v(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 > ${h.toLocaleString()})`:`${e.length} large AGENTS.md files detected (each > ${h.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:h}}async function X(e){if(!e)return null;let t=je(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:T(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 Re(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await l(e,t,n,U());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+T(((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 ze(e){let t=Ae(await e(),{sandboxAutoAllowEnabled:y.isSandboxingEnabled()&&y.isAutoAllowBashIfSandboxedEnabled()});if(t.length===0)return null;let n=t.flatMap(e=>[`${ce(e.rule.ruleValue)}: ${e.reason}`,` Fix: ${e.fix}`]);return{type:`unreachable_rules`,severity:`warning`,message:`${t.length} ${R(t.length,`unreachable permission rule`)} detected`,details:n,currentValue:t.length,threshold:0}}async function Be(e,t,n){let[r,i,a,o]=await Promise.all([Le(),X(t),Re(e,n,t),ze(n)]);return{agentsMdWarning:r,agentWarning:i,mcpWarning:a,unreachableRulesWarning:o}}var Z,Ve=e((()=>{_(),m(),C(),H(),L(),ke(),E(),Me(),z(),Z=25e3}));function He({promise:e}){let t=(0,Q.use)(e);return t.latest?(0,$.jsxs)($.Fragment,{children:[t.stable&&(0,$.jsxs)(k,{children:[`└ Stable version: `,t.stable]}),(0,$.jsxs)(k,{children:[`└ Latest version: `,t.latest]})]}):(0,$.jsx)(k,{dimColor:!0,children:`└ Failed to fetch versions`})}function Ue({onDone:e}){let t=w(e=>e.agentDefinitions),r=w(e=>e.mcp.tools),i=w(e=>e.toolPermissionContext),s=w(e=>e.plugins.errors);xe();let c=(0,Q.useMemo)(()=>r||[],[r]),[l,u]=(0,Q.useState)(null),[d,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=De(),y=(0,Q.useMemo)(()=>G().then(e=>(e.installationType===`native`?fe:he)().catch(()=>({latest:null,stable:null}))),[]),b=F()?.autoUpdatesChannel??`latest`,x=v.filter(e=>e.mcpErrorMetadata===void 0),S=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:ne,upperLimit:ee},{name:`TASK_MAX_OUTPUT_LENGTH`,default:f,upperLimit:re},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...V(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=te(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{G().then(u),(async()=>{let e=q(n(),`agents`),r=q(se(),`.workmate`,`agents`),{activeAgents:a,allAgents:o,failedFiles:s}=t,[l,u]=await Promise.all([P(e),P(r)]),d={activeAgents:a.map(e=>({agentType:e.agentType,source:e.source})),userAgentsDir:e,projectAgentsDir:r,userDirExists:l,projectDirExists:u,failedFiles:s};p(d);let f=await Be(c,{activeAgents:a,allAgents:o,failedFiles:s},async()=>i);if(h(f),_e()){let e=q(be(),`claude`,`locks`),t=ge(e),n=ve(e);_({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else _({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,c,t]);let C=(0,Q.useCallback)(()=>{e(`Claude Code diagnostics dismissed`,{display:`system`})},[e]);return D({"confirm:yes":C,"confirm:no":C},{context:`Confirmation`}),l?(0,$.jsxs)(M,{children:[(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(k,{children:[`└ Currently running: `,l.installationType,` (`,l.version,`)`]}),l.packageManager&&(0,$.jsxs)(k,{children:[`└ Package manager: `,l.packageManager]}),(0,$.jsxs)(k,{children:[`└ Path: `,l.installationPath]}),(0,$.jsxs)(k,{children:[`└ Invoked: `,l.invokedBinary]}),(0,$.jsxs)(k,{children:[`└ Config install method: `,l.configInstallMethod]}),(0,$.jsxs)(k,{children:[`└ Search: `,l.ripgrepStatus.working?`OK`:`Not working`,` (`,l.ripgrepStatus.mode===`embedded`?`bundled`:l.ripgrepStatus.mode===`builtin`?`vendor`:l.ripgrepStatus.systemPath||`system`,`)`]}),l.ripgrepStatus.note&&(0,$.jsxs)(k,{color:`warning`,children:[`└ Note: `,l.ripgrepStatus.note]}),l.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{}),(0,$.jsxs)(k,{color:`warning`,children:[`Recommendation: `,l.recommendation.split(`
2
- `)[0]]}),(0,$.jsx)(k,{dimColor:!0,children:l.recommendation.split(`
3
- `)[1]})]}),l.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{}),(0,$.jsx)(k,{color:`warning`,children:`Warning: Multiple installations found`}),l.multipleInstallations.map((e,t)=>(0,$.jsxs)(k,{children:[`└ `,e.type,` at `,e.path]},t))]}),l.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{}),l.warnings.map((e,t)=>(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsxs)(k,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(k,{children:[`Fix: `,e.fix]})]},t))]}),x.length>0&&(0,$.jsxs)(O,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(k,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(ue,{errors:x})]})]}),(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,children:`Updates`}),(0,$.jsxs)(k,{children:[`└ Auto-updates: `,l.packageManager?`Managed by package manager`:l.autoUpdates]}),l.hasUpdatePermissions!==null&&(0,$.jsxs)(k,{children:[`└ Update permissions: `,l.hasUpdatePermissions?`Yes`:`No (requires sudo)`]}),(0,$.jsxs)(k,{children:[`└ Auto-update channel: `,b]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(He,{promise:y})})]}),(0,$.jsx)(Fe,{}),(0,$.jsx)(we,{}),(0,$.jsx)(Ne,{}),S.length>0&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,children:`Environment Variables`}),S.map((e,t)=>(0,$.jsxs)(k,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(k,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),g?.enabled&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,children:`Version Locks`}),g.staleLocksCleaned>0&&(0,$.jsxs)(k,{dimColor:!0,children:[`└ Cleaned `,g.staleLocksCleaned,` stale lock(s)`]}),g.locks.length===0?(0,$.jsx)(k,{dimColor:!0,children:`└ No active version locks`}):g.locks.map((e,t)=>(0,$.jsxs)(k,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(k,{children:`(running)`}):(0,$.jsx)(k,{color:`warning`,children:`(stale)`})]},t))]}),d?.failedFiles&&d.failedFiles.length>0&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(k,{color:`error`,children:[`└ Failed to parse `,d.failedFiles.length,` agent file(s):`]}),d.failedFiles.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),s.length>0&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(k,{color:`error`,children:[`└ `,s.length,` plugin error(s) detected:`]}),s.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,o(e)]},t))]}),m?.unreachableRulesWarning&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(k,{children:[`└`,` `,(0,$.jsxs)(k,{color:`warning`,children:[a.warning,` `,m.unreachableRulesWarning.message]})]}),m.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m&&(m.agentsMdWarning||m.agentWarning||m.mcpWarning)&&(0,$.jsxs)(O,{flexDirection:`column`,children:[(0,$.jsx)(k,{bold:!0,children:`Context Usage Warnings`}),m.agentsMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{children:[`└`,` `,(0,$.jsxs)(k,{color:`warning`,children:[a.warning,` `,m.agentsMdWarning.message]})]}),(0,$.jsxs)(k,{children:[` `,`└ Files:`]}),m.agentsMdWarning.details.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{children:[`└`,` `,(0,$.jsxs)(k,{color:`warning`,children:[a.warning,` `,m.agentWarning.message]})]}),(0,$.jsxs)(k,{children:[` `,`└ Top contributors:`]}),m.agentWarning.details.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{children:[`└`,` `,(0,$.jsxs)(k,{color:`warning`,children:[a.warning,` `,m.mcpWarning.message]})]}),(0,$.jsxs)(k,{children:[` `,`└ MCP servers:`]}),m.mcpWarning.details.map((e,t)=>(0,$.jsxs)(k,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(O,{children:(0,$.jsx)(Ee,{})})]}):(0,$.jsx)(M,{children:(0,$.jsx)(k,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,We=e((()=>{i(),Q=t(A(),1),Pe(),Ce(),B(),r(),oe(),j(),Te(),Ie(),W(),Oe(),Se(),s(),b(),g(),pe(),Ve(),de(),ie(),I(),me(),le(),x(),u(),ye(),$=N()}));export{We as n,Ue as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./Doctor-BC6IuQhd.js";e();export{t as Doctor};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{AT as r,Au as i,Dt as a,Et as o,GC as s,KC as c,Mu as l,Sr as u,Xu as d,Yd as f,Zd as p,Zu as m,fE as h,gi as g,jT as _,mt as v,pE as y,wt as b,xt as x}from"./loadAgentsDir-mcRW90aq.js";import{I as S,P as C,fi as w,t as T,y as E}from"./src-P_wYS_NJ2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{c as O,i as k}from"./debug-Dr1SjdXn.js";import{r as A,t as j}from"./execFileNoThrow-mXq4K0rl.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(u(),e(g)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,r]=(0,I.useState)(`loading`),[s,l]=(0,I.useState)([]),[u,f]=(0,I.useState)(0),[p,m]=(0,I.useState)(),g=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()!==``),l(e)),g){let{stdout:t}=await j(`git`,[`rev-list`,`--count`,`${g.originalHeadCommit}..HEAD`]),n=parseInt(t.trim(),10)||0;if(f(n),e.length===0&&n===0){r(`removing`),v().then(()=>{process.chdir(g.originalCwd),c(g.originalCwd),P(),h.cache.clear?.(),m(`Worktree removed (no changes)`)}).catch(e=>{O(`Failed to clean up worktree: ${e}`,{level:`error`}),m(`Worktree cleanup failed, exiting anyway`)}).then(()=>{r(`done`)});return}else r(`asking`)}}e()},[g]),(0,I.useEffect)(()=>{n===`done`&&e(p)},[n,e,p]),!g)return e(`No active worktree session found`,{display:`system`}),null;if(n===`loading`||n===`done`)return null;async function _(e){if(!g)return;let t=!!g.tmuxSessionName;if(e===`keep`||e===`keep-with-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:u,changed_files:s.length}),await o(),process.chdir(g.originalCwd),c(g.originalCwd),P(),h.cache.clear?.(),m(t?`Worktree kept. Your work is saved at ${g.worktreePath} on branch ${g.worktreeBranch}. Reattach to tmux session with: tmux attach -t ${g.tmuxSessionName}`:`Worktree kept. Your work is saved at ${g.worktreePath} on branch ${g.worktreeBranch}`),r(`done`);else if(e===`keep-kill-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:u,changed_files:s.length}),g.tmuxSessionName&&await a(g.tmuxSessionName),await o(),process.chdir(g.originalCwd),c(g.originalCwd),P(),h.cache.clear?.(),m(`Worktree kept at ${g.worktreePath} on branch ${g.worktreeBranch}. Tmux session terminated.`),r(`done`);else if(e===`remove`||e===`remove-with-tmux`){r(`removing`),N(`tengu_worktree_removed`,{commits:u,changed_files:s.length}),g.tmuxSessionName&&await a(g.tmuxSessionName);try{await v(),process.chdir(g.originalCwd),c(g.originalCwd),P(),h.cache.clear?.()}catch(e){O(`Failed to clean up worktree: ${e}`,{level:`error`}),m(`Worktree cleanup failed, exiting anyway`),r(`done`);return}let e=t?` Tmux session terminated.`:``;u>0&&s.length>0?m(`Worktree removed. ${u} ${u===1?`commit`:`commits`} and uncommitted changes were discarded.${e}`):u>0?m(`Worktree removed. ${u} ${u===1?`commit`:`commits`} on ${g.worktreeBranch} ${u===1?`was`:`were`} discarded.${e}`):s.length>0?m(`Worktree removed. Uncommitted changes were discarded.${e}`):m(`Worktree removed.${e}`),r(`done`)}}if(n===`keeping`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(i,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(i,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let y=g.worktreeBranch,b=s.length>0,w=u>0,T=``;T=b&&w?`You have ${s.length} uncommitted ${s.length===1?`file`:`files`} and ${u} ${u===1?`commit`:`commits`} on ${y}. All will be lost if you remove.`:b?`You have ${s.length} uncommitted ${s.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${u} ${u===1?`commit`:`commits`} on ${y}. 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}_(`keep`)}let k=b||w?`All changes and commits will be lost.`:`Clean up the worktree directory.`,A=!!g.tmuxSessionName,M=A?[{label:`Keep worktree and tmux session`,value:`keep-with-tmux`,description:`Stays at ${g.worktreePath}. Reattach with: tmux attach -t ${g.tmuxSessionName}`},{label:`Keep worktree, kill tmux session`,value:`keep-kill-tmux`,description:`Keeps worktree at ${g.worktreePath}, terminates tmux session.`},{label:`Remove worktree and tmux session`,value:`remove-with-tmux`,description:k}]:[{label:`Keep worktree`,value:`keep`,description:`Stays at ${g.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)(d,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:_})})}var I,L,R=t((()=>{I=n(w(),1),M(),k(),T(),A(),y(),s(),b(),m(),l(),L=D()}));function z(){return _(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await f(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{r(),w(),p(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{Du as e,Eu as t,Xu as n,Yu as r,ng as i,tg as a}from"./loadAgentsDir-mcRW90aq.js";import{I as o,P as s,fi as c,kn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{C as p,T as m,x as h}from"./debug-Dr1SjdXn.js";import{t as g}from"./renderOptions-45A-EdsK.js";c(),u(),e(),i(),h(),r();var _=f();function v({filePath:e,errorDescription:t,onExit:r,onReset:i}){return(0,_.jsxs)(d,{title:`Configuration Error`,color:`error`,onCancel:r,children:[(0,_.jsxs)(o,{flexDirection:`column`,gap:1,children:[(0,_.jsxs)(s,{children:[`The configuration file at `,(0,_.jsx)(s,{bold:!0,children:e}),` contains invalid JSON.`]}),(0,_.jsx)(s,{children:t})]}),(0,_.jsxs)(o,{flexDirection:`column`,children:[(0,_.jsx)(s,{bold:!0,children:`Choose an option:`}),(0,_.jsx)(n,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Reset with default configuration`,value:`reset`}],onChange:e=>{e===`exit`?r():i()},onCancel:r})]})]})}var y=`dark`;async function b({error:e}){let n={...g(!1),theme:y};await new Promise(async r=>{let{unmount:i}=await l((0,_.jsx)(a,{children:(0,_.jsx)(t,{children:(0,_.jsx)(v,{filePath:e.filePath,errorDescription:e.message,onExit:()=>{i(),r(),process.exit(1)},onReset:()=>{m(e.filePath,p(e.defaultConfig,null,2),{flush:!1,encoding:`utf8`}),i(),r(),process.exit(0)}})})}),n)})}export{b as showInvalidConfigDialog};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{Xu as e,Yu as t}from"./loadAgentsDir-mcRW90aq.js";import{P as n,fi as r,t as i,y as a}from"./src-P_wYS_NJ2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{n as s,t as c}from"./ValidationErrorsList-DSSUWdgd.js";r(),i(),t(),s();var l=o();function u({settingsErrors:t,onContinue:r,onExit:i}){function o(e){e===`exit`?i():r()}return(0,l.jsxs)(a,{title:`Settings Error`,onCancel:i,color:`warning`,children:[(0,l.jsx)(c,{errors:t}),(0,l.jsx)(n,{dimColor:!0,children:`Files with errors are skipped entirely, not just the invalid settings.`}),(0,l.jsx)(e,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Continue without these settings`,value:`continue`}],onChange:o})]})}export{u as InvalidSettingsDialog};
@@ -1 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{$S as r,$x as i,Bx as a,Dx as o,Fb as s,Hb as c,Jd as l,Jx as u,Kb as d,Kx as f,Lb as p,MT as m,NT as h,Px as g,QS as _,Qx as v,Rb as y,Vb as b,Vx as ee,Wb as x,ag as te,eS as ne,ig as re,nC as S,nS as C,ng as w,qb as ie,qd as T,qx as E,rC as D,rg as O,xx as k,zb as A,zx as j}from"./loadAgentsDir-mcRW90aq.js";import{fi as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as ae,pt as oe}from"./state-BPFYBqm1.js";import{P,R as se,c as ce,i as le}from"./debug-Dr1SjdXn.js";import{it as F,nt as I}from"./settings-DiBMs2gM.js";import{c as L,l as R,o as z}from"./log-27kCA_9u.js";import{n as B,r as V}from"./analytics-DJobLaWP.js";import{n as H,t as U}from"./omit-KEhe84f4.js";import{o as ue,s as de}from"./localSearch-CCCDKpYx.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 fe(e,t=!1){let n=re(),c=O(e=>e.authVersion),d=O(e=>e.mcp.pluginReconnectKey),m=te(),g=(0,K.useRef)(new Map),{addNotification:C}=l(),w=(0,K.useRef)([]),T=(0,K.useRef)(null),E=(0,K.useCallback)(()=>{T.current=null;let e=w.current;e.length!==0&&(w.current=[],m(t=>{let n=t.mcp;for(let t of e){let{tools:e,commands:r,resources:i,...a}=t,o=a.type===`disabled`||a.type===`failed`?e??[]:e,s=a.type===`disabled`||a.type===`failed`?r??[]:r,c=a.type===`disabled`||a.type===`failed`?i??[]:i,l=I(a.name),u=n.clients.findIndex(e=>e.name===a.name)===-1?[...n.clients,a]:n.clients.map(e=>e.name===a.name?a:e),d=o===void 0?n.tools:[...h(n.tools,e=>e.name?.startsWith(l)),...o],f=s===void 0?n.commands:[...h(n.commands,e=>k(e,a.name)),...s],p=c===void 0?n.resources:{...n.resources,...c.length>0?{[a.name]:c}:H(n.resources,a.name)};n={...n,clients:u,tools:d,commands:f,resources:p}}return{...t,mcp:n}}))},[m]),D=(0,K.useCallback)(e=>{w.current.push(e),T.current===null&&(T.current=setTimeout(E,16))},[E]),M=(0,K.useCallback)(({client:e,tools:t,commands:n,resources:i})=>{switch(D({...e,tools:t,commands:n,resources:i}),e.type){case`connected`:ie(e.client,e.name,m),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(s(e.name,e.config).catch(()=>{ce(`Failed to invalidate the server cache: ${e.name}`)}),u(e.name)){L(e.name,`Server is disabled, skipping automatic reconnection`);return}if(t!==`stdio`&&t!==`sdk`){let n=pe(t);L(e.name,`${n} transport closed/disconnected, attempting automatic reconnection`);let r=g.current.get(e.name);r&&(clearTimeout(r),g.current.delete(e.name)),(async()=>{for(let t=1;t<=J;t++){if(u(e.name)){L(e.name,`Server disabled during reconnection, stopping retry`),g.current.delete(e.name);return}D({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:J});let r=Date.now();try{let i=await x(e.name,e.config),a=Date.now()-r;if(i.client.type===`connected`){L(e.name,`${n} reconnection successful after ${a}ms (attempt ${t})`),g.current.delete(e.name),M(i);return}if(L(e.name,`${n} reconnection attempt ${t} completed with status: ${i.client.type}`),t===J){L(e.name,`Max reconnection attempts (${J}) reached, giving up`),g.current.delete(e.name),M(i);return}}catch(i){let a=Date.now()-r;if(R(e.name,`${n} reconnection attempt ${t} failed after ${a}ms: ${i}`),t===J){L(e.name,`Max reconnection attempts (${J}) reached, giving up`),g.current.delete(e.name),D({...e,type:`failed`});return}}let i=Math.min(Y*2**(t-1),X);L(e.name,`Scheduling reconnection attempt ${t+1} in ${i}ms`),await new Promise(t=>{let n=setTimeout(t,i);g.current.set(e.name,n)})}})()}else D({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(S,async()=>{L(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=A.cache.get(e.name);A.cache.delete(e.name);let n=await A(e),r=n.length;t?t.then(e=>{V(`tengu_mcp_list_changed`,{type:`tools`,previousCount:e.length,newCount:r})},()=>{V(`tengu_mcp_list_changed`,{type:`tools`,newCount:r})}):V(`tengu_mcp_list_changed`,{type:`tools`,newCount:r}),D({...e,tools:n})}catch(t){R(e.name,`Failed to refresh tools after list_changed notification: ${P(t)}`)}}),e.capabilities?.prompts?.listChanged&&e.client.setNotificationHandler(_,async()=>{L(e.name,`Received prompts/list_changed notification, refreshing prompts`),V(`tengu_mcp_list_changed`,{type:`prompts`});try{p.cache.delete(e.name);let[t,n]=await Promise.all([p(e),Promise.resolve([])]);D({...e,commands:[...t,...n]}),q?.()}catch(t){R(e.name,`Failed to refresh prompts after list_changed notification: ${P(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(r,async()=>{L(e.name,`Received resources/list_changed notification, refreshing resources`),V(`tengu_mcp_list_changed`,{type:`resources`});try{y.cache.delete(e.name);{let t=await y(e);D({...e,resources:t})}}catch(t){R(e.name,`Failed to refresh resources after list_changed notification: ${P(t)}`)}});break;case`needs-auth`:case`failed`:case`pending`:case`disabled`:break}},[D]),N=oe();return(0,K.useEffect)(()=>{async function n(){let{servers:n,errors:r}=t?{servers:{},errors:[]}:await f(e),i={...n,...e};G(m,r),m(e=>{let{stale:t,...n}=o(e.mcp,i);for(let e of t){let t=g.current.get(e.name);t&&(clearTimeout(t),g.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,s(e.name,e.config).catch(()=>{}))}let r=new Set(n.clients.map(e=>e.name)),a=Object.entries(i).filter(([e])=>!r.has(e)).map(([e,t])=>({name:e,type:u(e)?`disabled`:`pending`,config:t}));return a.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...a]}}})}n().catch(e=>{R(`useManageMCPConnections`,`Failed to initialize servers as pending: ${P(e)}`)})},[t,e,m,N,d]),(0,K.useEffect)(()=>{let n=!1;async function r(){let r;t||a()?r=Promise.resolve({}):(i(),r=ne());let{servers:o,errors:s}=t?{servers:{},errors:[]}:await f(e,r);if(n)return;G(m,s);let c={...o,...e},l=Object.fromEntries(Object.entries(c).filter(([e])=>!u(e)));b(M,l).catch(e=>{R(`useManageMcpConnections`,`Failed to get MCP resources: ${P(e)}`)});let d={};if(!t){if(d=ee(await r).allowed,n)return;if(Object.keys(d).length>0){let{servers:e}=j(d,c);d=e}if(Object.keys(d).length>0){m(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(d).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:u(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(d).filter(([e])=>!u(e)));b(M,e).catch(e=>{R(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${P(e)}`)})}}let p={...c,...d},h={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(p))t.scope===`enterprise`?h.enterprise++:t.scope===`user`?h.global++:t.scope===`project`?h.project++:t.scope===`local`?h.user++:t.scope===`dynamic`?h.plugin++:t.scope===`claudeai`&&h.claudeai++;V(`tengu_mcp_servers`,{...h})}return r(),()=>{n=!0}},[t,e,M,m,c,N,d]),(0,K.useEffect)(()=>{let e=g.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),T.current!==null&&(clearTimeout(T.current),T.current=null,E())}},[E]),{reconnectMcpServer:(0,K.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);let r=g.current.get(e);r&&(clearTimeout(r),g.current.delete(e));let i=await x(e,t.config);return M(i),i},[n,M]),toggleMcpServer:(0,K.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);if(t.type!==`disabled`){let n=g.current.get(e);n&&(clearTimeout(n),g.current.delete(e)),v(e,!1),t.type===`connected`&&await s(e,t.config),D({name:e,type:`disabled`,config:t.config})}else{v(e,!0),D({name:e,type:`pending`,config:t.config});let n=await x(e,t.config);M(n)}},[n,D,M])}}function pe(e){switch(e){case`http`:return`HTTP`;case`ws`:case`ws-ide`:return`WebSocket`;default:return`SSE`}}var K,q,J,Y,X,me=t((()=>{K=n(M(),1),ae(),c(),D(),U(),m(),B(),E(),le(),T(),w(),se(),z(),d(),C(),F(),g(),q=(ue(),e(de)).clearSkillIndexCache,J=5,Y=1e3,X=3e4}));function he(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpReconnect must be used within MCPConnectionManager`);return e.reconnectMcpServer}function ge(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpToggleEnabled must be used within MCPConnectionManager`);return e.toggleMcpServer}function _e({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=fe(t,n),a=(0,Z.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,Q.jsx)($.Provider,{value:a,children:e})}var Z,Q,$,ve=t((()=>{Z=n(M(),1),me(),Q=N(),$=(0,Z.createContext)(null)}));export{ge as i,ve as n,he as r,_e as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Ap as i,Au as a,Ax as o,EC as s,Ex as c,Fb as l,Hb as u,MC as d,Mu as f,Ox as ee,Px as p,Sx as te,Tx as ne,Ux as re,Xu as ie,Yu as m,_S as ae,ag as oe,ax as h,cx as g,ex as se,gS as _,jp as v,jx as ce,ng as y,od as le,ox as ue,qx as b,rg as de,sd as fe}from"./loadAgentsDir-mcRW90aq.js";import{D as x,H as pe,I as S,Lt as me,P as C,T as w,Wt as he,dr as ge,fi as T,hn as _e,j as E,ot as ve,t as D,y as O}from"./src-P_wYS_NJ2.js";import{t as k}from"./jsx-runtime-Bb4Xn-E0.js";import{P as ye,R as A}from"./debug-Dr1SjdXn.js";import{et as j,it as M,tt as N}from"./settings-DiBMs2gM.js";import{c as be,o as P}from"./log-27kCA_9u.js";import{n as F,r as I}from"./analytics-DJobLaWP.js";import{l as xe,u as L}from"./oauth-D38aRTUb.js";import{l as Se,n as Ce,o as R}from"./stringUtils-Df-Lnjxd.js";import{Bt as z,jt as we}from"./model-C29_32BD.js";import{i as Te,n as B,r as Ee}from"./MCPConnectionManager-aDDsYkGM.js";import{n as De,t as V}from"./useExitOnCtrlCDWithKeybindings-CPLBDluY.js";function Oe({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,H.jsxs)(S,{children:[(0,H.jsx)(C,{bold:!0,children:`Capabilities: `}),(0,H.jsx)(C,{color:`text`,children:r.length>0?(0,H.jsx)(w,{children:r}):`none`})]})}var H,ke=e((()=>{T(),D(),H=k()}));function Ae(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 je(e,t){return`Error reconnecting to ${t}: ${e instanceof Error?e.message:String(e)}`}var U=e((()=>{}));function Me({server:e,serverToolsCount:t,onViewTools:n,onCancel:s,onComplete:u,borderless:d=!1}){let[f]=pe(),p=De(),{columns:re}=ve(),[m,h]=W.useState(!1),[_,v]=W.useState(null),ce=de(e=>e.mcp),y=oe(),[b,fe]=W.useState(null),[T,D]=(0,W.useState)(!1),O=(0,W.useRef)(null),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(null),[N,P]=(0,W.useState)(!1),[F,L]=(0,W.useState)(null),[Se,R]=(0,W.useState)(!1),[z,B]=(0,W.useState)(!1),V=(0,W.useRef)(void 0),H=(0,W.useRef)(!1),[ke,U]=(0,W.useState)(``),[Me,Ne]=(0,W.useState)(0),[Pe,K]=(0,W.useState)(null);(0,W.useEffect)(()=>()=>{H.current=!0,O.current?.abort(),V.current!==void 0&&clearTimeout(V.current)},[]);let q=e.isAuthenticated||e.client.type===`connected`&&t>0,J=Ee(),Fe=W.useCallback(async()=>{A(!1),M(null),D(!0);try{let t=await J(e.name),n=t.client.type===`connected`;I(`tengu_claudeai_mcp_auth_completed`,{success:n}),n?u?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?u?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):u?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`)}catch(t){I(`tengu_claudeai_mcp_auth_completed`,{success:!1}),u?.(je(t,e.name))}finally{D(!1)}},[J,e.name,u]),Y=W.useCallback(async()=>{await l(e.name,{...e.config,scope:e.scope}),y(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`needs-auth`}:t),r=ee(t.mcp.tools,e.name),i=ne(t.mcp.commands,e.name),a=c(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),I(`tengu_claudeai_mcp_clear_auth_completed`,{}),u?.(`Disconnected from ${e.name}.`),P(!1),L(null),R(!1)},[e.name,e.config,e.scope,y,u]);he(`confirm:no`,()=>{O.current?.abort(),O.current=null,h(!1),fe(null)},{context:`Confirmation`,isActive:m}),he(`confirm:no`,()=>{A(!1),M(null)},{context:`Confirmation`,isActive:k}),he(`confirm:no`,()=>{P(!1),L(null),R(!1)},{context:`Confirmation`,isActive:N}),_e((e,t)=>{if(t.return&&k&&Fe(),t.return&&N)if(Se)Y();else{let e=`${xe().CLAUDE_AI_ORIGIN}/settings/connectors`;L(e),R(!0),ae(e)}if(e===`c`&&!z){let e=b||j||F;e&&ge(e).then(e=>{H.current||(e&&process.stdout.write(e),B(!0),V.current!==void 0&&clearTimeout(V.current),V.current=setTimeout(B,2e3,!1))})}});let X=Ce(String(e.name)),Ie=o(ce.commands,e.name).length,Le=Te(),Z=W.useCallback(async()=>{let t=xe().CLAUDE_AI_ORIGIN,n=we()?.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`,M(r),A(!0),I(`tengu_claudeai_mcp_auth_started`,{}),await ae(r)},[e.config]),Q=W.useCallback(()=>{P(!0),I(`tengu_claudeai_mcp_clear_auth_started`,{})},[]),Re=W.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await Le(e.name),e.config.type===`claudeai-proxy`&&I(`tengu_claudeai_mcp_toggle`,{new_state:t?`disabled`:`enabled`}),s()}catch(n){u?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ye(n)}`)}},[e.client.type,e.config.type,e.name,Le,s,u]),ze=W.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;h(!0),v(null);let t=new AbortController;O.current=t;try{if(e.isAuthenticated&&e.config&&await g(e.name,e.config,{preserveStepUpState:!0}),e.config){await ue(e.name,e.config,fe,t.signal,{onWaitingForCallback:e=>{K(()=>e)}}),I(`tengu_mcp_auth_config_authenticate`,{wasAuthenticated:e.isAuthenticated});let n=await J(e.name);if(n.client.type===`connected`){let t=q?`Authentication successful. Reconnected to ${e.name}.`:`Authentication successful. Connected to ${e.name}.`;u?.(t)}else n.client.type===`needs-auth`?u?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):(be(e.name,`Reconnection failed after authentication`),u?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`))}}catch(e){e instanceof Error&&!(e instanceof se)&&v(e.message)}finally{h(!1),O.current=null,K(null),U(``)}},[e.isAuthenticated,e.config,e.name,u,J,q]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await g(e.name,e.config),I(`tengu_mcp_auth_config_clear`,{}),await l(e.name,{...e.config,scope:e.scope}),y(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`failed`}:t),r=ee(t.mcp.tools,e.name),i=ne(t.mcp.commands,e.name),a=c(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),u?.(`Authentication cleared for ${e.name}.`))};if(m){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,G.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,G.jsxs)(C,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,G.jsxs)(S,{children:[(0,G.jsx)(a,{}),(0,G.jsx)(C,{children:t})]}),b&&(0,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),z?(0,G.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,G.jsx)(C,{dimColor:!0,children:(0,G.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,G.jsx)(me,{url:b})]}),m&&b&&Pe&&(0,G.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,G.jsx)(C,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,G.jsxs)(S,{children:[(0,G.jsxs)(C,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,G.jsx)(le,{value:ke,onChange:U,onSubmit:e=>{Pe(e.trim()),U(``)},cursorOffset:Me,onChangeCursorOffset:Ne,columns:re-8})]})]}),(0,G.jsx)(S,{marginLeft:3,children:(0,G.jsx)(C,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(k)return(0,G.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,G.jsxs)(C,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,G.jsxs)(S,{children:[(0,G.jsx)(a,{}),(0,G.jsx)(C,{children:` A browser window will open for authentication`})]}),j&&(0,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),z?(0,G.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,G.jsx)(C,{dimColor:!0,children:(0,G.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,G.jsx)(me,{url:j})]}),(0,G.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,G.jsxs)(C,{color:`permission`,children:[`Press `,(0,G.jsx)(C,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,G.jsx)(C,{dimColor:!0,italic:!0,children:(0,G.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(N)return(0,G.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,G.jsxs)(C,{color:`claude`,children:[`Clear authentication for `,e.name]}),Se?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{children:`Find the MCP server in the browser and click "Disconnect".`}),F&&(0,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),z?(0,G.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,G.jsx)(C,{dimColor:!0,children:(0,G.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,G.jsx)(me,{url:F})]}),(0,G.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,G.jsxs)(C,{color:`permission`,children:[`Press `,(0,G.jsx)(C,{bold:!0,children:`Enter`}),` when done.`]}),(0,G.jsx)(C,{dimColor:!0,italic:!0,children:(0,G.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,G.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,G.jsxs)(C,{color:`permission`,children:[`Press `,(0,G.jsx)(C,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,G.jsx)(C,{dimColor:!0,italic:!0,children:(0,G.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(T)return(0,G.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,G.jsxs)(C,{color:`text`,children:[`Connecting to `,(0,G.jsx)(C,{bold:!0,children:e.name}),`…`]}),(0,G.jsxs)(S,{children:[(0,G.jsx)(a,{}),(0,G.jsx)(C,{children:` Establishing connection to MCP server`})]}),(0,G.jsx)(C,{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`}):(q&&($.push({label:`Re-authenticate`,value:`reauth`}),$.push({label:`Clear authentication`,value:`clear-auth`})),q||$.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,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsxs)(S,{flexDirection:`column`,paddingX:1,borderStyle:d?void 0:`round`,children:[(0,G.jsx)(S,{marginBottom:1,children:(0,G.jsxs)(C,{bold:!0,children:[X,` MCP Server`]})}),(0,G.jsxs)(S,{flexDirection:`column`,gap:0,children:[(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,G.jsxs)(C,{children:[E(`inactive`,f)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,G.jsxs)(C,{children:[E(`success`,f)(r.tick),` connected`]}):e.client.type===`pending`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{dimColor:!0,children:r.radioOff}),(0,G.jsx)(C,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,G.jsxs)(C,{children:[E(`warning`,f)(r.triangleUpOutline),` needs authentication`]}):(0,G.jsxs)(C,{children:[E(`error`,f)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{bold:!0,children:`Auth: `}),q?(0,G.jsxs)(C,{children:[E(`success`,f)(r.tick),` authenticated`]}):(0,G.jsxs)(C,{children:[E(`error`,f)(r.cross),` not authenticated`]})]}),(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{bold:!0,children:`URL: `}),(0,G.jsx)(C,{dimColor:!0,children:e.config.url})]}),(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{bold:!0,children:`Config location: `}),(0,G.jsx)(C,{dimColor:!0,children:te(e.scope)})]}),e.client.type===`connected`&&(0,G.jsx)(Oe,{serverToolsCount:t,serverPromptsCount:Ie,serverResourcesCount:ce.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,G.jsxs)(S,{children:[(0,G.jsx)(C,{bold:!0,children:`Tools: `}),(0,G.jsxs)(C,{dimColor:!0,children:[t,` tools`]})]})]}),_&&(0,G.jsx)(S,{marginTop:1,children:(0,G.jsxs)(C,{color:`error`,children:[`Error: `,_]})}),$.length>0&&(0,G.jsx)(S,{marginTop:1,children:(0,G.jsx)(ie,{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 Z();break;case`claudeai-clear-auth`:Q();break;case`reconnectMcpServer`:D(!0);try{let t=await J(e.name);e.config.type===`claudeai-proxy`&&I(`tengu_claudeai_mcp_reconnect`,{success:t.client.type===`connected`});let{message:n}=Ae(t,e.name);u?.(n)}catch(t){e.config.type===`claudeai-proxy`&&I(`tengu_claudeai_mcp_reconnect`,{success:!1}),u?.(je(t,e.name))}finally{D(!1)}break;case`toggle-enabled`:await Re();break;case`back`:s();break}},onCancel:s})})]}),(0,G.jsx)(S,{marginTop:1,children:(0,G.jsx)(C,{dimColor:!0,italic:!0,children:p.pending?(0,G.jsxs)(G.Fragment,{children:[`Press `,p.keyName,` again to exit`]}):(0,G.jsxs)(w,{children:[(0,G.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,G.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,G.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var W,G,Ne=e((()=>{n(),W=t(T(),1),F(),L(),V(),d(),D(),s(),h(),u(),B(),p(),y(),z(),_(),A(),P(),R(),v(),m(),f(),fe(),ke(),U(),G=k()}));function Pe({server:e,serverToolsCount:t,onViewTools:n,onCancel:s,onComplete:c,borderless:l=!1}){let[u]=pe(),d=De(),f=de(e=>e.mcp),ee=Ee(),p=Te(),[ne,m]=(0,K.useState)(!1),ae=K.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await p(e.name),s()}catch(n){c(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ye(n)}`)}},[e.client.type,e.name,p,s,c]),oe=Ce(String(e.name)),h=o(f.commands,e.name).length,g=[];return e.client.type!==`disabled`&&t>0&&g.push({label:`View tools`,value:`tools`}),e.client.type!==`disabled`&&g.push({label:`Reconnect`,value:`reconnectMcpServer`}),g.push({label:e.client.type===`disabled`?`Enable`:`Disable`,value:`toggle-enabled`}),g.length===0&&g.push({label:`Back`,value:`back`}),ne?(0,q.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(C,{color:`text`,children:[`Reconnecting to `,(0,q.jsx)(C,{bold:!0,children:e.name})]}),(0,q.jsxs)(S,{children:[(0,q.jsx)(a,{}),(0,q.jsx)(C,{children:` Restarting MCP server process`})]}),(0,q.jsx)(C,{dimColor:!0,children:`This may take a few moments.`})]}):(0,q.jsxs)(S,{flexDirection:`column`,children:[(0,q.jsxs)(S,{flexDirection:`column`,paddingX:1,borderStyle:l?void 0:`round`,children:[(0,q.jsx)(S,{marginBottom:1,children:(0,q.jsxs)(C,{bold:!0,children:[oe,` MCP Server`]})}),(0,q.jsxs)(S,{flexDirection:`column`,gap:0,children:[(0,q.jsxs)(S,{children:[(0,q.jsx)(C,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,q.jsxs)(C,{children:[E(`inactive`,u)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,q.jsxs)(C,{children:[E(`success`,u)(r.tick),` connected`]}):e.client.type===`pending`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(C,{dimColor:!0,children:r.radioOff}),(0,q.jsx)(C,{children:` connecting…`})]}):(0,q.jsxs)(C,{children:[E(`error`,u)(r.cross),` failed`]})]}),(0,q.jsxs)(S,{children:[(0,q.jsx)(C,{bold:!0,children:`Command: `}),(0,q.jsx)(C,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,q.jsxs)(S,{children:[(0,q.jsx)(C,{bold:!0,children:`Args: `}),(0,q.jsx)(C,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,q.jsxs)(S,{children:[(0,q.jsx)(C,{bold:!0,children:`Config location: `}),(0,q.jsx)(C,{dimColor:!0,children:te(re(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,q.jsx)(Oe,{serverToolsCount:t,serverPromptsCount:h,serverResourcesCount:f.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,q.jsxs)(S,{children:[(0,q.jsx)(C,{bold:!0,children:`Tools: `}),(0,q.jsxs)(C,{dimColor:!0,children:[t,` tools`]})]})]}),g.length>0&&(0,q.jsx)(S,{marginTop:1,children:(0,q.jsx)(ie,{options:g,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){m(!0);try{let{message:t}=Ae(await ee(e.name),e.name);c?.(t)}catch(t){c?.(je(t,e.name))}finally{m(!1)}}else t===`toggle-enabled`?await ae():t===`back`&&s()},onCancel:s})})]}),(0,q.jsx)(S,{marginTop:1,children:(0,q.jsx)(C,{dimColor:!0,italic:!0,children:d.pending?(0,q.jsxs)(q.Fragment,{children:[`Press `,d.keyName,` again to exit`]}):(0,q.jsxs)(w,{children:[(0,q.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,q.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,q.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var K,q,J=e((()=>{n(),K=t(T(),1),V(),D(),b(),B(),p(),y(),A(),R(),v(),m(),f(),ke(),U(),q=k()}));function Fe({tool:e,server:t,onBack:n}){let[r,a]=Y.useState(``),o=N(e.name,t.name),s=j(e.userFacingName?e.userFacingName({}):o),c=e.isReadOnly?.({})??!1,l=e.isDestructive?.({})??!1,u=e.isOpenWorld?.({})??!1;return Y.useEffect(()=>{async function t(){try{let t=await e.description({},{isNonInteractiveSession:!1,toolPermissionContext:{mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1},tools:[]});a(t)}catch{a(`Failed to load description`)}}t()},[e]),(0,X.jsx)(O,{title:(0,X.jsxs)(X.Fragment,{children:[s,c&&(0,X.jsx)(C,{color:`success`,children:` [read-only]`}),l&&(0,X.jsx)(C,{color:`error`,children:` [destructive]`}),u&&(0,X.jsx)(C,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,X.jsxs)(C,{children:[`Press `,e.keyName,` again to exit`]}):(0,X.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,X.jsxs)(S,{flexDirection:`column`,children:[(0,X.jsxs)(S,{children:[(0,X.jsx)(C,{bold:!0,children:`Tool name: `}),(0,X.jsx)(C,{dimColor:!0,children:o})]}),(0,X.jsxs)(S,{children:[(0,X.jsx)(C,{bold:!0,children:`Full name: `}),(0,X.jsx)(C,{dimColor:!0,children:e.name})]}),r&&(0,X.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(C,{bold:!0,children:`Description:`}),(0,X.jsx)(C,{wrap:`wrap`,children:r})]}),e.inputJSONSchema&&e.inputJSONSchema.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,X.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(C,{bold:!0,children:`Parameters:`}),(0,X.jsx)(S,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,X.jsxs)(C,{children:[`• `,t,r&&(0,X.jsx)(C,{dimColor:!0,children:` (required)`}),`:`,` `,(0,X.jsx)(C,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,X.jsxs)(C,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var Y,X,Ie=e((()=>{Y=t(T(),1),D(),M(),v(),X=k()}));function Le({server:e,onSelectTool:t,onBack:n}){let r=de(e=>e.mcp.tools),a=Z.useMemo(()=>e.client.type===`connected`?ce(r,e.name):[],[e,r]),o=a.map((t,n)=>{let r=N(t.name,e.name),i=j(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)(O,{title:`Tools for ${e.name}`,subtitle:`${a.length} ${Se(a.length,`tool`)}`,onCancel:n,inputGuide:e=>e.pending?(0,Q.jsxs)(C,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(w,{children:[(0,Q.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:a.length===0?(0,Q.jsx)(C,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(ie,{options:o,onChange:e=>{let n=parseInt(e,10),r=a[n];r&&t(r,n)},onCancel:n})})}var Z,Q,Re=e((()=>{Z=t(T(),1),D(),M(),p(),y(),R(),v(),m(),Q=k()}));export{Pe as a,Ne as c,Ie as i,Re as n,J as o,Fe as r,Me as s,Le as t};
@@ -1,3 +0,0 @@
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{Au as a,Ds as o,EC as s,Ea as c,Eg as l,Es as u,Ga as d,Hc as f,Jy as p,Kc as m,MC as h,Mu as g,Ua as _,Uc as v,Va as y,Wc as b,Xu as x,Zu as S,_n as C,ap as w,bg as T,fw as E,hw as D,in as O,ka as k,ks as A,mw as j,ng as M,pn as N,qy as P,rg as ee,rp as F,wa as I,xa as te,xg as ne,yg as re,za as L}from"./loadAgentsDir-mcRW90aq.js";import{C as ie,Gt as ae,I as R,P as z,Wt as oe,fi as B,ot as se,t as ce}from"./src-P_wYS_NJ2.js";import{t as le}from"./jsx-runtime-Bb4Xn-E0.js";import{Gn as ue,Wt as de}from"./state-BPFYBqm1.js";import{Ln as V,Rn as fe}from"./settings-DiBMs2gM.js";import{h as H,m as pe,o as me,q as he,s as U,w as ge}from"./log-27kCA_9u.js";import{n as W,r as G}from"./analytics-DJobLaWP.js";import{b as _e,m as ve,v as ye}from"./startupProfiler-Dc5r6LgE.js";import{E as be,T as xe,c as Se,d as Ce,w as we}from"./sessionTracing-CEsm8pZL.js";import{n as Te,t as Ee}from"./useExitOnCtrlCDWithKeybindings-CPLBDluY.js";import*as K from"path";import{randomUUID as q}from"crypto";B();var J=le();ce(),de(),he(),pe(),me(),fe(),W(),ye(),j(),P(),we(),F(),Se(),b(),f(),A(),L(),C();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();ue(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:[I({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:[I({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}W(),L();async function Ae({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:a,ideSelection:o,messages:s,setUserInputOnProcessing:c,uuid:l,isAlreadyProcessing:d,querySource:f,canUseTool:p,skipSlashCommands:h,bridgeOrigin:g,isMeta:_,skipAttachments:v,autonomy:y}){let b=typeof e==`string`?e:null,x=b?.startsWith(`/`)&&!h;n===`prompt`&&b!==null&&!_&&!x&&c?.(b),m(`query_process_user_input_base_start`);let S=i.getAppState(),C=await Me(e,n,r,i,a,o,s,l,d,f,p,S.toolPermissionContext.mode,h,g,_,v,t,y);if(m(`query_process_user_input_base_end`),!C.shouldQuery)return C;m(`query_hooks_start`);let w=k(e)||``;for await(let t of O(w,S.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[te(`${N(t.blockingError)}\n\nOriginal prompt: ${e}`,`warning`)],shouldQuery:!1,allowedTools:C.allowedTools};if(t.preventContinuation){let e=t.stopReason?`Operation stopped by hook: ${t.stopReason}`:`Operation stopped by hook`;return C.messages.push(I({content:e})),C.shouldQuery=!1,C}if(t.additionalContexts&&t.additionalContexts.length>0&&C.messages.push(u({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;C.messages.push({...t.message,attachment:{...t.message.attachment,content:je(t.message.attachment.content)}});break;default:C.messages.push(t.message);break}}return m(`query_hooks_end`),C}var Y=1e4;function je(e){return e.length>Y?`${e.substring(0,Y)}… [output truncated - exceeded ${Y} characters]`:e}async function Me(e,t,n,r,i,a,s,c,l,u,d,f,h,g,_,y,b,x){let S=null,C=[],T=[],O=e;if(typeof e==`string`)S=e;else if(e.length>0){m(`query_image_processing_start`);let t=[];for(let n of e)if(n.type===`image`){let e=await D(n);if(e.dimensions){let t=E(e.dimensions);t&&T.push(t)}t.push(e.block)}else t.push(n);O=t,m(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(S=n.text,C=t.slice(0,-1)):C=t}if(S===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let k=i?Object.values(i).filter(p):[],A=k.map(e=>e.id),j=i?await w(i):new Map;m(`query_pasted_image_processing_start`);let M=await Promise.all(k.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 D(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??j.get(e.id)}})),N=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of M){if(e.dimensions){let t=E(e.dimensions,n);t&&T.push(t)}else if(t){let e=E(t,n);e&&T.push(e)}else n&&T.push(`[Image source: ${n}]`);N.push(e.block)}m(`query_pasted_image_processing_end`);let P=h,ee=!y&&S!==null&&(t!==`prompt`||P||!S.startsWith(`/`));m(`query_attachment_loading_start`);let F=ee?await v(o(S,r,a??null,[],s,u)):[];if(m(`query_attachment_loading_end`),S!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-g3sAMpHt.js`);return X(await e(S,C,F,r,n),T)}if(S!==null&&!P&&S.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-tIbeCrv5.js`);return X(await e(S,C,N,F,r,n,c,l,d,x),T)}if(S!==null&&t===`prompt`){let e=S.trim(),t=F.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 X(ke(O,N,A,F,c,f,_),T)}function X(e,t){return t.length>0&&e.messages.push(I({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 Z(e){return e===`summarize`}function Fe({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:o,onClose:s,preselectedMessage:c}){let l=ee(e=>e.fileHistory),[u,d]=(0,Q.useState)(void 0),f=T(),p=(0,Q.useMemo)(q,[]),m=(0,Q.useMemo)(()=>[...e.filter(He),{...I({content:``}),uuid:p}],[e,p]),[h,g]=(0,Q.useState)(m.length-1),_=Math.max(0,Math.min(h-Math.floor($/2),m.length-$)),v=m.length>1,[y,b]=(0,Q.useState)(c),[S,C]=(0,Q.useState)(void 0);(0,Q.useEffect)(()=>{if(!c||!f)return;let e=!1;return ne(l,c.uuid).then(t=>{e||C(t)}),()=>{e=!0}},[c,f,l]);let[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(`both`),[j,M]=(0,Q.useState)(``);function N(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:M}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,Q.useEffect)(()=>{G(`tengu_message_selector_opened`,{})},[]);async function P(e){t(),E(!0);try{await n(e),E(!1),s()}catch(e){U(e),E(!1),d(`Failed to restore the conversation:\n${e}`)}}async function F(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)){s();return}if(!f){await P(t);return}let r=await ne(l,t.uuid);b(t),C(r)}async function te(e){if(G(`tengu_message_selector_restore_option_selected`,{option:e}),!y){d(`Message not found.`);return}if(e===`nevermind`){c?s():b(void 0);return}if(Z(e)){t(),E(!0),O(e),d(void 0);try{let e=j.trim()||void 0;await o(y,e,`from`),E(!1),O(null),b(void 0),s()}catch(e){U(e),E(!1),O(null),b(void 0),d(`Failed to summarize:\n${e}`)}return}t(),E(!0),d(void 0);let i=null,a=null;if(e===`code`||e===`both`)try{await r(y)}catch(e){i=e,U(i)}if(e===`conversation`||e===`both`)try{await n(y)}catch(e){a=e,U(a)}E(!1),b(void 0),a&&i?d(`Failed to restore the conversation and code:\n${a}\n${i}`):a?d(`Failed to restore the conversation:\n${a}`):i?d(`Failed to restore the code:\n${i}`):s()}let L=Te(),B=(0,Q.useCallback)(()=>{if(y&&!c){b(void 0);return}G(`tengu_message_selector_cancelled`,{}),s()},[s,y,c]),se=(0,Q.useCallback)(()=>g(e=>Math.max(0,e-1)),[]),ce=(0,Q.useCallback)(()=>g(e=>Math.min(m.length-1,e+1)),[m.length]),le=(0,Q.useCallback)(()=>g(0),[]),ue=(0,Q.useCallback)(()=>g(m.length-1),[m.length]),de=(0,Q.useCallback)(()=>{let e=m[h];e&&F(e)},[m,h,F]);oe(`confirm:no`,B,{context:`Confirmation`,isActive:!y}),ae({"messageSelector:up":se,"messageSelector:down":ce,"messageSelector:top":le,"messageSelector:bottom":ue,"messageSelector:select":de},{context:`MessageSelector`,isActive:!w&&!u&&!y&&v});let[V,fe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{async function t(){f&&Promise.all(m.map(async(t,n)=>{if(t.uuid!==p){let r=re(l,t.uuid),i=m.at(n+1),a=r?Ve(e,t.uuid,i?.uuid===p?void 0:i?.uuid):void 0;fe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[m,e,p,l,f]);let H=f&&S?.filesChanged&&S.filesChanged.length>0,pe=!u&&!y&&!c&&v;return(0,J.jsxs)(R,{flexDirection:`column`,width:`100%`,children:[(0,J.jsx)(ie,{color:`suggestion`}),(0,J.jsxs)(R,{flexDirection:`column`,marginX:1,gap:1,children:[(0,J.jsx)(z,{bold:!0,color:`suggestion`,children:`Rewind`}),u&&(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(z,{color:`error`,children:[`Error: `,u]})}),!v&&(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(z,{children:`Nothing to rewind to yet.`})}),!u&&y&&v&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{children:[`Confirm you want to restore `,!S&&`the conversation `,`to the point before you sent this message:`]}),(0,J.jsxs)(R,{flexDirection:`column`,paddingLeft:1,borderStyle:`single`,borderRight:!1,borderTop:!1,borderBottom:!1,borderLeft:!0,borderLeftDimColor:!0,children:[(0,J.jsx)(Be,{userMessage:y,color:`text`,isCurrent:!1}),(0,J.jsxs)(z,{dimColor:!0,children:[`(`,ve(new Date(y.timestamp)),`)`]})]}),(0,J.jsx)(Le,{selectedRestoreOption:k,canRestoreCode:!!H,diffStatsForRestore:S}),w&&Z(D)?(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(a,{}),(0,J.jsx)(z,{children:`Summarizing…`})]}):(0,J.jsx)(x,{isDisabled:w,options:N(!!H),defaultFocusValue:H?`both`:`conversation`,onFocus:e=>A(e),onChange:e=>te(e),onCancel:()=>c?s():b(void 0)}),H&&(0,J.jsx)(R,{marginBottom:1,children:(0,J.jsxs)(z,{dimColor:!0,children:[i.warning,` Rewinding does not affect files edited manually or via bash.`]})})]}),pe&&(0,J.jsxs)(J.Fragment,{children:[f?(0,J.jsx)(z,{children:`Restore the code and/or conversation to the point before…`}):(0,J.jsx)(z,{children:`Restore and fork the conversation to the point before…`}),(0,J.jsx)(R,{width:`100%`,flexDirection:`column`,children:m.slice(_,_+$).map((e,t)=>{let n=_+t,r=n===h,a=e.uuid===p,o=n in V,s=V[n],c=s?.filesChanged&&s.filesChanged.length;return(0,J.jsxs)(R,{height:f?3:2,overflow:`hidden`,width:`100%`,flexDirection:`row`,children:[(0,J.jsx)(R,{width:2,minWidth:2,children:r?(0,J.jsxs)(z,{color:`permission`,bold:!0,children:[i.pointer,` `]}):(0,J.jsx)(z,{children:` `})}),(0,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(R,{flexShrink:1,height:1,overflow:`hidden`,children:(0,J.jsx)(Be,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:a,paddingRight:10})}),f&&o&&(0,J.jsx)(R,{height:1,flexDirection:`row`,children:s?(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(z,{dimColor:!r,color:`inactive`,children:c?(0,J.jsxs)(J.Fragment,{children:[c===1&&s.filesChanged[0]?`${K.basename(s.filesChanged[0])} `:`${c} files changed `,(0,J.jsx)(ze,{diffStats:s})]}):(0,J.jsx)(J.Fragment,{children:`No code changes`})})}):(0,J.jsxs)(z,{dimColor:!0,color:`warning`,children:[i.warning,` No code restore`]})})]})]},e.uuid)})})]}),!y&&(0,J.jsx)(z,{dimColor:!0,italic:!0,children:L.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,L.keyName,` again to exit`]}):(0,J.jsxs)(J.Fragment,{children:[!u&&v&&`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,J.jsxs)(R,{flexDirection:`column`,children:[(0,J.jsx)(z,{dimColor:!0,children:Ie(e)}),!Z(e)&&(r?(0,J.jsx)(Re,{diffStatsForRestore:n}):(0,J.jsx)(z,{dimColor:!0,children:`The code will be unchanged.`}))]})}function Re({diffStatsForRestore:e}){if(e===void 0)return;if(!e.filesChanged||!e.filesChanged[0])return(0,J.jsx)(z,{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,J.jsx)(J.Fragment,{children:(0,J.jsxs)(z,{dimColor:!0,children:[`The code will be restored `,(0,J.jsx)(ze,{diffStats:e}),` in `,n,`.`]})})}function ze({diffStats:e}){if(!(!e||!e.filesChanged))return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{color:`diffAddedWord`,children:[`+`,e.insertions,` `]}),(0,J.jsxs)(z,{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,J.jsx)(R,{width:`100%`,children:(0,J.jsx)(z,{italic:!0,color:t,dimColor:n,children:`(current)`})});let o=e.message.content,s=typeof o==`string`?null:o[o.length-1],l=H(typeof o==`string`?o.trim():s&&Pe(s)?s.text.trim():`(no prompt)`);if(y(l))return(0,J.jsx)(R,{flexDirection:`row`,width:`100%`,children:(0,J.jsx)(z,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(l.includes(`<bash-input>`)){let e=c(l,`bash-input`);if(e)return(0,J.jsxs)(R,{flexDirection:`row`,width:`100%`,children:[(0,J.jsx)(z,{color:`bashBorder`,children:`!`}),(0,J.jsxs)(z,{color:t,dimColor:n,children:[` `,e]})]})}if(l.includes(`<command-message>`)){let e=c(l,ge),r=c(l,`command-args`),i=c(l,`skill-format`)===`true`;if(e)return i?(0,J.jsx)(R,{flexDirection:`row`,width:`100%`,children:(0,J.jsxs)(z,{color:t,dimColor:n,children:[`Skill(`,e,`)`]})}):(0,J.jsx)(R,{flexDirection:`row`,width:`100%`,children:(0,J.jsxs)(z,{color:t,dimColor:n,children:[`/`,e,` `,r]})})}return(0,J.jsx)(R,{flexDirection:`row`,width:`100%`,children:(0,J.jsx)(z,{color:t,dimColor:n,children:i?_e(l,a-i,!0):l.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||!d(n))continue;let r=n.toolUseResult;if(!(!r||!r.filePath||!r.structuredPatch)){a.includes(r.filePath)||a.push(r.filePath);try{if(`type`in r&&r.type===`create`)o+=r.content.split(/\r?\n/).length;else for(let e of r.structuredPatch){let t=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`||_(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&&!_(t)&&!d(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 Q,$,We=e((()=>{r(),Q=t(B(),1),W(),M(),l(),Ee(),s(),L(),S(),g(),h(),$=7}));export{He as a,Ue as i,Ne as n,Ae as o,We as r,Fe as t};
@@ -1,11 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{l as r,o as i}from"./envUtils-DcaKZlRU.js";import{n as a,t as o}from"./figures-5ThXQEtq.js";import{$a as s,CC as c,DC as l,Dp as u,Ea as d,Ep as f,Fa as p,Ff as m,Gf as h,Ha as g,Ig as _,Jf as v,Kf as y,Lu as b,MC as x,Ma as S,Na as C,Nf as w,OC as T,Pa as E,Pf as D,Qm as O,Ra as ee,Ru as k,SC as te,Ta as ne,Vf as re,Wf as ie,Xa as A,Xh as j,Yf as ae,Yh as M,Za as oe,Zm as N,Zy as se,_S as ce,aa as P,bC as le,dT as ue,da as de,eb as fe,fT as pe,fa as me,gS as he,gT as ge,ga as _e,ia as ve,ja as ye,ng as be,qa as xe,qf as Se,ra as Ce,rb as we,rg as Te,tb as Ee,vC as De,vS as F,vp as Oe,wC as ke,xC as Ae,yT as je,yp as Me,za as I,zu as Ne}from"./loadAgentsDir-mcRW90aq.js";import{C as Pe,Gr as L,I as R,N as Fe,P as z,Pn as Ie,Rn as Le,di as Re,fi as B,j as ze,mt as Be,ot as Ve,t as V,ui as He,xt as Ue}from"./src-P_wYS_NJ2.js";import{t as H}from"./jsx-runtime-Bb4Xn-E0.js";import{B as We,Wt as Ge}from"./state-BPFYBqm1.js";import{n as Ke,t as qe}from"./cwd-Besi3Os3.js";import{a as Je,c as Ye,i as Xe,n as Ze,o as Qe}from"./debug-Dr1SjdXn.js";import{Ht as $e,Wt as et,g as tt,n as nt}from"./settings-DiBMs2gM.js";import{c as rt,h as it,y as at}from"./config-9rLTDOYW.js";import{B as ot,L as st,R as ct,q as lt}from"./log-27kCA_9u.js";import{b as ut,f as dt,m as ft,v as pt}from"./startupProfiler-Dc5r6LgE.js";import{l as mt,o as ht}from"./stringUtils-Df-Lnjxd.js";import{Bt as gt,Dt as _t,E as vt,Gt as yt,St as bt,Tt as xt,_ as St,_n as Ct,b as wt,vn as Tt}from"./model-C29_32BD.js";import{bn as Et,vn as Dt}from"./prompt-DIlq8NTy.js";import{d as Ot,f as kt,h as At,p as jt}from"./terminalSetup-fwhFTxGi.js";import{_ as Mt,x as Nt}from"./sessionState-Bn3ESS5f.js";import{n as Pt,t as Ft}from"./systemTheme-Ceakddth.js";import{n as It,r as Lt}from"./PromptInputFooterSuggestions-R12fbdmp.js";import{n as Rt,t as zt}from"./useMainLoopModel-C00PbZ1Q.js";import{n as Bt,t as Vt}from"./modalContext-CUThy6Ph.js";import{n as Ht,r as Ut,t as Wt}from"./statusNoticeHelpers-Sl4jjauz.js";import{a as Gt,c as Kt,i as qt,l as Jt,n as Yt,o as Xt,r as Zt,t as Qt,u as $t}from"./logoV2Utils--8OUQQPd.js";import{homedir as en}from"os";import{relative as tn}from"path";import{fileURLToPath as nn}from"url";function rn(e,t){for(let n of e)if(!t.has(n))return!1;return!0}var an=t((()=>{}));function on(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`)||d(t.text,`status`)!==`completed`?!1:d(t.text,`summary`)?.startsWith(`Background command `)??!1}function sn(e,t){if(!j()||t)return e;let n=[],r=0;for(;r<e.length;){let t=e[r];if(on(t)){let i=0;for(;r<e.length&&on(e[r]);)i++,r++;i===1?n.push(t):n.push({...t,message:{role:`user`,content:[{type:`text`,text:`<${ot}><${st}>completed</${st}><${ct}>${i} background commands completed</${ct}></${ot}>`}]}})}else n.push(t),r++}return n}var cn=t((()=>{lt(),_(),M(),I()}));function ln(e){return e.type===`system`&&e.subtype===`stop_hook_summary`&&e.hookLabel!==void 0}function un(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(ln(r)){let i=r.hookLabel,a=[];for(;n<e.length;){let t=e[n];if(!ln(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 dn=t((()=>{}));function fn(e){let t=hn.get(e);return t||(t=new Set(e.filter(e=>e.renderGroupedToolUse).map(e=>e.name)),hn.set(e,t)),t}function pn(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 mn(e,t,n=!1){if(n)return{messages:e};let r=fn(t),i=new Map;for(let t of e){let e=pn(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=pn(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=pn(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 hn,gn=t((()=>{hn=new WeakMap}));function _n(e){let t=Cn.get(e);if(t!==void 0)return t;let n=vn(e).toLowerCase();return Cn.set(e,n),n}function vn(e){let t=``;switch(e.type){case`user`:{let n=e.message.content;if(typeof n==`string`)t=Sn.has(n)?``:n;else{let r=[];for(let t of n??[])t.type===`text`?Sn.has(t.text)||r.push(t.text):t.type===`tool_result`&&r.push(bn(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`?[yn(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(xn,r);if(e<0)break;n=n.slice(0,r)+n.slice(e+18),r=n.indexOf(`<system-reminder>`)}return n}function yn(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 bn(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?`
8
- `+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(`
9
- `))}return n.join(`
10
- `)}var xn,Sn,Cn,wn=t((()=>{I(),xn=`</system-reminder>`,Sn=new Set([ve,P]),Cn=new WeakMap}));function Tn({pose:e=`default`}={}){return(0,En.jsxs)(R,{flexDirection:`column`,alignItems:`center`,children:[(0,En.jsx)(z,{color:`clawd_body`,children:` █████ `}),(0,En.jsx)(z,{color:`clawd_body`,children:`██ ● ● ██`}),(0,En.jsx)(z,{color:`clawd_body`,children:`██ ▄▄▄ ██`}),(0,En.jsx)(z,{color:`clawd_body`,children:` █ █ █ █ `})]})}var En,Dn=t((()=>{B(),V(),En=H()}));function On(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 kn({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:ut(i,t)})]}):r.length===0&&a?(0,U.jsx)(z,{dimColor:!0,children:ut(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:ut(e.text,r)})]},n)}),i&&(0,U.jsx)(z,{dimColor:!0,italic:!0,children:ut(i,t)})]})]})}var U,An=t((()=>{B(),V(),pt(),U=H()}));function jn({feeds:e,maxWidth:t}){let n=e.map(e=>On(e)),r=Math.max(...n),i=Math.min(r,t);return(0,Nn.jsx)(R,{flexDirection:`column`,children:e.map((t,n)=>(0,Nn.jsxs)(Mn.Fragment,{children:[(0,Nn.jsx)(kn,{config:t,actualWidth:i}),n<e.length-1&&(0,Nn.jsx)(Pe,{color:`claude`,width:i})]},n))})}var Mn,Nn,Pn=t((()=>{Mn=n(B(),1),V(),An(),Nn=H()}));function Fn(e){let t=e.map(e=>{let t=ft(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 In(e){let t=e.filter(({isEnabled:e})=>e).sort((e,t)=>Number(e.isComplete)-Number(t.isComplete)).map(({text:e,isComplete:t})=>({text:`${t?`${o.tick} `:``}${e}`})),n=qe()===en()?`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 Ln=t((()=>{a(),Ke(),pt()}));function Rn(e,t,n){return Array.from({length:n},()=>({pose:e,offset:t}))}function zn(){let{pose:e,bounceOffset:t,onClick:n}=Bn();return(0,Hn.jsx)(R,{height:Jn,flexDirection:`column`,onClick:n,children:(0,Hn.jsx)(R,{marginTop:t,flexShrink:0,children:(0,Hn.jsx)(Tn,{pose:e})})})}function Bn(){let[e]=(0,Vn.useState)(()=>nt().prefersReducedMotion??!1),[t,n]=(0,Vn.useState)(-1),r=(0,Vn.useRef)(Un),i=()=>{e||t!==-1||(r.current=Wn[Math.floor(Math.random()*Wn.length)],n(0))};(0,Vn.useEffect)(()=>{if(t===-1)return;if(t>=r.current.length){n(-1);return}let e=setTimeout(n,Kn,qn);return()=>clearTimeout(e)},[t]);let a=r.current,o=t>=0&&t<a.length?a[t]:Gn;return{pose:o.pose,bounceOffset:o.offset,onClick:i}}var Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn=t((()=>{B(),Vn=n(B(),1),V(),tt(),Dn(),Hn=H(),Un=[...Rn(`default`,1,2),...Rn(`arms-up`,0,3),...Rn(`default`,0,1),...Rn(`default`,1,2),...Rn(`arms-up`,0,3),...Rn(`default`,0,1)],Wn=[Un,[...Rn(`look-right`,0,5),...Rn(`look-left`,0,5),...Rn(`default`,0,1)]],Gn={pose:`default`,offset:0},Kn=60,qn=e=>e+1,Jn=3}));function Xn(){let{columns:e}=Ve(),t=Te(e=>e.agent),n=vt(Rt()),{version:r,cwd:i,billingType:a,agentName:o}=Xt(),s=t??o,c=Math.max(e-15,20),l=ut(r,Math.max(c-11,6)),{shouldSplit:u,truncatedModel:d,truncatedBilling:f}=Zt(n,a,c),p=s?c-1-L(s)-3:c,m=$t(i,Math.max(p,10));return(0,W.jsx)(N,{children:(0,W.jsxs)(R,{flexDirection:`row`,gap:2,alignItems:`center`,children:[j()?(0,W.jsx)(zn,{}):(0,W.jsx)(Tn,{}),(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:d}),(0,W.jsx)(z,{dimColor:!0,children:f})]}):(0,W.jsxs)(z,{dimColor:!0,children:[d,` · `,f]}),(0,W.jsx)(z,{dimColor:!0,children:s?`@${s} · ${m}`:m})]})]})})}var W,Zn=t((()=>{zt(),x(),V(),be(),pt(),M(),Jt(),St(),O(),Yn(),Dn(),W=H()}));function Qn(){let e=(0,er.useMemo)($n,[]),t=(0,er.useMemo)(()=>rt().lastShownEmergencyTip,[]),n=e.tip&&e.tip!==t;return(0,er.useEffect)(()=>{n&&at(t=>t.lastShownEmergencyTip===e.tip?t:{...t,lastShownEmergencyTip:e.tip})},[n,e.tip]),n?(0,tr.jsx)(R,{paddingLeft:2,flexDirection:`column`,children:(0,tr.jsx)(z,{...e.color===`warning`?{color:`warning`}:e.color===`error`?{color:`error`}:{dimColor:!0},children:e.tip})}):null}function $n(){return nr}var er,tr,nr,rr=t((()=>{B(),er=n(B(),1),V(),it(),tr=H(),nr={tip:``,color:`dim`}}));function ir({char:e=`✻`}){let[t]=(0,ar.useState)(()=>nt().prefersReducedMotion??!1),[n,r]=(0,ar.useState)(t),i=(0,ar.useRef)(null),[a,o]=Be(n?null:50);return(0,ar.useEffect)(()=>{if(n)return;let e=setTimeout(r,cr,!0);return()=>clearTimeout(e)},[n]),n?(0,or.jsx)(R,{ref:a,children:(0,or.jsx)(z,{color:lr,children:e})}):(i.current===null&&(i.current=o),(0,or.jsx)(R,{ref:a,children:(0,or.jsx)(z,{color:Ne(b((o-i.current)/sr*360%360)),children:e})}))}var ar,or,sr,cr,lr,ur=t((()=>{B(),ar=n(B(),1),et(),V(),tt(),k(),or=H(),sr=1500,cr=sr*2,lr=Ne({r:153,g:153,b:153})}));function dr(){return wt()&&(rt().opus1mMergeNoticeSeenCount??0)<hr}function fr(){let[e]=(0,pr.useState)(dr);return(0,pr.useEffect)(()=>{if(!e)return;let t=(rt().opus1mMergeNoticeSeenCount??0)+1;at(e=>(e.opus1mMergeNoticeSeenCount??0)>=t?e:{...e,opus1mMergeNoticeSeenCount:t})},[e]),e?(0,mr.jsxs)(R,{paddingLeft:2,children:[(0,mr.jsx)(ir,{char:`↑`}),(0,mr.jsx)(z,{dimColor:!0,children:` Opus now defaults to 1M context · 5x more room, same pricing`})]}):null}var pr,mr,hr,gr=t((()=>{B(),pr=n(B(),1),et(),V(),it(),St(),ur(),mr=H(),hr=6}));function _r(){let e=Kt(),t=rt().oauthAccount?.displayName??``,{columns:n}=Ve(),i=At(),a=ge.isSandboxingEnabled(),o=Te(e=>e.agent),s=rt(),[c]=(0,vr.useState)(()=>{let e=nt().companyAnnouncements;if(!(!e||e.length===0))return s.numStartups===1?e[0]:e[Math.floor(Math.random()*e.length)]});(0,vr.useEffect)(()=>{i&&kt()},[i]),!i&&r(process.env.CLAUDE_CODE_FORCE_FULL_LOGO);let l=vt(Rt()),{version:u,cwd:d,billingType:f,agentName:p}=Xt(),m=o??p,h=ut(l,yr-20);if(!i&&!r(process.env.CLAUDE_CODE_FORCE_FULL_LOGO))return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xn,{}),(0,G.jsx)(fr,{}),Je()&&(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: `,Qe()?`stderr`:Ze()]})]}),(0,G.jsx)(Qn,{}),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 - Claude 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 g=Gt(n),_=Pt(rt().theme),v=` ${ze(`claude`,_)(`Work Mate`)} ${ze(`inactive`,_)(`v${u}`)} `,y=ze(`claude`,_)(` Work Mate `);if(g===`compact`){let e=qt(t);L(e)>n-4&&(e=qt(null));let r=m?n-4-1-L(m)-3:n-4,i=$t(d,Math.max(r,10));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(N,{children:(0,G.jsxs)(R,{flexDirection:`column`,borderStyle:`round`,borderColor:`claude`,borderText:{content:y,position:`top`,align:`start`,offset:1},paddingX:1,paddingY:1,alignItems:`center`,width:n,children:[(0,G.jsx)(z,{bold:!0,children:e}),(0,G.jsx)(R,{marginY:1,children:(0,G.jsx)(Tn,{})}),(0,G.jsx)(z,{dimColor:!0,children:h}),(0,G.jsx)(z,{dimColor:!0,children:f}),(0,G.jsx)(z,{dimColor:!0,children:m?`@${m} · ${i}`:i})]})}),(0,G.jsx)(fr,{}),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 b=qt(t),x=!process.env.IS_DEMO&&s.oauthAccount?.organizationName?`${h} · ${f} · ${s.oauthAccount.organizationName}`:`${h} · ${f}`,S=m?yr-1-L(m)-3:yr,C=$t(d,Math.max(S,10)),w=m?`@${m} · ${C}`:C,{leftWidth:T,rightWidth:E}=Qt(n,g,Yt(b,w,x));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(N,{children:(0,G.jsx)(R,{flexDirection:`column`,borderStyle:`round`,borderColor:`claude`,borderText:{content:v,position:`top`,align:`start`,offset:3},children:(0,G.jsxs)(R,{flexDirection:g===`horizontal`?`row`:`column`,paddingX:1,gap:1,children:[(0,G.jsxs)(R,{flexDirection:`column`,width:T,justifyContent:`space-between`,alignItems:`center`,minHeight:9,children:[(0,G.jsx)(R,{marginTop:1,children:(0,G.jsx)(z,{bold:!0,children:b})}),(0,G.jsx)(Tn,{}),(0,G.jsxs)(R,{flexDirection:`column`,alignItems:`center`,children:[(0,G.jsx)(z,{dimColor:!0,children:x}),(0,G.jsx)(z,{dimColor:!0,children:w})]})]}),g===`horizontal`&&(0,G.jsx)(R,{height:`100%`,borderStyle:`single`,borderColor:`claude`,borderDimColor:!0,borderTop:!1,borderBottom:!1,borderLeft:!1}),g===`horizontal`&&(0,G.jsx)(jn,{feeds:i?[In(Ot()),Fn(e)]:[Fn(e)],maxWidth:E})]})})}),(0,G.jsx)(fr,{}),Je()&&(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: `,Qe()?`stderr`:Ze()]})]}),(0,G.jsx)(Qn,{}),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 - Claude 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 vr,G,yr,br=t((()=>{B(),V(),x(),Jt(),pt(),Dn(),Pn(),Ln(),it(),Ft(),tt(),Xe(),vr=n(B(),1),jt(),Zn(),O(),i(),rr(),gr(),je(),be(),zt(),St(),G=H(),yr=50}));function xr({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,Sr.jsx)(R,{minWidth:L(i)+8,children:(0,Sr.jsx)(z,{dimColor:!0,children:i})})}var Sr,Cr=t((()=>{B(),V(),Sr=H()}));function wr({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,Tr.jsx)(R,{minWidth:L(n),children:(0,Tr.jsx)(z,{dimColor:!0,children:n})})}var Tr,Er=t((()=>{B(),V(),Tr=H()}));function Dr(e,t,n,r){for(let i=t+1;i<e.length;i++){let t=e[i];if(t?.type===`assistant`){let e=Pr(t.message.content);if(e?.type===`thinking`||e?.type===`redacted_thinking`||e?.type===`tool_use`&&(y(e.name,e.input,n).isCollapsible||r.has(e.id)))continue;return!0}if(!(t?.type===`system`||t?.type===`attachment`)&&!(t?.type===`user`&&Pr(t.message.content)?.type===`tool_result`)){if(t?.type===`grouped_tool_use`){let e=Pr(t.messages[0]?.message.content)?.input;if(y(t.toolName,e,n).isCollapsible)continue}return!0}}return!1}function Or({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:g}){let _=c===`transcript`,y=e.type===`grouped_tool_use`,b=e.type===`collapsed_read_search`,x=b&&(v(e,o)||p&&!n),T=y?e.displayMessage:b?h(e):e,D=y||b?[]:S(e,m),O=Ji(e,s,o,y||b?Ce:C(e,m),c,m),ee=!1;if(l)if(y)ee=e.messages.some(e=>{let t=Pr(e.message.content);return t?.type===`tool_use`&&o.has(t.id)});else if(b)ee=v(e,o);else{let t=E(e);ee=!t||o.has(t)}let k=_&&T.type===`assistant`&&Array.isArray(T.message.content)&&T.message.content.some(e=>e.type===`text`)&&(T.timestamp||T.message.model),te=(0,Nr.jsx)(w,{message:e,lookups:m,addMargin:!k,containerWidth:k?void 0:f,tools:r,commands:i,verbose:a,inProgressToolUseIDs:o,progressMessagesForMessage:D,shouldAnimate:ee,shouldShowDot:!0,isTranscriptMode:_,isStatic:O,isActiveCollapsedGroup:x,isUserContinuation:t,lastThinkingBlockId:u,latestBashOutputUUID:d,shouldCollapseDiffs:g});return k?(0,Nr.jsx)(N,{children:(0,Nr.jsxs)(R,{width:f,flexDirection:`column`,children:[(0,Nr.jsxs)(R,{flexDirection:`row`,justifyContent:`flex-end`,gap:1,marginTop:1,children:[(0,Nr.jsx)(wr,{message:T,isTranscriptMode:_}),(0,Nr.jsx)(xr,{message:T,isTranscriptMode:_})]}),te]})}):(0,Nr.jsx)(N,{children:te})}function kr(e,t){if(e.type===`grouped_tool_use`)return e.messages.some(e=>{let n=Pr(e.message.content);return n?.type===`tool_use`&&t.has(n.id)});if(e.type===`collapsed_read_search`)return Se(e).some(e=>t.has(e));let n=E(e);return!!n&&t.has(n)}function Ar(e,t){if(e.type===`grouped_tool_use`)return e.messages.every(e=>{let n=Pr(e.message.content);return n?.type===`tool_use`&&t.has(n.id)});if(e.type===`collapsed_read_search`)return Se(e).every(e=>t.has(e));if(e.type===`assistant`){let n=Pr(e.message.content);if(n?.type===`server_tool_use`)return t.has(n.id)}let n=E(e);return!n||t.has(n)}function jr(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&&D(t.message))return!1;let n=kr(e.message,e.streamingToolUseIDs),r=Ar(e.message,e.lookups.resolvedToolUseIDs);return!(n||!r)}var Mr,Nr,Pr,Fr,Ir=t((()=>{Mr=n(B(),1),V(),ae(),I(),m(),Nr=H(),Cr(),ra(),Er(),O(),Pr=e=>{if(!Array.isArray(e))return;let t=e[0];if(!(t==null||typeof t==`string`))return t},Fr=Mr.memo(Or,jr)}));function Lr(e){return e.type===`attachment`&&Rr.has(e.attachment.type)}var Rr,zr=t((()=>{Rr=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 Br(e){return Kr.filter(t=>t.isActive(e))}var K,Vr,Hr,Ur,Wr,Gr,Kr,qr=t((()=>{V(),B(),we(),a(),Ke(),pt(),gt(),Ut(),K=H(),Vr={id:`large-memory-files`,type:`warning`,isActive:e=>fe(e.memoryFiles).length>0,render:e=>(0,K.jsx)(K.Fragment,{children:fe(e.memoryFiles).map(e=>{let t=e.path.startsWith(qe())?tn(qe(),e.path):e.path;return(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:o.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Large `,(0,K.jsx)(z,{bold:!0,children:t}),` will impact performance (`,dt(e.content.length),` chars > `,dt(se),`)`,(0,K.jsx)(z,{dimColor:!0,children:` · /memory to edit`})]})]},e.path)})})},Hr={id:`claude-ai-external-token`,type:`warning`,isActive:()=>{let e=_t();return yt()&&(e.source===`ANTHROPIC_AUTH_TOKEN`||e.source===`apiKeyHelper`)},render:()=>{let e=_t();return(0,K.jsxs)(R,{flexDirection:`row`,marginTop:1,children:[(0,K.jsx)(z,{color:`warning`,children:o.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Auth conflict: Using `,e.source,` instead of Claude account subscription token. Either unset`,` `,e.source,", or run `claude /logout`."]})]})}},Ur={id:`api-key-conflict`,type:`warning`,isActive:()=>{let{source:e}=bt({skipRetrievingKeyFromApiKeyHelper:!0});return!!xt()&&(e===`ANTHROPIC_API_KEY`||e===`apiKeyHelper`)},render:()=>{let{source:e}=bt({skipRetrievingKeyFromApiKeyHelper:!0});return(0,K.jsxs)(R,{flexDirection:`row`,marginTop:1,children:[(0,K.jsx)(z,{color:`warning`,children:o.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Auth conflict: Using `,e,` instead of Console key. Either unset `,e,", or run `claude /logout`."]})]})}},Wr={id:`both-auth-methods`,type:`warning`,isActive:()=>{let{source:e}=bt({skipRetrievingKeyFromApiKeyHelper:!0}),t=_t();return e!==`none`&&t.source!==`none`&&!(e===`apiKeyHelper`&&t.source===`apiKeyHelper`)},render:()=>{let{source:e}=bt({skipRetrievingKeyFromApiKeyHelper:!0}),t=_t();return(0,K.jsxs)(R,{flexDirection:`column`,marginTop:1,children:[(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:o.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.`]})]})]})}},Gr={id:`large-agent-descriptions`,type:`warning`,isActive:e=>Ht(e.agentDefinitions)>Wt,render:e=>{let t=Ht(e.agentDefinitions);return(0,K.jsxs)(R,{flexDirection:`row`,children:[(0,K.jsx)(z,{color:`warning`,children:o.warning}),(0,K.jsxs)(z,{color:`warning`,children:[`Large cumulative agent descriptions will impact performance (~`,dt(t),` tokens > `,dt(Wt),`)`,(0,K.jsx)(z,{dimColor:!0,children:` · /agents to manage`})]})]})}},Kr=[Vr,Gr,Hr,Ur,Wr]}));function Jr({agentDefinitions:e}={}){let t={config:rt(),agentDefinitions:e,memoryFiles:(0,Xr.use)(Ee())},n=Br(t);return n.length===0?null:(0,Zr.jsx)(R,{flexDirection:`column`,paddingLeft:1,children:n.map(e=>(0,Zr.jsx)(Yr.Fragment,{children:e.render(t)},e.id))})}var Yr,Xr,Zr,Qr=t((()=>{Yr=n(B(),1),Xr=n(B(),1),V(),we(),it(),qr(),Zr=H()}));function $r(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)??si,[e]),()=>{let t=e.current;if(!t)return NaN;let n=t.getScrollTop()+t.getPendingDelta(),r=Math.floor(n/ri);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])??ei);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-ni),w=b;else{if(y){let e=v+ti;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-ti;{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*ti,y=Math.min(b,C+ai),S=0;for(w=C;w<y&&(S<h||x[w]<f+v+ti);)S+=r.current.get(t[w])??ii,w++}let e=v+2*ti,n=Math.max(0,w-ai),i=0;for(let e=C;e<w;e++)i+=r.current.get(t[e])??ii;for(;C>n&&i<e;)C--,i+=r.current.get(t[C])??ii;let o=d.current,c=Math.abs(g-a.current)+Math.abs(_);if(o&&c>v*2){let[e,t]=o;C<e-oi&&(C=e-oi),w>t+oi&&(w=t+oi),C>w&&(w=Math.min(C+oi,b))}a.current=g}f.current>0?f.current--:d.current=[C,w];let T=(0,q.useDeferredValue)(C),E=(0,q.useDeferredValue)(w),D=C<T?T:C,O=w>E?E:w;if((D>O||y)&&(D=C,O=w),_>0&&(O=w),O-D>ai){let e=(x[D]+x[O])/2;g-m.current<e?O=D+ai:D=O-ai}let ee=m.current,k=x[D],te=D===0?0:k+ee,ne=O===b?1/0:Math.max(k,x[O]-v)+ee;(0,q.useLayoutEffect)(()=>{y?e.current?.setClampBounds(void 0,void 0):e.current?.setClampBounds(te,ne)}),(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 re=(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},[]),ie=(0,q.useCallback)(e=>{let n=s.current.get(t[e])?.yogaNode;return!n||n.getComputedWidth()===0?-1:n.getComputedTop()},[t]),A=(0,q.useCallback)(e=>s.current.get(t[e])??null,[t]),j=(0,q.useCallback)(e=>r.current.get(t[e]),[t]),ae=(0,q.useCallback)(t=>{let n=o.current;t<0||t>=n.n||e.current?.scrollTo(n.arr[t]+m.current)},[e]),M=S-x[O];return{range:[D,O],topSpacer:k,bottomSpacer:M,measureRef:re,spacerRef:h,offsets:x,getItemTop:ie,getItemElement:A,getItemHeight:j,scrollToIndex:ae}}var q,ei,ti,ni,ri,ii,ai,oi,si,ci=t((()=>{q=n(B(),1),ei=3,ti=40,ni=30,ri=20,ii=1,ai=200,oi=25,si=()=>{}}));function li({children:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null);return(0,mi.jsx)(gi.Provider,{value:n,children:(0,mi.jsx)(vi.Provider,{value:i,children:(0,mi.jsx)(hi.Provider,{value:t,children:(0,mi.jsx)(_i.Provider,{value:r,children:e})})})})}function ui(){return(0,J.useContext)(hi)}function di(){return(0,J.useContext)(_i)}function fi(e){let t=(0,J.useContext)(gi);(0,J.useEffect)(()=>{if(t)return t(e),()=>t(null)},[t,e])}function pi(e){let t=(0,J.useContext)(vi);(0,J.useEffect)(()=>{if(t)return t(e),()=>t(null)},[t,e])}var J,mi,hi,gi,_i,vi,yi=t((()=>{J=n(B(),1),mi=H(),hi=(0,J.createContext)(null),gi=(0,J.createContext)(null),_i=(0,J.createContext)(null),vi=(0,J.createContext)(null)}));function bi(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 xi(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`&&!Si(t))continue;let a=t.type===`assistant`;a&&!r&&n++,r=a}return n}function Si(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 Ci(e,t){if(t===null)return;let n=t;for(;n<e.length&&(e[n]?.type===`progress`||Lr(e[n]));)n++;let r=e[n]?.uuid;if(!r)return;let i=xi(e,t);return{firstUnseenUuid:r,count:Math.max(1,i)}}function wi({scrollable:e,bottom:t,overlay:n,bottomFloat:r,modal:i,modalScrollRef:a,scrollRef:o,dividerYRef:s,hidePill:c=!1,hideSticky:l=!1,newMessageCount:u=0,onPillClick:d}){let{rows:f,columns:p}=Ve(),[m,h]=(0,Y.useState)(null),g=(0,Y.useMemo)(()=>({setStickyPrompt:h}),[]),_=(0,Y.useSyncExternalStore)((0,Y.useCallback)(e=>o?.current?.subscribe(e)??(()=>{}),[o]),()=>{let e=o?.current,t=s?.current;return!e||t==null?!1:e.getScrollTop()+e.getPendingDelta()+e.getViewportHeight()<t});if((0,Y.useLayoutEffect)(()=>{if(!j())return;let e=Le.get(process.stdout);if(e)return e.onHyperlinkClick=e=>{if(e.startsWith(`file:`))try{F(nn(e))}catch{}else ce(e)},()=>{e.onHyperlinkClick=void 0}},[]),j()){let s=l?null:m,h=s!=null&&s!==`clicked`&&n==null?s:null,v=s!=null&&n==null;return(0,X.jsxs)(li,{children:[(0,X.jsx)(R,{flexDirection:`row`,flexGrow:1,overflow:`hidden`,width:`100%`,children:(0,X.jsxs)(R,{flexDirection:`column`,flexGrow:1,width:p,overflow:`hidden`,children:[(0,X.jsxs)(R,{flexGrow:1,flexDirection:`column`,overflow:`hidden`,children:[h&&(0,X.jsx)(Ei,{text:h.text,onClick:h.scrollTo}),(0,X.jsxs)(Ue,{ref:o,flexGrow:1,flexDirection:`column`,paddingTop:+!v,stickyScroll:!0,children:[(0,X.jsx)(Ai,{value:g,children:e}),n]}),!c&&_&&n==null&&(0,X.jsx)(Ti,{count:u,onClick:d}),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)(Di,{}),(0,X.jsx)(Oi,{}),(0,X.jsx)(R,{flexDirection:`column`,width:`100%`,flexGrow:1,overflowY:`hidden`,children:t})]})]})}),i!=null&&(0,X.jsx)(Vt,{value:{rows:f-ki-1,columns:p-4,scrollRef:a??null},children:(0,X.jsxs)(R,{position:`absolute`,bottom:0,left:0,right:0,maxHeight:f-ki,flexDirection:`column`,overflow:`hidden`,opaque:!0,children:[(0,X.jsx)(R,{flexShrink:0,children:(0,X.jsx)(z,{color:`permission`,children:`▔`.repeat(p)})}),(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 Ti({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 ${mt(e,`message`)}`:`Jump to bottom`,` `,o.arrowDown,` `]})})})}function Ei({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:[o.pointer,` `,e]})})}function Di(){let e=ui();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)(It,{suggestions:e.suggestions,selectedSuggestion:e.selectedSuggestion,maxColumnWidth:e.maxColumnWidth,overlay:!0})})}function Oi(){let e=di();return e?(0,X.jsx)(R,{position:`absolute`,bottom:`100%`,left:0,right:0,opaque:!0,children:e}):null}var Y,X,ki,Ai,ji=t((()=>{a(),Y=n(B(),1),Bt(),yi(),x(),V(),he(),M(),ht(),zr(),Lt(),X=H(),ki=2,Ai=(0,Y.createContext)({setStickyPrompt:()=>{}})}));function Mi(e){let t=Bi.get(e);if(t!==void 0)return t;let n=_n(e);return Bi.set(e,n),n}function Ni(e){let t=Hi.get(e);if(t!==void 0)return t;let n=Pi(e);return Hi.set(e,n),n}function Pi(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(`
11
- `)}if(t===null)return null;let n=c(t);return n.startsWith(`<`)||n===``?null:n}function Fi({itemKey:e,msg:t,idx:n,measureRef:r,expanded:i,hovered:a,clickable:o,onClickK:s,onEnterK:c,onLeaveK:l,renderItem:u}){return(0,Ri.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,Ri.jsx)(Fe.Provider,{value:a&&!i?`text`:void 0,children:u(t,n)})})}function Ii({messages:e,scrollRef:t,columns:n,itemKey:r,renderItem:i,onItemClick:a,isItemClickable:o,isItemExpanded:s,extractSearchText:c=Mi,trackStickyPrompt:l,selectedIndex:u,cursorNavRef:d,setCursor:f,jumpRef:p,onSearchMatchesChange:m,scanElement:h,setPositions:g}){let _=(0,Z.useRef)([]),v=(0,Z.useRef)(e),y=(0,Z.useRef)(r);if(y.current!==r||e.length<_.current.length||e[0]!==v.current[0])_.current=e.map(e=>r(e));else for(let t=_.current.length;t<e.length;t++)_.current.push(r(e[t]));v.current=e,y.current=r;let b=_.current,{range:x,topSpacer:S,bottomSpacer:C,measureRef:w,spacerRef:T,offsets:E,getItemTop:D,getItemElement:O,getItemHeight:ee,scrollToIndex:k}=$r(t,b,n),[ne,re]=x,ie=(0,Z.useCallback)(t=>ee(t)!==0&&te(e[t]),[ee,e]);(0,Z.useImperativeHandle)(d,()=>{let n=e=>f?.({uuid:e.uuid,msgType:e.type,expanded:!1,toolName:ke(e)?.name}),r=u??-1,i=(t,r,i=ie)=>{for(let a=t;a>=0&&a<e.length;a+=r)if(i(a))return n(e[a]),!0;return!1},a=t=>ie(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(),f?.(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,f,ie]);let A=(0,Z.useRef)({offsets:E,start:ne,getItemElement:O,getItemTop:D,messages:e,scrollToIndex:k});A.current={offsets:E,start:ne,getItemElement:O,getItemTop:D,messages:e,scrollToIndex:k},(0,Z.useEffect)(()=>{if(u===void 0)return;let e=A.current,n=e.getItemElement(u);n?t.current?.scrollToElement(n,1):e.scrollToIndex(u)},[u,t]);let j=(0,Z.useRef)(null),ae=(0,Z.useRef)({msgIdx:-1,positions:[]}),M=(0,Z.useRef)(-1),oe=(0,Z.useRef)(0),N=(0,Z.useRef)(0),se=(0,Z.useRef)(()=>{}),ce=(0,Z.useRef)(()=>{}),P=(0,Z.useRef)({matches:[],ptr:0,screenOrd:0,prefixSum:[]}),le=(0,Z.useRef)(-1),ue=(0,Z.useRef)(!1);function de(e){let t=A.current.getItemTop(e);return Math.max(0,t-zi)}function fe(e){let n=t.current,{msgIdx:r,positions:i}=ae.current;if(!n||i.length===0||r<0){g?.(null);return}let a=Math.max(0,Math.min(e,i.length-1)),o=i[a],s=A.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-zi)),l=s-n.getScrollTop(),d=c+l+o.row),g?.({positions:i,rowOffset:c+l,currentIdx:a});let f=P.current,p=f.prefixSum.at(-1)??0,h=(f.prefixSum[f.ptr]??0)+a+1;m?.(p,h),Ye(`highlight(i=${r}, ord=${a}/${i.length}): pos={row:${o.row},col:${o.col}} lo=${l} screenRow=${d} badge=${h}/${p}`)}ce.current=fe;let[pe,me]=(0,Z.useState)(0),he=(0,Z.useCallback)(()=>me(e=>e+1),[]);(0,Z.useEffect)(()=>{let e=j.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}=A.current,l=o(n),u=l?.yogaNode?.getComputedHeight()??0;if(!l||u===0){if(i>1){j.current=null,Ye(`seek(i=${n}): no mount after scrollToIndex, skip`),se.current(r?-1:1);return}j.current={idx:n,wantLast:r,tries:i+1},c(n),he();return}j.current=null,a.scrollTo(Math.max(0,s(n)-zi));let d=h?.(l)??[];if(ae.current={msgIdx:n,positions:d},Ye(`seek(i=${n} t=${i}): ${d.length} positions`),d.length===0){if(++oe.current>20){oe.current=0;return}se.current(r?-1:1);return}oe.current=0;let f=r?d.length-1:0;P.current.screenOrd=f,M.current=-1,ce.current(f);let p=N.current;p&&(N.current=0,se.current(p))},[pe]);function ge(e,n){let r=t.current;if(!r)return;let i=A.current,{getItemElement:a,scrollToIndex:o}=i;if(e<0||e>=i.messages.length)return;g?.(null),ae.current={msgIdx:-1,positions:[]},j.current={idx:e,wantLast:n,tries:0};let s=a(e),c=s?.yogaNode?.getComputedHeight()??0;s&&c>0?r.scrollTo(de(e)):o(e),he()}function _e(e){let t=P.current,{matches:n,prefixSum:r}=t,i=r.at(-1)??0;if(n.length===0)return;if(j.current){N.current=e;return}M.current<0&&(M.current=t.ptr);let{positions:a}=ae.current,o=t.screenOrd+e;if(o>=0&&o<a.length){t.screenOrd=o,fe(o),M.current=-1;return}let s=(t.ptr+e+n.length)%n.length;if(s===M.current){g?.(null),M.current=-1,Ye(`step: wraparound at ptr=${s}, all ${n.length} msgs phantoms`);return}t.ptr=s,t.screenOrd=0,ge(n[s],e<0);let c=e<0?r[s+1]??i:r[s]+1;m?.(i,c)}se.current=_e,(0,Z.useImperativeHandle)(p,()=>({jumpToIndex:e=>{let n=t.current;n&&n.scrollTo(de(e))},setSearchQuery:e=>{j.current=null,ae.current={msgIdx:-1,positions:[]},M.current=-1,g?.(null);let n=e.toLowerCase(),r=[],i=[0];if(n){let e=A.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}=A.current,f=d(u),p=f>=0?f-l[u]:0;if(r.length>0&&s){let t=le.current>=0?le.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)}Ye(`setSearchQuery('${e}'): ${r.length} msgs · ptr=${o} msgIdx=${r[o]} curTop=${t} origin=${p}`)}P.current={matches:r,ptr:o,screenOrd:0,prefixSum:i},r.length>0?ge(r[o],!0):le.current>=0&&s&&s.scrollTo(le.current),m?.(a,r.length>0?i[o+1]??a:0)},nextMatch:()=>_e(1),prevMatch:()=>_e(-1),setAnchor:()=>{let e=t.current;e&&(le.current=e.getScrollTop())},disarmSearch:()=>{g?.(null),j.current=null,ae.current={msgIdx:-1,positions:[]},M.current=-1},warmSearchIndex:async()=>{if(ue.current)return 0;let e=A.current.messages,t=0,n=performance.now();for(let n=0;n<e.length;n+=500){await Tt(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 Ye(`warmSearchIndex: ${e.length} msgs · work=${Math.round(t)}ms wall=${r}ms chunks=${Math.ceil(e.length/500)}`),ue.current=!0,Math.round(t)}}),[t]);let[ve,ye]=(0,Z.useState)(null),be=(0,Z.useRef)({onItemClick:a,setHoveredKey:ye});be.current={onItemClick:a,setHoveredKey:ye};let xe=(0,Z.useCallback)((e,t)=>{let n=be.current;!t&&n.onItemClick&&n.onItemClick(e)},[]),Se=(0,Z.useCallback)(e=>{be.current.setHoveredKey(e)},[]),Ce=(0,Z.useCallback)(e=>{be.current.setHoveredKey(t=>t===e?null:t)},[]);return(0,Ri.jsxs)(Ri.Fragment,{children:[(0,Ri.jsx)(R,{ref:T,height:S,flexShrink:0}),e.slice(ne,re).map((e,t)=>{let n=ne+t,r=b[n],c=!!a&&(o?.(e)??!0),l=c&&ve===r,u=s?.(e);return(0,Ri.jsx)(Fi,{itemKey:r,msg:e,idx:n,measureRef:w,expanded:u,hovered:l,clickable:c,onClickK:xe,onEnterK:Se,onLeaveK:Ce,renderItem:i},r)}),C>0&&(0,Ri.jsx)(R,{height:C,flexShrink:0}),l&&(0,Ri.jsx)(Li,{messages:e,start:ne,end:re,offsets:E,getItemTop:D,getItemElement:O,scrollRef:t})]})}function Li({messages:e,start:t,end:n,offsets:r,getItemTop:i,getItemElement:a,scrollRef:o}){let{setStickyPrompt:s}=(0,Z.useContext)(Ai);(0,Z.useSyncExternalStore)((0,Z.useCallback)(e=>o.current?.subscribe(e)??Ui,[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=Ni(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,Vi).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,Ri,zi,Bi,Vi,Hi,Ui,Wi=t((()=>{B(),Z=n(B(),1),ci(),V(),re(),ji(),Ri=H(),Xe(),Ct(),wn(),Ae(),zi=3,Bi=new WeakMap,Vi=500,Hi=new WeakMap,Ui=()=>{}}));function Gi(e,t,n=$i,r=ea){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 Ki(e){return(e.type===`assistant`||e.type===`user`?E(e):null)??e.uuid}function qi(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ji(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=E(e);return i?t.has(i)||n.has(i)||ee(i,`PostToolUse`,a)?!1:rn(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 Yi,Q,$,Xi,Zi,Qi,$i,ea,ta,na,ra=t((()=>{Re(),Yi=n(B(),1),Q=n(B(),1),an(),Ge(),et(),x(),V(),l(),Et(),ue(),cn(),dn(),ae(),it(),i(),M(),gn(),I(),ht(),wn(),br(),u(),Ir(),Ae(),Me(),zr(),O(),Qr(),$=H(),Wi(),Xi=Yi.memo(function({agentDefinitions:e}){return(0,$.jsx)(N,{children:(0,$.jsxs)(R,{flexDirection:`column`,gap:1,children:[(0,$.jsx)(_r,{}),(0,$.jsx)(Yi.Suspense,{fallback:null,children:(0,$.jsx)(Jr,{agentDefinitions:e})})]})})}),Zi=(Mt(),e(Nt)),Qi=30,$i=200,ea=50,ta=({messages:e,tools:t,commands:n,verbose:i,toolJSX:a,toolUseConfirmQueue:o,inProgressToolUseIDs:c,isMessageSelectorVisible:l,conversationId:u,screen:d,streamingToolUses:m,showAllInTranscript:h=!1,agentDefinitions:_,hideLogo:v=!1,isLoading:y,hidePastThinking:b=!1,streamingThinking:x,streamingText:S,unseenDivider:C,scrollRef:w,trackStickyPrompt:E,jumpRef:D,onSearchMatchesChange:O,scanElement:ee,setPositions:k,disableRenderCap:te=!1,cursor:re=null,setCursor:ae,cursorNavRef:M,renderRange:N})=>{let{columns:se}=Ve(),ce=T(`transcript:toggleShowAll`,`Transcript`,`Ctrl+E`),P=(0,Q.useMemo)(()=>xe(e).filter(g),[e]),ue=(0,Q.useMemo)(()=>x?x.isStreaming?!0:x.streamingEndedAt?Date.now()-x.streamingEndedAt<3e4:!1:!1,[x]),{lastThinkingBlockId:fe,latestBashOutputUUID:he}=(0,Q.useMemo)(()=>{let e=null,t=null,n=b&&!ue;b&&ue&&(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 b||(e=null),{lastThinkingBlockId:e,latestBashOutputUUID:t}},[P,b,ue]),ge=(0,Q.useMemo)(()=>p(P),[P]),ve=(0,Q.useMemo)(()=>m.filter(e=>!c.has(e.contentBlock.id)&&!ge.has(e.contentBlock.id)),[m,c,ge]),be=(0,Q.useMemo)(()=>ve.flatMap(e=>{let t=_e({content:[e.contentBlock]});return t.uuid=ne(e.contentBlock.id,0),xe([t])}),[ve]),Se=d===`transcript`,Ce=(0,Q.useMemo)(()=>r(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]),we=w!=null&&!Ce,Te=Se&&!h&&!we,Ee=(0,Q.useRef)(null),F=(0,Q.useRef)(null),{collapsed:ke,lookups:Ae,hasTruncatedMessages:je,hiddenMessageCount:Me}=(0,Q.useMemo)(()=>{let e=A((i||j()?P:ye(P,{includeSnipped:!0})).filter(e=>e.type!==`progress`&&!Lr(e)&&oe(e,Se)),be),n=Te?e.slice(-30):e,r=Te&&e.length>Qi,{messages:a}=mn(n,t,i),o=sn(un(ie(a,t)),i),c=me(P,n),l=(()=>{let e=n.at(-1);return e?.type===`assistant`?e.message?.id:void 0})(),u;if(F.current&&F.current.key===c)u=F.current.lookups;else if(F.current&&P.length>=F.current.normalizedCount&&n.length>=F.current.messageCount&&F.current.lastAssistantMsgId===l){let e=s(F.current.lookups,F.current.normalizedCount,F.current.messageCount,P,n);e?(u=e,F.current={key:c,lookups:u,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:l}):(u=de(P,n),F.current={key:c,lookups:u,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:l})}else u=de(P,n),F.current={key:c,lookups:u,normalizedCount:P.length,messageCount:n.length,lastAssistantMsgId:l};let d=e.length-Qi;return{collapsed:o,lookups:u,hasTruncatedMessages:r,hiddenMessageCount:d}},[i,P,Se,be,Te,t]),I=(0,Q.useMemo)(()=>{let e=!we&&!te?Gi(ke,Ee):0;return N?ke.slice(N[0],N[1]):e>0?ke.slice(e):ke},[ke,N,we,te]),Ne=(0,Q.useMemo)(()=>new Set(m.map(e=>e.contentBlock.id)),[m]),{dividerBeforeIndex:L,selectedIdx:Fe}=(0,Q.useMemo)(()=>{if(!C&&!re)return{dividerBeforeIndex:-1,selectedIdx:-1};let e=-1,t=-1,n=C?.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&&re&&i.uuid===re.uuid&&(t=r),e!==-1&&t!==-1)break}return{dividerBeforeIndex:e,selectedIdx:t}},[C,re,I]),[Le,Re]=(0,Q.useState)(()=>new Set),B=(0,Q.useCallback)(e=>{let t=Ki(e);Re(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),ze=(0,Q.useCallback)(e=>Le.size>0&&Le.has(Ki(e)),[Le]),Be=(0,Q.useRef)(Ae);Be.current=Ae;let V=(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&&pe(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=Be.current.toolUseByToolUseID.get(n.tool_use_id??``)?.name;return(r?Dt(t,r):void 0)?.isResultTruncated?.(e.toolUseResult)??!1},[t]),Ue=(!a||!!a.shouldContinueAnimation)&&!o.length&&!l,H=c.size>0,{progress:Ge}=Ie(),Ke=(0,Q.useRef)(null),qe=rt().terminalProgressBarEnabled&&!We()&&!(Zi?.isProactiveActive()??!1);(0,Q.useEffect)(()=>{let e=qe?H?`indeterminate`:`completed`:null;Ke.current!==e&&(Ke.current=e,Ge(e))},[Ge,qe,H]),(0,Q.useEffect)(()=>()=>Ge(null),[Ge]);let Je=(0,Q.useCallback)(e=>`${e.uuid}-${u}`,[u]),Ye=(e,r)=>{let a=r>0?I[r-1]?.type:void 0,o=e.type===`user`&&a===`user`,s=e.type===`collapsed_read_search`&&(!!S||Dr(I,r,t,Ne)),l=I.length-1-r>0,u=Je(e),f=(0,$.jsx)(Fr,{message:e,isUserContinuation:o,hasContentAfter:s,tools:t,commands:n,verbose:i||ze(e)||re?.expanded===!0&&r===Fe,inProgressToolUseIDs:c,streamingToolUseIDs:Ne,screen:d,canAnimate:Ue,lastThinkingBlockId:fe,latestBashOutputUUID:he,columns:se,isLoading:y,lookups:Ae,shouldCollapseDiffs:l},u),p=(0,$.jsx)(le.Provider,{value:r===Fe,children:f},u);return C&&r===L?[(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(Pe,{title:`${C.count} new ${mt(C.count,`message`)}`,width:se,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=_n(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=Ae.toolUseByToolUseID.get(n.tool_use_id),a=(i&&Dt(t,i.name))?.extractSearchText?.(e.toolUseResult);a!==void 0&&(r=a)}}let i=r.toLowerCase();return Xe.current.set(e,i),i},[t,Ae]);return(0,$.jsxs)($.Fragment,{children:[!v&&!(N&&N[0]>0)&&(0,$.jsx)(Xi,{agentDefinitions:_}),je&&(0,$.jsx)(Pe,{title:`${ce} to show ${He.bold(Me)} previous messages`,width:se}),Se&&h&&Me>0&&!te&&(0,$.jsx)(Pe,{title:`${ce} to hide ${He.bold(Me)} previous messages`,width:se}),we?(0,$.jsx)(De.Provider,{value:!0,children:(0,$.jsx)(Ii,{messages:I,scrollRef:w,columns:se,itemKey:Je,renderItem:Ye,onItemClick:B,isItemClickable:V,isItemExpanded:ze,trackStickyPrompt:E,selectedIndex:Fe>=0?Fe:void 0,cursorNavRef:M,setCursor:ae,jumpRef:D,onSearchMatchesChange:O,scanElement:ee,setPositions:k,extractSearchText:Ze})}):I.flatMap(Ye),S&&(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)(f,{children:S})})]})}),ue&&x&&(0,$.jsx)(R,{marginTop:1,children:(0,$.jsx)(Oe,{param:{type:`thinking`,thinking:x.thinking},addMargin:!1,isTranscriptMode:!0,verbose:i,hideInTranscript:!1})})]})},na=Yi.memo(ta,(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`&&qi(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{ji as a,fi as c,Ci as i,pi as l,ra as n,bi as o,wi as r,yi as s,na as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,fi as r,t as i}from"./src-P_wYS_NJ2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";function o({title:e,subtitle:r,color:i=`permission`}){return(0,s.jsxs)(t,{flexDirection:`column`,children:[(0,s.jsx)(t,{flexDirection:`row`,gap:1,children:(0,s.jsx)(n,{bold:!0,color:i,children:e})}),r!=null&&(typeof r==`string`?(0,s.jsx)(n,{dimColor:!0,wrap:`truncate-start`,children:r}):r)]})}var s,c=e((()=>{r(),i(),s=a()}));function l({title:e,subtitle:n,color:r=`permission`,titleColor:i,innerPaddingX:a=1,titleRight:s,children:c}){return(0,u.jsxs)(t,{flexDirection:`column`,borderStyle:`round`,borderColor:r,borderLeft:!1,borderRight:!1,borderBottom:!1,marginTop:1,children:[(0,u.jsx)(t,{paddingX:1,flexDirection:`column`,children:(0,u.jsxs)(t,{justifyContent:`space-between`,children:[(0,u.jsx)(o,{title:e,subtitle:n,color:i}),s]})}),(0,u.jsx)(t,{flexDirection:`column`,paddingX:a,children:c})]})}var u,d=e((()=>{r(),i(),c(),u=a()}));export{c as i,d as n,o as r,l as t};