@readmagic/workmate 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DgAxYgBY.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-DGMRVexR.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-Dp6CwZyI.js +1 -0
  4. package/dist/chunks/App-VWyPd524.js +1 -0
  5. package/dist/chunks/ApproveApiKey-Bolw0sPs.js +1 -0
  6. package/dist/chunks/ApproveApiKey-CyNPMd6g.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-DxagIOOw.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-OS2S66zQ.js +1 -0
  9. package/dist/chunks/{DiffDialog-6Srcz3NW.js → DiffDialog-CMtml9iw.js} +3 -3
  10. package/dist/chunks/Doctor-Bk9P37mU.js +1 -0
  11. package/dist/chunks/Doctor-D9F3tKsr.js +3 -0
  12. package/dist/chunks/ExitFlow-DhRv5JPj.js +2 -0
  13. package/dist/chunks/{Grove-DC4jyxeB.js → Grove-Bbh8PpH0.js} +1 -1
  14. package/dist/chunks/{HybridTransport-DArmWb1V.js → HybridTransport-P1vEUwhv.js} +1 -1
  15. package/dist/chunks/InvalidConfigDialog-xAYpE-20.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-CXFSISy3.js +1 -0
  17. package/dist/chunks/MCPConnectionManager-CoId-C__.js +1 -0
  18. package/dist/chunks/MCPToolListView-BQkQ-hyF.js +1 -0
  19. package/dist/chunks/McpParsingWarnings-6ENzOklf.js +1 -0
  20. package/dist/chunks/MessageSelector-BvRVrfg6.js +3 -0
  21. package/dist/chunks/Messages-Cykztq1O.js +10 -0
  22. package/dist/chunks/Onboarding-CfeRwPNQ.js +1 -0
  23. package/dist/chunks/PermissionDialog-BaibiQae.js +1 -0
  24. package/dist/chunks/PressEnterToContinue-DZc_s_pE.js +1 -0
  25. package/dist/chunks/PromptInputFooterSuggestions-Blzgj5yW.js +1 -0
  26. package/dist/chunks/PromptInputHelpMenu-Ckp0k8E3.js +1 -0
  27. package/dist/chunks/QueryEngine-DduzztIG.js +1 -0
  28. package/dist/chunks/REPL-B8e5UU3H.js +128 -0
  29. package/dist/chunks/REPL-C4mbOhyL.js +1 -0
  30. package/dist/chunks/{RemoteSessionManager-CRWOHvKf.js → RemoteSessionManager-BPESC6Wu.js} +2 -2
  31. package/dist/chunks/ResumeConversation-DG1sLryB.js +1 -0
  32. package/dist/chunks/{SSETransport-pPrlSZNF.js → SSETransport-CDNP2PlK.js} +1 -1
  33. package/dist/chunks/{SearchBox-CwwV0W-w.js → SearchBox-C9xxQzh1.js} +1 -1
  34. package/dist/chunks/SearchExtraToolsTool-vK2PP628.js +1 -0
  35. package/dist/chunks/Settings-B7n_dfP-.js +2 -0
  36. package/dist/chunks/TeleportProgress-QL3ibQfK.js +1 -0
  37. package/dist/chunks/TeleportRepoMismatchDialog-f-xl7biD.js +1 -0
  38. package/dist/chunks/TeleportResumeWrapper-DzVcrFuP.js +1 -0
  39. package/dist/chunks/ThemePicker-CIFKZza0.js +1 -0
  40. package/dist/chunks/TrustDialog-C0HEwZPk.js +1 -0
  41. package/dist/chunks/{ValidationErrorsList-BfZ5gcIv.js → ValidationErrorsList-2QWIs_6h.js} +1 -1
  42. package/dist/chunks/add-dir-DmEhPnvj.js +1 -0
  43. package/dist/chunks/{agentDisplay-D01ZlnVX.js → agentDisplay-1Y-N-gqz.js} +1 -1
  44. package/dist/chunks/{agents-Bxenhf8S.js → agents-CvW8XjoJ.js} +1 -1
  45. package/dist/chunks/agents-D96ng5I9.js +101 -0
  46. package/dist/chunks/allErrors-CT2dbBF3.js +1 -0
  47. package/dist/chunks/{api-C5ULzZny.js → api-DTyrmy1O.js} +1 -1
  48. package/dist/chunks/api-DumFOErN.js +1 -0
  49. package/dist/chunks/{auth-DvcZHXGk.js → auth-CZ4EsFWF.js} +1 -1
  50. package/dist/chunks/auth-QvonHoG9.js +1 -0
  51. package/dist/chunks/auth-jV5THRH8.js +1 -0
  52. package/dist/chunks/backgroundHousekeeping-C72oPgfD.js +17 -0
  53. package/dist/chunks/backgroundHousekeeping-D9PScHES.js +1 -0
  54. package/dist/chunks/{banner-BkUdig-T.js → banner-ChT5Ri7Q.js} +1 -1
  55. package/dist/chunks/{bg-tGgpwpYx.js → bg-qG2osBbP.js} +2 -2
  56. package/dist/chunks/{branch-CqQxCSHG.js → branch-K8X6jx0i.js} +1 -1
  57. package/dist/chunks/{break-cache-CcwOjTKt.js → break-cache-BZ_UMtEL.js} +1 -1
  58. package/dist/chunks/{bridgeConfig-MxsnEEPx.js → bridgeConfig-C-bI-slm.js} +1 -1
  59. package/dist/chunks/bridgeConfig-_xpxhGB5.js +1 -0
  60. package/dist/chunks/{bridgeMessaging-Bx5pkkkx.js → bridgeMessaging-DSJlYarJ.js} +1 -1
  61. package/dist/chunks/{bridgeStatusUtil-B9EcQksI.js → bridgeStatusUtil-DaEq5c69.js} +1 -1
  62. package/dist/chunks/btw-BNs5OX7x.js +1 -0
  63. package/dist/chunks/caches-CC5NHwAz.js +1 -0
  64. package/dist/chunks/caches-nHxJWXgO.js +1 -0
  65. package/dist/chunks/{ccrClient-CimQTd0b.js → ccrClient-JnhF5b3z.js} +1 -1
  66. package/dist/chunks/{clear-KvoD-lFN.js → clear-D2KRoibg.js} +1 -1
  67. package/dist/chunks/client-BtTkq0YS.js +1 -0
  68. package/dist/chunks/commands-C_rYjyQZ.js +1 -0
  69. package/dist/chunks/compact-Cqd6vKpn.js +2 -0
  70. package/dist/chunks/config-Be0BkAAr.js +1 -0
  71. package/dist/chunks/{config-DRy1I12M.js → config-DUTgj3js.js} +1 -1
  72. package/dist/chunks/{config-e0Goy478.js → config-DoEDgAfv.js} +1 -1
  73. package/dist/chunks/context-Db9tH1VF.js +1 -0
  74. package/dist/chunks/{context-noninteractive-ApbVPU86.js → context-noninteractive-CacA9VlT.js} +2 -2
  75. package/dist/chunks/context-noninteractive-D9tJYwi7.js +1 -0
  76. package/dist/chunks/conversation-DWfE4KGH.js +1 -0
  77. package/dist/chunks/conversation-Tvo4EDpQ.js +1 -0
  78. package/dist/chunks/convert-legacy-node-http-options-BZnGSjx2.js +1 -0
  79. package/dist/chunks/{createSSHSession-DOz_Ox1_.js → createSSHSession-BQ83MMtr.js} +1 -1
  80. package/dist/chunks/createSession-CqHnHhCR.js +1 -0
  81. package/dist/chunks/{createSession-yR87Rhiv.js → createSession-DqTtBycR.js} +1 -1
  82. package/dist/chunks/crossProjectResume-DIXtiODF.js +40 -0
  83. package/dist/chunks/{datadog-DBgIEaEd.js → datadog-BuElf2EQ.js} +1 -1
  84. package/dist/chunks/detectRepository-DUJBh5s2.js +1 -0
  85. package/dist/chunks/{detectRepository-CDOJ-M7h.js → detectRepository-pRAVv8SH.js} +1 -1
  86. package/dist/chunks/{diff-qOom_T1G.js → diff-yA6v_dpP.js} +1 -1
  87. package/dist/chunks/{directoryCompletion-BDGcGDuv.js → directoryCompletion-CuA3_YIT.js} +1 -1
  88. package/dist/chunks/doctor-eNAm6OiS.js +1 -0
  89. package/dist/chunks/{entry-EmOA7oWN.js → entry-DidpiR-D.js} +5 -5
  90. package/dist/chunks/esm-0CwQE5CJ.js +10 -0
  91. package/dist/chunks/esm-BCUC71kt.js +1 -0
  92. package/dist/chunks/esm-BCmY8V0C.js +1 -0
  93. package/dist/chunks/esm-BUJtY-Rb.js +1 -0
  94. package/dist/chunks/esm-BadZVa27.js +1 -0
  95. package/dist/chunks/esm-BbMeEYcz.js +1 -0
  96. package/dist/chunks/esm-sVMjGuep.js +1 -0
  97. package/dist/chunks/execFileNoThrow-B_KRY4cT.js +34 -0
  98. package/dist/chunks/exit-DywUeiYd.js +1 -0
  99. package/dist/chunks/extraUsage-DiAirtuk.js +1 -0
  100. package/dist/chunks/extractMemories-_xiTnX95.js +1 -0
  101. package/dist/chunks/fast-DCXZACT9.js +1 -0
  102. package/dist/chunks/fast-Qo4WVqiW.js +1 -0
  103. package/dist/chunks/{fetchModelList-BbjuFHQT.js → fetchModelList-fQDsmR3E.js} +1 -1
  104. package/dist/chunks/fetchModelList-woVzIVde.js +1 -0
  105. package/dist/chunks/{fileSuggestions-Ct7vKEpR.js → fileSuggestions-CRx1D6uk.js} +3 -3
  106. package/dist/chunks/firstPartyEventLogger-B261Wksn.js +3 -0
  107. package/dist/chunks/firstPartyEventLogger-DtFTeHy-.js +1 -0
  108. package/dist/chunks/{flushGate-BZe_QwEz.js → flushGate-BA8dSr0i.js} +1 -1
  109. package/dist/chunks/fpsMetrics-wxj9GAsd.js +1 -0
  110. package/dist/chunks/{gemini-8sSwOtEf.js → gemini-BXAyy1JN.js} +1 -1
  111. package/dist/chunks/generateSessionName-Cwmk2N3F.js +1 -0
  112. package/dist/chunks/{genericProcessUtils-6E7fB1dI.js → genericProcessUtils-Cnyun_Wr.js} +3 -3
  113. package/dist/chunks/{git-By_J4XJL.js → git-Wid-XppW.js} +1 -1
  114. package/dist/chunks/git-hO-TMvXc.js +1 -0
  115. package/dist/chunks/{githubRepoPathMapping-CzgPGOHQ.js → githubRepoPathMapping-OV8U1VFK.js} +1 -1
  116. package/dist/chunks/goal-C9clrwEH.js +3 -0
  117. package/dist/chunks/{grok-cEzUsG-s.js → grok-CjeCecsZ.js} +1 -1
  118. package/dist/chunks/{grove--HtQL4QZ.js → grove-DqTnK9nn.js} +2 -2
  119. package/dist/chunks/help-Bb6LdzXK.js +1 -0
  120. package/dist/chunks/{hooks-CN5hLrhi.js → hooks-BDgToO1Z.js} +2 -2
  121. package/dist/chunks/hooks-BX2s7aoL.js +1 -0
  122. package/dist/chunks/{initReplBridge-BJhmlcVt.js → initReplBridge-D7cuY_os.js} +1 -1
  123. package/dist/chunks/install-eCA8UACi.js +1 -0
  124. package/dist/chunks/{instrumentation-DpgB3GFx.js → instrumentation-BaRKojJh.js} +6 -6
  125. package/dist/chunks/{job-DDoX1iFe.js → job-DYMfSglZ.js} +1 -1
  126. package/dist/chunks/{jwtUtils-C_LG1txt.js → jwtUtils-JE2okZ70.js} +1 -1
  127. package/dist/chunks/keybindings-iBqc1KHL.js +1 -0
  128. package/dist/chunks/launchLocalMemory-IZPGEzMk.js +3 -0
  129. package/dist/chunks/launchOnboarding-BeNf51Ig.js +8 -0
  130. package/dist/chunks/loadAgentsDir-Bpke9CtB.js +1 -0
  131. package/dist/chunks/{loadAgentsDir-DXOkUcW3.js → loadAgentsDir-C96o6gCj.js} +601 -626
  132. package/dist/chunks/loadPluginHooks-0nGlugZ4.js +1 -0
  133. package/dist/chunks/{localSearch-DnT21UkF.js → localSearch-DLz5IGGu.js} +1 -1
  134. package/dist/chunks/localSearch-dodgnjGn.js +1 -0
  135. package/dist/chunks/logoUtils-Cg_6QV1Z.js +1 -0
  136. package/dist/chunks/{magicDocs-rxv0rR8E.js → magicDocs-DmPNMnNY.js} +2 -2
  137. package/dist/chunks/{main-Blm02_Js.js → main-7ssnA9Yb.js} +2 -2
  138. package/dist/chunks/{main-BOvY4O6D.js → main-BEv6MqMX.js} +34 -34
  139. package/dist/chunks/{managedEnv-CpgCYISH.js → managedEnv-CHYvwXBH.js} +1 -1
  140. package/dist/chunks/managedEnv-CbjOQmEe.js +1 -0
  141. package/dist/chunks/mappers-D8VLUZ2N.js +1 -0
  142. package/dist/chunks/mcp-BUn3yqsT.js +1 -0
  143. package/dist/chunks/mcp-BskLq9iP.js +2 -0
  144. package/dist/chunks/mcp-C-0DMaXx.js +6 -0
  145. package/dist/chunks/memory-vDkJM58W.js +1 -0
  146. package/dist/chunks/modalContext-DDZdU1J8.js +1 -0
  147. package/dist/chunks/mode-Dbh21H2Y.js +2 -0
  148. package/dist/chunks/model-BaMclMXn.js +1 -0
  149. package/dist/chunks/model-atn3_JBi.js +1 -0
  150. package/dist/chunks/model-vS1Iewyq.js +1 -0
  151. package/dist/chunks/{modelOptions-BqBHEyiR.js → modelOptions-Cw1ThINb.js} +1 -1
  152. package/dist/chunks/{src-l6_O0K-a.js → modifiersNative-BYHdmWw1.js} +1 -1
  153. package/dist/chunks/modifiersNative-D7nm70eq.js +1 -0
  154. package/dist/chunks/nativeInstaller-CfZ5uNTh.js +1 -0
  155. package/dist/chunks/omit-B7eQ9q0x.js +1 -0
  156. package/dist/chunks/{onChangeAppState-qHXqufwy.js → onChangeAppState-kEAt8nxV.js} +1 -1
  157. package/dist/chunks/{openai-_FQ9EhuR.js → openai-wh8AX5iz.js} +3 -3
  158. package/dist/chunks/panel-Cm23FDVt.js +1 -0
  159. package/dist/chunks/{partition-BgwHlPsO.js → partition-CENvOfiS.js} +1 -1
  160. package/dist/chunks/permissions-ChuIx-d4.js +3 -0
  161. package/dist/chunks/{pidLock-CEhbTkBE.js → pidLock-C1hmh3YQ.js} +2 -2
  162. package/dist/chunks/plan-s228H7IU.js +1 -0
  163. package/dist/chunks/plugin-DVBEWwMP.js +17 -0
  164. package/dist/chunks/{pluginAutoupdate-C2YbEHrP.js → pluginAutoupdate-aLXhSUVD.js} +1 -1
  165. package/dist/chunks/pluginBlocklist-BprCv0En.js +1 -0
  166. package/dist/chunks/pluginCliCommands-WzzqR1Sr.js +1 -0
  167. package/dist/chunks/{pluginFlagging-BDTgCYuC.js → pluginFlagging-BSLuTk3M.js} +1 -1
  168. package/dist/chunks/pluginOperations-Ca9Lup5G.js +2 -0
  169. package/dist/chunks/pluginStartupCheck-DdtxcNwH.js +1 -0
  170. package/dist/chunks/{pluginStartupCheck-DhhMk3dA.js → pluginStartupCheck-xQbHZ5gf.js} +1 -1
  171. package/dist/chunks/plugins-DdIaXpNb.js +4 -0
  172. package/dist/chunks/{poorMode-CKQfWf3S.js → poorMode-Bt_A2arj.js} +1 -1
  173. package/dist/chunks/poorMode-ZIq2oz7q.js +1 -0
  174. package/dist/chunks/print-vxrRE1O2.js +14 -0
  175. package/dist/chunks/processBashCommand-ISucgwpi.js +1 -0
  176. package/dist/chunks/processSlashCommand-BnpXO_fI.js +5 -0
  177. package/dist/chunks/prompt-2AA5W7EH.js +1 -0
  178. package/dist/chunks/prompt-AXiS2LoO.js +1 -0
  179. package/dist/chunks/{prompt-DEioJrx_.js → prompt-BNNE5tsG.js} +1 -1
  180. package/dist/chunks/promptEditor-DT6egmcb.js +4 -0
  181. package/dist/chunks/{protocolHandler-C-CFTcUJ.js → protocolHandler-DukQ6b4Q.js} +2 -2
  182. package/dist/chunks/{reconciler-DZP4dJJG.js → reconciler-D3zyJCnV.js} +1 -1
  183. package/dist/chunks/refresh-BSG0t4cf.js +1 -0
  184. package/dist/chunks/registerProtocol-BOEYaX-X.js +1 -0
  185. package/dist/chunks/{reload-plugins-m9CzoIxu.js → reload-plugins-BFMRhbv8.js} +1 -1
  186. package/dist/chunks/{remoteBridgeCore-C4vSr1gp.js → remoteBridgeCore-D5OwvmAz.js} +1 -1
  187. package/dist/chunks/{remoteManagedSettings-6RAHPt_g.js → remoteManagedSettings-DyGVvvcW.js} +1 -1
  188. package/dist/chunks/rename-BrEwj3Xw.js +1 -0
  189. package/dist/chunks/resume-DR5JbICs.js +2 -0
  190. package/dist/chunks/{ripgrep-C3jtZL7k.js → ripgrep-Dt4a91S5.js} +1 -1
  191. package/dist/chunks/ripgrep-KTOU5s9J.js +1 -0
  192. package/dist/chunks/{runtimeObserver-C2vjqtCE.js → runtimeObserver-CsZw5XBt.js} +2 -2
  193. package/dist/chunks/{runtimeObserver-CSroopId.js → runtimeObserver-DS1PK6We.js} +1 -1
  194. package/dist/chunks/sandbox-adapter-BqDyWcol.js +1 -0
  195. package/dist/chunks/sandbox-toggle-B9f_0NQI.js +1 -0
  196. package/dist/chunks/sanitization-DV-94a9Z.js +1 -0
  197. package/dist/chunks/searchExtraTools-2pIT2C8u.js +1 -0
  198. package/dist/chunks/session-wkRTfdo8.js +2 -0
  199. package/dist/chunks/sessionFileAccessHooks-DV22q9JO.js +1 -0
  200. package/dist/chunks/sessionObserver-BLJg0qm_.js +1 -0
  201. package/dist/chunks/{sessionObserver-iAJLH92a.js → sessionObserver-N7fORFdL.js} +2 -2
  202. package/dist/chunks/{sessionState-DAcub-HK.js → sessionState-8jutEorw.js} +1 -1
  203. package/dist/chunks/sessionStorage-DRV7IhZF.js +1 -0
  204. package/dist/chunks/sessionTracing-fIp8g04N.js +11 -0
  205. package/dist/chunks/{settings-3xZ0fsvE.js → settings-BowI3jp-.js} +2 -2
  206. package/dist/chunks/settings-CHn0gJCG.js +1 -0
  207. package/dist/chunks/settingsSync-DF4JgSNc.js +1 -0
  208. package/dist/chunks/setup-UiEO9i7F.js +3 -0
  209. package/dist/chunks/{shadowedRuleDetection-BL7dEv-u.js → shadowedRuleDetection-DEo1hvGi.js} +1 -1
  210. package/dist/chunks/{sideQuestion-Ct87yvOR.js → sideQuestion-C11KgNGL.js} +3 -3
  211. package/dist/chunks/sinks-DnLqRPEC.js +1 -0
  212. package/dist/chunks/{sinks-Bmn3li0M.js → sinks-mGBiINp8.js} +1 -1
  213. package/dist/chunks/skillChangeDetector-Dc6YZXJE.js +1 -0
  214. package/dist/chunks/{skillGapStore-MtlRyYmT.js → skillGapStore-H4MkUFUY.js} +2 -2
  215. package/dist/chunks/{skillLifecycle-Drs6gEv9.js → skillLifecycle-ADUTDK7D.js} +2 -2
  216. package/dist/chunks/{skillSearchPanel-DkvmjNaw.js → skillSearchPanel-PpfVDMGR.js} +2 -2
  217. package/dist/chunks/skills-DKtN17ch.js +1 -0
  218. package/dist/chunks/src-9vmGsuSI.js +1 -0
  219. package/dist/chunks/{src-CgZmCiiH.js → src-BacxF9BD.js} +2 -2
  220. package/dist/chunks/{startupProfiler-CbzxVmbv.js → startupProfiler-B90b5vuq.js} +1 -1
  221. package/dist/chunks/startupProfiler-DG2TN5R_.js +1 -0
  222. package/dist/chunks/staticRender-BVWx0IM1.js +1 -0
  223. package/dist/chunks/stats-D4LEtkrw.js +1 -0
  224. package/dist/chunks/status-0ZBx6Ls0.js +2 -0
  225. package/dist/chunks/status-BUJ4-omB.js +1 -0
  226. package/dist/chunks/{statusNoticeHelpers-BrN_2q7H.js → statusNoticeHelpers-BrpQWj0l.js} +1 -1
  227. package/dist/chunks/{stringUtils-CKD8qDqx.js → stringUtils-D7oJIyY2.js} +1 -1
  228. package/dist/chunks/switcher-D7Ey5uIi.js +1 -0
  229. package/dist/chunks/{switcher-99gm2vpe.js → switcher-DWfKi17X.js} +1 -1
  230. package/dist/chunks/{syncCache-B3OVvp8K.js → syncCache-DUhciJLz.js} +1 -1
  231. package/dist/chunks/{tasks-t5zT_D32.js → tasks-BwSsj2vI.js} +1 -1
  232. package/dist/chunks/teleport-DwZMevmQ.js +1 -0
  233. package/dist/chunks/{templateJobs-Bm8bovHx.js → templateJobs-fiKuu4DK.js} +1 -1
  234. package/dist/chunks/{terminalSetup-7PdC4fV5.js → terminalSetup-Cte5a4hM.js} +1 -1
  235. package/dist/chunks/{terminalSetup-kWdZRKWq.js → terminalSetup-a7-BNS4T.js} +1 -1
  236. package/dist/chunks/theme-CAoGjf2D.js +1 -0
  237. package/dist/chunks/{tmux-CpGd0Aca.js → tmux-DA06aewY.js} +1 -1
  238. package/dist/chunks/{toolEventObserver-C_nHI27x.js → toolEventObserver-Cq_ZV7x9.js} +1 -1
  239. package/dist/chunks/toolPool-mdsxlKWR.js +1 -0
  240. package/dist/chunks/{trustedDevice-Bb7O8_tj.js → trustedDevice-C1m--Yjw.js} +1 -1
  241. package/dist/chunks/trustedDevice-CeDIk_ln.js +1 -0
  242. package/dist/chunks/{udsClient-U7MEfYj7.js → udsClient-BcwsY0XE.js} +1 -1
  243. package/dist/chunks/useExitOnCtrlCDWithKeybindings-L5idX6Kz.js +1 -0
  244. package/dist/chunks/useMainLoopModel-VXeS2EC6.js +1 -0
  245. package/dist/chunks/useManagePlugins-CAXp5CfH.js +1 -0
  246. package/dist/chunks/useMergedTools-DYXrPTIA.js +1 -0
  247. package/dist/chunks/useSearchInput-Bxl4wGcZ.js +1 -0
  248. package/dist/chunks/useSettingsErrors-sbjsaT7k.js +1 -0
  249. package/dist/chunks/{userAgent-CJ5Rp9kc.js → userAgent-NbKd-hN7.js} +1 -1
  250. package/dist/chunks/util-DU63xTwZ.js +1 -0
  251. package/dist/chunks/validatePlugin-DQ_9OCpP.js +1 -0
  252. package/dist/chunks/{vim-BagKUX4j.js → vim-xruiCyUd.js} +1 -1
  253. package/dist/chunks/which-B8rchd8P.js +1 -0
  254. package/dist/chunks/{workerRegistry-BGJtgrko.js → workerRegistry-BBgquE8F.js} +2 -2
  255. package/dist/chunks/worktree-C28I8mFB.js +1 -0
  256. package/dist/cli.js +1 -1
  257. package/package.json +3 -25
  258. package/dist/chunks/AddWorkspaceDirectory-9FcHMKgX.js +0 -1
  259. package/dist/chunks/AgentsMdExternalIncludesDialog-Bny8WDwC.js +0 -1
  260. package/dist/chunks/AgentsMdExternalIncludesDialog-DLnj3JQO.js +0 -1
  261. package/dist/chunks/App-NkBqbDbC.js +0 -1
  262. package/dist/chunks/ApproveApiKey-BKzkEkW-.js +0 -1
  263. package/dist/chunks/ApproveApiKey-rgB6AsYD.js +0 -1
  264. package/dist/chunks/BackgroundTasksDialog-CcViruUO.js +0 -2
  265. package/dist/chunks/BypassPermissionsModeDialog-D254L98G.js +0 -1
  266. package/dist/chunks/Doctor-DYEdLRxR.js +0 -1
  267. package/dist/chunks/Doctor-DiNxlXfC.js +0 -3
  268. package/dist/chunks/ExitFlow-Bt2De110.js +0 -2
  269. package/dist/chunks/InvalidConfigDialog-DFiB0Kzc.js +0 -1
  270. package/dist/chunks/InvalidSettingsDialog-BHNo2__T.js +0 -1
  271. package/dist/chunks/MCPConnectionManager-CdpO2Tj9.js +0 -1
  272. package/dist/chunks/MCPToolListView-Ch4jOk_x.js +0 -1
  273. package/dist/chunks/McpParsingWarnings-D4UQ8Q2e.js +0 -1
  274. package/dist/chunks/MessageSelector-BgsrdJur.js +0 -3
  275. package/dist/chunks/Messages-DB1pmDY_.js +0 -10
  276. package/dist/chunks/Onboarding-BnjdTwci.js +0 -1
  277. package/dist/chunks/PermissionDialog-BPhvs5xH.js +0 -1
  278. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +0 -1
  279. package/dist/chunks/PromptInputFooterSuggestions-Chg9U-BC.js +0 -1
  280. package/dist/chunks/PromptInputHelpMenu-C0ZSo12s.js +0 -1
  281. package/dist/chunks/QueryEngine-bKlupZpA.js +0 -1
  282. package/dist/chunks/REPL-Cg8UXYpX.js +0 -128
  283. package/dist/chunks/REPL-yzvMFfaU.js +0 -1
  284. package/dist/chunks/ResumeConversation-Ld7tYLKO.js +0 -1
  285. package/dist/chunks/SearchExtraToolsTool-CdgQlm--.js +0 -1
  286. package/dist/chunks/Settings-CsOlPcIW.js +0 -2
  287. package/dist/chunks/TeleportProgress-Di-PMey7.js +0 -1
  288. package/dist/chunks/TeleportRepoMismatchDialog-CDv1cbo-.js +0 -1
  289. package/dist/chunks/TeleportResumeWrapper-Bmf13tGU.js +0 -1
  290. package/dist/chunks/ThemePicker-B3AO3_jA.js +0 -1
  291. package/dist/chunks/TrustDialog-C0aiR_LU.js +0 -1
  292. package/dist/chunks/add-dir-w1Ay3861.js +0 -1
  293. package/dist/chunks/agents-B_hUgPnR.js +0 -101
  294. package/dist/chunks/allErrors-C_iHQOlK.js +0 -1
  295. package/dist/chunks/api-CB3e0De0.js +0 -1
  296. package/dist/chunks/attributionHooks-C0aXyx9L.js +0 -1
  297. package/dist/chunks/auth-CsYEYXBO.js +0 -1
  298. package/dist/chunks/auth-CubXYcRl.js +0 -1
  299. package/dist/chunks/backgroundHousekeeping-BGKR5cdA.js +0 -17
  300. package/dist/chunks/backgroundHousekeeping-CykbtljP.js +0 -1
  301. package/dist/chunks/bridgeConfig-Cp2x_wtE.js +0 -1
  302. package/dist/chunks/btw-DeznoRrw.js +0 -1
  303. package/dist/chunks/caches-BiVRgePi.js +0 -1
  304. package/dist/chunks/caches-CGzKSWiP.js +0 -1
  305. package/dist/chunks/client-CmnPWgLq.js +0 -1
  306. package/dist/chunks/commands-CrzVgHxp.js +0 -1
  307. package/dist/chunks/compact-Dgzve3dI.js +0 -2
  308. package/dist/chunks/config-Df8jooTW.js +0 -1
  309. package/dist/chunks/context-Dz-bbYCw.js +0 -1
  310. package/dist/chunks/context-noninteractive-m4O3VtG7.js +0 -1
  311. package/dist/chunks/conversation-BYBX07j8.js +0 -1
  312. package/dist/chunks/conversation-CJ-d0O-U.js +0 -1
  313. package/dist/chunks/createSession-C_-ZEQT5.js +0 -1
  314. package/dist/chunks/crossProjectResume-DNnZo3gU.js +0 -40
  315. package/dist/chunks/detectRepository-Cv9-k6dg.js +0 -1
  316. package/dist/chunks/doctor-CflXjqVK.js +0 -1
  317. package/dist/chunks/esm-BYnFh4pG.js +0 -1
  318. package/dist/chunks/esm-Bx6rTxIs.js +0 -1
  319. package/dist/chunks/esm-C367Cyo-.js +0 -1
  320. package/dist/chunks/esm-CXM9jqO_.js +0 -1
  321. package/dist/chunks/esm-CXczu_-W.js +0 -1
  322. package/dist/chunks/esm-CXt5K8Xt.js +0 -1
  323. package/dist/chunks/esm-Cb-L4oAk.js +0 -1
  324. package/dist/chunks/esm-DBMVQDVv.js +0 -1
  325. package/dist/chunks/esm-DhRjocaU.js +0 -1
  326. package/dist/chunks/esm-DklLYEuz.js +0 -1
  327. package/dist/chunks/esm-IYgGg4wR.js +0 -1
  328. package/dist/chunks/esm-lyfry1WB.js +0 -10
  329. package/dist/chunks/execFileNoThrow-Bmb5HEFz.js +0 -34
  330. package/dist/chunks/exit-DDrAFCzE.js +0 -1
  331. package/dist/chunks/extraUsage-DylXI7Fc.js +0 -1
  332. package/dist/chunks/extractMemories-B_8wZpXA.js +0 -1
  333. package/dist/chunks/fast-4ajfJv-M.js +0 -1
  334. package/dist/chunks/fast-BCkhj9Dq.js +0 -1
  335. package/dist/chunks/fetchModelList-V8_e2O1N.js +0 -1
  336. package/dist/chunks/firstPartyEventLogger-CxUuXQhL.js +0 -3
  337. package/dist/chunks/firstPartyEventLogger-YQm0DoVu.js +0 -1
  338. package/dist/chunks/fpsMetrics-Dk_pnSHJ.js +0 -1
  339. package/dist/chunks/generateSessionName-vT1khubt.js +0 -1
  340. package/dist/chunks/git-zJCasBa6.js +0 -1
  341. package/dist/chunks/goal-CznQA1n1.js +0 -3
  342. package/dist/chunks/help-B6A_kDQA.js +0 -1
  343. package/dist/chunks/hooks-CJY5Vfy6.js +0 -1
  344. package/dist/chunks/install-DUOtI2Hq.js +0 -1
  345. package/dist/chunks/keybindings-BGTuYfk-.js +0 -1
  346. package/dist/chunks/launchLocalMemory-CoWeLNeP.js +0 -3
  347. package/dist/chunks/launchOnboarding-CTIBGSLV.js +0 -8
  348. package/dist/chunks/loadAgentsDir-Dxz1vp3F.js +0 -1
  349. package/dist/chunks/loadPluginHooks-DrNVtTBq.js +0 -1
  350. package/dist/chunks/localSearch-CCs5fOd_.js +0 -1
  351. package/dist/chunks/logoUtils-YwL3izJt.js +0 -1
  352. package/dist/chunks/managedEnv-CrnBYTtQ.js +0 -1
  353. package/dist/chunks/mappers-DYtq2XVS.js +0 -1
  354. package/dist/chunks/mcp-BPvcoKDY.js +0 -1
  355. package/dist/chunks/mcp-BfqsHRx0.js +0 -2
  356. package/dist/chunks/mcp-BoU3TNFs.js +0 -6
  357. package/dist/chunks/memory-BPKRdkBb.js +0 -1
  358. package/dist/chunks/modalContext-wY9CeN4G.js +0 -1
  359. package/dist/chunks/mode-CXpXux2s.js +0 -2
  360. package/dist/chunks/model-CxPYKiW1.js +0 -1
  361. package/dist/chunks/model-Cxx3suBa.js +0 -1
  362. package/dist/chunks/model-aEJ54cMA.js +0 -1
  363. package/dist/chunks/nativeInstaller-CaXwRpoR.js +0 -1
  364. package/dist/chunks/omit-DZUxsClb.js +0 -1
  365. package/dist/chunks/panel-CVd1dzYl.js +0 -1
  366. package/dist/chunks/permissions-Dv5d5Nu3.js +0 -3
  367. package/dist/chunks/plan-DVPBW5OS.js +0 -1
  368. package/dist/chunks/plugin-Bh2eBwLW.js +0 -17
  369. package/dist/chunks/pluginBlocklist-B2NAKaB9.js +0 -1
  370. package/dist/chunks/pluginCliCommands-Cw5TrYYb.js +0 -1
  371. package/dist/chunks/pluginOperations-BBwGEdfC.js +0 -2
  372. package/dist/chunks/pluginStartupCheck-CHx379_R.js +0 -1
  373. package/dist/chunks/plugins-r0h93GT_.js +0 -4
  374. package/dist/chunks/poorMode-BTIe8W_H.js +0 -1
  375. package/dist/chunks/postCommitAttribution-DoSP9wZD.js +0 -1
  376. package/dist/chunks/print-CDzhHi2F.js +0 -14
  377. package/dist/chunks/processBashCommand-DmdCAWOR.js +0 -1
  378. package/dist/chunks/processSlashCommand-B43TkiaI.js +0 -5
  379. package/dist/chunks/prompt-C50mDqWv.js +0 -1
  380. package/dist/chunks/prompt-WGH9CcXh.js +0 -1
  381. package/dist/chunks/promptEditor-eJzbtNn4.js +0 -4
  382. package/dist/chunks/refresh-vaY-Sr80.js +0 -1
  383. package/dist/chunks/registerProtocol-Xsq4ldwg.js +0 -1
  384. package/dist/chunks/rename-DmauGVBX.js +0 -1
  385. package/dist/chunks/resume-ut_pBrLN.js +0 -2
  386. package/dist/chunks/ripgrep-CBUbn6Po.js +0 -1
  387. package/dist/chunks/sandbox-adapter-CL0qdcxn.js +0 -1
  388. package/dist/chunks/sandbox-toggle-BJKd1ZYk.js +0 -1
  389. package/dist/chunks/searchExtraTools-ByWuNCGo.js +0 -1
  390. package/dist/chunks/session-DTin6hOR.js +0 -2
  391. package/dist/chunks/sessionFileAccessHooks-DorzHolr.js +0 -1
  392. package/dist/chunks/sessionObserver-Dy6NFlzL.js +0 -1
  393. package/dist/chunks/sessionStorage-DItJMkwx.js +0 -1
  394. package/dist/chunks/sessionTracing-Dvi520eN.js +0 -11
  395. package/dist/chunks/settings-Crx1cI1u.js +0 -1
  396. package/dist/chunks/settingsSync-aHn3p-6J.js +0 -1
  397. package/dist/chunks/setup-CK3ybjjM.js +0 -3
  398. package/dist/chunks/sinks-QQ_6Op7q.js +0 -1
  399. package/dist/chunks/skillChangeDetector-Bco3UoeW.js +0 -1
  400. package/dist/chunks/skills-axToWEo0.js +0 -1
  401. package/dist/chunks/src-D3yIF9I42.js +0 -1
  402. package/dist/chunks/src-DPUAq5Ty.js +0 -1
  403. package/dist/chunks/src-DQOX_xI1.js +0 -1
  404. package/dist/chunks/src-Dt5IJd3C.js +0 -1
  405. package/dist/chunks/src-Dvp6-vB7.js +0 -19
  406. package/dist/chunks/src-PM8NIIu_.js +0 -1
  407. package/dist/chunks/startupProfiler-uHetQush.js +0 -1
  408. package/dist/chunks/staticRender-D9AbnQFr.js +0 -1
  409. package/dist/chunks/stats-Ce15gc3E.js +0 -1
  410. package/dist/chunks/status-3uevwSMo.js +0 -1
  411. package/dist/chunks/status-CGp4uRlH.js +0 -2
  412. package/dist/chunks/switcher-DJDxjLPQ.js +0 -1
  413. package/dist/chunks/teleport-CvX_nUjQ.js +0 -1
  414. package/dist/chunks/theme-DzaSXOpQ.js +0 -1
  415. package/dist/chunks/toolPool-CgKK0K8f.js +0 -1
  416. package/dist/chunks/trustedDevice-C2gnF9Lc.js +0 -1
  417. package/dist/chunks/useExitOnCtrlCDWithKeybindings-D0uqGxGw.js +0 -1
  418. package/dist/chunks/useMainLoopModel-BGPOmBkl.js +0 -1
  419. package/dist/chunks/useManagePlugins-ITVFO9dz.js +0 -1
  420. package/dist/chunks/useMergedTools-rQ19rFvH.js +0 -1
  421. package/dist/chunks/useSearchInput-CXTa-leH.js +0 -1
  422. package/dist/chunks/useSettingsErrors-Xc6RYjYF.js +0 -1
  423. package/dist/chunks/util-CD3ar4of.js +0 -1
  424. package/dist/chunks/validatePlugin-CxrlCKc1.js +0 -1
  425. package/dist/chunks/which-BxQ1hpjp.js +0 -1
  426. package/dist/chunks/worktree-CanG5GhE.js +0 -1
  427. /package/dist/chunks/{src-DL3w8VPk2.js → src-DL3w8VPk.js} +0 -0
  428. /package/dist/chunks/{src-DLz3FZm1.js → urlHandler-DLz3FZm1.js} +0 -0
@@ -1,2 +1,2 @@
1
- import{l as e,o as t,u as n}from"./envUtils-DcaKZlRU.js";import{Dt as r,St as i,mt as a,oS as o,sS as s}from"./loadAgentsDir-DXOkUcW3.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-D58GQBDG.js";import{Ut as g}from"./settings-3xZ0fsvE.js";import{O as _,k as v}from"./git-By_J4XJL.js";import{o as y,s as b}from"./log-CZ7ploQm.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-CbzxVmbv.js";import{Pt as E,St as D,dn as O,fn as k}from"./model-Cxx3suBa.js";import{i as ee,t as A}from"./sessionIdCompat-Dgp6PW_1.js";import{n as j}from"./firstPartyEventLogger-CxUuXQhL.js";import{t as te}from"./datadog-DBgIEaEd.js";import{n as M,o as N,r as P}from"./debugUtils-DXBRbwCE.js";import{t as F}from"./pollConfig-2nFzv6Hy.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-BpP6c7x3.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-CaM2yIJD.js";import{i as U}from"./trustedDevice-Bb7O8_tj.js";import{t as le}from"./jwtUtils-C_LG1txt.js";import{n as W,r as G}from"./cliLaunch-DDtwAolw.js";import"./bridgeStatusUtil-B9EcQksI.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(),s(),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,s,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,s,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 s=g.data.id;I(`work received: type=session sessionId=${s} workId=${g.id}`);try{ne(s,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${s}`);break}let f=x.get(s);if(f){f.updateAccessToken(P.session_ingress_token),D.set(s,P.session_ingress_token),T.set(s,g.id),V?.schedule(s,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${s} 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,s);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=${s} 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 ${s}: ${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,s);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(s,h))){let e=Date.now();try{let t=await a(`bridge-${he(s)}`);B=Date.now()-e,j.set(s,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),z=t.worktreePath,p(`[bridge:session] Created worktree for sessionId=${s} at ${t.worktreePath}`)}catch(e){let t=u(e);d.logError(`Failed to create worktree for session ${s}: ${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=${s} sdkUrl=${w}`);let H=ee(s);I(`spawning session: sessionId=${s} 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:s,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-C_-ZEQT5.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 ${s}: ${se}`);let e=j.get(s);e&&(j.delete(s),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(s),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(s),spawn_duration_ms:le,worktree_create_ms:B}),x.set(s,U),T.set(s,g.id),D.set(s,P.session_ingress_token),E.set(s,H);let W=Date.now();C.set(s,W),d.logSessionStart(s,`Session ${s}`);let K=he(s),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,o(H,t.sessionIngressUrl)),Q(),d.setAttached(H),Ie(H,t.apiBaseUrl).then(e=>{e&&x.has(s)&&(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,s,J,d,te,U);O.set(s,e)}N&&re.add(s),V?.schedule(s,P.session_ingress_token),U.done.then(me(s,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-DfTOjgtX.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-C_-ZEQT5.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-BStOuCh4.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-e0Goy478.js`);o();let{initSinks:c}=await import(`./sinks-QQ_6Op7q.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-Cp2x_wtE.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-zJCasBa6.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-CJY5Vfy6.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.19`,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-C_-ZEQT5.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};
1
+ import{l as e,o as t,u as n}from"./envUtils-DcaKZlRU.js";import{Dt as r,Fx as i,Ix as a,St as o,mt as s}from"./loadAgentsDir-C96o6gCj.js";import{t as c}from"./src-DL3w8VPk.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-D58GQBDG.js";import{Ut as g}from"./settings-BowI3jp-.js";import{O as _,k as v}from"./git-Wid-XppW.js";import{o as y,s as b}from"./log-CZ7ploQm.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-B90b5vuq.js";import{Pt as E,St as D,dn as O,fn as k}from"./model-BaMclMXn.js";import{i as ee,t as A}from"./sessionIdCompat-Dgp6PW_1.js";import{n as j}from"./firstPartyEventLogger-B261Wksn.js";import{t as te}from"./datadog-BuElf2EQ.js";import{n as M,o as N,r as P}from"./debugUtils-DXBRbwCE.js";import{t as F}from"./pollConfig-2nFzv6Hy.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-BpP6c7x3.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-CaM2yIJD.js";import{i as U}from"./trustedDevice-C1m--Yjw.js";import{t as le}from"./jwtUtils-JE2okZ70.js";import{n as W,r as G}from"./cliLaunch-DDtwAolw.js";import"./bridgeStatusUtil-DaEq5c69.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(),a(),te(),j(),o(),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,a,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 i=T.get(r),o=D.get(r);if(!(!i||!o))try{await c.heartbeatWork(a,i,o),e=!0}catch(e){p(`[bridge:heartbeat] Failed for sessionId=${r} workId=${i}: ${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(a,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(a,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=${a}`),v(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),d.printBanner(t,a),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,i){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=${i.lastStderr.length>0?i.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=i.lastStderr.length>0?i.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,a,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=${a} activeSessions=${x.size}`);let g=await c.pollForWork(a,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,a,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(a,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,a,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,a,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-CqHnHhCR.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,a,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,i(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(a,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(a),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-DfTOjgtX.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-CqHnHhCR.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-BStOuCh4.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-DoEDgAfv.js`);o();let{initSinks:c}=await import(`./sinks-DnLqRPEC.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-_xpxhGB5.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-hO-TMvXc.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-BX2s7aoL.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.21`,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-CqHnHhCR.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-C96o6gCj.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.19 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-uHetQush.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-EmOA7oWN.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-BGJtgrko.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-e0Goy478.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);r();let{initSinks:i}=await import(`./chunks/sinks-QQ_6Op7q.js`);i();let{daemonMain:a}=await import(`./chunks/main-Blm02_Js.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-e0Goy478.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);r(),await(await import(`./chunks/bg-tGgpwpYx.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-e0Goy478.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);i();let{initSinks:a}=await import(`./chunks/sinks-QQ_6Op7q.js`);a();let{daemonMain:o}=await import(`./chunks/main-Blm02_Js.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-Bm8bovHx.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-Bm8bovHx.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-e0Goy478.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-CanG5GhE.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.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-BOvY4O6D.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.21 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-DG2TN5R_.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-DidpiR-D.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-BBgquE8F.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-DoEDgAfv.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);r();let{initSinks:i}=await import(`./chunks/sinks-DnLqRPEC.js`);i();let{daemonMain:a}=await import(`./chunks/main-7ssnA9Yb.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-DoEDgAfv.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);r(),await(await import(`./chunks/bg-qG2osBbP.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-DoEDgAfv.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-DtGZ83kH.js`);i();let{initSinks:a}=await import(`./chunks/sinks-DnLqRPEC.js`);a();let{daemonMain:o}=await import(`./chunks/main-7ssnA9Yb.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-fiKuu4DK.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-fiKuu4DK.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-DoEDgAfv.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-C28I8mFB.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.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-BEv6MqMX.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.19",
3
+ "version": "0.0.21",
4
4
  "description": "workMate",
5
5
  "type": "module",
6
6
  "author": "Frandy",
@@ -88,30 +88,22 @@
88
88
  "@aws-sdk/credential-providers": "^3.1037.0",
89
89
  "@azure/identity": "^4.13.1",
90
90
  "@biomejs/biome": "^2.4.12",
91
- "@readmagic/workmate-agent-tools": "workspace:*",
92
- "@readmagic/workmate-builtin-tools": "workspace:*",
93
- "@readmagic/workmate-mcp-client": "workspace:*",
94
- "@readmagic/workmate-workflow-engine": "workspace:*",
95
91
  "@commander-js/extra-typings": "^14.0.0",
96
92
  "@modelcontextprotocol/sdk": "^1.29.0",
97
93
  "@opentelemetry/api": "^1.9.1",
98
94
  "@opentelemetry/api-logs": "^0.215.0",
99
95
  "@opentelemetry/core": "^2.7.0",
100
- "@opentelemetry/exporter-logs-otlp-grpc": "^0.215.0",
101
96
  "@opentelemetry/exporter-logs-otlp-http": "^0.215.0",
102
- "@opentelemetry/exporter-logs-otlp-proto": "^0.215.0",
103
- "@opentelemetry/exporter-metrics-otlp-grpc": "^0.215.0",
104
97
  "@opentelemetry/exporter-metrics-otlp-http": "^0.215.0",
105
- "@opentelemetry/exporter-metrics-otlp-proto": "^0.215.0",
106
98
  "@opentelemetry/exporter-prometheus": "^0.215.0",
107
- "@opentelemetry/exporter-trace-otlp-grpc": "^0.215.0",
108
99
  "@opentelemetry/exporter-trace-otlp-http": "^0.215.0",
109
- "@opentelemetry/exporter-trace-otlp-proto": "^0.215.0",
110
100
  "@opentelemetry/resources": "^2.7.0",
111
101
  "@opentelemetry/sdk-logs": "^0.215.0",
112
102
  "@opentelemetry/sdk-metrics": "^2.7.0",
113
103
  "@opentelemetry/sdk-trace-base": "^2.7.0",
114
104
  "@opentelemetry/semantic-conventions": "^1.40.0",
105
+ "@readmagic/workmate-builtin-tools": "workspace:*",
106
+ "@readmagic/workmate-workflow-engine": "workspace:*",
115
107
  "@smithy/core": "^3.23.15",
116
108
  "@smithy/node-http-handler": "^4.5.3",
117
109
  "@types/bun": "^1.3.12",
@@ -125,8 +117,6 @@
125
117
  "@types/react": "^19.2.14",
126
118
  "@types/react-reconciler": "^0.33.0",
127
119
  "@types/semver": "^7.7.1",
128
- "@types/sharp": "^0.32.0",
129
- "@types/shell-quote": "^1.7.5",
130
120
  "@types/stack-utils": "^2.0.3",
131
121
  "@types/ws": "^8.18.1",
132
122
  "ajv": "^8.18.0",
@@ -156,11 +146,9 @@
156
146
  "indent-string": "^5.0.0",
157
147
  "jsonc-parser": "^3.3.1",
158
148
  "knip": "^6.4.1",
159
- "lint-staged": "^16.4.0",
160
149
  "lodash-es": "^4.18.1",
161
150
  "lru-cache": "^11.3.5",
162
151
  "marked": "^17.0.6",
163
- "modifiers-napi": "workspace:*",
164
152
  "openai": "^6.34.0",
165
153
  "p-map": "^7.0.4",
166
154
  "picomatch": "^4.0.4",
@@ -179,10 +167,8 @@
179
167
  "strip-ansi": "^7.2.0",
180
168
  "supports-hyperlinks": "^4.4.0",
181
169
  "tree-kill": "^1.2.2",
182
- "type-fest": "^5.6.0",
183
170
  "typescript": "^6.0.3",
184
171
  "undici": "^7.25.0",
185
- "url-handler-napi": "workspace:*",
186
172
  "usehooks-ts": "^3.1.1",
187
173
  "vite": "^8.0.8",
188
174
  "vscode-jsonrpc": "^8.2.1",
@@ -200,13 +186,5 @@
200
186
  "hono": "4.12.15",
201
187
  "postcss": "8.5.10",
202
188
  "uuid": "14.0.0"
203
- },
204
- "lint-staged": {
205
- "*.{ts,tsx,js,mjs,jsx}": [
206
- "biome check --fix --no-errors-on-unmatched"
207
- ],
208
- "*.{json,jsonc}": [
209
- "biome format --write --no-errors-on-unmatched"
210
- ]
211
189
  }
212
190
  }
@@ -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{$u as i,Dp as a,F as o,N as s,Op as c,P as l,Qu as u,cd as d,ld as f,uC as p}from"./loadAgentsDir-DXOkUcW3.js";import{D as m,I as h,P as g,T as _,Wt as v,ai as y,t as b,vn as x,y as S,yn as C}from"./src-DL3w8VPk2.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{r as T,t as E}from"./directoryCompletion-BDGcGDuv.js";import{r as D,t as O}from"./PromptInputFooterSuggestions-Chg9U-BC.js";function k(){return(0,P.jsx)(g,{dimColor:!0,children:`Work Mate will be able to read files in this directory and make edits when auto-accept edits is on.`})}function A({path:e}){return(0,P.jsxs)(h,{flexDirection:`column`,paddingX:2,gap:1,children:[(0,P.jsx)(g,{color:`permission`,children:e}),(0,P.jsx)(k,{})]})}function j({value:e,onChange:t,onSubmit:n,error:i,suggestions:a,selectedSuggestion: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)(d,{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[i,c]=(0,N.useState)(``),[l,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(i)},[i,w]);let T=(0,N.useCallback)(e=>{let t=`${e.id}/`;c(t),d(null)},[]),D=(0,N.useCallback)(async t=>{let r=await o(t,n);r.resultType===`success`?e(r.absolutePath,!1):d(s(r))},[n,e]);v(`confirm:no`,t,{context:`Settings`});let O=(0,N.useCallback)(e=>{if(f.length>0){if(e.key===`tab`){e.preventDefault();let t=f[y];t&&T(t);return}if(e.key===`return`){e.preventDefault();let t=f[y];t&&D(`${t.id}/`);return}if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b(e=>e<=0?f.length-1:e-1);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),b(e=>e>=f.length-1?0:e+1);return}}},[f,y,T,D]),M=(0,N.useCallback)(n=>{if(r)switch(n){case`yes-session`:e(r,!1);break;case`yes-remember`:e(r,!0);break;case`no`:t();break}},[r,e,t]);return(0,P.jsx)(h,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:O,children:(0,P.jsx)(S,{title:`Add directory to workspace`,onCancel:t,color:`permission`,isCancelActive:!1,inputGuide:r?void 0:e=>e.pending?(0,P.jsxs)(g,{children:[`Press `,e.keyName,` again to exit`]}):(0,P.jsxs)(_,{children:[(0,P.jsx)(m,{shortcut:`Tab`,action:`complete`}),(0,P.jsx)(m,{shortcut:`Enter`,action:`add`}),(0,P.jsx)(a,{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)(u,{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:i,onChange:c,onSubmit:D,error:l,suggestions:f,selectedSuggestion:y})]})})})}var N,P,F,I=e((()=>{n(),N=t(y(),1),x(),l(),f(),b(),p(),T(),c(),i(),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-DLnj3JQO.js";e();export{t as AgentsMdExternalIncludesDialog};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Qu as n,Zu as r}from"./loadAgentsDir-DXOkUcW3.js";import{I as i,Lt as a,P as o,ai as s,t as c,y as l}from"./src-DL3w8VPk2.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{h as d,v as f}from"./config-DRy1I12M.js";import{n as p,r as m}from"./analytics-DJobLaWP.js";function h({onDone:e,isStandaloneDialog:t,externalIncludes:r}){g.useEffect(()=>{m(`tengu_claude_md_includes_dialog_shown`,{})},[]);let s=(0,g.useCallback)(t=>{t===`no`?(m(`tengu_claude_md_external_includes_dialog_declined`,{}),f(e=>({...e,hasAgentsMdExternalIncludesApproved:!1,hasAgentsMdExternalIncludesWarningShown:!0}))):(m(`tengu_claude_md_external_includes_dialog_accepted`,{}),f(e=>({...e,hasAgentsMdExternalIncludesApproved:!0,hasAgentsMdExternalIncludesWarningShown:!0}))),e()},[e]);return(0,_.jsxs)(l,{title:`Allow external AGENTS.md file imports?`,color:`warning`,onCancel:(0,g.useCallback)(()=>{s(`no`)},[s]),hideBorder:!t,hideInputGuide:!t,children:[(0,_.jsx)(o,{children:`This project's AGENTS.md imports files outside the current working directory. Never allow this for third-party repositories.`}),r&&r.length>0&&(0,_.jsxs)(i,{flexDirection:`column`,children:[(0,_.jsx)(o,{dimColor:!0,children:`External imports:`}),r.map((e,t)=>(0,_.jsxs)(o,{dimColor:!0,children:[` `,e.path]},t))]}),(0,_.jsxs)(o,{dimColor:!0,children:[`Important: Only use Work Mate with files you trust. Accessing untrusted files may pose security risks`,` `,(0,_.jsx)(a,{url:`https://code.workmate.com/docs/en/security`}),` `]}),(0,_.jsx)(n,{options:[{label:`Yes, allow external imports`,value:`yes`},{label:`No, disable external imports`,value:`no`}],onChange:e=>s(e)})]})}var g,_,v=e((()=>{g=t(s(),1),p(),c(),d(),r(),_=u()}));export{v as n,h as t};
@@ -1 +0,0 @@
1
- import{Xh as e,Yh as t}from"./loadAgentsDir-DXOkUcW3.js";import{R as n,t as r}from"./src-DL3w8VPk2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{c as a,h as o,y as s}from"./config-DRy1I12M.js";import{n as c}from"./onChangeAppState-qHXqufwy.js";import{t as l}from"./fpsMetrics-Dk_pnSHJ.js";import{t as u}from"./stats-Ce15gc3E.js";e(),r(),o();var d=i();function f({getFpsMetrics:e,stats:r,initialState:i,children:o}){return(0,d.jsx)(l,{getFpsMetrics:e,children:(0,d.jsx)(u,{store:r,children:(0,d.jsx)(t,{initialState:i,onChangeAppState:c,children:(0,d.jsx)(n,{initialState:a().theme,onThemeSave:e=>s(t=>({...t,theme:e})),children:o})})})})}export{f as App};
@@ -1 +0,0 @@
1
- import{t as e}from"./ApproveApiKey-rgB6AsYD.js";export{e as ApproveApiKey};
@@ -1 +0,0 @@
1
- import{Qu as e,Zu as t}from"./loadAgentsDir-DXOkUcW3.js";import{P as n,t as r,y as i}from"./src-DL3w8VPk2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{h as o,y as s}from"./config-DRy1I12M.js";r(),o(),t();var c=a();function l({customApiKeyTruncated:t,onDone:r}){function a(e){switch(e){case`yes`:s(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,approved:[...e.customApiKeyResponses?.approved??[],t]}})),r(!0);break;case`no`:s(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,rejected:[...e.customApiKeyResponses?.rejected??[],t]}})),r(!1);break}}return(0,c.jsxs)(i,{title:`Detected a custom API key in your environment`,color:`warning`,onCancel:()=>a(`no`),children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{bold:!0,children:`ANTHROPIC_API_KEY`}),(0,c.jsxs)(n,{children:[`: sk-ant-...`,t]})]}),(0,c.jsx)(n,{children:`Do you want to use this API key?`}),(0,c.jsx)(e,{defaultValue:`no`,defaultFocusValue:`no`,options:[{label:`Yes`,value:`yes`},{label:(0,c.jsxs)(n,{children:[`No (`,(0,c.jsx)(n,{bold:!0,children:`recommended`}),`)`]}),value:`no`}],onChange:e=>a(e),onCancel:()=>a(`no`)})]})}export{l as t};
@@ -1,2 +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{$h as i,$u as a,Af as o,Ag as s,Dg as c,En as l,Ga as u,If as d,Is as f,Jh as p,Kc as m,La as h,Lf as g,Ls as _,Mf as v,On as y,Qu as b,Xh as ee,Zh as te,ad as ne,au as x,dC as S,df as re,dp as ie,eS as ae,ea as oe,fC as se,fp as ce,gC as C,iu as w,lu as T,nd as E,nu as le,op as ue,pu as de,qc as fe,qh as pe,ru as me,sp as he,tS as ge,tu as _e,uC as ve,uf as ye,wa as be}from"./loadAgentsDir-DXOkUcW3.js";import{D,Gt as O,H as xe,I as k,Lt as Se,P as A,T as j,ai as M,mt as Ce,ot as we,t as N,y as P}from"./src-DL3w8VPk2.js";import{t as F}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Te,R as Ee,_ as De,f as Oe}from"./debug-D58GQBDG.js";import{In as ke,Ln as Ae,Rn as je,Ut as Me}from"./settings-3xZ0fsvE.js";import{C as Ne,b as I,f as Pe,l as Fe,u as Ie,v as L}from"./startupProfiler-CbzxVmbv.js";import{l as R,o as Le}from"./stringUtils-CKD8qDqx.js";import{Nt as Re,_n as ze,gn as Be,vn as Ve}from"./prompt-DEioJrx_.js";import{i as He,n as Ue}from"./mappers-DYtq2XVS.js";function z(e,t,n=1e3,r=0,i){let a=()=>Fe(Math.max(0,(i??Date.now())-e-r));return(0,We.useSyncExternalStore)((0,We.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var We,B=e((()=>{We=t(M(),1),L()}));function Ge(e,t,n){let r=Be(t,e.toolName);if(!r)return e.toolName;try{let t=r.inputSchema.safeParse(e.input),i=t.success?t.data:{},a=r.userFacingName(i);if(!a)return e.toolName;let o=r.renderToolUseMessage(i,{theme:n,verbose:!1});return o?(0,Ke.jsxs)(A,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var Ke,qe=e((()=>{N(),Ve(),Ke=F()}));function Je(e,t){let{isIdle:n,awaitingApproval:i,hasError:a,shutdownRequested:o}=t??{};return a?r.cross:i?r.questionMarkPrefix:o?r.warning:e===`running`?n?r.ellipsis:r.play:e===`completed`?r.tick:e===`failed`||e===`killed`?r.cross:r.bullet}function Ye(e,t){let{isIdle:n,awaitingApproval:r,hasError:i,shutdownRequested:a}=t??{};return i?`error`:r||a?`warning`:n?`background`:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:`background`}function Xe(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(g(t))return n=!0,!1;return n}var Ze=e((()=>{n(),d()}));function Qe({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=xe(),a=(0,$e.useMemo)(()=>m(ze()),[]),o=z(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);O({"confirm:yes":t},{context:`Confirmation`});let s=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},c=be(e.prompt,`plan`),l=e.prompt.length>300?`${e.prompt.substring(0,297)}…`:e.prompt,u=e.result?.totalTokens??e.progress?.tokenCount,d=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,V.jsx)(k,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:(0,V.jsx)(P,{title:(0,V.jsxs)(A,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,V.jsxs)(A,{children:[e.status!==`running`&&(0,V.jsxs)(A,{color:Ye(e.status),children:[Je(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,V.jsxs)(A,{dimColor:!0,children:[o,u!==void 0&&u>0&&(0,V.jsxs)(V.Fragment,{children:[` · `,Pe(u),` tokens`]}),d!==void 0&&d>0&&(0,V.jsxs)(V.Fragment,{children:[` `,`· `,d,` `,d===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,V.jsxs)(A,{children:[`Press `,t.keyName,` again to exit`]}):(0,V.jsxs)(j,{children:[r&&(0,V.jsx)(D,{shortcut:`←`,action:`go back`}),(0,V.jsx)(D,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,V.jsx)(D,{shortcut:`x`,action:`stop`})]}),children:(0,V.jsxs)(k,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,V.jsxs)(k,{flexDirection:`column`,children:[(0,V.jsx)(A,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,V.jsxs)(A,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,Ge(t,a,i)]},n))]}),c?(0,V.jsx)(k,{marginTop:1,children:(0,V.jsx)(ie,{addMargin:!1,planContent:c})}):(0,V.jsxs)(k,{flexDirection:`column`,marginTop:1,children:[(0,V.jsx)(A,{bold:!0,dimColor:!0,children:`Prompt`}),(0,V.jsx)(A,{wrap:`wrap`,children:l})]}),e.status===`failed`&&e.error&&(0,V.jsxs)(k,{flexDirection:`column`,marginTop:1,children:[(0,V.jsx)(A,{bold:!0,color:`error`,children:`Error`}),(0,V.jsx)(A,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var $e,V,et=e((()=>{$e=t(M(),1),B(),N(),ve(),Ve(),fe(),L(),h(),ce(),qe(),Ze(),V=F()}));function tt(e,t,n,r){if(!e)return`${t} found · ${n} verified`;if(e===`synthesizing`){let e=[`${n} verified`];return r>0&&e.push(`${r} refuted`),e.push(`deduping`),e.join(` · `)}if(e===`verifying`){let e=[`${t} found`,`${n} verified`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return t>0?`${t} found`:`finding`}function nt({text:e,phase:t=0}){return(0,H.jsx)(H.Fragment,{children:[...e].map((e,n)=>(0,H.jsx)(A,{color:ue(n+t),children:e},n))})}function rt(e,t,n){let r=(0,ot.useRef)(e),i=(0,ot.useRef)(t);return n||e<r.current?r.current=e:e>r.current&&t!==i.current&&(r.current+=1,i.current=t),r.current}function it({session:e}){let t=p().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=Ce(r&&!t?st:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,l=rt(a,i,c),u=rt(o,i,c),d=rt(s,i,c),f=Math.floor(i/(st*3))%7;if(e.status===`completed`)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(A,{color:`background`,children:[`◆`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:0}),(0,H.jsx)(A,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(A,{color:`background`,children:[`◆`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:0}),(0,H.jsxs)(A,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let m=n?tt(n.stage,l,u,d):`setting up`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(A,{color:`background`,children:[`◇`,` `]}),(0,H.jsx)(nt,{text:`ultrareview`,phase:r?f:0}),(0,H.jsxs)(A,{dimColor:!0,children:[` · `,m]})]})}function at({session:e}){if(e.isRemoteReview)return(0,H.jsx)(it,{session:e});if(e.status===`completed`)return(0,H.jsx)(A,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,H.jsx)(A,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,H.jsxs)(A,{dimColor:!0,children:[e.status,`…`]});let t=ke(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,H.jsxs)(A,{dimColor:!0,children:[t,`/`,n]})}var ot,H,st,ct=e((()=>{ot=t(M(),1),Me(),pe(),N(),Ae(),he(),H=F(),st=80}));function U({status:e,label:t,suffix:n}){return(0,W.jsxs)(A,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function lt({shell:e}){switch(e.status){case`completed`:return(0,W.jsx)(U,{status:`completed`,label:`done`});case`failed`:return(0,W.jsx)(U,{status:`failed`,label:`error`});case`killed`:return(0,W.jsx)(U,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,W.jsx)(U,{status:`running`})}}var W,ut=e((()=>{N(),W=F()}));function dt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,G.jsxs)(A,{children:[I(e.command,n,!0),` `,(0,G.jsx)(lt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,G.jsx)(A,{children:(0,G.jsx)(at,{session:e})}):(0,G.jsxs)(A,{children:[(0,G.jsxs)(A,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),I(e.title,n,!0),(0,G.jsx)(A,{dimColor:!0,children:` · `}),(0,G.jsx)(at,{session:e})]});case`local_agent`:return(0,G.jsxs)(A,{children:[I(e.description,n,!0),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]});case`local_workflow`:{let t=e;return(0,G.jsxs)(A,{children:[I(t.workflowName??e.summary??e.description,n,!0),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`running`?`${t.agentCount} ${R(t.agentCount,`agent`)}`:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}case`dream`:{let t=e.filesTouched.length,n=e.phase===`updating`&&t>0?`${t} ${R(t,`file`)}`:`${e.sessionsReviewing} ${R(e.sessionsReviewing,`session`)}`;return(0,G.jsxs)(A,{children:[e.description,` `,(0,G.jsxs)(A,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,G.jsx)(U,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var G,ft=e((()=>{N(),L(),Le(),Me(),ct(),ut(),G=F()}));function pt({task:e,onDone:t,onBack:n,onKill:r}){let i=z(e.startTime,e.status===`running`,1e3,0);O({"confirm:yes":t},{context:`Confirmation`});let a=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&n?(i.preventDefault(),n()):i.key===`x`&&e.status===`running`&&r&&(i.preventDefault(),r())},o=e.turns.filter(e=>e.text!==``),s=o.slice(-6),c=o.length-s.length;return(0,K.jsx)(k,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,K.jsx)(P,{title:`Memory consolidation`,subtitle:(0,K.jsxs)(A,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,R(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,R(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,K.jsxs)(A,{children:[`Press `,t.keyName,` again to exit`]}):(0,K.jsxs)(j,{children:[n&&(0,K.jsx)(D,{shortcut:`←`,action:`go back`}),(0,K.jsx)(D,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,K.jsx)(D,{shortcut:`x`,action:`stop`})]}),children:(0,K.jsxs)(k,{flexDirection:`column`,gap:1,children:[(0,K.jsxs)(A,{children:[(0,K.jsx)(A,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,K.jsx)(A,{color:`background`,children:`running`}):e.status===`completed`?(0,K.jsx)(A,{color:`success`,children:e.status}):(0,K.jsx)(A,{color:`error`,children:e.status})]}),s.length===0?(0,K.jsx)(A,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,K.jsxs)(K.Fragment,{children:[c>0&&(0,K.jsxs)(A,{dimColor:!0,children:[`(`,c,` earlier `,R(c,`turn`),`)`]}),s.map((e,t)=>(0,K.jsxs)(k,{flexDirection:`column`,children:[(0,K.jsx)(A,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,K.jsxs)(A,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,R(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var K,mt=e((()=>{B(),N(),ve(),Le(),K=F()}));function ht({stage:e,completed:t,hasProgress:n}){let r=e?yt.indexOf(e):-1,i=!t&&!n;return(0,J.jsxs)(A,{children:[i?(0,J.jsx)(A,{color:`background`,children:`Setup`}):(0,J.jsx)(A,{dimColor:!0,children:`Setup`}),(0,J.jsx)(A,{dimColor:!0,children:` → `}),yt.map((e,n)=>{let a=!t&&!i&&n===r;return(0,J.jsxs)(q.Fragment,{children:[n>0&&(0,J.jsx)(A,{dimColor:!0,children:` → `}),a?(0,J.jsx)(A,{color:`background`,children:bt[e]}):(0,J.jsx)(A,{dimColor:!0,children:bt[e]})]},e)}),t&&(0,J.jsx)(A,{color:`success`,children:` ✓`})]})}function gt(e){let t=e.reviewProgress;if(!t)return e.status===`completed`?`done`:`setting up`;let n=t.bugsVerified,r=t.bugsRefuted??0;if(e.status===`completed`){let e=[`${n} ${R(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return tt(t.stage,t.bugsFound,n,r)}function _t({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,a=e.status===`running`||e.status===`pending`,[o,s]=(0,q.useState)(!1),c=z(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,J.jsx)(P,{title:`Stop ultrareview?`,onCancel:()=>s(!1),color:`background`,children:(0,J.jsxs)(k,{flexDirection:`column`,gap:1,children:[(0,J.jsx)(A,{dimColor:!0,children:`This archives the remote session and stops local tracking. The review will not complete and any findings so far are discarded.`}),(0,J.jsx)(b,{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,J.jsx)(P,{title:(0,J.jsxs)(A,{children:[(0,J.jsxs)(A,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,J.jsx)(A,{bold:!0,children:`ultrareview`}),(0,J.jsxs)(A,{dimColor:!0,children:[` · `,c,` · `,f]})]}),onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,J.jsxs)(A,{children:[`Press `,e.keyName,` again to exit`]}):(0,J.jsxs)(j,{children:[(0,J.jsx)(D,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(D,{shortcut:`Esc`,action:`go back`})]}),children:(0,J.jsxs)(k,{flexDirection:`column`,gap:1,children:[(0,J.jsx)(ht,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,J.jsxs)(k,{flexDirection:`column`,children:[(0,J.jsx)(A,{children:gt(e)}),(0,J.jsx)(Se,{url:d,children:(0,J.jsx)(A,{dimColor:!0,children:d})})]}),(0,J.jsx)(b,{options:p,onChange:e=>{switch(e){case`open`:ge(d),t();break;case`stop`:s(!0);break;case`back`:u();break;case`dismiss`:l();break}}})]})})}function vt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),d=(0,q.useMemo)(()=>e.isRemoteReview?[]:u(He(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,J.jsx)(_t,{session:e,onDone:n,onBack:r,onKill:i});let f=()=>n(`Remote session details dismissed`,{display:`system`}),p=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(),m()):e.key===`return`&&(e.preventDefault(),f())};async function m(){s(!0),l(null);try{await de(e.sessionId)}catch(e){l(Te(e))}finally{s(!1)}}let h=Ne(e.title,50),g=e.status===`pending`?`starting`:e.status;return(0,J.jsx)(k,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:p,children:(0,J.jsxs)(P,{title:`Remote session details`,onCancel:f,color:`background`,inputGuide:e=>e.pending?(0,J.jsxs)(A,{children:[`Press `,e.keyName,` again to exit`]}):(0,J.jsxs)(j,{children:[r&&(0,J.jsx)(D,{shortcut:`←`,action:`go back`}),(0,J.jsx)(D,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,J.jsx)(D,{shortcut:`t`,action:`teleport`})]}),children:[(0,J.jsxs)(k,{flexDirection:`column`,children:[(0,J.jsxs)(A,{children:[(0,J.jsx)(A,{bold:!0,children:`Status`}),`:`,` `,g===`running`||g===`starting`?(0,J.jsx)(A,{color:`background`,children:g}):g===`completed`?(0,J.jsx)(A,{color:`success`,children:g}):(0,J.jsx)(A,{color:`error`,children:g})]}),(0,J.jsxs)(A,{children:[(0,J.jsx)(A,{bold:!0,children:`Runtime`}),`: `,Fe((e.endTime??Date.now())-e.startTime)]}),(0,J.jsxs)(A,{wrap:`truncate-end`,children:[(0,J.jsx)(A,{bold:!0,children:`Title`}),`: `,h]}),(0,J.jsxs)(A,{children:[(0,J.jsx)(A,{bold:!0,children:`Progress`}),`: `,(0,J.jsx)(at,{session:e})]}),(0,J.jsxs)(A,{children:[(0,J.jsx)(A,{bold:!0,children:`Session URL`}),`:`,` `,(0,J.jsx)(Se,{url:w(e.sessionId),children:(0,J.jsx)(A,{dimColor:!0,children:w(e.sessionId)})})]})]}),e.log.length>0&&(0,J.jsxs)(k,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(A,{children:[(0,J.jsx)(A,{bold:!0,children:`Recent messages`}),`:`]}),(0,J.jsx)(k,{flexDirection:`column`,height:10,overflowY:`hidden`,children:d.map((e,n)=>(0,J.jsx)(o,{message:e,lookups:oe,addMargin:n>0,tools:t.options.tools,commands:t.options.commands,verbose:t.options.verbose,inProgressToolUseIDs:new Set,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,style:`condensed`,isTranscriptMode:!1,isStatic:!0},n))}),(0,J.jsx)(k,{marginTop:1,children:(0,J.jsxs)(A,{dimColor:!0,italic:!0,children:[`Showing last `,d.length,` of `,e.log.length,` messages`]})})]}),c&&(0,J.jsx)(k,{marginTop:1,children:(0,J.jsxs)(A,{color:`error`,children:[`Teleport failed: `,c]})}),a&&(0,J.jsx)(A,{color:`background`,children:`Teleporting to session…`})]})})}var q,J,yt,bt,xt=e((()=>{q=t(M(),1),Me(),B(),N(),x(),Re(),ae(),Ee(),L(),Ue(),h(),Le(),T(),a(),v(),ct(),J=F(),yt=[`finding`,`verifying`,`synthesizing`],bt={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function St(e){let t=l(e.id);try{let e=await De(t,Tt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function Ct({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=we(),[a,o]=(0,Y.useState)(()=>St(e)),s=(0,Y.useDeferredValue)(a);(0,Y.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(St(t)),1e3,o,e);return()=>clearInterval(t)},[e.id,e.status]);let c=()=>t(`Shell details dismissed`,{display:`system`});O({"confirm:yes":c},{context:`Confirmation`});let l=i=>{i.key===` `?(i.preventDefault(),t(`Shell details dismissed`,{display:`system`})):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},u=Ne(e.command,280);return(0,X.jsx)(k,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,X.jsxs)(P,{title:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,X.jsxs)(A,{children:[`Press `,t.keyName,` again to exit`]}):(0,X.jsxs)(j,{children:[r&&(0,X.jsx)(D,{shortcut:`←`,action:`go back`}),(0,X.jsx)(D,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,X.jsx)(D,{shortcut:`x`,action:`stop`})]}),children:[(0,X.jsxs)(k,{flexDirection:`column`,children:[(0,X.jsxs)(A,{children:[(0,X.jsx)(A,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,X.jsxs)(A,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,X.jsxs)(A,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,X.jsxs)(A,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,X.jsxs)(A,{children:[(0,X.jsx)(A,{bold:!0,children:`Runtime:`}),` `,Fe((e.endTime??Date.now())-e.startTime)]}),(0,X.jsxs)(A,{wrap:`wrap`,children:[(0,X.jsx)(A,{bold:!0,children:`Command:`}),` `,u]})]}),(0,X.jsxs)(k,{flexDirection:`column`,children:[(0,X.jsx)(A,{bold:!0,children:`Output:`}),(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(A,{dimColor:!0,children:`Loading output…`}),children:(0,X.jsx)(wt,{outputPromise:s,columns:i})})]})]})})}function wt({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,Y.use)(e);if(!n)return(0,X.jsx)(A,{dimColor:!0,children:`No output available`});let i=[],a=n.length;for(let e=0;e<10&&a>0;e++){let e=n.lastIndexOf(`
2
- `,a-1);i.push(e+1),a=e}i.reverse();let o=r>n.length,s=[];for(let e=0;e<i.length;e++){let t=i[e],r=e<i.length-1?i[e+1]-1:n.length,a=n.slice(t,r);a&&s.push(a)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,X.jsx)(A,{wrap:`truncate-end`,children:e},t))}),(0,X.jsxs)(A,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Ie(r)}`:``]})]})}var Y,X,Tt,Et=e((()=>{Y=t(M(),1),C(),N(),ve(),L(),Oe(),y(),X=F(),Tt=8192}));function Dt(e,t){return Object.values(e??{}).filter(g).filter(e=>!(e.type===`local_agent`&&e.id===t))}function Ot({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=te(e=>e.tasks),a=te(e=>e.foregroundedTaskId),o=i(),s=se(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),l=r,u=(0,Q.useRef)(!1),[d,p]=(0,Q.useState)(()=>{if(n)return u.current=!0,{mode:`detail`,itemId:n};let e=Dt(l,a);return e.length===1?(u.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[m,h]=(0,Q.useState)(0);ne(`background-tasks-dialog`);let{bashTasks:_,remoteSessions:v,agentTasks:y,workflowTasks:b,dreamTasks:ee,allSelectableItems:x}=(0,Q.useMemo)(()=>{let e=Object.values(l??{}).filter(g).map(kt).sort((e,t)=>{let n=e.status,r=t.status;if(n===`running`&&r!==`running`)return-1;if(n!==`running`&&r===`running`)return 1;let i=`task`in e?e.task.startTime:0;return(`task`in t?t.task.startTime:0)-i}),t=e.filter(e=>e.type===`local_bash`),n=e.filter(e=>e.type===`remote_agent`),r=e.filter(e=>e.type===`local_agent`&&e.id!==a),i=e.filter(e=>e.type===`local_workflow`),o=e.filter(e=>e.type===`dream`);return{bashTasks:t,remoteSessions:n,agentTasks:r,workflowTasks:i,dreamTasks:o,allSelectableItems:[...t,...n,...r,...i,...o]}},[l,a]),S=x[m]??null;O({"confirm:previous":()=>h(e=>Math.max(0,e-1)),"confirm:next":()=>h(e=>Math.min(x.length-1,e+1)),"confirm:yes":()=>{let e=x[m];e&&p({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:d.mode===`list`});let re=t=>{if(d.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=x[m];n&&t.key===`x`&&(t.preventDefault(),n.type===`local_bash`&&n.status===`running`?ie(n.id):n.type===`local_agent`&&n.status===`running`?ae(n.id):n.type===`local_workflow`&&n.status===`running`?At(n.id,o):n.type===`dream`&&n.status===`running`?oe(n.id):n.type===`remote_agent`&&n.status===`running`&&ce(n.id))};async function ie(e){await c.kill(e,o)}async function ae(e){await f.kill(e,o)}async function oe(e){await ye.kill(e,o)}async function ce(e){await me.kill(e,o)}let C=(0,Q.useEffectEvent)(e);(0,Q.useEffect)(()=>{if(d.mode!==`list`){let e=l?.[d.itemId];(!e||e.type!==`local_workflow`&&!g(e))&&(u.current?C(`Background tasks dialog dismissed`,{display:`system`}):p({mode:`list`}))}let e=x.length;m>=e&&e>0&&h(e-1)},[d,l,m,x,C]);let w=()=>{u.current&&x.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(u.current=!1,p({mode:`list`}))};if(d.mode!==`list`&&l){let n=l[d.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,$.jsx)(Ct,{shell:n,onDone:e,onKillShell:()=>void ie(n.id),onBack:w},`shell-${n.id}`);case`local_agent`:return(0,$.jsx)(Qe,{agent:n,onDone:e,onKillAgent:()=>void ae(n.id),onBack:w},`agent-${n.id}`);case`remote_agent`:return(0,$.jsx)(vt,{session:n,onDone:e,toolUseContext:t,onBack:w,onKill:n.status===`running`?()=>void ce(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`?()=>At(n.id,o):void 0;return(0,$.jsx)(k,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),w()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,$.jsx)(P,{title:n.workflowName,subtitle:(0,$.jsxs)(A,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:w,inputGuide:()=>(0,$.jsxs)(j,{children:[(0,$.jsx)(D,{shortcut:`←`,action:`go back`}),(0,$.jsx)(D,{shortcut:`Esc`,action:`close`}),e&&(0,$.jsx)(D,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,$.jsxs)(A,{color:`error`,children:[`失败原因:`,n.error]}):null})},`workflow-${n.id}`)}case`dream`:return(0,$.jsx)(pt,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:w,onKill:n.status===`running`?()=>void oe(n.id):void 0},`dream-${n.id}`)}}let T=ke(_,e=>e.status===`running`),E=ke(v,e=>e.status===`running`||e.status===`pending`)+ke(y,e=>e.status===`running`),le=je([...T>0?[(0,$.jsxs)(A,{children:[T,` `,T===1?`active shell`:`active shells`]},`shells`)]:[],...E>0?[(0,$.jsxs)(A,{children:[E,` `,E===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,$.jsx)(A,{children:` · `},`separator-${e}`)),ue=[(0,$.jsx)(D,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,$.jsx)(D,{shortcut:`Enter`,action:`view`},`enter`),...(S?.type===`local_bash`||S?.type===`local_agent`||S?.type===`local_workflow`||S?.type===`dream`||S?.type===`remote_agent`)&&S.status===`running`?[(0,$.jsx)(D,{shortcut:`x`,action:`stop`},`kill`)]:[],...y.some(e=>e.status===`running`)?[(0,$.jsx)(D,{shortcut:s,action:`stop all agents`},`kill-all`)]:[],(0,$.jsx)(D,{shortcut:`←/Esc`,action:`close`},`esc`)],de=()=>e(`Background tasks dialog dismissed`,{display:`system`});function fe(e){return e.pending?(0,$.jsxs)(A,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsx)(j,{children:ue})}return(0,$.jsx)(k,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:re,children:(0,$.jsx)(P,{title:`Background tasks`,subtitle:le,onCancel:de,color:`background`,inputGuide:fe,children:x.length===0?(0,$.jsx)(A,{dimColor:!0,children:`No tasks currently running`}):(0,$.jsxs)(k,{flexDirection:`column`,children:[_.length>0&&(0,$.jsxs)(k,{flexDirection:`column`,children:[(v.length>0||y.length>0)&&(0,$.jsxs)(A,{dimColor:!0,children:[(0,$.jsxs)(A,{bold:!0,children:[` `,`Shells`]}),` (`,_.length,`)`]}),(0,$.jsx)(k,{flexDirection:`column`,children:_.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===S?.id},e.id))})]}),v.length>0&&(0,$.jsxs)(k,{flexDirection:`column`,marginTop:+(_.length>0),children:[(0,$.jsxs)(A,{dimColor:!0,children:[(0,$.jsxs)(A,{bold:!0,children:[` `,`Remote agents`]}),` (`,v.length,`)`]}),(0,$.jsx)(k,{flexDirection:`column`,children:v.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===S?.id},e.id))})]}),y.length>0&&(0,$.jsxs)(k,{flexDirection:`column`,marginTop:+(_.length>0||v.length>0),children:[(0,$.jsxs)(A,{dimColor:!0,children:[(0,$.jsxs)(A,{bold:!0,children:[` `,`Local agents`]}),` (`,y.length,`)`]}),(0,$.jsx)(k,{flexDirection:`column`,children:y.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===S?.id},e.id))})]}),b.length>0&&(0,$.jsxs)(k,{flexDirection:`column`,marginTop:+(_.length>0||v.length>0||y.length>0),children:[(0,$.jsxs)(A,{dimColor:!0,children:[(0,$.jsxs)(A,{bold:!0,children:[` `,`Workflows`]}),` (`,b.length,`)`]}),(0,$.jsx)(k,{flexDirection:`column`,children:b.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===S?.id},e.id))})]}),ee.length>0&&(0,$.jsx)(k,{flexDirection:`column`,marginTop:+(_.length>0||v.length>0||y.length>0||b.length>0),children:(0,$.jsx)(k,{flexDirection:`column`,children:ee.map(e=>(0,$.jsx)(Z,{item:e,isSelected:e.id===S?.id},e.id))})})]})})})}function kt(e){switch(e.type){case`local_bash`:return{id:e.id,type:`local_bash`,label:e.command,status:e.status,task:e};case`remote_agent`:return{id:e.id,type:`remote_agent`,label:e.title,status:e.status,task:e};case`local_agent`:return{id:e.id,type:`local_agent`,label:e.description,status:e.status,task:e};case`local_workflow`:return{id:e.id,type:`local_workflow`,label:e.summary??e.description,status:e.status,task:e};case`dream`:return{id:e.id,type:`dream`,label:e.description,status:e.status,task:e}}}function Z({item:e,isSelected:t}){let{columns:n}=we(),i=Math.max(30,n-26);return(0,$.jsxs)(k,{flexDirection:`row`,children:[(0,$.jsx)(A,{children:t?`${r.pointer} `:` `}),(0,$.jsx)(A,{color:t?`suggestion`:void 0,children:(0,$.jsx)(dt,{task:e.task,maxActivityWidth:i})})]})}var Q,$,At,jt=e((()=>{n(),Q=t(M(),1),C(),ee(),re(),_(),s(),x(),d(),Ae(),E(),N(),ve(),S(),et(),ft(),mt(),xt(),Et(),_e(),$=F(),At=le}));export{B as a,Xe as i,jt as n,z as o,Ze as r,Ot as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$d as t,Qd as n,Qu as r,Zu as i}from"./loadAgentsDir-DXOkUcW3.js";import{I as a,Lt as o,P as s,ai as c,kt as l,t as u,y as d}from"./src-DL3w8VPk2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{b as p,h as m}from"./settings-3xZ0fsvE.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";var _=e(c(),1);h(),u(),t(),m(),i();var v=f();function y({onAccept:e}){let[t,i]=_.useState(null);_.useEffect(()=>{if(t!==null){let e=t,r=setTimeout(()=>n(e));return()=>clearTimeout(r)}},[t]),_.useEffect(()=>{g(`tengu_bypass_permissions_mode_dialog_shown`,{})},[]);function c(t){switch(t){case`accept`:g(`tengu_bypass_permissions_mode_dialog_accept`,{}),p(`userSettings`,{skipDangerousModePermissionPrompt:!0}),e();break;case`decline`:i(1);break}}let u=(0,_.useCallback)(()=>{i(0)},[]);return t===null?(0,v.jsxs)(d,{title:`WARNING: Work Mate running in Bypass Permissions mode`,color:`error`,onCancel:u,children:[(0,v.jsxs)(a,{flexDirection:`column`,gap:1,children:[(0,v.jsxs)(s,{children:[`In Bypass Permissions mode, Work Mate will not ask for your approval before running potentially dangerous commands.`,(0,v.jsx)(l,{}),`This mode should only be used in a sandboxed container/VM that has restricted internet access and can easily be restored if damaged.`]}),(0,v.jsx)(s,{children:`By proceeding, you accept all responsibility for actions taken while running in Bypass Permissions mode.`}),(0,v.jsx)(o,{url:`https://code.workmate.com/docs/en/security`})]}),(0,v.jsx)(r,{options:[{label:`No, exit`,value:`decline`},{label:`Yes, I accept`,value:`accept`}],onChange:e=>c(e)})]}):null}export{y as BypassPermissionsModeDialog};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./Doctor-DiNxlXfC.js";e();export{t as Doctor};
@@ -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{$i as o,AT as s,By as c,GC as l,HC as u,H_ as d,Jl as f,KC as p,Ky as m,Lw as ee,OT as h,Qi as g,Qw as _,Rw as v,UC as te,U_ as y,Uy as b,WC as x,Wy as ne,Xh as re,Xl as S,Yl as C,Zh as w,jT as ie,kT as ae,tT as T,uC as oe}from"./loadAgentsDir-DXOkUcW3.js";import{Gt as se,I as E,P as D,ai as ce,t as O,x as k}from"./src-DL3w8VPk2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as j,Ut as M}from"./state-D5D6QpTX.js";import{Cn as N,On as P,R as F,V as I}from"./settings-3xZ0fsvE.js";import{l as L,o as R}from"./stringUtils-CKD8qDqx.js";import{Bn as z,Ln as B,_ as V,u as H}from"./model-Cxx3suBa.js";import{n as U,t as W}from"./ValidationErrorsList-BfZ5gcIv.js";import{f as G,g as le,h as ue,i as de,n as fe,o as pe,p as me,r as he}from"./pidLock-CEhbTkBE.js";import{n as ge,t as _e}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";import{n as ve,t as ye}from"./McpParsingWarnings-D4UQ8Q2e.js";import{n as be,t as xe}from"./PressEnterToContinue-Dwoh6CaW.js";import{n as Se,t as Ce}from"./useSettingsErrors-Xc6RYjYF.js";import{n as we,t as Te}from"./shadowedRuleDetection-BL7dEv-u.js";import{n as Ee,r as De,t as K}from"./statusNoticeHelpers-BrN_2q7H.js";import{join as q}from"path";function Oe(){if(!ie())return null;let e=h();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)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(D,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`Location: `}),(0,J.jsx)(D,{dimColor:!0,children:ae()})]}),(0,J.jsxs)(E,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`error`,children:`[Error]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,ke=e((()=>{O(),s(),J=A()}));function Ae(){if(!_.isSupportedPlatform()||!_.isSandboxEnabledInSettings())return null;let e=_.checkDependencies(),t=e.errors.length>0,n=e.warnings.length>0;return!t&&!n?null:(0,Y.jsxs)(E,{flexDirection:`column`,children:[(0,Y.jsx)(D,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(D,{children:[`└ Status: `,(0,Y.jsx)(D,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(D,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(D,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(D,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,je=e((()=>{O(),T(),Y=A()}));async function Me(){let e=b(await ne());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 > ${c.toLocaleString()})`:`${e.length} large AGENTS.md files detected (each > ${c.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:c}}async function Ne(e){if(!e)return null;let t=Ee(e);if(t<=15e3)return null;let n=e.activeAgents.filter(e=>e.source!==`built-in`).map(e=>{let t=`${e.agentType}: ${e.whenToUse}`;return{name:e.agentType,tokens:o(t)}}).sort((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>`${e.name}: ~${e.tokens.toLocaleString()} tokens`);return n.length>5&&r.push(`(${n.length-5} more custom agents)`),{type:`agent_descriptions`,severity:`warning`,message:`Large agent descriptions (~${t.toLocaleString()} tokens > ${K.toLocaleString()})`,details:r,currentValue:t,threshold:K}}async function X(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await d(e,t,n,H());if(r<=Z)return null;let a=new Map;for(let e of i){let t=e.name.split(`__`)[1]||`unknown`,n=a.get(t)||{count:0,tokens:0};a.set(t,{count:n.count+1,tokens:n.tokens+e.tokens})}let o=Array.from(a.entries()).sort((e,t)=>t[1].tokens-e[1].tokens),s=o.slice(0,5).map(([e,t])=>`${e}: ${t.count} tools (~${t.tokens.toLocaleString()} tokens)`);return o.length>5&&s.push(`(${o.length-5} more servers)`),{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${r.toLocaleString()} tokens > ${Z.toLocaleString()})`,details:s,currentValue:r,threshold:Z}}catch{let e=r.reduce((e,t)=>e+o(((t.name?.length||0)+t.description.length).toString()),0);return e<=Z?null:{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${e.toLocaleString()} tokens estimated > ${Z.toLocaleString()})`,details:[`${r.length} MCP tools detected (token count estimated)`],currentValue:e,threshold:Z}}}async function Pe(e){let t=Te(await e(),{sandboxAutoAllowEnabled:_.isSandboxingEnabled()&&_.isAutoAllowBashIfSandboxedEnabled()});if(t.length===0)return null;let n=t.flatMap(e=>[`${I(e.rule.ruleValue)}: ${e.reason}`,` Fix: ${e.fix}`]);return{type:`unreachable_rules`,severity:`warning`,message:`${t.length} ${L(t.length,`unreachable permission rule`)} detected`,details:n,currentValue:t.length,threshold:0}}async function Fe(e,t,n){let[r,i,a,o]=await Promise.all([Me(),Ne(t),X(e,n,t),Pe(n)]);return{agentsMdWarning:r,agentWarning:i,mcpWarning:a,unreachableRulesWarning:o}}var Z,Ie=e((()=>{g(),y(),m(),V(),F(),we(),T(),De(),R(),Z=25e3}));function Le({onDone:e}){let t=w(e=>e.agentDefinitions),r=w(e=>e.mcp.tools),i=w(e=>e.toolPermissionContext),o=w(e=>e.plugins.errors);ge();let s=(0,Q.useMemo)(()=>r||[],[r]),[c,l]=(0,Q.useState)(null),[d,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=Se().filter(e=>e.mcpErrorMetadata===void 0),b=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:u,upperLimit:te},{name:`TASK_MAX_OUTPUT_LENGTH`,default:f,upperLimit:C},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...B(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=p(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{ue().then(l),(async()=>{let e=q(n(),`agents`),r=q(j(),`.workmate`,`agents`),{activeAgents:a,allAgents:o,failedFiles:c}=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:c};m(d);let f=await Fe(s,{activeAgents:a,allAgents:o,failedFiles:c},async()=>i);if(g(f),pe()){let e=q(G(),`claude`,`locks`),t=fe(e),n=he(e);v({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else v({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,s,t]);let x=(0,Q.useCallback)(()=>{e(`Work Mate diagnostics dismissed`,{display:`system`})},[e]);return se({"confirm:yes":x,"confirm:no":x},{context:`Confirmation`}),c?(0,$.jsxs)(k,{children:[(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(D,{children:[`└ Currently running: `,c.installationType,` (`,c.version,`)`]}),c.packageManager&&(0,$.jsxs)(D,{children:[`└ Package manager: `,c.packageManager]}),(0,$.jsxs)(D,{children:[`└ Path: `,c.installationPath]}),(0,$.jsxs)(D,{children:[`└ Invoked: `,c.invokedBinary]}),(0,$.jsxs)(D,{children:[`└ Config install method: `,c.configInstallMethod]}),(0,$.jsxs)(D,{children:[`└ Search: `,c.ripgrepStatus.working?`OK`:`Not working`,` (`,c.ripgrepStatus.mode===`embedded`?`bundled`:c.ripgrepStatus.mode===`builtin`?`vendor`:c.ripgrepStatus.systemPath||`system`,`)`]}),c.ripgrepStatus.note&&(0,$.jsxs)(D,{color:`warning`,children:[`└ Note: `,c.ripgrepStatus.note]}),c.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsxs)(D,{color:`warning`,children:[`Recommendation: `,c.recommendation.split(`
2
- `)[0]]}),(0,$.jsx)(D,{dimColor:!0,children:c.recommendation.split(`
3
- `)[1]})]}),c.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsx)(D,{color:`warning`,children:`Warning: Multiple installations found`}),c.multipleInstallations.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.type,` at `,e.path]},t))]}),c.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),c.warnings.map((e,t)=>(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsxs)(D,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(D,{children:[`Fix: `,e.fix]})]},t))]}),y.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(D,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(W,{errors:y})]})]}),(0,$.jsx)(Ae,{}),(0,$.jsx)(ye,{}),(0,$.jsx)(Oe,{}),b.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Environment Variables`}),b.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(D,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),_?.enabled&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Version Locks`}),_.staleLocksCleaned>0&&(0,$.jsxs)(D,{dimColor:!0,children:[`└ Cleaned `,_.staleLocksCleaned,` stale lock(s)`]}),_.locks.length===0?(0,$.jsx)(D,{dimColor:!0,children:`└ No active version locks`}):_.locks.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(D,{children:`(running)`}):(0,$.jsx)(D,{color:`warning`,children:`(stale)`})]},t))]}),d?.failedFiles&&d.failedFiles.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ Failed to parse `,d.failedFiles.length,` agent file(s):`]}),d.failedFiles.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),o.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ `,o.length,` plugin error(s) detected:`]}),o.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,ee(e)]},t))]}),h?.unreachableRulesWarning&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,h.unreachableRulesWarning.message]})]}),h.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),h&&(h.agentsMdWarning||h.agentWarning||h.mcpWarning)&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Context Usage Warnings`}),h.agentsMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,h.agentsMdWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Files:`]}),h.agentsMdWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),h.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,h.agentWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Top contributors:`]}),h.agentWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),h.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,h.mcpWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ MCP servers:`]}),h.mcpWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(E,{children:(0,$.jsx)(xe,{})})]}):(0,$.jsx)(k,{children:(0,$.jsx)(D,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,Re=e((()=>{i(),Q=t(ce(),1),ke(),ve(),z(),r(),M(),O(),be(),je(),U(),Ce(),_e(),oe(),re(),v(),Ie(),le(),l(),N(),de(),x(),S(),me(),$=A()}));export{Re as n,Le as t};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{$d as r,$u as i,AC as a,JT as o,Mu as s,Pu as c,Qu as l,St as u,Tt as d,YT as f,Zd as p,br as m,fT as h,ft as g,kC as _,mi as v,pT as y,wt as b,yt as x}from"./loadAgentsDir-DXOkUcW3.js";import{I as S,P as C,ai as w,t as T,y as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{c as O,i as k}from"./debug-D58GQBDG.js";import{r as A,t as j}from"./execFileNoThrow-Bmb5HEFz.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(m(),e(v)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,r]=(0,I.useState)(`loading`),[i,c]=(0,I.useState)([]),[u,f]=(0,I.useState)(0),[p,m]=(0,I.useState)(),h=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()!==``),c(e)),h){let{stdout:t}=await j(`git`,[`rev-list`,`--count`,`${h.originalHeadCommit}..HEAD`]),n=parseInt(t.trim(),10)||0;if(f(n),e.length===0&&n===0){r(`removing`),g().then(()=>{process.chdir(h.originalCwd),a(h.originalCwd),P(),o.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()},[h]),(0,I.useEffect)(()=>{n===`done`&&e(p)},[n,e,p]),!h)return e(`No active worktree session found`,{display:`system`}),null;if(n===`loading`||n===`done`)return null;async function _(e){if(!h)return;let t=!!h.tmuxSessionName;if(e===`keep`||e===`keep-with-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:u,changed_files:i.length}),await b(),process.chdir(h.originalCwd),a(h.originalCwd),P(),o.cache.clear?.(),m(t?`Worktree kept. Your work is saved at ${h.worktreePath} on branch ${h.worktreeBranch}. Reattach to tmux session with: tmux attach -t ${h.tmuxSessionName}`:`Worktree kept. Your work is saved at ${h.worktreePath} on branch ${h.worktreeBranch}`),r(`done`);else if(e===`keep-kill-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:u,changed_files:i.length}),h.tmuxSessionName&&await d(h.tmuxSessionName),await b(),process.chdir(h.originalCwd),a(h.originalCwd),P(),o.cache.clear?.(),m(`Worktree kept at ${h.worktreePath} on branch ${h.worktreeBranch}. Tmux session terminated.`),r(`done`);else if(e===`remove`||e===`remove-with-tmux`){r(`removing`),N(`tengu_worktree_removed`,{commits:u,changed_files:i.length}),h.tmuxSessionName&&await d(h.tmuxSessionName);try{await g(),process.chdir(h.originalCwd),a(h.originalCwd),P(),o.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&&i.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 ${h.worktreeBranch} ${u===1?`was`:`were`} discarded.${e}`):i.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)(s,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(s,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let v=h.worktreeBranch,y=i.length>0,w=u>0,T=``;T=y&&w?`You have ${i.length} uncommitted ${i.length===1?`file`:`files`} and ${u} ${u===1?`commit`:`commits`} on ${v}. All will be lost if you remove.`:y?`You have ${i.length} uncommitted ${i.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${u} ${u===1?`commit`:`commits`} on ${v}. 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=y||w?`All changes and commits will be lost.`:`Clean up the worktree directory.`,A=!!h.tmuxSessionName,M=A?[{label:`Keep worktree and tmux session`,value:`keep-with-tmux`,description:`Stays at ${h.worktreePath}. Reattach with: tmux attach -t ${h.tmuxSessionName}`},{label:`Keep worktree, kill tmux session`,value:`keep-kill-tmux`,description:`Keeps worktree at ${h.worktreePath}, terminates tmux session.`},{label:`Remove worktree and tmux session`,value:`remove-with-tmux`,description:k}]:[{label:`Keep worktree`,value:`keep`,description:`Stays at ${h.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)(l,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:_})})}var I,L,R=t((()=>{I=n(w(),1),M(),k(),T(),A(),f(),_(),u(),i(),c(),L=D()}));function z(){return y(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await p(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{h(),r(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
@@ -1 +0,0 @@
1
- import{Ou as e,Qu as t,Xh as n,Yh as r,Zu as i,ku as a}from"./loadAgentsDir-DXOkUcW3.js";import{I as o,P as s,kn as c,t as l,y as u}from"./src-DL3w8VPk2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{C as f,T as p,x as m}from"./debug-D58GQBDG.js";import{t as h}from"./renderOptions-D-aQZbzS.js";l(),a(),n(),m(),i();var g=d();function _({filePath:e,errorDescription:n,onExit:r,onReset:i}){return(0,g.jsxs)(u,{title:`Configuration Error`,color:`error`,onCancel:r,children:[(0,g.jsxs)(o,{flexDirection:`column`,gap:1,children:[(0,g.jsxs)(s,{children:[`The configuration file at `,(0,g.jsx)(s,{bold:!0,children:e}),` contains invalid JSON.`]}),(0,g.jsx)(s,{children:n})]}),(0,g.jsxs)(o,{flexDirection:`column`,children:[(0,g.jsx)(s,{bold:!0,children:`Choose an option:`}),(0,g.jsx)(t,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Reset with default configuration`,value:`reset`}],onChange:e=>{e===`exit`?r():i()},onCancel:r})]})]})}var v=`dark`;async function y({error:t}){let n={...h(!1),theme:v};await new Promise(async i=>{let{unmount:a}=await c((0,g.jsx)(r,{children:(0,g.jsx)(e,{children:(0,g.jsx)(_,{filePath:t.filePath,errorDescription:t.message,onExit:()=>{a(),i(),process.exit(1)},onReset:()=>{p(t.filePath,f(t.defaultConfig,null,2),{flush:!1,encoding:`utf8`}),a(),i(),process.exit(0)}})})}),n)})}export{y as showInvalidConfigDialog};
@@ -1 +0,0 @@
1
- import{Qu as e,Zu as t}from"./loadAgentsDir-DXOkUcW3.js";import{P as n,t as r,y as i}from"./src-DL3w8VPk2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{n as o,t as s}from"./ValidationErrorsList-BfZ5gcIv.js";r(),t(),o();var c=a();function l({settingsErrors:t,onContinue:r,onExit:a}){function o(e){e===`exit`?a():r()}return(0,c.jsxs)(i,{title:`Settings Error`,onCancel:a,color:`warning`,children:[(0,c.jsx)(s,{errors:t}),(0,c.jsx)(n,{dimColor:!0,children:`Files with errors are skipped entirely, not just the invalid settings.`}),(0,c.jsx)(e,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Continue without these settings`,value:`continue`}],onChange:o})]})}export{l as InvalidSettingsDialog};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$h as n,Ab as r,Ax as i,BS as a,Bx as o,Cb as s,Cx as c,Eb as l,IS as u,Ix as d,LS as f,Lx as p,Mx as m,Ob as h,Qh as ee,Rx as g,Sb as _,Tb as v,Tx as te,VS as y,Xd as b,Xh as x,Yd as ne,Zh as S,ax as C,dx as re,hT as w,jb as T,jx as E,mT as D,vx as O,wx as ie,xb as k,yb as A}from"./loadAgentsDir-DXOkUcW3.js";import{ai as j}from"./src-DL3w8VPk2.js";import{t as M}from"./jsx-runtime-Bb4Xn-E0.js";import{Ut as N,ft as ae}from"./state-D5D6QpTX.js";import{P,R as oe,c as se,i as ce}from"./debug-D58GQBDG.js";import{rt as F,tt as I}from"./settings-3xZ0fsvE.js";import{c as L,l as R,o as z}from"./log-CZ7ploQm.js";import{n as B,r as V}from"./analytics-DJobLaWP.js";import{o as H,t as U}from"./localSearch-DnT21UkF.js";import{n as W,t as le}from"./omit-DZUxsClb.js";function G(e){let t=`plugin`in e?e.plugin:`no-plugin`;return`${e.type}:${e.source}:${t}`}function K(e,t){t.length!==0&&e(e=>{let n=new Set(e.plugins.errors.map(e=>G(e))),r=t.filter(e=>!n.has(G(e)));return r.length===0?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,...r]}}})}function ue(e,t=!1){let r=ee(),o=S(e=>e.authVersion),l=S(e=>e.mcp.pluginReconnectKey),y=n(),x=(0,q.useRef)(new Map),{addNotification:ne}=b(),E=(0,q.useRef)([]),D=(0,q.useRef)(null),O=(0,q.useCallback)(()=>{D.current=null;let e=E.current;e.length!==0&&(E.current=[],y(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:[...w(n.tools,e=>e.name?.startsWith(l)),...o],f=s===void 0?n.commands:[...w(n.commands,e=>C(e,a.name)),...s],p=c===void 0?n.resources:{...n.resources,...c.length>0?{[a.name]:c}:W(n.resources,a.name)};n={...n,clients:u,tools:d,commands:f,resources:p}}return{...t,mcp:n}}))},[y]),j=(0,q.useCallback)(e=>{E.current.push(e),D.current===null&&(D.current=setTimeout(O,16))},[O]),M=(0,q.useCallback)(({client:e,tools:t,commands:n,resources:r})=>{switch(j({...e,tools:t,commands:n,resources:r}),e.type){case`connected`:T(e.client,e.name,y),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(A(e.name,e.config).catch(()=>{se(`Failed to invalidate the server cache: ${e.name}`)}),m(e.name)){L(e.name,`Server is disabled, skipping automatic reconnection`);return}if(t!==`stdio`&&t!==`sdk`){let n=de(t);L(e.name,`${n} transport closed/disconnected, attempting automatic reconnection`);let r=x.current.get(e.name);r&&(clearTimeout(r),x.current.delete(e.name)),(async()=>{for(let t=1;t<=J;t++){if(m(e.name)){L(e.name,`Server disabled during reconnection, stopping retry`),x.current.delete(e.name);return}j({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:J});let r=Date.now();try{let i=await h(e.name,e.config),a=Date.now()-r;if(i.client.type===`connected`){L(e.name,`${n} reconnection successful after ${a}ms (attempt ${t})`),x.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`),x.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`),x.current.delete(e.name),j({...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);x.current.set(e.name,n)})}})()}else j({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(a,async()=>{L(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=s.cache.get(e.name);s.cache.delete(e.name);let n=await s(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}),j({...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(u,async()=>{L(e.name,`Received prompts/list_changed notification, refreshing prompts`),V(`tengu_mcp_list_changed`,{type:`prompts`});try{k.cache.delete(e.name);let[t,n]=await Promise.all([k(e),Promise.resolve([])]);j({...e,commands:[...t,...n]}),U()}catch(t){R(e.name,`Failed to refresh prompts after list_changed notification: ${P(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(f,async()=>{L(e.name,`Received resources/list_changed notification, refreshing resources`),V(`tengu_mcp_list_changed`,{type:`resources`});try{_.cache.delete(e.name);{let t=await _(e);j({...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}},[j]),N=ae();return(0,q.useEffect)(()=>{async function n(){let{servers:n,errors:r}=t?{servers:{},errors:[]}:await i(e),a={...n,...e};K(y,r),y(e=>{let{stale:t,...n}=re(e.mcp,a);for(let e of t){let t=x.current.get(e.name);t&&(clearTimeout(t),x.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,A(e.name,e.config).catch(()=>{}))}let r=new Set(n.clients.map(e=>e.name)),i=Object.entries(a).filter(([e])=>!r.has(e)).map(([e,t])=>({name:e,type:m(e)?`disabled`:`pending`,config:t}));return i.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...i]}}})}n().catch(e=>{R(`useManageMCPConnections`,`Failed to initialize servers as pending: ${P(e)}`)})},[t,e,y,N,l]),(0,q.useEffect)(()=>{let n=!1;async function r(){let r;t||ie()?r=Promise.resolve({}):(p(),r=g());let{servers:a,errors:o}=t?{servers:{},errors:[]}:await i(e,r);if(n)return;K(y,o);let s={...a,...e},l=Object.fromEntries(Object.entries(s).filter(([e])=>!m(e)));v(M,l).catch(e=>{R(`useManageMcpConnections`,`Failed to get MCP resources: ${P(e)}`)});let u={};if(!t){if(u=te(await r).allowed,n)return;if(Object.keys(u).length>0){let{servers:e}=c(u,s);u=e}if(Object.keys(u).length>0){y(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(u).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:m(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(u).filter(([e])=>!m(e)));v(M,e).catch(e=>{R(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${P(e)}`)})}}let d={...s,...u},f={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(d))t.scope===`enterprise`?f.enterprise++:t.scope===`user`?f.global++:t.scope===`project`?f.project++:t.scope===`local`?f.user++:t.scope===`dynamic`?f.plugin++:t.scope===`claudeai`&&f.claudeai++;V(`tengu_mcp_servers`,{...f})}return r(),()=>{n=!0}},[t,e,M,y,o,N,l]),(0,q.useEffect)(()=>{let e=x.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),D.current!==null&&(clearTimeout(D.current),D.current=null,O())}},[O]),{reconnectMcpServer:(0,q.useCallback)(async e=>{let t=r.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);let n=x.current.get(e);n&&(clearTimeout(n),x.current.delete(e));let i=await h(e,t.config);return M(i),i},[r,M]),toggleMcpServer:(0,q.useCallback)(async e=>{let t=r.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);if(t.type!==`disabled`){let n=x.current.get(e);n&&(clearTimeout(n),x.current.delete(e)),d(e,!1),t.type===`connected`&&await A(e,t.config),j({name:e,type:`disabled`,config:t.config})}else{d(e,!0),j({name:e,type:`pending`,config:t.config});let n=await h(e,t.config);M(n)}},[r,j,M])}}function de(e){switch(e){case`http`:return`HTTP`;case`ws`:case`ws-ide`:return`WebSocket`;default:return`SSE`}}var q,J,Y,X,fe=e((()=>{q=t(j(),1),N(),l(),H(),y(),le(),D(),B(),E(),ce(),ne(),x(),oe(),z(),r(),o(),F(),O(),J=5,Y=1e3,X=3e4}));function pe(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpReconnect must be used within MCPConnectionManager`);return e.reconnectMcpServer}function me(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpToggleEnabled must be used within MCPConnectionManager`);return e.toggleMcpServer}function he({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=ue(t,n),a=(0,Z.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,Q.jsx)($.Provider,{value:a,children:e})}var Z,Q,$,ge=e((()=>{Z=t(j(),1),fe(),Q=M(),$=(0,Z.createContext)(null)}));export{me as i,ge as n,pe as r,he 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{$h as i,Dp as a,Dx as o,Eb as s,Kb as c,Mu as l,Op as u,Pu as d,Qu as ee,Rb as te,Ub as f,Wb as ne,Xh as p,Zh as m,Zu as h,cd as re,eS as g,fx as ie,gC as _,hx as ae,jx as v,ld as y,lx as oe,mx as se,ox as ce,tS as le,uC as b,ux as ue,vx as x,yb as de}from"./loadAgentsDir-DXOkUcW3.js";import{D as S,H as fe,I as C,Lt as pe,P as w,T,Wt as me,ai as E,dr as he,hn as ge,j as D,ot as _e,t as O,y as k}from"./src-DL3w8VPk2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{P as ve,R as j}from"./debug-D58GQBDG.js";import{$ as M,et as N,rt as P}from"./settings-3xZ0fsvE.js";import{c as ye,o as F}from"./log-CZ7ploQm.js";import{n as I,r as L}from"./analytics-DJobLaWP.js";import{l as be,u as R}from"./oauth-D38aRTUb.js";import{l as xe,n as Se,o as z}from"./stringUtils-CKD8qDqx.js";import{Pt as B,Tt as Ce}from"./model-Cxx3suBa.js";import{i as we,n as V,r as Te}from"./MCPConnectionManager-CdpO2Tj9.js";import{n as Ee,t as H}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";function De({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,U.jsxs)(C,{children:[(0,U.jsx)(w,{bold:!0,children:`Capabilities: `}),(0,U.jsx)(w,{color:`text`,children:r.length>0?(0,U.jsx)(T,{children:r}):`none`})]})}var U,Oe=e((()=>{O(),U=A()}));function ke(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 Ae(e,t){return`Error reconnecting to ${t}: ${e instanceof Error?e.message:String(e)}`}var W=e((()=>{}));function je({server:e,serverToolsCount:t,onViewTools:n,onCancel:o,onComplete:s,borderless:u=!1}){let[d]=fe(),f=Ee(),{columns:p}=_e(),[h,g]=G.useState(!1),[_,ae]=G.useState(null),v=m(e=>e.mcp),y=i(),[b,x]=G.useState(null),[E,O]=(0,G.useState)(!1),k=(0,G.useRef)(null),[A,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(!1),[I,R]=(0,G.useState)(null),[xe,z]=(0,G.useState)(!1),[B,V]=(0,G.useState)(!1),H=(0,G.useRef)(void 0),U=(0,G.useRef)(!1),[Oe,W]=(0,G.useState)(``),[je,Me]=(0,G.useState)(0),[Ne,q]=(0,G.useState)(null);(0,G.useEffect)(()=>()=>{U.current=!0,k.current?.abort(),H.current!==void 0&&clearTimeout(H.current)},[]);let J=e.isAuthenticated||e.client.type===`connected`&&t>0,Y=Te(),Pe=G.useCallback(async()=>{j(!1),N(null),O(!0);try{let t=await Y(e.name),n=t.client.type===`connected`;L(`tengu_claudeai_mcp_auth_completed`,{success:n}),n?s?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?s?.(`Authentication successful, but server still requires authentication. You may need to manually restart Work Mate.`):s?.(`Authentication successful, but server reconnection failed. You may need to manually restart Work Mate for the changes to take effect.`)}catch(t){L(`tengu_claudeai_mcp_auth_completed`,{success:!1}),s?.(Ae(t,e.name))}finally{O(!1)}},[Y,e.name,s]),X=G.useCallback(async()=>{await de(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=ie(t.mcp.tools,e.name),i=oe(t.mcp.commands,e.name),a=ue(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),L(`tengu_claudeai_mcp_clear_auth_completed`,{}),s?.(`Disconnected from ${e.name}.`),F(!1),R(null),z(!1)},[e.name,e.config,e.scope,y,s]);me(`confirm:no`,()=>{k.current?.abort(),k.current=null,g(!1),x(null)},{context:`Confirmation`,isActive:h}),me(`confirm:no`,()=>{j(!1),N(null)},{context:`Confirmation`,isActive:A}),me(`confirm:no`,()=>{F(!1),R(null),z(!1)},{context:`Confirmation`,isActive:P}),ge((e,t)=>{if(t.return&&A&&Pe(),t.return&&P)if(xe)X();else{let e=`${be().CLAUDE_AI_ORIGIN}/settings/connectors`;R(e),z(!0),le(e)}if(e===`c`&&!B){let e=b||M||I;e&&he(e).then(e=>{U.current||(e&&process.stdout.write(e),V(!0),H.current!==void 0&&clearTimeout(H.current),H.current=setTimeout(V,2e3,!1))})}});let Z=Se(String(e.name)),Fe=se(v.commands,e.name).length,Ie=we(),Le=G.useCallback(async()=>{let t=be().CLAUDE_AI_ORIGIN,n=Ce()?.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`,N(r),j(!0),L(`tengu_claudeai_mcp_auth_started`,{}),await le(r)},[e.config]),Q=G.useCallback(()=>{F(!0),L(`tengu_claudeai_mcp_clear_auth_started`,{})},[]),Re=G.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await Ie(e.name),e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_toggle`,{new_state:t?`disabled`:`enabled`}),o()}catch(n){s?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.config.type,e.name,Ie,o,s]),ze=G.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;g(!0),ae(null);let t=new AbortController;k.current=t;try{if(e.isAuthenticated&&e.config&&await c(e.name,e.config,{preserveStepUpState:!0}),e.config){await ne(e.name,e.config,x,t.signal,{onWaitingForCallback:e=>{q(()=>e)}}),L(`tengu_mcp_auth_config_authenticate`,{wasAuthenticated:e.isAuthenticated});let n=await Y(e.name);if(n.client.type===`connected`){let t=J?`Authentication successful. Reconnected to ${e.name}.`:`Authentication successful. Connected to ${e.name}.`;s?.(t)}else n.client.type===`needs-auth`?s?.(`Authentication successful, but server still requires authentication. You may need to manually restart Work Mate.`):(ye(e.name,`Reconnection failed after authentication`),s?.(`Authentication successful, but server reconnection failed. You may need to manually restart Work Mate for the changes to take effect.`))}}catch(e){e instanceof Error&&!(e instanceof te)&&ae(e.message)}finally{g(!1),k.current=null,q(null),W(``)}},[e.isAuthenticated,e.config,e.name,s,Y,J]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await c(e.name,e.config),L(`tengu_mcp_auth_config_clear`,{}),await de(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=ie(t.mcp.tools,e.name),i=oe(t.mcp.commands,e.name),a=ue(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),s?.(`Authentication cleared for ${e.name}.`))};if(h){let t=e.config.type!==`claudeai-proxy`&&e.config.oauth?.xaa?` Authenticating via your identity provider`:` A browser window will open for authentication`;return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(l,{}),(0,K.jsx)(w,{children:t})]}),b&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:b})]}),h&&b&&Ne&&(0,K.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,K.jsx)(w,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,K.jsxs)(C,{children:[(0,K.jsxs)(w,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,K.jsx)(re,{value:Oe,onChange:W,onSubmit:e=>{Ne(e.trim()),W(``)},cursorOffset:je,onChangeCursorOffset:Me,columns:p-8})]})]}),(0,K.jsx)(C,{marginLeft:3,children:(0,K.jsx)(w,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(A)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(l,{}),(0,K.jsx)(w,{children:` A browser window will open for authentication`})]}),M&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:M})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(P)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Clear authentication for `,e.name]}),xe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`Find the MCP server in the browser and click "Disconnect".`}),I&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:I})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` when done.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(E)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`text`,children:[`Connecting to `,(0,K.jsx)(w,{bold:!0,children:e.name}),`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(l,{}),(0,K.jsx)(w,{children:` Establishing connection to MCP server`})]}),(0,K.jsx)(w,{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`}):(J&&($.push({label:`Re-authenticate`,value:`reauth`}),$.push({label:`Clear authentication`,value:`clear-auth`})),J||$.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,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:u?void 0:`round`,children:[(0,K.jsx)(C,{marginBottom:1,children:(0,K.jsxs)(w,{bold:!0,children:[Z,` MCP Server`]})}),(0,K.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,K.jsxs)(w,{children:[D(`inactive`,d)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,K.jsxs)(w,{children:[D(`success`,d)(r.tick),` connected`]}):e.client.type===`pending`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,K.jsx)(w,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,K.jsxs)(w,{children:[D(`warning`,d)(r.triangleUpOutline),` needs authentication`]}):(0,K.jsxs)(w,{children:[D(`error`,d)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Auth: `}),J?(0,K.jsxs)(w,{children:[D(`success`,d)(r.tick),` authenticated`]}):(0,K.jsxs)(w,{children:[D(`error`,d)(r.cross),` not authenticated`]})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`URL: `}),(0,K.jsx)(w,{dimColor:!0,children:e.config.url})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Config location: `}),(0,K.jsx)(w,{dimColor:!0,children:ce(e.scope)})]}),e.client.type===`connected`&&(0,K.jsx)(De,{serverToolsCount:t,serverPromptsCount:Fe,serverResourcesCount:v.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Tools: `}),(0,K.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),_&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsxs)(w,{color:`error`,children:[`Error: `,_]})}),$.length>0&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(ee,{options:$,onChange:async t=>{switch(t){case`tools`:n();break;case`auth`:case`reauth`:await ze();break;case`clear-auth`:await Be();break;case`claudeai-auth`:await Le();break;case`claudeai-clear-auth`:Q();break;case`reconnectMcpServer`:O(!0);try{let t=await Y(e.name);e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:t.client.type===`connected`});let{message:n}=ke(t,e.name);s?.(n)}catch(t){e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:!1}),s?.(Ae(t,e.name))}finally{O(!1)}break;case`toggle-enabled`:await Re();break;case`back`:o();break}},onCancel:o})})]}),(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(w,{dimColor:!0,italic:!0,children:f.pending?(0,K.jsxs)(K.Fragment,{children:[`Press `,f.keyName,` again to exit`]}):(0,K.jsxs)(T,{children:[(0,K.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,K.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,K.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var G,K,Me=e((()=>{n(),G=t(E(),1),I(),R(),H(),_(),O(),b(),f(),s(),V(),x(),p(),B(),g(),j(),F(),z(),u(),h(),d(),y(),Oe(),W(),K=A()}));function Ne({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:s,borderless:c=!1}){let[u]=fe(),d=Ee(),te=m(e=>e.mcp),f=Te(),ne=we(),[p,h]=(0,q.useState)(!1),re=q.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await ne(e.name),i()}catch(n){s(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.name,ne,i,s]),g=Se(String(e.name)),ie=se(te.commands,e.name).length,_=[];return e.client.type!==`disabled`&&t>0&&_.push({label:`View tools`,value:`tools`}),e.client.type!==`disabled`&&_.push({label:`Reconnect`,value:`reconnectMcpServer`}),_.push({label:e.client.type===`disabled`?`Enable`:`Disable`,value:`toggle-enabled`}),_.length===0&&_.push({label:`Back`,value:`back`}),p?(0,J.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(w,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(w,{bold:!0,children:e.name})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(l,{}),(0,J.jsx)(w,{children:` Restarting MCP server process`})]}),(0,J.jsx)(w,{dimColor:!0,children:`This may take a few moments.`})]}):(0,J.jsxs)(C,{flexDirection:`column`,children:[(0,J.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:c?void 0:`round`,children:[(0,J.jsx)(C,{marginBottom:1,children:(0,J.jsxs)(w,{bold:!0,children:[g,` MCP Server`]})}),(0,J.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,J.jsxs)(w,{children:[D(`inactive`,u)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,J.jsxs)(w,{children:[D(`success`,u)(r.tick),` connected`]}):e.client.type===`pending`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,J.jsx)(w,{children:` connecting…`})]}):(0,J.jsxs)(w,{children:[D(`error`,u)(r.cross),` failed`]})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Command: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Args: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Config location: `}),(0,J.jsx)(w,{dimColor:!0,children:ce(o(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,J.jsx)(De,{serverToolsCount:t,serverPromptsCount:ie,serverResourcesCount:te.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Tools: `}),(0,J.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),_.length>0&&(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(ee,{options:_,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){h(!0);try{let{message:t}=ke(await f(e.name),e.name);s?.(t)}catch(t){s?.(Ae(t,e.name))}finally{h(!1)}}else t===`toggle-enabled`?await re():t===`back`&&i()},onCancel:i})})]}),(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(w,{dimColor:!0,italic:!0,children:d.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,d.keyName,` again to exit`]}):(0,J.jsxs)(T,{children:[(0,J.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var q,J,Y=e((()=>{n(),q=t(E(),1),H(),O(),v(),V(),x(),p(),j(),z(),u(),h(),d(),Oe(),W(),J=A()}));function Pe({tool:e,server:t,onBack:n}){let[r,i]=X.useState(``),o=N(e.name,t.name),s=M(e.userFacingName?e.userFacingName({}):o),c=e.isReadOnly?.({})??!1,l=e.isDestructive?.({})??!1,u=e.isOpenWorld?.({})??!1;return X.useEffect(()=>{async function t(){try{let t=await e.description({},{isNonInteractiveSession:!1,toolPermissionContext:{mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1},tools:[]});i(t)}catch{i(`Failed to load description`)}}t()},[e]),(0,Z.jsx)(k,{title:(0,Z.jsxs)(Z.Fragment,{children:[s,c&&(0,Z.jsx)(w,{color:`success`,children:` [read-only]`}),l&&(0,Z.jsx)(w,{color:`error`,children:` [destructive]`}),u&&(0,Z.jsx)(w,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,Z.jsxs)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,Z.jsxs)(C,{flexDirection:`column`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Tool name: `}),(0,Z.jsx)(w,{dimColor:!0,children:o})]}),(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Full name: `}),(0,Z.jsx)(w,{dimColor:!0,children:e.name})]}),r&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Description:`}),(0,Z.jsx)(w,{wrap:`wrap`,children:r})]}),e.inputJSONSchema?.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Parameters:`}),(0,Z.jsx)(C,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,Z.jsxs)(w,{children:[`• `,t,r&&(0,Z.jsx)(w,{dimColor:!0,children:` (required)`}),`:`,` `,(0,Z.jsx)(w,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,Z.jsxs)(w,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var X,Z,Fe=e((()=>{X=t(E(),1),O(),P(),u(),Z=A()}));function Ie({server:e,onSelectTool:t,onBack:n}){let r=m(e=>e.mcp.tools),i=Le.useMemo(()=>e.client.type===`connected`?ae(r,e.name):[],[e,r]),o=i.map((t,n)=>{let r=N(t.name,e.name),i=M(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)(k,{title:`Tools for ${e.name}`,subtitle:`${i.length} ${xe(i.length,`tool`)}`,onCancel:n,inputGuide:e=>e.pending?(0,Q.jsxs)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(T,{children:[(0,Q.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(a,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:i.length===0?(0,Q.jsx)(w,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(ee,{options:o,onChange:e=>{let n=parseInt(e,10),r=i[n];r&&t(r,n)},onCancel:n})})}var Le,Q,Re=e((()=>{Le=t(E(),1),O(),P(),x(),p(),z(),u(),h(),Q=A()}));export{Ne as a,Me as c,Fe as i,Re as n,Y as o,Pe as r,je as s,Ie as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Ox as n,_x as r,jx as i,ox as a,vx as o}from"./loadAgentsDir-DXOkUcW3.js";import{I as s,Lt as c,P as l,ai as u,t as d}from"./src-DL3w8VPk2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";function p({scope:e,parsingErrors:t,warnings:n}){let i=t.length>0,o=n.length>0;return!i&&!o?null:(0,_.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,_.jsxs)(s,{children:[(i||o)&&(0,_.jsxs)(l,{color:i?`error`:`warning`,children:[`[`,i?`Failed to parse`:`Contains warnings`,`] `]}),(0,_.jsx)(l,{children:r(e)})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(l,{dimColor:!0,children:`Location: `}),(0,_.jsx)(l,{dimColor:!0,children:a(e)})]}),(0,_.jsxs)(s,{marginLeft:1,flexDirection:`column`,children:[t.map((e,t)=>{let n=e.mcpErrorMetadata?.serverName;return(0,_.jsx)(s,{children:(0,_.jsxs)(l,{children:[(0,_.jsx)(l,{dimColor:!0,children:`└ `}),(0,_.jsx)(l,{color:`error`,children:`[Error]`}),(0,_.jsxs)(l,{dimColor:!0,children:[` `,n&&`[${n}] `,e.path&&e.path!==``?`${e.path}: `:``,e.message]})]})},`error-${t}`)}),n.map((e,t)=>{let n=e.mcpErrorMetadata?.serverName;return(0,_.jsx)(s,{children:(0,_.jsxs)(l,{children:[(0,_.jsx)(l,{dimColor:!0,children:`└ `}),(0,_.jsx)(l,{color:`warning`,children:`[Warning]`}),(0,_.jsxs)(l,{dimColor:!0,children:[` `,n&&`[${n}] `,e.path&&e.path!==``?`${e.path}: `:``,e.message]})]})},`warning-${t}`)})]})]})}function m(){let e=(0,g.useMemo)(()=>[{scope:`user`,config:n(`user`)},{scope:`project`,config:n(`project`)},{scope:`local`,config:n(`local`)},{scope:`enterprise`,config:n(`enterprise`)}],[]),t=e.some(({config:e})=>h(e.errors,`fatal`).length>0),r=e.some(({config:e})=>h(e.errors,`warning`).length>0);return!t&&!r?null:(0,_.jsxs)(s,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,_.jsx)(l,{bold:!0,children:`MCP Config Diagnostics`}),(0,_.jsx)(s,{marginTop:1,children:(0,_.jsxs)(l,{dimColor:!0,children:[`For help configuring MCP servers, see:`,` `,(0,_.jsx)(c,{url:`https://code.workmate.com/docs/en/mcp`,children:`https://code.workmate.com/docs/en/mcp`})]})}),e.map(({scope:e,config:t})=>(0,_.jsx)(p,{scope:e,parsingErrors:h(t.errors,`fatal`),warnings:h(t.errors,`warning`)},e))]})}function h(e,t){return e.filter(e=>e.mcpErrorMetadata?.severity===t)}var g,_,v=e((()=>{g=t(u(),1),i(),o(),d(),_=f()}));export{v as n,m 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{$C as a,$u as o,Da as s,Ds as c,Fc as l,Ic as u,Iy as d,La as f,Lc as p,Ly as m,Mu as h,Pu as g,QC as _,Qu as v,Sa as y,Ts as b,Ua as x,Va as S,XC as C,Xh as w,Zh as T,bg as E,dn as D,ep as O,gC as k,hg as A,hn as j,mg as M,nn as N,np as ee,pg as P,uC as te,wa as F,ws as ne,ya as I,za as re,zc as L}from"./loadAgentsDir-DXOkUcW3.js";import{C as ie,Gt as ae,I as R,P as z,Wt as oe,ai as se,ot as ce,t as le}from"./src-DL3w8VPk2.js";import{t as ue}from"./jsx-runtime-Bb4Xn-E0.js";import{Ut as de,Wn as fe}from"./state-D5D6QpTX.js";import{In as B,Ln as pe}from"./settings-3xZ0fsvE.js";import{h as V,m as me,o as he,q as ge,s as H,w as _e}from"./log-CZ7ploQm.js";import{n as U,r as W}from"./analytics-DJobLaWP.js";import{b as ve,m as ye,v as be}from"./startupProfiler-CbzxVmbv.js";import{E as xe,T as Se,c as Ce,d as we,w as Te}from"./sessionTracing-Dvi520eN.js";import{n as Ee,t as De}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";import*as G from"path";import{randomUUID as K}from"crypto";var q=t(se(),1),J=ue();le(),de(),ge(),me(),he(),pe(),U(),be(),_(),d(),Te(),O(),Ce(),p(),l(),c(),f(),j();function Oe(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 ke(e){let t=e.toLowerCase().trim();return t===`continue`||/\b(keep going|go on)\b/.test(t)}function Ae(e,t,n,r,i,a,o){let s=K();fe(s);let c=typeof e==`string`?e:e.find(e=>e.type===`text`)?.text||``;we(c);let l=typeof e==`string`?e:e.findLast(e=>e.type===`text`)?.text||``;return l&&Se(`user_prompt`,{prompt_length:String(l.length),prompt:xe(l),"prompt.id":s}),W(`tengu_input_prompt`,{is_negative:Oe(c),is_keep_going:ke(c)}),t.length>0?{messages:[y({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:[y({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}U(),f();async function je({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:a,ideSelection:o,messages:c,setUserInputOnProcessing:l,uuid:u,isAlreadyProcessing:d,querySource:f,canUseTool:p,skipSlashCommands:m,bridgeOrigin:h,isMeta:g,skipAttachments:_,autonomy:v}){let b=typeof e==`string`?e:null,x=b?.startsWith(`/`)&&!m;n===`prompt`&&b!==null&&!g&&!x&&l?.(b),L(`query_process_user_input_base_start`);let S=i.getAppState(),C=await Ne(e,n,r,i,a,o,c,u,d,f,p,S.toolPermissionContext.mode,m,h,g,_,t,v);if(L(`query_process_user_input_base_end`),!C.shouldQuery)return C;L(`query_hooks_start`);let w=s(e)||``;for await(let t of N(w,S.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[I(`${D(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(y({content:e})),C.shouldQuery=!1,C}if(t.additionalContexts&&t.additionalContexts.length>0&&C.messages.push(ne({type:`hook_additional_context`,content:t.additionalContexts.map(Me),hookName:`UserPromptSubmit`,toolUseID:`hook-${K()}`,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:Me(t.message.attachment.content)}});break;default:C.messages.push(t.message);break}}return L(`query_hooks_end`),C}var Y=1e4;function Me(e){return e.length>Y?`${e.substring(0,Y)}… [output truncated - exceeded ${Y} characters]`:e}async function Ne(e,t,n,r,i,o,s,c,l,d,f,p,h,g,_,v,y,x){let S=null,w=[],T=[],E=e;if(typeof e==`string`)S=e;else if(e.length>0){L(`query_image_processing_start`);let t=[];for(let n of e)if(n.type===`image`){let e=await a(n);if(e.dimensions){let t=C(e.dimensions);t&&T.push(t)}t.push(e.block)}else t.push(n);E=t,L(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(S=n.text,w=t.slice(0,-1)):w=t}if(S===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let D=i?Object.values(i).filter(m):[],O=D.map(e=>e.id),k=i?await ee(i):new Map;L(`query_pasted_image_processing_start`);let A=await Promise.all(D.map(async e=>{let t={type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}};return W(`tengu_pasted_image_resize_attempt`,{original_size_bytes:e.content.length}),{resized:await a(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??k.get(e.id)}})),j=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of A){if(e.dimensions){let t=C(e.dimensions,n);t&&T.push(t)}else if(t){let e=C(t,n);e&&T.push(e)}else n&&T.push(`[Image source: ${n}]`);j.push(e.block)}L(`query_pasted_image_processing_end`);let M=h,N=!v&&S!==null&&(t!==`prompt`||M||!S.startsWith(`/`));L(`query_attachment_loading_start`);let P=N?await u(b(S,r,o??null,[],s,d)):[];if(L(`query_attachment_loading_end`),S!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-DmdCAWOR.js`);return X(await e(S,w,P,r,n),T)}if(S!==null&&!M&&S.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-B43TkiaI.js`);return X(await e(S,w,j,P,r,n,c,l,f,x),T)}if(S!==null&&t===`prompt`){let e=S.trim(),t=P.find(e=>e.attachment.type===`agent_mention`);if(t){let n=`@agent-${t.attachment.agentType}`,r=e===n;W(`tengu_subagent_at_mention`,{is_subagent_only:r,is_prefix:e.startsWith(n)&&!r})}}return X(Ae(E,j,O,P,c,p,_),T)}function X(e,t){return t.length>0&&e.messages.push(y({content:t.map(e=>({type:`text`,text:e})),isMeta:!0})),e}var Pe=n({MessageSelector:()=>Ie,messagesAfterAreOnlySynthetic:()=>Ue,selectableUserMessagesFilter:()=>Q});function Fe(e){return e.type===`text`}function Z(e){return e===`summarize`}function Ie({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:a,onClose:o,preselectedMessage:s}){let c=T(e=>e.fileHistory),[l,u]=(0,q.useState)(void 0),d=M(),f=(0,q.useMemo)(K,[]),p=(0,q.useMemo)(()=>[...e.filter(Q),{...y({content:``}),uuid:f}],[e,f]),[m,g]=(0,q.useState)(p.length-1),_=Math.max(0,Math.min(m-Math.floor($/2),p.length-$)),b=p.length>1,[x,S]=(0,q.useState)(s),[C,w]=(0,q.useState)(void 0);(0,q.useEffect)(()=>{if(!s||!d)return;let e=!1;return A(c,s.uuid).then(t=>{e||w(t)}),()=>{e=!0}},[s,d,c]);let[E,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(null),[j,N]=(0,q.useState)(`both`),[ee,te]=(0,q.useState)(``);function F(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:te}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,q.useEffect)(()=>{W(`tengu_message_selector_opened`,{})},[]);async function ne(e){t(),D(!0);try{await n(e),D(!1),o()}catch(e){H(e),D(!1),u(`Failed to restore the conversation:\n${e}`)}}async function I(t){let n=e.indexOf(t);if(W(`tengu_message_selector_selected`,{index_from_end:e.length-1-n,message_type:t.type,is_current_prompt:!1}),!e.includes(t)){o();return}if(!d){await ne(t);return}let r=await A(c,t.uuid);S(t),w(r)}async function re(e){if(W(`tengu_message_selector_restore_option_selected`,{option:e}),!x){u(`Message not found.`);return}if(e===`nevermind`){s?o():S(void 0);return}if(Z(e)){t(),D(!0),k(e),u(void 0);try{let e=ee.trim()||void 0;await a(x,e,`from`),D(!1),k(null),S(void 0),o()}catch(e){H(e),D(!1),k(null),S(void 0),u(`Failed to summarize:\n${e}`)}return}t(),D(!0),u(void 0);let i=null,c=null;if(e===`code`||e===`both`)try{await r(x)}catch(e){i=e,H(i)}if(e===`conversation`||e===`both`)try{await n(x)}catch(e){c=e,H(c)}D(!1),S(void 0),c&&i?u(`Failed to restore the conversation and code:\n${c}\n${i}`):c?u(`Failed to restore the conversation:\n${c}`):i?u(`Failed to restore the code:\n${i}`):o()}let L=Ee(),se=(0,q.useCallback)(()=>{if(x&&!s){S(void 0);return}W(`tengu_message_selector_cancelled`,{}),o()},[o,x,s]),ce=(0,q.useCallback)(()=>g(e=>Math.max(0,e-1)),[]),le=(0,q.useCallback)(()=>g(e=>Math.min(p.length-1,e+1)),[p.length]),ue=(0,q.useCallback)(()=>g(0),[]),de=(0,q.useCallback)(()=>g(p.length-1),[p.length]),fe=(0,q.useCallback)(()=>{let e=p[m];e&&I(e)},[p,m,I]);oe(`confirm:no`,se,{context:`Confirmation`,isActive:!x}),ae({"messageSelector:up":ce,"messageSelector:down":le,"messageSelector:top":ue,"messageSelector:bottom":de,"messageSelector:select":fe},{context:`MessageSelector`,isActive:!E&&!l&&!x&&b});let[B,pe]=(0,q.useState)({});(0,q.useEffect)(()=>{async function t(){d&&Promise.all(p.map(async(t,n)=>{if(t.uuid!==f){let r=P(c,t.uuid),i=p.at(n+1),a=r?He(e,t.uuid,i?.uuid===f?void 0:i?.uuid):void 0;pe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[p,e,f,c,d]);let V=d&&C?.filesChanged&&C.filesChanged.length>0,me=!l&&!x&&!s&&b;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`}),l&&(0,J.jsxs)(z,{color:`error`,children:[`Error: `,l]}),!b&&(0,J.jsx)(z,{children:`Nothing to rewind to yet.`}),!l&&x&&b&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(z,{children:[`Confirm you want to restore `,!C&&`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)(Ve,{userMessage:x,color:`text`,isCurrent:!1}),(0,J.jsxs)(z,{dimColor:!0,children:[`(`,ye(new Date(x.timestamp)),`)`]})]}),(0,J.jsx)(Re,{selectedRestoreOption:j,canRestoreCode:!!V,diffStatsForRestore:C}),E&&Z(O)?(0,J.jsxs)(R,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(h,{}),(0,J.jsx)(z,{children:`Summarizing…`})]}):(0,J.jsx)(v,{isDisabled:E,options:F(!!V),defaultFocusValue:V?`both`:`conversation`,onFocus:e=>N(e),onChange:e=>re(e),onCancel:()=>s?o():S(void 0)}),V&&(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.`]})})]}),me&&(0,J.jsxs)(J.Fragment,{children:[d?(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:p.slice(_,_+$).map((e,t)=>{let n=_+t,r=n===m,a=e.uuid===f,o=n in B,s=B[n],c=s?.filesChanged?.length;return(0,J.jsxs)(R,{height:d?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)(Ve,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:a,paddingRight:10})}),d&&o&&(0,J.jsx)(R,{height:1,flexDirection:`row`,children:s?(0,J.jsx)(z,{dimColor:!r,color:`inactive`,children:c?(0,J.jsxs)(J.Fragment,{children:[c===1&&s.filesChanged[0]?`${G.basename(s.filesChanged[0])} `:`${c} files changed `,(0,J.jsx)(Be,{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)})})]}),!x&&(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:[!l&&b&&`Enter to continue · `,`Esc to exit`]})})]})]})}function Le(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 Re({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:Le(e)}),!Z(e)&&(r?(0,J.jsx)(ze,{diffStatsForRestore:n}):(0,J.jsx)(z,{dimColor:!0,children:`The code will be unchanged.`}))]})}function ze({diffStatsForRestore:e}){if(e===void 0)return;if(!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?G.basename(e.filesChanged[0]||``):t===2?`${G.basename(e.filesChanged[0]||``)} and ${G.basename(e.filesChanged[1]||``)}`:`${G.basename(e.filesChanged[0]||``)} and ${e.filesChanged.length-1} other files`,(0,J.jsxs)(z,{dimColor:!0,children:[`The code will be restored `,(0,J.jsx)(Be,{diffStats:e}),` in `,n,`.`]})}function Be({diffStats:e}){if(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 Ve({userMessage:e,color:t,dimColor:n,isCurrent:r,paddingRight:i}){let{columns:a}=ce();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],c=V(typeof o==`string`?o.trim():s&&Fe(s)?s.text.trim():`(no prompt)`);if(re(c))return(0,J.jsx)(R,{flexDirection:`row`,width:`100%`,children:(0,J.jsx)(z,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(c.includes(`<bash-input>`)){let e=F(c,`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(c.includes(`<command-message>`)){let e=F(c,_e),r=F(c,`command-args`),i=F(c,`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?ve(c,a-i,!0):c.slice(0,500).split(`
2
- `).slice(0,4).join(`
3
- `)})})}function He(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||!x(n))continue;let r=n.toolUseResult;if(!(!r?.filePath||!r.structuredPatch)){a.includes(r.filePath)||a.push(r.filePath);try{if(`type`in r&&r.type===`create`)o+=r.content.split(/\r?\n/).length;else for(let e of r.structuredPatch){let t=B(e.lines,e=>e.startsWith(`+`)),n=B(e.lines,e=>e.startsWith(`-`));o+=t,s+=n}}catch{}}}return{filesChanged:a,insertions:o,deletions:s}}function Q(e){if(e.type!==`user`||Array.isArray(e.message.content)&&e.message.content[0]?.type===`tool_result`||S(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&&Fe(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&&!S(t)&&!x(t)&&t.type!==`progress`&&t.type!==`system`&&t.type!==`attachment`&&!(t.type===`user`&&t.isMeta)){if(t.type===`assistant`){let e=t.message.content;if(Array.isArray(e)&&e.some(e=>e.type===`text`&&e.text.trim()||e.type===`tool_use`))return!1;continue}if(t.type===`user`)return!1}}return!0}var $,We=e((()=>{r(),U(),w(),E(),De(),te(),f(),o(),g(),k(),$=7}));export{Q as a,Ue as i,Pe as n,je as o,We as r,Ie as t};