@readmagic/workmate 0.0.10 → 0.0.11

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 (399) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Vmmm7p1c.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/App-BuKmqFPm.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +1 -0
  4. package/dist/chunks/ApproveApiKey-M6U-NafA.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-CLSACUmo.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BqNxQOXJ.js → ClaudeMdExternalIncludesDialog-CSywJdVL.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +1 -0
  10. package/dist/chunks/{DiffDialog-9AYwtupw.js → DiffDialog-DUbFrzKu.js} +2 -2
  11. package/dist/chunks/Doctor-BcnUfJ4I.js +1 -0
  12. package/dist/chunks/Doctor-Dz4TuYas.js +3 -0
  13. package/dist/chunks/ExitFlow-BwyAtIHx.js +2 -0
  14. package/dist/chunks/{Grove-B9-hhkZA.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-MxJ_W_np.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/InvalidConfigDialog-bih293Xt.js +1 -0
  17. package/dist/chunks/{InvalidSettingsDialog-YyQcHocx.js → InvalidSettingsDialog-Br8kQOHz.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +1 -0
  19. package/dist/chunks/MCPToolListView-DJ06N1DG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-BCpfHaBK.js → McpParsingWarnings-COa71S9q.js} +1 -1
  21. package/dist/chunks/MessageSelector-o4ULADFg.js +3 -0
  22. package/dist/chunks/Messages-qqwHuAW5.js +11 -0
  23. package/dist/chunks/{Onboarding-ClwHS5rh.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BSA9NrZc.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/{PromptInputHelpMenu-Bb4KdIX_.js → PromptInputHelpMenu-CfMFx-TF.js} +1 -1
  26. package/dist/chunks/QueryEngine-Dt0BKUeF.js +1 -0
  27. package/dist/chunks/REPL-CUbEDqEl.js +133 -0
  28. package/dist/chunks/REPL-DMaKNhTa.js +1 -0
  29. package/dist/chunks/{RemoteSessionManager-CS6mywIn.js → RemoteSessionManager-Bf44A0Ol.js} +2 -2
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-CoxQ8YpH.js → SSETransport-DN4tCDEh.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +1 -0
  33. package/dist/chunks/Settings-DfdcmvOV.js +2 -0
  34. package/dist/chunks/{TeleportProgress-Doucj-50.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/TeleportRepoMismatchDialog-BZL8Zblz.js +1 -0
  36. package/dist/chunks/{TeleportResumeWrapper-D6kpr2c6.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-DrC8tlp0.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-Fk4m_Sy4.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-D_OUa4RT.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DvfQHnZY.js → WelcomeV2-ZQRKlcT4.js} +1 -1
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-B755vMZE.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-CIvP8l0s.js → agents-CMC0iQP4.js} +1 -1
  44. package/dist/chunks/agents-ZgRKpjHv.js +103 -0
  45. package/dist/chunks/allErrors-_cOQksHC.js +1 -0
  46. package/dist/chunks/{api-nSHc_GIQ.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-5QB6tsfB.js → auth-7mJGtlZp.js} +2 -2
  49. package/dist/chunks/auth-DGZzCbU0.js +1 -0
  50. package/dist/chunks/auth-DN1MUpB8.js +1 -0
  51. package/dist/chunks/{autoMode-BnUiK9Cu.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/{autonomy-Src6sKCp.js → autonomy-DuQmYhq6.js} +9 -9
  53. package/dist/chunks/{autonomy-C1aSgWPQ.js → autonomy-lJV7yWUl.js} +1 -1
  54. package/dist/chunks/autonomyPanel-DAQm6lDz.js +1 -0
  55. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +1 -0
  56. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +17 -0
  57. package/dist/chunks/{banner-D0P7wXdw.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-DAPORXF3.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/{branch-DFWa4Oxo.js → branch-k3kirqbA.js} +2 -2
  61. package/dist/chunks/{break-cache-Chj9i9MP.js → break-cache-CAoZ9b72.js} +1 -1
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-Bb6URf4Q.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/{bridgeMessaging-C3huGcR3.js → bridgeMessaging-Ci5H68MX.js} +1 -1
  65. package/dist/chunks/{bridgePointer-DLYyvRKb.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/{bridgeStatusUtil-DFMftajD.js → bridgeStatusUtil-C36w15ge.js} +1 -1
  67. package/dist/chunks/btw-nVoVuIae.js +1 -0
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-amzeeBz0.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CsJfF1b-.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-ClFDpWVJ.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWcoyZDP.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-DFlE4fYh.js → client-B9404qIP.js} +1 -1
  76. package/dist/chunks/client-BCAbKdNz.js +1 -0
  77. package/dist/chunks/client-CJE6gEvU.js +1 -0
  78. package/dist/chunks/commands-DL-BzoMQ.js +1 -0
  79. package/dist/chunks/compact-Cx7BPXLU.js +2 -0
  80. package/dist/chunks/config-S5OW4Xqr.js +1 -0
  81. package/dist/chunks/{config-Do1870_d.js → config-aRiTrtCv.js} +2 -2
  82. package/dist/chunks/{config-CVHMRMwd.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/context-BN7DEjoH.js +1 -0
  84. package/dist/chunks/{context-noninteractive-D5iQhasu.js → context-noninteractive-D91W2B8e.js} +5 -5
  85. package/dist/chunks/context-noninteractive-DPacEFJ1.js +1 -0
  86. package/dist/chunks/conversation-D5Nbu9eT.js +1 -0
  87. package/dist/chunks/conversation-hcUx9e-C.js +1 -0
  88. package/dist/chunks/{createSSHSession-CJtzNQdZ.js → createSSHSession-DecOR6M5.js} +6 -6
  89. package/dist/chunks/createSession-D27zvmOs.js +1 -0
  90. package/dist/chunks/createSession-DRqkLZWt.js +1 -0
  91. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +40 -0
  92. package/dist/chunks/{datadog-DjeJThpV.js → datadog-bm551AVV.js} +1 -1
  93. package/dist/chunks/debug-BecbSVoN.js +39 -0
  94. package/dist/chunks/{debugUtils-DX0KAXNK.js → debugUtils-CmJfIUxW.js} +1 -1
  95. package/dist/chunks/{detached-X_yjYR7x.js → detached-CIyF0M5O.js} +1 -1
  96. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  97. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  98. package/dist/chunks/{diff-jEJJe58I.js → diff-DeK4bwjw.js} +1 -1
  99. package/dist/chunks/{directoryCompletion-BbXR2bfy.js → directoryCompletion-BJCu19HJ.js} +1 -1
  100. package/dist/chunks/doctor-BJORBomU.js +1 -0
  101. package/dist/chunks/{entry-oIqjxIjQ.js → entry-mdegyj8z.js} +3 -3
  102. package/dist/chunks/{esm-Cf4nSRjF.js → esm-Ka3lhafK.js} +1 -1
  103. package/dist/chunks/{execFileNoThrow-Dwu6psHW.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  104. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  105. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  106. package/dist/chunks/{extraUsage-Mi66JwFZ.js → extraUsage-BrKbpBK-.js} +1 -1
  107. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  108. package/dist/chunks/fast-0Vi354KI.js +1 -0
  109. package/dist/chunks/{fast-BU4iUZ8E.js → fast-DWn40OcQ.js} +1 -1
  110. package/dist/chunks/{fileSuggestions-BMfQIDdW.js → fileSuggestions-C7Pwq2yj.js} +3 -3
  111. package/dist/chunks/{firstPartyEventLogger-B3cXgR67.js → firstPartyEventLogger-BHjBQH0J.js} +2 -2
  112. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  113. package/dist/chunks/{flushGate-DgSDVGKZ.js → flushGate-DdJjxCes.js} +1 -1
  114. package/dist/chunks/gemini-DHv2iVfy.js +1 -0
  115. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  116. package/dist/chunks/{genericProcessUtils-CmsUPyRz.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  117. package/dist/chunks/git-DBlOv64X.js +6 -0
  118. package/dist/chunks/git-DF4RFFaT.js +1 -0
  119. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  120. package/dist/chunks/{goal-ZmSRBx4q.js → goal-BZG4gtnb.js} +3 -3
  121. package/dist/chunks/{grok-BXMvezWb.js → grok-BS57ZhyW.js} +1 -1
  122. package/dist/chunks/{grove-CeOjTaY6.js → grove-_zlQ83yR.js} +2 -2
  123. package/dist/chunks/{help-5DNZO6_H.js → help-C_2tdXHC.js} +1 -1
  124. package/dist/chunks/{hooks-C637tFtd.js → hooks-C7Bn7MBe.js} +2 -2
  125. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  126. package/dist/chunks/{initReplBridge-D1h10vQ9.js → initReplBridge-NkZRcM77.js} +1 -1
  127. package/dist/chunks/{install-C-6ItpH0.js → install-Du-DSVzj.js} +1 -1
  128. package/dist/chunks/{instrumentation-DaiPDUst.js → instrumentation-DMs3b82f.js} +5 -5
  129. package/dist/chunks/{job-BeYzQUiR.js → job-rbX1VZmp.js} +1 -1
  130. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  131. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  132. package/dist/chunks/{launchLocalMemory-CE4J98xO.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  133. package/dist/chunks/{launchOnboarding-BfTdC6vp.js → launchOnboarding-Al_X75Vz.js} +1 -1
  134. package/dist/chunks/{loadAgentsDir-C7lOqvfh.js → loadAgentsDir-BL93ulMm.js} +619 -619
  135. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  136. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  137. package/dist/chunks/{localSearch-BKrznW5x.js → localSearch-C5ipegd9.js} +1 -1
  138. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  139. package/dist/chunks/{log-CezCRpAN.js → log-Dauqle-Z.js} +1 -1
  140. package/dist/chunks/{logoV2Utils-BkQfyQ1-.js → logoV2Utils-CkvOihX7.js} +1 -1
  141. package/dist/chunks/{magicDocs-BpVcON9o.js → magicDocs-DLav5QK0.js} +3 -3
  142. package/dist/chunks/main-CVNWNAoh.js +513 -0
  143. package/dist/chunks/{main-CvOv59-7.js → main-LMyE3jXY.js} +2 -2
  144. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  145. package/dist/chunks/{managedEnv-DhWRJ5DK.js → managedEnv-DJSCuqCb.js} +1 -1
  146. package/dist/chunks/{mappers-bOab8ipV.js → mappers-DQxMcezy.js} +1 -1
  147. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  148. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  149. package/dist/chunks/{mcp-VcGPYCkW.js → mcp-D5HkCqUh.js} +2 -2
  150. package/dist/chunks/{memoize-DsqYrbeR.js → memoize-FeyE7JEh.js} +1 -1
  151. package/dist/chunks/memory-COa7aUbx.js +1 -0
  152. package/dist/chunks/{mode-DlKnUM8l.js → mode-Bl2RZC8M.js} +2 -2
  153. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  154. package/dist/chunks/{model-BsZ4sP_H.js → model-Bgh_r4lg.js} +1 -1
  155. package/dist/chunks/model-DiuEAv6h.js +1 -0
  156. package/dist/chunks/{modelOptions-CxP067Qv.js → modelOptions-BtEZe5BB.js} +1 -1
  157. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  158. package/dist/chunks/omit--yH_T4rf.js +1 -0
  159. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  160. package/dist/chunks/{openai-B9C2XN5Q.js → openai-DWs4D-nQ.js} +3 -3
  161. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  162. package/dist/chunks/{parser-BwPXQomy.js → parser-BH4u7QiV.js} +1 -1
  163. package/dist/chunks/parser-BMIaRErw.js +1 -0
  164. package/dist/chunks/{partition-D-UhsUCx.js → partition-DLcW5Oo_.js} +1 -1
  165. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  166. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  167. package/dist/chunks/{plan-CyU2zrCK.js → plan-BNYDTnQd.js} +1 -1
  168. package/dist/chunks/{platform-BMPbglug.js → platform-B0uTQc9P.js} +1 -1
  169. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  171. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  172. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  173. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  174. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  175. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  176. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  177. package/dist/chunks/plugins-CBW7kPyp.js +4 -0
  178. package/dist/chunks/{poorMode-DEwQOAJt.js → poorMode-B_xEvuEV.js} +1 -1
  179. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  180. package/dist/chunks/{print-eCRv_Li-.js → print-BZOx09SU.js} +16 -16
  181. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  182. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  183. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  184. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  185. package/dist/chunks/{prompt-M2lu8_Oa.js → prompt-Dx7IWhBt.js} +2 -2
  186. package/dist/chunks/{promptEditor-DhcZY-iu.js → promptEditor-WCkmpejM.js} +2 -2
  187. package/dist/chunks/{protocolHandler-CkFaJKKo.js → protocolHandler-BiVWrpHi.js} +4 -4
  188. package/dist/chunks/{proxy-CuMaO_YV.js → proxy-CVn7o19p.js} +3 -3
  189. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  190. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  191. package/dist/chunks/{registerProtocol-CsNYRZKr.js → registerProtocol-E0Iu5hEx.js} +2 -2
  192. package/dist/chunks/{reload-plugins-B7JAE3b4.js → reload-plugins-D-3AUT9g.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-CFLJhsB6.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  194. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  195. package/dist/chunks/{rename-BCp2Vtqu.js → rename-CSavuBIE.js} +1 -1
  196. package/dist/chunks/{renderOptions-Q5oCLFIC.js → renderOptions-DDLbSMQU.js} +1 -1
  197. package/dist/chunks/resume-CROylN3J.js +2 -0
  198. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  199. package/dist/chunks/{ripgrep-DvOOsDMv.js → ripgrep-C1ydIMzT.js} +5 -5
  200. package/dist/chunks/{runtimeObserver-CS_3BDNo.js → runtimeObserver-L7pSIWBT.js} +2 -2
  201. package/dist/chunks/{runtimeObserver-DYUva6g-.js → runtimeObserver-OU8KrZQG.js} +1 -1
  202. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  203. package/dist/chunks/{sandbox-toggle--zNSKce_.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  204. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  205. package/dist/chunks/{session-CO3gEqQP.js → session-DUYsfPy_.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  207. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  208. package/dist/chunks/{sessionObserver-YkRHC-Aa.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  209. package/dist/chunks/{sessionState-Bifmu95-.js → sessionState-D-SaBzWD.js} +2 -2
  210. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  211. package/dist/chunks/{sessionTitle-COBSgSXS.js → sessionTitle-uCuYaNif.js} +2 -2
  212. package/dist/chunks/{sessionTracing-BrNx1k2V.js → sessionTracing-Bqb3vJTt.js} +3 -3
  213. package/dist/chunks/settings-BG15IFYx.js +1 -0
  214. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  215. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  216. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  217. package/dist/chunks/{shadowedRuleDetection-DEaw-X5j.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  218. package/dist/chunks/{shellQuote-BYeOv3Ip.js → shellQuote-DS6WrivY.js} +2 -2
  219. package/dist/chunks/{sideQuestion-D0OKljee.js → sideQuestion-CvMBBjI8.js} +2 -2
  220. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  221. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  222. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  223. package/dist/chunks/{skillGapStore-N_kmvXML.js → skillGapStore-CqaT8c0C.js} +2 -2
  224. package/dist/chunks/{skillLifecycle-C4F5RXuh.js → skillLifecycle-CnR8IqJM.js} +2 -2
  225. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  226. package/dist/chunks/{skills-C4CTRN9o.js → skills-BgcFh0vy.js} +1 -1
  227. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  228. package/dist/chunks/{startupProfiler-L_UWZ03w.js → startupProfiler-CmH_aVy2.js} +2 -2
  229. package/dist/chunks/{stats-IzV0_vEc.js → stats-B8uQ-UDi.js} +1 -1
  230. package/dist/chunks/{status-CeVP_uDT.js → status-BekdWoIj.js} +1 -1
  231. package/dist/chunks/status-D6KlRJmR.js +2 -0
  232. package/dist/chunks/{statusNoticeHelpers-Bb9gxdSt.js → statusNoticeHelpers-BMM8_uJ1.js} +1 -1
  233. package/dist/chunks/{stringUtils-C84IJ91d.js → stringUtils-C8PaYpQF.js} +1 -1
  234. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  235. package/dist/chunks/{switcher-CCs9xl1z.js → switcher-DnAhkyIn.js} +1 -1
  236. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  237. package/dist/chunks/{tasks-DZDhgx0w.js → tasks-Dmh6qikm.js} +1 -1
  238. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  239. package/dist/chunks/{templateJobs-CrNPEKkh.js → templateJobs-CxqU-s5i.js} +1 -1
  240. package/dist/chunks/{terminalSetup-CBqcwQll.js → terminalSetup-BKGcmlWp.js} +1 -1
  241. package/dist/chunks/{terminalSetup-D-N8YPiQ.js → terminalSetup-Cy19F1Js.js} +4 -4
  242. package/dist/chunks/{theme-Dazsirbw.js → theme-U7lMFHQ0.js} +1 -1
  243. package/dist/chunks/{tmux-DewYVEBm.js → tmux-D5EvHWi3.js} +1 -1
  244. package/dist/chunks/{toolEventObserver-lnHJ9fLQ.js → toolEventObserver-D9qjoVl5.js} +1 -1
  245. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  246. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  247. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  248. package/dist/chunks/{types-3j8PS-Du.js → types-DafcFtmb.js} +2 -2
  249. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  250. package/dist/chunks/{updateCCB-BPe9_FW6.js → updateCCB-C6XftzIG.js} +6 -6
  251. package/dist/chunks/{upstreamproxy-DF00RzGG.js → upstreamproxy-CXmjxHpl.js} +2 -2
  252. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  253. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  254. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  255. package/dist/chunks/{useMergedTools-Dk5cPqLc.js → useMergedTools-DbhqKk1-.js} +1 -1
  256. package/dist/chunks/{useSearchInput-C7Y1I9P9.js → useSearchInput-gUDbkLaC.js} +1 -1
  257. package/dist/chunks/{useSettingsErrors-DAEO7AyB.js → useSettingsErrors-CgPad-H0.js} +1 -1
  258. package/dist/chunks/{userAgent-CIq27vUR.js → userAgent-CU7Ndh79.js} +1 -1
  259. package/dist/chunks/util-B4oMhJKh.js +1 -0
  260. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  261. package/dist/chunks/{vim-EYQn94Kx.js → vim-w37BfGZ5.js} +1 -1
  262. package/dist/chunks/{which-DzFN5TNM.js → which-BRWBO7Gu.js} +1 -1
  263. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  264. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  265. package/dist/chunks/{workSecret-DUqdPy44.js → workSecret-BEhXgH2M.js} +1 -1
  266. package/dist/chunks/{workerRegistry-C07BcZIw.js → workerRegistry-Bq9bS5pw.js} +5 -5
  267. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  268. package/dist/cli.js +1 -1
  269. package/package.json +2 -3
  270. package/dist/chunks/App-C2yQjBgY.js +0 -1
  271. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +0 -1
  272. package/dist/chunks/ApproveApiKey-MscC-ssL.js +0 -1
  273. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +0 -2
  274. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +0 -1
  275. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +0 -1
  276. package/dist/chunks/Doctor-DmgAwce2.js +0 -1
  277. package/dist/chunks/Doctor-jEs9chPk.js +0 -3
  278. package/dist/chunks/ExitFlow-DVKxFdpX.js +0 -2
  279. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +0 -1
  280. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +0 -1
  281. package/dist/chunks/MCPToolListView-CvqB4nCw.js +0 -1
  282. package/dist/chunks/MessageSelector-BLzw172f.js +0 -3
  283. package/dist/chunks/Messages-4K5sLmNh.js +0 -11
  284. package/dist/chunks/QueryEngine-DPHLSsax.js +0 -1
  285. package/dist/chunks/REPL-Bf46iQCN.js +0 -1
  286. package/dist/chunks/REPL-DIaAo9M9.js +0 -133
  287. package/dist/chunks/ResumeConversation-Br2KsBoe.js +0 -1
  288. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +0 -1
  289. package/dist/chunks/Settings-BMXysXIx.js +0 -2
  290. package/dist/chunks/TeleportRepoMismatchDialog-B5I73j7Y.js +0 -1
  291. package/dist/chunks/add-dir-CZ6Clvq8.js +0 -1
  292. package/dist/chunks/agents-DHnNg4h6.js +0 -103
  293. package/dist/chunks/allErrors-CU89tF-z.js +0 -1
  294. package/dist/chunks/api-BSeE6MwB.js +0 -1
  295. package/dist/chunks/auth-BIGJth5U.js +0 -1
  296. package/dist/chunks/auth-CDQMhIZP.js +0 -1
  297. package/dist/chunks/autonomyPanel-DnHpuiy4.js +0 -1
  298. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +0 -17
  299. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +0 -1
  300. package/dist/chunks/bg-50rllUNh.js +0 -1
  301. package/dist/chunks/bridgeConfig-BeqChxJC.js +0 -1
  302. package/dist/chunks/btw-DSK9R2C8.js +0 -1
  303. package/dist/chunks/caches-BTQAW9zc.js +0 -1
  304. package/dist/chunks/caches-BVtSCnV1.js +0 -1
  305. package/dist/chunks/ccrClient-Bu7Tf1Z5.js +0 -1
  306. package/dist/chunks/client-BWQ4-rN7.js +0 -1
  307. package/dist/chunks/client-c-3-PW1F.js +0 -1
  308. package/dist/chunks/commands-Bi7k3Wg-.js +0 -1
  309. package/dist/chunks/compact-J-h0Yf4b.js +0 -2
  310. package/dist/chunks/config-yyFe87vW.js +0 -1
  311. package/dist/chunks/context-Tb1Ca2Q-.js +0 -1
  312. package/dist/chunks/context-noninteractive-soPYKAc9.js +0 -1
  313. package/dist/chunks/conversation-CSEtUxOY.js +0 -1
  314. package/dist/chunks/conversation-Dk1WDQuN.js +0 -1
  315. package/dist/chunks/createSession-DkT1GL8y.js +0 -1
  316. package/dist/chunks/createSession-eE8mswkv.js +0 -1
  317. package/dist/chunks/crossProjectResume-04n3Ppy9.js +0 -40
  318. package/dist/chunks/debug-RAynG_nM.js +0 -39
  319. package/dist/chunks/detectRepository-DgpNd87p.js +0 -1
  320. package/dist/chunks/detectRepository-ctF9KDbb.js +0 -1
  321. package/dist/chunks/doctor-B-Wag4C1.js +0 -1
  322. package/dist/chunks/execSyncWrapper-BTZJjCuv.js +0 -1
  323. package/dist/chunks/exit-BtW7LfRX.js +0 -1
  324. package/dist/chunks/extractMemories-CUrdiNcr.js +0 -1
  325. package/dist/chunks/fast-C60p6AqJ.js +0 -1
  326. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +0 -1
  327. package/dist/chunks/gemini-BwvSxGgn.js +0 -1
  328. package/dist/chunks/generateSessionName-DlrdedOk.js +0 -1
  329. package/dist/chunks/git-2c7WlGDL.js +0 -6
  330. package/dist/chunks/git-XtKbtJMc.js +0 -1
  331. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +0 -1
  332. package/dist/chunks/hooks-DWg07LmS.js +0 -1
  333. package/dist/chunks/jwtUtils-CUPXdX3W.js +0 -1
  334. package/dist/chunks/keybindings-DgIPdBy9.js +0 -2
  335. package/dist/chunks/loadAgentsDir-zikjxLvn.js +0 -1
  336. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +0 -1
  337. package/dist/chunks/localSearch-ZFyFy5FN.js +0 -1
  338. package/dist/chunks/main-9r5gLzUW.js +0 -605
  339. package/dist/chunks/managedEnv-B61yLpwp.js +0 -1
  340. package/dist/chunks/mcp-BckPBjaM.js +0 -6
  341. package/dist/chunks/mcp-CS1DA3JL.js +0 -1
  342. package/dist/chunks/memory-C5ohwh-T.js +0 -1
  343. package/dist/chunks/model-BGu1AGq0.js +0 -1
  344. package/dist/chunks/model-D19IIcll.js +0 -1
  345. package/dist/chunks/nativeInstaller-QB8cEJ18.js +0 -1
  346. package/dist/chunks/omit-DDUIPHnl.js +0 -1
  347. package/dist/chunks/onChangeAppState-RBl6H7ho.js +0 -1
  348. package/dist/chunks/panel-KW-wmEvU.js +0 -1
  349. package/dist/chunks/parser-xSBaQRLH.js +0 -1
  350. package/dist/chunks/permissions-BoLXYN1j.js +0 -3
  351. package/dist/chunks/pidLock-nJHbufJN.js +0 -3
  352. package/dist/chunks/plugin-C6-GQke5.js +0 -17
  353. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +0 -1
  354. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +0 -1
  355. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +0 -1
  356. package/dist/chunks/pluginFlagging-DZaYzecY.js +0 -1
  357. package/dist/chunks/pluginOperations-D90IRawu.js +0 -2
  358. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +0 -1
  359. package/dist/chunks/pluginStartupCheck-CB2q2dLv.js +0 -1
  360. package/dist/chunks/plugins-B9eSjLSA.js +0 -4
  361. package/dist/chunks/poorMode-BAnubpn1.js +0 -1
  362. package/dist/chunks/processBashCommand-B5F2Cl7K.js +0 -1
  363. package/dist/chunks/processSlashCommand-BC_D3cH5.js +0 -5
  364. package/dist/chunks/prompt-C1JPqinc.js +0 -1
  365. package/dist/chunks/prompt-DZhBz_Vu.js +0 -1
  366. package/dist/chunks/reconciler-B4GDm_iC.js +0 -1
  367. package/dist/chunks/refresh-DBVizOzg.js +0 -1
  368. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +0 -1
  369. package/dist/chunks/resume-DVCSzKvv.js +0 -2
  370. package/dist/chunks/ripgrep-e-iewvTf.js +0 -1
  371. package/dist/chunks/sandbox-adapter-BFZFHplu.js +0 -1
  372. package/dist/chunks/searchExtraTools-ui5y2VSE.js +0 -1
  373. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +0 -1
  374. package/dist/chunks/sessionObserver-Ba7um95p.js +0 -1
  375. package/dist/chunks/sessionStorage-CedwLLQs.js +0 -1
  376. package/dist/chunks/settings-DkDH7WQT.js +0 -1
  377. package/dist/chunks/settings-DnptdP79.js +0 -20
  378. package/dist/chunks/settingsSync-PmU7SmkU.js +0 -1
  379. package/dist/chunks/setup-BEsBuzsk.js +0 -3
  380. package/dist/chunks/sinks-BJHgxz6Y.js +0 -1
  381. package/dist/chunks/sinks-D5-yhcgU.js +0 -2
  382. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +0 -1
  383. package/dist/chunks/skillSearchPanel-CftorvAM.js +0 -21
  384. package/dist/chunks/startupProfiler-D4FBdEQr.js +0 -1
  385. package/dist/chunks/status-Dzuw3hBv.js +0 -2
  386. package/dist/chunks/switcher-4KzBvuKH.js +0 -1
  387. package/dist/chunks/syncCache-CBRiRU5x.js +0 -1
  388. package/dist/chunks/teleport-Bw0jSxe9.js +0 -1
  389. package/dist/chunks/toolPool-CkXFlqsn.js +0 -1
  390. package/dist/chunks/trustedDevice-CFf5yaG-.js +0 -1
  391. package/dist/chunks/trustedDevice-CuwSv8dG.js +0 -1
  392. package/dist/chunks/udsClient-e9dIkwVA.js +0 -1
  393. package/dist/chunks/useMainLoopModel-2-eujv0n.js +0 -1
  394. package/dist/chunks/useManagePlugins-CYBIkaB1.js +0 -1
  395. package/dist/chunks/util-VO98TdOz.js +0 -1
  396. package/dist/chunks/validatePlugin-Kk6pxnO2.js +0 -1
  397. package/dist/chunks/windowsPaths-BU3yQWTB.js +0 -1
  398. package/dist/chunks/windowsPaths-DgZ3YY4a.js +0 -1
  399. package/dist/chunks/worktree-dFUkhVE_.js +0 -1
@@ -1 +1 @@
1
- import{n as e,t}from"./axios-DaWTGg7G.js";import{C as n,S as r,w as i}from"./debug-RAynG_nM.js";t(),r();function a(e){let t=n(Buffer.from(e,`base64url`).toString(`utf-8`));if(!t||typeof t!=`object`||!(`version`in t)||t.version!==1)throw Error(`Unsupported work secret version: ${t&&typeof t==`object`&&`version`in t?t.version:`unknown`}`);let r=t;if(typeof r.session_ingress_token!=`string`||r.session_ingress_token.length===0)throw Error(`Invalid work secret: missing or empty session_ingress_token`);if(typeof r.api_base_url!=`string`)throw Error(`Invalid work secret: missing api_base_url`);return t}function o(e,t){let n=e.includes(`localhost`)||e.includes(`127.0.0.1`),r=e.startsWith(`https`)?`wss`:`ws`,i=n?`v2`:`v1`;return`${r}://${e.replace(/^https?:\/\//,``).replace(/\/+$/,``)}/${i}/session_ingress/ws/${t}`}function s(e,t){if(e===t)return!0;let n=e.slice(e.lastIndexOf(`_`)+1),r=t.slice(t.lastIndexOf(`_`)+1);return n.length>=4&&n===r}function c(e,t){return`${e.replace(/\/+$/,``)}/v1/code/sessions/${t}`}async function l(t,n){let r=await e.post(`${t}/worker/register`,{},{headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`},timeout:1e4}),a=r.data?.worker_epoch,o=typeof a==`string`?Number(a):a;if(typeof o!=`number`||!Number.isFinite(o)||!Number.isSafeInteger(o))throw Error(`registerWorker: invalid worker_epoch in response: ${i(r.data)}`);return o}export{s as a,l as i,o as n,a as r,c as t};
1
+ import{n as e,t}from"./axios-DaWTGg7G.js";import{C as n,S as r,x as i}from"./debug-BecbSVoN.js";t(),i();function a(e){let t=r(Buffer.from(e,`base64url`).toString(`utf-8`));if(!t||typeof t!=`object`||!(`version`in t)||t.version!==1)throw Error(`Unsupported work secret version: ${t&&typeof t==`object`&&`version`in t?t.version:`unknown`}`);let n=t;if(typeof n.session_ingress_token!=`string`||n.session_ingress_token.length===0)throw Error(`Invalid work secret: missing or empty session_ingress_token`);if(typeof n.api_base_url!=`string`)throw Error(`Invalid work secret: missing api_base_url`);return t}function o(e,t){let n=e.includes(`localhost`)||e.includes(`127.0.0.1`),r=e.startsWith(`https`)?`wss`:`ws`,i=n?`v2`:`v1`;return`${r}://${e.replace(/^https?:\/\//,``).replace(/\/+$/,``)}/${i}/session_ingress/ws/${t}`}function s(e,t){if(e===t)return!0;let n=e.slice(e.lastIndexOf(`_`)+1),r=t.slice(t.lastIndexOf(`_`)+1);return n.length>=4&&n===r}function c(e,t){return`${e.replace(/\/+$/,``)}/v1/code/sessions/${t}`}async function l(t,r){let i=await e.post(`${t}/worker/register`,{},{headers:{Authorization:`Bearer ${r}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`},timeout:1e4}),a=i.data?.worker_epoch,o=typeof a==`string`?Number(a):a;if(typeof o!=`number`||!Number.isFinite(o)||!Number.isSafeInteger(o))throw Error(`registerWorker: invalid worker_epoch in response: ${n(i.data)}`);return o}export{s as a,l as i,o as n,a as r,c as t};
@@ -1,6 +1,6 @@
1
- import{l as e,o as t,u as n}from"./envUtils-BDhHQY0-.js";import{At as r,Tt as i,US as a,WS as o,_t as s}from"./loadAgentsDir-C7lOqvfh.js";import{t as c}from"./src-P_wYS_NJ2.js";import{C as l,F as u,S as d,a as f,l as p,w as m,z as h}from"./debug-RAynG_nM.js";import{Ut as g}from"./settings-DnptdP79.js";import{O as _,k as v}from"./git-2c7WlGDL.js";import{o as y,s as b}from"./log-CezCRpAN.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-L_UWZ03w.js";import{Bt as E,Ot as D,_n as O,vn as k}from"./model-BsZ4sP_H.js";import{i as ee,t as A}from"./sessionIdCompat-DMayYBrf.js";import{n as j}from"./firstPartyEventLogger-B3cXgR67.js";import{t as te}from"./datadog-DjeJThpV.js";import{n as M,o as N,r as P}from"./debugUtils-DX0KAXNK.js";import{t as F}from"./pollConfig-BgpfHQPJ.js";import{n as I,t as L}from"./rcDebugLog-CARUIORE.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-amzeeBz0.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-DUqdPy44.js";import{i as U}from"./trustedDevice-CFf5yaG-.js";import{t as le}from"./jwtUtils-CUPXdX3W.js";import{i as W,n as G,r as K}from"./cliLaunch-BWcoyZDP.js";import"./bridgeStatusUtil-DFMftajD.js";import{t as q}from"./lib-BlVGipXx.js";import{hostname as J,tmpdir as ue}from"os";import{dirname as Y,join as de,resolve as X}from"path";import{createWriteStream as Z}from"fs";import{randomUUID as fe}from"crypto";import{spawn as pe}from"child_process";import{createInterface as Q}from"readline";t(),h(),d(),_(),y(),x(),T(),O(),o(),te(),j(),i(),L(),W(),q(),g(),c(),f(),A(),N();var me=10,he=10;function ge(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var $={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(e,t){let n=$[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 ve(e,t,n){let r;try{r=l(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(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${be(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 ye(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 be(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 xe(e){return{spawn(t,n){let r=ge(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(Y(e.debugFile),`bridge-transcript-${r}.jsonl`),a=Z(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=pe(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=[],f=null,p=[],h=!1,g=!1;u.stderr&&Q({input:u.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(t+`
2
- `),p.length>=he&&p.shift(),p.push(t)}),u.stdout&&Q({input:u.stdout}).on(`line`,n=>{a&&a.write(n+`
1
+ import{l as e,o as t,u as n}from"./envUtils-BDhHQY0-.js";import{At as r,HS as i,Tt as a,VS as o,_t as s}from"./loadAgentsDir-BL93ulMm.js";import{t as c}from"./src-P_wYS_NJ2.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-BecbSVoN.js";import{Wt as g}from"./settings-D4CpDv2y.js";import{O as _,k as v}from"./git-DBlOv64X.js";import{o as y,s as b}from"./log-Dauqle-Z.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-CmH_aVy2.js";import{Bt as E,Ot as D,_n as O,vn as k}from"./model-Bgh_r4lg.js";import{i as ee,t as A}from"./sessionIdCompat-DMayYBrf.js";import{n as j}from"./firstPartyEventLogger-BHjBQH0J.js";import{t as te}from"./datadog-bm551AVV.js";import{n as M,o as N,r as P}from"./debugUtils-CmJfIUxW.js";import{t as F}from"./pollConfig-BgpfHQPJ.js";import{n as I,t as L}from"./rcDebugLog-CARUIORE.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-BOySRJUJ.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-BEhXgH2M.js";import{i as U}from"./trustedDevice-DL0pWP4_.js";import{t as le}from"./jwtUtils-OzxN2zts.js";import{i as W,n as G,r as K}from"./cliLaunch-BTpfAGGI.js";import"./bridgeStatusUtil-C36w15ge.js";import{t as q}from"./lib-BlVGipXx.js";import{hostname as J,tmpdir as ue}from"os";import{dirname as Y,join as de,resolve as X}from"path";import{createWriteStream as Z}from"fs";import{randomUUID as fe}from"crypto";import{spawn as pe}from"child_process";import{createInterface as Q}from"readline";t(),d(),h(),_(),y(),x(),T(),O(),i(),te(),j(),a(),L(),W(),q(),g(),c(),m(),A(),N();var me=10,he=10;function ge(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var $={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(e,t){let n=$[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 ve(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(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${be(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 ye(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 be(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 xe(e){return{spawn(t,n){let r=ge(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(Y(e.debugFile),`bridge-transcript-${r}.jsonl`),a=Z(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=pe(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+`
2
+ `),m.length>=he&&m.shift(),m.push(t)}),u.stdout&&Q({input:u.stdout}).on(`line`,n=>{a&&a.write(n+`
3
3
  `),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${M(n)}`),e.verbose&&process.stderr.write(n+`
4
- `);let r=ve(n,t.sessionId,e.onDebug);for(let n of r)d.length>=me&&d.shift(),d.push(n),f=n,e.onActivity?.(t.sessionId,n);{let r;try{r=l(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=ye(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:p,get currentActivity(){return f},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(m({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})+`
5
- `),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return v}}}f(),N();var Se={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Ce=1e3;function we(e){return e.connCapMs*2}function Te(){let e=[...G()],t=K();return t&&e.push(t),e}function Ee(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 De(t,i,o,c,l,d,f,m=Se,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 pe(){Q(),fe(),Z=setInterval(fe,Ce)}function Q(){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(),Q();let ee=a.lastStderr.length>0?a.lastStderr.join(`
6
- `):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(Ne(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||pe()}}for(h||pe();!y.aborted;){let f=F();try{I(`poll: envId=${i} activeSessions=${x.size}`);let g=await c.pollForWork(i,o,y,f.reclaim_older_than_ms);if(J!==null||Y!==null){let e=Date.now()-(J??Y??Date.now());d.logReconnected(e),p(`[bridge:poll] Reconnected after ${w(e)}`),S(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(K=0,q=0,J=null,Y=null,X=null,!g){if(x.size>=t.maxSessions){let e=f.multisession_poll_interval_ms_at_capacity;if(f.non_exclusive_heartbeat_interval_ms>0){S(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:x.size,heartbeat_interval_ms:f.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!y.aborted&&x.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=F();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=N.signal();if(r=await L(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await k(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:y.aborted?`shutdown`:x.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(S(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:x.size}),a===`poll_due`&&p(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=N.signal();await k(e>0?e:f.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=N.signal();await k(e,t.signal),t.cleanup()}}else await k(x.size>0?f.multisession_poll_interval_ms_partial_capacity:f.multisession_poll_interval_ms_not_at_capacity,y);continue}let _=x.size>=t.maxSessions;if(A.has(g.id)){if(p(`[bridge:work] Skipping already-completed workId=${g.id}`),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await k(1e3,y);continue}let P;try{P=se(g.secret)}catch(e){let t=u(e);if(d.logError(`Failed to decode work secret for workId=${g.id}: ${t}`),S(`tengu_bridge_work_secret_failed`,{}),A.add(g.id),G(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs)),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let R=async()=>{p(`[bridge:work] Acknowledging workId=${g.id}`);try{await c.acknowledgeWork(i,g.id,P.session_ingress_token)}catch(e){p(`[bridge:work] Acknowledge failed workId=${g.id}: ${u(e)}`)}},z=g.data.type;switch(g.data.type){case`healthcheck`:await R(),p(`[bridge:work] Healthcheck received`),d.logVerbose(`Healthcheck received`);break;case`session`:{let o=g.data.id;I(`work received: type=session sessionId=${o} workId=${g.id}`);try{ne(o,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${o}`);break}let f=x.get(o);if(f){f.updateAccessToken(P.session_ingress_token),D.set(o,P.session_ingress_token),T.set(o,g.id),V?.schedule(o,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${o} workId=${g.id}`),await R();break}if(x.size>=t.maxSessions){p(`[bridge:work] At capacity (${x.size}/${t.maxSessions}), cannot spawn new session for workId=${g.id}`);break}await R();let _=Date.now(),w,N=!1,F;if(P.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){w=ce(t.apiBaseUrl,o);for(let e=1;e<=2;e++)try{F=await ae(w,P.session_ingress_token),N=!0,p(`[bridge:session] CCR v2: registered worker sessionId=${o} epoch=${F} attempt=${e}`);break}catch(t){let n=u(t);if(e<2){if(p(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await k(2e3,y),y.aborted)break;continue}d.logError(`CCR v2 worker registration failed for session ${o}: ${n}`),b(Error(`registerWorker failed: ${n}`)),A.add(g.id),G(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs))}if(!N)break}else w=oe(t.sessionIngressUrl,o);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(o,h))){let e=Date.now();try{let t=await s(`bridge-${ge(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(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs));break}}p(`[bridge:session] Spawning sessionId=${o} sdkUrl=${w}`);let H=ee(o);I(`spawning session: sessionId=${o} sdkUrl=${w} useCcrV2=${N} workerEpoch=${F} dir=${z} accessToken=${P.session_ingress_token?P.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let se=Ee(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=Ie(e);d.setSessionTitle(H,n),p(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-eE8mswkv.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(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs));break}let U=se,le=Date.now()-_;S(`tengu_bridge_session_started`,{active_sessions:x.size,spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B}),x.set(o,U),T.set(o,g.id),D.set(o,P.session_ingress_token),E.set(o,H);let W=Date.now();C.set(o,W),d.logSessionStart(o,`Session ${o}`);let K=ge(o),q;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);q=e>0?`${t.debugFile.slice(0,e)}-${K}${t.debugFile.slice(e)}`:`${t.debugFile}-${K}`}else t.verbose&&(q=de(ue(),`claude`,`bridge-session-${K}.log`));q&&d.logVerbose(`Debug log: ${q}`),d.addSession(H,a(H,t.sessionIngressUrl)),pe(),d.setAttached(H),Le(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(Pe,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=${ke(e)} isServer=${Ae(e)} activeSessions=${x.size}`),ke(e)||Ae(e)){let e=Date.now();X!==null&&e-X>we(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=je(K);d.logVerbose(`Connection error, retrying in ${Me(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(Me(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>we(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=je(q);d.logVerbose(`Poll failed, retrying in ${Me(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(Me(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}}}Q(),d.clearStatus();let he=Date.now()-U;S(`tengu_bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:he}),v(`info`,`bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:he});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-DLYyvRKb.js`);await ve(t.dir),d.logVerbose(`Environment offline.`)}var Oe=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function ke(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&Oe.has(e.code))}function Ae(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function je(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function Me(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function Ne(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=je(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${Me(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 Pe(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 Fe=80;function Ie(e){return C(e.replace(/\s+/g,` `).trim(),Fe)}async function Le(e,t){let{getBridgeSession:n}=await import(`./createSession-eE8mswkv.js`);return(await n(e,{baseUrl:t}))?.title||void 0}var Re=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function ze(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-D_lk6z-C.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-CVHMRMwd.js`);o();let{initSinks:c}=await import(`./sinks-BJHgxz6Y.js`);if(c(),!s())throw new Re(`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-BeqChxJC.js`),d=l();if(d.startsWith(`http://`)&&!d.includes(`localhost`)&&!d.includes(`127.0.0.1`))throw new Re(`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-XtKbtJMc.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-DWg07LmS.js`);if(e.spawnMode===`worktree`&&!(g()||h(n)!==null))throw new Re(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let _=await p(),v=await m(),y=J(),b=fe(),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:fe(),apiBaseUrl:d,sessionIngressUrl:f,sessionTimeoutMs:e.sessionTimeoutMs},S=re({baseUrl:d,getAccessToken:e.getAccessToken,runnerVersion:`0.0.10`,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=xe({execPath:process.execPath,scriptArgs:Te(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),E=Be(r);E.printBanner(x,C);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-eE8mswkv.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 De(x,C,w,S,T,E,t,void 0,D,async()=>e.getAccessToken())}function Be(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(),h();var Ve=78,He=1;async function Ue(e){if(!e){console.error(`Error: --daemon-worker requires a worker kind`),process.exitCode=Ve;return}switch(e){case`remoteControl`:await We();break;default:console.error(`Error: unknown daemon worker kind '${e}'`),process.exitCode=Ve}}async function We(){let e=process.env.DAEMON_WORKER_DIR||X(`.`),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 ze(d,c.signal)}catch(e){e instanceof Re?(console.error(`[remoteControl] permanent error: ${e.message}`),process.exitCode=Ve):(console.error(`[remoteControl] transient error: ${u(e)}`),process.exitCode=He)}finally{process.off(`SIGTERM`,l),process.off(`SIGINT`,l)}}export{Ue as runDaemonWorker};
4
+ `);let r=ve(n,t.sessionId,e.onDebug);for(let n of r)d.length>=me&&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=ye(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}})+`
5
+ `),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return v}}}m(),N();var Se={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Ce=1e3;function we(e){return e.connCapMs*2}function Te(){let e=[...G()],t=K();return t&&e.push(t),e}function Ee(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 De(t,i,a,c,l,d,f,m=Se,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 pe(){Q(),fe(),Z=setInterval(fe,Ce)}function Q(){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(),Q();let ee=a.lastStderr.length>0?a.lastStderr.join(`
6
+ `):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(Ne(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||pe()}}for(h||pe();!y.aborted;){let f=F();try{I(`poll: envId=${i} activeSessions=${x.size}`);let g=await c.pollForWork(i,a,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(Ne(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 a=g.data.id;I(`work received: type=session sessionId=${a} workId=${g.id}`);try{ne(a,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${a}`);break}let f=x.get(a);if(f){f.updateAccessToken(P.session_ingress_token),D.set(a,P.session_ingress_token),T.set(a,g.id),V?.schedule(a,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${a} 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,a);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=${a} 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 ${a}: ${n}`),b(Error(`registerWorker failed: ${n}`)),A.add(g.id),G(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs))}if(!N)break}else w=oe(t.sessionIngressUrl,a);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(a,h))){let e=Date.now();try{let t=await s(`bridge-${ge(a)}`);B=Date.now()-e,j.set(a,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),z=t.worktreePath,p(`[bridge:session] Created worktree for sessionId=${a} at ${t.worktreePath}`)}catch(e){let t=u(e);d.logError(`Failed to create worktree for session ${a}: ${t}`),b(Error(`Worktree creation failed: ${t}`)),A.add(g.id),G(Ne(c,i,g.id,d,m.stopWorkBaseDelayMs));break}}p(`[bridge:session] Spawning sessionId=${a} sdkUrl=${w}`);let H=ee(a);I(`spawning session: sessionId=${a} sdkUrl=${w} useCcrV2=${N} workerEpoch=${F} dir=${z} accessToken=${P.session_ingress_token?P.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let se=Ee(l,{sessionId:a,sdkUrl:w,accessToken:P.session_ingress_token,useCcrV2:N,workerEpoch:F,onFirstUserMessage:e=>{if(M.has(H))return;M.add(H);let n=Ie(e);d.setSessionTitle(H,n),p(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-D27zvmOs.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 ${a}: ${se}`);let e=j.get(a);e&&(j.delete(a),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(Ne(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(a),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(a),spawn_duration_ms:le,worktree_create_ms:B}),x.set(a,U),T.set(a,g.id),D.set(a,P.session_ingress_token),E.set(a,H);let W=Date.now();C.set(a,W),d.logSessionStart(a,`Session ${a}`);let K=ge(a),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)),pe(),d.setAttached(H),Le(H,t.apiBaseUrl).then(e=>{e&&x.has(a)&&(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(Pe,J,a,J,d,te,U);O.set(a,e)}N&&re.add(a),V?.schedule(a,P.session_ingress_token),U.done.then(me(a,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=${ke(e)} isServer=${Ae(e)} activeSessions=${x.size}`),ke(e)||Ae(e)){let e=Date.now();X!==null&&e-X>we(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=je(K);d.logVerbose(`Connection error, retrying in ${Me(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(Me(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>we(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=je(q);d.logVerbose(`Poll failed, retrying in ${Me(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(Me(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}}}Q(),d.clearStatus();let he=Date.now()-U;S(`tengu_bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:he}),v(`info`,`bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:he});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-BL8-lGvN.js`);await ve(t.dir),d.logVerbose(`Environment offline.`)}var Oe=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function ke(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&Oe.has(e.code))}function Ae(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function je(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function Me(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function Ne(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=je(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${Me(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 Pe(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 Fe=80;function Ie(e){return C(e.replace(/\s+/g,` `).trim(),Fe)}async function Le(e,t){let{getBridgeSession:n}=await import(`./createSession-D27zvmOs.js`);return(await n(e,{baseUrl:t}))?.title||void 0}var Re=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function ze(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-D_lk6z-C.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-kB2eazPX.js`);o();let{initSinks:c}=await import(`./sinks-WJ7nzLQs.js`);if(c(),!s())throw new Re(`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-CzRUPn-D.js`),d=l();if(d.startsWith(`http://`)&&!d.includes(`localhost`)&&!d.includes(`127.0.0.1`))throw new Re(`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-DF4RFFaT.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-DT80Arzc.js`);if(e.spawnMode===`worktree`&&!(g()||h(n)!==null))throw new Re(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let _=await p(),v=await m(),y=J(),b=fe(),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:fe(),apiBaseUrl:d,sessionIngressUrl:f,sessionTimeoutMs:e.sessionTimeoutMs},S=re({baseUrl:d,getAccessToken:e.getAccessToken,runnerVersion:`0.0.11`,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=xe({execPath:process.execPath,scriptArgs:Te(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),E=Be(r);E.printBanner(x,C);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-D27zvmOs.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 De(x,C,w,S,T,E,t,void 0,D,async()=>e.getAccessToken())}function Be(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 Ve=78,He=1;async function Ue(e){if(!e){console.error(`Error: --daemon-worker requires a worker kind`),process.exitCode=Ve;return}switch(e){case`remoteControl`:await We();break;default:console.error(`Error: unknown daemon worker kind '${e}'`),process.exitCode=Ve}}async function We(){let e=process.env.DAEMON_WORKER_DIR||X(`.`),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 ze(d,c.signal)}catch(e){e instanceof Re?(console.error(`[remoteControl] permanent error: ${e.message}`),process.exitCode=Ve):(console.error(`[remoteControl] transient error: ${u(e)}`),process.exitCode=He)}finally{process.off(`SIGTERM`,l),process.off(`SIGINT`,l)}}export{Ue as runDaemonWorker};
@@ -0,0 +1 @@
1
+ import{Tt as e,bt as t}from"./loadAgentsDir-BL93ulMm.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-BDhHQY0-.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.10 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-D4FBdEQr.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-oIqjxIjQ.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-C07BcZIw.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-CVHMRMwd.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DgZ3YY4a.js`);r();let{initSinks:i}=await import(`./chunks/sinks-BJHgxz6Y.js`);i();let{daemonMain:a}=await import(`./chunks/main-CvOv59-7.js`);await a(e.slice(1));return}if(e[0]===`autonomy`){t(`cli_autonomy_path`);let{getAutonomyCommandText:n}=await import(`./chunks/autonomy-C1aSgWPQ.js`),r=await n(e.slice(1).join(` `));await new Promise((e,t)=>{process.stdout.write(`${r}\n`,n=>{if(n){t(n);return}e()})}),process.exit(0)}if(e.includes(`--bg`)||e.includes(`--background`)){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-CVHMRMwd.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-DgZ3YY4a.js`);r(),await(await import(`./chunks/bg-50rllUNh.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-CVHMRMwd.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-DgZ3YY4a.js`);i();let{initSinks:a}=await import(`./chunks/sinks-BJHgxz6Y.js`);a();let{daemonMain:o}=await import(`./chunks/main-CvOv59-7.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-CrNPEKkh.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-CrNPEKkh.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-CVHMRMwd.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-dFUkhVE_.js`),n=await t(e);if(n.handled)return;if(n.error){let{exitWithError:e}=await import(`./chunks/process-CNfq37LF.js`);e(n.error)}}}e.length===1&&(e[0]===`--update`||e[0]===`--upgrade`)&&(process.argv=[process.argv[0],process.argv[1],`update`]),e.includes(`--bare`)&&(process.env.CLAUDE_CODE_SIMPLE=`1`);let{startCapturingEarlyInput:n}=await import(`./chunks/earlyInput-BEjRkAtH.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-9r5gLzUW.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-BDhHQY0-.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.11 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-B4HBBbHN.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-mdegyj8z.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-Bq9bS5pw.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-kB2eazPX.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-BY-IVNwQ.js`);r();let{initSinks:i}=await import(`./chunks/sinks-WJ7nzLQs.js`);i();let{daemonMain:a}=await import(`./chunks/main-LMyE3jXY.js`);await a(e.slice(1));return}if(e[0]===`autonomy`){t(`cli_autonomy_path`);let{getAutonomyCommandText:n}=await import(`./chunks/autonomy-lJV7yWUl.js`),r=await n(e.slice(1).join(` `));await new Promise((e,t)=>{process.stdout.write(`${r}\n`,n=>{if(n){t(n);return}e()})}),process.exit(0)}if(e.includes(`--bg`)||e.includes(`--background`)){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-kB2eazPX.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-BY-IVNwQ.js`);r(),await(await import(`./chunks/bg-CeUrRz_7.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-kB2eazPX.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-BY-IVNwQ.js`);i();let{initSinks:a}=await import(`./chunks/sinks-WJ7nzLQs.js`);a();let{daemonMain:o}=await import(`./chunks/main-LMyE3jXY.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-CxqU-s5i.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-CxqU-s5i.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-kB2eazPX.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-4SUJ4dtz.js`),n=await t(e);if(n.handled)return;if(n.error){let{exitWithError:e}=await import(`./chunks/process-CNfq37LF.js`);e(n.error)}}}e.length===1&&(e[0]===`--update`||e[0]===`--upgrade`)&&(process.argv=[process.argv[0],process.argv[1],`update`]),e.includes(`--bare`)&&(process.env.CLAUDE_CODE_SIMPLE=`1`);let{startCapturingEarlyInput:n}=await import(`./chunks/earlyInput-BEjRkAtH.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-CVNWNAoh.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.10",
3
+ "version": "0.0.11",
4
4
  "description": "workMate",
5
5
  "type": "module",
6
6
  "author": "Frandy",
@@ -30,8 +30,7 @@
30
30
  },
31
31
  "workspaces": [
32
32
  "packages/*",
33
- "packages/@ant/*",
34
- "packages/@anthropic-ai/*"
33
+ "packages/@ant/*"
35
34
  ],
36
35
  "files": [
37
36
  "dist",
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{Cg as e,Sg as t}from"./loadAgentsDir-C7lOqvfh.js";import{R as n,fi as r,t as i}from"./src-P_wYS_NJ2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{c as o,h as s,y as c}from"./config-Do1870_d.js";import{n as l}from"./onChangeAppState-RBl6H7ho.js";import{t as u}from"./fpsMetrics-DffAomdg.js";import{t as d}from"./stats-IzV0_vEc.js";r(),e(),i(),s();var f=a();function p({getFpsMetrics:e,stats:r,initialState:i,children:a}){return(0,f.jsx)(u,{getFpsMetrics:e,children:(0,f.jsx)(d,{store:r,children:(0,f.jsx)(t,{initialState:i,onChangeAppState:l,children:(0,f.jsx)(n,{initialState:o().theme,onThemeSave:e=>c(t=>({...t,theme:e})),children:a})})})})}export{p as App};
@@ -1 +0,0 @@
1
- import{t as e}from"./ApproveApiKey-MscC-ssL.js";export{e as ApproveApiKey};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{nd as e,td as t}from"./loadAgentsDir-C7lOqvfh.js";import{P as n,fi as r,t as i,y as a}from"./src-P_wYS_NJ2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{h as s,y as c}from"./config-Do1870_d.js";r(),i(),s(),t();var l=o();function u({customApiKeyTruncated:t,onDone:r}){function i(e){switch(e){case`yes`:c(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,approved:[...e.customApiKeyResponses?.approved??[],t]}})),r(!0);break;case`no`:c(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,rejected:[...e.customApiKeyResponses?.rejected??[],t]}})),r(!1);break}}return(0,l.jsxs)(a,{title:`Detected a custom API key in your environment`,color:`warning`,onCancel:()=>i(`no`),children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,children:`ANTHROPIC_API_KEY`}),(0,l.jsxs)(n,{children:[`: sk-ant-...`,t]})]}),(0,l.jsx)(n,{children:`Do you want to use this API key?`}),(0,l.jsx)(e,{defaultValue:`no`,defaultFocusValue:`no`,options:[{label:`Yes`,value:`yes`},{label:(0,l.jsxs)(n,{children:[`No (`,(0,l.jsx)(n,{bold:!0,children:`recommended`}),`)`]}),value:`no`}],onChange:e=>i(e),onCancel:()=>i(`no`)})]})}export{u as t};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./figures-5ThXQEtq.js";import{$C as a,Ba as o,Cg as s,Da as c,Eg as l,Gf as u,Hs as d,JC as f,Ja as p,Kf as m,LS as h,RS as g,Vf as _,Vs as ee,YC as te,_u as v,au as ne,bf as y,bg as b,bp as re,cu as x,e_ as ie,gp as ae,hp as oe,jn as se,kn as ce,ld as le,lu as S,nd as C,nl as w,od as ue,ou as de,pu as fe,qC as T,r_ as pe,ra as me,rd as he,rl as ge,su as _e,wg as ve,xg as ye,xp as be,yf as xe,zf as Se}from"./loadAgentsDir-C7lOqvfh.js";import{D as E,Gt as Ce,H as we,I as D,Lt as Te,P as O,T as k,fi as A,mt as Ee,ot as De,t as j,y as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{F as Oe,p as ke,v as Ae,z as je}from"./debug-RAynG_nM.js";import{In as P,Ln as Me,Rn as Ne,Ut as Pe}from"./settings-DnptdP79.js";import{C as Fe,b as F,f as Ie,l as Le,u as Re,v as I}from"./startupProfiler-L_UWZ03w.js";import{l as L,o as ze}from"./stringUtils-C84IJ91d.js";import{bn as Be,jt as Ve,vn as He,yn as Ue}from"./prompt-M2lu8_Oa.js";import{i as We,n as Ge}from"./mappers-bOab8ipV.js";function R(e,t,n=1e3,r=0,i){let a=()=>Le(Math.max(0,(i??Date.now())-e-r));return(0,Ke.useSyncExternalStore)((0,Ke.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var Ke,z=t((()=>{Ke=n(A(),1),I()}));function qe(e,t,n){let r=He(t,e.toolName);if(!r)return e.toolName;try{let t=r.inputSchema.safeParse(e.input),i=t.success?t.data:{},a=r.userFacingName(i);if(!a)return e.toolName;let o=r.renderToolUseMessage(i,{theme:n,verbose:!1});return o?(0,Je.jsxs)(O,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var Je,Ye=t((()=>{A(),j(),Be(),Je=N()}));function Xe(e,t){let{isIdle:n,awaitingApproval:r,hasError:a,shutdownRequested:o}=t??{};return a?i.cross:r?i.questionMarkPrefix:o?i.warning:e===`running`?n?i.ellipsis:i.play:e===`completed`?i.tick:e===`failed`||e===`killed`?i.cross:i.bullet}function Ze(e,t){let{isIdle:n,awaitingApproval:r,hasError:i,shutdownRequested:a}=t??{};return i?`error`:r||a?`warning`:n?`background`:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:`background`}function Qe(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(m(t))return n=!0,!1;return n}var $e=t((()=>{r(),u()}));function et({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=we(),a=(0,tt.useMemo)(()=>w(Ue()),[]),o=R(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);Ce({"confirm:yes":t},{context:`Confirmation`});let s=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},l=c(e.prompt,`plan`),u=e.prompt.length>300?e.prompt.substring(0,297)+`…`:e.prompt,d=e.result?.totalTokens??e.progress?.tokenCount,f=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,B.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:(0,B.jsx)(M,{title:(0,B.jsxs)(O,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,B.jsxs)(O,{children:[e.status!==`running`&&(0,B.jsxs)(O,{color:Ze(e.status),children:[Xe(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,B.jsxs)(O,{dimColor:!0,children:[o,d!==void 0&&d>0&&(0,B.jsxs)(B.Fragment,{children:[` · `,Ie(d),` tokens`]}),f!==void 0&&f>0&&(0,B.jsxs)(B.Fragment,{children:[` `,`· `,f,` `,f===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,B.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,B.jsxs)(k,{children:[r&&(0,B.jsx)(E,{shortcut:`←`,action:`go back`}),(0,B.jsx)(E,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,B.jsx)(E,{shortcut:`x`,action:`stop`})]}),children:(0,B.jsxs)(D,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,B.jsxs)(D,{flexDirection:`column`,children:[(0,B.jsx)(O,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,B.jsxs)(O,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,qe(t,a,i)]},n))]}),l?(0,B.jsx)(D,{marginTop:1,children:(0,B.jsx)(re,{addMargin:!1,planContent:l})}):(0,B.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(O,{bold:!0,dimColor:!0,children:`Prompt`}),(0,B.jsx)(O,{wrap:`wrap`,children:u})]}),e.status===`failed`&&e.error&&(0,B.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(O,{bold:!0,color:`error`,children:`Error`}),(0,B.jsx)(O,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var tt,B,nt=t((()=>{tt=n(A(),1),z(),j(),T(),Be(),ge(),I(),o(),be(),Ye(),$e(),B=N()}));function rt(e,t,n,r){if(!e)return`${t} found · ${n} verified`;if(e===`synthesizing`){let e=[`${n} verified`];return r>0&&e.push(`${r} refuted`),e.push(`deduping`),e.join(` · `)}if(e===`verifying`){let e=[`${t} found`,`${n} verified`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return t>0?`${t} found`:`finding`}function it({text:e,phase:t=0}){return(0,V.jsx)(V.Fragment,{children:[...e].map((e,n)=>(0,V.jsx)(O,{color:oe(n+t),children:e},n))})}function at(e,t,n){let r=(0,ct.useRef)(e),i=(0,ct.useRef)(t);return n||e<r.current?r.current=e:e>r.current&&t!==i.current&&(r.current+=1,i.current=t),r.current}function ot({session:e}){let t=ye().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=Ee(r&&!t?lt:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,l=at(a,i,c),u=at(o,i,c),d=at(s,i,c),f=Math.floor(i/(lt*3))%7;if(e.status===`completed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsx)(O,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsxs)(O,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let p=n?rt(n.stage,l,u,d):`setting up`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(O,{color:`background`,children:[`◇`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:r?f:0}),(0,V.jsxs)(O,{dimColor:!0,children:[` · `,p]})]})}function st({session:e}){if(e.isRemoteReview)return(0,V.jsx)(ot,{session:e});if(e.status===`completed`)return(0,V.jsx)(O,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,V.jsx)(O,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,V.jsxs)(O,{dimColor:!0,children:[e.status,`…`]});let t=P(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,V.jsxs)(O,{dimColor:!0,children:[t,`/`,n]})}var ct,V,lt,ut=t((()=>{ct=n(A(),1),Pe(),b(),j(),Me(),ae(),V=N(),lt=80}));function H({status:e,label:t,suffix:n}){return(0,U.jsxs)(O,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function dt({shell:e}){switch(e.status){case`completed`:return(0,U.jsx)(H,{status:`completed`,label:`done`});case`failed`:return(0,U.jsx)(H,{status:`failed`,label:`error`});case`killed`:return(0,U.jsx)(H,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,U.jsx)(H,{status:`running`})}}var U,ft=t((()=>{j(),U=N()}));function pt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,W.jsxs)(O,{children:[F(e.command,n,!0),` `,(0,W.jsx)(dt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,W.jsx)(O,{children:(0,W.jsx)(st,{session:e})}):(0,W.jsxs)(O,{children:[(0,W.jsxs)(O,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),F(e.title,n,!0),(0,W.jsx)(O,{dimColor:!0,children:` · `}),(0,W.jsx)(st,{session:e})]});case`local_agent`:return(0,W.jsxs)(O,{children:[F(e.description,n,!0),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]});case`local_workflow`:{let t=e;return(0,W.jsxs)(O,{children:[F(t.workflowName??e.summary??e.description,n,!0),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`running`?`${t.agentCount} ${L(t.agentCount,`agent`)}`:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}case`dream`:{let t=e.filesTouched.length,n=e.phase===`updating`&&t>0?`${t} ${L(t,`file`)}`:`${e.sessionsReviewing} ${L(e.sessionsReviewing,`session`)}`;return(0,W.jsxs)(O,{children:[e.description,` `,(0,W.jsxs)(O,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var W,mt=t((()=>{A(),j(),I(),ze(),Pe(),ut(),ft(),W=N()}));function ht({task:e,onDone:t,onBack:n,onKill:r}){let i=R(e.startTime,e.status===`running`,1e3,0);Ce({"confirm:yes":t},{context:`Confirmation`});let a=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&n?(i.preventDefault(),n()):i.key===`x`&&e.status===`running`&&r&&(i.preventDefault(),r())},o=e.turns.filter(e=>e.text!==``),s=o.slice(-6),c=o.length-s.length;return(0,G.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,G.jsx)(M,{title:`Memory consolidation`,subtitle:(0,G.jsxs)(O,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,L(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,G.jsxs)(G.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,L(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,G.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,G.jsxs)(k,{children:[n&&(0,G.jsx)(E,{shortcut:`←`,action:`go back`}),(0,G.jsx)(E,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,G.jsx)(E,{shortcut:`x`,action:`stop`})]}),children:(0,G.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,G.jsxs)(O,{children:[(0,G.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,G.jsx)(O,{color:`background`,children:`running`}):e.status===`completed`?(0,G.jsx)(O,{color:`success`,children:e.status}):(0,G.jsx)(O,{color:`error`,children:e.status})]}),s.length===0?(0,G.jsx)(O,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,G.jsxs)(G.Fragment,{children:[c>0&&(0,G.jsxs)(O,{dimColor:!0,children:[`(`,c,` earlier `,L(c,`turn`),`)`]}),s.map((e,t)=>(0,G.jsxs)(D,{flexDirection:`column`,children:[(0,G.jsx)(O,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,G.jsxs)(O,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,L(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var G,gt=t((()=>{A(),z(),j(),T(),ze(),G=N()}));function _t({stage:e,completed:t,hasProgress:n}){let r=e?xt.indexOf(e):-1,i=!t&&!n;return(0,q.jsxs)(O,{children:[i?(0,q.jsx)(O,{color:`background`,children:`Setup`}):(0,q.jsx)(O,{dimColor:!0,children:`Setup`}),(0,q.jsx)(O,{dimColor:!0,children:` → `}),xt.map((e,n)=>{let a=!t&&!i&&n===r;return(0,q.jsxs)(K.Fragment,{children:[n>0&&(0,q.jsx)(O,{dimColor:!0,children:` → `}),a?(0,q.jsx)(O,{color:`background`,children:St[e]}):(0,q.jsx)(O,{dimColor:!0,children:St[e]})]},e)}),t&&(0,q.jsx)(O,{color:`success`,children:` ✓`})]})}function vt(e){let t=e.reviewProgress;if(!t)return e.status===`completed`?`done`:`setting up`;let n=t.bugsVerified,r=t.bugsRefuted??0;if(e.status===`completed`){let e=[`${n} ${L(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return rt(t.stage,t.bugsFound,n,r)}function yt({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,a=e.status===`running`||e.status===`pending`,[o,s]=(0,K.useState)(!1),c=R(e.startTime,a,1e3,0,e.endTime),l=()=>t(`Remote session details dismissed`,{display:`system`}),u=n??l,d=x(e.sessionId),f=i?`ready`:a?`running`:e.status;if(o)return(0,q.jsx)(M,{title:`Stop ultrareview?`,onCancel:()=>s(!1),color:`background`,children:(0,q.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(O,{dimColor:!0,children:`This archives the remote session and stops local tracking. The review will not complete and any findings so far are discarded.`}),(0,q.jsx)(C,{options:[{label:`Stop ultrareview`,value:`stop`},{label:`Back`,value:`back`}],onChange:e=>{e===`stop`?(r?.(),u()):s(!1)}})]})});let p=i?[{label:`Open in Claude Code on the web`,value:`open`},{label:`Dismiss`,value:`dismiss`}]:[{label:`Open in Claude Code on the web`,value:`open`},...r&&a?[{label:`Stop ultrareview`,value:`stop`}]:[],{label:`Back`,value:`back`}];return(0,q.jsx)(M,{title:(0,q.jsxs)(O,{children:[(0,q.jsxs)(O,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,q.jsx)(O,{bold:!0,children:`ultrareview`}),(0,q.jsxs)(O,{dimColor:!0,children:[` · `,c,` · `,f]})]}),onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(k,{children:[(0,q.jsx)(E,{shortcut:`Enter`,action:`select`}),(0,q.jsx)(E,{shortcut:`Esc`,action:`go back`})]}),children:(0,q.jsxs)(D,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(_t,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,q.jsxs)(D,{flexDirection:`column`,children:[(0,q.jsx)(O,{children:vt(e)}),(0,q.jsx)(Te,{url:d,children:(0,q.jsx)(O,{dimColor:!0,children:d})})]}),(0,q.jsx)(C,{options:p,onChange:e=>{switch(e){case`open`:g(d),t();break;case`stop`:s(!0);break;case`back`:u();break;case`dismiss`:l();break}}})]})})}function bt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null),l=(0,K.useMemo)(()=>e.isRemoteReview?[]:p(We(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,q.jsx)(yt,{session:e,onDone:n,onBack:r,onKill:i});let u=()=>n(`Remote session details dismissed`,{display:`system`}),d=e=>{e.key===` `?(e.preventDefault(),n(`Remote session details dismissed`,{display:`system`})):e.key===`left`&&r?(e.preventDefault(),r()):e.key===`t`&&!a?(e.preventDefault(),f()):e.key===`return`&&(e.preventDefault(),u())};async function f(){o(!0),c(null);try{await v(e.sessionId)}catch(e){c(Oe(e))}finally{o(!1)}}let m=Fe(e.title,50),h=e.status===`pending`?`starting`:e.status;return(0,q.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:(0,q.jsxs)(M,{title:`Remote session details`,onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(k,{children:[r&&(0,q.jsx)(E,{shortcut:`←`,action:`go back`}),(0,q.jsx)(E,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,q.jsx)(E,{shortcut:`t`,action:`teleport`})]}),children:[(0,q.jsxs)(D,{flexDirection:`column`,children:[(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Status`}),`:`,` `,h===`running`||h===`starting`?(0,q.jsx)(O,{color:`background`,children:h}):h===`completed`?(0,q.jsx)(O,{color:`success`,children:h}):(0,q.jsx)(O,{color:`error`,children:h})]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Runtime`}),`: `,Le((e.endTime??Date.now())-e.startTime)]}),(0,q.jsxs)(O,{wrap:`truncate-end`,children:[(0,q.jsx)(O,{bold:!0,children:`Title`}),`: `,m]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Progress`}),`: `,(0,q.jsx)(st,{session:e})]}),(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Session URL`}),`:`,` `,(0,q.jsx)(Te,{url:x(e.sessionId),children:(0,q.jsx)(O,{dimColor:!0,children:x(e.sessionId)})})]})]}),e.log.length>0&&(0,q.jsxs)(D,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(O,{children:[(0,q.jsx)(O,{bold:!0,children:`Recent messages`}),`:`]}),(0,q.jsx)(D,{flexDirection:`column`,height:10,overflowY:`hidden`,children:l.map((e,n)=>(0,q.jsx)(Se,{message:e,lookups:me,addMargin:n>0,tools:t.options.tools,commands:t.options.commands,verbose:t.options.verbose,inProgressToolUseIDs:new Set,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,style:`condensed`,isTranscriptMode:!1,isStatic:!0},n))}),(0,q.jsx)(D,{marginTop:1,children:(0,q.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing last `,l.length,` of `,e.log.length,` messages`]})})]}),s&&(0,q.jsx)(D,{marginTop:1,children:(0,q.jsxs)(O,{color:`error`,children:[`Teleport failed: `,s]})}),a&&(0,q.jsx)(O,{color:`background`,children:`Teleporting to session…`})]})})}var K,q,xt,St,Ct=t((()=>{K=n(A(),1),Pe(),z(),j(),S(),Ve(),h(),je(),I(),Ge(),o(),ze(),fe(),he(),_(),ut(),q=N(),xt=[`finding`,`verifying`,`synthesizing`],St={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function wt(e){let t=ce(e.id);try{let e=await Ae(t,Dt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function Tt({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=De(),[a,o]=(0,J.useState)(()=>wt(e)),s=(0,J.useDeferredValue)(a);(0,J.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(wt(t)),1e3,o,e);return()=>clearInterval(t)},[e.id,e.status]);let c=()=>t(`Shell details dismissed`,{display:`system`});Ce({"confirm:yes":c},{context:`Confirmation`});let l=i=>{i.key===` `?(i.preventDefault(),t(`Shell details dismissed`,{display:`system`})):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},u=Fe(e.command,280);return(0,Y.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,Y.jsxs)(M,{title:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,Y.jsxs)(O,{children:[`Press `,t.keyName,` again to exit`]}):(0,Y.jsxs)(k,{children:[r&&(0,Y.jsx)(E,{shortcut:`←`,action:`go back`}),(0,Y.jsx)(E,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,Y.jsx)(E,{shortcut:`x`,action:`stop`})]}),children:[(0,Y.jsxs)(D,{flexDirection:`column`,children:[(0,Y.jsxs)(O,{children:[(0,Y.jsx)(O,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,Y.jsxs)(O,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,Y.jsxs)(O,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,Y.jsxs)(O,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,Y.jsxs)(O,{children:[(0,Y.jsx)(O,{bold:!0,children:`Runtime:`}),` `,Le((e.endTime??Date.now())-e.startTime)]}),(0,Y.jsxs)(O,{wrap:`wrap`,children:[(0,Y.jsx)(O,{bold:!0,children:`Command:`}),` `,u]})]}),(0,Y.jsxs)(D,{flexDirection:`column`,children:[(0,Y.jsx)(O,{bold:!0,children:`Output:`}),(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(O,{dimColor:!0,children:`Loading output…`}),children:(0,Y.jsx)(Et,{outputPromise:s,columns:i})})]})]})})}function Et({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,J.use)(e);if(!n)return(0,Y.jsx)(O,{dimColor:!0,children:`No output available`});let i=[],a=n.length;for(let e=0;e<10&&a>0;e++){let e=n.lastIndexOf(`
2
- `,a-1);i.push(e+1),a=e}i.reverse();let o=r>n.length,s=[];for(let e=0;e<i.length;e++){let t=i[e],r=e<i.length-1?i[e+1]-1:n.length,a=n.slice(t,r);a&&s.push(a)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,Y.jsx)(O,{wrap:`truncate-end`,children:e},t))}),(0,Y.jsxs)(O,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Re(r)}`:``]})]})}var J,Y,Dt,Ot=t((()=>{J=n(A(),1),a(),j(),T(),I(),ke(),se(),Y=N(),Dt=8192}));function kt(e,t){return Object.values(e??{}).filter(m).filter(e=>!(e.type===`local_agent`&&e.id===t))}function At({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=ve(e=>e.tasks),i=ve(e=>e.foregroundedTaskId),a=l(),o=te(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),s=r,c=(0,Z.useRef)(!1),[u,d]=(0,Z.useState)(()=>{if(n)return c.current=!0,{mode:`detail`,itemId:n};let e=kt(s,i);return e.length===1?(c.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[f,p]=(0,Z.useState)(0);le(`background-tasks-dialog`);let{bashTasks:h,remoteSessions:g,agentTasks:_,workflowTasks:v,dreamTasks:ne,allSelectableItems:y}=(0,Z.useMemo)(()=>{let e=Object.values(s??{}).filter(m).map(jt).sort((e,t)=>{let n=e.status,r=t.status;if(n===`running`&&r!==`running`)return-1;if(n!==`running`&&r===`running`)return 1;let i=`task`in e?e.task.startTime:0;return(`task`in t?t.task.startTime:0)-i}),t=e.filter(e=>e.type===`local_bash`),n=e.filter(e=>e.type===`remote_agent`),r=e.filter(e=>e.type===`local_agent`&&e.id!==i),a=e.filter(e=>e.type===`local_workflow`),o=e.filter(e=>e.type===`dream`);return{bashTasks:t,remoteSessions:n,agentTasks:r,workflowTasks:a,dreamTasks:o,allSelectableItems:[...t,...n,...r,...a,...o]}},[s,i]),b=y[f]??null;Ce({"confirm:previous":()=>p(e=>Math.max(0,e-1)),"confirm:next":()=>p(e=>Math.min(y.length-1,e+1)),"confirm:yes":()=>{let e=y[f];e&&d({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:u.mode===`list`});let re=t=>{if(u.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=y[f];n&&t.key===`x`&&(t.preventDefault(),n.type===`local_bash`&&n.status===`running`?x(n.id):n.type===`local_agent`&&n.status===`running`?ae(n.id):n.type===`local_workflow`&&n.status===`running`&&$?$(n.id,a):n.type===`dream`&&n.status===`running`?oe(n.id):n.type===`remote_agent`&&n.status===`running`&&se(n.id))};async function x(e){await ie.kill(e,a)}async function ae(e){await ee.kill(e,a)}async function oe(e){await xe.kill(e,a)}async function se(e){await _e.kill(e,a)}let ce=(0,Z.useEffectEvent)(e);(0,Z.useEffect)(()=>{if(u.mode!==`list`){let e=(s??{})[u.itemId];(!e||e.type!==`local_workflow`&&!m(e))&&(c.current?ce(`Background tasks dialog dismissed`,{display:`system`}):d({mode:`list`}))}let e=y.length;f>=e&&e>0&&p(e-1)},[u,s,f,y,ce]);let S=()=>{c.current&&y.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(c.current=!1,d({mode:`list`}))};if(u.mode!==`list`&&s){let n=s[u.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,Q.jsx)(Tt,{shell:n,onDone:e,onKillShell:()=>void x(n.id),onBack:S},`shell-${n.id}`);case`local_agent`:return(0,Q.jsx)(et,{agent:n,onDone:e,onKillAgent:()=>void ae(n.id),onBack:S},`agent-${n.id}`);case`remote_agent`:return(0,Q.jsx)(bt,{session:n,onDone:e,toolUseContext:t,onBack:S,onKill:n.status===`running`?()=>void se(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`&&$?()=>$(n.id,a):void 0;return(0,Q.jsx)(D,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),S()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,Q.jsx)(M,{title:n.workflowName,subtitle:(0,Q.jsxs)(O,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:S,inputGuide:()=>(0,Q.jsxs)(k,{children:[(0,Q.jsx)(E,{shortcut:`←`,action:`go back`}),(0,Q.jsx)(E,{shortcut:`Esc`,action:`close`}),e&&(0,Q.jsx)(E,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,Q.jsxs)(O,{color:`error`,children:[`失败原因:`,n.error]}):null})},`workflow-${n.id}`)}case`dream`:return(0,Q.jsx)(ht,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:S,onKill:n.status===`running`?()=>void oe(n.id):void 0},`dream-${n.id}`)}}let C=P(h,e=>e.status===`running`),w=P(g,e=>e.status===`running`||e.status===`pending`)+P(_,e=>e.status===`running`),ue=Ne([...C>0?[(0,Q.jsxs)(O,{children:[C,` `,C===1?`active shell`:`active shells`]},`shells`)]:[],...w>0?[(0,Q.jsxs)(O,{children:[w,` `,w===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,Q.jsx)(O,{children:` · `},`separator-${e}`)),de=[(0,Q.jsx)(E,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,Q.jsx)(E,{shortcut:`Enter`,action:`view`},`enter`),...(b?.type===`local_bash`||b?.type===`local_agent`||b?.type===`local_workflow`||b?.type===`dream`||b?.type===`remote_agent`)&&b.status===`running`?[(0,Q.jsx)(E,{shortcut:`x`,action:`stop`},`kill`)]:[],..._.some(e=>e.status===`running`)?[(0,Q.jsx)(E,{shortcut:o,action:`stop all agents`},`kill-all`)]:[],(0,Q.jsx)(E,{shortcut:`←/Esc`,action:`close`},`esc`)],fe=()=>e(`Background tasks dialog dismissed`,{display:`system`});function T(e){return e.pending?(0,Q.jsxs)(O,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsx)(k,{children:de})}return(0,Q.jsx)(D,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:re,children:(0,Q.jsx)(M,{title:`Background tasks`,subtitle:(0,Q.jsx)(Q.Fragment,{children:ue}),onCancel:fe,color:`background`,inputGuide:T,children:y.length===0?(0,Q.jsx)(O,{dimColor:!0,children:`No tasks currently running`}):(0,Q.jsxs)(D,{flexDirection:`column`,children:[h.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,children:[(g.length>0||_.length>0)&&(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Shells`]}),` (`,h.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:h.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),g.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(h.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Remote agents`]}),` (`,g.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:g.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),_.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(h.length>0||g.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Local agents`]}),` (`,_.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:_.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),v.length>0&&(0,Q.jsxs)(D,{flexDirection:`column`,marginTop:+(h.length>0||g.length>0||_.length>0),children:[(0,Q.jsxs)(O,{dimColor:!0,children:[(0,Q.jsxs)(O,{bold:!0,children:[` `,`Workflows`]}),` (`,v.length,`)`]}),(0,Q.jsx)(D,{flexDirection:`column`,children:v.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),ne.length>0&&(0,Q.jsx)(D,{flexDirection:`column`,marginTop:+(h.length>0||g.length>0||_.length>0||v.length>0),children:(0,Q.jsx)(D,{flexDirection:`column`,children:ne.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})})]})})})}function jt(e){switch(e.type){case`local_bash`:return{id:e.id,type:`local_bash`,label:e.command,status:e.status,task:e};case`remote_agent`:return{id:e.id,type:`remote_agent`,label:e.title,status:e.status,task:e};case`local_agent`:return{id:e.id,type:`local_agent`,label:e.description,status:e.status,task:e};case`local_workflow`:return{id:e.id,type:`local_workflow`,label:e.summary??e.description,status:e.status,task:e};case`dream`:return{id:e.id,type:`dream`,label:e.description,status:e.status,task:e}}}function X({item:e,isSelected:t}){let{columns:n}=De(),r=Math.max(30,n-26);return(0,Q.jsxs)(D,{flexDirection:`row`,children:[(0,Q.jsx)(O,{children:t?i.pointer+` `:` `}),(0,Q.jsx)(O,{color:t?`suggestion`:void 0,children:(0,Q.jsx)(pt,{task:e.task,maxActivityWidth:r})})]})}var Z,Q,$,Mt=t((()=>{r(),Z=n(A(),1),a(),s(),y(),d(),pe(),S(),u(),Me(),ue(),j(),T(),f(),nt(),mt(),gt(),Ct(),Ot(),Q=N(),$=(de(),e(ne))?.killWorkflowTask??null}));export{z as a,Qe as i,Mt as n,R as o,$e as r,At as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./ClaudeMdExternalIncludesDialog-BqNxQOXJ.js";e();export{t as ClaudeMdExternalIncludesDialog};
@@ -1 +0,0 @@
1
- import{dd as e,ud as t}from"./loadAgentsDir-C7lOqvfh.js";e();export{t as ConsoleOAuthFlow};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./Doctor-jEs9chPk.js";e();export{t as Doctor};
@@ -1,3 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-BDhHQY0-.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$l as o,BT as s,Cg as c,Dw as l,Ew as u,LT as d,Ow as f,Ql as ee,Sb as p,Tw as te,bT as ne,eu as m,gE as h,gv as g,hE as _,hv as v,kw as re,mE as y,na as b,pE as x,qC as S,ta as C,vb as w,wb as ie,wg as T,xT as ae,xb as E}from"./loadAgentsDir-C7lOqvfh.js";import{Gt as oe,I as D,P as O,fi as k,t as A,x as j}from"./src-P_wYS_NJ2.js";import{t as M}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as se,et as ce}from"./state-BemZdQIl.js";import{Cn as le,H as N,On as P,g as F,n as I,z as L}from"./settings-DnptdP79.js";import{l as R,o as z}from"./stringUtils-C84IJ91d.js";import{Kn as B,Un as V,_ as H,u as U}from"./model-BsZ4sP_H.js";import{n as W,t as ue}from"./ValidationErrorsList-D_OUa4RT.js";import{d as de,f as fe,h as pe,i as me,m as he,n as ge,o as _e,r as ve,u as G}from"./pidLock-nJHbufJN.js";import{a as ye,i as be}from"./xdg-DcF9ejUM.js";import{n as xe,t as Se}from"./useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js";import{n as Ce,t as we}from"./McpParsingWarnings-BCpfHaBK.js";import{n as Te,t as Ee}from"./PressEnterToContinue-Dq0Imo9c.js";import{n as De,t as Oe}from"./useSettingsErrors-DAEO7AyB.js";import{n as ke,t as Ae}from"./shadowedRuleDetection-DEaw-X5j.js";import{n as je,r as Me,t as K}from"./statusNoticeHelpers-Bb9gxdSt.js";import{join as q}from"path";function Ne(){if(!h())return null;let e=x();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)(D,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(O,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(D,{children:[(0,J.jsx)(O,{dimColor:!0,children:`Location: `}),(0,J.jsx)(O,{dimColor:!0,children:y()})]}),(0,J.jsxs)(D,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(D,{flexDirection:`column`,children:[(0,J.jsxs)(D,{children:[(0,J.jsx)(O,{dimColor:!0,children:`└ `}),(0,J.jsx)(O,{color:`error`,children:`[Error]`}),(0,J.jsxs)(O,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(D,{marginLeft:3,children:(0,J.jsxs)(O,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(D,{flexDirection:`column`,children:[(0,J.jsxs)(D,{children:[(0,J.jsx)(O,{dimColor:!0,children:`└ `}),(0,J.jsx)(O,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(O,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(D,{marginLeft:3,children:(0,J.jsxs)(O,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,Pe=e((()=>{k(),A(),_(),J=M()}));function Fe(){if(!d.isSupportedPlatform()||!d.isSandboxEnabledInSettings())return null;let e=d.checkDependencies(),t=e.errors.length>0,n=e.warnings.length>0;return!t&&!n?null:(0,Y.jsxs)(D,{flexDirection:`column`,children:[(0,Y.jsx)(O,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(O,{children:[`└ Status: `,(0,Y.jsx)(O,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(O,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(O,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(O,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,Ie=e((()=>{k(),A(),s(),Y=M()}));async function Le(){let e=E(await p());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:`claudemd_files`,severity:`warning`,message:e.length===1?`Large CLAUDE.md file detected (${e[0].content.length.toLocaleString()} chars > ${w.toLocaleString()})`:`${e.length} large CLAUDE.md files detected (each > ${w.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:w}}async function X(e){if(!e)return null;let t=je(e);if(t<=15e3)return null;let n=e.activeAgents.filter(e=>e.source!==`built-in`).map(e=>{let t=`${e.agentType}: ${e.whenToUse}`;return{name:e.agentType,tokens:b(t)}}).sort((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>`${e.name}: ~${e.tokens.toLocaleString()} tokens`);return n.length>5&&r.push(`(${n.length-5} more custom agents)`),{type:`agent_descriptions`,severity:`warning`,message:`Large agent descriptions (~${t.toLocaleString()} tokens > ${K.toLocaleString()})`,details:r,currentValue:t,threshold:K}}async function Re(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await v(e,t,n,U());if(r<=Z)return null;let a=new Map;for(let e of i){let t=e.name.split(`__`)[1]||`unknown`,n=a.get(t)||{count:0,tokens:0};a.set(t,{count:n.count+1,tokens:n.tokens+e.tokens})}let o=Array.from(a.entries()).sort((e,t)=>t[1].tokens-e[1].tokens),s=o.slice(0,5).map(([e,t])=>`${e}: ${t.count} tools (~${t.tokens.toLocaleString()} tokens)`);return o.length>5&&s.push(`(${o.length-5} more servers)`),{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${r.toLocaleString()} tokens > ${Z.toLocaleString()})`,details:s,currentValue:r,threshold:Z}}catch{let e=r.reduce((e,t)=>e+b(((t.name?.length||0)+t.description.length).toString()),0);return e<=Z?null:{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${e.toLocaleString()} tokens estimated > ${Z.toLocaleString()})`,details:[`${r.length} MCP tools detected (token count estimated)`],currentValue:e,threshold:Z}}}async function ze(e){let t=Ae(await e(),{sandboxAutoAllowEnabled:d.isSandboxingEnabled()&&d.isAutoAllowBashIfSandboxedEnabled()});if(t.length===0)return null;let n=t.flatMap(e=>[`${N(e.rule.ruleValue)}: ${e.reason}`,` Fix: ${e.fix}`]);return{type:`unreachable_rules`,severity:`warning`,message:`${t.length} ${R(t.length,`unreachable permission rule`)} detected`,details:n,currentValue:t.length,threshold:0}}async function Be(e,t,n){let[r,i,a,o]=await Promise.all([Le(),X(t),Re(e,n,t),ze(n)]);return{claudeMdWarning:r,agentWarning:i,mcpWarning:a,unreachableRulesWarning:o}}var Z,Ve=e((()=>{C(),g(),ie(),H(),L(),ke(),s(),Me(),z(),Z=25e3}));function He({promise:e}){let t=(0,Q.use)(e);return t.latest?(0,$.jsxs)($.Fragment,{children:[t.stable&&(0,$.jsxs)(O,{children:[`└ Stable version: `,t.stable]}),(0,$.jsxs)(O,{children:[`└ Latest version: `,t.latest]})]}):(0,$.jsx)(O,{dimColor:!0,children:`└ Failed to fetch versions`})}function Ue({onDone:e}){let t=T(e=>e.agentDefinitions),r=T(e=>e.mcp.tools),i=T(e=>e.toolPermissionContext),s=T(e=>e.plugins.errors);xe();let c=(0,Q.useMemo)(()=>r||[],[r]),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=De(),y=(0,Q.useMemo)(()=>G().then(e=>(e.installationType===`native`?fe:he)().catch(()=>({latest:null,stable:null}))),[]),b=I()?.autoUpdatesChannel??`latest`,x=v.filter(e=>e.mcpErrorMetadata===void 0),S=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:te,upperLimit:u},{name:`TASK_MAX_OUTPUT_LENGTH`,default:ee,upperLimit:o},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...V(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=re(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{G().then(d),(async()=>{let e=q(n(),`agents`),r=q(ce(),`.claude`,`agents`),{activeAgents:a,allAgents:o,failedFiles:s}=t,[l,u]=await Promise.all([P(e),P(r)]),d={activeAgents:a.map(e=>({agentType:e.agentType,source:e.source})),userAgentsDir:e,projectAgentsDir:r,userDirExists:l,projectDirExists:u,failedFiles:s};p(d);let f=await Be(c,{activeAgents:a,allAgents:o,failedFiles:s},async()=>i);if(h(f),_e()){let e=q(be(),`claude`,`locks`),t=ge(e),n=ve(e);_({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else _({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,c,t]);let C=(0,Q.useCallback)(()=>{e(`Claude Code diagnostics dismissed`,{display:`system`})},[e]);return oe({"confirm:yes":C,"confirm:no":C},{context:`Confirmation`}),l?(0,$.jsxs)(j,{children:[(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(O,{children:[`└ Currently running: `,l.installationType,` (`,l.version,`)`]}),l.packageManager&&(0,$.jsxs)(O,{children:[`└ Package manager: `,l.packageManager]}),(0,$.jsxs)(O,{children:[`└ Path: `,l.installationPath]}),(0,$.jsxs)(O,{children:[`└ Invoked: `,l.invokedBinary]}),(0,$.jsxs)(O,{children:[`└ Config install method: `,l.configInstallMethod]}),(0,$.jsxs)(O,{children:[`└ Search: `,l.ripgrepStatus.working?`OK`:`Not working`,` (`,l.ripgrepStatus.mode===`embedded`?`bundled`:l.ripgrepStatus.mode===`builtin`?`vendor`:l.ripgrepStatus.systemPath||`system`,`)`]}),l.ripgrepStatus.note&&(0,$.jsxs)(O,{color:`warning`,children:[`└ Note: `,l.ripgrepStatus.note]}),l.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{}),(0,$.jsxs)(O,{color:`warning`,children:[`Recommendation: `,l.recommendation.split(`
2
- `)[0]]}),(0,$.jsx)(O,{dimColor:!0,children:l.recommendation.split(`
3
- `)[1]})]}),l.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{}),(0,$.jsx)(O,{color:`warning`,children:`Warning: Multiple installations found`}),l.multipleInstallations.map((e,t)=>(0,$.jsxs)(O,{children:[`└ `,e.type,` at `,e.path]},t))]}),l.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{}),l.warnings.map((e,t)=>(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsxs)(O,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(O,{children:[`Fix: `,e.fix]})]},t))]}),x.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(O,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(ue,{errors:x})]})]}),(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,children:`Updates`}),(0,$.jsxs)(O,{children:[`└ Auto-updates: `,l.packageManager?`Managed by package manager`:l.autoUpdates]}),l.hasUpdatePermissions!==null&&(0,$.jsxs)(O,{children:[`└ Update permissions: `,l.hasUpdatePermissions?`Yes`:`No (requires sudo)`]}),(0,$.jsxs)(O,{children:[`└ Auto-update channel: `,b]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(He,{promise:y})})]}),(0,$.jsx)(Fe,{}),(0,$.jsx)(we,{}),(0,$.jsx)(Ne,{}),S.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,children:`Environment Variables`}),S.map((e,t)=>(0,$.jsxs)(O,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(O,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),g?.enabled&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,children:`Version Locks`}),g.staleLocksCleaned>0&&(0,$.jsxs)(O,{dimColor:!0,children:[`└ Cleaned `,g.staleLocksCleaned,` stale lock(s)`]}),g.locks.length===0?(0,$.jsx)(O,{dimColor:!0,children:`└ No active version locks`}):g.locks.map((e,t)=>(0,$.jsxs)(O,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(O,{children:`(running)`}):(0,$.jsx)(O,{color:`warning`,children:`(stale)`})]},t))]}),f?.failedFiles&&f.failedFiles.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(O,{color:`error`,children:[`└ Failed to parse `,f.failedFiles.length,` agent file(s):`]}),f.failedFiles.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),s.length>0&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(O,{color:`error`,children:[`└ `,s.length,` plugin error(s) detected:`]}),s.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,ne(e)]},t))]}),m?.unreachableRulesWarning&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(O,{children:[`└`,` `,(0,$.jsxs)(O,{color:`warning`,children:[a.warning,` `,m.unreachableRulesWarning.message]})]}),m.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m&&(m.claudeMdWarning||m.agentWarning||m.mcpWarning)&&(0,$.jsxs)(D,{flexDirection:`column`,children:[(0,$.jsx)(O,{bold:!0,children:`Context Usage Warnings`}),m.claudeMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{children:[`└`,` `,(0,$.jsxs)(O,{color:`warning`,children:[a.warning,` `,m.claudeMdWarning.message]})]}),(0,$.jsxs)(O,{children:[` `,`└ Files:`]}),m.claudeMdWarning.details.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{children:[`└`,` `,(0,$.jsxs)(O,{color:`warning`,children:[a.warning,` `,m.agentWarning.message]})]}),(0,$.jsxs)(O,{children:[` `,`└ Top contributors:`]}),m.agentWarning.details.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e]},t))]}),m.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{children:[`└`,` `,(0,$.jsxs)(O,{color:`warning`,children:[a.warning,` `,m.mcpWarning.message]})]}),(0,$.jsxs)(O,{children:[` `,`└ MCP servers:`]}),m.mcpWarning.details.map((e,t)=>(0,$.jsxs)(O,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(D,{children:(0,$.jsx)(Ee,{})})]}):(0,$.jsx)(j,{children:(0,$.jsx)(O,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,We=e((()=>{i(),Q=t(k(),1),Pe(),Ce(),B(),r(),se(),A(),Te(),Ie(),W(),Oe(),Se(),S(),c(),ae(),pe(),Ve(),de(),f(),le(),me(),F(),l(),m(),ye(),$=M()}));export{We as n,Ue as t};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{Cr as r,Dt as i,Iu as a,NE as o,Ot as s,PE as c,QT as l,Ru as u,St as d,Tt as f,ZT as p,_i as m,fw as h,ht as g,nd as _,pw as v,rd as y,rf as b,tf as x}from"./loadAgentsDir-C7lOqvfh.js";import{I as S,P as C,fi as w,t as T,y as E}from"./src-P_wYS_NJ2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{a as O,l as k}from"./debug-RAynG_nM.js";import{r as A,t as j}from"./execFileNoThrow-Dwu6psHW.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(r(),e(m)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,r]=(0,I.useState)(`loading`),[c,l]=(0,I.useState)([]),[u,f]=(0,I.useState)(0),[p,m]=(0,I.useState)(),h=d();if((0,I.useEffect)(()=>{async function e(){let e=[],t=await j(`git`,[`status`,`--porcelain`]);if(t.stdout&&(e=t.stdout.split(`
2
- `).filter(e=>e.trim()!==``),l(e)),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),v(h.originalCwd),P(),o.cache.clear?.(),m(`Worktree removed (no changes)`)}).catch(e=>{k(`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 y(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:c.length}),await i(),process.chdir(h.originalCwd),v(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:c.length}),h.tmuxSessionName&&await s(h.tmuxSessionName),await i(),process.chdir(h.originalCwd),v(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:c.length}),h.tmuxSessionName&&await s(h.tmuxSessionName);try{await g(),process.chdir(h.originalCwd),v(h.originalCwd),P(),o.cache.clear?.()}catch(e){k(`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&&c.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}`):c.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)(a,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(a,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let b=h.worktreeBranch,x=c.length>0,w=u>0,T=``;T=x&&w?`You have ${c.length} uncommitted ${c.length===1?`file`:`files`} and ${u} ${u===1?`commit`:`commits`} on ${b}. All will be lost if you remove.`:x?`You have ${c.length} uncommitted ${c.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${u} ${u===1?`commit`:`commits`} on ${b}. 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}y(`keep`)}let O=x||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:O}]:[{label:`Keep worktree`,value:`keep`,description:`Stays at ${h.worktreePath}`},{label:`Remove worktree`,value:`remove`,description:O}];return(0,L.jsx)(E,{title:`Exiting worktree session`,subtitle:T,onCancel:D,children:(0,L.jsx)(_,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:y})})}var I,L,R=t((()=>{I=n(w(),1),M(),O(),T(),A(),c(),h(),f(),y(),u(),L=D()}));function z(){return l(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await x(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{p(),w(),b(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{Cg as e,Mu as t,Nu as n,Sg as r,nd as i,td as a}from"./loadAgentsDir-C7lOqvfh.js";import{I as o,P as s,fi as c,kn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{E as p,S as m,w as h}from"./debug-RAynG_nM.js";import{t as g}from"./renderOptions-Q5oCLFIC.js";c(),u(),n(),e(),m(),a();var _=f();function v({filePath:e,errorDescription:t,onExit:n,onReset:r}){return(0,_.jsxs)(d,{title:`Configuration Error`,color:`error`,onCancel:n,children:[(0,_.jsxs)(o,{flexDirection:`column`,gap:1,children:[(0,_.jsxs)(s,{children:[`The configuration file at `,(0,_.jsx)(s,{bold:!0,children:e}),` contains invalid JSON.`]}),(0,_.jsx)(s,{children:t})]}),(0,_.jsxs)(o,{flexDirection:`column`,children:[(0,_.jsx)(s,{bold:!0,children:`Choose an option:`}),(0,_.jsx)(i,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Reset with default configuration`,value:`reset`}],onChange:e=>{e===`exit`?n():r()},onCancel:n})]})]})}var y=`dark`;async function b({error:e}){let n={...g(!1),theme:y};await new Promise(async i=>{let{unmount:a}=await l((0,_.jsx)(r,{children:(0,_.jsx)(t,{children:(0,_.jsx)(v,{filePath:e.filePath,errorDescription:e.message,onExit:()=>{a(),i(),process.exit(1)},onReset:()=>{p(e.filePath,h(e.defaultConfig,null,2),{flush:!1,encoding:`utf8`}),a(),i(),process.exit(0)}})})}),n)})}export{b as showInvalidConfigDialog};
@@ -1 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{$T as r,$d as i,CC as a,CS as o,Cg as s,Eg as c,Hx as l,Jx as u,Tg as d,ax as f,bC as p,bS as m,cS as ee,cx as h,dx as g,eE as _,ef as te,hS as v,ix as y,lx as ne,mS as b,mx as x,nx as S,oS as C,ox as w,px as T,sS as re,tS as E,uS as D,wC as O,wg as k,xS as A,yC as ie,yS as j}from"./loadAgentsDir-C7lOqvfh.js";import{fi as M}from"./src-P_wYS_NJ2.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as ae,pt as oe}from"./state-BemZdQIl.js";import{F as P,a as se,l as ce,z as le}from"./debug-RAynG_nM.js";import{it as ue,nt as F}from"./settings-DnptdP79.js";import{c as I,l as L,o as R}from"./log-CezCRpAN.js";import{n as z,r as B}from"./analytics-DJobLaWP.js";import{n as V,t as H}from"./omit-DDUIPHnl.js";import{o as de,s as fe}from"./localSearch-BKrznW5x.js";function U(e){let t=`plugin`in e?e.plugin:`no-plugin`;return`${e.type}:${e.source}:${t}`}function W(e,t){t.length!==0&&e(e=>{let n=new Set(e.plugins.errors.map(e=>U(e))),r=t.filter(e=>!n.has(U(e)));return r.length===0?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,...r]}}})}function pe(e,t=!1){let n=d(),r=k(e=>e.authVersion),i=k(e=>e.mcp.pluginReconnectKey),o=c(),s=(0,G.useRef)(new Map),{addNotification:ne}=te(),b=(0,G.useRef)([]),T=(0,G.useRef)(null),E=(0,G.useCallback)(()=>{T.current=null;let e=b.current;e.length!==0&&(b.current=[],o(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,u=F(a.name),d=n.clients.findIndex(e=>e.name===a.name)===-1?[...n.clients,a]:n.clients.map(e=>e.name===a.name?a:e),f=o===void 0?n.tools:[..._(n.tools,e=>e.name?.startsWith(u)),...o],p=s===void 0?n.commands:[..._(n.commands,e=>l(e,a.name)),...s],m=c===void 0?n.resources:{...n.resources,...c.length>0?{[a.name]:c}:V(n.resources,a.name)};n={...n,clients:d,tools:f,commands:p,resources:m}}return{...t,mcp:n}}))},[o]),O=(0,G.useCallback)(e=>{b.current.push(e),T.current===null&&(T.current=setTimeout(E,16))},[E]),M=(0,G.useCallback)(({client:e,tools:t,commands:n,resources:r})=>{switch(O({...e,tools:t,commands:n,resources:r}),e.type){case`connected`:x(e.client,e.name,o),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(S(e.name,e.config).catch(()=>{ce(`Failed to invalidate the server cache: ${e.name}`)}),v(e.name)){I(e.name,`Server is disabled, skipping automatic reconnection`);return}if(t!==`stdio`&&t!==`sdk`){let n=me(t);I(e.name,`${n} transport closed/disconnected, attempting automatic reconnection`);let r=s.current.get(e.name);r&&(clearTimeout(r),s.current.delete(e.name)),(async()=>{for(let t=1;t<=q;t++){if(v(e.name)){I(e.name,`Server disabled during reconnection, stopping retry`),s.current.delete(e.name);return}O({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:q});let r=Date.now();try{let i=await g(e.name,e.config),a=Date.now()-r;if(i.client.type===`connected`){I(e.name,`${n} reconnection successful after ${a}ms (attempt ${t})`),s.current.delete(e.name),M(i);return}if(I(e.name,`${n} reconnection attempt ${t} completed with status: ${i.client.type}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),s.current.delete(e.name),M(i);return}}catch(i){let a=Date.now()-r;if(L(e.name,`${n} reconnection attempt ${t} failed after ${a}ms: ${i}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),s.current.delete(e.name),O({...e,type:`failed`});return}}let i=Math.min(J*2**(t-1),Y);I(e.name,`Scheduling reconnection attempt ${t+1} in ${i}ms`),await new Promise(t=>{let n=setTimeout(t,i);s.current.set(e.name,n)})}})()}else O({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(a,async()=>{I(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=w.cache.get(e.name);w.cache.delete(e.name);let n=await w(e),r=n.length;t?t.then(e=>{B(`tengu_mcp_list_changed`,{type:`tools`,previousCount:e.length,newCount:r})},()=>{B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r})}):B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r}),O({...e,tools:n})}catch(t){L(e.name,`Failed to refresh tools after list_changed notification: ${P(t)}`)}}),e.capabilities?.prompts?.listChanged&&e.client.setNotificationHandler(ie,async()=>{I(e.name,`Received prompts/list_changed notification, refreshing prompts`),B(`tengu_mcp_list_changed`,{type:`prompts`});try{y.cache.delete(e.name);let[t,n]=await Promise.all([y(e),Promise.resolve([])]);O({...e,commands:[...t,...n]}),K?.()}catch(t){L(e.name,`Failed to refresh prompts after list_changed notification: ${P(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(p,async()=>{I(e.name,`Received resources/list_changed notification, refreshing resources`),B(`tengu_mcp_list_changed`,{type:`resources`});try{f.cache.delete(e.name);{let t=await f(e);O({...e,resources:t})}}catch(t){L(e.name,`Failed to refresh resources after list_changed notification: ${P(t)}`)}});break;case`needs-auth`:case`failed`:case`pending`:case`disabled`:break}},[O]),N=oe();return(0,G.useEffect)(()=>{async function n(){let{servers:n,errors:r}=t?{servers:{},errors:[]}:await D(e),i={...n,...e};W(o,r),o(e=>{let{stale:t,...n}=u(e.mcp,i);for(let e of t){let t=s.current.get(e.name);t&&(clearTimeout(t),s.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,S(e.name,e.config).catch(()=>{}))}let r=new Set(n.clients.map(e=>e.name)),a=Object.entries(i).filter(([e])=>!r.has(e)).map(([e,t])=>({name:e,type:v(e)?`disabled`:`pending`,config:t}));return a.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...a]}}})}n().catch(e=>{L(`useManageMCPConnections`,`Failed to initialize servers as pending: ${P(e)}`)})},[t,e,o,N,i]),(0,G.useEffect)(()=>{let n=!1;async function r(){let r;t||re()?r=Promise.resolve({}):(m(),r=A());let{servers:i,errors:a}=t?{servers:{},errors:[]}:await D(e,r);if(n)return;W(o,a);let s={...i,...e},c=Object.fromEntries(Object.entries(s).filter(([e])=>!v(e)));h(M,c).catch(e=>{L(`useManageMcpConnections`,`Failed to get MCP resources: ${P(e)}`)});let l={};if(!t){if(l=ee(await r).allowed,n)return;if(Object.keys(l).length>0){let{servers:e}=C(l,s);l=e}if(Object.keys(l).length>0){o(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(l).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:v(e)?`disabled`:`pending`,config:t}));return n.length===0?e:{...e,mcp:{...e.mcp,clients:[...e.mcp.clients,...n]}}});let e=Object.fromEntries(Object.entries(l).filter(([e])=>!v(e)));h(M,e).catch(e=>{L(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${P(e)}`)})}}let u={...s,...l},d={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(u))t.scope===`enterprise`?d.enterprise++:t.scope===`user`?d.global++:t.scope===`project`?d.project++:t.scope===`local`?d.user++:t.scope===`dynamic`?d.plugin++:t.scope===`claudeai`&&d.claudeai++;B(`tengu_mcp_servers`,{...d})}return r(),()=>{n=!0}},[t,e,M,o,r,N,i]),(0,G.useEffect)(()=>{let e=s.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),T.current!==null&&(clearTimeout(T.current),T.current=null,E())}},[E]),{reconnectMcpServer:(0,G.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);let r=s.current.get(e);r&&(clearTimeout(r),s.current.delete(e));let i=await g(e,t.config);return M(i),i},[n,M]),toggleMcpServer:(0,G.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);if(t.type!==`disabled`){let n=s.current.get(e);n&&(clearTimeout(n),s.current.delete(e)),j(e,!1),t.type===`connected`&&await S(e,t.config),O({name:e,type:`disabled`,config:t.config})}else{j(e,!0),O({name:e,type:`pending`,config:t.config});let n=await g(e,t.config);M(n)}},[n,O,M])}}function me(e){switch(e){case`http`:return`HTTP`;case`ws`:case`ws-ide`:return`WebSocket`;default:return`SSE`}}var G,K,q,J,Y,he=t((()=>{G=n(M(),1),ae(),ne(),O(),H(),r(),z(),b(),se(),i(),s(),le(),R(),T(),o(),ue(),E(),K=(de(),e(fe)).clearSkillIndexCache,q=5,J=1e3,Y=3e4}));function ge(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpReconnect must be used within MCPConnectionManager`);return e.reconnectMcpServer}function X(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpToggleEnabled must be used within MCPConnectionManager`);return e.toggleMcpServer}function _e({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=pe(t,n),a=(0,Z.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,Q.jsx)($.Provider,{value:a,children:e})}var Z,Q,$,ve=t((()=>{Z=n(M(),1),he(),Q=N(),$=(0,Z.createContext)(null)}));export{X as i,ve as n,ge as r,_e as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{$C as i,Cg as a,Dx as o,Eg as s,Ex as c,Ip as l,Iu as u,Kx as d,LS as f,Lp as p,Qx as ee,RS as m,Ru as h,Ux as te,Yx as ne,Zx as re,dS as g,fd as ie,kx as _,lx as ae,mS as oe,nd as se,nx as ce,pd as le,qC as v,qx as ue,tS as y,td as b,wg as de,xx as fe}from"./loadAgentsDir-C7lOqvfh.js";import{D as x,H as pe,I as S,Lt as me,P as C,T as w,Wt as T,dr as he,fi as E,hn as ge,j as D,ot as _e,t as O,y as k}from"./src-P_wYS_NJ2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{F as ve,z as j}from"./debug-RAynG_nM.js";import{et as M,it as N,tt as P}from"./settings-DnptdP79.js";import{c as ye,o as F}from"./log-CezCRpAN.js";import{n as I,r as L}from"./analytics-DJobLaWP.js";import{l as be,u as R}from"./oauth-C9VBDB0Y.js";import{l as xe,n as Se,o as z}from"./stringUtils-C84IJ91d.js";import{Bt as B,jt as Ce}from"./model-BsZ4sP_H.js";import{i as we,n as V,r as Te}from"./MCPConnectionManager-CUTuaa8T.js";import{n as Ee,t as H}from"./useExitOnCtrlCDWithKeybindings-ChqBs9Lr.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)(S,{children:[(0,U.jsx)(C,{bold:!0,children:`Capabilities: `}),(0,U.jsx)(C,{color:`text`,children:r.length>0?(0,U.jsx)(w,{children:r}):`none`})]})}var U,Oe=e((()=>{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:i,onComplete:a,borderless:c=!1}){let[f]=pe(),p=Ee(),{columns:ee}=_e(),[h,g]=G.useState(!1),[ae,oe]=G.useState(null),le=de(e=>e.mcp),v=s(),[y,b]=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?a?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?a?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):a?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`)}catch(t){L(`tengu_claudeai_mcp_auth_completed`,{success:!1}),a?.(Ae(t,e.name))}finally{O(!1)}},[Y,e.name,a]),X=G.useCallback(async()=>{await ce(e.name,{...e.config,scope:e.scope}),v(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`needs-auth`}:t),r=ne(t.mcp.tools,e.name),i=d(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`,{}),a?.(`Disconnected from ${e.name}.`),F(!1),R(null),z(!1)},[e.name,e.config,e.scope,v,a]);T(`confirm:no`,()=>{k.current?.abort(),k.current=null,g(!1),b(null)},{context:`Confirmation`,isActive:h}),T(`confirm:no`,()=>{j(!1),N(null)},{context:`Confirmation`,isActive:A}),T(`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),m(e)}if(e===`c`&&!B){let e=y||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=re(le.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 m(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`}),i()}catch(n){a?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.config.type,e.name,Ie,i,a]),ze=G.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;g(!0),oe(null);let t=new AbortController;k.current=t;try{if(e.isAuthenticated&&e.config&&await _(e.name,e.config,{preserveStepUpState:!0}),e.config){await o(e.name,e.config,b,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}.`;a?.(t)}else n.client.type===`needs-auth`?a?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):(ye(e.name,`Reconnection failed after authentication`),a?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`))}}catch(e){e instanceof Error&&!(e instanceof fe)&&oe(e.message)}finally{g(!1),k.current=null,q(null),W(``)}},[e.isAuthenticated,e.config,e.name,a,Y,J]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await _(e.name,e.config),L(`tengu_mcp_auth_config_clear`,{}),await ce(e.name,{...e.config,scope:e.scope}),v(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`failed`}:t),r=ne(t.mcp.tools,e.name),i=d(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}}}),a?.(`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)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(C,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(S,{children:[(0,K.jsx)(u,{}),(0,K.jsx)(C,{children:t})]}),y&&(0,K.jsxs)(S,{flexDirection:`column`,children:[(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(C,{dimColor:!0,children:(0,K.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(me,{url:y})]}),h&&y&&Ne&&(0,K.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,K.jsx)(C,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,K.jsxs)(S,{children:[(0,K.jsxs)(C,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,K.jsx)(ie,{value:Oe,onChange:W,onSubmit:e=>{Ne(e.trim()),W(``)},cursorOffset:je,onChangeCursorOffset:Me,columns:ee-8})]})]}),(0,K.jsx)(S,{marginLeft:3,children:(0,K.jsx)(C,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(A)return(0,K.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(C,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(S,{children:[(0,K.jsx)(u,{}),(0,K.jsx)(C,{children:` A browser window will open for authentication`})]}),M&&(0,K.jsxs)(S,{flexDirection:`column`,children:[(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(C,{dimColor:!0,children:(0,K.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(me,{url:M})]}),(0,K.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(C,{color:`permission`,children:[`Press `,(0,K.jsx)(C,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,K.jsx)(C,{dimColor:!0,italic:!0,children:(0,K.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(P)return(0,K.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(C,{color:`claude`,children:[`Clear authentication for `,e.name]}),xe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(C,{children:`Find the MCP server in the browser and click "Disconnect".`}),I&&(0,K.jsxs)(S,{flexDirection:`column`,children:[(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),B?(0,K.jsx)(C,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(C,{dimColor:!0,children:(0,K.jsx)(x,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(me,{url:I})]}),(0,K.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(C,{color:`permission`,children:[`Press `,(0,K.jsx)(C,{bold:!0,children:`Enter`}),` when done.`]}),(0,K.jsx)(C,{dimColor:!0,italic:!0,children:(0,K.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(C,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,K.jsxs)(S,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(C,{color:`permission`,children:[`Press `,(0,K.jsx)(C,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,K.jsx)(C,{dimColor:!0,italic:!0,children:(0,K.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(E)return(0,K.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(C,{color:`text`,children:[`Connecting to `,(0,K.jsx)(C,{bold:!0,children:e.name}),`…`]}),(0,K.jsxs)(S,{children:[(0,K.jsx)(u,{}),(0,K.jsx)(C,{children:` Establishing connection to MCP server`})]}),(0,K.jsx)(C,{dimColor:!0,children:`This may take a few moments.`})]});let $=[];return e.client.type===`disabled`&&$.push({label:`Enable`,value:`toggle-enabled`}),e.client.type===`connected`&&t>0&&$.push({label:`View tools`,value:`tools`}),e.config.type===`claudeai-proxy`?e.client.type===`connected`?$.push({label:`Clear authentication`,value:`claudeai-clear-auth`}):e.client.type!==`disabled`&&$.push({label:`Authenticate`,value:`claudeai-auth`}):(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)(S,{flexDirection:`column`,children:[(0,K.jsxs)(S,{flexDirection:`column`,paddingX:1,borderStyle:c?void 0:`round`,children:[(0,K.jsx)(S,{marginBottom:1,children:(0,K.jsxs)(C,{bold:!0,children:[Z,` MCP Server`]})}),(0,K.jsxs)(S,{flexDirection:`column`,gap:0,children:[(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,K.jsxs)(C,{children:[D(`inactive`,f)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,K.jsxs)(C,{children:[D(`success`,f)(r.tick),` connected`]}):e.client.type===`pending`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(C,{dimColor:!0,children:r.radioOff}),(0,K.jsx)(C,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,K.jsxs)(C,{children:[D(`warning`,f)(r.triangleUpOutline),` needs authentication`]}):(0,K.jsxs)(C,{children:[D(`error`,f)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{bold:!0,children:`Auth: `}),J?(0,K.jsxs)(C,{children:[D(`success`,f)(r.tick),` authenticated`]}):(0,K.jsxs)(C,{children:[D(`error`,f)(r.cross),` not authenticated`]})]}),(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{bold:!0,children:`URL: `}),(0,K.jsx)(C,{dimColor:!0,children:e.config.url})]}),(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{bold:!0,children:`Config location: `}),(0,K.jsx)(C,{dimColor:!0,children:te(e.scope)})]}),e.client.type===`connected`&&(0,K.jsx)(De,{serverToolsCount:t,serverPromptsCount:Fe,serverResourcesCount:le.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,K.jsxs)(S,{children:[(0,K.jsx)(C,{bold:!0,children:`Tools: `}),(0,K.jsxs)(C,{dimColor:!0,children:[t,` tools`]})]})]}),ae&&(0,K.jsx)(S,{marginTop:1,children:(0,K.jsxs)(C,{color:`error`,children:[`Error: `,ae]})}),$.length>0&&(0,K.jsx)(S,{marginTop:1,children:(0,K.jsx)(se,{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);a?.(n)}catch(t){e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:!1}),a?.(Ae(t,e.name))}finally{O(!1)}break;case`toggle-enabled`:await Re();break;case`back`:i();break}},onCancel:i})})]}),(0,K.jsx)(S,{marginTop:1,children:(0,K.jsx)(C,{dimColor:!0,italic:!0,children:p.pending?(0,K.jsxs)(K.Fragment,{children:[`Press `,p.keyName,` again to exit`]}):(0,K.jsxs)(w,{children:[(0,K.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,K.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,K.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var G,K,Me=e((()=>{n(),G=t(E(),1),I(),R(),H(),i(),O(),v(),c(),ae(),V(),y(),a(),B(),f(),j(),F(),z(),p(),b(),h(),le(),Oe(),W(),K=A()}));function Ne({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:a,borderless:o=!1}){let[s]=pe(),c=Ee(),d=de(e=>e.mcp),f=Te(),p=we(),[ee,m]=(0,q.useState)(!1),h=q.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await p(e.name),i()}catch(n){a(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.name,p,i,a]),ne=Se(String(e.name)),ie=re(d.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`}),ee?(0,J.jsxs)(S,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(C,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(C,{bold:!0,children:e.name})]}),(0,J.jsxs)(S,{children:[(0,J.jsx)(u,{}),(0,J.jsx)(C,{children:` Restarting MCP server process`})]}),(0,J.jsx)(C,{dimColor:!0,children:`This may take a few moments.`})]}):(0,J.jsxs)(S,{flexDirection:`column`,children:[(0,J.jsxs)(S,{flexDirection:`column`,paddingX:1,borderStyle:o?void 0:`round`,children:[(0,J.jsx)(S,{marginBottom:1,children:(0,J.jsxs)(C,{bold:!0,children:[ne,` MCP Server`]})}),(0,J.jsxs)(S,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(S,{children:[(0,J.jsx)(C,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,J.jsxs)(C,{children:[D(`inactive`,s)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,J.jsxs)(C,{children:[D(`success`,s)(r.tick),` connected`]}):e.client.type===`pending`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C,{dimColor:!0,children:r.radioOff}),(0,J.jsx)(C,{children:` connecting…`})]}):(0,J.jsxs)(C,{children:[D(`error`,s)(r.cross),` failed`]})]}),(0,J.jsxs)(S,{children:[(0,J.jsx)(C,{bold:!0,children:`Command: `}),(0,J.jsx)(C,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,J.jsxs)(S,{children:[(0,J.jsx)(C,{bold:!0,children:`Args: `}),(0,J.jsx)(C,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,J.jsxs)(S,{children:[(0,J.jsx)(C,{bold:!0,children:`Config location: `}),(0,J.jsx)(C,{dimColor:!0,children:te(g(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,J.jsx)(De,{serverToolsCount:t,serverPromptsCount:ie,serverResourcesCount:d.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,J.jsxs)(S,{children:[(0,J.jsx)(C,{bold:!0,children:`Tools: `}),(0,J.jsxs)(C,{dimColor:!0,children:[t,` tools`]})]})]}),_.length>0&&(0,J.jsx)(S,{marginTop:1,children:(0,J.jsx)(se,{options:_,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){m(!0);try{let{message:t}=ke(await f(e.name),e.name);a?.(t)}catch(t){a?.(Ae(t,e.name))}finally{m(!1)}}else t===`toggle-enabled`?await h():t===`back`&&i()},onCancel:i})})]}),(0,J.jsx)(S,{marginTop:1,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:c.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,c.keyName,` again to exit`]}):(0,J.jsxs)(w,{children:[(0,J.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var q,J,Y=e((()=>{n(),q=t(E(),1),H(),O(),oe(),V(),y(),a(),j(),z(),p(),b(),h(),Oe(),W(),J=A()}));function Pe({tool:e,server:t,onBack:n}){let[r,i]=X.useState(``),a=P(e.name,t.name),o=M(e.userFacingName?e.userFacingName({}):a),s=e.isReadOnly?.({})??!1,c=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:[o,s&&(0,Z.jsx)(C,{color:`success`,children:` [read-only]`}),c&&(0,Z.jsx)(C,{color:`error`,children:` [destructive]`}),u&&(0,Z.jsx)(C,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,Z.jsxs)(C,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,Z.jsxs)(S,{flexDirection:`column`,children:[(0,Z.jsxs)(S,{children:[(0,Z.jsx)(C,{bold:!0,children:`Tool name: `}),(0,Z.jsx)(C,{dimColor:!0,children:a})]}),(0,Z.jsxs)(S,{children:[(0,Z.jsx)(C,{bold:!0,children:`Full name: `}),(0,Z.jsx)(C,{dimColor:!0,children:e.name})]}),r&&(0,Z.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(C,{bold:!0,children:`Description:`}),(0,Z.jsx)(C,{wrap:`wrap`,children:r})]}),e.inputJSONSchema&&e.inputJSONSchema.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,Z.jsxs)(S,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(C,{bold:!0,children:`Parameters:`}),(0,Z.jsx)(S,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,Z.jsxs)(C,{children:[`• `,t,r&&(0,Z.jsx)(C,{dimColor:!0,children:` (required)`}),`:`,` `,(0,Z.jsx)(C,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,Z.jsxs)(C,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var X,Z,Fe=e((()=>{X=t(E(),1),O(),N(),p(),Z=A()}));function Ie({server:e,onSelectTool:t,onBack:n}){let r=de(e=>e.mcp.tools),i=Le.useMemo(()=>e.client.type===`connected`?ee(r,e.name):[],[e,r]),a=i.map((t,n)=>{let r=P(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)(C,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(w,{children:[(0,Q.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(l,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:i.length===0?(0,Q.jsx)(C,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(se,{options:a,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(),N(),y(),a(),z(),p(),b(),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,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,Aa as o,As as s,Ba as c,Bg as l,Cg as u,Da as d,Fw as f,Gc as p,Ha as m,Hg as h,Iu as g,Iw as _,Ka as v,Kc as y,Ms as b,Nw as x,Ru as S,Sa as C,Ta as w,Vg as T,Wa as E,Yc as D,an as O,dp as ee,hb as k,ks as A,lp as j,mb as M,mn as N,nd as te,qC as P,qc as ne,qg as F,rd as re,vn as I,wg as ie}from"./loadAgentsDir-C7lOqvfh.js";import{C as ae,Gt as oe,I as L,P as R,Wt as se,fi as z,ot as ce,t as le}from"./src-P_wYS_NJ2.js";import{t as ue}from"./jsx-runtime-Bb4Xn-E0.js";import{Gn as de,Wt as fe}from"./state-BemZdQIl.js";import{In as B,Ln as pe}from"./settings-DnptdP79.js";import{h as V,m as me,o as he,q as ge,s as H,w as _e}from"./log-CezCRpAN.js";import{n as U,r as W}from"./analytics-DJobLaWP.js";import{b as ve,m as ye,v as be}from"./startupProfiler-L_UWZ03w.js";import{E as xe,T as Se,c as Ce,d as we,w as Te}from"./sessionTracing-BrNx1k2V.js";import{n as Ee,t as De}from"./useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js";import*as G from"path";import{randomUUID as K}from"crypto";z();var q=ue();le(),fe(),ge(),me(),he(),pe(),U(),be(),f(),M(),Te(),j(),Ce(),ne(),p(),b(),c(),I();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();de(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:[w({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:[w({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}U(),c();async function je({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:a,ideSelection:s,messages:c,setUserInputOnProcessing:l,uuid:u,isAlreadyProcessing:d,querySource:f,canUseTool:p,skipSlashCommands:m,bridgeOrigin:h,isMeta:g,skipAttachments:_,autonomy:v}){let y=typeof e==`string`?e:null,b=y?.startsWith(`/`)&&!m;n===`prompt`&&y!==null&&!g&&!b&&l?.(y),D(`query_process_user_input_base_start`);let x=i.getAppState(),S=await Ne(e,n,r,i,a,s,c,u,d,f,p,x.toolPermissionContext.mode,m,h,g,_,t,v);if(D(`query_process_user_input_base_end`),!S.shouldQuery)return S;D(`query_hooks_start`);let T=o(e)||``;for await(let t of O(T,x.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[C(`${N(t.blockingError)}\n\nOriginal prompt: ${e}`,`warning`)],shouldQuery:!1,allowedTools:S.allowedTools};if(t.preventContinuation){let e=t.stopReason?`Operation stopped by hook: ${t.stopReason}`:`Operation stopped by hook`;return S.messages.push(w({content:e})),S.shouldQuery=!1,S}if(t.additionalContexts&&t.additionalContexts.length>0&&S.messages.push(A({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;S.messages.push({...t.message,attachment:{...t.message.attachment,content:Me(t.message.attachment.content)}});break;default:S.messages.push(t.message);break}}return D(`query_hooks_end`),S}var J=1e4;function Me(e){return e.length>J?`${e.substring(0,J)}… [output truncated - exceeded ${J} characters]`:e}async function Ne(e,t,n,r,i,a,o,c,l,u,d,f,p,m,h,g,v,b){let S=null,C=[],w=[],T=e;if(typeof e==`string`)S=e;else if(e.length>0){D(`query_image_processing_start`);let t=[];for(let n of e)if(n.type===`image`){let e=await _(n);if(e.dimensions){let t=x(e.dimensions);t&&w.push(t)}t.push(e.block)}else t.push(n);T=t,D(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(S=n.text,C=t.slice(0,-1)):C=t}if(S===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let E=i?Object.values(i).filter(k):[],O=E.map(e=>e.id),A=i?await ee(i):new Map;D(`query_pasted_image_processing_start`);let j=await Promise.all(E.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 _(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??A.get(e.id)}})),M=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of j){if(e.dimensions){let t=x(e.dimensions,n);t&&w.push(t)}else if(t){let e=x(t,n);e&&w.push(e)}else n&&w.push(`[Image source: ${n}]`);M.push(e.block)}D(`query_pasted_image_processing_end`);let N=p,te=!g&&S!==null&&(t!==`prompt`||N||!S.startsWith(`/`));D(`query_attachment_loading_start`);let P=te?await y(s(S,r,a??null,[],o,u)):[];if(D(`query_attachment_loading_end`),S!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-B5F2Cl7K.js`);return Y(await e(S,C,P,r,n),w)}if(S!==null&&!N&&S.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-BC_D3cH5.js`);return Y(await e(S,C,M,P,r,n,c,l,d,b),w)}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 Y(Ae(T,M,O,P,c,f,h),w)}function Y(e,t){return t.length>0&&e.messages.push(w({content:t.map(e=>({type:`text`,text:e})),isMeta:!0})),e}var Pe=n({MessageSelector:()=>Ie,messagesAfterAreOnlySynthetic:()=>Ue,selectableUserMessagesFilter:()=>Z});function Fe(e){return e.type===`text`}function X(e){return e===`summarize`}function Ie({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:a,onClose:o,preselectedMessage:s}){let c=ie(e=>e.fileHistory),[u,d]=(0,Q.useState)(void 0),f=T(),p=(0,Q.useMemo)(K,[]),m=(0,Q.useMemo)(()=>[...e.filter(Z),{...w({content:``}),uuid:p}],[e,p]),[_,v]=(0,Q.useState)(m.length-1),y=Math.max(0,Math.min(_-Math.floor($/2),m.length-$)),b=m.length>1,[x,S]=(0,Q.useState)(s),[C,E]=(0,Q.useState)(void 0);(0,Q.useEffect)(()=>{if(!s||!f)return;let e=!1;return h(c,s.uuid).then(t=>{e||E(t)}),()=>{e=!0}},[s,f,c]);let[D,O]=(0,Q.useState)(!1),[ee,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(`both`),[M,N]=(0,Q.useState)(``);function P(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:N}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,Q.useEffect)(()=>{W(`tengu_message_selector_opened`,{})},[]);async function ne(e){t(),O(!0);try{await n(e),O(!1),o()}catch(e){H(e),O(!1),d(`Failed to restore the conversation:\n${e}`)}}async function F(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(!f){await ne(t);return}let r=await h(c,t.uuid);S(t),E(r)}async function re(e){if(W(`tengu_message_selector_restore_option_selected`,{option:e}),!x){d(`Message not found.`);return}if(e===`nevermind`){s?o():S(void 0);return}if(X(e)){t(),O(!0),k(e),d(void 0);try{let e=M.trim()||void 0;await a(x,e,`from`),O(!1),k(null),S(void 0),o()}catch(e){H(e),O(!1),k(null),S(void 0),d(`Failed to summarize:\n${e}`)}return}t(),O(!0),d(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)}O(!1),S(void 0),c&&i?d(`Failed to restore the conversation and code:\n${c}\n${i}`):c?d(`Failed to restore the conversation:\n${c}`):i?d(`Failed to restore the code:\n${i}`):o()}let I=Ee(),z=(0,Q.useCallback)(()=>{if(x&&!s){S(void 0);return}W(`tengu_message_selector_cancelled`,{}),o()},[o,x,s]),ce=(0,Q.useCallback)(()=>v(e=>Math.max(0,e-1)),[]),le=(0,Q.useCallback)(()=>v(e=>Math.min(m.length-1,e+1)),[m.length]),ue=(0,Q.useCallback)(()=>v(0),[]),de=(0,Q.useCallback)(()=>v(m.length-1),[m.length]),fe=(0,Q.useCallback)(()=>{let e=m[_];e&&F(e)},[m,_,F]);se(`confirm:no`,z,{context:`Confirmation`,isActive:!x}),oe({"messageSelector:up":ce,"messageSelector:down":le,"messageSelector:top":ue,"messageSelector:bottom":de,"messageSelector:select":fe},{context:`MessageSelector`,isActive:!D&&!u&&!x&&b});let[B,pe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{async function t(){f&&Promise.all(m.map(async(t,n)=>{if(t.uuid!==p){let r=l(c,t.uuid),i=m.at(n+1),a=r?He(e,t.uuid,i?.uuid===p?void 0:i?.uuid):void 0;pe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[m,e,p,c,f]);let V=f&&C?.filesChanged&&C.filesChanged.length>0,me=!u&&!x&&!s&&b;return(0,q.jsxs)(L,{flexDirection:`column`,width:`100%`,children:[(0,q.jsx)(ae,{color:`suggestion`}),(0,q.jsxs)(L,{flexDirection:`column`,marginX:1,gap:1,children:[(0,q.jsx)(R,{bold:!0,color:`suggestion`,children:`Rewind`}),u&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(R,{color:`error`,children:[`Error: `,u]})}),!b&&(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(R,{children:`Nothing to rewind to yet.`})}),!u&&x&&b&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(R,{children:[`Confirm you want to restore `,!C&&`the conversation `,`to the point before you sent this message:`]}),(0,q.jsxs)(L,{flexDirection:`column`,paddingLeft:1,borderStyle:`single`,borderRight:!1,borderTop:!1,borderBottom:!1,borderLeft:!0,borderLeftDimColor:!0,children:[(0,q.jsx)(Ve,{userMessage:x,color:`text`,isCurrent:!1}),(0,q.jsxs)(R,{dimColor:!0,children:[`(`,ye(new Date(x.timestamp)),`)`]})]}),(0,q.jsx)(Re,{selectedRestoreOption:A,canRestoreCode:!!V,diffStatsForRestore:C}),D&&X(ee)?(0,q.jsxs)(L,{flexDirection:`row`,gap:1,children:[(0,q.jsx)(g,{}),(0,q.jsx)(R,{children:`Summarizing…`})]}):(0,q.jsx)(te,{isDisabled:D,options:P(!!V),defaultFocusValue:V?`both`:`conversation`,onFocus:e=>j(e),onChange:e=>re(e),onCancel:()=>s?o():S(void 0)}),V&&(0,q.jsx)(L,{marginBottom:1,children:(0,q.jsxs)(R,{dimColor:!0,children:[i.warning,` Rewinding does not affect files edited manually or via bash.`]})})]}),me&&(0,q.jsxs)(q.Fragment,{children:[f?(0,q.jsx)(R,{children:`Restore the code and/or conversation to the point before…`}):(0,q.jsx)(R,{children:`Restore and fork the conversation to the point before…`}),(0,q.jsx)(L,{width:`100%`,flexDirection:`column`,children:m.slice(y,y+$).map((e,t)=>{let n=y+t,r=n===_,a=e.uuid===p,o=n in B,s=B[n],c=s?.filesChanged&&s.filesChanged.length;return(0,q.jsxs)(L,{height:f?3:2,overflow:`hidden`,width:`100%`,flexDirection:`row`,children:[(0,q.jsx)(L,{width:2,minWidth:2,children:r?(0,q.jsxs)(R,{color:`permission`,bold:!0,children:[i.pointer,` `]}):(0,q.jsx)(R,{children:` `})}),(0,q.jsxs)(L,{flexDirection:`column`,children:[(0,q.jsx)(L,{flexShrink:1,height:1,overflow:`hidden`,children:(0,q.jsx)(Ve,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:a,paddingRight:10})}),f&&o&&(0,q.jsx)(L,{height:1,flexDirection:`row`,children:s?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(R,{dimColor:!r,color:`inactive`,children:c?(0,q.jsxs)(q.Fragment,{children:[c===1&&s.filesChanged[0]?`${G.basename(s.filesChanged[0])} `:`${c} files changed `,(0,q.jsx)(Be,{diffStats:s})]}):(0,q.jsx)(q.Fragment,{children:`No code changes`})})}):(0,q.jsxs)(R,{dimColor:!0,color:`warning`,children:[i.warning,` No code restore`]})})]})]},e.uuid)})})]}),!x&&(0,q.jsx)(R,{dimColor:!0,italic:!0,children:I.pending?(0,q.jsxs)(q.Fragment,{children:[`Press `,I.keyName,` again to exit`]}):(0,q.jsxs)(q.Fragment,{children:[!u&&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,q.jsxs)(L,{flexDirection:`column`,children:[(0,q.jsx)(R,{dimColor:!0,children:Le(e)}),!X(e)&&(r?(0,q.jsx)(ze,{diffStatsForRestore:n}):(0,q.jsx)(R,{dimColor:!0,children:`The code will be unchanged.`}))]})}function ze({diffStatsForRestore:e}){if(e===void 0)return;if(!e.filesChanged||!e.filesChanged[0])return(0,q.jsx)(R,{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,q.jsx)(q.Fragment,{children:(0,q.jsxs)(R,{dimColor:!0,children:[`The code will be restored `,(0,q.jsx)(Be,{diffStats:e}),` in `,n,`.`]})})}function Be({diffStats:e}){if(!(!e||!e.filesChanged))return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(R,{color:`diffAddedWord`,children:[`+`,e.insertions,` `]}),(0,q.jsxs)(R,{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,q.jsx)(L,{width:`100%`,children:(0,q.jsx)(R,{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(m(c))return(0,q.jsx)(L,{flexDirection:`row`,width:`100%`,children:(0,q.jsx)(R,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(c.includes(`<bash-input>`)){let e=d(c,`bash-input`);if(e)return(0,q.jsxs)(L,{flexDirection:`row`,width:`100%`,children:[(0,q.jsx)(R,{color:`bashBorder`,children:`!`}),(0,q.jsxs)(R,{color:t,dimColor:n,children:[` `,e]})]})}if(c.includes(`<command-message>`)){let e=d(c,_e),r=d(c,`command-args`),i=d(c,`skill-format`)===`true`;if(e)return i?(0,q.jsx)(L,{flexDirection:`row`,width:`100%`,children:(0,q.jsxs)(R,{color:t,dimColor:n,children:[`Skill(`,e,`)`]})}):(0,q.jsx)(L,{flexDirection:`row`,width:`100%`,children:(0,q.jsxs)(R,{color:t,dimColor:n,children:[`/`,e,` `,r]})})}return(0,q.jsx)(L,{flexDirection:`row`,width:`100%`,children:(0,q.jsx)(R,{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||!v(n))continue;let r=n.toolUseResult;if(!(!r||!r.filePath||!r.structuredPatch)){a.includes(r.filePath)||a.push(r.filePath);try{if(`type`in r&&r.type===`create`)o+=r.content.split(/\r?\n/).length;else for(let e of r.structuredPatch){let t=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 Z(e){if(e.type!==`user`||Array.isArray(e.message.content)&&e.message.content[0]?.type===`tool_result`||E(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&&!E(t)&&!v(t)&&t.type!==`progress`&&t.type!==`system`&&t.type!==`attachment`&&!(t.type===`user`&&t.isMeta)){if(t.type===`assistant`){let e=t.message.content;if(Array.isArray(e)&&e.some(e=>e.type===`text`&&e.text.trim()||e.type===`tool_use`))return!1;continue}if(t.type===`user`)return!1}}return!0}var Q,$,We=e((()=>{r(),Q=t(z(),1),U(),u(),F(),De(),P(),c(),re(),S(),a(),$=7}));export{Z as a,Ue as i,Pe as n,je as o,We as r,Ie as t};