@readmagic/workmate 0.0.9 → 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 (445) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/{App-DW4elk6E.js → App-BuKmqFPm.js} +1 -1
  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-BuRFF1fQ.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.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-BIcwpgSr.js → DiffDialog-DUbFrzKu.js} +3 -3
  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-BmirUB6V.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-bih293Xt.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.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-CH4yyMAL.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-BboWs1pp.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-CfMFx-TF.js +1 -0
  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-Bf44A0Ol.js +2 -0
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-1KBBUikF.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-BmgPAZAi.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-BZL8Zblz.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/WelcomeV2-ZQRKlcT4.js +1 -0
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-Bz1MLp4A.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-DzccRM_z.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-Cjnyy10u.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-CQ5nqP9c.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/autonomy-DuQmYhq6.js +15 -0
  53. package/dist/chunks/{autonomy-CPUCe-YU.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-BJZNMppT.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-w3Vlsm3Y.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/branch-k3kirqbA.js +3 -0
  61. package/dist/chunks/{break-cache-DXV0brco.js → break-cache-CAoZ9b72.js} +2 -2
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/bridgeMessaging-Ci5H68MX.js +1 -0
  65. package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/bridgeStatusUtil-C36w15ge.js +1 -0
  67. package/dist/chunks/{btw-DDUC_t0w.js → btw-nVoVuIae.js} +1 -1
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-DdWexxbM.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-CoXtVRzi.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-aRiTrtCv.js +3 -0
  82. package/dist/chunks/{config-CVvUNkj2.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/{context-BWcfhhDj.js → context-BN7DEjoH.js} +1 -1
  84. package/dist/chunks/{context-noninteractive-c7jGVWHQ.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-DP7B8yvb.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/cwd-Cfdf7z7s.js +1 -0
  93. package/dist/chunks/cwd-ClLru_7T.js +1 -0
  94. package/dist/chunks/datadog-bm551AVV.js +1 -0
  95. package/dist/chunks/debug-BecbSVoN.js +39 -0
  96. package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-CmJfIUxW.js} +1 -1
  97. package/dist/chunks/{detached-CkPpYMJj.js → detached-CIyF0M5O.js} +1 -1
  98. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  99. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  100. package/dist/chunks/{diff-DHzz9WAp.js → diff-DeK4bwjw.js} +1 -1
  101. package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BJCu19HJ.js} +1 -1
  102. package/dist/chunks/doctor-BJORBomU.js +1 -0
  103. package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
  104. package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
  105. package/dist/chunks/entry-mdegyj8z.js +14 -0
  106. package/dist/chunks/esm-Ka3lhafK.js +1 -0
  107. package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  108. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  109. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  110. package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-BrKbpBK-.js} +1 -1
  111. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  112. package/dist/chunks/fast-0Vi354KI.js +1 -0
  113. package/dist/chunks/{fast-ClYQcEv5.js → fast-DWn40OcQ.js} +1 -1
  114. package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
  115. package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
  116. package/dist/chunks/{fileSuggestions-fNxREjpe.js → fileSuggestions-C7Pwq2yj.js} +3 -3
  117. package/dist/chunks/firstPartyEventLogger-BHjBQH0J.js +5 -0
  118. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  119. package/dist/chunks/flushGate-DdJjxCes.js +1 -0
  120. package/dist/chunks/{gemini-fZ0VPU2A.js → gemini-DHv2iVfy.js} +1 -1
  121. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  122. package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  123. package/dist/chunks/git-DBlOv64X.js +6 -0
  124. package/dist/chunks/git-DF4RFFaT.js +1 -0
  125. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  126. package/dist/chunks/{goal-IasZVqKh.js → goal-BZG4gtnb.js} +3 -3
  127. package/dist/chunks/{grok-Dk3LyzMa.js → grok-BS57ZhyW.js} +1 -1
  128. package/dist/chunks/{grove-BE4fQ6tG.js → grove-_zlQ83yR.js} +2 -2
  129. package/dist/chunks/help-C_2tdXHC.js +1 -0
  130. package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C7Bn7MBe.js} +2 -2
  131. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  132. package/dist/chunks/initReplBridge-NkZRcM77.js +1 -0
  133. package/dist/chunks/{install-CVGZ55wV.js → install-Du-DSVzj.js} +1 -1
  134. package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DMs3b82f.js} +5 -5
  135. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  136. package/dist/chunks/{job-DEXxW_Zo.js → job-rbX1VZmp.js} +1 -1
  137. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  138. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  139. package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  140. package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-Al_X75Vz.js} +1 -1
  141. package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-BL93ulMm.js} +2197 -2332
  142. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  143. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  144. package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-C5ipegd9.js} +1 -1
  145. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  146. package/dist/chunks/log-Dauqle-Z.js +1 -0
  147. package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-CkvOihX7.js} +1 -1
  148. package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-DLav5QK0.js} +3 -3
  149. package/dist/chunks/main-CVNWNAoh.js +513 -0
  150. package/dist/chunks/{main-ClXu1ilx.js → main-LMyE3jXY.js} +4 -4
  151. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  152. package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DJSCuqCb.js} +1 -1
  153. package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-DQxMcezy.js} +1 -1
  154. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  155. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  156. package/dist/chunks/mcp-D5HkCqUh.js +2 -0
  157. package/dist/chunks/{memoize-FJv2HV1u.js → memoize-FeyE7JEh.js} +1 -1
  158. package/dist/chunks/memory-COa7aUbx.js +1 -0
  159. package/dist/chunks/{mode-lYTs0XHs.js → mode-Bl2RZC8M.js} +2 -2
  160. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  161. package/dist/chunks/model-Bgh_r4lg.js +1 -0
  162. package/dist/chunks/model-DiuEAv6h.js +1 -0
  163. package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-BtEZe5BB.js} +1 -1
  164. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  165. package/dist/chunks/omit--yH_T4rf.js +1 -0
  166. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  167. package/dist/chunks/{openai-DJLYqiRl.js → openai-DWs4D-nQ.js} +3 -3
  168. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  169. package/dist/chunks/{parser-BdCj2GrE.js → parser-BH4u7QiV.js} +1 -1
  170. package/dist/chunks/parser-BMIaRErw.js +1 -0
  171. package/dist/chunks/partition-DLcW5Oo_.js +1 -0
  172. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  173. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  174. package/dist/chunks/{plan-BeoIjNPv.js → plan-BNYDTnQd.js} +1 -1
  175. package/dist/chunks/{platform-D6IMiyqT.js → platform-B0uTQc9P.js} +1 -1
  176. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  177. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  178. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  179. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  180. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  181. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  182. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  183. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  184. package/dist/chunks/{plugins-pmipe7kE.js → plugins-CBW7kPyp.js} +4 -4
  185. package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-B_xEvuEV.js} +1 -1
  186. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  187. package/dist/chunks/print-BZOx09SU.js +26 -0
  188. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  189. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  190. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  191. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  192. package/dist/chunks/{prompt-CybUvG8G.js → prompt-Dx7IWhBt.js} +34 -34
  193. package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-WCkmpejM.js} +2 -2
  194. package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-BiVWrpHi.js} +4 -4
  195. package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CVn7o19p.js} +3 -3
  196. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  197. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  198. package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-E0Iu5hEx.js} +2 -2
  199. package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-D-3AUT9g.js} +1 -1
  200. package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  201. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  202. package/dist/chunks/rename-CSavuBIE.js +1 -0
  203. package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-DDLbSMQU.js} +1 -1
  204. package/dist/chunks/resume-CROylN3J.js +2 -0
  205. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  206. package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-C1ydIMzT.js} +5 -5
  207. package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-L7pSIWBT.js} +4 -4
  208. package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-OU8KrZQG.js} +1 -1
  209. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  210. package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  211. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  212. package/dist/chunks/{session-BbQlh2S5.js → session-DUYsfPy_.js} +2 -2
  213. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  214. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  215. package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  216. package/dist/chunks/sessionState-D-SaBzWD.js +11 -0
  217. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  218. package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-uCuYaNif.js} +2 -2
  219. package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-Bqb3vJTt.js} +3 -3
  220. package/dist/chunks/settings-BG15IFYx.js +1 -0
  221. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  222. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  223. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  224. package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  225. package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-DS6WrivY.js} +2 -2
  226. package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-CvMBBjI8.js} +3 -3
  227. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  228. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  229. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  230. package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-CqaT8c0C.js} +2 -2
  231. package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-CnR8IqJM.js} +2 -2
  232. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  233. package/dist/chunks/{skills-t6krW8GZ.js → skills-BgcFh0vy.js} +1 -1
  234. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  235. package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-CmH_aVy2.js} +3 -3
  236. package/dist/chunks/state-BemZdQIl.js +1 -0
  237. package/dist/chunks/state-D_lk6z-C.js +1 -0
  238. package/dist/chunks/{stats-BJBhl-Lc.js → stats-B8uQ-UDi.js} +1 -1
  239. package/dist/chunks/{status-BtsnKNVY.js → status-BekdWoIj.js} +1 -1
  240. package/dist/chunks/{status-nZQEar7T.js → status-D6KlRJmR.js} +2 -2
  241. package/dist/chunks/statusNoticeHelpers-BMM8_uJ1.js +1 -0
  242. package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C8PaYpQF.js} +1 -1
  243. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  244. package/dist/chunks/{switcher-77h2J5HC.js → switcher-DnAhkyIn.js} +1 -1
  245. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  246. package/dist/chunks/{tasks-BNrdmF9p.js → tasks-Dmh6qikm.js} +1 -1
  247. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  248. package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CxqU-s5i.js} +1 -1
  249. package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-BKGcmlWp.js} +1 -1
  250. package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-Cy19F1Js.js} +4 -4
  251. package/dist/chunks/{theme-BjpBVRf5.js → theme-U7lMFHQ0.js} +1 -1
  252. package/dist/chunks/{tmux-CMRiI6CD.js → tmux-D5EvHWi3.js} +1 -1
  253. package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-D9qjoVl5.js} +1 -1
  254. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  255. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  256. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  257. package/dist/chunks/{types-DWRxAH0E.js → types-DafcFtmb.js} +2 -2
  258. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  259. package/dist/chunks/updateCCB-C6XftzIG.js +11 -0
  260. package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-CXmjxHpl.js} +2 -2
  261. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  262. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  263. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  264. package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-DbhqKk1-.js} +1 -1
  265. package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-gUDbkLaC.js} +1 -1
  266. package/dist/chunks/useSettingsErrors-CgPad-H0.js +1 -0
  267. package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CU7Ndh79.js} +1 -1
  268. package/dist/chunks/util-B4oMhJKh.js +1 -0
  269. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  270. package/dist/chunks/{vim-3mUqsEJm.js → vim-w37BfGZ5.js} +1 -1
  271. package/dist/chunks/{which-DznMOwny.js → which-BRWBO7Gu.js} +1 -1
  272. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  273. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  274. package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-BEhXgH2M.js} +1 -1
  275. package/dist/chunks/workerRegistry-Bq9bS5pw.js +6 -0
  276. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  277. package/dist/cli.js +1 -1
  278. package/package.json +2 -3
  279. package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
  280. package/dist/chunks/ApproveApiKey-DHAbdwkC.js +0 -1
  281. package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +0 -2
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +0 -1
  284. package/dist/chunks/Doctor-D160J8Ad.js +0 -3
  285. package/dist/chunks/Doctor-VhJi2cmL.js +0 -1
  286. package/dist/chunks/ExitFlow-CoWHhKHJ.js +0 -2
  287. package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +0 -1
  288. package/dist/chunks/MCPToolListView-BPmE0C2o.js +0 -1
  289. package/dist/chunks/MessageSelector-kOn2GaU-.js +0 -3
  290. package/dist/chunks/Messages-4EnHFeh1.js +0 -11
  291. package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +0 -1
  292. package/dist/chunks/QueryEngine-J6ElcO16.js +0 -1
  293. package/dist/chunks/REPL-DBjbAJsm.js +0 -133
  294. package/dist/chunks/REPL-oBemMXvp.js +0 -1
  295. package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +0 -2
  296. package/dist/chunks/ResumeConversation-wBG8OD9P.js +0 -1
  297. package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +0 -1
  298. package/dist/chunks/Settings-DptKuJE7.js +0 -2
  299. package/dist/chunks/WelcomeV2-BWF-cJOu.js +0 -1
  300. package/dist/chunks/add-dir-DBVT1cEK.js +0 -1
  301. package/dist/chunks/agents-CnwTOlqO.js +0 -103
  302. package/dist/chunks/allErrors-DYw_q14e.js +0 -1
  303. package/dist/chunks/api-DXDXTFGa.js +0 -1
  304. package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
  305. package/dist/chunks/auth-CnLb6RWc.js +0 -1
  306. package/dist/chunks/auth-D-SGHS0K.js +0 -1
  307. package/dist/chunks/autonomy-dSJl0hN1.js +0 -15
  308. package/dist/chunks/autonomyPanel-Ccr9ilei.js +0 -1
  309. package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
  310. package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
  311. package/dist/chunks/bg-DWloqGwk.js +0 -1
  312. package/dist/chunks/branch-CG0AKS1J.js +0 -3
  313. package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
  314. package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
  315. package/dist/chunks/caches-1IFb6_M_.js +0 -1
  316. package/dist/chunks/caches-CB8MHqy2.js +0 -1
  317. package/dist/chunks/ccrClient-CG6HTv_n.js +0 -1
  318. package/dist/chunks/client-Crrwkw7g.js +0 -1
  319. package/dist/chunks/client-D8hKghba.js +0 -1
  320. package/dist/chunks/color-Cuq0c6xy.js +0 -1
  321. package/dist/chunks/commands-D3sESsTp.js +0 -1
  322. package/dist/chunks/compact-DIpwuBDq.js +0 -2
  323. package/dist/chunks/config-D4G8_MqJ.js +0 -3
  324. package/dist/chunks/config-q9D4hFiK.js +0 -1
  325. package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
  326. package/dist/chunks/conversation-Bjo_8kia.js +0 -1
  327. package/dist/chunks/conversation-DrHZIQX2.js +0 -1
  328. package/dist/chunks/createSession-CPo6GBSb.js +0 -1
  329. package/dist/chunks/createSession-DnykRoia.js +0 -1
  330. package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
  331. package/dist/chunks/cwd--q1ONL7P.js +0 -1
  332. package/dist/chunks/cwd-L4wygFqJ.js +0 -1
  333. package/dist/chunks/daemon-D2vFIVOz.js +0 -2
  334. package/dist/chunks/datadog-DrmHyl3_.js +0 -1
  335. package/dist/chunks/debug-BdqxZ7rV.js +0 -39
  336. package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
  337. package/dist/chunks/detectRepository-DvxoaPlk.js +0 -1
  338. package/dist/chunks/doctor-PWqB46xd.js +0 -1
  339. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  340. package/dist/chunks/entry-4JtoJONR.js +0 -14
  341. package/dist/chunks/esm-DcIr7tVd.js +0 -1
  342. package/dist/chunks/execSyncWrapper-DKuxVTaf.js +0 -1
  343. package/dist/chunks/exit-OW9g7b9A.js +0 -1
  344. package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
  345. package/dist/chunks/fast-CrvLdpy3.js +0 -1
  346. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  347. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  348. package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
  349. package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
  350. package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
  351. package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
  352. package/dist/chunks/generateSessionName-nZj_VvKZ.js +0 -1
  353. package/dist/chunks/git-B9uvt96d.js +0 -6
  354. package/dist/chunks/git-BfS5Hk4S.js +0 -1
  355. package/dist/chunks/githubRepoPathMapping-Cqx3pSfc.js +0 -1
  356. package/dist/chunks/help-D2-v9Ug9.js +0 -1
  357. package/dist/chunks/hooks-DGd02IKF.js +0 -1
  358. package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
  359. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  360. package/dist/chunks/jwtUtils-C9sdGhvT.js +0 -1
  361. package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
  362. package/dist/chunks/language-C0cIpKE2.js +0 -1
  363. package/dist/chunks/language-CxThoWRC.js +0 -1
  364. package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
  365. package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
  366. package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
  367. package/dist/chunks/log-CTFl4qpD.js +0 -1
  368. package/dist/chunks/main-BIiwW4mM.js +0 -605
  369. package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
  370. package/dist/chunks/mcp-B_m1XBDt.js +0 -6
  371. package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
  372. package/dist/chunks/mcp-BjlaPUWX.js +0 -2
  373. package/dist/chunks/memory-LN8f_p2b.js +0 -1
  374. package/dist/chunks/model-C2e73CJD.js +0 -1
  375. package/dist/chunks/model-CvmS-Esk.js +0 -1
  376. package/dist/chunks/model-DJ8mFfuR.js +0 -1
  377. package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
  378. package/dist/chunks/omit-CLPZGevl.js +0 -1
  379. package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
  380. package/dist/chunks/panel-q0_iT9cg.js +0 -1
  381. package/dist/chunks/panelCall-sum-3zvi.js +0 -1
  382. package/dist/chunks/parser-BcdhBGx0.js +0 -1
  383. package/dist/chunks/partition-CpfoVrg1.js +0 -1
  384. package/dist/chunks/permissions-DTb9wkAP.js +0 -3
  385. package/dist/chunks/pidLock-BR5M6RQw.js +0 -3
  386. package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
  387. package/dist/chunks/plugin-D_dHjTud.js +0 -17
  388. package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
  389. package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
  390. package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
  391. package/dist/chunks/pluginFlagging-CxuRF2Vc.js +0 -1
  392. package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
  393. package/dist/chunks/pluginStartupCheck-B6leNWq9.js +0 -1
  394. package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
  395. package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
  396. package/dist/chunks/print-CAUvczBM.js +0 -23
  397. package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
  398. package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
  399. package/dist/chunks/prompt-RBn4JdEg.js +0 -1
  400. package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
  401. package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
  402. package/dist/chunks/refresh-D8TLHO_T.js +0 -1
  403. package/dist/chunks/remoteManagedSettings-CCrq-qL-.js +0 -1
  404. package/dist/chunks/rename-CKsSc7Z3.js +0 -1
  405. package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
  406. package/dist/chunks/resume-B1a5gLVR.js +0 -2
  407. package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
  408. package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
  409. package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
  410. package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
  411. package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
  412. package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
  413. package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
  414. package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
  415. package/dist/chunks/sessionState-BvECKycx.js +0 -11
  416. package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
  417. package/dist/chunks/settings-B-R9ZJNY.js +0 -1
  418. package/dist/chunks/settings-Xbq6AaD-.js +0 -20
  419. package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
  420. package/dist/chunks/setup-uZ0dSekt.js +0 -3
  421. package/dist/chunks/sinks-C7q46rvE.js +0 -2
  422. package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
  423. package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
  424. package/dist/chunks/skillSearchPanel-mpaC62y4.js +0 -21
  425. package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
  426. package/dist/chunks/state-B4HwLt8i.js +0 -1
  427. package/dist/chunks/state-Bs5xweDL.js +0 -1
  428. package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
  429. package/dist/chunks/switcher-B2CYzCC_.js +0 -1
  430. package/dist/chunks/syncCache-By_-buUC.js +0 -1
  431. package/dist/chunks/teleport-mdnhIZBj.js +0 -1
  432. package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
  433. package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
  434. package/dist/chunks/trustedDevice-j1u2TG5U.js +0 -1
  435. package/dist/chunks/udsClient-Cm3HqYUu.js +0 -1
  436. package/dist/chunks/updateCCB-BlUAU2Vp.js +0 -11
  437. package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
  438. package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
  439. package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
  440. package/dist/chunks/util-D-X8i5Z2.js +0 -1
  441. package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
  442. package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
  443. package/dist/chunks/windowsPaths-BVztIhXM.js +0 -1
  444. package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
  445. package/dist/chunks/worktree-BX1ULzrw.js +0 -1
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Dg as n,Og as r,Qd as i,Zd as a}from"./loadAgentsDir-BL93ulMm.js";import{fi as o}from"./src-P_wYS_NJ2.js";import{B as s,Wt as c}from"./state-BemZdQIl.js";import{n as l,t as u}from"./allErrors-_cOQksHC.js";function d(){let{addNotification:e,removeNotification:t}=i(),[n,a]=(0,f.useState)(()=>{let{errors:e}=u();return e});return r((0,f.useCallback)(()=>{let{errors:e}=u();a(e)},[])),(0,f.useEffect)(()=>{if(!s())if(n.length>0){let t=`Found ${n.length} settings ${n.length===1?`issue`:`issues`} · /doctor for details`;e({key:p,text:t,color:`warning`,priority:`high`,timeoutMs:6e4})}else t(p)},[n,e,t]),n}var f,p,m=e((()=>{f=t(o(),1),a(),c(),l(),n(),p=`settings-errors`}));export{d as n,m as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return`claude-code/0.0.9`}var n=e((()=>{}));export{n,t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return`claude-code/0.0.11`}var n=e((()=>{}));export{n,t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Au as t,bg as n,ju as r,xg as i}from"./loadAgentsDir-BL93ulMm.js";import{I as a,P as o,fi as s,t as c}from"./src-P_wYS_NJ2.js";import{t as l}from"./jsx-runtime-Bb4Xn-E0.js";import{n as u,r as d}from"./analytics-DJobLaWP.js";import{Bt as f,Ht as p}from"./model-Bgh_r4lg.js";import{t as m}from"./WelcomeV2-ZQRKlcT4.js";import{t as h}from"./useManagePlugins-CjnsO-Of.js";import{n as g,t as _}from"./MCPConnectionManager-B9n4SXN4.js";import{n as v}from"./onChangeAppState-ZdwI7boX.js";import{cwd as y}from"process";var b=e(s(),1);c(),r(),u(),g(),i(),f();var x=l();async function S(e){d(`tengu_setup_token_command`,{});let r=!p(),{ConsoleOAuthFlow:i}=await import(`./ConsoleOAuthFlow-CV6PcJOP.js`);await new Promise(s=>{e.render((0,x.jsx)(n,{onChangeAppState:v,children:(0,x.jsx)(t,{children:(0,x.jsxs)(a,{flexDirection:`column`,gap:1,children:[(0,x.jsx)(m,{}),r&&(0,x.jsxs)(a,{flexDirection:`column`,children:[(0,x.jsx)(o,{color:`warning`,children:`Warning: You already have authentication configured via environment variable or API key helper.`}),(0,x.jsx)(o,{color:`warning`,children:`The setup-token command will create a new OAuth token which you can use instead.`})]}),(0,x.jsx)(i,{onDone:()=>{s()}})]})})}))}),e.unmount(),process.exit(0)}var C=b.lazy(()=>import(`./Doctor-BcnUfJ4I.js`).then(e=>({default:e.Doctor})));function w({onDone:e}){return h(),(0,x.jsx)(b.Suspense,{fallback:null,children:(0,x.jsx)(C,{onDone:e})})}async function T(e){d(`tengu_doctor_command`,{}),await new Promise(r=>{e.render((0,x.jsx)(n,{children:(0,x.jsx)(t,{children:(0,x.jsx)(_,{dynamicMcpConfig:void 0,isStrictMcpConfig:!1,children:(0,x.jsx)(w,{onDone:()=>{r()}})})})}))}),e.unmount(),process.exit(0)}async function E(e,t){let{setup:n}=await import(`./setup-C62oq4AZ.js`);await n(y(),`default`,!1,!1,void 0,!1);let{install:r}=await import(`./install-Du-DSVzj.js`);await new Promise(n=>{let i=[];e&&i.push(e),t.force&&i.push(`--force`),r.call(e=>{n(),process.exit(+!!e.includes(`failed`))},{},i)})}export{T as doctorHandler,E as installHandler,S as setupTokenHandler};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{Jw as r,KE as i,UE as a,WE as o,Yw as s,eT as c,nT as l,qE as u,tT as d}from"./loadAgentsDir-BL93ulMm.js";import{p as f}from"./external-CEp-aPkt.js";import{r as p}from"./lazySchema-B4D4qJVE.js";import{B as m,C as ee,F as h,P as g,R as _,S as v,c as y,f as b,i as te,u as x,x as S}from"./debug-BecbSVoN.js";import{_t as C,gt as w,ht as T,pt as ne,vt as re}from"./settings-D4CpDv2y.js";import{o as ie,s as E}from"./log-Dauqle-Z.js";import{homedir as ae}from"os";import*as D from"path";import{join as oe,resolve as se}from"path";import{randomBytes as O}from"crypto";import{readFile as k,readdir as A,rename as j,stat as M,unlink as N,writeFile as P}from"fs/promises";function F(){return oe(r(),H)}async function I(){let e=F();try{let t=v(await k(e,{encoding:`utf-8`}));if(typeof t!=`object`||!t||!(`version`in t)||!(`fetchedAt`in t)||!(`counts`in t))return y(`Install counts cache has invalid structure`),null;let n=t;if(n.version!==V)return y(`Install counts cache version mismatch (got ${n.version}, expected ${V})`),null;if(typeof n.fetchedAt!=`string`||!Array.isArray(n.counts))return y(`Install counts cache has invalid structure`),null;let r=new Date(n.fetchedAt).getTime();return Number.isNaN(r)?(y(`Install counts cache has invalid fetchedAt timestamp`),null):n.counts.every(e=>typeof e==`object`&&!!e&&typeof e.plugin==`string`&&typeof e.unique_installs==`number`)?Date.now()-r>W?(y(`Install counts cache is stale (>24h old)`),null):{version:n.version,fetchedAt:n.fetchedAt,counts:n.counts}:(y(`Install counts cache has malformed entries`),null)}catch(e){return h(e)!==`ENOENT`&&y(`Failed to load install counts cache: ${g(e)}`),null}}async function L(e){let t=F(),n=`${t}.${O(8).toString(`hex`)}.tmp`;try{let i=r();await x().mkdir(i),await P(n,ee(e,null,2),{encoding:`utf-8`,mode:384}),await j(n,t),y(`Install counts cache saved successfully`)}catch(e){E(e);try{await N(n)}catch{}}}async function R(){y(`Fetching install counts from ${U}`);let e=performance.now();try{let n=await t.get(U,{timeout:1e4});if(!n.data?.plugins||!Array.isArray(n.data.plugins))throw Error(`Invalid response format from install counts API`);return l(`install_counts`,U,`success`,performance.now()-e),n.data.plugins}catch(t){throw l(`install_counts`,U,`failure`,performance.now()-e,c(t)),t}}async function z(){let e=await I();if(e){y(`Using cached install counts`),l(`install_counts`,U,`cache_hit`,0);let t=new Map;for(let n of e.counts)t.set(n.plugin,n.unique_installs);return t}try{let e=await R();await L({version:V,fetchedAt:new Date().toISOString(),counts:e});let t=new Map;for(let n of e)t.set(n.plugin,n.unique_installs);return t}catch(e){return E(e),y(`Failed to fetch install counts: ${g(e)}`),null}}function B(e){if(e<1e3)return String(e);if(e<1e6){let t=(e/1e3).toFixed(1);return t.endsWith(`.0`)?`${t.slice(0,-2)}K`:`${t}K`}let t=(e/1e6).toFixed(1);return t.endsWith(`.0`)?`${t.slice(0,-2)}M`:`${t}M`}var V,H,U,W,G=e((()=>{n(),te(),_(),b(),ie(),S(),d(),s(),V=1,H=`install-counts-cache.json`,U=`https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json`,W=1440*60*1e3}));async function K(e){let t=e.trim(),n=x(),r=t.match(/^([a-zA-Z0-9._-]+@[^:]+:.+?(?:\.git)?)(#(.+))?$/);if(r?.[1]){let e=r[1],t=r[3];return t?{source:`git`,url:e,ref:t}:{source:`git`,url:e}}if(t.startsWith(`http://`)||t.startsWith(`https://`)){let e=t.match(/^([^#]+)(#(.+))?$/),n=e?.[1]||t,r=e?.[3];if(n.endsWith(`.git`)||n.includes(`/_git/`))return r?{source:`git`,url:n,ref:r}:{source:`git`,url:n};let i;try{i=new URL(n)}catch{return{source:`url`,url:n}}if((i.hostname===`github.com`||i.hostname===`www.github.com`)&&i.pathname.match(/^\/([^/]+\/[^/]+?)(\/|\.git|$)/)?.[1]){let e=n.endsWith(`.git`)?n:`${n}.git`;return r?{source:`git`,url:e,ref:r}:{source:`git`,url:e}}return{source:`url`,url:n}}let i=process.platform===`win32`&&(t.startsWith(`.\\`)||t.startsWith(`..\\`)||/^[a-zA-Z]:[/\\]/.test(t));if(t.startsWith(`./`)||t.startsWith(`../`)||t.startsWith(`/`)||t.startsWith(`~`)||i){let e=se(t.startsWith(`~`)?t.replace(/^~/,ae()):t),r;try{r=await n.stat(e)}catch(t){let n=h(t);return{error:n===`ENOENT`?`Path does not exist: ${e}`:`Cannot access path: ${e} (${n??t})`}}return r.isFile()?e.endsWith(`.json`)?{source:`file`,path:e}:{error:`File path must point to a .json file (marketplace.json), but got: ${e}`}:r.isDirectory()?{source:`directory`,path:e}:{error:`Path is neither a file nor a directory: ${e}`}}if(t.includes(`/`)&&!t.startsWith(`@`)){if(t.includes(`:`))return null;let e=t.match(/^([^#@]+)(?:[#@](.+))?$/),n=e?.[1]||t,r=e?.[2];return r?{source:`github`,repo:n,ref:r}:{source:`github`,repo:n}}return null}var ce=e((()=>{_(),b()}));function le(e){let t=D.basename(e),n=D.basename(D.dirname(e));return t===`plugin.json`?`plugin`:t===`marketplace.json`?`marketplace`:n===`.claude-plugin`?`plugin`:`unknown`}function q(e){return e.issues.map(e=>({path:e.path.join(`.`)||`root`,message:e.message,code:e.code}))}function J(e,t,n,r){e.includes(`..`)&&n.push({path:t,message:r?`Path contains "..": ${e}. ${r}`:`Path contains ".." which could be a path traversal attempt: ${e}`})}function ue(e){let t=e.replace(/^(\.\.\/)+/,``);return`Plugin source paths are resolved relative to the marketplace root (the directory containing .claude-plugin/), not relative to marketplace.json. Use "${t===e?`./plugins/my-plugin`:`./${t}`}" instead of "${e}".`}async function Y(e){let t=[],n=[],r=D.resolve(e),i;try{i=await k(r,{encoding:`utf-8`})}catch(e){let t=h(e),n;return n=t===`ENOENT`?`File not found: ${r}`:t===`EISDIR`?`Path is not a file: ${r}`:`Failed to read file: ${g(e)}`,{success:!1,errors:[{path:`file`,message:n,code:t}],warnings:[],filePath:r,fileType:`plugin`}}let a;try{a=v(i)}catch(e){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${g(e)}`}],warnings:[],filePath:r,fileType:`plugin`}}if(a&&typeof a==`object`){let e=a;e.commands&&(Array.isArray(e.commands)?e.commands:[e.commands]).forEach((e,n)=>{typeof e==`string`&&J(e,`commands[${n}]`,t)}),e.agents&&(Array.isArray(e.agents)?e.agents:[e.agents]).forEach((e,n)=>{typeof e==`string`&&J(e,`agents[${n}]`,t)}),e.skills&&(Array.isArray(e.skills)?e.skills:[e.skills]).forEach((e,n)=>{typeof e==`string`&&J(e,`skills[${n}]`,t)})}let o=a;if(typeof a==`object`&&a){let e=a,t=Object.keys(e).filter(e=>$.has(e));if(t.length>0){let r={...e};for(let e of t)delete r[e],n.push({path:e,message:`Field '${e}' belongs in the marketplace entry (marketplace.json), not plugin.json. It's harmless here but unused — Work Mate ignores it at load time.`});o=r}}let s=T().strict().safeParse(o);if(s.success||t.push(...q(s.error)),s.success){let e=s.data;/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)||n.push({path:`name`,message:`Plugin name "${e.name}" is not kebab-case. Work Mate accepts it, but the Claude.ai marketplace sync requires kebab-case (lowercase letters, digits, and hyphens only, e.g., "my-plugin").`}),e.version||n.push({path:`version`,message:`No version specified. Consider adding a version following semver (e.g., "1.0.0")`}),e.description||n.push({path:`description`,message:`No description provided. Adding a description helps users understand what your plugin does`}),e.author||n.push({path:`author`,message:`No author information provided. Consider adding author details for plugin attribution`})}return{success:t.length===0,errors:t,warnings:n,filePath:r,fileType:`plugin`}}async function X(e){let t=[],n=[],r=D.resolve(e),i;try{i=await k(r,{encoding:`utf-8`})}catch(e){let t=h(e),n;return n=t===`ENOENT`?`File not found: ${r}`:t===`EISDIR`?`Path is not a file: ${r}`:`Failed to read file: ${g(e)}`,{success:!1,errors:[{path:`file`,message:n,code:t}],warnings:[],filePath:r,fileType:`marketplace`}}let a;try{a=v(i)}catch(e){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${g(e)}`}],warnings:[],filePath:r,fileType:`marketplace`}}if(a&&typeof a==`object`){let e=a;Array.isArray(e.plugins)&&e.plugins.forEach((e,n)=>{if(e&&typeof e==`object`&&`source`in e){let r=e.source;typeof r==`string`&&J(r,`plugins[${n}].source`,t,ue(r)),r&&typeof r==`object`&&`path`in r&&typeof r.path==`string`&&J(r.path,`plugins[${n}].source.path`,t)}})}let o=C().extend({plugins:f(w().strict())}).strict().safeParse(a);if(o.success||t.push(...q(o.error)),o.success){let e=o.data;if((!e.plugins||e.plugins.length===0)&&n.push({path:`plugins`,message:`Marketplace has no plugins defined`}),e.plugins){e.plugins.forEach((n,r)=>{e.plugins.filter(e=>e.name===n.name).length>1&&t.push({path:`plugins[${r}].name`,message:`Duplicate plugin name "${n.name}" found in marketplace`})});let i=D.dirname(r),a=D.basename(i)===`.claude-plugin`?D.dirname(i):i;for(let[t,r]of e.plugins.entries()){if(!r.version||typeof r.source!=`string`||!r.source.startsWith(`./`))continue;let e=D.join(a,r.source,`.claude-plugin`,`plugin.json`),i;try{let t=v(await k(e,{encoding:`utf-8`}));typeof t.version==`string`&&(i=t.version)}catch{continue}i&&i!==r.version&&n.push({path:`plugins[${t}].version`,message:`Entry declares version "${r.version}" but ${r.source}/.claude-plugin/plugin.json says "${i}". At install time, plugin.json wins (calculatePluginVersion precedence) — the entry version is silently ignored. Update this entry to "${i}" to match.`})}}e.metadata?.description||n.push({path:`metadata.description`,message:`No marketplace description provided. Adding a description helps users understand what this marketplace offers`})}return{success:t.length===0,errors:t,warnings:n,filePath:r,fileType:`marketplace`}}function de(e,t,n){let r=[],i=[],o=t.match(a);if(!o)return i.push({path:`frontmatter`,message:`No frontmatter block found. Add YAML frontmatter between --- delimiters at the top of the file to set description and other metadata.`}),{success:!0,errors:r,warnings:i,filePath:e,fileType:n};let s=o[1]||``,c;try{c=u(s)}catch(t){return r.push({path:`frontmatter`,message:`YAML frontmatter failed to parse: ${g(t)}. At runtime this ${n} loads with empty metadata (all frontmatter fields silently dropped).`}),{success:!1,errors:r,warnings:i,filePath:e,fileType:n}}if(typeof c!=`object`||!c||Array.isArray(c))return r.push({path:`frontmatter`,message:`Frontmatter must be a YAML mapping (key: value pairs), got ${Array.isArray(c)?`an array`:c===null?`null`:typeof c}.`}),{success:!1,errors:r,warnings:i,filePath:e,fileType:n};let l=c;if(l.description!==void 0){let e=l.description;typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`&&e!==null&&r.push({path:`description`,message:`description must be a string, got ${Array.isArray(e)?`array`:typeof e}. At runtime this value is dropped.`})}else i.push({path:`description`,message:`No description in frontmatter. A description helps users and Claude understand when to use this ${n}.`});l.name!==void 0&&l.name!==null&&typeof l.name!=`string`&&r.push({path:`name`,message:`name must be a string, got ${typeof l.name}.`});let d=l[`allowed-tools`];d!=null&&(typeof d!=`string`&&!Array.isArray(d)?r.push({path:`allowed-tools`,message:`allowed-tools must be a string or array of strings, got ${typeof d}.`}):Array.isArray(d)&&d.some(e=>typeof e!=`string`)&&r.push({path:`allowed-tools`,message:`allowed-tools array must contain only strings.`}));let f=l.shell;if(f!=null)if(typeof f!=`string`)r.push({path:`shell`,message:`shell must be a string, got ${typeof f}.`});else{let e=f.trim().toLowerCase();e!==`bash`&&e!==`powershell`&&r.push({path:`shell`,message:`shell must be 'bash' or 'powershell', got '${f}'.`})}return{success:r.length===0,errors:r,warnings:i,filePath:e,fileType:n}}async function Z(e){let t;try{t=await k(e,{encoding:`utf-8`})}catch(t){return h(t)===`ENOENT`?{success:!0,errors:[],warnings:[],filePath:e,fileType:`hooks`}:{success:!1,errors:[{path:`file`,message:`Failed to read file: ${g(t)}`}],warnings:[],filePath:e,fileType:`hooks`}}let n;try{n=v(t)}catch(t){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${g(t)}. At runtime this breaks the entire plugin load.`}],warnings:[],filePath:e,fileType:`hooks`}}let r=ne().safeParse(n);return r.success?{success:!0,errors:[],warnings:[],filePath:e,fileType:`hooks`}:{success:!1,errors:q(r.error),warnings:[],filePath:e,fileType:`hooks`}}async function Q(e,t){let n;try{n=await A(e,{withFileTypes:!0})}catch(e){let t=h(e);if(t===`ENOENT`||t===`ENOTDIR`)return[];throw e}if(t)return n.filter(e=>e.isDirectory()).map(t=>D.join(e,t.name,`SKILL.md`));let r=[];for(let t of n){let n=D.join(e,t.name);t.isDirectory()?r.push(...await Q(n,!1)):t.isFile()&&t.name.toLowerCase().endsWith(`.md`)&&r.push(n)}return r}async function fe(e){let t=[],n=[[`skill`,D.join(e,`skills`)],[`agent`,D.join(e,`agents`)],[`command`,D.join(e,`commands`)]];for(let[e,r]of n){let n=await Q(r,e===`skill`);for(let r of n){let n;try{n=await k(r,{encoding:`utf-8`})}catch(n){if(m(n))continue;t.push({success:!1,errors:[{path:`file`,message:`Failed to read: ${g(n)}`}],warnings:[],filePath:r,fileType:e});continue}let i=de(r,n,e);(i.errors.length>0||i.warnings.length>0)&&t.push(i)}}let r=await Z(D.join(e,`hooks`,`hooks.json`));return(r.errors.length>0||r.warnings.length>0)&&t.push(r),t}async function pe(e){let t=D.resolve(e),n=null;try{n=await M(t)}catch(e){if(!m(e))throw e}if(n?.isDirectory()){let e=await X(D.join(t,`.claude-plugin`,`marketplace.json`));if(e.errors[0]?.code!==`ENOENT`)return e;let n=await Y(D.join(t,`.claude-plugin`,`plugin.json`));return n.errors[0]?.code===`ENOENT`?{success:!1,errors:[{path:`directory`,message:`No manifest found in directory. Expected .claude-plugin/marketplace.json or .claude-plugin/plugin.json`}],warnings:[],filePath:t,fileType:`plugin`}:n}switch(le(e)){case`plugin`:return Y(e);case`marketplace`:return X(e);case`unknown`:try{let n=v(await k(t,{encoding:`utf-8`}));if(Array.isArray(n.plugins))return X(e)}catch(e){if(h(e)===`ENOENT`)return{success:!1,errors:[{path:`file`,message:`File not found: ${t}`}],warnings:[],filePath:t,fileType:`plugin`}}return Y(e)}}var $,me=e((()=>{p(),_(),o(),S(),i(),re(),$=new Set([`category`,`source`,`tags`,`strict`,`id`])}));export{K as a,G as c,ce as i,pe as n,B as o,fe as r,z as s,me as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,h as n,y as r}from"./config-D4G8_MqJ.js";import{n as i,r as a}from"./analytics-DJobLaWP.js";var o;e((()=>{i(),n(),o=async()=>{let e=t().editorMode||`normal`;e===`emacs`&&(e=`normal`);let n=e===`normal`?`vim`:`normal`;return r(e=>({...e,editorMode:n})),a(`tengu_editor_mode_changed`,{mode:n,source:`command`}),{type:`text`,value:`Editor mode set to ${n}. ${n===`vim`?`Use Escape key to toggle between INSERT and NORMAL modes.`:`Using standard (readline) keyboard bindings.`}`}}}))();export{o as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,h as n,y as r}from"./config-aRiTrtCv.js";import{n as i,r as a}from"./analytics-DJobLaWP.js";var o;e((()=>{i(),n(),o=async()=>{let e=t().editorMode||`normal`;e===`emacs`&&(e=`normal`);let n=e===`normal`?`vim`:`normal`;return r(e=>({...e,editorMode:n})),a(`tengu_editor_mode_changed`,{mode:n,source:`command`}),{type:`text`,value:`Editor mode set to ${n}. ${n===`vim`?`Use Escape key to toggle between INSERT and NORMAL modes.`:`Using standard (readline) keyboard bindings.`}`}}}))();export{o as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,o as n}from"./execFileNoThrow-5SylUnAI.js";import{n as r,t as i}from"./execSyncWrapper-DKuxVTaf.js";async function a(e){if(process.platform===`win32`){let t=await n(`where.exe ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim().split(/\r?\n/)[0]||null}let t=await n(`which ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim()}function o(e){if(process.platform===`win32`)try{return i(`where.exe ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim().split(/\r?\n/)[0]||null}catch{return null}try{return i(`which ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()||null}catch{return null}}var s,c,l,u=e((()=>{t(),r(),s=typeof Bun<`u`&&typeof Bun.which==`function`?Bun.which:null,c=s?async e=>s(e):a,l=s??o}));export{c as n,l as r,u as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,o as n}from"./execFileNoThrow-DHyW8FMX.js";import{n as r,t as i}from"./execSyncWrapper-CDzB0BM1.js";async function a(e){if(process.platform===`win32`){let t=await n(`where.exe ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim().split(/\r?\n/)[0]||null}let t=await n(`which ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim()}function o(e){if(process.platform===`win32`)try{return i(`where.exe ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim().split(/\r?\n/)[0]||null}catch{return null}try{return i(`which ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()||null}catch{return null}}var s,c,l,u=e((()=>{t(),r(),s=typeof Bun<`u`&&typeof Bun.which==`function`?Bun.which:null,c=s?async e=>s(e):a,l=s??o}));export{c as n,l as r,u as t};
@@ -0,0 +1 @@
1
+ import{i as e,o as t}from"./windowsPaths-DtWHLjmE.js";e();export{t as setShellIfWindows};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./cwd-Cfdf7z7s.js";import{c as a,i as o}from"./debug-BecbSVoN.js";import{n as s,t as c}from"./memoize-FeyE7JEh.js";import{n as l,t as u}from"./execSyncWrapper-CDzB0BM1.js";import{i as d,o as f}from"./platform-B0uTQc9P.js";import{existsSync as p}from"fs";import*as m from"path/win32";function h(){if(d()===`windows`){let e=y();process.env.SHELL=e,process.env.CLAUDE_CODE_GIT_BASH_PATH=e,a(`Using bash path: "${e}"`)}}function g(e,t){let n=[`C:\\Program Files\\Git\\bin\\bash.exe`,`C:\\Program Files\\Git\\usr\\bin\\bash.exe`,`C:\\Program Files (x86)\\Git\\bin\\bash.exe`,`C:\\Program Files (x86)\\Git\\usr\\bin\\bash.exe`];t&&n.push(`${t}\\scoop\\apps\\git\\current\\usr\\bin\\bash.exe`);for(let t of n)if(e(t))return t;return null}function _(e,t){if(e===`git`){for(let e of[`C:\\Program Files\\Git\\cmd\\git.exe`,`C:\\Program Files (x86)\\Git\\cmd\\git.exe`])if(t.checkExists(e))return e}try{let n=t.execCommand(`where.exe ${e}`).split(/\r?\n/).map(e=>e.trim()).filter(Boolean),r=m.resolve(t.cwdFn()).toLowerCase();for(let e of n){let t=m.resolve(e).toLowerCase(),n=m.dirname(t).toLowerCase(),i=m.relative(r,n);if(i===``||!i.startsWith(`..`)&&!m.isAbsolute(i)){a(`Skipping potentially malicious executable in current directory: ${e}`);continue}return e}return null}catch{return null}}function v(e=b){let t=e.envOverride??process.env.CLAUDE_CODE_GIT_BASH_PATH;if(t)return e.checkExists(t)?t:null;let n=_(`bash`,e);if(n&&e.checkExists(n))return n;let r=_(`git`,e);if(r){let t=[m.join(r,`..`,`..`,`bin`,`bash.exe`),m.join(r,`..`,`..`,`usr`,`bin`,`bash.exe`),m.join(r,`..`,`bash.exe`)];for(let n of t)if(e.checkExists(n))return n}return g(e.checkExists,e.userProfile)}function y(){let e=x();if(e!==null)return e;let t=process.env.CLAUDE_CODE_GIT_BASH_PATH;console.error(t?`Work Mate was unable to find CLAUDE_CODE_GIT_BASH_PATH path "${t}"`:`Work Mate on Windows requires git-bash (https://git-scm.com/downloads/win). If installed but not in PATH, set environment variable pointing to your bash.exe, similar to: CLAUDE_CODE_GIT_BASH_PATH=C:\\Program Files\\Git\\bin\\bash.exe`),process.exit(1)}var b,x,S,C,w=e((()=>{n(),r(),o(),l(),c(),f(),b={checkExists:p,execCommand:e=>u(e,{stdio:`pipe`,encoding:`utf8`}).trim(),cwdFn:i,userProfile:process.env.USERPROFILE,envOverride:void 0},x=t(()=>v()),S=s(e=>{if(e.startsWith(`\\\\`))return e.replace(/\\/g,`/`);let t=e.match(/^([A-Za-z]):[/\\]/);return t?`/`+t[1].toLowerCase()+e.slice(2).replace(/\\/g,`/`):e.replace(/\\/g,`/`)},e=>e,500),C=s(e=>{if(e.startsWith(`//`))return e.replace(/\//g,`\\`);let t=e.match(/^\/cygdrive\/([A-Za-z])(\/|$)/);if(t){let n=t[1].toUpperCase(),r=e.slice((`/cygdrive/`+t[1]).length);return n+`:`+(r||`\\`).replace(/\//g,`\\`)}let n=e.match(/^\/([A-Za-z])(\/|$)/);if(n){let t=n[1].toUpperCase(),r=e.slice(2);return t+`:`+(r||`\\`).replace(/\//g,`\\`)}return e.replace(/\//g,`\\`)},e=>e,500)}));export{C as a,w as i,x as n,h as o,v as r,S as s,y as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./axios-DaWTGg7G.js";import{C as n,S as r,w as i}from"./debug-BdqxZ7rV.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};
@@ -0,0 +1,6 @@
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
+ `),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),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.9 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-BaiXZ9tr.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-4JtoJONR.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-DdOYjLm3.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-CVvUNkj2.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-1mgenSWa.js`);r();let{initSinks:i}=await import(`./chunks/sinks-D3bXeHlQ.js`);i();let{daemonMain:a}=await import(`./chunks/main-ClXu1ilx.js`);await a(e.slice(1));return}if(e[0]===`autonomy`){t(`cli_autonomy_path`);let{getAutonomyCommandText:n}=await import(`./chunks/autonomy-CPUCe-YU.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-CVvUNkj2.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-1mgenSWa.js`);r(),await(await import(`./chunks/bg-DWloqGwk.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-CVvUNkj2.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-1mgenSWa.js`);i();let{initSinks:a}=await import(`./chunks/sinks-D3bXeHlQ.js`);a();let{daemonMain:o}=await import(`./chunks/main-ClXu1ilx.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-Dkv4I9c1.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-Dkv4I9c1.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-CVvUNkj2.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-BX1ULzrw.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-xcoTbKQn.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-BIiwW4mM.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.9",
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{t as e}from"./ApproveApiKey-DHAbdwkC.js";export{e as ApproveApiKey};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-DaDcL9Zw.js";import{dd as e,ud as t}from"./loadAgentsDir-CKSb56Gp.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-D4G8_MqJ.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,r}from"./rolldown-runtime-DaDcL9Zw.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{Dw as o,Ew as s,Jp as c,Of as l,Ow as u,Qa as d,Qf as f,Ra as p,Sm as m,Xf as h,Xs as ee,Yp as g,Zs as _,aw as v,cu as y,dd as b,dl as x,du as S,fd as te,fl as ne,hd as re,hu as ie,iv as ae,iw as oe,iy as se,jn as C,kf as ce,kn as le,lu as ue,lv as de,ma as fe,nm as pe,np as me,oo as he,ov as ge,pw as _e,rp as ve,rv as ye,su as be,sv as xe,sy as Se,tm as Ce,uu as we,vd as Te,xm as Ee,yu as De}from"./loadAgentsDir-CKSb56Gp.js";import{D as w,Gt as T,H as Oe,I as E,Lt as ke,P as D,T as O,fi as k,mt as Ae,ot as je,t as A,y as j}from"./src-P_wYS_NJ2.js";import{t as M}from"./jsx-runtime-Bb4Xn-E0.js";import{F as Me,p as Ne,v as Pe,z as Fe}from"./debug-BdqxZ7rV.js";import{In as Ie,Ln as Le,Rn as Re,Ut as ze}from"./settings-Xbq6AaD-.js";import{C as Be,b as N,f as Ve,l as He,u as Ue,v as P}from"./startupProfiler-jeId9f2i.js";import{l as F,o as We}from"./stringUtils-CbS6OkmE.js";import{Ct as Ge,bn as Ke,vn as qe,yn as Je}from"./prompt-CybUvG8G.js";import{i as Ye,n as Xe}from"./mappers-xQC-Z4-h.js";function I(e,t,n=1e3,r=0,i){let a=()=>He(Math.max(0,(i??Date.now())-e-r));return(0,Ze.useSyncExternalStore)((0,Ze.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var Ze,L=t((()=>{Ze=n(k(),1),P()}));function Qe(e,t,n){let r=qe(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,$e.jsxs)(D,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var $e,et=t((()=>{k(),A(),Ke(),$e=M()}));function tt(e,t){let{isIdle:n,awaitingApproval:r,hasError:i,shutdownRequested:o}=t??{};return i?a.cross:r?a.questionMarkPrefix:o?a.warning:e===`running`?n?a.ellipsis:a.play:e===`completed`?a.tick:e===`failed`||e===`killed`?a.cross:a.bullet}function nt(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 rt(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(ve(t))return n=!0,!1;return n}var it=t((()=>{i(),me()}));function at({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=Oe(),a=(0,ot.useMemo)(()=>x(Je()),[]),o=I(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);T({"confirm:yes":t},{context:`Confirmation`});let s=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},c=p(e.prompt,`plan`),l=e.prompt.length>300?e.prompt.substring(0,297)+`…`:e.prompt,u=e.result?.totalTokens??e.progress?.tokenCount,d=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,R.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:(0,R.jsx)(j,{title:(0,R.jsxs)(D,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,R.jsxs)(D,{children:[e.status!==`running`&&(0,R.jsxs)(D,{color:nt(e.status),children:[tt(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,R.jsxs)(D,{dimColor:!0,children:[o,u!==void 0&&u>0&&(0,R.jsxs)(R.Fragment,{children:[` · `,Ve(u),` tokens`]}),d!==void 0&&d>0&&(0,R.jsxs)(R.Fragment,{children:[` `,`· `,d,` `,d===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,R.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,R.jsxs)(O,{children:[r&&(0,R.jsx)(w,{shortcut:`←`,action:`go back`}),(0,R.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,R.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:(0,R.jsxs)(E,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,R.jsxs)(E,{flexDirection:`column`,children:[(0,R.jsx)(D,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,R.jsxs)(D,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,Qe(t,a,i)]},n))]}),c?(0,R.jsx)(E,{marginTop:1,children:(0,R.jsx)(Ce,{addMargin:!1,planContent:c})}):(0,R.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,R.jsx)(D,{bold:!0,dimColor:!0,children:`Prompt`}),(0,R.jsx)(D,{wrap:`wrap`,children:l})]}),e.status===`failed`&&e.error&&(0,R.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,R.jsx)(D,{bold:!0,color:`error`,children:`Error`}),(0,R.jsx)(D,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var ot,R,st=t((()=>{ot=n(k(),1),L(),A(),s(),Ke(),ne(),P(),d(),pe(),et(),it(),R=M()}));function ct(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 lt({text:e,phase:t=0}){return(0,z.jsx)(z.Fragment,{children:[...e].map((e,n)=>(0,z.jsx)(D,{color:c(n+t),children:e},n))})}function ut(e,t,n){let r=(0,pt.useRef)(e),i=(0,pt.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 dt({session:e}){let t=ae().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=Ae(r&&!t?mt:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,l=ut(a,i,c),u=ut(o,i,c),d=ut(s,i,c),f=Math.floor(i/(mt*3))%7;if(e.status===`completed`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(D,{color:`background`,children:[`◆`,` `]}),(0,z.jsx)(lt,{text:`ultrareview`,phase:0}),(0,z.jsx)(D,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(D,{color:`background`,children:[`◆`,` `]}),(0,z.jsx)(lt,{text:`ultrareview`,phase:0}),(0,z.jsxs)(D,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let p=n?ct(n.stage,l,u,d):`setting up`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(D,{color:`background`,children:[`◇`,` `]}),(0,z.jsx)(lt,{text:`ultrareview`,phase:r?f:0}),(0,z.jsxs)(D,{dimColor:!0,children:[` · `,p]})]})}function ft({session:e}){if(e.isRemoteReview)return(0,z.jsx)(dt,{session:e});if(e.status===`completed`)return(0,z.jsx)(D,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,z.jsx)(D,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,z.jsxs)(D,{dimColor:!0,children:[e.status,`…`]});let t=Ie(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,z.jsxs)(D,{dimColor:!0,children:[t,`/`,n]})}var pt,z,mt,ht=t((()=>{pt=n(k(),1),ze(),ye(),A(),Le(),g(),z=M(),mt=80}));function B({status:e,label:t,suffix:n}){return(0,V.jsxs)(D,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function gt({shell:e}){switch(e.status){case`completed`:return(0,V.jsx)(B,{status:`completed`,label:`done`});case`failed`:return(0,V.jsx)(B,{status:`failed`,label:`error`});case`killed`:return(0,V.jsx)(B,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,V.jsx)(B,{status:`running`})}}var V,_t=t((()=>{A(),V=M()}));function vt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,H.jsxs)(D,{children:[N(e.kind===`monitor`?e.description:e.command,n,!0),` `,(0,H.jsx)(gt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,H.jsx)(D,{children:(0,H.jsx)(ft,{session:e})}):(0,H.jsxs)(D,{children:[(0,H.jsxs)(D,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),N(e.title,n,!0),(0,H.jsx)(D,{dimColor:!0,children:` · `}),(0,H.jsx)(ft,{session:e})]});case`local_agent`:return(0,H.jsxs)(D,{children:[N(e.description,n,!0),` `,(0,H.jsx)(B,{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,H.jsxs)(D,{children:[N(t.workflowName??e.summary??e.description,n,!0),` `,(0,H.jsx)(B,{status:e.status,label:e.status===`running`?`${t.agentCount} ${F(t.agentCount,`agent`)}`:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}case`monitor_mcp`:return(0,H.jsxs)(D,{children:[N(e.description,n,!0),` `,(0,H.jsx)(B,{status:e.status,label: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} ${F(t,`file`)}`:`${e.sessionsReviewing} ${F(e.sessionsReviewing,`session`)}`;return(0,H.jsxs)(D,{children:[e.description,` `,(0,H.jsxs)(D,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,H.jsx)(B,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var H,yt=t((()=>{k(),A(),P(),We(),ze(),ht(),_t(),H=M()}));function bt({task:e,onDone:t,onBack:n,onKill:r}){let i=I(e.startTime,e.status===`running`,1e3,0);T({"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,U.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,U.jsx)(j,{title:`Memory consolidation`,subtitle:(0,U.jsxs)(D,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,F(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,U.jsxs)(U.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,F(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,U.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,U.jsxs)(O,{children:[n&&(0,U.jsx)(w,{shortcut:`←`,action:`go back`}),(0,U.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,U.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:(0,U.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,U.jsxs)(D,{children:[(0,U.jsx)(D,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,U.jsx)(D,{color:`background`,children:`running`}):e.status===`completed`?(0,U.jsx)(D,{color:`success`,children:e.status}):(0,U.jsx)(D,{color:`error`,children:e.status})]}),s.length===0?(0,U.jsx)(D,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,U.jsxs)(U.Fragment,{children:[c>0&&(0,U.jsxs)(D,{dimColor:!0,children:[`(`,c,` earlier `,F(c,`turn`),`)`]}),s.map((e,t)=>(0,U.jsxs)(E,{flexDirection:`column`,children:[(0,U.jsx)(D,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,U.jsxs)(D,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,F(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var U,xt=t((()=>{k(),L(),A(),s(),We(),U=M()}));function St({stage:e,completed:t,hasProgress:n}){let r=e?Et.indexOf(e):-1,i=!t&&!n;return(0,G.jsxs)(D,{children:[i?(0,G.jsx)(D,{color:`background`,children:`Setup`}):(0,G.jsx)(D,{dimColor:!0,children:`Setup`}),(0,G.jsx)(D,{dimColor:!0,children:` → `}),Et.map((e,n)=>{let a=!t&&!i&&n===r;return(0,G.jsxs)(W.Fragment,{children:[n>0&&(0,G.jsx)(D,{dimColor:!0,children:` → `}),a?(0,G.jsx)(D,{color:`background`,children:Dt[e]}):(0,G.jsx)(D,{dimColor:!0,children:Dt[e]})]},e)}),t&&(0,G.jsx)(D,{color:`success`,children:` ✓`})]})}function Ct(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} ${F(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return ct(t.stage,t.bugsFound,n,r)}function wt({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,a=e.status===`running`||e.status===`pending`,[o,s]=(0,W.useState)(!1),c=I(e.startTime,a,1e3,0,e.endTime),l=()=>t(`Remote session details dismissed`,{display:`system`}),u=n??l,d=we(e.sessionId),f=i?`ready`:a?`running`:e.status;if(o)return(0,G.jsx)(j,{title:`Stop ultrareview?`,onCancel:()=>s(!1),color:`background`,children:(0,G.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,G.jsx)(D,{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,G.jsx)(b,{options:[{label:`Stop ultrareview`,value:`stop`},{label:`Back`,value:`back`}],onChange:e=>{e===`stop`?(r?.(),u()):s(!1)}})]})});let p=i?[{label:`Open in Claude Code on the web`,value:`open`},{label:`Dismiss`,value:`dismiss`}]:[{label:`Open in Claude Code on the web`,value:`open`},...r&&a?[{label:`Stop ultrareview`,value:`stop`}]:[],{label:`Back`,value:`back`}];return(0,G.jsx)(j,{title:(0,G.jsxs)(D,{children:[(0,G.jsxs)(D,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,G.jsx)(D,{bold:!0,children:`ultrareview`}),(0,G.jsxs)(D,{dimColor:!0,children:[` · `,c,` · `,f]})]}),onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,G.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,G.jsxs)(O,{children:[(0,G.jsx)(w,{shortcut:`Enter`,action:`select`}),(0,G.jsx)(w,{shortcut:`Esc`,action:`go back`})]}),children:(0,G.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,G.jsx)(St,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,G.jsxs)(E,{flexDirection:`column`,children:[(0,G.jsx)(D,{children:Ct(e)}),(0,G.jsx)(ke,{url:d,children:(0,G.jsx)(D,{dimColor:!0,children:d})})]}),(0,G.jsx)(b,{options:p,onChange:e=>{switch(e){case`open`:v(d),t();break;case`stop`:s(!0);break;case`back`:u();break;case`dismiss`:l();break}}})]})})}function Tt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=(0,W.useMemo)(()=>e.isRemoteReview?[]:he(Ye(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,G.jsx)(wt,{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 De(e.sessionId)}catch(e){c(Me(e))}finally{o(!1)}}let p=Be(e.title,50),m=e.status===`pending`?`starting`:e.status;return(0,G.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:(0,G.jsxs)(j,{title:`Remote session details`,onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,G.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,G.jsxs)(O,{children:[r&&(0,G.jsx)(w,{shortcut:`←`,action:`go back`}),(0,G.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,G.jsx)(w,{shortcut:`t`,action:`teleport`})]}),children:[(0,G.jsxs)(E,{flexDirection:`column`,children:[(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Status`}),`:`,` `,m===`running`||m===`starting`?(0,G.jsx)(D,{color:`background`,children:m}):m===`completed`?(0,G.jsx)(D,{color:`success`,children:m}):(0,G.jsx)(D,{color:`error`,children:m})]}),(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Runtime`}),`: `,He((e.endTime??Date.now())-e.startTime)]}),(0,G.jsxs)(D,{wrap:`truncate-end`,children:[(0,G.jsx)(D,{bold:!0,children:`Title`}),`: `,p]}),(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Progress`}),`: `,(0,G.jsx)(ft,{session:e})]}),(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Session URL`}),`:`,` `,(0,G.jsx)(ke,{url:we(e.sessionId),children:(0,G.jsx)(D,{dimColor:!0,children:we(e.sessionId)})})]})]}),e.log.length>0&&(0,G.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Recent messages`}),`:`]}),(0,G.jsx)(E,{flexDirection:`column`,height:10,overflowY:`hidden`,children:l.map((e,n)=>(0,G.jsx)(h,{message:e,lookups:fe,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,G.jsx)(E,{marginTop:1,children:(0,G.jsxs)(D,{dimColor:!0,italic:!0,children:[`Showing last `,l.length,` of `,e.log.length,` messages`]})})]}),s&&(0,G.jsx)(E,{marginTop:1,children:(0,G.jsxs)(D,{color:`error`,children:[`Teleport failed: `,s]})}),a&&(0,G.jsx)(D,{color:`background`,children:`Teleporting to session…`})]})})}var W,G,Et,Dt,Ot=t((()=>{W=n(k(),1),ze(),L(),A(),S(),Ge(),oe(),Fe(),P(),Xe(),d(),We(),ie(),te(),f(),ht(),G=M(),Et=[`finding`,`verifying`,`synthesizing`],Dt={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function kt(e){let t=le(e.id);try{let e=await Pe(t,Mt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function At({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=je(),[a,o]=(0,K.useState)(()=>kt(e)),s=(0,K.useDeferredValue)(a);(0,K.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(kt(t)),1e3,o,e);return()=>clearInterval(t)},[e.id,e.status]);let c=()=>t(`Shell details dismissed`,{display:`system`});T({"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=e.kind===`monitor`,d=Be(e.command,280);return(0,q.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,q.jsxs)(j,{title:u?`Monitor details`:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,q.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,q.jsxs)(O,{children:[r&&(0,q.jsx)(w,{shortcut:`←`,action:`go back`}),(0,q.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,q.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:[(0,q.jsxs)(E,{flexDirection:`column`,children:[(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,q.jsxs)(D,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,q.jsxs)(D,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,q.jsxs)(D,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Runtime:`}),` `,He((e.endTime??Date.now())-e.startTime)]}),(0,q.jsxs)(D,{wrap:`wrap`,children:[(0,q.jsx)(D,{bold:!0,children:u?`Script:`:`Command:`}),` `,d]})]}),(0,q.jsxs)(E,{flexDirection:`column`,children:[(0,q.jsx)(D,{bold:!0,children:`Output:`}),(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(D,{dimColor:!0,children:`Loading output…`}),children:(0,q.jsx)(jt,{outputPromise:s,columns:i})})]})]})})}function jt({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,K.use)(e);if(!n)return(0,q.jsx)(D,{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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,q.jsx)(D,{wrap:`truncate-end`,children:e},t))}),(0,q.jsxs)(D,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Ue(r)}`:``]})]})}var K,q,Mt,Nt=t((()=>{K=n(k(),1),_e(),A(),s(),P(),Ne(),C(),q=M(),Mt=8192})),Pt=t((()=>{A()})),Ft=t((()=>{A()})),It=t((()=>{A()})),Lt=r({MonitorMcpDetailDialog:()=>Rt});function Rt({task:e,onBack:t,onKill:n}){let r=I(e.startTime,e.status===`running`,1e3,0);return T({},{context:`MonitorMcpDetail`}),(0,J.jsx)(E,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:r=>{r.key===`left`&&t?(r.preventDefault(),t()):r.key===`x`&&e.status===`running`&&n&&(r.preventDefault(),n())},children:(0,J.jsx)(j,{title:`MCP Monitor`,subtitle:(0,J.jsxs)(D,{dimColor:!0,children:[r,` · `,e.serverName,`:`,e.resourceUri]}),onCancel:t??(()=>{}),inputGuide:()=>(0,J.jsxs)(O,{children:[t&&(0,J.jsx)(w,{shortcut:`←`,action:`go back`}),(0,J.jsx)(w,{shortcut:`Esc`,action:`close`}),e.status===`running`&&n&&(0,J.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:(0,J.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,J.jsxs)(D,{children:[(0,J.jsx)(D,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,J.jsx)(D,{color:`ansi:green`,children:`running`}):e.status===`completed`?(0,J.jsx)(D,{color:`ansi:green`,children:e.status}):(0,J.jsx)(D,{color:`ansi:red`,children:e.status})]}),(0,J.jsxs)(D,{children:[(0,J.jsx)(D,{bold:!0,children:`Description:`}),` `,e.description]}),(0,J.jsxs)(D,{children:[(0,J.jsx)(D,{bold:!0,children:`Server:`}),` `,e.serverName]}),(0,J.jsxs)(D,{children:[(0,J.jsx)(D,{bold:!0,children:`Resource:`}),` `,e.resourceUri]}),e.command&&(0,J.jsxs)(D,{children:[(0,J.jsx)(D,{bold:!0,children:`Command:`}),` `,e.command]})]})})})}var J,zt=t((()=>{k(),L(),A(),s(),Pt(),Ft(),It(),J=M()}));function Bt(e,t){return Object.values(e??{}).filter(ve).filter(e=>!(e.type===`local_agent`&&e.id===t))}function Vt({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=xe(e=>e.tasks),i=xe(e=>e.foregroundedTaskId),a=de(),o=u(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),s=r,c=(0,X.useRef)(!1),[d,f]=(0,X.useState)(()=>{if(n)return c.current=!0,{mode:`detail`,itemId:n};let e=Bt(s,i);return e.length===1?(c.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[p,m]=(0,X.useState)(0);Te(`background-tasks-dialog`);let{bashTasks:h,remoteSessions:g,agentTasks:_,workflowTasks:v,mcpMonitors:y,dreamTasks:b,allSelectableItems:x}=(0,X.useMemo)(()=>{let e=Object.values(s??{}).filter(ve).map(Ht).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===`monitor_mcp`),c=e.filter(e=>e.type===`dream`);return{bashTasks:t,remoteSessions:n,agentTasks:r,workflowTasks:a,mcpMonitors:o,dreamTasks:c,allSelectableItems:[...t,...o,...n,...r,...a,...c]}},[s,i]),S=x[p]??null;T({"confirm:previous":()=>m(e=>Math.max(0,e-1)),"confirm:next":()=>m(e=>Math.min(x.length-1,e+1)),"confirm:yes":()=>{let e=x[p];e&&f({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:d.mode===`list`});let te=t=>{if(d.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=x[p];n&&t.key===`x`&&(t.preventDefault(),n.type===`local_bash`&&n.status===`running`?ne(n.id):n.type===`local_agent`&&n.status===`running`?re(n.id):n.type===`local_workflow`&&n.status===`running`&&Q?Q(n.id,a):n.type===`monitor_mcp`&&n.status===`running`&&$?$(n.id,a):n.type===`dream`&&n.status===`running`?ie(n.id):n.type===`remote_agent`&&n.status===`running`&&ae(n.id))};async function ne(e){await se.kill(e,a)}async function re(e){await ee.kill(e,a)}async function ie(e){await l.kill(e,a)}async function ae(e){await ue.kill(e,a)}let oe=(0,X.useEffectEvent)(e);(0,X.useEffect)(()=>{if(d.mode!==`list`){let e=(s??{})[d.itemId];(!e||e.type!==`local_workflow`&&!ve(e))&&(c.current?oe(`Background tasks dialog dismissed`,{display:`system`}):f({mode:`list`}))}let e=x.length;p>=e&&e>0&&m(e-1)},[d,s,p,x,oe]);let C=()=>{c.current&&x.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(c.current=!1,f({mode:`list`}))};if(d.mode!==`list`&&s){let n=s[d.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,Z.jsx)(At,{shell:n,onDone:e,onKillShell:()=>void ne(n.id),onBack:C},`shell-${n.id}`);case`local_agent`:return(0,Z.jsx)(at,{agent:n,onDone:e,onKillAgent:()=>void re(n.id),onBack:C},`agent-${n.id}`);case`remote_agent`:return(0,Z.jsx)(Tt,{session:n,onDone:e,toolUseContext:t,onBack:C,onKill:n.status===`running`?()=>void ae(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`&&Q?()=>Q(n.id,a):void 0;return(0,Z.jsx)(E,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),C()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,Z.jsx)(j,{title:n.workflowName,subtitle:(0,Z.jsxs)(D,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:C,inputGuide:()=>(0,Z.jsxs)(O,{children:[(0,Z.jsx)(w,{shortcut:`←`,action:`go back`}),(0,Z.jsx)(w,{shortcut:`Esc`,action:`close`}),e&&(0,Z.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,Z.jsxs)(E,{flexDirection:`column`,children:[(0,Z.jsxs)(D,{color:`error`,children:[`失败原因:`,n.error]}),(0,Z.jsx)(D,{color:`subtle`,children:`用 /workflows 查看阶段与 agent 实时进度`})]}):(0,Z.jsx)(D,{color:`subtle`,children:`用 /workflows 查看阶段与 agent 实时进度`})})},`workflow-${n.id}`)}case`monitor_mcp`:return Ut?(0,Z.jsx)(Ut,{task:n,onKill:n.status===`running`&&$?()=>$(n.id,a):void 0,onBack:C},`monitor-mcp-${n.id}`):null;case`dream`:return(0,Z.jsx)(bt,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:C,onKill:n.status===`running`?()=>void ie(n.id):void 0},`dream-${n.id}`)}}let ce=Ie(h,e=>e.status===`running`),le=Ie(g,e=>e.status===`running`||e.status===`pending`)+Ie(_,e=>e.status===`running`),fe=Re([...ce>0?[(0,Z.jsxs)(D,{children:[ce,` `,ce===1?`active shell`:`active shells`]},`shells`)]:[],...le>0?[(0,Z.jsxs)(D,{children:[le,` `,le===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,Z.jsx)(D,{children:` · `},`separator-${e}`)),pe=[(0,Z.jsx)(w,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,Z.jsx)(w,{shortcut:`Enter`,action:`view`},`enter`),...(S?.type===`local_bash`||S?.type===`local_agent`||S?.type===`local_workflow`||S?.type===`monitor_mcp`||S?.type===`dream`||S?.type===`remote_agent`)&&S.status===`running`?[(0,Z.jsx)(w,{shortcut:`x`,action:`stop`},`kill`)]:[],..._.some(e=>e.status===`running`)?[(0,Z.jsx)(w,{shortcut:o,action:`stop all agents`},`kill-all`)]:[],(0,Z.jsx)(w,{shortcut:`←/Esc`,action:`close`},`esc`)],me=()=>e(`Background tasks dialog dismissed`,{display:`system`});function he(e){return e.pending?(0,Z.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(O,{children:pe})}return(0,Z.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:te,children:(0,Z.jsx)(j,{title:`Background tasks`,subtitle:(0,Z.jsx)(Z.Fragment,{children:fe}),onCancel:me,color:`background`,inputGuide:he,children:x.length===0?(0,Z.jsx)(D,{dimColor:!0,children:`No tasks currently running`}):(0,Z.jsxs)(E,{flexDirection:`column`,children:[h.length>0&&(0,Z.jsxs)(E,{flexDirection:`column`,children:[(g.length>0||_.length>0)&&(0,Z.jsxs)(D,{dimColor:!0,children:[(0,Z.jsxs)(D,{bold:!0,children:[` `,`Shells`]}),` (`,h.length,`)`]}),(0,Z.jsx)(E,{flexDirection:`column`,children:h.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})]}),y.length>0&&(0,Z.jsxs)(E,{flexDirection:`column`,marginTop:+(h.length>0),children:[(0,Z.jsxs)(D,{dimColor:!0,children:[(0,Z.jsxs)(D,{bold:!0,children:[` `,`Monitors`]}),` (`,y.length,`)`]}),(0,Z.jsx)(E,{flexDirection:`column`,children:y.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})]}),g.length>0&&(0,Z.jsxs)(E,{flexDirection:`column`,marginTop:+(h.length>0||y.length>0),children:[(0,Z.jsxs)(D,{dimColor:!0,children:[(0,Z.jsxs)(D,{bold:!0,children:[` `,`Remote agents`]}),` (`,g.length,`)`]}),(0,Z.jsx)(E,{flexDirection:`column`,children:g.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})]}),_.length>0&&(0,Z.jsxs)(E,{flexDirection:`column`,marginTop:+(h.length>0||y.length>0||g.length>0),children:[(0,Z.jsxs)(D,{dimColor:!0,children:[(0,Z.jsxs)(D,{bold:!0,children:[` `,`Local agents`]}),` (`,_.length,`)`]}),(0,Z.jsx)(E,{flexDirection:`column`,children:_.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})]}),v.length>0&&(0,Z.jsxs)(E,{flexDirection:`column`,marginTop:+(h.length>0||y.length>0||g.length>0||_.length>0),children:[(0,Z.jsxs)(D,{dimColor:!0,children:[(0,Z.jsxs)(D,{bold:!0,children:[` `,`Workflows`]}),` (`,v.length,`)`]}),(0,Z.jsx)(E,{flexDirection:`column`,children:v.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})]}),b.length>0&&(0,Z.jsx)(E,{flexDirection:`column`,marginTop:+(h.length>0||y.length>0||g.length>0||_.length>0||v.length>0),children:(0,Z.jsx)(E,{flexDirection:`column`,children:b.map(e=>(0,Z.jsx)(Y,{item:e,isSelected:e.id===S?.id},e.id))})})]})})})}function Ht(e){switch(e.type){case`local_bash`:return{id:e.id,type:`local_bash`,label:e.kind===`monitor`?e.description: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`monitor_mcp`:return{id:e.id,type:`monitor_mcp`,label:e.description,status:e.status,task:e};case`dream`:return{id:e.id,type:`dream`,label:e.description,status:e.status,task:e}}}function Y({item:e,isSelected:t}){let{columns:n}=je(),r=Math.max(30,n-26);return(0,Z.jsxs)(E,{flexDirection:`row`,children:[(0,Z.jsx)(D,{children:t?a.pointer+` `:` `}),(0,Z.jsx)(D,{color:t?`suggestion`:void 0,children:(0,Z.jsx)(vt,{task:e.task,maxActivityWidth:r})})]})}var X,Z,Q,$,Ut,Wt=t((()=>{i(),X=n(k(),1),_e(),ge(),ce(),_(),Se(),S(),me(),Le(),re(),A(),s(),o(),st(),yt(),xt(),Ot(),Nt(),Z=M(),Q=(y(),e(be))?.killWorkflowTask??null,$=(m(),e(Ee))?.killMonitorMcp??null,Ut=(zt(),e(Lt)).MonitorMcpDetailDialog}));export{L as a,rt as i,Wt as n,I as o,it as r,Vt as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./ClaudeMdExternalIncludesDialog-CDrArsSX.js";e();export{t as ClaudeMdExternalIncludesDialog};
@@ -1 +0,0 @@
1
- import{bd as e,yd as t}from"./loadAgentsDir-CKSb56Gp.js";e();export{t as ConsoleOAuthFlow};
@@ -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{Av as o,Ax as s,Ew as c,Fg as l,Fw as u,Ig as d,Ix as f,Mv as p,Mw as m,Nv as h,Nw as g,Nx as _,Pv as ee,Pw as v,Px as y,aE as b,cE as x,eD as te,eu as ne,fa as S,jv as re,nu as ie,ov as ae,pa as C,sv as w,tD as T,tu as oe}from"./loadAgentsDir-CKSb56Gp.js";import{Gt as se,I as E,P as D,fi as O,t as k,x as A}from"./src-P_wYS_NJ2.js";import{t as j}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as ce,tt as le}from"./state-Bs5xweDL.js";import{Cn as M,H as N,On as P,g as F,n as I,z as L}from"./settings-Xbq6AaD-.js";import{l as R,o as z}from"./stringUtils-CbS6OkmE.js";import{Kn as B,Un as V,_ as H,u as U}from"./model-C2e73CJD.js";import{n as W,t as ue}from"./ValidationErrorsList-De3kzHtz.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-BR5M6RQw.js";import{a as ye,i as be}from"./xdg-DcF9ejUM.js";import{n as xe,t as Se}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import{n as Ce,t as we}from"./McpParsingWarnings-CH4yyMAL.js";import{n as Te,t as Ee}from"./PressEnterToContinue-Dq0Imo9c.js";import{n as De,t as Oe}from"./useSettingsErrors-DKh4rkGi.js";import{n as ke,t as Ae}from"./shadowedRuleDetection-B9iSx6mB.js";import{n as je,r as Me,t as K}from"./statusNoticeHelpers-DMqRGFOh.js";import{join as q}from"path";function Ne(){if(!u())return null;let e=m();if(e.length===0)return null;let t=e.filter(e=>e.severity===`error`),n=e.filter(e=>e.severity===`warning`);return(0,J.jsxs)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(D,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`Location: `}),(0,J.jsx)(D,{dimColor:!0,children:g()})]}),(0,J.jsxs)(E,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`error`,children:`[Error]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,Pe=e((()=>{O(),k(),v(),J=j()}));function Fe(){if(!b.isSupportedPlatform()||!b.isSandboxEnabledInSettings())return null;let e=b.checkDependencies(),t=e.errors.length>0,n=e.warnings.length>0;return!t&&!n?null:(0,Y.jsxs)(E,{flexDirection:`column`,children:[(0,Y.jsx)(D,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(D,{children:[`└ Status: `,(0,Y.jsx)(D,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(D,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(D,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(D,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,Ie=e((()=>{O(),k(),x(),Y=j()}));async function Le(){let e=_(await y());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 > ${s.toLocaleString()})`:`${e.length} large CLAUDE.md files detected (each > ${s.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:s}}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:C(t)}}).sort((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>`${e.name}: ~${e.tokens.toLocaleString()} tokens`);return n.length>5&&r.push(`(${n.length-5} more custom agents)`),{type:`agent_descriptions`,severity:`warning`,message:`Large agent descriptions (~${t.toLocaleString()} tokens > ${K.toLocaleString()})`,details:r,currentValue:t,threshold:K}}async function Re(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await l(e,t,n,U());if(r<=Z)return null;let a=new Map;for(let e of i){let t=e.name.split(`__`)[1]||`unknown`,n=a.get(t)||{count:0,tokens:0};a.set(t,{count:n.count+1,tokens:n.tokens+e.tokens})}let o=Array.from(a.entries()).sort((e,t)=>t[1].tokens-e[1].tokens),s=o.slice(0,5).map(([e,t])=>`${e}: ${t.count} tools (~${t.tokens.toLocaleString()} tokens)`);return o.length>5&&s.push(`(${o.length-5} more servers)`),{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${r.toLocaleString()} tokens > ${Z.toLocaleString()})`,details:s,currentValue:r,threshold:Z}}catch{let e=r.reduce((e,t)=>e+C(((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:b.isSandboxingEnabled()&&b.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((()=>{S(),d(),f(),H(),L(),ke(),x(),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)(D,{children:[`└ Stable version: `,t.stable]}),(0,$.jsxs)(D,{children:[`└ Latest version: `,t.latest]})]}):(0,$.jsx)(D,{dimColor:!0,children:`└ Failed to fetch versions`})}function Ue({onDone:e}){let t=w(e=>e.agentDefinitions),r=w(e=>e.mcp.tools),i=w(e=>e.toolPermissionContext),s=w(e=>e.plugins.errors);xe();let c=(0,Q.useMemo)(()=>r||[],[r]),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),_=De(),v=(0,Q.useMemo)(()=>G().then(e=>(e.installationType===`native`?fe:he)().catch(()=>({latest:null,stable:null}))),[]),y=I()?.autoUpdatesChannel??`latest`,b=_.filter(e=>e.mcpErrorMetadata===void 0),x=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:o,upperLimit:re},{name:`TASK_MAX_OUTPUT_LENGTH`,default:ne,upperLimit:oe},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...V(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=ee(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{G().then(u),(async()=>{let e=q(n(),`agents`),r=q(le(),`.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};f(d);let p=await Be(c,{activeAgents:a,allAgents:o,failedFiles:s},async()=>i);if(m(p),_e()){let e=q(be(),`claude`,`locks`),t=ge(e),n=ve(e);g({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else g({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,c,t]);let S=(0,Q.useCallback)(()=>{e(`Claude Code diagnostics dismissed`,{display:`system`})},[e]);return se({"confirm:yes":S,"confirm:no":S},{context:`Confirmation`}),l?(0,$.jsxs)(A,{children:[(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(D,{children:[`└ Currently running: `,l.installationType,` (`,l.version,`)`]}),l.packageManager&&(0,$.jsxs)(D,{children:[`└ Package manager: `,l.packageManager]}),(0,$.jsxs)(D,{children:[`└ Path: `,l.installationPath]}),(0,$.jsxs)(D,{children:[`└ Invoked: `,l.invokedBinary]}),(0,$.jsxs)(D,{children:[`└ Config install method: `,l.configInstallMethod]}),(0,$.jsxs)(D,{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)(D,{color:`warning`,children:[`└ Note: `,l.ripgrepStatus.note]}),l.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsxs)(D,{color:`warning`,children:[`Recommendation: `,l.recommendation.split(`
2
- `)[0]]}),(0,$.jsx)(D,{dimColor:!0,children:l.recommendation.split(`
3
- `)[1]})]}),l.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsx)(D,{color:`warning`,children:`Warning: Multiple installations found`}),l.multipleInstallations.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.type,` at `,e.path]},t))]}),l.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),l.warnings.map((e,t)=>(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsxs)(D,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(D,{children:[`Fix: `,e.fix]})]},t))]}),b.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(D,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(ue,{errors:b})]})]}),(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Updates`}),(0,$.jsxs)(D,{children:[`└ Auto-updates: `,l.packageManager?`Managed by package manager`:l.autoUpdates]}),l.hasUpdatePermissions!==null&&(0,$.jsxs)(D,{children:[`└ Update permissions: `,l.hasUpdatePermissions?`Yes`:`No (requires sudo)`]}),(0,$.jsxs)(D,{children:[`└ Auto-update channel: `,y]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(He,{promise:v})})]}),(0,$.jsx)(Fe,{}),(0,$.jsx)(we,{}),(0,$.jsx)(Ne,{}),x.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Environment Variables`}),x.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(D,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),h?.enabled&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Version Locks`}),h.staleLocksCleaned>0&&(0,$.jsxs)(D,{dimColor:!0,children:[`└ Cleaned `,h.staleLocksCleaned,` stale lock(s)`]}),h.locks.length===0?(0,$.jsx)(D,{dimColor:!0,children:`└ No active version locks`}):h.locks.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(D,{children:`(running)`}):(0,$.jsx)(D,{color:`warning`,children:`(stale)`})]},t))]}),d?.failedFiles&&d.failedFiles.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ Failed to parse `,d.failedFiles.length,` agent file(s):`]}),d.failedFiles.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),s.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ `,s.length,` plugin error(s) detected:`]}),s.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,te(e)]},t))]}),p?.unreachableRulesWarning&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.unreachableRulesWarning.message]})]}),p.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p&&(p.claudeMdWarning||p.agentWarning||p.mcpWarning)&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Context Usage Warnings`}),p.claudeMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.claudeMdWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Files:`]}),p.claudeMdWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.agentWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Top contributors:`]}),p.agentWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.mcpWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ MCP servers:`]}),p.mcpWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(E,{children:(0,$.jsx)(Ee,{})})]}):(0,$.jsx)(A,{children:(0,$.jsx)(D,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,We=e((()=>{i(),Q=t(O(),1),Pe(),Ce(),B(),r(),ce(),k(),Te(),Ie(),W(),Oe(),Se(),c(),ae(),T(),pe(),Ve(),de(),h(),M(),me(),F(),p(),ie(),ye(),$=j()}));export{We as n,Ue as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./Doctor-D160J8Ad.js";e();export{t as Doctor};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{Ar as r,Dt as i,FT as a,Ot as o,PT as s,SE as c,St as l,Ti as u,Tt as d,Vu as f,bv as p,dd as m,fd as h,ff as g,ht as _,uf as v,xE as y,xv as b,zu as x}from"./loadAgentsDir-CKSb56Gp.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-BdqxZ7rV.js";import{r as A,t as j}from"./execFileNoThrow-5SylUnAI.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(r(),e(u)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,r]=(0,I.useState)(`loading`),[a,c]=(0,I.useState)([]),[u,d]=(0,I.useState)(0),[f,p]=(0,I.useState)(),h=l();if((0,I.useEffect)(()=>{async function e(){let e=[],t=await j(`git`,[`status`,`--porcelain`]);if(t.stdout&&(e=t.stdout.split(`
2
- `).filter(e=>e.trim()!==``),c(e)),h){let{stdout:t}=await j(`git`,[`rev-list`,`--count`,`${h.originalHeadCommit}..HEAD`]),n=parseInt(t.trim(),10)||0;if(d(n),e.length===0&&n===0){r(`removing`),_().then(()=>{process.chdir(h.originalCwd),b(h.originalCwd),P(),s.cache.clear?.(),p(`Worktree removed (no changes)`)}).catch(e=>{k(`Failed to clean up worktree: ${e}`,{level:`error`}),p(`Worktree cleanup failed, exiting anyway`)}).then(()=>{r(`done`)});return}else r(`asking`)}}e()},[h]),(0,I.useEffect)(()=>{n===`done`&&e(f)},[n,e,f]),!h)return e(`No active worktree session found`,{display:`system`}),null;if(n===`loading`||n===`done`)return null;async function g(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:a.length}),await i(),process.chdir(h.originalCwd),b(h.originalCwd),P(),s.cache.clear?.(),p(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:a.length}),h.tmuxSessionName&&await o(h.tmuxSessionName),await i(),process.chdir(h.originalCwd),b(h.originalCwd),P(),s.cache.clear?.(),p(`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:a.length}),h.tmuxSessionName&&await o(h.tmuxSessionName);try{await _(),process.chdir(h.originalCwd),b(h.originalCwd),P(),s.cache.clear?.()}catch(e){k(`Failed to clean up worktree: ${e}`,{level:`error`}),p(`Worktree cleanup failed, exiting anyway`),r(`done`);return}let e=t?` Tmux session terminated.`:``;u>0&&a.length>0?p(`Worktree removed. ${u} ${u===1?`commit`:`commits`} and uncommitted changes were discarded.${e}`):u>0?p(`Worktree removed. ${u} ${u===1?`commit`:`commits`} on ${h.worktreeBranch} ${u===1?`was`:`were`} discarded.${e}`):a.length>0?p(`Worktree removed. Uncommitted changes were discarded.${e}`):p(`Worktree removed.${e}`),r(`done`)}}if(n===`keeping`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(x,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(x,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let v=h.worktreeBranch,y=a.length>0,w=u>0,T=``;T=y&&w?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`} and ${u} ${u===1?`commit`:`commits`} on ${v}. All will be lost if you remove.`:y?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${u} ${u===1?`commit`:`commits`} on ${v}. The branch will be deleted if you remove the worktree.`:`You are working in a worktree. Keep it to continue working there, or remove it to clean up.`;function D(){if(t){t();return}g(`keep`)}let O=y||w?`All changes and commits will be lost.`:`Clean up the worktree directory.`,A=!!h.tmuxSessionName,M=A?[{label:`Keep worktree and tmux session`,value:`keep-with-tmux`,description:`Stays at ${h.worktreePath}. Reattach with: tmux attach -t ${h.tmuxSessionName}`},{label:`Keep worktree, kill tmux session`,value:`keep-kill-tmux`,description:`Keeps worktree at ${h.worktreePath}, terminates tmux session.`},{label:`Remove worktree and tmux session`,value:`remove-with-tmux`,description: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)(m,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:g})})}var I,L,R=t((()=>{I=n(w(),1),M(),O(),T(),A(),a(),p(),d(),h(),f(),L=D()}));function z(){return c(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await v(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{y(),w(),g(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
@@ -1 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{CE as r,CS as i,CT as a,EC as o,ES as s,LC as c,MC as l,NC as u,OC as d,RC as f,ST as p,TC as m,TS as h,VC as g,_S as _,bS as v,cf as y,cv as ee,fC as te,gS as b,lf as ne,lv as x,mS as S,oC as C,ov as w,sv as T,vS as E,vT as re,wC as ie,wE as D,xS as O,yC as k,yT as ae,zC as oe}from"./loadAgentsDir-CKSb56Gp.js";import{fi as A}from"./src-P_wYS_NJ2.js";import{t as j}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as se,mt as ce}from"./state-Bs5xweDL.js";import{F as M,a as le,l as ue,z as N}from"./debug-BdqxZ7rV.js";import{it as P,nt as F}from"./settings-Xbq6AaD-.js";import{c as I,l as L,o as R}from"./log-CTFl4qpD.js";import{n as z,r as B}from"./analytics-DJobLaWP.js";import{n as V,t as H}from"./omit-CLPZGevl.js";import{o as de,s as fe}from"./localSearch-CPOnyi8I.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=ee(),r=T(e=>e.authVersion),a=T(e=>e.mcp.pluginReconnectKey),l=x(),h=(0,G.useRef)(new Map),{addNotification:g}=ne(),y=(0,G.useRef)([]),w=(0,G.useRef)(null),O=(0,G.useCallback)(()=>{w.current=null;let e=y.current;e.length!==0&&(y.current=[],l(t=>{let n=t.mcp;for(let t of e){let{tools:e,commands:r,resources:i,...a}=t,o=a.type===`disabled`||a.type===`failed`?e??[]:e,s=a.type===`disabled`||a.type===`failed`?r??[]:r,c=a.type===`disabled`||a.type===`failed`?i??[]:i,l=F(a.name),u=n.clients.findIndex(e=>e.name===a.name)===-1?[...n.clients,a]:n.clients.map(e=>e.name===a.name?a:e),d=o===void 0?n.tools:[...D(n.tools,e=>e.name?.startsWith(l)),...o],f=s===void 0?n.commands:[...D(n.commands,e=>C(e,a.name)),...s],p=c===void 0?n.resources:{...n.resources,...c.length>0?{[a.name]:c}:V(n.resources,a.name)};n={...n,clients:u,tools:d,commands:f,resources:p}}return{...t,mcp:n}}))},[l]),k=(0,G.useCallback)(e=>{y.current.push(e),w.current===null&&(w.current=setTimeout(O,16))},[O]),A=(0,G.useCallback)(({client:e,tools:t,commands:n,resources:r})=>{switch(k({...e,tools:t,commands:n,resources:r}),e.type){case`connected`:s(e.client,e.name,l),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(S(e.name,e.config).catch(()=>{ue(`Failed to invalidate the server cache: ${e.name}`)}),u(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=h.current.get(e.name);r&&(clearTimeout(r),h.current.delete(e.name)),(async()=>{for(let t=1;t<=q;t++){if(u(e.name)){I(e.name,`Server disabled during reconnection, stopping retry`),h.current.delete(e.name);return}k({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:q});let r=Date.now();try{let a=await i(e.name,e.config),o=Date.now()-r;if(a.client.type===`connected`){I(e.name,`${n} reconnection successful after ${o}ms (attempt ${t})`),h.current.delete(e.name),A(a);return}if(I(e.name,`${n} reconnection attempt ${t} completed with status: ${a.client.type}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),h.current.delete(e.name),A(a);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`),h.current.delete(e.name),k({...e,type:`failed`});return}}let a=Math.min(J*2**(t-1),Y);I(e.name,`Scheduling reconnection attempt ${t+1} in ${a}ms`),await new Promise(t=>{let n=setTimeout(t,a);h.current.set(e.name,n)})}})()}else k({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(p,async()=>{I(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=E.cache.get(e.name);E.cache.delete(e.name);let n=await E(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}),k({...e,tools:n})}catch(t){L(e.name,`Failed to refresh tools after list_changed notification: ${M(t)}`)}}),e.capabilities?.prompts?.listChanged&&e.client.setNotificationHandler(re,async()=>{I(e.name,`Received prompts/list_changed notification, refreshing prompts`),B(`tengu_mcp_list_changed`,{type:`prompts`});try{b.cache.delete(e.name);let[t,n]=await Promise.all([b(e),Promise.resolve([])]);k({...e,commands:[...t,...n]}),K?.()}catch(t){L(e.name,`Failed to refresh prompts after list_changed notification: ${M(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(ae,async()=>{I(e.name,`Received resources/list_changed notification, refreshing resources`),B(`tengu_mcp_list_changed`,{type:`resources`});try{_.cache.delete(e.name);{let t=await _(e);k({...e,resources:t})}}catch(t){L(e.name,`Failed to refresh resources after list_changed notification: ${M(t)}`)}});break;case`needs-auth`:case`failed`:case`pending`:case`disabled`:break}},[k]),j=ce();return(0,G.useEffect)(()=>{async function n(){let{servers:n,errors:r}=t?{servers:{},errors:[]}:await d(e),i={...n,...e};W(l,r),l(e=>{let{stale:t,...n}=te(e.mcp,i);for(let e of t){let t=h.current.get(e.name);t&&(clearTimeout(t),h.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,S(e.name,e.config).catch(()=>{}))}let r=new Set(n.clients.map(e=>e.name)),a=Object.entries(i).filter(([e])=>!r.has(e)).map(([e,t])=>({name:e,type:u(e)?`disabled`:`pending`,config:t}));return a.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...a]}}})}n().catch(e=>{L(`useManageMCPConnections`,`Failed to initialize servers as pending: ${M(e)}`)})},[t,e,l,j,a]),(0,G.useEffect)(()=>{let n=!1;async function r(){let r;t||m()?r=Promise.resolve({}):(f(),r=oe());let{servers:i,errors:a}=t?{servers:{},errors:[]}:await d(e,r);if(n)return;W(l,a);let s={...i,...e},c=Object.fromEntries(Object.entries(s).filter(([e])=>!u(e)));v(A,c).catch(e=>{L(`useManageMcpConnections`,`Failed to get MCP resources: ${M(e)}`)});let p={};if(!t){if(p=o(await r).allowed,n)return;if(Object.keys(p).length>0){let{servers:e}=ie(p,s);p=e}if(Object.keys(p).length>0){l(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(p).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:u(e)?`disabled`:`pending`,config:t}));return n.length===0?e:{...e,mcp:{...e.mcp,clients:[...e.mcp.clients,...n]}}});let e=Object.fromEntries(Object.entries(p).filter(([e])=>!u(e)));v(A,e).catch(e=>{L(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${M(e)}`)})}}let h={...s,...p},g={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(h))t.scope===`enterprise`?g.enterprise++:t.scope===`user`?g.global++:t.scope===`project`?g.project++:t.scope===`local`?g.user++:t.scope===`dynamic`?g.plugin++:t.scope===`claudeai`&&g.claudeai++;B(`tengu_mcp_servers`,{...g})}return r(),()=>{n=!0}},[t,e,A,l,r,j,a]),(0,G.useEffect)(()=>{let e=h.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),w.current!==null&&(clearTimeout(w.current),w.current=null,O())}},[O]),{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=h.current.get(e);r&&(clearTimeout(r),h.current.delete(e));let a=await i(e,t.config);return A(a),a},[n,A]),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=h.current.get(e);n&&(clearTimeout(n),h.current.delete(e)),c(e,!1),t.type===`connected`&&await S(e,t.config),k({name:e,type:`disabled`,config:t.config})}else{c(e,!0),k({name:e,type:`pending`,config:t.config});let n=await i(e,t.config);A(n)}},[n,k,A])}}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(A(),1),se(),O(),a(),H(),r(),z(),l(),le(),y(),w(),N(),R(),h(),g(),P(),k(),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(A(),1),he(),Q=j(),$=(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{Ew as i,GS as a,MC as o,Sd as s,Vu as c,WS as l,_m as u,aw as ee,dC as d,dd as te,gC as ne,hC as re,iw as f,kC as p,lv as ie,mS as ae,ov as m,pC as h,pw as g,qS as oe,sC as se,sv as ce,uC as le,ud as _,vm as v,xS as y,xd as ue,yC as b,zS as de,zu as x}from"./loadAgentsDir-CKSb56Gp.js";import{D as S,H as fe,I as C,Lt as pe,P as w,T,Wt as me,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-BdqxZ7rV.js";import{et as M,it as N,tt as P}from"./settings-Xbq6AaD-.js";import{c as ye,o as F}from"./log-CTFl4qpD.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-CbS6OkmE.js";import{Bt as B,jt as Ce}from"./model-C2e73CJD.js";import{i as we,n as V,r as Te}from"./MCPConnectionManager-DPFe4hPh.js";import{n as Ee,t as H}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";function De({serverToolsCount:e,serverPromptsCount:t,serverResourcesCount:n}){let r=[];return e>0&&r.push(`tools`),n>0&&r.push(`resources`),t>0&&r.push(`prompts`),(0,U.jsxs)(C,{children:[(0,U.jsx)(w,{bold:!0,children:`Capabilities: `}),(0,U.jsx)(w,{color:`text`,children:r.length>0?(0,U.jsx)(T,{children:r}):`none`})]})}var U,Oe=e((()=>{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:o,borderless:s=!1}){let[c]=fe(),l=Ee(),{columns:ne}=_e(),[f,p]=G.useState(!1),[m,g]=G.useState(null),_=ce(e=>e.mcp),v=ie(),[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?o?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?o?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):o?.(`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}),o?.(Ae(t,e.name))}finally{O(!1)}},[Y,e.name,o]),X=G.useCallback(async()=>{await ae(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=h(t.mcp.tools,e.name),i=le(t.mcp.commands,e.name),a=d(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`,{}),o?.(`Disconnected from ${e.name}.`),F(!1),R(null),z(!1)},[e.name,e.config,e.scope,v,o]);me(`confirm:no`,()=>{k.current?.abort(),k.current=null,p(!1),b(null)},{context:`Confirmation`,isActive:f}),me(`confirm:no`,()=>{j(!1),N(null)},{context:`Confirmation`,isActive:A}),me(`confirm:no`,()=>{F(!1),R(null),z(!1)},{context:`Confirmation`,isActive:P}),ge((e,t)=>{if(t.return&&A&&Pe(),t.return&&P)if(xe)X();else{let e=`${be().CLAUDE_AI_ORIGIN}/settings/connectors`;R(e),z(!0),ee(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(_.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 ee(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){o?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.config.type,e.name,Ie,i,o]),ze=G.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;p(!0),g(null);let t=new AbortController;k.current=t;try{if(e.isAuthenticated&&e.config&&await oe(e.name,e.config,{preserveStepUpState:!0}),e.config){await a(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}.`;o?.(t)}else n.client.type===`needs-auth`?o?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):(ye(e.name,`Reconnection failed after authentication`),o?.(`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 de)&&g(e.message)}finally{p(!1),k.current=null,q(null),W(``)}},[e.isAuthenticated,e.config,e.name,o,Y,J]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await oe(e.name,e.config),L(`tengu_mcp_auth_config_clear`,{}),await ae(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=h(t.mcp.tools,e.name),i=le(t.mcp.commands,e.name),a=d(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:a}}}),o?.(`Authentication cleared for ${e.name}.`))};if(f){let t=e.config.type!==`claudeai-proxy`&&e.config.oauth?.xaa?` Authenticating via your identity provider`:` A browser window will open for authentication`;return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(x,{}),(0,K.jsx)(w,{children:t})]}),y&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:y})]}),f&&y&&Ne&&(0,K.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,K.jsx)(w,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,K.jsxs)(C,{children:[(0,K.jsxs)(w,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,K.jsx)(ue,{value:Oe,onChange:W,onSubmit:e=>{Ne(e.trim()),W(``)},cursorOffset:je,onChangeCursorOffset:Me,columns:ne-8})]})]}),(0,K.jsx)(C,{marginLeft:3,children:(0,K.jsx)(w,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(A)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(x,{}),(0,K.jsx)(w,{children:` A browser window will open for authentication`})]}),M&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:M})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(P)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Clear authentication for `,e.name]}),xe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`Find the MCP server in the browser and click "Disconnect".`}),I&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:I})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` when done.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(E)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`text`,children:[`Connecting to `,(0,K.jsx)(w,{bold:!0,children:e.name}),`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(x,{}),(0,K.jsx)(w,{children:` Establishing connection to MCP server`})]}),(0,K.jsx)(w,{dimColor:!0,children:`This may take a few moments.`})]});let $=[];return e.client.type===`disabled`&&$.push({label:`Enable`,value:`toggle-enabled`}),e.client.type===`connected`&&t>0&&$.push({label:`View tools`,value:`tools`}),e.config.type===`claudeai-proxy`?e.client.type===`connected`?$.push({label:`Clear authentication`,value:`claudeai-clear-auth`}):e.client.type!==`disabled`&&$.push({label:`Authenticate`,value:`claudeai-auth`}):(J&&($.push({label:`Re-authenticate`,value:`reauth`}),$.push({label:`Clear authentication`,value:`clear-auth`})),J||$.push({label:`Authenticate`,value:`auth`})),e.client.type!==`disabled`&&(e.client.type!==`needs-auth`&&$.push({label:`Reconnect`,value:`reconnectMcpServer`}),$.push({label:`Disable`,value:`toggle-enabled`})),$.length===0&&$.push({label:`Back`,value:`back`}),(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:s?void 0:`round`,children:[(0,K.jsx)(C,{marginBottom:1,children:(0,K.jsxs)(w,{bold:!0,children:[Z,` MCP Server`]})}),(0,K.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,K.jsxs)(w,{children:[D(`inactive`,c)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,K.jsxs)(w,{children:[D(`success`,c)(r.tick),` connected`]}):e.client.type===`pending`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,K.jsx)(w,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,K.jsxs)(w,{children:[D(`warning`,c)(r.triangleUpOutline),` needs authentication`]}):(0,K.jsxs)(w,{children:[D(`error`,c)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Auth: `}),J?(0,K.jsxs)(w,{children:[D(`success`,c)(r.tick),` authenticated`]}):(0,K.jsxs)(w,{children:[D(`error`,c)(r.cross),` not authenticated`]})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`URL: `}),(0,K.jsx)(w,{dimColor:!0,children:e.config.url})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Config location: `}),(0,K.jsx)(w,{dimColor:!0,children:se(e.scope)})]}),e.client.type===`connected`&&(0,K.jsx)(De,{serverToolsCount:t,serverPromptsCount:Fe,serverResourcesCount:_.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Tools: `}),(0,K.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),m&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsxs)(w,{color:`error`,children:[`Error: `,m]})}),$.length>0&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(te,{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);o?.(n)}catch(t){e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:!1}),o?.(Ae(t,e.name))}finally{O(!1)}break;case`toggle-enabled`:await Re();break;case`back`:i();break}},onCancel:i})})]}),(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(w,{dimColor:!0,italic:!0,children:l.pending?(0,K.jsxs)(K.Fragment,{children:[`Press `,l.keyName,` again to exit`]}):(0,K.jsxs)(T,{children:[(0,K.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,K.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,K.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var G,K,Me=e((()=>{n(),G=t(E(),1),I(),R(),H(),g(),O(),i(),l(),y(),V(),b(),m(),B(),f(),j(),F(),z(),v(),_(),c(),s(),Oe(),W(),K=A()}));function Ne({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:a,borderless:o=!1}){let[s]=fe(),c=Ee(),l=ce(e=>e.mcp),ee=Te(),d=we(),[ne,f]=(0,q.useState)(!1),ie=q.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await d(e.name),i()}catch(n){a(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.name,d,i,a]),ae=Se(String(e.name)),m=re(l.commands,e.name).length,h=[];return e.client.type!==`disabled`&&t>0&&h.push({label:`View tools`,value:`tools`}),e.client.type!==`disabled`&&h.push({label:`Reconnect`,value:`reconnectMcpServer`}),h.push({label:e.client.type===`disabled`?`Enable`:`Disable`,value:`toggle-enabled`}),h.length===0&&h.push({label:`Back`,value:`back`}),ne?(0,J.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(w,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(w,{bold:!0,children:e.name})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(x,{}),(0,J.jsx)(w,{children:` Restarting MCP server process`})]}),(0,J.jsx)(w,{dimColor:!0,children:`This may take a few moments.`})]}):(0,J.jsxs)(C,{flexDirection:`column`,children:[(0,J.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:o?void 0:`round`,children:[(0,J.jsx)(C,{marginBottom:1,children:(0,J.jsxs)(w,{bold:!0,children:[ae,` MCP Server`]})}),(0,J.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,J.jsxs)(w,{children:[D(`inactive`,s)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,J.jsxs)(w,{children:[D(`success`,s)(r.tick),` connected`]}):e.client.type===`pending`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,J.jsx)(w,{children:` connecting…`})]}):(0,J.jsxs)(w,{children:[D(`error`,s)(r.cross),` failed`]})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Command: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Args: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Config location: `}),(0,J.jsx)(w,{dimColor:!0,children:se(p(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,J.jsx)(De,{serverToolsCount:t,serverPromptsCount:m,serverResourcesCount:l.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Tools: `}),(0,J.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),h.length>0&&(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(te,{options:h,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){f(!0);try{let{message:t}=ke(await ee(e.name),e.name);a?.(t)}catch(t){a?.(Ae(t,e.name))}finally{f(!1)}}else t===`toggle-enabled`?await ie():t===`back`&&i()},onCancel:i})})]}),(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(w,{dimColor:!0,italic:!0,children:c.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,c.keyName,` again to exit`]}):(0,J.jsxs)(T,{children:[(0,J.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var q,J,Y=e((()=>{n(),q=t(E(),1),H(),O(),o(),V(),b(),m(),j(),z(),v(),_(),c(),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,l=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)(w,{color:`success`,children:` [read-only]`}),c&&(0,Z.jsx)(w,{color:`error`,children:` [destructive]`}),l&&(0,Z.jsx)(w,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,Z.jsxs)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,Z.jsxs)(C,{flexDirection:`column`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Tool name: `}),(0,Z.jsx)(w,{dimColor:!0,children:a})]}),(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Full name: `}),(0,Z.jsx)(w,{dimColor:!0,children:e.name})]}),r&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Description:`}),(0,Z.jsx)(w,{wrap:`wrap`,children:r})]}),e.inputJSONSchema&&e.inputJSONSchema.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Parameters:`}),(0,Z.jsx)(C,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,Z.jsxs)(w,{children:[`• `,t,r&&(0,Z.jsx)(w,{dimColor:!0,children:` (required)`}),`:`,` `,(0,Z.jsx)(w,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,Z.jsxs)(w,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var X,Z,Fe=e((()=>{X=t(E(),1),O(),N(),v(),Z=A()}));function Ie({server:e,onSelectTool:t,onBack:n}){let r=ce(e=>e.mcp.tools),i=Le.useMemo(()=>e.client.type===`connected`?ne(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)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(T,{children:[(0,Q.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(u,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:i.length===0?(0,Q.jsx)(w,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(te,{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(),b(),m(),z(),v(),_(),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{Dx as a,Ew as o,Ex as s,Gv as c,Ha as l,Hp as u,Ia as d,Kv as f,Na as p,Qa as m,Ra as h,Rs as g,Vs as _,Vu as v,Wp as y,Wv as b,Zv as x,an as S,dd as C,el as w,eo as T,fd as E,il as D,io as O,lw as k,mn as A,nl as j,no as M,ov as ee,pw as te,sv as ne,sw as N,tl as re,uw as P,vn as ie,yo as F,zs as ae,zu as oe}from"./loadAgentsDir-CKSb56Gp.js";import{C as se,Gt as ce,I,P as L,Wt as le,fi as R,ot as ue,t as de}from"./src-P_wYS_NJ2.js";import{t as fe}from"./jsx-runtime-Bb4Xn-E0.js";import{Kt as z,ft as B,mt as pe,qn as V}from"./state-Bs5xweDL.js";import{n as me,t as he}from"./cwd-L4wygFqJ.js";import{In as ge,Ln as _e,Q as ve,Y as ye,f as be,g as xe}from"./settings-Xbq6AaD-.js";import{J as Se,h as Ce,m as we,o as Te,s as H,w as Ee}from"./log-CTFl4qpD.js";import{n as U,r as W}from"./analytics-DJobLaWP.js";import{b as De,m as Oe,v as ke}from"./startupProfiler-jeId9f2i.js";import{Bt as Ae,St as je,Y as Me,et as Ne}from"./model-C2e73CJD.js";import{E as Pe,T as Fe,c as Ie,d as Le,w as Re}from"./sessionTracing-ClGQ08jM.js";import{n as ze,t as Be}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import*as G from"path";import{randomUUID as K}from"crypto";R();var q=fe();r(),de(),z(),me(),Se(),we(),Te(),_e(),U(),ke(),ve(),xe(),Ae(),k(),s(),Re(),u(),Ie(),j(),w(),_(),F(),m(),ie();function Ve(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 He(e){let t=e.toLowerCase().trim();return t===`continue`||/\b(keep going|go on)\b/.test(t)}function Ue(e,t,n,r,i,a,o){let s=K();V(s);let c=typeof e==`string`?e:e.find(e=>e.type===`text`)?.text||``;Le(c);let l=typeof e==`string`?e:e.findLast(e=>e.type===`text`)?.text||``;return l&&Fe(`user_prompt`,{prompt_length:String(l.length),prompt:Pe(l),"prompt.id":s}),W(`tengu_input_prompt`,{is_negative:Ve(c),is_keep_going:He(c)}),t.length>0?{messages:[d({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:[d({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}U(),m();async function We({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:a,ideSelection:o,messages:s,setUserInputOnProcessing:c,uuid:u,isAlreadyProcessing:f,querySource:m,canUseTool:h,skipSlashCommands:_,bridgeOrigin:v,isMeta:y,skipAttachments:b,autonomy:x}){let C=typeof e==`string`?e:null,w=C?.startsWith(`/`)&&!_;n===`prompt`&&C!==null&&!y&&!w&&c?.(C),D(`query_process_user_input_base_start`);let T=i.getAppState(),E=await Ke(e,n,r,i,a,o,s,u,f,m,h,T.toolPermissionContext.mode,_,v,y,b,t,x);if(D(`query_process_user_input_base_end`),!E.shouldQuery)return E;D(`query_hooks_start`);let O=l(e)||``;for await(let t of S(O,T.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[p(`${A(t.blockingError)}\n\nOriginal prompt: ${e}`,`warning`)],shouldQuery:!1,allowedTools:E.allowedTools};if(t.preventContinuation){let e=t.stopReason?`Operation stopped by hook: ${t.stopReason}`:`Operation stopped by hook`;return E.messages.push(d({content:e})),E.shouldQuery=!1,E}if(t.additionalContexts&&t.additionalContexts.length>0&&E.messages.push(g({type:`hook_additional_context`,content:t.additionalContexts.map(Ge),hookName:`UserPromptSubmit`,toolUseID:`hook-${K()}`,hookEvent:`UserPromptSubmit`})),t.message)switch(t.message.attachment.type){case`hook_success`:if(!t.message.attachment.content)break;E.messages.push({...t.message,attachment:{...t.message.attachment,content:Ge(t.message.attachment.content)}});break;default:E.messages.push(t.message);break}}return D(`query_hooks_end`),E}var J=1e4;function Ge(e){return e.length>J?`${e.substring(0,J)}… [output truncated - exceeded ${J} characters]`:e}async function Ke(e,t,n,r,i,o,s,c,l,u,d,f,p,m,h,g,_,v){let b=null,x=[],S=[],C=e;if(typeof e==`string`)b=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 P(n);if(e.dimensions){let t=N(e.dimensions);t&&S.push(t)}t.push(e.block)}else t.push(n);C=t,D(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(b=n.text,x=t.slice(0,-1)):x=t}if(b===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let w=i?Object.values(i).filter(a):[],T=w.map(e=>e.id),E=i?await y(i):new Map;D(`query_pasted_image_processing_start`);let O=await Promise.all(w.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 P(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??E.get(e.id)}})),k=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of O){if(e.dimensions){let t=N(e.dimensions,n);t&&S.push(t)}else if(t){let e=N(t,n);e&&S.push(e)}else n&&S.push(`[Image source: ${n}]`);k.push(e.block)}D(`query_pasted_image_processing_end`);let A=p,j=!g&&b!==null&&(t!==`prompt`||A||!b.startsWith(`/`));D(`query_attachment_loading_start`);let M=j?await re(ae(b,r,o??null,[],s,u)):[];if(D(`query_attachment_loading_end`),b!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-CdeQg_c6.js`);return Y(await e(b,x,M,r,n),S)}if(b!==null&&!A&&b.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-CbkshIC6.js`);return Y(await e(b,x,k,M,r,n,c,l,d,v),S)}if(b!==null&&t===`prompt`){let e=b.trim(),t=M.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(Ue(C,k,T,M,c,f,h),S)}function Y(e,t){return t.length>0&&e.messages.push(d({content:t.map(e=>({type:`text`,text:e})),isMeta:!0})),e}z(),Ne();function qe(e){return e===`Agent`?ye:e}function Je(e){let t=be()?.outputStyle??`default`,n={type:`system`,subtype:`init`,cwd:he(),session_id:pe(),tools:e.tools.map(e=>qe(e.name)),mcp_servers:e.mcpClients.map(e=>({name:e.name,status:e.type})),model:e.model,permissionMode:e.permissionMode,slash_commands:e.commands.filter(e=>e.userInvocable!==!1).map(e=>e.name),apiKeySource:je().source,betas:B(),claude_code_version:`0.0.9`,output_style:t,agents:e.agents.map(e=>e.agentType),skills:e.skills.filter(e=>e.userInvocable!==!1).map(e=>e.name),plugins:e.plugins.map(e=>({name:e.name,path:e.path,source:e.source})),uuid:K()};return n.fast_mode_state=Me(e.model,e.fastMode),n}var Ye=n({MessageSelector:()=>Ze,messagesAfterAreOnlySynthetic:()=>it,selectableUserMessagesFilter:()=>Z});function Xe(e){return e.type===`text`}function X(e){return e===`summarize`}function Ze({messages:e,onPreRestore:t,onRestoreMessage:n,onRestoreCode:r,onSummarize:a,onClose:o,preselectedMessage:s}){let l=ne(e=>e.fileHistory),[u,p]=(0,Q.useState)(void 0),m=c(),h=(0,Q.useMemo)(K,[]),g=(0,Q.useMemo)(()=>[...e.filter(Z),{...d({content:``}),uuid:h}],[e,h]),[_,v]=(0,Q.useState)(g.length-1),y=Math.max(0,Math.min(_-Math.floor($/2),g.length-$)),x=g.length>1,[S,w]=(0,Q.useState)(s),[T,E]=(0,Q.useState)(void 0);(0,Q.useEffect)(()=>{if(!s||!m)return;let e=!1;return f(l,s.uuid).then(t=>{e||E(t)}),()=>{e=!0}},[s,m,l]);let[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(`both`),[ee,te]=(0,Q.useState)(``);function N(e){let t=e?[{value:`both`,label:`Restore code and conversation`},{value:`conversation`,label:`Restore conversation`},{value:`code`,label:`Restore code`}]:[{value:`conversation`,label:`Restore conversation`}];return t.push({value:`summarize`,label:`Summarize from here`,type:`input`,placeholder:`add context (optional)`,initialValue:``,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,onChange:te}),t.push({value:`nevermind`,label:`Never mind`}),t}(0,Q.useEffect)(()=>{W(`tengu_message_selector_opened`,{})},[]);async function re(e){t(),O(!0);try{await n(e),O(!1),o()}catch(e){H(e),O(!1),p(`Failed to restore the conversation:\n${e}`)}}async function P(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(!m){await re(t);return}let r=await f(l,t.uuid);w(t),E(r)}async function ie(e){if(W(`tengu_message_selector_restore_option_selected`,{option:e}),!S){p(`Message not found.`);return}if(e===`nevermind`){s?o():w(void 0);return}if(X(e)){t(),O(!0),A(e),p(void 0);try{let e=ee.trim()||void 0;await a(S,e,`from`),O(!1),A(null),w(void 0),o()}catch(e){H(e),O(!1),A(null),w(void 0),p(`Failed to summarize:\n${e}`)}return}t(),O(!0),p(void 0);let i=null,c=null;if(e===`code`||e===`both`)try{await r(S)}catch(e){i=e,H(i)}if(e===`conversation`||e===`both`)try{await n(S)}catch(e){c=e,H(c)}O(!1),w(void 0),c&&i?p(`Failed to restore the conversation and code:\n${c}\n${i}`):c?p(`Failed to restore the conversation:\n${c}`):i?p(`Failed to restore the code:\n${i}`):o()}let F=ze(),ae=(0,Q.useCallback)(()=>{if(S&&!s){w(void 0);return}W(`tengu_message_selector_cancelled`,{}),o()},[o,S,s]),R=(0,Q.useCallback)(()=>v(e=>Math.max(0,e-1)),[]),ue=(0,Q.useCallback)(()=>v(e=>Math.min(g.length-1,e+1)),[g.length]),de=(0,Q.useCallback)(()=>v(0),[]),fe=(0,Q.useCallback)(()=>v(g.length-1),[g.length]),z=(0,Q.useCallback)(()=>{let e=g[_];e&&P(e)},[g,_,P]);le(`confirm:no`,ae,{context:`Confirmation`,isActive:!S}),ce({"messageSelector:up":R,"messageSelector:down":ue,"messageSelector:top":de,"messageSelector:bottom":fe,"messageSelector:select":z},{context:`MessageSelector`,isActive:!D&&!u&&!S&&x});let[B,pe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{async function t(){m&&Promise.all(g.map(async(t,n)=>{if(t.uuid!==h){let r=b(l,t.uuid),i=g.at(n+1),a=r?rt(e,t.uuid,i?.uuid===h?void 0:i?.uuid):void 0;pe(a===void 0?e=>({...e,[n]:void 0}):e=>({...e,[n]:a}))}}))}t()},[g,e,h,l,m]);let V=m&&T?.filesChanged&&T.filesChanged.length>0,me=!u&&!S&&!s&&x;return(0,q.jsxs)(I,{flexDirection:`column`,width:`100%`,children:[(0,q.jsx)(se,{color:`suggestion`}),(0,q.jsxs)(I,{flexDirection:`column`,marginX:1,gap:1,children:[(0,q.jsx)(L,{bold:!0,color:`suggestion`,children:`Rewind`}),u&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(L,{color:`error`,children:[`Error: `,u]})}),!x&&(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(L,{children:`Nothing to rewind to yet.`})}),!u&&S&&x&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(L,{children:[`Confirm you want to restore `,!T&&`the conversation `,`to the point before you sent this message:`]}),(0,q.jsxs)(I,{flexDirection:`column`,paddingLeft:1,borderStyle:`single`,borderRight:!1,borderTop:!1,borderBottom:!1,borderLeft:!0,borderLeftDimColor:!0,children:[(0,q.jsx)(nt,{userMessage:S,color:`text`,isCurrent:!1}),(0,q.jsxs)(L,{dimColor:!0,children:[`(`,Oe(new Date(S.timestamp)),`)`]})]}),(0,q.jsx)($e,{selectedRestoreOption:j,canRestoreCode:!!V,diffStatsForRestore:T}),D&&X(k)?(0,q.jsxs)(I,{flexDirection:`row`,gap:1,children:[(0,q.jsx)(oe,{}),(0,q.jsx)(L,{children:`Summarizing…`})]}):(0,q.jsx)(C,{isDisabled:D,options:N(!!V),defaultFocusValue:V?`both`:`conversation`,onFocus:e=>M(e),onChange:e=>ie(e),onCancel:()=>s?o():w(void 0)}),V&&(0,q.jsx)(I,{marginBottom:1,children:(0,q.jsxs)(L,{dimColor:!0,children:[i.warning,` Rewinding does not affect files edited manually or via bash.`]})})]}),me&&(0,q.jsxs)(q.Fragment,{children:[m?(0,q.jsx)(L,{children:`Restore the code and/or conversation to the point before…`}):(0,q.jsx)(L,{children:`Restore and fork the conversation to the point before…`}),(0,q.jsx)(I,{width:`100%`,flexDirection:`column`,children:g.slice(y,y+$).map((e,t)=>{let n=y+t,r=n===_,a=e.uuid===h,o=n in B,s=B[n],c=s?.filesChanged&&s.filesChanged.length;return(0,q.jsxs)(I,{height:m?3:2,overflow:`hidden`,width:`100%`,flexDirection:`row`,children:[(0,q.jsx)(I,{width:2,minWidth:2,children:r?(0,q.jsxs)(L,{color:`permission`,bold:!0,children:[i.pointer,` `]}):(0,q.jsx)(L,{children:` `})}),(0,q.jsxs)(I,{flexDirection:`column`,children:[(0,q.jsx)(I,{flexShrink:1,height:1,overflow:`hidden`,children:(0,q.jsx)(nt,{userMessage:e,color:r?`suggestion`:void 0,isCurrent:a,paddingRight:10})}),m&&o&&(0,q.jsx)(I,{height:1,flexDirection:`row`,children:s?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(L,{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)(tt,{diffStats:s})]}):(0,q.jsx)(q.Fragment,{children:`No code changes`})})}):(0,q.jsxs)(L,{dimColor:!0,color:`warning`,children:[i.warning,` No code restore`]})})]})]},e.uuid)})})]}),!S&&(0,q.jsx)(L,{dimColor:!0,italic:!0,children:F.pending?(0,q.jsxs)(q.Fragment,{children:[`Press `,F.keyName,` again to exit`]}):(0,q.jsxs)(q.Fragment,{children:[!u&&x&&`Enter to continue · `,`Esc to exit`]})})]})]})}function Qe(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 $e({selectedRestoreOption:e,canRestoreCode:t,diffStatsForRestore:n}){let r=t&&(e===`both`||e===`code`);return(0,q.jsxs)(I,{flexDirection:`column`,children:[(0,q.jsx)(L,{dimColor:!0,children:Qe(e)}),!X(e)&&(r?(0,q.jsx)(et,{diffStatsForRestore:n}):(0,q.jsx)(L,{dimColor:!0,children:`The code will be unchanged.`}))]})}function et({diffStatsForRestore:e}){if(e===void 0)return;if(!e.filesChanged||!e.filesChanged[0])return(0,q.jsx)(L,{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)(L,{dimColor:!0,children:[`The code will be restored `,(0,q.jsx)(tt,{diffStats:e}),` in `,n,`.`]})})}function tt({diffStats:e}){if(!(!e||!e.filesChanged))return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(L,{color:`diffAddedWord`,children:[`+`,e.insertions,` `]}),(0,q.jsxs)(L,{color:`diffRemovedWord`,children:[`-`,e.deletions]})]})}function nt({userMessage:e,color:t,dimColor:n,isCurrent:r,paddingRight:i}){let{columns:a}=ue();if(r)return(0,q.jsx)(I,{width:`100%`,children:(0,q.jsx)(L,{italic:!0,color:t,dimColor:n,children:`(current)`})});let o=e.message.content,s=typeof o==`string`?null:o[o.length-1],c=Ce(typeof o==`string`?o.trim():s&&Xe(s)?s.text.trim():`(no prompt)`);if(T(c))return(0,q.jsx)(I,{flexDirection:`row`,width:`100%`,children:(0,q.jsx)(L,{italic:!0,color:t,dimColor:n,children:`((empty message))`})});if(c.includes(`<bash-input>`)){let e=h(c,`bash-input`);if(e)return(0,q.jsxs)(I,{flexDirection:`row`,width:`100%`,children:[(0,q.jsx)(L,{color:`bashBorder`,children:`!`}),(0,q.jsxs)(L,{color:t,dimColor:n,children:[` `,e]})]})}if(c.includes(`<command-message>`)){let e=h(c,Ee),r=h(c,`command-args`),i=h(c,`skill-format`)===`true`;if(e)return i?(0,q.jsx)(I,{flexDirection:`row`,width:`100%`,children:(0,q.jsxs)(L,{color:t,dimColor:n,children:[`Skill(`,e,`)`]})}):(0,q.jsx)(I,{flexDirection:`row`,width:`100%`,children:(0,q.jsxs)(L,{color:t,dimColor:n,children:[`/`,e,` `,r]})})}return(0,q.jsx)(I,{flexDirection:`row`,width:`100%`,children:(0,q.jsx)(L,{color:t,dimColor:n,children:i?De(c,a-i,!0):c.slice(0,500).split(`
2
- `).slice(0,4).join(`
3
- `)})})}function rt(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||!O(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=ge(e.lines,e=>e.startsWith(`+`)),n=ge(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`||M(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&&Xe(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 it(e,t){for(let n=t+1;n<e.length;n++){let t=e[n];if(t&&!M(t)&&!O(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,$,at=e((()=>{Q=t(R(),1),U(),ee(),x(),Be(),o(),m(),E(),v(),te(),$=7}));export{Z as a,We as c,it as i,Ye as n,Je as o,at as r,qe as s,Ze as t};